diff --git a/Balancing/BalancingChangesManager.cs b/Balancing/BalancingChangesManager.cs index 3502b3f91e..1f1eaa0022 100644 --- a/Balancing/BalancingChangesManager.cs +++ b/Balancing/BalancingChangesManager.cs @@ -21,6 +21,7 @@ using Terraria.ID; using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; using CalamityMod.NPCs.ProfanedGuardians; +using CalamityMod.NPCs.Yharon; namespace CalamityMod.Balancing { @@ -63,8 +64,8 @@ namespace CalamityMod.Balancing // Nerf Luminite Arrow trails by 50%. Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.MoonlordArrowTrail)), - // Nerf Seedler seeds by 66.6%. - Do(new ProjectileResistBalancingRule(1f / 3f, ProjectileID.SeedlerNut, ProjectileID.SeedlerThorn)), + // Nerf Seedler seeds by 25%. + Do(new ProjectileResistBalancingRule(0.75f, ProjectileID.SeedlerNut, ProjectileID.SeedlerThorn)), // Nerf Cursed Dart flames by 50%. Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.CursedDartFlame)), @@ -136,12 +137,15 @@ namespace CalamityMod.Balancing // 40% resist to Cryophobia. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new ProjectileResistBalancingRule(0.6f, ProjectileType())))); + // 20% resist to Mineral Mortar's Projectile. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); + // 15% resist to Snowstorm Staff. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new ProjectileResistBalancingRule(0.85f, ProjectileType())))); #endregion #region Astrum Aureus - //35% resist to The Ballista's greatarrows. + // 35% resist to The Ballista's greatarrows. NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), Do(new ProjectileResistBalancingRule(0.65f, ProjectileType())))); #endregion @@ -160,8 +164,8 @@ namespace CalamityMod.Balancing #endregion #region Empress of Light - // 30% resist to Plague Tainted SMG's drones. - NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCID.HallowBoss, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType())))); + // 20% resist to Plague Tainted SMG's drones. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCID.HallowBoss, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); #endregion #region Lunatic Cultist @@ -184,11 +188,17 @@ namespace CalamityMod.Balancing // 25% resist to Resurrection Butterfly. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AstrumDeusIDs, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType(), ProjectileType())))); + + // 70% resist to the Stardust Dragon. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AstrumDeusIDs, Do(new ProjectileResistBalancingRule(0.3f, ProjectileID.StardustDragon1, ProjectileID.StardustDragon2, ProjectileID.StardustDragon3, ProjectileID.StardustDragon4)))); #endregion #region Moon Lord // 90% resist to Mercurial Tides (True Biome Blade). NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCID.MoonLordCore, Do(new ProjectileResistBalancingRule(0.1f, ProjectileType(), ProjectileType(), ProjectileType())))); + + // 15% resist to Pestilent Defiler. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCID.MoonLordCore, Do(new ProjectileResistBalancingRule(0.85f, ProjectileType(), ProjectileType())))); #endregion #region Profaned Guardians @@ -236,17 +246,19 @@ namespace CalamityMod.Balancing #endregion #region The Devourer of Gods + // 50% resist to Eidolic Wail. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DevourerOfGodsIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + + // 35% resist to Venusian Trident's explosions. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DevourerOfGodsIDs, Do(new ProjectileResistBalancingRule(0.65f, ProjectileType(), ProjectileType())))); + // 15% vulnerability to Time Bolt stealth strikes. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DevourerOfGodsIDs, Do(new StealthStrikeBalancingRule(1.15f, ProjectileType())))); #endregion The Devourer of Gods #region Yharon // 15% resist to Time Bolt. - NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AresIDs, Do(new ProjectileResistBalancingRule(0.85f, ProjectileType())))); - - // 10% resist to Old Reaper. - NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AresIDs, Do(new ProjectileResistBalancingRule(0.9f, ProjectileType())))); - + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), Do(new ProjectileResistBalancingRule(0.85f, ProjectileType())))); #endregion #region Exo Mechs: Ares @@ -256,14 +268,11 @@ namespace CalamityMod.Balancing // 30% resist to Dynamic Pursuer. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AresIDs, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType(), ProjectileType(), ProjectileType())))); - // 30% resist to the Spin Throw part of the Ark of the Cosmos' combo. - NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AresIDs, Do(new ProjectileSpecificRequirementBalancingRule(0.7f, AotCThrowCombo)))); - // 25% resist to Aetherflux Cannon. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AresIDs, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType())))); - - // 25% resist to Murasama. - NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AresIDs, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType())))); + + // 20% resist to the Spin Throw part of the Ark of the Cosmos' combo. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AresIDs, Do(new ProjectileSpecificRequirementBalancingRule(0.8f, AotCThrowCombo)))); // 20% resist to Dragon Rage projectiles. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AresIDs, Do(new ProjectileSpecificRequirementBalancingRule(0.8f, DragonRageFilter)))); @@ -279,6 +288,9 @@ namespace CalamityMod.Balancing // 15% resist to Enforcer projectiles. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AresIDs, Do(new ProjectileResistBalancingRule(0.85f, ProjectileType())))); + + // 15% resist to Murasama. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AresIDs, Do(new ProjectileResistBalancingRule(0.85f, ProjectileType())))); #endregion #region Exo Mechs: Artemis and Apollo @@ -286,14 +298,8 @@ namespace CalamityMod.Balancing // TODO -- NPC sets (mostly worm bosses) should probably be their own holding class. int[] exoTwins = new int[] { NPCType(), NPCType() }; - // 20% resist to Dynamic Pursuer. - NPCSpecificBalancingChanges.AddRange(Bundle(exoTwins, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType(), ProjectileType(), ProjectileType())))); - // 10% resist to Eclipse's Fall stealth strike. NPCSpecificBalancingChanges.AddRange(Bundle(exoTwins, Do(new ProjectileResistBalancingRule(0.9f, ProjectileType())))); - - // 10% resist to Seared Pan. - NPCSpecificBalancingChanges.AddRange(Bundle(exoTwins, Do(new ProjectileResistBalancingRule(0.9f, ProjectileType(), ProjectileType(), ProjectileType())))); #endregion #region Exo Mechs: Thanatos @@ -303,12 +309,12 @@ namespace CalamityMod.Balancing // 65% resist to Enforcer projectiles. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.35f, ProjectileType())))); - // 65% resist to Dynamic Pursuer. (Do 40% if lightning pierce is removed) - NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.35f, ProjectileType(), ProjectileType(), ProjectileType())))); - // 65% resist to Final Dawn lunge. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.35f, ProjectileType())))); + // 60% resist to Dynamic Pursuer. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.4f, ProjectileType(), ProjectileType(), ProjectileType())))); + // 50% resist to Chicken Cannon. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); @@ -318,24 +324,24 @@ namespace CalamityMod.Balancing // 50% resist to Vehemence skulls. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType(), ProjectileType())))); - // 50% resist to Wrathwing stealth strike. - NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); - // 50% resist to Yharim's Crystal. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + // 45% resist to Wrathwing stealth strike's fireballs. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.55f, ProjectileType())))); + // 40% resist to Rancor. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.6f, ProjectileType())))); // 35% resist to Anomaly's Nanogun bomb explosions. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.65f, ProjectileType())))); - // 30% resist to the Spin Throw part of the Ark of the Cosmos' combo. - NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileSpecificRequirementBalancingRule(0.7f, AotCThrowCombo)))); - // 30% resist to Eclipse Fall. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType())))); + // 30% resist to Prismatic Breaker's laser beam. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType())))); + // 30% resist to Pulse Rifle. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType())))); @@ -345,8 +351,8 @@ namespace CalamityMod.Balancing // 30% resist to Dragon Scales and The Wand's tornadoes NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType(), ProjectileType())))); - // 30% resist to Prismatic Breaker's laser beam. - NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType())))); + // 25% resist to the Spin Throw part of the Ark of the Cosmos' combo. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileSpecificRequirementBalancingRule(0.75f, AotCThrowCombo)))); // 25% resist to Dragon Rage projectiles. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileSpecificRequirementBalancingRule(0.75f, DragonRageFilter)))); @@ -354,12 +360,6 @@ namespace CalamityMod.Balancing // 25% resist to Gael's Greatsword's big skulls. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileSpecificRequirementBalancingRule(0.75f, BigGaelsSkullFilter)))); - // 25% resist to Godslayer Slugs. - NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType())))); - - // 25% resist to Luminite Bullets. - NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.75f, ProjectileID.MoonlordBullet)))); - // 25% resist to Zenith. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.75f, ProjectileID.FinalFractal)))); @@ -369,18 +369,23 @@ namespace CalamityMod.Balancing // 20% resist to Eradicator beams. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); + // 20% resist to Plasma Grenade and Dynamic Pursuer's explosions + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType(),ProjectileType(), ProjectileType())))); + // 20% resist to Voltaic Climax / Void Vortex hitscan beams. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); - // 20% resist to Plasma grenades and Dynamic Pursuer's explosions - NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType(),ProjectileType(), ProjectileType())))); - // 15% resist to Final Dawn AoE sweep flames. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.85f, ProjectileType())))); + // 15% resist to Godslayer Slugs. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.85f, ProjectileType())))); + // 15% resist to Gruesome Eminence. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.85f, ProjectileType())))); + // 15% resist to Luminite Bullets. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.85f, ProjectileID.MoonlordBullet)))); #endregion #region Supreme Calamitas: Brimstone Hearts @@ -398,23 +403,20 @@ namespace CalamityMod.Balancing // 50% resist to Subsuming Vortex. NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.5f, ProjectileType(), ProjectileType(), ProjectileType()))); - // 30% resist to Murasama. - NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.7f, ProjectileType()))); - // 30% resist to Zenith. NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.7f, ProjectileID.FinalFractal))); // 25% resist to Yharim's Crystal. NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.75f, ProjectileType()))); - // 10% resist to Surge Driver's alt click comets. - NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.9f, ProjectileType()))); + // 10% resist to Celestus. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.9f, ProjectileType(), ProjectileType()))); // 10% resist to Executioner's Blade stealth strikes. NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.9f, ProjectileType()))); - - // 10% resist to Celestus. - NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.9f, ProjectileType(), ProjectileType()))); + + // 10% resist to Surge Driver's alt click comets. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.9f, ProjectileType()))); // 15% vulnerability to The Atom Splitter. (Yes, this is kinda weird, but it's what Piky asked for). NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(1.15f, ProjectileType(), ProjectileType()))); diff --git a/Balancing/BalancingConstants.cs b/Balancing/BalancingConstants.cs index 955416882c..f23d2281f1 100644 --- a/Balancing/BalancingConstants.cs +++ b/Balancing/BalancingConstants.cs @@ -59,7 +59,11 @@ // Rogue stealth // If stealth is too weak, increase this number. If stealth is too strong, decrease this number. // This value is intentionally not readonly. - public static double UniversalStealthStrikeDamageFactor = 0.5; + public static double UniversalStealthStrikeDamageFactor = 0.42; + // Shade 23/10/2023: So stealth apparently was indeed way too strong after the bugfix with nearly every weapon being way stronger than before + // due to Flawless now working properly and thus the stealth factor was changed back to 0.42 from 0.5. + // This nerf takes feedback from various players as well as my own personal experience with testing rogue stuff today; it feels too strong and + // something needed to be done about it. internal static readonly float BaseStealthGenTime = 4f; // 4 seconds internal static readonly float MovingStealthGenRatio = 0.5f; @@ -93,6 +97,26 @@ internal static readonly float MinimumAllowedAttackSpeed = 0.25f; internal static readonly float MaximumAllowedAttackSpeed = 10f; + // Defense Damage + internal const double DefaultDefenseDamageRatio = 0.3333; + + // Defense damage floor: PHM | HM | PML + // + // Normal/Expert: 3 | 8 | 16 + // Revengeance: 4 | 10 | 20 + // Death Mode: 5 | 12 | 24 + // Boss Rush: 25 + internal static readonly int DefenseDamageFloor_NormalPHM = 3; + internal static readonly int DefenseDamageFloor_NormalHM = 8; + internal static readonly int DefenseDamageFloor_NormalPML = 16; + internal static readonly int DefenseDamageFloor_RevPHM = 4; + internal static readonly int DefenseDamageFloor_RevHM = 10; + internal static readonly int DefenseDamageFloor_RevPML = 20; + internal static readonly int DefenseDamageFloor_DeathPHM = 5; + internal static readonly int DefenseDamageFloor_DeathHM = 12; + internal static readonly int DefenseDamageFloor_DeathPML = 24; + internal static readonly int DefenseDamageFloor_BossRush = 25; + // TODO -- Add all balance related constants here that don't belong in other files. // Review all constants and static readonlys in the entire mod to find things to add. } diff --git a/Buffs/Alcohol/BloodyMaryBuff.png b/Buffs/Alcohol/BloodyMaryBuff.png index 04b959506c..46cf3a0b57 100644 Binary files a/Buffs/Alcohol/BloodyMaryBuff.png and b/Buffs/Alcohol/BloodyMaryBuff.png differ diff --git a/Buffs/Alcohol/CinnamonRollBuff.png b/Buffs/Alcohol/CinnamonRollBuff.png index 075531eacc..8d9ff66e26 100644 Binary files a/Buffs/Alcohol/CinnamonRollBuff.png and b/Buffs/Alcohol/CinnamonRollBuff.png differ diff --git a/Buffs/Alcohol/FireballBuff.png b/Buffs/Alcohol/FireballBuff.png index 7ee9784312..8887354d3f 100644 Binary files a/Buffs/Alcohol/FireballBuff.png and b/Buffs/Alcohol/FireballBuff.png differ diff --git a/Buffs/Alcohol/MoscowMuleBuff.png b/Buffs/Alcohol/MoscowMuleBuff.png index 969367e33f..4ba5245776 100644 Binary files a/Buffs/Alcohol/MoscowMuleBuff.png and b/Buffs/Alcohol/MoscowMuleBuff.png differ diff --git a/Buffs/Alcohol/OldFashionedBuff.cs b/Buffs/Alcohol/OldFashionedBuff.cs new file mode 100644 index 0000000000..1f059a26d5 --- /dev/null +++ b/Buffs/Alcohol/OldFashionedBuff.cs @@ -0,0 +1,22 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Alcohol +{ + public class OldFashionedBuff : ModBuff + { + public override void SetStaticDefaults() + { + Main.debuff[Type] = true; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = false; + BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().oldFashioned = true; + } + } +} diff --git a/Buffs/Alcohol/OldFashionedBuff.png b/Buffs/Alcohol/OldFashionedBuff.png new file mode 100644 index 0000000000..2b6e8fdaf0 Binary files /dev/null and b/Buffs/Alcohol/OldFashionedBuff.png differ diff --git a/Buffs/Alcohol/ScrewdriverBuff.png b/Buffs/Alcohol/ScrewdriverBuff.png index 868d695c58..2c0984bc98 100644 Binary files a/Buffs/Alcohol/ScrewdriverBuff.png and b/Buffs/Alcohol/ScrewdriverBuff.png differ diff --git a/Buffs/Alcohol/TequilaBuff.png b/Buffs/Alcohol/TequilaBuff.png index ca3a7b204e..a6c233e3d1 100644 Binary files a/Buffs/Alcohol/TequilaBuff.png and b/Buffs/Alcohol/TequilaBuff.png differ diff --git a/Buffs/Alcohol/TequilaSunriseBuff.png b/Buffs/Alcohol/TequilaSunriseBuff.png index 04c3901caf..ef5bee8678 100644 Binary files a/Buffs/Alcohol/TequilaSunriseBuff.png and b/Buffs/Alcohol/TequilaSunriseBuff.png differ diff --git a/Buffs/Alcohol/Trippy.png b/Buffs/Alcohol/Trippy.png index 641781ec77..7efc1b9c5d 100644 Binary files a/Buffs/Alcohol/Trippy.png and b/Buffs/Alcohol/Trippy.png differ diff --git a/Buffs/Alcohol/VodkaBuff.png b/Buffs/Alcohol/VodkaBuff.png index b2c2eb1496..485745f805 100644 Binary files a/Buffs/Alcohol/VodkaBuff.png and b/Buffs/Alcohol/VodkaBuff.png differ diff --git a/Buffs/DamageOverTime/ElementalMix.cs b/Buffs/DamageOverTime/ElementalMix.cs new file mode 100644 index 0000000000..d206bffc57 --- /dev/null +++ b/Buffs/DamageOverTime/ElementalMix.cs @@ -0,0 +1,102 @@ +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.DamageOverTime +{ + public class ElementalMix : ModBuff + { + public override void SetStaticDefaults() + { + Main.debuff[Type] = true; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = true; + BuffID.Sets.LongerExpertDebuff[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().elementalMix = true; + } + + public override void Update(NPC npc, ref int buffIndex) + { + if (npc.Calamity().elementalMix < npc.buffTime[buffIndex]) + npc.Calamity().elementalMix = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; + } + + internal static void DrawEffects(PlayerDrawSet drawInfo) + { + Player player = drawInfo.drawPlayer; + var modPlayer = player.Calamity(); + var effectcolor = Main.rand.Next(4) switch + { + 0 => Color.DeepSkyBlue, + 1 => Color.MediumSpringGreen, + 2 => Color.DarkOrange, + _ => Color.Violet, + }; + Vector2 speed = new Vector2(Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(-2.5f, -8.3f)); + + GeneralParticleHandler.SpawnParticle(new TechyHoloysquareParticle(player.Calamity().RandomDebuffVisualSpot, speed, Main.rand.NextFloat(1.2f, 1.8f), effectcolor, Main.rand.Next(8, 14))); + + int dustType = Main.rand.NextBool() ? 66 : 247; + Dust dust = Dust.NewDustPerfect(player.Calamity().RandomDebuffVisualSpot, dustType); + dust.scale = (dustType == 66 ? 1.4f : 1.2f); + dust.velocity = Vector2.Zero + new Vector2(Main.rand.NextFloat(-1, 1), Main.rand.NextFloat(4f, 8f)) - player.velocity / 2; + dust.noGravity = true; + dust.alpha = Main.rand.Next(90, 150); + dust.color = effectcolor; + } + + internal static void DrawEffects(NPC npc, ref Color drawColor) + { + if (Main.rand.NextBool()) + { + var effectcolor = Main.rand.Next(4) switch + { + 0 => Color.DeepSkyBlue, + 1 => Color.MediumSpringGreen, + 2 => Color.DarkOrange, + _ => Color.Violet, + }; + Vector2 npcSize = npc.Center + new Vector2(Main.rand.NextFloat(-npc.width / 2, npc.width / 2), Main.rand.NextFloat(-npc.height / 2, npc.height / 2)); + Vector2 speed = new Vector2(Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(-2.5f, -8.3f)); + + GeneralParticleHandler.SpawnParticle(new TechyHoloysquareParticle(npcSize, speed, Main.rand.NextFloat(1.2f, 3.1f), effectcolor, Main.rand.Next(8, 14))); + + int dustType = Main.rand.NextBool() ? 66 : 247; + Dust dust = Dust.NewDustPerfect(npcSize, dustType); + dust.scale = (dustType == 66 ? 1.4f : 1.2f); + dust.noGravity = true; + dust.velocity = Vector2.Zero + new Vector2(Main.rand.NextFloat(-2, 2), Main.rand.NextFloat(2f, 4f)) - npc.velocity / 2; + dust.alpha = Main.rand.Next(90, 150); + dust.color = effectcolor; + } + if (Main.rand.NextBool(5)) + { + var effectcolor = Main.rand.Next(4) switch + { + 0 => Color.DeepSkyBlue, + 1 => Color.MediumSpringGreen, + 2 => Color.DarkOrange, + _ => Color.Violet, + }; + Vector2 npcSize = npc.Center + new Vector2(Main.rand.NextFloat(-npc.width / 2, npc.width / 2), Main.rand.NextFloat(-npc.height / 2, npc.height / 2)); + int dustType = Main.rand.NextBool() ? 66 : 247; + Dust dust = Dust.NewDustPerfect(npcSize, dustType); + dust.scale = (dustType == 66 ? 0.9f : 1.4f); + dust.noGravity = true; + dust.velocity = Vector2.Zero + new Vector2(Main.rand.NextFloat(-2, 2), Main.rand.NextFloat(2f, 4f)); + dust.alpha = Main.rand.Next(35, 90); + dust.color = effectcolor; + } + } + } +} diff --git a/Buffs/DamageOverTime/ElementalMix.png b/Buffs/DamageOverTime/ElementalMix.png new file mode 100644 index 0000000000..cc0be9283f Binary files /dev/null and b/Buffs/DamageOverTime/ElementalMix.png differ diff --git a/Buffs/DamageOverTime/MiracleBlight.cs b/Buffs/DamageOverTime/MiracleBlight.cs index f295731167..1fee9f02c9 100644 --- a/Buffs/DamageOverTime/MiracleBlight.cs +++ b/Buffs/DamageOverTime/MiracleBlight.cs @@ -36,37 +36,29 @@ namespace CalamityMod.Buffs.DamageOverTime var sparkColor = Main.rand.Next(4) switch { - 0 => Color.DarkRed, + 0 => Color.Red, 1 => Color.MediumTurquoise, 2 => Color.Orange, _ => Color.LawnGreen, }; - DirectionalPulseRing pulse = new DirectionalPulseRing(Player.Calamity().RandomDebuffVisualSpot, Vector2.Zero, sparkColor, new Vector2(1, 1), 0, Main.rand.NextFloat(0.09f, 0.17f), 0f, 25); - GeneralParticleHandler.SpawnParticle(pulse); - float numberOfDusts = 3f; - float rotFactor = 360f / numberOfDusts; - if (Player.miscCounter % 4 == 0) + if (Main.rand.NextBool(2)) { - for (int i = 0; i < numberOfDusts; i++) - { - var DustType = Main.rand.Next(4) switch - { - 0 => 219, - 1 => 220, - 2 => 226, - _ => 222, - }; - float rot = MathHelper.ToRadians(i * rotFactor); - Vector2 offset = new Vector2(0.3f, 0).RotatedBy(rot * Main.rand.NextFloat(0.2f, 0.3f)); - Vector2 velOffset = CalamityUtils.RandomVelocity(100f, 70f, 150f, 0.04f); - Dust dust = Dust.NewDustPerfect(Player.Calamity().RandomDebuffVisualSpot + offset, DustType, new Vector2(velOffset.X, velOffset.Y)); - dust.noGravity = true; - dust.velocity = velOffset; - velOffset *= 10; - dust.position = Player.Center - velOffset; - dust.scale = Main.rand.NextFloat(0.7f, 0.8f); - } + Dust dust = Dust.NewDustPerfect(Player.Calamity().RandomDebuffVisualSpot, 278, CalamityUtils.RandomVelocity(100f, 70f, 150f, 0.04f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.7f, 0.85f); + dust.color = sparkColor * 0.45f; + } + + float numberOfDusts = 1f; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) + { + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 velOffset = CalamityUtils.RandomVelocity(100f, 70f, 150f, 0.04f); + velOffset *= Main.rand.NextFloat(2, 13); + SquishyLightParticle exoEnergy = new(Player.Center + Player.velocity * 3 + velOffset * 1.5f, -velOffset * 0.25f, 0.3f, sparkColor, 8); + GeneralParticleHandler.SpawnParticle(exoEnergy); } } @@ -75,36 +67,31 @@ 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)); var sparkColor = Main.rand.Next(4) switch { - 0 => Color.DarkRed, + 0 => Color.Red, 1 => Color.MediumTurquoise, 2 => Color.Orange, _ => Color.LawnGreen, }; - DirectionalPulseRing pulse = new DirectionalPulseRing(npcSize, Vector2.Zero, sparkColor, new Vector2(1, 1), 0, 0.18f + (0.0000007f * npc.width * npc.height), 0f, 25); - GeneralParticleHandler.SpawnParticle(pulse); - float numberOfDusts = 2f; - float rotFactor = 360f / numberOfDusts; if (Main.rand.NextBool(3)) + { + Dust dust = Dust.NewDustPerfect(npcSize, 278, CalamityUtils.RandomVelocity(100f, 70f, 150f, 0.04f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.7f, 0.85f) + (0.0000007f * npc.width * npc.height); + dust.color = sparkColor * 0.45f; + } + + float numberOfDusts = 1f; + float rotFactor = 360f / numberOfDusts; + if (Main.rand.NextBool()) { for (int i = 0; i < numberOfDusts; i++) { - var DustType = Main.rand.Next(4) switch - { - 0 => 219, - 1 => 220, - 2 => 226, - _ => 222, - }; float rot = MathHelper.ToRadians(i * rotFactor); - Vector2 offset = new Vector2(0.3f, 0).RotatedBy(rot * Main.rand.NextFloat(0.2f, 0.3f)); Vector2 velOffset = CalamityUtils.RandomVelocity(100f, 70f, 150f, 0.04f); - Dust dust = Dust.NewDustPerfect(npc.Center + offset, DustType, new Vector2(velOffset.X, velOffset.Y)); - dust.noGravity = true; - dust.velocity = velOffset; - velOffset *= 10 + (0.0003f * npc.width * npc.height); - dust.position = npc.Center - velOffset; - dust.scale = Main.rand.NextFloat(0.7f, 0.8f); + velOffset *= Main.rand.NextFloat(1, 9) + (0.0002f * npc.width * npc.height); + SquishyLightParticle exoEnergy = new(npc.Center + npc.velocity * 3 + velOffset * 1.5f, -velOffset * 0.25f, 0.3f, sparkColor, 8); + GeneralParticleHandler.SpawnParticle(exoEnergy); } } } diff --git a/Buffs/Placeables/CirrusBlueCandleBuff.png b/Buffs/Placeables/CirrusBlueCandleBuff.png index 49bd55dfe6..a73721ff8f 100644 Binary files a/Buffs/Placeables/CirrusBlueCandleBuff.png and b/Buffs/Placeables/CirrusBlueCandleBuff.png differ diff --git a/Buffs/Placeables/CirrusPinkCandleBuff.png b/Buffs/Placeables/CirrusPinkCandleBuff.png index 93720eb840..c299a08857 100644 Binary files a/Buffs/Placeables/CirrusPinkCandleBuff.png and b/Buffs/Placeables/CirrusPinkCandleBuff.png differ diff --git a/Buffs/Placeables/CirrusPurpleCandleBuff.png b/Buffs/Placeables/CirrusPurpleCandleBuff.png index b0eccec1a3..3ff18f000a 100644 Binary files a/Buffs/Placeables/CirrusPurpleCandleBuff.png and b/Buffs/Placeables/CirrusPurpleCandleBuff.png differ diff --git a/Buffs/Placeables/CirrusYellowCandleBuff.png b/Buffs/Placeables/CirrusYellowCandleBuff.png index 691d19958d..2ac39e16dd 100644 Binary files a/Buffs/Placeables/CirrusYellowCandleBuff.png and b/Buffs/Placeables/CirrusYellowCandleBuff.png differ diff --git a/Buffs/Potions/Zerg.png b/Buffs/Potions/Zerg.png index 70410f5d48..6aebf745ce 100644 Binary files a/Buffs/Potions/Zerg.png and b/Buffs/Potions/Zerg.png differ diff --git a/Buffs/StatBuffs/BloodyBoost.png b/Buffs/StatBuffs/BloodyBoost.png deleted file mode 100644 index 020e7e63c1..0000000000 Binary files a/Buffs/StatBuffs/BloodyBoost.png and /dev/null differ diff --git a/Buffs/StatBuffs/BloodyBoost.cs b/Buffs/StatBuffs/BrutalCarnage.cs similarity index 80% rename from Buffs/StatBuffs/BloodyBoost.cs rename to Buffs/StatBuffs/BrutalCarnage.cs index a00c7b3cb5..8479469036 100644 --- a/Buffs/StatBuffs/BloodyBoost.cs +++ b/Buffs/StatBuffs/BrutalCarnage.cs @@ -3,7 +3,7 @@ using Terraria.ModLoader; namespace CalamityMod.Buffs.StatBuffs { - public class BloodyBoost : ModBuff + public class BrutalCarnage : ModBuff { public override void SetStaticDefaults() { @@ -14,7 +14,7 @@ namespace CalamityMod.Buffs.StatBuffs public override void Update(Player player, ref int buffIndex) { - player.Calamity().bloodPactBoost = true; + player.Calamity().brutalCarnage = true; } } } diff --git a/Buffs/StatBuffs/TyrantsFury.png b/Buffs/StatBuffs/BrutalCarnage.png similarity index 100% rename from Buffs/StatBuffs/TyrantsFury.png rename to Buffs/StatBuffs/BrutalCarnage.png diff --git a/Buffs/StatBuffs/ShellBoost.cs b/Buffs/StatBuffs/ShellBoost.cs deleted file mode 100644 index 020cf4cfc6..0000000000 --- a/Buffs/StatBuffs/ShellBoost.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.StatBuffs -{ - public class ShellBoost : ModBuff - { - public override void SetStaticDefaults() - { - Main.debuff[Type] = false; - Main.pvpBuff[Type] = true; - Main.buffNoSave[Type] = true; - } - - public override void Update(Player player, ref int buffIndex) - { - player.Calamity().shellBoost = true; - } - } -} diff --git a/Buffs/StatBuffs/ShellBoost.png b/Buffs/StatBuffs/ShellBoost.png deleted file mode 100644 index 72926348cd..0000000000 Binary files a/Buffs/StatBuffs/ShellBoost.png and /dev/null differ diff --git a/Buffs/StatBuffs/TyrantsFury.cs b/Buffs/StatBuffs/TyrantsFury.cs deleted file mode 100644 index 3f5056cb03..0000000000 --- a/Buffs/StatBuffs/TyrantsFury.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.StatBuffs -{ - public class TyrantsFury : ModBuff - { - public override void SetStaticDefaults() - { - Main.debuff[Type] = false; - Main.pvpBuff[Type] = true; - Main.buffNoSave[Type] = true; - } - - public override void Update(Player player, ref int buffIndex) - { - player.Calamity().tFury = true; - } - } -} diff --git a/Buffs/Summon/BrittleStar.png b/Buffs/Summon/BrittleStar.png index edb678d19b..30f00daabc 100644 Binary files a/Buffs/Summon/BrittleStar.png and b/Buffs/Summon/BrittleStar.png differ diff --git a/Buffs/Summon/IceClasperBuff.cs b/Buffs/Summon/IceClasperBuff.cs index 08a56cc4f1..d7c5d328a7 100644 --- a/Buffs/Summon/IceClasperBuff.cs +++ b/Buffs/Summon/IceClasperBuff.cs @@ -19,9 +19,9 @@ namespace CalamityMod.Buffs.Summon CalamityPlayer modPlayer = player.Calamity(); if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) { - modPlayer.iClasper = true; + modPlayer.IceClasperBool = true; } - if (!modPlayer.iClasper) + if (!modPlayer.IceClasperBool) { player.DelBuff(buffIndex); buffIndex--; diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 420de15706..885e58a505 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -26,6 +26,7 @@ using CalamityMod.Items.Dyes; using CalamityMod.Items.Mounts; using CalamityMod.Items.Mounts.Minecarts; using CalamityMod.Items.PermanentBoosters; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Items.TreasureBags.MiscGrabBags; using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.Items.Weapons.DraedonsArsenal; @@ -97,7 +98,7 @@ namespace CalamityMod.CalPlayer public bool reducedHolyFlamesDamage = false; public bool reducedNightwitherDamage = false; public float rangedAmmoCost = 1f; - public float healingPotBonus = 1f; + public float healingPotionMultiplier = 1f; public bool heldGaelsLastFrame = false; internal bool hadNanomachinesLastFrame = false; public bool disableVoodooSpawns = false; @@ -178,12 +179,20 @@ namespace CalamityMod.CalPlayer #region Timer and Counter public int gaelSwipes = 0; + public int dragoonDrizzlefishGelBoost = 1; + public int deadSunCounter = 6; + public int DragonsBreathAudioCooldown = 0; + public int DragonsBreathAudioCooldown2 = 0; + public int PhotoAudioCooldown = 0; + public int PhotoTimer = 90; + public bool brittleStarBuffMode = false; public bool sBlasterDashActivated = false; + public int saharaSlicersBolts = 0; + public int oceanCrestTimer = 0; public int Holyhammer = 0; public int PHAThammer = 0; public int StellarHammer = 0; public int GalaxyHammer = 0; - public int gaelRageAttackCooldown = 0; public int hideOfDeusMeleeBoostTimer = 0; public int nebulaManaNerfCounter = 0; public int alcoholPoisonLevel = 0; @@ -216,12 +225,14 @@ namespace CalamityMod.CalPlayer public int auralisAurora = 0; public int necroReviveCounter = -1; public int hideOfDeusTimer = 0; + public int murasamaHitCooldown = 0; public int giantShellPostHit = 0; public int tortShellPostHit = 0; public int spiritOriginBullseyeShootCountdown = 0; public int spiritOriginConvertedCrit = 0; public int RustyMedallionCooldown = 0; public float SulphWaterPoisoningLevel; + public float holyInfernoFadeIntensity; public NPC unstableSelectedTarget; public int zapActivity = 0; public bool ragePulse = false; @@ -355,27 +366,55 @@ namespace CalamityMod.CalPlayer #endregion #region Defense Damage - // Ratio at which incoming damage (after mitigation) is converted into defense damage. - // Used to be 5% normal, 10% expert, 12% rev, 15% death, 20% boss rush - // It is now 10% on all difficulties because you already take less damage on lower difficulties. - public const double DefenseDamageRatio = 0.1; + // Ratio at which mitigated damage is converted into defense damage. + // This is a significant rework, so the ratio is much higher than the previous 0.1 / 10%. + // The net difference between incoming damage and final taken damage is what is multiplied by this ratio. + // + // Example: You have 200 defense and 25% DR and get hit for 576, on Expert. + // + // Incoming damage = 576 + // Defense reduction = 0.75 * 200 = 150 + // Damage after defense = 426 + // DR reduction = 0.25 * 426 = 106.5 + // Damage after DR = 319.5 (rounds down to 319) + // + // Net Difference = 576 - 319 = 257 + // Defense Damage = 257 * 0.3333 = 85.6581 (rounds up to 86) + // + // The player then loses 86 defense. + // DR is lost according to the ratio of defense lost versus total defense. + // In this case, that ratio is 86 / 200 = 0.43. + // The player loses 0.43 * 0.25 = 10.75% DR. + public double defenseDamageRatio = BalancingConstants.DefaultDefenseDamageRatio; + + // Current effect of defense damage, calculated as total defense damage lerped to zero over the recovery time. public int CurrentDefenseDamage => (int)(totalDefenseDamage * ((float)defenseDamageRecoveryFrames / totalDefenseDamageRecoveryFrames)); + + // Total defense damage inflicted. This number keeps increasing if the player is repeatedly hit during the recovery period. internal int totalDefenseDamage = 0; - // Defense damage from a single hit recovers in 50 frames, no matter how big the hit was. - // If you get hit AGAIN before you have fully recovered, 50 more frames are added to your recovery timer! + + // Defense damage from a single hit recovers in 60 frames, no matter how big the hit was. + // If you get hit AGAIN before you have fully recovered, 60 more frames are added to your recovery timer! internal const int DefenseDamageBaseRecoveryTime = 60; + // The maximum possible recovery time is 15 seconds. This is to prevent annoyance where godmode defense damage never goes away. internal const int DefenseDamageMaxRecoveryTime = 900; + // How many frames the player will continue to be recovering from defense damage. internal int defenseDamageRecoveryFrames = 0; + // The total timer of defense damage recovery that the player is currently suffering from. internal int totalDefenseDamageRecoveryFrames = DefenseDamageBaseRecoveryTime; + // Defense damage does not start recovering for a certain number of frames after iframes end. internal const int DefenseDamageRecoveryDelay = 10; + // The current timer for how long the player must wait before defense damage begins recovering. internal int defenseDamageDelayFrames = 0; - public bool justHitByDefenseDamage = false; - public int defenseDamageToTake = 0; + + // Temporary bool for whether the current instance of incoming damage to the player is one that inflicts defense damage. + // Bloodflare Core ignores this and makes every single instance of incoming damage apply defense damage. + public bool nextHitDealsDefenseDamage = false; #endregion #region Energy Shields @@ -466,8 +505,12 @@ namespace CalamityMod.CalPlayer public bool badgeOfBravery = false; public bool warbannerOfTheSun = false; public bool cryogenSoul = false; - public bool yInsignia = false; + public bool ascendantInsignia = false; + public int ascendantInsigniaBuffTime = 0; + public int ascendantInsigniaCooldown = 0; + public bool ascendantTrail = false; public bool eGauntlet = false; + public int gloveLevel = 0; // Used to prevent glove stacking public bool eTalisman = false; public int statisTimer = 0; public bool nucleogenesis = false; @@ -534,8 +577,10 @@ namespace CalamityMod.CalPlayer public bool bloodPact = false; public bool bloodPactBoost = false; public bool bloodflareCore = false; - public int bloodflareCoreLostDefense = 0; - public bool coreOfTheBloodGod = false; + public int bloodflareCoreRemainingHealOverTime = 0; + public bool chaliceOfTheBloodGod = false; + public double chaliceBleedoutBuffer = 0D; + public double chaliceDamagePointPartialProgress = 0D; public bool elementalHeart = false; public bool crownJewel = false; public bool infectedJewel = false; @@ -553,6 +598,7 @@ namespace CalamityMod.CalPlayer public bool hellfireTreads = false; public bool abyssalAmulet = false; public bool lumenousAmulet = false; + public bool oceanCrest = false; public bool aquaticEmblem = false; public bool spiritOrigin = false; public bool spiritOriginVanity = false; @@ -745,8 +791,6 @@ namespace CalamityMod.CalPlayer public bool plagueReaper = false; public bool plaguebringerPatronSet = false; public bool plaguebringerCarapace = false; - public bool plaguebringerPistons = false; - public int pistonsCounter = 0; public float ataxiaDmg; public bool ataxiaMage = false; public bool ataxiaGeyser = false; @@ -828,6 +872,7 @@ namespace CalamityMod.CalPlayer public bool gState = false; public bool bBlood = false; public bool brainRot = false; + public bool elementalMix = false; public bool icarusFolly = false; public bool weakPetrification = false; public bool vHex = false; @@ -865,7 +910,7 @@ namespace CalamityMod.CalPlayer public bool xWrath = false; public bool graxDefense = false; public bool encased = false; - public bool tFury = false; + public bool brutalCarnage = false; public bool omniscience = false; public bool zerg = false; public bool zen = false; @@ -876,7 +921,6 @@ namespace CalamityMod.CalPlayer public bool PinkJellyRegen = false; public bool GreenJellyRegen = false; public bool AbsorberRegen = false; - public bool shellBoost = false; public bool cFreeze = false; public bool shine = false; public bool anechoicCoating = false; @@ -910,6 +954,7 @@ namespace CalamityMod.CalPlayer public bool cinnamonRoll = false; public bool tequilaSunrise = false; public bool margarita = false; + public bool oldFashioned = false; public bool starBeamRye = false; public bool screwdriver = false; public bool moscowMule = false; @@ -940,7 +985,7 @@ namespace CalamityMod.CalPlayer public bool wDroid = false; public bool resButterfly = false; public bool mWorm = false; - public bool iClasper = false; + public bool IceClasperBool = false; public bool magicHat = false; public bool herring = false; public bool blackhawk = false; @@ -1417,8 +1462,11 @@ namespace CalamityMod.CalPlayer KeyValuePair kv = tagIterator.Current; string id = kv.Key; TagCompound singleCDTag = cooldownsTag.GetCompound(id); + + // If the cooldown has no registered handler, don't add it. Doing so will cause crashes. CooldownInstance instance = new CooldownInstance(Player, id, singleCDTag); - cooldowns.Add(id, instance); + if (instance.handler is not null) + cooldowns.Add(id, instance); } } #endregion @@ -1432,10 +1480,13 @@ namespace CalamityMod.CalPlayer int percentMaxLifeIncrease = 0; if (ZoneAbyss && abyssalAmulet) percentMaxLifeIncrease += lumenousAmulet ? 25 : 10; - if (coreOfTheBloodGod) - percentMaxLifeIncrease += 15; + + // Blood Pact and Chalice of the Blood God stack their HP bonuses if you want to equip both if (bloodPact) - percentMaxLifeIncrease += 100; + percentMaxLifeIncrease += 25; + if (chaliceOfTheBloodGod) + percentMaxLifeIncrease += 25; + if (affliction || afflicted) percentMaxLifeIncrease += 10; @@ -1457,6 +1508,7 @@ namespace CalamityMod.CalPlayer // Reset adrenaline duration to default. If Draedon's Heart is equipped, it'll change itself every frame. AdrenalineDuration = CalamityUtils.SecondsToFrames(5); + defenseDamageRatio = BalancingConstants.DefaultDefenseDamageRatio; contactDamageReduction = 0D; projectileDamageReduction = 0D; rogueVelocity = 1f; @@ -1622,8 +1674,10 @@ namespace CalamityMod.CalPlayer nanotech = false; deadshotBrooch = false; cryogenSoul = false; - yInsignia = false; + ascendantInsignia = false; + ascendantTrail = false; eGauntlet = false; + gloveLevel = 0; eTalisman = false; nucleogenesis = false; nuclearFuelRod = false; @@ -1644,7 +1698,7 @@ namespace CalamityMod.CalPlayer fleshTotem = false; bloodPact = false; bloodflareCore = false; - coreOfTheBloodGod = false; + chaliceOfTheBloodGod = false; elementalHeart = false; crownJewel = false; infectedJewel = false; @@ -1724,7 +1778,7 @@ namespace CalamityMod.CalPlayer lunicCorpsLegs = false; rangedAmmoCost = 1f; - healingPotBonus = 1f; + healingPotionMultiplier = 1f; avertorBonus = false; @@ -1741,6 +1795,7 @@ namespace CalamityMod.CalPlayer hellfireTreads = false; abyssalAmulet = false; lumenousAmulet = false; + oceanCrest = false; aquaticEmblem = false; spiritOrigin = false; spiritOriginVanity = false; @@ -1782,7 +1837,6 @@ namespace CalamityMod.CalPlayer plagueReaper = false; plaguebringerPatronSet = false; plaguebringerCarapace = false; - plaguebringerPistons = false; fathomSwarmer = false; fathomSwarmerVisage = false; fathomSwarmerBreastplate = false; @@ -1853,6 +1907,7 @@ namespace CalamityMod.CalPlayer gState = false; bBlood = false; brainRot = false; + elementalMix = false; icarusFolly = false; vHex = false; DoGExtremeGravity = false; @@ -1883,7 +1938,7 @@ namespace CalamityMod.CalPlayer xWrath = false; graxDefense = false; encased = false; - tFury = false; + brutalCarnage = false; omniscience = false; zerg = false; zen = false; @@ -1913,14 +1968,12 @@ namespace CalamityMod.CalPlayer PinkJellyRegen = false; GreenJellyRegen = false; AbsorberRegen = false; - shellBoost = false; cFreeze = false; tRegen = false; polarisBoost = false; polarisBoostTwo = false; polarisBoostThree = false; bloodfinBoost = false; - bloodPactBoost = false; divineBless = false; killSpikyBalls = false; @@ -1939,6 +1992,7 @@ namespace CalamityMod.CalPlayer cinnamonRoll = false; tequilaSunrise = false; margarita = false; + oldFashioned = false; starBeamRye = false; screwdriver = false; moscowMule = false; @@ -1954,7 +2008,7 @@ namespace CalamityMod.CalPlayer wDroid = false; resButterfly = false; mWorm = false; - iClasper = false; + IceClasperBool = false; magicHat = false; herring = false; blackhawk = false; @@ -2190,15 +2244,17 @@ namespace CalamityMod.CalPlayer } } - #region Debuffs + #region Defense Damage totalDefenseDamage = 0; defenseDamageRecoveryFrames = 0; totalDefenseDamageRecoveryFrames = DefenseDamageBaseRecoveryTime; defenseDamageDelayFrames = 0; - justHitByDefenseDamage = false; - defenseDamageToTake = 0; + nextHitDealsDefenseDamage = false; + bloodflareCoreRemainingHealOverTime = 0; + #endregion + + #region Debuffs heldGaelsLastFrame = false; - gaelRageAttackCooldown = 0; gaelSwipes = 0; andromedaState = AndromedaPlayerState.Inactive; planarSpeedBoost = 0; @@ -2212,8 +2268,10 @@ namespace CalamityMod.CalPlayer auralisAurora = 0; necroReviveCounter = -1; hideOfDeusTimer = 0; + murasamaHitCooldown = 0; RustyMedallionCooldown = 0; SulphWaterPoisoningLevel = 0f; + holyInfernoFadeIntensity = 0f; spiritOriginConvertedCrit = 0; rage = 0f; adrenaline = 0f; @@ -2272,6 +2330,7 @@ namespace CalamityMod.CalPlayer gState = false; bBlood = false; brainRot = false; + elementalMix = false; icarusFolly = false; vHex = false; DoGExtremeGravity = false; @@ -2338,7 +2397,7 @@ namespace CalamityMod.CalPlayer kamiBoost = false; graxDefense = false; encased = false; - tFury = false; + brutalCarnage = false; omniscience = false; zerg = false; zen = false; @@ -2368,12 +2427,10 @@ namespace CalamityMod.CalPlayer GreenJellyRegen = false; AbsorberRegen = false; enraged = false; - shellBoost = false; cFreeze = false; tRegen = false; rageModeActive = false; adrenalineModeActive = false; - AdrenalineTrail = false; vodka = false; redWine = false; grapeBeer = false; @@ -2388,6 +2445,7 @@ namespace CalamityMod.CalPlayer cinnamonRoll = false; tequilaSunrise = false; margarita = false; + oldFashioned = false; starBeamRye = false; screwdriver = false; moscowMule = false; @@ -2408,9 +2466,8 @@ namespace CalamityMod.CalPlayer bloodfinTimer = 0; healCounter = 300; danceOfLightCharge = 0; - bloodPactBoost = false; rangedAmmoCost = 1f; - healingPotBonus = 1f; + healingPotionMultiplier = 1f; avertorBonus = false; divineBless = false; #endregion @@ -2480,8 +2537,6 @@ namespace CalamityMod.CalPlayer plagueReaper = false; plaguebringerPatronSet = false; plaguebringerCarapace = false; - plaguebringerPistons = false; - pistonsCounter = 0; ataxiaMage = false; ataxiaBolt = false; ataxiaGeyser = false; @@ -2551,17 +2606,21 @@ namespace CalamityMod.CalPlayer KameiBladeUseDelay = 0; brimlashBusterBoost = false; + AdrenalineTrail = false; + ascendantTrail = false; evilSmasherBoost = 0; hellbornBoost = 0; searedPanCounter = 0; searedPanTimer = 0; potionTimer = 0; - bloodflareCoreLostDefense = 0; persecutedEnchantSummonTimer = 0; momentumCapacitorTime = 0; momentumCapacitorBoost = 0f; LungingDown = false; + chaliceBleedoutBuffer = 0D; + chaliceDamagePointPartialProgress = 0D; + if (BossRushEvent.BossRushActive) { // https://github.com/tModLoader/tModLoader/wiki/IEntitySource#detailed-list @@ -2571,13 +2630,11 @@ namespace CalamityMod.CalPlayer Projectile.NewProjectile(source, Player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f); } - // Respawn the player faster if no bosses are alive - if (!areThereAnyDamnBosses) - { - int respawnTimerSet = areThereAnyDamnEvents ? 360 : 180; - if (Player.respawnTimer > respawnTimerSet) - Player.respawnTimer = respawnTimerSet; - } + // Respawn the player faster + // 3 seconds normally, 5 seconds while an event is happening and 15 seconds while a boss is alive + int respawnTimerSet = areThereAnyDamnBosses ? 900 : areThereAnyDamnEvents ? 300 : 180; + if (Player.respawnTimer > respawnTimerSet) + Player.respawnTimer = respawnTimerSet; } #endregion @@ -2680,7 +2737,11 @@ namespace CalamityMod.CalPlayer { Projectile proj = Main.projectile[projIndex]; float start = 360f / angelAmt; - Projectile.NewProjectile(source, new Vector2((int)(Player.Center.X + (Math.Sin(projIndex * start) * 300)), (int)(Player.Center.Y + (Math.Cos(projIndex * start) * 300))), Vector2.Zero, ModContent.ProjectileType(), proj.damage / 10, proj.knockBack / 10f, Player.whoAmI, Main.rand.Next(180), projIndex * start); + int damage = proj.damage / 10; + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + + Projectile.NewProjectile(source, new Vector2((int)(Player.Center.X + (Math.Sin(projIndex * start) * 300)), (int)(Player.Center.Y + (Math.Cos(projIndex * start) * 300))), Vector2.Zero, ModContent.ProjectileType(), damage, proj.knockBack / 10f, Player.whoAmI, Main.rand.Next(180), projIndex * start); Player.statLife += 2; Player.HealEffect(2); } @@ -2692,7 +2753,11 @@ namespace CalamityMod.CalPlayer var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); rogueStealth -= rogueStealthMax * 0.1f; - int veil = Projectile.NewProjectile(source, Player.Center, Vector2.Zero, ModContent.ProjectileType(), 7, 8, Player.whoAmI); + int damage = 7; + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + + int veil = Projectile.NewProjectile(source, Player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 8, Player.whoAmI); Main.projectile[veil].Center = Player.Center; SoundEngine.PlaySound(SoundID.Item45, Player.Center); } @@ -2770,22 +2835,22 @@ namespace CalamityMod.CalPlayer brimflameFrenzy = true; Player.AddBuff(ModContent.BuffType(), 10 * 60, true); SoundEngine.PlaySound(BrimflameScowl.ActivationSound, Player.Center); - for (int num502 = 0; num502 < 36; num502++) + for (int i = 0; i < 36; i++) { - int dust = Dust.NewDust(new Vector2(Player.position.X, Player.position.Y + 16f), Player.width, Player.height - 16, (int)CalamityDusts.Brimstone, 0f, 0f, 0, default, 1f); - Main.dust[dust].velocity *= 3f; - Main.dust[dust].scale *= 1.15f; + int brimDust = Dust.NewDust(new Vector2(Player.position.X, Player.position.Y + 16f), Player.width, Player.height - 16, (int)CalamityDusts.Brimstone, 0f, 0f, 0, default, 1f); + Main.dust[brimDust].velocity *= 3f; + Main.dust[brimDust].scale *= 1.15f; } - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int j = 0; j < dustAmt; j++) { - Vector2 vector6 = Vector2.Normalize(Player.velocity) * new Vector2((float)Player.width / 2f, (float)Player.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * MathHelper.TwoPi / (float)num226), default) + Player.Center; - Vector2 vector7 = vector6 - Player.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, (int)CalamityDusts.Brimstone, vector7.X * 1.5f, vector7.Y * 1.5f, 100, default, 1.4f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 dustRotation = Vector2.Normalize(Player.velocity) * new Vector2((float)Player.width / 2f, (float)Player.height) * 0.75f; + dustRotation = dustRotation.RotatedBy((double)((float)(j - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + Player.Center; + Vector2 dustVelocity = dustRotation - Player.Center; + int brimDust2 = Dust.NewDust(dustRotation + dustVelocity, 0, 0, (int)CalamityDusts.Brimstone, dustVelocity.X * 1.5f, dustVelocity.Y * 1.5f, 100, default, 1.4f); + Main.dust[brimDust2].noGravity = true; + Main.dust[brimDust2].noLight = true; + Main.dust[brimDust2].velocity = dustVelocity; } } } @@ -2826,6 +2891,9 @@ namespace CalamityMod.CalPlayer double offsetAngle; int damage = (int)(Player.GetTotalDamage().ApplyTo(300f)); + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + if (Player.whoAmI == Main.myPlayer) { var source = Player.GetSource_Misc("1"); @@ -2864,22 +2932,22 @@ namespace CalamityMod.CalPlayer if (dsSetBonus) { SoundEngine.PlaySound(DemonshadeHelm.ActivationSound, Player.Center); - for (int num502 = 0; num502 < 36; num502++) + for (int i = 0; i < 36; i++) { - int dust = Dust.NewDust(new Vector2(Player.position.X, Player.position.Y + 16f), Player.width, Player.height - 16, (int)CalamityDusts.Brimstone, 0f, 0f, 0, default, 1f); - Main.dust[dust].velocity *= 3f; - Main.dust[dust].scale *= 1.15f; + int brimDust = Dust.NewDust(new Vector2(Player.position.X, Player.position.Y + 16f), Player.width, Player.height - 16, (int)CalamityDusts.Brimstone, 0f, 0f, 0, default, 1f); + Main.dust[brimDust].velocity *= 3f; + Main.dust[brimDust].scale *= 1.15f; } - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int j = 0; j < dustAmt; j++) { - Vector2 vector6 = Vector2.Normalize(Player.velocity) * new Vector2((float)Player.width / 2f, (float)Player.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * MathHelper.TwoPi / (float)num226), default) + Player.Center; - Vector2 vector7 = vector6 - Player.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, (int)CalamityDusts.Brimstone, vector7.X * 1.5f, vector7.Y * 1.5f, 100, default, 1.4f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 dustRotation = Vector2.Normalize(Player.velocity) * new Vector2((float)Player.width / 2f, (float)Player.height) * 0.75f; + dustRotation = dustRotation.RotatedBy((double)((float)(j - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + Player.Center; + Vector2 dustVelocity = dustRotation - Player.Center; + int brimDust2 = Dust.NewDust(dustRotation + dustVelocity, 0, 0, (int)CalamityDusts.Brimstone, dustVelocity.X * 1.5f, dustVelocity.Y * 1.5f, 100, default, 1.4f); + Main.dust[brimDust2].noGravity = true; + Main.dust[brimDust2].noLight = true; + Main.dust[brimDust2].velocity = dustVelocity; } if (Player.whoAmI == Main.myPlayer) { @@ -2920,6 +2988,9 @@ namespace CalamityMod.CalPlayer // To compute Forbidden Circlet tornado damage, create a fake stat modifier on the spot which combines both classes. StatModifier forbidden = Player.GetTotalDamage().CombineWith(Player.GetDamage()); int damage = (int)forbidden.ApplyTo(ForbiddenCirclet.tornadoBaseDmg); + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + float kBack = Player.GetTotalKnockback().ApplyTo(ForbiddenCirclet.tornadoBaseKB); if (Player.whoAmI == Main.myPlayer) @@ -2961,7 +3032,6 @@ namespace CalamityMod.CalPlayer SoundEngine.PlaySound(ProfanedGuardianDefender.RockShieldSpawnSound, Player.Center); flameLickedShellParry = FlameLickedShell.flameLickedParry; } - } } @@ -2993,7 +3063,7 @@ namespace CalamityMod.CalPlayer if (CalamityKeybinds.RageHotKey.JustPressed) { // Gael's Greatsword replaces Rage Mode with an uber skull attack - if (gaelRageAttackCooldown == 0 && Player.ActiveItem().type == ModContent.ItemType() && rage > 0f) + if (!(Player.HasCooldown(Cooldowns.GaelsRage.ID)) && Player.ActiveItem().type == ModContent.ItemType() && rage > 0f) { SoundEngine.PlaySound(SilvaHeadSummon.DispelSound, Player.Center); @@ -3032,7 +3102,7 @@ namespace CalamityMod.CalPlayer // Remove all rage when the special attack is used, and apply the cooldown. rage = 0f; - gaelRageAttackCooldown = CalamityUtils.SecondsToFrames(GaelsGreatsword.SkullsplosionCooldownSeconds); + Player.AddCooldown(Cooldowns.GaelsRage.ID, 1800); } // Activating Rage Mode @@ -3133,9 +3203,9 @@ namespace CalamityMod.CalPlayer public static Vector2? GetUnderworldPosition(Player player) { bool canSpawn = false; - int num = Main.maxTilesX / 2; - int num2 = 100; - int num3 = num2 / 2; + int halfWorldXTiles = Main.maxTilesX / 2; + int largerCheckRadius = 100; + int smallerCheckRadius = 50; int teleportStartY = Main.UnderworldLayer + 20; int teleportRangeY = 80; Player.RandomTeleportationAttemptSettings settings = new Player.RandomTeleportationAttemptSettings @@ -3149,12 +3219,12 @@ namespace CalamityMod.CalPlayer maximumFallDistanceFromOrignalPoint = 30 }; - Vector2 vector = player.CheckForGoodTeleportationSpot(ref canSpawn, num - num3, num2, teleportStartY, teleportRangeY, settings); + Vector2 vector = player.CheckForGoodTeleportationSpot(ref canSpawn, halfWorldXTiles - smallerCheckRadius, largerCheckRadius, teleportStartY, teleportRangeY, settings); if (!canSpawn) - vector = player.CheckForGoodTeleportationSpot(ref canSpawn, num - num2, num3, teleportStartY, teleportRangeY, settings); + vector = player.CheckForGoodTeleportationSpot(ref canSpawn, halfWorldXTiles - largerCheckRadius, smallerCheckRadius, teleportStartY, teleportRangeY, settings); if (!canSpawn) - vector = player.CheckForGoodTeleportationSpot(ref canSpawn, num + num3, num3, teleportStartY, teleportRangeY, settings); + vector = player.CheckForGoodTeleportationSpot(ref canSpawn, halfWorldXTiles + smallerCheckRadius, smallerCheckRadius, teleportStartY, teleportRangeY, settings); if (canSpawn) { @@ -3349,7 +3419,11 @@ namespace CalamityMod.CalPlayer { var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); //Spawn explosion. ai[0] is used for transferring the recorded falling time - Projectile.NewProjectile(source, Player.Center, Vector2.Zero, ModContent.ProjectileType(), 300, 4f, Player.whoAmI, gSabatonFall); + int damage = 300; + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + + Projectile.NewProjectile(source, Player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 4f, Player.whoAmI, gSabatonFall); gSabatonFall = 0; gSabatonFalling = false; //Temporary jump speed is granted for 40 frames @@ -3449,12 +3523,12 @@ namespace CalamityMod.CalPlayer if (Player.controlLeft) { Player.velocity.X = -speed; - Player.direction = -1; + Player.ChangeDir(-1); } else if (Player.controlRight) { Player.velocity.X = speed; - Player.direction = 1; + Player.ChangeDir(1); } else Player.velocity.X = 0f; @@ -3663,7 +3737,7 @@ namespace CalamityMod.CalPlayer #region Get Heal Life public override void GetHealLife(Item item, bool quickHeal, ref int healValue) { - healValue = (int)(healValue * healingPotBonus); + healValue = (int)(healValue * healingPotionMultiplier); } #endregion @@ -3892,46 +3966,50 @@ namespace CalamityMod.CalPlayer { if (!CalamityLists.VeneratedLocketBanlist.Contains(item.type)) { - float num72 = item.shootSpeed; - Vector2 vector2 = Player.RotatedRelativePoint(Player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float veneratedCloneSpeed = item.shootSpeed; + Vector2 realPlayerPos = Player.RotatedRelativePoint(Player.MountedCenter, true); + float veneratedCloneXPos = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float veneratedCloneYPos = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (Player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + veneratedCloneYPos = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float veneratedCloneDistance = (float)Math.Sqrt((double)(veneratedCloneXPos * veneratedCloneXPos + veneratedCloneYPos * veneratedCloneYPos)); + if ((float.IsNaN(veneratedCloneXPos) && float.IsNaN(veneratedCloneYPos)) || (veneratedCloneXPos == 0f && veneratedCloneYPos == 0f)) { - num78 = (float)Player.direction; - num79 = 0f; - num80 = num72; + veneratedCloneXPos = (float)Player.direction; + veneratedCloneYPos = 0f; + veneratedCloneDistance = veneratedCloneSpeed; } else { - num80 = num72 / num80; + veneratedCloneDistance = veneratedCloneSpeed / veneratedCloneDistance; } - vector2 = new Vector2(Player.position.X + (float)Player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)Player.direction) + ((float)Main.mouseX + Main.screenPosition.X - Player.position.X), Player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + Player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= 100f; - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(Player.position.X + (float)Player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)Player.direction) + ((float)Main.mouseX + Main.screenPosition.X - Player.position.X), Player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + Player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= 100f; + veneratedCloneXPos = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + veneratedCloneYPos = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (veneratedCloneYPos < 0f) { - num79 *= -1f; + veneratedCloneYPos *= -1f; } - if (num79 < 20f) + if (veneratedCloneYPos < 20f) { - num79 = 20f; + veneratedCloneYPos = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-30, 31) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-30, 31) * 0.02f; - int p = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, (int)(damage * 0.07), knockBack * 0.5f, Player.whoAmI); + veneratedCloneDistance = (float)Math.Sqrt((double)(veneratedCloneXPos * veneratedCloneXPos + veneratedCloneYPos * veneratedCloneYPos)); + veneratedCloneDistance = veneratedCloneSpeed / veneratedCloneDistance; + veneratedCloneXPos *= veneratedCloneDistance; + veneratedCloneYPos *= veneratedCloneDistance; + float speedX4 = veneratedCloneXPos + (float)Main.rand.Next(-30, 31) * 0.02f; + float speedY5 = veneratedCloneYPos + (float)Main.rand.Next(-30, 31) * 0.02f; + int locketDamage = (int)(damage * 0.07f); + if (oldFashioned) + locketDamage = CalamityUtils.CalcOldFashionedDamage(locketDamage); + + int p = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, locketDamage, knockBack * 0.5f, Player.whoAmI); if (p.WithinBounds(Main.maxProjectiles)) { @@ -3950,6 +4028,9 @@ namespace CalamityMod.CalPlayer { int knifeCount = 12; int knifeDamage = (int)Player.GetTotalDamage().ApplyTo(55); + if (oldFashioned) + knifeDamage = CalamityUtils.CalcOldFashionedDamage(knifeDamage); + float angleStep = MathHelper.TwoPi / knifeCount; float speed = 14f; @@ -3972,6 +4053,9 @@ namespace CalamityMod.CalPlayer if (item.CountsAsClass()) { int d = (int)Player.GetTotalDamage().ApplyTo(Items.Accessories.RustyMedallion.AcidDropBaseDamage); + if (oldFashioned) + d = CalamityUtils.CalcOldFashionedDamage(d); + Vector2 startingPosition = Main.MouseWorld - Vector2.UnitY.RotatedByRandom(0.4f) * 1250f; Vector2 directionToMouse = (Main.MouseWorld - startingPosition).SafeNormalize(Vector2.UnitY).RotatedByRandom(0.1f); int drop = Projectile.NewProjectile(source, startingPosition, directionToMouse * 15f, ModContent.ProjectileType(), d, 0f, Player.whoAmI); diff --git a/CalPlayer/CalamityPlayerDashEffects.cs b/CalPlayer/CalamityPlayerDashEffects.cs index 9e36bbecba..6249e17649 100644 --- a/CalPlayer/CalamityPlayerDashEffects.cs +++ b/CalPlayer/CalamityPlayerDashEffects.cs @@ -160,7 +160,7 @@ namespace CalamityMod.CalPlayer // Decide the player's facing direction. if (Player.velocity.X != 0f) - Player.direction = Math.Sign(Player.velocity.X); + Player.ChangeDir(Math.Sign(Player.velocity.X)); // Handle mid-dash movement. if (UsedDash.IsOmnidirectional) diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index 10ea51320e..eaf39cd6f5 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -233,6 +233,9 @@ namespace CalamityMod.CalPlayer if (calamityPlayer.dragonFire && drawInfo.shadow == 0f) Dragonfire.DrawEffects(drawInfo); + if (calamityPlayer.elementalMix && drawInfo.shadow == 0f) + ElementalMix.DrawEffects(drawInfo); + if (calamityPlayer.eutrophication && drawInfo.shadow == 0f) Eutrophication.DrawEffects(drawInfo); @@ -472,10 +475,8 @@ namespace CalamityMod.CalPlayer SpriteEffects spriteEffects = Player.direction == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - float num25 = -4f; - float num24 = -8f; DrawData howDoIDrawThings = new DrawData(thingToDraw, - new Vector2((int)(drawPlayer.position.X - Main.screenPosition.X + (drawPlayer.width / 2) - (9 * drawPlayer.direction)) + num25 * drawPlayer.direction, (int)(drawPlayer.position.Y - Main.screenPosition.Y + (drawPlayer.height / 2) + 2f * drawPlayer.gravDir + num24 * drawPlayer.gravDir)), + new Vector2((int)(drawPlayer.position.X - Main.screenPosition.X + (drawPlayer.width / 2) - (9 * drawPlayer.direction)) - 4f * drawPlayer.direction, (int)(drawPlayer.position.Y - Main.screenPosition.Y + (drawPlayer.height / 2) + 2f * drawPlayer.gravDir - 8f * drawPlayer.gravDir)), new Rectangle(0, 0, thingToDraw.Width, thingToDraw.Height), drawInfo.colorArmorBody, drawPlayer.bodyRotation, diff --git a/CalPlayer/CalamityPlayerHitHurt.cs b/CalPlayer/CalamityPlayerHitHurt.cs index f22f377201..7d6621add7 100644 --- a/CalPlayer/CalamityPlayerHitHurt.cs +++ b/CalPlayer/CalamityPlayerHitHurt.cs @@ -18,6 +18,7 @@ using CalamityMod.Items.Armor.LunicCorps; using CalamityMod.Items.Armor.Silva; using CalamityMod.Items.Armor.Wulfrum; using CalamityMod.Items.Mounts; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.Items.Weapons.Melee; using CalamityMod.NPCs; @@ -119,8 +120,8 @@ namespace CalamityMod.CalPlayer for (int j = 0; j < 100; j++) { - int num = Dust.NewDust(Player.position, Player.width, Player.height, 235, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[num]; + int scarfDodgeDust = Dust.NewDust(Player.position, Player.width, Player.height, 235, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[scarfDodgeDust]; dust.position.X += Main.rand.Next(-20, 21); dust.position.Y += Main.rand.Next(-20, 21); dust.velocity *= 0.4f; @@ -153,6 +154,9 @@ namespace CalamityMod.CalPlayer for (int i = 0; i < 10; i++) { int damage = (int)Player.GetTotalDamage().ApplyTo(55); + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + int lumenyl = Projectile.NewProjectile(source, Player.Center.X, Player.Center.Y, Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-2f, 2f), ModContent.ProjectileType(), damage, 0, Player.whoAmI); Main.projectile[lumenyl].rotation = Main.rand.NextFloat(0, 360); Main.projectile[lumenyl].frame = Main.rand.Next(0, 4); @@ -183,6 +187,9 @@ namespace CalamityMod.CalPlayer var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); int damage = (int)Player.GetTotalDamage().ApplyTo(2750); + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + int eclipse = Projectile.NewProjectile(source, Player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0, Player.whoAmI); if (eclipse.WithinBounds(Main.maxProjectiles)) Main.projectile[eclipse].DamageType = DamageClass.Generic; @@ -233,8 +240,8 @@ namespace CalamityMod.CalPlayer for (int j = 0; j < 50; j++) { - int num = Dust.NewDust(Player.position, Player.width, Player.height, 173, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[num]; + int nebulousReviveDust = Dust.NewDust(Player.position, Player.width, Player.height, 173, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[nebulousReviveDust]; dust.position.X += Main.rand.Next(-20, 21); dust.position.Y += Main.rand.Next(-20, 21); dust.velocity *= 0.9f; @@ -245,6 +252,13 @@ namespace CalamityMod.CalPlayer dust.scale *= 1f + Main.rand.Next(40) * 0.01f; } + // Nebulous Core clears Chalice of the Blood God's bleedout buffer + if (chaliceOfTheBloodGod) + { + chaliceBleedoutBuffer = 0D; + chaliceDamagePointPartialProgress = 0D; + } + Player.statLife += 100; Player.HealEffect(100); @@ -286,6 +300,14 @@ namespace CalamityMod.CalPlayer if (Player.statLife < 1) Player.statLife = 1; + // Silva revive clears Chalice of the Blood God's bleedout buffer every frame while active + // Can we please remove this from the game + if (chaliceOfTheBloodGod) + { + chaliceBleedoutBuffer = 0D; + chaliceDamagePointPartialProgress = 0D; + } + return false; } @@ -391,6 +413,10 @@ namespace CalamityMod.CalPlayer { damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.BrainRot" + Main.rand.Next(1, 3 + 1)).Format(Player.name)); } + if (elementalMix) + { + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ElementalMix" + Main.rand.Next(1, 2 + 1)).Format(Player.name)); + } if (cDepth) { damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.CrushDepth" + Main.rand.Next(1, 3 + 1)).Format(Player.name)); @@ -776,7 +802,7 @@ namespace CalamityMod.CalPlayer } if (trinketOfChiBuff) - contactDamageReduction += 0.1; + contactDamageReduction += 0.04; // Fearmonger set provides 15% multiplicative DR that ignores caps during the Holiday Moons. // To prevent abuse, this effect does not work if there are any bosses alive. @@ -1027,7 +1053,7 @@ namespace CalamityMod.CalPlayer } if (trinketOfChiBuff) - projectileDamageReduction += 0.1; + projectileDamageReduction += 0.04; // Fearmonger set provides 15% multiplicative DR that ignores caps during the Holiday Moons. // To prevent abuse, this effect does not work if there are any bosses alive. @@ -1141,15 +1167,12 @@ namespace CalamityMod.CalPlayer // If this NPC deals defense damage with contact damage, then mark the player to take defense damage. // Defense damage is not applied if the player has iframes, or is in Journey god mode. if (!hasIFrames && !Player.creativeGodMode) - { - justHitByDefenseDamage |= npc.Calamity().canBreakPlayerDefense; - defenseDamageToTake = npc.Calamity().canBreakPlayerDefense ? hurtInfo.Damage : 0; - } + nextHitDealsDefenseDamage |= npc.Calamity().canBreakPlayerDefense; // ModifyHit (Flesh Totem effect happens here) -> Hurt (includes dodges) -> OnHit // As such, to avoid cooldowns proccing from dodge hits, do it here if (fleshTotem && !Player.HasCooldown(Cooldowns.FleshTotem.ID) && hurtInfo.Damage > 0) - Player.AddCooldown(Cooldowns.FleshTotem.ID, CalamityUtils.SecondsToFrames(20), true, coreOfTheBloodGod ? "bloodgod" : "default"); + Player.AddCooldown(Cooldowns.FleshTotem.ID, CalamityUtils.SecondsToFrames(20), true, "default"); if (NPC.AnyNPCs(ModContent.NPCType())) Player.AddBuff(ModContent.BuffType(), 15, true); @@ -1211,10 +1234,7 @@ namespace CalamityMod.CalPlayer // If this projectile is capable of dealing defense damage, then mark the player to take defense damage. // Defense damage is not applied if the player has iframes, or is in Journey god mode. if (!hasIFrames && !Player.creativeGodMode) - { - justHitByDefenseDamage = proj.Calamity().DealsDefenseDamage; - defenseDamageToTake = proj.Calamity().DealsDefenseDamage ? hurtInfo.Damage : 0; - } + nextHitDealsDefenseDamage |= proj.Calamity().DealsDefenseDamage; if (sulfurSet && !proj.friendly && hurtInfo.Damage > 0) { @@ -1429,7 +1449,11 @@ namespace CalamityMod.CalPlayer Rectangle npcHitbox = n.getRect(); if ((Player.getRect()).Intersects(npcHitbox) && (n.noTileCollide || Collision.CanHit(Player.position, Player.width, Player.height, n.position, n.width, n.height))) { - Projectile.NewProjectile(Player.GetSource_FromThis(), n.Center, Vector2.Zero, ModContent.ProjectileType(), 150, 0, Main.myPlayer); + int damage = 150; + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + + Projectile.NewProjectile(Player.GetSource_FromThis(), n.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0, Main.myPlayer); n.Calamity().dashImmunityTime[Player.whoAmI] = 4; Player.GiveIFrames(5, false); @@ -1587,14 +1611,6 @@ namespace CalamityMod.CalPlayer if (Player.beetleDefense && Player.beetleOrbs > 0) damageMult += 0.05 * Player.beetleOrbs; - // Blood Pact gives you a 1/4 chance to be crit, increasing the incoming damage by 25%. - if (bloodPact && Main.rand.NextBool(4)) - { - Player.AddBuff(ModContent.BuffType(), 600); - SoundEngine.PlaySound(BloodCritSound, Player.Center); - damageMult += 1.25; - } - modifiers.SourceDamage *= (float)damageMult; #endregion @@ -1890,10 +1906,27 @@ namespace CalamityMod.CalPlayer freeDodgeFromShieldAbsorption = true; // Cancel defense damage, if it was going to occur this frame. - justHitByDefenseDamage = false; - defenseDamageToTake = 0; + nextHitDealsDefenseDamage = false; } } + + // Chalice of the Blood God is implemented as a dirty modifier. + // + // Chalice of the Blood God does nothing to a hit that was just fully blocked by shields. + // Otherwise, it reduces the damage of any hit to 5, which allows for full iframes. + // It then applies the full hit (minus that 5 damage) to its own bleedout buffer. + // Hits for less than 5 damage are ignored entirely and allowed to strike the player as normal. + if (chaliceOfTheBloodGod && !freeDodgeFromShieldAbsorption && info.Damage > ChaliceOfTheBloodGod.MinAllowedDamage) + { + int bleedoutToApply = info.Damage - ChaliceOfTheBloodGod.MinAllowedDamage; + chaliceBleedoutBuffer += bleedoutToApply; + info.Damage = ChaliceOfTheBloodGod.MinAllowedDamage; + + // Display text indicating that damage was transferred to bleedout. + string text = $"({-bleedoutToApply})"; + Rectangle location = new Rectangle((int)Player.position.X + 4, (int)Player.position.Y - 3, Player.width - 4, Player.height - 4); + CombatText.NewText(location, ChaliceOfTheBloodGod.BleedoutBufferDamageTextColor, Language.GetTextValue(text), dot: true); + } } #endregion @@ -1912,13 +1945,46 @@ namespace CalamityMod.CalPlayer hasIFrames = true; // If the player was just hit by something capable of dealing defense damage, then apply defense damage. + // Bloodflare Core makes every hit deal defense damage (to enable its function). // Defense damage is not applied if the player has iframes. - if (justHitByDefenseDamage && !hasIFrames && !Player.creativeGodMode) + bool hitCanApplyDefenseDamage = nextHitDealsDefenseDamage || bloodflareCore; + + if (hitCanApplyDefenseDamage && !hasIFrames && !Player.creativeGodMode) { - DealDefenseDamage(defenseDamageToTake, hurtInfo.Damage); + double halfDefense = Player.statDefense / 2.0; + int netMitigation = hurtInfo.SourceDamage - hurtInfo.Damage; + double standardDefenseDamage = netMitigation * defenseDamageRatio; + + // If Bloodflare Core is equipped and standard defense damage would be less than half the player's total defense, + // then instead forcibly deal half of the player's total defense as defense damage. + if (bloodflareCore && standardDefenseDamage < halfDefense) + { + DealDefenseDamage(hurtInfo, (int)halfDefense, true); + + // Set up Bloodflare Core's heal over time. Any in-progress heals are overwritten if they would have a shorter duration. + if (bloodflareCoreRemainingHealOverTime < halfDefense) + bloodflareCoreRemainingHealOverTime = (int)halfDefense; + + // Play a sound and make dust to signify that defense has been shattered + SoundEngine.PlaySound(SoundID.DD2_MonkStaffGroundImpact, Player.Center); + for (int i = 0; i < 36; ++i) + { + float speed = Main.rand.NextFloat(1.8f, 8f); + Vector2 dustVel = new Vector2(speed, speed); + Dust d = Dust.NewDustDirect(Player.position, Player.width, Player.height, 90); + d.velocity = dustVel; + d.noGravity = true; + d.scale *= Main.rand.NextFloat(1.1f, 1.4f); + Dust.CloneDust(d).velocity = dustVel.RotatedBy(MathHelper.PiOver2); + Dust.CloneDust(d).velocity = dustVel.RotatedBy(MathHelper.Pi); + Dust.CloneDust(d).velocity = dustVel.RotatedBy(MathHelper.Pi * 1.5f); + } + } + else + DealDefenseDamage(hurtInfo); } - justHitByDefenseDamage = false; - defenseDamageToTake = 0; + + nextHitDealsDefenseDamage = false; #endregion #region Shattered Community Rage Gain @@ -2291,39 +2357,6 @@ namespace CalamityMod.CalPlayer if (silverMedkit && hurtInfo.Damage >= SilverArmorSetChange.SetBonusMinimumDamageToHeal) silverMedkitTimer = SilverArmorSetChange.SetBonusHealTime; - // Bloodflare Core defense shattering - if (bloodflareCore) - { - // Shattered defense has a hard cap equal to half of total defense. - // It also has a soft cap determined by a formula so it isn't too powerful at excessively high defense. - int shatterDefenseCap = (int)(1.5D * Math.Pow(Player.statDefense, 0.91D) - 0.5D * Player.statDefense); - if (shatterDefenseCap > Player.statDefense / 2) - shatterDefenseCap = Player.statDefense / 2; - - // Every hit adds its damage as shattered defense. - int newLostDefense = Math.Min(bloodflareCoreLostDefense + (int)hurtInfo.Damage, shatterDefenseCap); - - // Suddenly reducing your base defense stat does not let you suddenly reduce your shattered defense cap. - // In other words, you can't ever reduce your lost defense by taking another hit. - if (bloodflareCoreLostDefense < newLostDefense) - bloodflareCoreLostDefense = newLostDefense; - - // Play a sound and make dust to signify that defense has been shattered - SoundEngine.PlaySound(SoundID.DD2_MonkStaffGroundImpact, Player.Center); - for (int i = 0; i < 36; ++i) - { - float speed = Main.rand.NextFloat(1.8f, 8f); - Vector2 dustVel = new Vector2(speed, speed); - Dust d = Dust.NewDustDirect(Player.position, Player.width, Player.height, 90); - d.velocity = dustVel; - d.noGravity = true; - d.scale *= Main.rand.NextFloat(1.1f, 1.4f); - Dust.CloneDust(d).velocity = dustVel.RotatedBy(MathHelper.PiOver2); - Dust.CloneDust(d).velocity = dustVel.RotatedBy(MathHelper.Pi); - Dust.CloneDust(d).velocity = dustVel.RotatedBy(MathHelper.Pi * 1.5f); - } - } - // Handle hit effects from the gem tech armor set. Player.Calamity().GemTechState.PlayerOnHitEffects((int)hurtInfo.Damage); @@ -2365,7 +2398,10 @@ namespace CalamityMod.CalPlayer var source = Player.GetSource_OnHurt(hurtInfo.DamageSource, AerospecBreastplate.FeatherEntitySourceContext); for (int n = 0; n < 4; n++) { - int featherDamage = (int)Player.GetBestClassDamage().ApplyTo(20); + int featherDamage = (int)Player.GetBestClassDamage().ApplyTo(80); + if (oldFashioned) + featherDamage = CalamityUtils.CalcOldFashionedDamage(featherDamage); + CalamityUtils.ProjectileRain(source, Player.Center, 400f, 100f, 500f, 800f, 20f, ModContent.ProjectileType(), featherDamage, 1f, Player.whoAmI); } } @@ -2375,6 +2411,12 @@ namespace CalamityMod.CalPlayer SoundEngine.PlaySound(SoundID.Item74, Player.Center); int blazeDamage = (int)Player.GetBestClassDamage().ApplyTo(25); int astralStarDamage = (int)Player.GetBestClassDamage().ApplyTo(320); + if (oldFashioned) + { + blazeDamage = CalamityUtils.CalcOldFashionedDamage(blazeDamage); + astralStarDamage = CalamityUtils.CalcOldFashionedDamage(astralStarDamage); + } + Projectile.NewProjectile(source, Player.Center.X, Player.Center.Y, 0f, 0f, ModContent.ProjectileType(), blazeDamage, 5f, Player.whoAmI, 0f, 1f); for (int n = 0; n < 12; n++) { @@ -2387,6 +2429,9 @@ namespace CalamityMod.CalPlayer for (int n = 0; n < 3; n++) { int deificStarDamage = (int)Player.GetBestClassDamage().ApplyTo(130); + if (oldFashioned) + deificStarDamage = CalamityUtils.CalcOldFashionedDamage(deificStarDamage); + Projectile star = CalamityUtils.ProjectileRain(source, Player.Center, 400f, 100f, 500f, 800f, 29f, ProjectileID.StarVeilStar, deificStarDamage, 4f, Player.whoAmI); if (star.whoAmI.WithinBounds(Main.maxProjectiles)) { @@ -2412,6 +2457,9 @@ namespace CalamityMod.CalPlayer if (transformer) sDamage += 42; sDamage = (int)Player.GetBestClassDamage().ApplyTo(sDamage); + if (oldFashioned) + sDamage = CalamityUtils.CalcOldFashionedDamage(sDamage); + if (Player.whoAmI == Main.myPlayer) { for (int i = 0; i < 4; i++) @@ -2455,7 +2503,10 @@ namespace CalamityMod.CalPlayer if (hurtInfo.Damage > 0) { SoundEngine.PlaySound(SoundID.Item74, Player.Center); - int eDamage = (int)Player.GetBestClassDamage().ApplyTo(100); + int eDamage = (int)Player.GetBestClassDamage().ApplyTo(300); + if (oldFashioned) + eDamage = CalamityUtils.CalcOldFashionedDamage(eDamage); + if (Player.whoAmI == Main.myPlayer) Projectile.NewProjectile(fuckYouBitch, Player.Center, Vector2.Zero, ModContent.ProjectileType(), eDamage, 1f, Player.whoAmI, 0f, 0f); } @@ -2470,7 +2521,10 @@ namespace CalamityMod.CalPlayer double startAngle = Math.Atan2(Player.velocity.X, Player.velocity.Y) - spread / 2; double deltaAngle = spread / 8f; double offsetAngle; - int sDamage = (int)Player.GetTotalDamage().ApplyTo(27); + int sDamage = (int)Player.GetTotalDamage().ApplyTo(90); + if (oldFashioned) + sDamage = CalamityUtils.CalcOldFashionedDamage(sDamage); + if (Player.whoAmI == Main.myPlayer) { for (int i = 0; i < 8; i++) @@ -2493,7 +2547,10 @@ namespace CalamityMod.CalPlayer var source = Player.GetSource_Misc("23"); if (hurtInfo.Damage > 0) { - int rDamage = (int)Player.GetBestClassDamage().ApplyTo(80); + int rDamage = (int)Player.GetBestClassDamage().ApplyTo(240); + if (oldFashioned) + rDamage = CalamityUtils.CalcOldFashionedDamage(rDamage); + if (Player.whoAmI == Main.myPlayer) Projectile.NewProjectile(source, Player.Center.X, Player.position.Y + 36f, 0f, -18f, ModContent.ProjectileType(), rDamage, 0f, Player.whoAmI, 0f, 0f); } @@ -2509,6 +2566,9 @@ namespace CalamityMod.CalPlayer double deltaAngle = spread / 8f; double offsetAngle; int baseDamage = 675; + if (oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + int shrapnelFinalDamage = (int)Player.GetTotalDamage().ApplyTo(baseDamage); if (Player.whoAmI == Main.myPlayer) { @@ -2530,6 +2590,9 @@ namespace CalamityMod.CalPlayer for (int l = 0; l < 2; l++) { int shadowbeamDamage = (int)Player.GetBestClassDamage().ApplyTo(3000); + if (oldFashioned) + shadowbeamDamage = CalamityUtils.CalcOldFashionedDamage(shadowbeamDamage); + Projectile beam = CalamityUtils.ProjectileRain(source, Player.Center, 400f, 100f, 500f, 800f, 22f, ProjectileID.ShadowBeamFriendly, shadowbeamDamage, 7f, Player.whoAmI); if (beam.whoAmI.WithinBounds(Main.maxProjectiles)) { @@ -2541,6 +2604,9 @@ namespace CalamityMod.CalPlayer for (int l = 0; l < 5; l++) { int scytheDamage = (int)Player.GetBestClassDamage().ApplyTo(5000); + if (oldFashioned) + scytheDamage = CalamityUtils.CalcOldFashionedDamage(scytheDamage); + Projectile scythe = CalamityUtils.ProjectileRain(source, Player.Center, 400f, 100f, 500f, 800f, 22f, ProjectileID.DemonScythe, scytheDamage, 7f, Player.whoAmI); if (scythe.whoAmI.WithinBounds(Main.maxProjectiles)) { @@ -2581,18 +2647,18 @@ namespace CalamityMod.CalPlayer { if (Player.inventory[i].stack > 0 && ((Player.inventory[i].type >= ItemID.LargeAmethyst && Player.inventory[i].type <= ItemID.LargeDiamond) || Player.inventory[i].type == ItemID.LargeAmber)) { - int num = Item.NewItem(source, (int)Player.position.X, (int)Player.position.Y, Player.width, Player.height, Player.inventory[i].type, 1, false, 0, false, false); - Main.item[num].netDefaults(Player.inventory[i].netID); - Main.item[num].Prefix((int)Player.inventory[i].prefix); - Main.item[num].stack = Player.inventory[i].stack; - Main.item[num].velocity.Y = (float)Main.rand.Next(-20, 1) * 0.2f; - Main.item[num].velocity.X = (float)Main.rand.Next(-20, 21) * 0.2f; - Main.item[num].noGrabDelay = 100; - Main.item[num].favorited = false; - Main.item[num].newAndShiny = false; + int droppedLargeGem = Item.NewItem(source, (int)Player.position.X, (int)Player.position.Y, Player.width, Player.height, Player.inventory[i].type, 1, false, 0, false, false); + Main.item[droppedLargeGem].netDefaults(Player.inventory[i].netID); + Main.item[droppedLargeGem].Prefix((int)Player.inventory[i].prefix); + Main.item[droppedLargeGem].stack = Player.inventory[i].stack; + Main.item[droppedLargeGem].velocity.Y = (float)Main.rand.Next(-20, 1) * 0.2f; + Main.item[droppedLargeGem].velocity.X = (float)Main.rand.Next(-20, 21) * 0.2f; + Main.item[droppedLargeGem].noGrabDelay = 100; + Main.item[droppedLargeGem].favorited = false; + Main.item[droppedLargeGem].newAndShiny = false; if (Main.netMode == NetmodeID.MultiplayerClient) { - NetMessage.SendData(MessageID.SyncItem, -1, -1, null, num, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncItem, -1, -1, null, droppedLargeGem, 0f, 0f, 0f, 0, 0, 0); } Player.inventory[i].SetDefaults(0, false); } @@ -2682,37 +2748,70 @@ namespace CalamityMod.CalPlayer #endregion #region Defense Damage Function - private void DealDefenseDamage(int damage, double realDamage) + /// + /// Deals Calamity defense damage to a player. + /// + /// HurtInfo of the incoming strike to the player. + /// If set to zero or a positive number, ignores the HurtInfo and uses this value as the incoming damage. + /// If true, deals exactly the custom amount defense damage, ignoring the standard ratios and Draedon's Heart.
+ /// This also bypasses the + /// This does nothing unless customIncomingDefenseDamage is specified. + public void DealDefenseDamage(Player.HurtInfo hurtInfo, int customIncomingDamage = -1, bool absolute = false) { - if (realDamage <= 0) + // Legacy safeguard: Skip defense damage if the player is somehow "hit for zero" (this should never happen). + if (hurtInfo.Damage <= 0 || hurtInfo.SourceDamage <= 0) return; - double ratioToUse = DefenseDamageRatio; - if (draedonsHeart) - ratioToUse *= DraedonsHeart.DefenseDamageMultiplier; + double ratioToUse = defenseDamageRatio; // Calculate the defense damage taken from this hit. - int defenseDamageTaken = (int)(damage * ratioToUse); + // If custom incoming defense damage is specified, then ignore the incoming hurt info and use the custom value. + int incomingDamageToUse; + if (customIncomingDamage >= 0) + { + incomingDamageToUse = customIncomingDamage; + // If absolute is specified, then ignore the ratio and always inflict EXACTLY THAT MUCH defense damage. This means it bypasses Draedon's Heart! + if (absolute) + ratioToUse = 1D; + } + + // Standard hits. Defense damage scales with "net mitigation", aka how much damage the player DIDN'T take. + // Thematically, this means it scales with how much damage the player's defense took instead of them. + else + { + int netMitigation = hurtInfo.SourceDamage - hurtInfo.Damage; + + // If the player somehow took amplified damage (their mitigation was negative) then they take no base defense damage. + // The defense damage floor will still apply to them. + incomingDamageToUse = netMitigation <= 0 ? 0 : netMitigation; + } + + int defenseDamageTaken = (int)Math.Round(incomingDamageToUse * ratioToUse); // There is a floor on defense damage based on difficulty; i.e. there is a minimum amount of defense damage from any hit that can deal defense damage. - // This floor is only applied if bosses are alive - if (areThereAnyDamnBosses) + // This floor is only applied if bosses are alive, but is bypassed by the absolute flag. + // Details on the floor can be seen in the BalancingConstants file. + bool useDefenseDamageFloor = areThereAnyDamnBosses && !absolute; + if (useDefenseDamageFloor) { - int defenseDamageFloor = (BossRushEvent.BossRushActive ? 5 : CalamityWorld.death ? 4 : CalamityWorld.revenge ? 3 : Main.expertMode ? 2 : 1) * (NPC.downedMoonlord ? 3 : Main.hardMode ? 2 : 1); + int defenseDamageFloor = CalamityUtils.GetDefenseDamageFloor(); + + // Apply floor if (defenseDamageTaken < defenseDamageFloor) defenseDamageTaken = defenseDamageFloor; } - // There is also a cap on defense damage: 25% of the player's original defense. - int cap = Player.statDefense / 4; - if (defenseDamageTaken > cap) - defenseDamageTaken = cap; - - // Apply defense damage to the adamantite armor set boost. + // + // The amount of defense damage taken is now final. + // + + // Apply incoming defense damage to the Adamantite armor set bonus. if (AdamantiteSetDefenseBoost > 0) { int defenseDamageToAdamantite = Math.Min(AdamantiteSetDefenseBoost, defenseDamageTaken); AdamantiteSetDefenseBoost -= defenseDamageToAdamantite; + + // Reduce remaining defense damage by whatever was applied to Adamantite armor. defenseDamageTaken -= defenseDamageToAdamantite; // If Adamantite Armor's set bonus entirely absorbed the defense damage, then display the number and play the sound, @@ -2724,7 +2823,7 @@ namespace CalamityMod.CalPlayer } } - // Apply that defense damage on top of whatever defense damage the player currently has. + // Apply incoming defense damage on top of whatever defense damage the player currently has. int previousDefenseDamage = CurrentDefenseDamage; totalDefenseDamage = previousDefenseDamage + defenseDamageTaken; @@ -2732,15 +2831,16 @@ namespace CalamityMod.CalPlayer if (defenseDamageRecoveryFrames < 0) defenseDamageRecoveryFrames = 0; - // DIRECTLY ADD the base defense damage recovery time to whatever recovery time the player already has. + // Directly add the base defense damage recovery time to whatever recovery time the player already has. totalDefenseDamageRecoveryFrames = defenseDamageRecoveryFrames + DefenseDamageBaseRecoveryTime; if (totalDefenseDamageRecoveryFrames > DefenseDamageMaxRecoveryTime) totalDefenseDamageRecoveryFrames = DefenseDamageMaxRecoveryTime; + // Reset any recovery progress they may have already made. // They start the new recovery timer from the beginning. defenseDamageRecoveryFrames = totalDefenseDamageRecoveryFrames; - // Reset the delay between iframes and being able to recover from defense damage. + // Reset the delay between iframes ending and defense damage recovery starting. defenseDamageDelayFrames = DefenseDamageRecoveryDelay; // Audiovisual effects diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index 05886270c4..c7ec23ee84 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -11,7 +11,6 @@ using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; -using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; @@ -99,6 +98,7 @@ namespace CalamityMod.CalPlayer ApplyDoTDebuff(weakBrimstoneFlames, 7); ApplyDoTDebuff(bBlood, 8, purity); ApplyDoTDebuff(brainRot, 8, purity); + ApplyDoTDebuff(elementalMix, 50, purity); ApplyDoTDebuff(vaporfied, 8, purity); ApplyDoTDebuff(bFlames, abaddon ? 10 : 30, purity); ApplyDoTDebuff(nightwither, reducedNightwitherDamage ? 20 : 40, purity); @@ -228,6 +228,10 @@ namespace CalamityMod.CalPlayer { alcoholPoisonLevel++; } + if (oldFashioned) + { + alcoholPoisonLevel++; + } if (margarita) { alcoholPoisonLevel++; @@ -586,6 +590,10 @@ namespace CalamityMod.CalPlayer Player.mount.Dismount(Player); } #endregion + + // Chalice of the Blood God bleedout + // The bleedout is applied by directly reducing the player's health. It is not canceled by anything. + ChaliceOfTheBloodGod.HandleBleedout(Player); } #endregion @@ -714,10 +722,6 @@ namespace CalamityMod.CalPlayer { Player.lifeRegen += 2; } - if (bloodPactBoost) - { - Player.lifeRegen += 2; - } if (avertorBonus) { Player.lifeRegen += 4; diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 66b3d7fa16..865807daac 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -44,7 +44,6 @@ using CalamityMod.NPCs.Other; using CalamityMod.NPCs.PlagueEnemies; using CalamityMod.NPCs.TownNPCs; using CalamityMod.Particles; -using CalamityMod.Projectiles.Healing; using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Rogue; @@ -126,7 +125,7 @@ namespace CalamityMod.CalPlayer // Update energy shields EnergyShields(); - // Defense manipulation (Mostly defense damage, but also Bloodflare Core and others) + // Defense manipulation (Mostly defense damage, but also other defense changes) DefenseEffects(); // Limits @@ -188,6 +187,9 @@ namespace CalamityMod.CalPlayer if (Player.ActiveItem().type == ModContent.ItemType()) heldGaelsLastFrame = true; + if (Player.ActiveItem().type != ModContent.ItemType()) + saharaSlicersBolts = 0; + // De-equipping Gael's Greatsword deletes all rage. else if (heldGaelsLastFrame) { @@ -227,13 +229,19 @@ namespace CalamityMod.CalPlayer if (lAmbergris) { + if (Player.miscCounter % 3 == 2 && Player.dashDelay > 0) // Reduced dash cooldown by 33% + Player.dashDelay--; + if (Player.dashDelay == -1)// TODO: prevent working with special dashes, this was inconsitent with my old solution so I didn't keep it. not huge deal) { - Player.endurance += 0.05f; if (!HasIncreasedDashFirstFrame) { - Player.velocity.X *= 1.15f; - Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center + Player.velocity * 1.5f, Vector2.Zero, ModContent.ProjectileType(), 75, 20f, Player.whoAmI); + Player.velocity.X *= 1.2f; + int damage = 75; + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + + Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center + Player.velocity * 1.5f, Vector2.Zero, ModContent.ProjectileType(), damage, 20f, Player.whoAmI); HasIncreasedDashFirstFrame = true; } float numberOfDusts = 10f; @@ -253,14 +261,20 @@ namespace CalamityMod.CalPlayer { float sparkscale = (Player.velocity.X * Player.direction * 0.07f); Vector2 SparkVelocity1 = Player.velocity.RotatedBy(Player.direction * 2, default) * 0.1f - Player.velocity / 2f; - SparkParticle spark = new SparkParticle(Player.Center + Player.velocity.RotatedBy(2f * Player.direction) * 1.5f, SparkVelocity1, false, Main.rand.Next(11, 13), sparkscale, Main.rand.NextBool() ? Color.DarkTurquoise : Color.DodgerBlue); + LineParticle spark = new LineParticle(Player.Center + Player.velocity.RotatedBy(2f * Player.direction) * 1.5f, SparkVelocity1, false, Main.rand.Next(11, 13), sparkscale, Main.rand.NextBool() ? Color.DarkTurquoise : Color.DodgerBlue); GeneralParticleHandler.SpawnParticle(spark); Vector2 SparkVelocity2 = Player.velocity.RotatedBy(Player.direction * -2, default) * 0.1f - Player.velocity / 2f; - 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.DarkTurquoise : Color.DodgerBlue); + LineParticle spark2 = new LineParticle(Player.Center + Player.velocity.RotatedBy(-2f * Player.direction) * 1.5f, SparkVelocity2, false, Main.rand.Next(11, 13), sparkscale, Main.rand.NextBool() ? Color.DarkTurquoise : Color.DodgerBlue); GeneralParticleHandler.SpawnParticle(spark2); } if (Player.miscCounter % 4 == 0 && Player.velocity != Vector2.Zero) //every other frame spawn the hitbox - Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center + Player.velocity * 1.5f, Vector2.Zero, ModContent.ProjectileType(), 90, 0f, Player.whoAmI); + { + int damage = 90; + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + + Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center + Player.velocity * 1.5f, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Player.whoAmI); + } } else HasIncreasedDashFirstFrame = false; @@ -270,11 +284,15 @@ namespace CalamityMod.CalPlayer { if (Player.dashDelay == -1)// TODO: prevent working with special dashes, this was inconsitent with my old solution so I didn't keep it. not huge deal) { - Player.endurance += 0.05f; + Player.endurance += 0.1f; if (!HasReducedDashFirstFrame) // Dash isn't reduced, this is used to determine the first frame of dashing { SoundEngine.PlaySound(SoundID.DD2_BetsyFireballImpact with { Volume = 0.4f , PitchVariance = 0.4f }, Player.Center); - Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center + Player.velocity * 1.5f, Vector2.Zero, ModContent.ProjectileType(), 67, 16f, Player.whoAmI); + int damage = 67; + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + + Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center + Player.velocity * 1.5f, Vector2.Zero, ModContent.ProjectileType(), damage, 16f, Player.whoAmI); HasReducedDashFirstFrame = true; } float numberOfDusts = 10f; @@ -299,7 +317,13 @@ namespace CalamityMod.CalPlayer GeneralParticleHandler.SpawnParticle(spark2); if (Player.miscCounter % 5 == 0 && Player.velocity != Vector2.Zero) //every other frame spawn the hitbox - Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center + Player.velocity * 1.5f, Vector2.Zero, ModContent.ProjectileType(), 175, 10f, Player.whoAmI); + { + int damage = 175; + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + + Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center + Player.velocity * 1.5f, Vector2.Zero, ModContent.ProjectileType(), damage, 10f, Player.whoAmI); + } } else HasReducedDashFirstFrame = false; @@ -319,6 +343,28 @@ namespace CalamityMod.CalPlayer else HasReducedDashFirstFrame = false; } + + if (oceanCrest) + { + bool surface = Player.Center.Y < Main.worldSurface * 16.0; + bool GetEffects = ((Main.raining && surface) || Player.dripping || (Player.wet && !Player.lavaWet && !Player.honeyWet)); + if (GetEffects) + { + if (oceanCrestTimer < 300) + oceanCrestTimer += 5; + if (Player.StandingStill(0.1f) && !ZoneAbyss && Player.breath < 201 && Player.miscCounter % 2 == 0) + Player.breath += 1; + } + else + if (oceanCrestTimer > 0) + oceanCrestTimer--; + + if (oceanCrestTimer > 0 || GetEffects) + Player.pickSpeed -= 0.15f; // 15% mining speed + + Vector3 Light = new Vector3(0.090f, 0.180f, 0.200f); + Lighting.AddLight(Player.Center, Light * (0.55f + (oceanCrestTimer * 0.0035f))); + } } #endregion @@ -895,8 +941,8 @@ namespace CalamityMod.CalPlayer providenceBurnIntensity = (Main.npc[CalamityGlobalNPC.holyBoss].ModNPC as ProvidenceBoss).CalculateBurnIntensity(); ProvidenceBurnEffectDrawer.ParticleSpawnRate = int.MaxValue; - // If the burn intensity is great enough, cause the player to ignite into flames. - if (providenceBurnIntensity > 0.45f) + // If the player has holy inferno, cause the player to ignite into flames. + if (hInferno) ProvidenceBurnEffectDrawer.ParticleSpawnRate = 1; // Otherwise, if the intensity is too weak, but still present, cause the player to release holy cinders. @@ -907,17 +953,24 @@ namespace CalamityMod.CalPlayer { if (!Main.rand.NextBool(3)) continue; - - Dust holyCinder = Dust.NewDustDirect(Player.position, Player.width, Player.head, (int)CalamityDusts.ProfanedFire); + + Dust holyCinder = Dust.NewDustDirect(Player.position, Player.width, Player.height, (int)CalamityDusts.ProfanedFire); holyCinder.velocity = Main.rand.NextVector2Circular(3.5f, 3.5f); holyCinder.velocity.Y -= Main.rand.NextFloat(1f, 3f); holyCinder.scale = Main.rand.NextFloat(1.15f, 1.45f); holyCinder.noGravity = true; } } - ProvidenceBurnEffectDrawer.Update(); + if (hInferno && holyInfernoFadeIntensity < 1f) + { + holyInfernoFadeIntensity = MathHelper.Clamp(holyInfernoFadeIntensity + 0.015f, 0f, 1f); + } + else if (!hInferno && holyInfernoFadeIntensity > 0f) + { + holyInfernoFadeIntensity = MathHelper.Clamp(holyInfernoFadeIntensity - 0.01f, 0f, 1f); + } // Transformer immunity to Electrified if (transformer) Player.buffImmune[BuffID.Electrified] = true; @@ -1101,6 +1154,9 @@ namespace CalamityMod.CalPlayer if (!tentaclesPresent[i]) { int damage = (int)Player.GetBestClassDamage().ApplyTo(390); + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + var source = Player.GetSource_FromThis(OmegaBlueHelmet.TentacleEntitySourceContext); Vector2 vel = new Vector2(Main.rand.Next(-13, 14), Main.rand.Next(-13, 14)) * 0.25f; Projectile.NewProjectile(source, Player.Center, vel, ModContent.ProjectileType(), damage, 8f, Main.myPlayer, Main.rand.Next(120), i); @@ -1156,7 +1212,7 @@ namespace CalamityMod.CalPlayer Vector2 dustLineEnd = Player.Center; Vector2 currentDustPos = default; Vector2 spinningpoint = new Vector2(0f, -3f).RotatedByRandom(MathHelper.Pi); - Vector2 value5 = new Vector2(2.1f, 2f); + Vector2 healerDustVel = new Vector2(2.1f, 2f); Color dustColor = Main.hslToRgb(Main.rgbToHsl(new Color(255, 200, Main.DiscoB)).X, 1f, 0.5f); dustColor.A = 255; for (int i = 0; i < maxHealDustIterations; i++) @@ -1164,18 +1220,18 @@ namespace CalamityMod.CalPlayer if (i % dustDivisor == 0) { currentDustPos = Vector2.Lerp(dustLineStart, dustLineEnd, i / (float)maxHealDustIterations); - int dust = Dust.NewDust(currentDustPos, 0, 0, 267, 0f, 0f, 0, dustColor, 1f); - Main.dust[dust].position = currentDustPos; - Main.dust[dust].velocity = spinningpoint.RotatedBy(MathHelper.TwoPi * i / maxHealDustIterations) * value5 * (0.8f + Main.rand.NextFloat() * 0.4f) + Player.velocity; - Main.dust[dust].noGravity = true; - Main.dust[dust].scale = 1f; - Main.dust[dust].fadeIn = Main.rand.NextFloat() * 2f; - Dust dust2 = Dust.CloneDust(dust); - Dust dust3 = dust2; - dust3.scale /= 2f; - dust3 = dust2; - dust3.fadeIn /= 2f; - dust2.color = new Color(255, 255, 255, 255); + int holyDust = Dust.NewDust(currentDustPos, 0, 0, 267, 0f, 0f, 0, dustColor, 1f); + Main.dust[holyDust].position = currentDustPos; + Main.dust[holyDust].velocity = spinningpoint.RotatedBy(MathHelper.TwoPi * i / maxHealDustIterations) * healerDustVel * (0.8f + Main.rand.NextFloat() * 0.4f) + Player.velocity; + Main.dust[holyDust].noGravity = true; + Main.dust[holyDust].scale = 1f; + Main.dust[holyDust].fadeIn = Main.rand.NextFloat() * 2f; + Dust dustClone = Dust.CloneDust(holyDust); + Dust extraDust = dustClone; + extraDust.scale /= 2f; + extraDust = dustClone; + extraDust.fadeIn /= 2f; + dustClone.color = new Color(255, 255, 255, 255); } } } @@ -1208,7 +1264,11 @@ namespace CalamityMod.CalPlayer { unstableSelectedTarget = Main.npc[target]; unstableSelectedTarget.Calamity().arcZapCooldown = 18; - Projectile.NewProjectile(Player.GetSource_FromThis(), new Vector2(Player.Center.X, Player.Center.Y - 20f), new Vector2(0f, -2f), ModContent.ProjectileType(), 18, 0f, Player.whoAmI, target, 3f); + int damage = 18; + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + + Projectile.NewProjectile(Player.GetSource_FromThis(), new Vector2(Player.Center.X, Player.Center.Y - 20f), new Vector2(0f, -2f), ModContent.ProjectileType(), damage, 0f, Player.whoAmI, target, 3f); target = -1; } } @@ -1283,6 +1343,12 @@ namespace CalamityMod.CalPlayer if (expiredCooldowns.Count > 0) SyncCooldownRemoval(Main.netMode == NetmodeID.Server, expiredCooldowns); + if (DragonsBreathAudioCooldown > 0) + DragonsBreathAudioCooldown--; + if (DragonsBreathAudioCooldown2 > 0) + DragonsBreathAudioCooldown2--; + if (PhotoAudioCooldown > 0) + PhotoAudioCooldown--; if (fullRageSoundCountdownTimer > 0) --fullRageSoundCountdownTimer; if (plagueTaintedSMGDroneCooldown > 0) @@ -1345,8 +1411,6 @@ namespace CalamityMod.CalPlayer xerocDmg = 0f; if (hideOfDeusMeleeBoostTimer > 0) hideOfDeusMeleeBoostTimer--; - if (gaelRageAttackCooldown > 0) - gaelRageAttackCooldown--; if (evolutionLifeRegenCounter > 0) evolutionLifeRegenCounter--; if (hurtSoundTimer > 0) @@ -1373,6 +1437,8 @@ namespace CalamityMod.CalPlayer titanCooldown--; if (hideOfDeusTimer > 0) hideOfDeusTimer--; + if (murasamaHitCooldown > 0) + murasamaHitCooldown--; if (hellbornBoost > 0) hellbornBoost--; if (persecutedEnchantSummonTimer < 1800) @@ -1402,10 +1468,11 @@ namespace CalamityMod.CalPlayer if (Player.miscCounter % 100 == 0) canFireBloodflareMageProjectile = true; if (Player.miscCounter % 120 == 0) + canFireAtaxiaRogueProjectile = true; + if (Player.miscCounter % 150 == 0) { canFireGodSlayerRangedProjectile = true; canFireBloodflareRangedProjectile = true; - canFireAtaxiaRogueProjectile = true; } if (reaverRegenCooldown < 60 && reaverRegen) reaverRegenCooldown++; @@ -1733,7 +1800,7 @@ namespace CalamityMod.CalPlayer } Lighting.AddLight((int)(Player.Center.X / 16f), (int)(Player.Center.Y / 16f), light[0], light[1], light[2]); - //Permafrost's Concoction bonuses/debuffs + // Permafrost's Concoction bonuses/debuffs if (permafrostsConcoction) { Player.manaCost *= 0.85f; @@ -1745,7 +1812,7 @@ namespace CalamityMod.CalPlayer Player.statDefense += 30; Player.frozen = true; Player.velocity.X = 0f; - Player.velocity.Y = -0.4f; //should negate gravity + Player.velocity.Y = -0.4f; // Should negate gravity int ice = Dust.NewDust(Player.position, Player.width, Player.height, 88); Main.dust[ice].noGravity = true; @@ -1886,6 +1953,9 @@ namespace CalamityMod.CalPlayer lightningVel.Normalize(); lightningVel *= Main.rand.NextFloat(1f, 2f); int damage = (int)Player.GetTotalDamage().ApplyTo(30); + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + int projectile = Projectile.NewProjectile(source, Player.Center, lightningVel, ModContent.ProjectileType(), damage, 0, Player.whoAmI, Main.rand.Next(2), 0f); Main.projectile[projectile].timeLeft = Main.rand.Next(180, 240); if (projectile.WithinBounds(Main.maxProjectiles)) @@ -1910,6 +1980,9 @@ namespace CalamityMod.CalPlayer cloudVelocity.Normalize(); cloudVelocity *= Main.rand.NextFloat(0f, 1f); int damage = (int)Player.GetTotalDamage().ApplyTo(20); + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + int projectile = Projectile.NewProjectile(source, Player.Center, cloudVelocity, ModContent.ProjectileType(), damage, 0, Player.whoAmI, 0, 0); Main.projectile[projectile].timeLeft = Main.rand.Next(180, 240); if (projectile.WithinBounds(Main.maxProjectiles)) @@ -2056,6 +2129,7 @@ namespace CalamityMod.CalPlayer // Breath Loss Multiplier, depending on gear double breathLossMult = 1D - (Player.gills ? 0.2 : 0D) - // 0.8 + (oceanCrest ? 0.2 : 0D) - // 0.8 (Player.accDivingHelm ? 0.25 : 0D) - // 0.75 (Player.arcticDivingGear ? 0.25 : 0D) - // 0.75 (aquaticEmblem ? 0.25 : 0D) - // 0.75 @@ -2119,6 +2193,7 @@ namespace CalamityMod.CalPlayer // Tick (frame) multiplier, depending on gear double tickMult = 1D + (Player.gills ? 4D : 0D) + // 5 + (oceanCrest ? 4D : 0D) + // 5 (Player.ignoreWater ? 5D : 0D) + // 10 (Player.accDivingHelm ? 10D : 0D) + // 20 (Player.arcticDivingGear ? 10D : 0D) + // 30 @@ -2395,7 +2470,7 @@ namespace CalamityMod.CalPlayer #region Other Buff Effects private void OtherBuffEffects() { - + if (gravityNormalizer) { Player.buffImmune[BuffID.VortexDebuff] = true; @@ -2424,11 +2499,11 @@ namespace CalamityMod.CalPlayer } } - // Cobalt armor set effects. + // Cobalt armor set effects if (CobaltSet) CobaltArmorSetChange.ApplyMovementSpeedBonuses(Player); - // Adamantite armor set effects. + // Adamantite armor set effects if (AdamantiteSet) Player.statDefense += AdamantiteSetDefenseBoost; @@ -2462,7 +2537,7 @@ namespace CalamityMod.CalPlayer Player.GetDamage() += 0.2f; } - if (tFury) + if (brutalCarnage) { Player.GetDamage() += 0.25f; Player.GetCritChance() += 10; @@ -2527,7 +2602,7 @@ namespace CalamityMod.CalPlayer if (tortShell) { if (tortShellPostHit == 1) - SoundEngine.PlaySound(SoundID.NPCHit24 with {Volume = 0.5f}, Player.Center); + SoundEngine.PlaySound(SoundID.NPCHit24 with { Volume = 0.5f }, Player.Center); if (tortShellPostHit > 0) { @@ -2550,22 +2625,41 @@ namespace CalamityMod.CalPlayer if (eGauntlet) { - Player.kbGlove = true; Player.GetDamage() += 0.15f; Player.GetCritChance() += 5; } - if (bloodPactBoost) + // Gauntlet Melee Speed, prevents glove stacking for melee speed + if (gloveLevel > 0) { - Player.GetDamage() += 0.05f; - Player.statDefense += 20; - Player.longInvince = true; - Player.crimsonRegen = true; - healingPotBonus += 0.5f; + // Determine the glove the player benefits from in priority of latest in progression + float gloveAttackSpeed = (gloveLevel == 5 ? 0.15f : gloveLevel == 4 ? 0.14f : gloveLevel == 3 ? 0.12f : gloveLevel <= 2 ? 0.10f : 0); + Player.GetAttackSpeed() += gloveAttackSpeed; // Give the player attack speed based on the glove they have } - // 50% movement speed bonus so that you don't feel like a snail in the early game. - // Disabled while Overhaul is enabled, because Overhaul does very similar things to make movement more snappy. + // Bloodflare Core's heal over time + if (bloodflareCore && bloodflareCoreRemainingHealOverTime > 0 && Player.miscCounter % BloodflareCore.HealFrameCooldown == 0) + { + Player.statLife += 1; + Player.HealEffect(1, false); + + // Produce an implosion of blood themed dust so it's obvious an effect is occurring + for (int i = 0; i < 3; ++i) + { + Vector2 offset = Main.rand.NextVector2Unit() * Main.rand.NextFloat(23f, 33f); + Vector2 dustPos = Player.Center + offset; + Vector2 dustVel = offset * -0.08f; + Dust d = Dust.NewDustDirect(dustPos, 0, 0, 90, 0.08f, 0.08f); + d.velocity = dustVel; + d.noGravity = true; + } + + // Decrement the remaining possible heal over time + --bloodflareCoreRemainingHealOverTime; + } + + // 50% movement speed bonus so that you don't feel like a snail in the early game + // Disabled while Overhaul is enabled, because Overhaul does very similar things to make movement more snappy if (CalamityMod.Instance.overhaul is null && CalamityConfig.Instance.FasterBaseSpeed) Player.moveSpeed += BalancingConstants.DefaultMoveSpeedBoost; @@ -2648,6 +2742,9 @@ namespace CalamityMod.CalPlayer Player.GetCritChance() += MoscowMule.CritBoost; } + if (oldFashioned) + Player.GetDamage() -= OldFashioned.DamageStatReduction; + if (whiteWine) Player.GetDamage() += 0.08f; @@ -2714,6 +2811,7 @@ namespace CalamityMod.CalPlayer (soaring ? 0.1 : 0D) + (prismaticGreaves ? 0.1 : 0D) + (plagueReaper ? 0.05 : 0D) + + (ascendantInsignia ? 0.05 : 0D) + // Added to soaring insignia's flight to get 30% (Player.empressBrooch ? 0.25 : 0D); if (blueCandle) @@ -2736,7 +2834,7 @@ namespace CalamityMod.CalPlayer if (profanedCrystalBuffs) { bool offenseBuffs = pscState == (int)ProfanedSoulCrystal.ProfanedSoulCrystalState.Buffs || (Main.dayTime && !Player.wet) || Player.lavaWet; - if (offenseBuffs) + if (offenseBuffs || pscState == (int)ProfanedSoulCrystal.ProfanedSoulCrystalState.Empowered) flightTimeMult += 0.1; } @@ -2798,9 +2896,6 @@ namespace CalamityMod.CalPlayer Player.findTreasure = true; } - if (shellBoost) - Player.moveSpeed += 0.3f; - if (tarraSet) { if (!tarraMelee) @@ -2950,23 +3045,43 @@ namespace CalamityMod.CalPlayer for (int I = 0; I < 3; I++) { float ai1 = I * 120; - int damage = (int)Player.GetTotalDamage().ApplyTo(3750); + int baseDamage = 3750; + if (oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + int damage = (int)Player.GetTotalDamage().ApplyTo(baseDamage); int projectile = Projectile.NewProjectile(source, Player.Center.X + (float)(Math.Sin(I * 120) * 550), Player.Center.Y + (float)(Math.Cos(I * 120) * 550), 0f, 0f, ModContent.ProjectileType(), damage, 1f, Player.whoAmI, ai1, 0f); if (projectile.WithinBounds(Main.maxProjectiles)) { - Main.projectile[projectile].originalDamage = 3750; + Main.projectile[projectile].originalDamage = baseDamage; Main.projectile[projectile].DamageType = DamageClass.Generic; } } } } - if (yInsignia) + if (ascendantInsignia) { - Player.GetDamage() += 0.15f; - if (Player.statLife <= (int)(Player.statLifeMax2 * 0.5)) - Player.GetDamage() += 0.1f; + if (CalamityKeybinds.AscendantInsigniaHotKey.JustPressed && ascendantInsigniaCooldown <= 0) + { + var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); + Projectile.NewProjectileDirect(source, Player.Center - Vector2.UnitY * 45f, Vector2.Zero, ModContent.ProjectileType(), 0, 0f); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/AscendantActivate")); + ascendantInsigniaCooldown = 2400; + ascendantInsigniaBuffTime = 240; //4 seconds + } + + if (ascendantInsigniaCooldown > 0 && ascendantInsigniaBuffTime <= 0) + ascendantInsigniaCooldown--; + if (ascendantInsigniaBuffTime == 1) + Player.AddCooldown(AscendEffect.ID, 2400); + if (ascendantInsigniaBuffTime > 0) + { + ascendantTrail = true; + infiniteFlight = true; + ascendantInsigniaBuffTime--; + } } if (deepDiver && Player.IsUnderwater()) @@ -3009,6 +3124,9 @@ namespace CalamityMod.CalPlayer { const int BaseDamage = 120; int damage = (int)Player.GetTotalDamage().ApplyTo(BaseDamage); + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + // https://github.com/tModLoader/tModLoader/wiki/IEntitySource#detailed-list var source = Player.GetSource_FromThis(TarragonHeadSummon.LifeAuraEntitySourceContext); float range = 300f; @@ -3080,6 +3198,9 @@ namespace CalamityMod.CalPlayer { const int BaseDamage = 50; int damage = (int)Player.GetBestClassDamage().ApplyTo(BaseDamage); + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + // https://github.com/tModLoader/tModLoader/wiki/IEntitySource#detailed-list var source = Player.GetSource_FromThis(HydrothermicArmor.InfernoPotionEntitySourceContext); float range = 300f; @@ -3117,7 +3238,7 @@ namespace CalamityMod.CalPlayer } if (dArtifact) - Player.GetDamage() += 0.25f; + Player.GetDamage() *= 1.2f; if (trippy) Player.GetDamage() += 0.5f; @@ -3144,6 +3265,8 @@ namespace CalamityMod.CalPlayer int guardianAmt = 1; float babCheck = profanedCrystal ? 1f : 0f; int babDamage = profanedCrystal ? 346 : 52; + if (oldFashioned) + babDamage = CalamityUtils.CalcOldFashionedDamage(babDamage); if (Player.ownedProjectileCounts[ModContent.ProjectileType()] < guardianAmt) { @@ -3174,8 +3297,8 @@ namespace CalamityMod.CalPlayer bool empowered = pscState == (int)ProfanedSoulCrystal.ProfanedSoulCrystalState.Empowered; Player.lavaImmune = true; Player.fireWalk = true; - Player.buffImmune[ModContent.BuffType()] = Main.dayTime; - Player.buffImmune[ModContent.BuffType()] = !Main.dayTime; + Player.buffImmune[ModContent.BuffType()] = Main.dayTime || empowered; + Player.buffImmune[ModContent.BuffType()] = !Main.dayTime || empowered; Player.buffImmune[BuffID.OnFire] = true; Player.buffImmune[BuffID.Burning] = true; Player.buffImmune[BuffID.Daybreak] = true; @@ -3203,39 +3326,6 @@ namespace CalamityMod.CalPlayer } } - if (plaguebringerPistons) - { - //Spawn bees while sprinting or dashing - pistonsCounter++; - if (pistonsCounter % 12 == 0) - { - if (Player.velocity.Length() >= 5f && Player.whoAmI == Main.myPlayer) - { - int beeCount = 1; - if (Main.rand.NextBool(3)) - ++beeCount; - if (Main.rand.NextBool(3)) - ++beeCount; - if (Player.strongBees && Main.rand.NextBool(3)) - ++beeCount; - int damage = (int)Player.GetTotalDamage().ApplyTo(30); - // TODO -- should be from accessory, can't do that because this code is in the wrong place. - // This needs to be part of the update accessory function of the accessory itself to have the right entity source - // https://github.com/tModLoader/tModLoader/wiki/IEntitySource#detailed-list - var source = Player.GetSource_FromThis("PlaguebringerPistonBees"); - for (int index = 0; index < beeCount; ++index) - { - int bee = Projectile.NewProjectile(source, Player.Center.X, Player.Center.Y, Main.rand.NextFloat(-35f, 35f) * 0.02f, Main.rand.NextFloat(-35f, 35f) * 0.02f, (Main.rand.NextBool(4) ? ModContent.ProjectileType() : Player.beeType()), damage, Player.beeKB(0f), Player.whoAmI, 0f, 0f); - Main.projectile[bee].usesLocalNPCImmunity = true; - Main.projectile[bee].localNPCHitCooldown = 10; - Main.projectile[bee].penetrate = 2; - if (bee.WithinBounds(Main.maxProjectiles)) - Main.projectile[bee].DamageType = DamageClass.Generic; - } - } - } - } - List summonDeleteList = new List() { ModContent.ProjectileType(), @@ -3276,6 +3366,9 @@ namespace CalamityMod.CalPlayer { var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); int damage = (int)Player.GetTotalDamage().ApplyTo(30); + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + if (Player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) Projectile.NewProjectile(source, Player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Player.whoAmI, 0f, 0f); } @@ -3335,6 +3428,9 @@ namespace CalamityMod.CalPlayer { var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); int damage = (int)Player.GetBestClassDamage().ApplyTo(70); + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + if (Player.whoAmI == Main.myPlayer && Player.ownedProjectileCounts[ModContent.ProjectileType()] == 0) Projectile.NewProjectile(source, Player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Player.whoAmI); } @@ -3355,6 +3451,9 @@ namespace CalamityMod.CalPlayer { float shootSpeed = 18f; int dmg = (int)Player.GetTotalDamage().ApplyTo(30); + if (oldFashioned) + dmg = CalamityUtils.CalcOldFashionedDamage(dmg); + Vector2 startPos = Player.RotatedRelativePoint(Player.MountedCenter, true); Vector2 velocity = Main.MouseWorld - startPos; if (Player.gravDir == -1f) @@ -3833,7 +3932,7 @@ namespace CalamityMod.CalPlayer // (in addition to the player taking more defense damage, of course). if (totalDefenseDamage > 0) { - //Used to cleanse all defense damage by accessories + // Used to cleanse all defense damage by accessories if (CleansingEffect == 1) { totalDefenseDamage = 0; @@ -3891,39 +3990,6 @@ namespace CalamityMod.CalPlayer Player.statDefense -= currentDefenseDamage; } - // Bloodflare Core's defense reduction - // This is intentionally after defense damage. - // This defense still comes back over time if you take off Bloodflare Core while you're missing defense. - // However, removing the item means you won't get healed as the defense comes back. - ref int lostDef = ref bloodflareCoreLostDefense; - if (lostDef > 0) - { - // Defense regeneration occurs every six frames while defense is missing - if (Player.miscCounter % 6 == 0) - { - --lostDef; - if (bloodflareCore) - { - Player.statLife += 1; - Player.HealEffect(1, false); - - // Produce an implosion of blood themed dust so it's obvious an effect is occurring - for (int i = 0; i < 3; ++i) - { - Vector2 offset = Main.rand.NextVector2Unit() * Main.rand.NextFloat(23f, 33f); - Vector2 dustPos = Player.Center + offset; - Vector2 dustVel = offset * -0.08f; - Dust d = Dust.NewDustDirect(dustPos, 0, 0, 90, 0.08f, 0.08f); - d.velocity = dustVel; - d.noGravity = true; - } - } - } - - // Actually apply Bloodflare Core defense reduction - Player.statDefense -= lostDef; - } - // Defense can never be reduced below zero, no matter what if (Player.statDefense < 0) Player.statDefense *= 0; @@ -4249,7 +4315,7 @@ namespace CalamityMod.CalPlayer Player.potionDelay = potionTimer; if (potionTimer == 1) { - //Reduced duration than normal + // Reduced duration than normal int duration = HadalStew.SicknessDuration; if (Player.pStone) duration = (int)(duration * 0.75); diff --git a/CalPlayer/CalamityPlayerOnHit.cs b/CalPlayer/CalamityPlayerOnHit.cs index 236ef7c293..057fabcfb2 100644 --- a/CalPlayer/CalamityPlayerOnHit.cs +++ b/CalPlayer/CalamityPlayerOnHit.cs @@ -10,6 +10,7 @@ using CalamityMod.EntitySources; using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Prismatic; using CalamityMod.Items.Armor.Reaver; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.NPCs; @@ -23,6 +24,7 @@ using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; +using MonoMod.Cil; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -344,7 +346,11 @@ namespace CalamityMod.CalPlayer ProjectileID.StarCloakStar, ProjectileID.StarCannonStar }); + int astralStarDamage = (int)Player.GetBestClassDamage().ApplyTo(120); + if (oldFashioned) + astralStarDamage = CalamityUtils.CalcOldFashionedDamage(astralStarDamage); + Projectile star = CalamityUtils.ProjectileRain(source, position, 400f, 100f, 500f, 800f, 12f, projectileType, astralStarDamage, 5f, Player.whoAmI); if (star.whoAmI.WithinBounds(Main.maxProjectiles)) star.DamageType = DamageClass.Generic; @@ -360,6 +366,9 @@ namespace CalamityMod.CalPlayer { // Ataxia True Melee Geysers: 15%, softcap starts at 300 base damage int geyserDamage = CalamityUtils.DamageSoftCap(damage * 0.15, 45); + if (oldFashioned) + geyserDamage = CalamityUtils.CalcOldFashionedDamage(geyserDamage); + Projectile.NewProjectile(source, position, Vector2.Zero, ProjectileType(), geyserDamage, 2f, Player.whoAmI, 0f, 0f); } if (soaring) @@ -397,6 +406,9 @@ namespace CalamityMod.CalPlayer if (alchFlask && Player.ownedProjectileCounts[ProjectileType()] < 3 && hasClass) { int seekerDamage = (int)Player.GetBestClassDamage().ApplyTo(30); + if (oldFashioned) + seekerDamage = CalamityUtils.CalcOldFashionedDamage(seekerDamage); + Projectile projectile = CalamityUtils.SpawnOrb(proj, seekerDamage, ProjectileType(), 400f, 12f); if (projectile.whoAmI.WithinBounds(Main.maxProjectiles)) Main.projectile[projectile.whoAmI].DamageType = DamageClass.Generic; @@ -423,7 +435,11 @@ namespace CalamityMod.CalPlayer ProjectileID.StarCloakStar, ProjectileID.StarCannonStar }); + int astralStarDamage = (int)Player.GetBestClassDamage().ApplyTo(120); + if (oldFashioned) + astralStarDamage = CalamityUtils.CalcOldFashionedDamage(astralStarDamage); + Projectile star = CalamityUtils.ProjectileRain(source, position, 400f, 100f, 500f, 800f, 25f, projectileType, astralStarDamage, 5f, Player.whoAmI); if (star.whoAmI.WithinBounds(Main.maxProjectiles)) star.DamageType = DamageClass.Generic; @@ -487,6 +503,9 @@ namespace CalamityMod.CalPlayer { // Ataxia Melee Geysers: 15%, softcap starts at 240 base damage int geyserDamage = CalamityUtils.DamageSoftCap(proj.damage * 0.15, 36); + if (oldFashioned) + geyserDamage = CalamityUtils.CalcOldFashionedDamage(geyserDamage); + Projectile.NewProjectile(source, proj.Center, Vector2.Zero, ProjectileType(), geyserDamage, 0f, Player.whoAmI, 0f, 0f); } if (bloodflareMelee && proj.IsTrueMelee() && bloodflareMeleeHits < 15 && !bloodflareFrenzy && !Player.HasCooldown(BloodflareFrenzy.ID)) @@ -509,6 +528,9 @@ namespace CalamityMod.CalPlayer { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); int leafDamage = (int)(0.25 * proj.damage); + if (oldFashioned) + leafDamage = CalamityUtils.CalcOldFashionedDamage(leafDamage); + int leaf = Projectile.NewProjectile(source, position, velocity, ProjectileID.Leaf, leafDamage, 0f, Player.whoAmI); if (leaf.WithinBounds(Main.maxProjectiles)) { @@ -522,6 +544,9 @@ namespace CalamityMod.CalPlayer { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); int energyDamage = (int)(0.33 * proj.damage); + if (oldFashioned) + energyDamage = CalamityUtils.CalcOldFashionedDamage(energyDamage); + Projectile.NewProjectile(source, proj.Center, velocity, ProjectileType(), energyDamage, 0f, proj.owner); } } @@ -541,6 +566,9 @@ namespace CalamityMod.CalPlayer if (ataxiaMage && ataxiaDmg <= 0) { int orbDamage = (int)(proj.damage * 0.6); + if (oldFashioned) + orbDamage = CalamityUtils.CalcOldFashionedDamage(orbDamage); + CalamityUtils.SpawnOrb(proj, orbDamage, ProjectileType(), 800f, 20f); int cooldown = (int)(orbDamage * 0.5); ataxiaDmg += cooldown; @@ -559,6 +587,9 @@ namespace CalamityMod.CalPlayer Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); // Bloodflare Mage Fireballs: 3 x 50%, softcap starts at 500 base damage to not overly punish slow weapons int bloodflareFireballDamage = CalamityUtils.DamageSoftCap(proj.damage * 0.5, 250); + if (oldFashioned) + bloodflareFireballDamage = CalamityUtils.CalcOldFashionedDamage(bloodflareFireballDamage); + int fire = Projectile.NewProjectile(source, position, velocity, ProjectileID.BallofFire, bloodflareFireballDamage, 0f, Player.whoAmI); if (fire.WithinBounds(Main.maxProjectiles)) { @@ -574,6 +605,9 @@ namespace CalamityMod.CalPlayer SoundEngine.PlaySound(SoundID.Zombie103 , proj.Center); //So scuffed, just because zombie sounds werent ported normally // Silva Mage Blasts: 800 + 60%, softcap on the whole combined thing starts at 1400 int silvaBurstDamage = CalamityUtils.DamageSoftCap(800.0 + 0.6 * proj.damage, 1400); + if (oldFashioned) + silvaBurstDamage = CalamityUtils.CalcOldFashionedDamage(silvaBurstDamage); + Projectile.NewProjectile(source, proj.Center, Vector2.Zero, ProjectileType(), silvaBurstDamage, 8f, Player.whoAmI); } } @@ -613,6 +647,9 @@ namespace CalamityMod.CalPlayer if (Player.ownedProjectileCounts[ProjectileType()] < 3 && Main.rand.NextBool(10)) { int damage = (int)Player.GetTotalDamage().ApplyTo(100); + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + Projectile.NewProjectile(source, proj.position, proj.velocity, ProjectileType(), damage, 1f, Player.whoAmI); } } @@ -669,24 +706,36 @@ namespace CalamityMod.CalPlayer if (nucleogenesis) { int apparatusDamage = (int)Player.GetTotalDamage().ApplyTo(60); + if (oldFashioned) + apparatusDamage = CalamityUtils.CalcOldFashionedDamage(apparatusDamage); + Projectile.NewProjectile(source, proj.Center, Vector2.Zero, ProjectileType(), apparatusDamage, 4f, proj.owner); summonProjCooldown = 100f; } else if (starbusterCore) { int starburstDamage = (int)Player.GetTotalDamage().ApplyTo(40); + if (oldFashioned) + starburstDamage = CalamityUtils.CalcOldFashionedDamage(starburstDamage); + Projectile.NewProjectile(source, proj.Center, Vector2.Zero, ProjectileType(), starburstDamage, 3.5f, proj.owner); summonProjCooldown = 60f; } else if (nuclearFuelRod) { int nuclearDamage = (int)Player.GetTotalDamage().ApplyTo(20); + if (oldFashioned) + nuclearDamage = CalamityUtils.CalcOldFashionedDamage(nuclearDamage); + Projectile.NewProjectile(source, proj.Center, Vector2.Zero, ProjectileType(), nuclearDamage, 0f, proj.owner); summonProjCooldown = 60f; } else if (jellyChargedBattery) { int batteryDamage = (int)Player.GetTotalDamage().ApplyTo(15); + if (oldFashioned) + batteryDamage = CalamityUtils.CalcOldFashionedDamage(batteryDamage); + CalamityUtils.SpawnOrb(proj, batteryDamage, ProjectileType(), 800f, 15f); summonProjCooldown = 60f; } @@ -700,6 +749,9 @@ namespace CalamityMod.CalPlayer Vector2 spawnPosition = position - new Vector2(0f, 920f).RotatedByRandom(0.3f); float speed = Main.rand.NextFloat(17f, 23f); int hallowedDamage = (int)Player.GetTotalDamage().ApplyTo(50); + if (oldFashioned) + hallowedDamage = CalamityUtils.CalcOldFashionedDamage(hallowedDamage); + Projectile.NewProjectile(source, spawnPosition, Vector2.Normalize(position - spawnPosition) * speed, ProjectileType(), hallowedDamage, 3f, proj.owner); } } @@ -716,11 +768,12 @@ namespace CalamityMod.CalPlayer { int damage = (int)Player.GetTotalDamage().ApplyTo(DragonScales.TornadoBaseDamage); + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + int projectileIndex = Projectile.NewProjectile(spawnSource, proj.Center.X, proj.Center.Y, 0f, 0f, ProjectileType(), damage, 15f, Main.myPlayer, 10f, 9f); //First overload seems to deal with timing, second is segment amount if (projectileIndex.WithinBounds(Main.maxProjectiles)) - { Main.projectile[projectileIndex].netUpdate = true; - } } if (crit && tarraThrowing && tarraThrowingCrits < 50 && !tarragonImmunity && !Player.HasCooldown(Cooldowns.TarragonImmunity.ID)) @@ -733,6 +786,9 @@ namespace CalamityMod.CalPlayer case 0: // Exodus Rogue Stars: 80% int starDamage = (int)(proj.damage * 0.8); + if (oldFashioned) + starDamage = CalamityUtils.CalcOldFashionedDamage(starDamage); + CalamityUtils.SpawnOrb(proj, starDamage, ProjectileType(), 800f, Main.rand.Next(15, 30)); xerocDmg += (int)(starDamage * 0.5); break; @@ -740,6 +796,9 @@ namespace CalamityMod.CalPlayer case 1: // Exodus Rogue Orbs: 60% int orbDamage = (int)(proj.damage * 0.6); + if (oldFashioned) + orbDamage = CalamityUtils.CalcOldFashionedDamage(orbDamage); + CalamityUtils.SpawnOrb(proj, orbDamage, ProjectileType(), 800f, 30f); xerocDmg += (int)(orbDamage * 0.5); break; @@ -747,18 +806,27 @@ namespace CalamityMod.CalPlayer case 2: // Exodus Rogue Fire: 15% int fireDamage = (int)(proj.damage * 0.15); + if (oldFashioned) + fireDamage = CalamityUtils.CalcOldFashionedDamage(fireDamage); + Projectile.NewProjectile(spawnSource, proj.Center, Vector2.Zero, ProjectileType(), fireDamage, 0f, proj.owner, 0f, 0f); break; case 3: // Exodus Rogue Blast: 20% int blastDamage = (int)(proj.damage * 0.2); + if (oldFashioned) + blastDamage = CalamityUtils.CalcOldFashionedDamage(blastDamage); + Projectile.NewProjectile(spawnSource, proj.Center, Vector2.Zero, ProjectileType(), blastDamage, 0f, proj.owner, 0f, 0f); break; case 4: // Exodus Rogue Bubble: 60% int bubbleDamage = (int)(proj.damage * 0.6); + if (oldFashioned) + bubbleDamage = CalamityUtils.CalcOldFashionedDamage(bubbleDamage); + CalamityUtils.SpawnOrb(proj, bubbleDamage, ProjectileType(), 800f, 15f); xerocDmg += (int)(bubbleDamage * 0.5); break; @@ -778,12 +846,18 @@ namespace CalamityMod.CalPlayer Vector2 source = new Vector2(position.X + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); Vector2 velocity = (position - source) / 40f; int damage = (int)Player.GetTotalDamage().ApplyTo(120); + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + Projectile.NewProjectile(spawnSource, source, velocity, ProjectileType(), damage, 3f, proj.owner); } } else if (moonCrown) { int lunarFlareDamage = (int)Player.GetTotalDamage().ApplyTo(MoonstoneCrown.BaseDamage); + if (oldFashioned) + lunarFlareDamage = CalamityUtils.CalcOldFashionedDamage(lunarFlareDamage); + float lunarFlareKB = 3f; for (int i = 0; i < 3; i++) { @@ -803,6 +877,9 @@ namespace CalamityMod.CalPlayer float speedY = (position.Y - source.Y) * 8; Vector2 velocity = new Vector2(speedX, speedY); int featherDamage = (int)Player.GetTotalDamage().ApplyTo(25); + if (oldFashioned) + featherDamage = CalamityUtils.CalcOldFashionedDamage(featherDamage); + int feather = Projectile.NewProjectile(spawnSource, source, velocity, ProjectileType(), featherDamage, 3f, proj.owner); if (feather.WithinBounds(Main.maxProjectiles)) { @@ -824,6 +901,9 @@ namespace CalamityMod.CalPlayer xVector *= 10f; yVector *= 10f; int damage = (int)Player.GetTotalDamage().ApplyTo(40); + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + int eater = Projectile.NewProjectile(spawnSource, proj.Center.X, proj.Center.Y, xVector, yVector, ProjectileType(), damage, proj.knockBack, proj.owner); if (eater.WithinBounds(Main.maxProjectiles)) Main.projectile[eater].DamageType = DamageClass.Generic; @@ -834,6 +914,9 @@ namespace CalamityMod.CalPlayer if (titanHeartSet && modProj.stealthStrike && titanCooldown <= 0 && modProj.stealthStrikeHitCount < 3) { int damage = (int)Player.GetTotalDamage().ApplyTo(40); + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + Projectile.NewProjectile(spawnSource, proj.Center, Vector2.Zero, ProjectileType(), damage, proj.knockBack, proj.owner, 1f, 0f); SoundEngine.PlaySound(SoundID.Item14, proj.Center); for (int dustexplode = 0; dustexplode < 360; dustexplode++) @@ -870,6 +953,9 @@ namespace CalamityMod.CalPlayer if (type != -1) { int damage = (int)Player.GetTotalDamage().ApplyTo(24); + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + float speed = Main.rand.NextFloat(5f, 11f); int cloud = Projectile.NewProjectile(spawnSource, position, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * speed, type, damage, proj.knockBack, Player.whoAmI); if (cloud.WithinBounds(Main.maxProjectiles)) @@ -906,6 +992,9 @@ namespace CalamityMod.CalPlayer { // Umbraphile Rogue Blasts: 20%, softcap starts at 50 base damage int umbraBlastDamage = CalamityUtils.DamageSoftCap(proj.damage * 0.20, 50); + if (oldFashioned) + umbraBlastDamage = CalamityUtils.CalcOldFashionedDamage(umbraBlastDamage); + Projectile.NewProjectile(spawnSource, proj.Center, Vector2.Zero, ProjectileType(), umbraBlastDamage, 0f, Player.whoAmI); } if (electricianGlove && modProj.stealthStrike && modProj.stealthStrikeHitCount < 3) @@ -914,6 +1003,9 @@ namespace CalamityMod.CalPlayer { Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f); int damage = (int)Player.GetTotalDamage().ApplyTo(9); + if (oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + int spark = Projectile.NewProjectile(spawnSource, position, velocity, ProjectileType(), damage, 0f, Player.whoAmI); if (spark.WithinBounds(Main.maxProjectiles)) { @@ -935,16 +1027,12 @@ namespace CalamityMod.CalPlayer { if (eGauntlet) { - CalamityUtils.Inflict246DebuffsNPC(target, BuffID.OnFire3); + CalamityUtils.Inflict246DebuffsNPC(target, ModContent.BuffType()); } if (cryogenSoul) { CalamityUtils.Inflict246DebuffsNPC(target, BuffID.Frostburn); } - if (yInsignia) - { - CalamityUtils.Inflict246DebuffsNPC(target, BuffType()); - } if (ataxiaFire) { CalamityUtils.Inflict246DebuffsNPC(target, BuffID.OnFire3, 4f); @@ -1040,7 +1128,7 @@ namespace CalamityMod.CalPlayer } } if (voidOfExtinction) - //CalamityUtils.Inflict246DebuffsNPC(target, BuffType()); + CalamityUtils.Inflict246DebuffsNPC(target, BuffType()); if (frostFlare) CalamityUtils.Inflict246DebuffsNPC(target, BuffID.Frostburn2); if (omegaBlueChestplate) @@ -1109,7 +1197,7 @@ namespace CalamityMod.CalPlayer } } - if (gladiatorSword && !target.IsAnEnemy(false) && target.life <= 0 && target.Calamity().gladiatorOnKill) + if (gladiatorSword && target.IsAnEnemy(false) && target.life <= 0 && target.Calamity().gladiatorOnKill) { target.Calamity().gladiatorOnKill = false; Projectile.NewProjectile(Player.GetSource_FromThis(), target.Center.X, target.Center.Y, target.velocity.X / 2, target.velocity.Y / 2, ModContent.ProjectileType(), 0, 0f); diff --git a/CalPlayer/Dashes/AsgardianAegisDash.cs b/CalPlayer/Dashes/AsgardianAegisDash.cs index 7cc66bec8c..334246d449 100644 --- a/CalPlayer/Dashes/AsgardianAegisDash.cs +++ b/CalPlayer/Dashes/AsgardianAegisDash.cs @@ -3,6 +3,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Enums; using CalamityMod.Items.Accessories; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Particles; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; @@ -73,8 +74,13 @@ namespace CalamityMod.CalPlayer.Dashes hitContext.KnockbackFactor = kbFactor; hitContext.PlayerImmunityFrames = AsgardianAegis.ShieldSlamIFrames; hitContext.Damage = (int)player.GetTotalDamage().ApplyTo(300f); + if (player.Calamity().oldFashioned) + hitContext.Damage = CalamityUtils.CalcOldFashionedDamage(hitContext.Damage); int supremeExplosionDamage = (int)player.GetBestClassDamage().ApplyTo(135); + if (player.Calamity().oldFashioned) + supremeExplosionDamage = CalamityUtils.CalcOldFashionedDamage(supremeExplosionDamage); + Projectile.NewProjectile(source, player.Center, Vector2.Zero, ModContent.ProjectileType(), supremeExplosionDamage, 20f, Main.myPlayer, 3f, 0f); npc.AddBuff(ModContent.BuffType(), 300); } diff --git a/CalPlayer/Dashes/AsgardsValorDash.cs b/CalPlayer/Dashes/AsgardsValorDash.cs index 27368abd27..c929028a13 100644 --- a/CalPlayer/Dashes/AsgardsValorDash.cs +++ b/CalPlayer/Dashes/AsgardsValorDash.cs @@ -2,6 +2,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Enums; using CalamityMod.Items.Accessories; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; @@ -70,8 +71,13 @@ namespace CalamityMod.CalPlayer.Dashes hitContext.KnockbackFactor = kbFactor; hitContext.PlayerImmunityFrames = AsgardsValor.ShieldSlamIFrames; hitContext.Damage = (int)player.GetTotalDamage().ApplyTo(100f); + if (player.Calamity().oldFashioned) + hitContext.Damage = CalamityUtils.CalcOldFashionedDamage(hitContext.Damage); int holyExplosionDamage = (int)player.GetBestClassDamage().ApplyTo(60); + if (player.Calamity().oldFashioned) + holyExplosionDamage = CalamityUtils.CalcOldFashionedDamage(holyExplosionDamage); + Projectile.NewProjectile(source, player.Center, Vector2.Zero, ModContent.ProjectileType(), holyExplosionDamage, 15f, Main.myPlayer, 0f, 0f); npc.AddBuff(ModContent.BuffType(), 180); } diff --git a/CalPlayer/Dashes/ElysianAegisDash.cs b/CalPlayer/Dashes/ElysianAegisDash.cs index 9f46dd1b95..2ea0019aed 100644 --- a/CalPlayer/Dashes/ElysianAegisDash.cs +++ b/CalPlayer/Dashes/ElysianAegisDash.cs @@ -2,6 +2,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Enums; using CalamityMod.Items.Accessories; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; @@ -73,8 +74,13 @@ namespace CalamityMod.CalPlayer.Dashes hitContext.KnockbackFactor = kbFactor; hitContext.PlayerImmunityFrames = ElysianAegis.ShieldSlamIFrames; hitContext.Damage = (int)player.GetTotalDamage().ApplyTo(250f); + if (player.Calamity().oldFashioned) + hitContext.Damage = CalamityUtils.CalcOldFashionedDamage(hitContext.Damage); int supremeExplosionDamage = (int)player.GetBestClassDamage().ApplyTo(120); + if (player.Calamity().oldFashioned) + supremeExplosionDamage = CalamityUtils.CalcOldFashionedDamage(supremeExplosionDamage); + Projectile.NewProjectile(source, player.Center, Vector2.Zero, ModContent.ProjectileType(), supremeExplosionDamage, 15f, Main.myPlayer, 1f, 0f); npc.AddBuff(ModContent.BuffType(), 300); } diff --git a/CalPlayer/Dashes/GodslayerArmorDash.cs b/CalPlayer/Dashes/GodslayerArmorDash.cs index 8fb8b6eb64..1c36714003 100644 --- a/CalPlayer/Dashes/GodslayerArmorDash.cs +++ b/CalPlayer/Dashes/GodslayerArmorDash.cs @@ -3,6 +3,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Enums; using CalamityMod.Items.Armor.GodSlayer; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.NPCs.DevourerofGods; using CalamityMod.Particles; using Microsoft.Xna.Framework; @@ -146,6 +147,8 @@ namespace CalamityMod.CalPlayer.Dashes // This is because its immunity is meant to be completely consistent and not subject to vanilla anticheese. hitContext.PlayerImmunityFrames = GodSlayerChestplate.DashIFrames; hitContext.Damage = (int)player.GetBestClassDamage().ApplyTo(3000f); + if (player.Calamity().oldFashioned) + hitContext.Damage = CalamityUtils.CalcOldFashionedDamage(hitContext.Damage); npc.AddBuff(ModContent.BuffType(), 300); } diff --git a/CalPlayer/Dashes/OrnateShieldDash.cs b/CalPlayer/Dashes/OrnateShieldDash.cs index dc6a380965..44442b569d 100644 --- a/CalPlayer/Dashes/OrnateShieldDash.cs +++ b/CalPlayer/Dashes/OrnateShieldDash.cs @@ -1,6 +1,7 @@ using System; using CalamityMod.Enums; using CalamityMod.Items.Accessories; +using CalamityMod.Items.Potions.Alcohol; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -59,6 +60,8 @@ namespace CalamityMod.CalPlayer.Dashes hitContext.KnockbackFactor = kbFactor; hitContext.PlayerImmunityFrames = OrnateShield.ShieldSlamIFrames; hitContext.Damage = (int)player.GetTotalDamage().ApplyTo(50f); + if (player.Calamity().oldFashioned) + hitContext.Damage = CalamityUtils.CalcOldFashionedDamage(hitContext.Damage); npc.AddBuff(BuffID.Frostburn2, 180); //Great, Frostbite is ACTUALLY called Frostburn 2 } diff --git a/CalPlayer/Dashes/PlaguebringerArmorDash.cs b/CalPlayer/Dashes/PlaguebringerArmorDash.cs index ac567d7484..6b938d8c5f 100644 --- a/CalPlayer/Dashes/PlaguebringerArmorDash.cs +++ b/CalPlayer/Dashes/PlaguebringerArmorDash.cs @@ -1,6 +1,7 @@ using System; using CalamityMod.Enums; using CalamityMod.Items.Accessories; +using CalamityMod.Items.Potions.Alcohol; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -71,6 +72,8 @@ namespace CalamityMod.CalPlayer.Dashes hitContext.KnockbackFactor = kbFactor; hitContext.PlayerImmunityFrames = AsgardsValor.ShieldSlamIFrames; hitContext.Damage = (int)player.GetBestClassDamage().ApplyTo(50f); + if (player.Calamity().oldFashioned) + hitContext.Damage = CalamityUtils.CalcOldFashionedDamage(hitContext.Damage); } } } diff --git a/CalPlayer/Dashes/PlayerDashManager.cs b/CalPlayer/Dashes/PlayerDashManager.cs index c0f3f54b0b..d28827ea6d 100644 --- a/CalPlayer/Dashes/PlayerDashManager.cs +++ b/CalPlayer/Dashes/PlayerDashManager.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Terraria; namespace CalamityMod.CalPlayer.Dashes { @@ -13,6 +14,32 @@ namespace CalamityMod.CalPlayer.Dashes return DashIdentificationTable.TryGetValue(id, out dashEffect); } + // A new function that allows to add in new modded dashes for Calamity to recognize, it attempts + // to make it as safe as possible. + + + /// + /// Attempts to add a dash effect into the dash manager. It should be executed in a Load() function. + /// + /// An instance of the desired dash effect to add. + + public static void TryAddDash(PlayerDashEffect dashEffect) + { + //If DashIdentificationTable is not loaded or modder tries to load an abstract type of + //PlayerDashEffect, then don't add the dash and stop the method. + if (DashIdentificationTable == null || dashEffect.GetType().IsAbstract) return; + + string id = (string)dashEffect.GetType().GetProperty("ID").GetValue(null); + + //This chunk of the code only executes if the dash isn't already added and + //the dash id isn't empty. + if (!DashIdentificationTable.ContainsKey(id) && !String.IsNullOrEmpty(id)) + { + DashIdentificationTable[id] = dashEffect; + } + + } + internal static void Load() { DashIdentificationTable = new(); @@ -32,6 +59,7 @@ namespace CalamityMod.CalPlayer.Dashes } } + internal static void Unload() { DashIdentificationTable = null; diff --git a/CalPlayer/Dashes/StatisVoidSashDash.cs b/CalPlayer/Dashes/StatisVoidSashDash.cs index cc496e1705..d36ae9e5ce 100644 --- a/CalPlayer/Dashes/StatisVoidSashDash.cs +++ b/CalPlayer/Dashes/StatisVoidSashDash.cs @@ -1,4 +1,5 @@ using CalamityMod.Enums; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Particles; using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; @@ -42,6 +43,9 @@ namespace CalamityMod.CalPlayer.Dashes if (Main.myPlayer == player.whoAmI && player.Calamity().statisTimer % 5 == 0) { int scytheDamage = (int)player.GetBestClassDamage().ApplyTo(250); + if (player.Calamity().oldFashioned) + scytheDamage = CalamityUtils.CalcOldFashionedDamage(scytheDamage); + int scythe = Projectile.NewProjectile(player.GetSource_FromAI(), player.Center, player.velocity.RotatedBy(player.direction * (AngleSwap ? 30 : -30), default) * 0.1f - player.velocity / 2f, ModContent.ProjectileType(), scytheDamage, 5f, player.whoAmI);; if (scythe.WithinBounds(Main.maxProjectiles)) { diff --git a/CalPlayer/DrawLayers/AscendedTrailLayer.cs b/CalPlayer/DrawLayers/AscendedTrailLayer.cs new file mode 100644 index 0000000000..3ec0408121 --- /dev/null +++ b/CalPlayer/DrawLayers/AscendedTrailLayer.cs @@ -0,0 +1,46 @@ +using System.Collections.Generic; +using CalamityMod.Items.VanillaArmorChanges; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ModLoader; + +namespace CalamityMod.CalPlayer.DrawLayers +{ + public class AscendantTrailLayer : PlayerDrawLayer + { + public override Position GetDefaultPosition() => new AfterParent(PlayerDrawLayers.LastVanillaLayer); + + public override bool GetDefaultVisibility(PlayerDrawSet drawInfo) + { + Player drawPlayer = drawInfo.drawPlayer; + if (drawInfo.shadow != 0f || drawPlayer.dead || drawPlayer.Calamity().AdrenalineTrail) + return false; + + return drawPlayer.Calamity().ascendantTrail; + } + + protected override void Draw(ref PlayerDrawSet drawInfo) + { + Player drawPlayer = drawInfo.drawPlayer; + List existingDrawData = drawInfo.DrawDataCache; + float movementSpeedInterpolant = CobaltArmorSetChange.CalculateMovementSpeedInterpolant(drawPlayer); + for (float i = 0f; i < drawPlayer.Calamity().OldPositions.Length; i += 1.2f) + { + float completionRatio = i / (float)drawPlayer.Calamity().OldPositions.Length; + float scale = MathHelper.Lerp(1f, 0.7f, completionRatio); + float opacity = MathHelper.Lerp(0.18f, 0.06f, completionRatio) * movementSpeedInterpolant; + List afterimages = new List(); + for (int j = 0; j < existingDrawData.Count; j++) + { + var drawData = existingDrawData[j]; + drawData.position = existingDrawData[j].position - drawPlayer.position + drawPlayer.oldPosition; + drawData.color = Color.Khaki * opacity; + drawData.scale = new Vector2(scale); + afterimages.Add(drawData); + } + drawInfo.DrawDataCache.InsertRange(0, afterimages); + } + } + } +} diff --git a/CalPlayer/DrawLayers/AuricSetTrailLayer.cs b/CalPlayer/DrawLayers/AuricSetTrailLayer.cs index e6f1ec9e73..2ba962f104 100644 --- a/CalPlayer/DrawLayers/AuricSetTrailLayer.cs +++ b/CalPlayer/DrawLayers/AuricSetTrailLayer.cs @@ -14,7 +14,7 @@ namespace CalamityMod.CalPlayer.DrawLayers public override bool GetDefaultVisibility(PlayerDrawSet drawInfo) { Player drawPlayer = drawInfo.drawPlayer; - if (drawInfo.shadow != 0f || drawPlayer.dead || drawPlayer.Calamity().AdrenalineTrail) + if (drawInfo.shadow != 0f || drawPlayer.dead || drawPlayer.Calamity().AdrenalineTrail || drawPlayer.Calamity().ascendantTrail) return false; return drawPlayer.Calamity().auricSet; diff --git a/CalPlayer/DrawLayers/Backpack_HavocsBreath.png b/CalPlayer/DrawLayers/Backpack_HavocsBreath.png index bf5bbda5b7..9748fd090e 100644 Binary files a/CalPlayer/DrawLayers/Backpack_HavocsBreath.png and b/CalPlayer/DrawLayers/Backpack_HavocsBreath.png differ diff --git a/CalPlayer/DrawLayers/CobaltSetTrailLayer.cs b/CalPlayer/DrawLayers/CobaltSetTrailLayer.cs index 3d836cd38d..06da8a818e 100644 --- a/CalPlayer/DrawLayers/CobaltSetTrailLayer.cs +++ b/CalPlayer/DrawLayers/CobaltSetTrailLayer.cs @@ -14,7 +14,7 @@ namespace CalamityMod.CalPlayer.DrawLayers public override bool GetDefaultVisibility(PlayerDrawSet drawInfo) { Player drawPlayer = drawInfo.drawPlayer; - if (drawInfo.shadow != 0f || drawPlayer.dead || drawPlayer.Calamity().AdrenalineTrail) + if (drawInfo.shadow != 0f || drawPlayer.dead || drawPlayer.Calamity().AdrenalineTrail || drawPlayer.Calamity().ascendantTrail) return false; return drawPlayer.Calamity().CobaltSet; diff --git a/CalPlayer/DrawLayers/HatExtensionLayer.cs b/CalPlayer/DrawLayers/HatExtensionLayer.cs index 9c1a8e5141..158ac2ef32 100644 --- a/CalPlayer/DrawLayers/HatExtensionLayer.cs +++ b/CalPlayer/DrawLayers/HatExtensionLayer.cs @@ -4,6 +4,7 @@ using Terraria; using Terraria.ID; using Terraria.DataStructures; using Terraria.ModLoader; +using CalamityMod.Items.Accessories.Vanity; namespace CalamityMod.CalPlayer.DrawLayers { @@ -22,6 +23,9 @@ namespace CalamityMod.CalPlayer.DrawLayers if (drawPlayer.armor[10].type > ItemID.None) headItem = drawPlayer.armor[10]; + if (drawPlayer.Calamity().cocosFeather) + headItem = new Item(ModContent.ItemType()); + if (ModContent.GetModItem(headItem.type) is IExtendedHat extendedHatDrawer) { string equipSlotName = extendedHatDrawer.EquipSlotName(drawPlayer) != "" ? extendedHatDrawer.EquipSlotName(drawPlayer) : headItem.ModItem.Name; diff --git a/CalamityConfig.cs b/CalamityConfig.cs index ba16655a34..4c5685d50d 100644 --- a/CalamityConfig.cs +++ b/CalamityConfig.cs @@ -25,6 +25,7 @@ namespace CalamityMod { BossHealthBoost = Utils.Clamp(BossHealthBoost, MinBossHealthBoost, MaxBossHealthBoost); RipperMeterShake = Utils.Clamp(RipperMeterShake, MinMeterShake, MaxMeterShake); + ParticleLimit = (int)Utils.Clamp(ParticleLimit, MinParticleLimit, MaxParticleLimit); } #region Graphics Changes @@ -34,9 +35,12 @@ namespace CalamityMod [DefaultValue(true)] public bool Afterimages { get; set; } + private const int MinParticleLimit = 100; + private const int MaxParticleLimit = 2000; + [BackgroundColor(192, 54, 64, 192)] [SliderColor(224, 165, 56, 128)] - [Range(0, 1000)] + [Range(MinParticleLimit, MaxParticleLimit)] [DefaultValue(500)] public int ParticleLimit { get; set; } diff --git a/CalamityKeybinds.cs b/CalamityKeybinds.cs index 35b2f08622..9f320901ea 100644 --- a/CalamityKeybinds.cs +++ b/CalamityKeybinds.cs @@ -8,6 +8,7 @@ namespace CalamityMod public static ModKeybind AdrenalineHotKey { get; private set; } public static ModKeybind AngelicAllianceHotKey { get; private set; } public static ModKeybind ArmorSetBonusHotKey { get; private set; } + public static ModKeybind AscendantInsigniaHotKey { get; private set; } public static ModKeybind BoosterDashHotKey { get; private set; } public static ModKeybind DashHotkey { get; private set; } public static ModKeybind ExoChairSlowdownHotkey { get; private set; } @@ -25,6 +26,7 @@ namespace CalamityMod AdrenalineHotKey = KeybindLoader.RegisterKeybind(Mod, "AdrenalineMode", "B"); AngelicAllianceHotKey = KeybindLoader.RegisterKeybind(Mod, "AngelicAllianceBlessing", "G"); ArmorSetBonusHotKey = KeybindLoader.RegisterKeybind(Mod, "ArmorSetBonus", "Y"); + AscendantInsigniaHotKey = KeybindLoader.RegisterKeybind(Mod, "AscendantInsigniaHotKey", "K"); BoosterDashHotKey = KeybindLoader.RegisterKeybind(Mod, "BoosterDash", "Q"); DashHotkey = KeybindLoader.RegisterKeybind(Mod, "DashDoubleTapOverride", "F"); ExoChairSlowdownHotkey = KeybindLoader.RegisterKeybind(Mod, "ExoChairSlowDown", "RightShift"); @@ -42,6 +44,7 @@ namespace CalamityMod AdrenalineHotKey = null; AngelicAllianceHotKey = null; ArmorSetBonusHotKey = null; + AscendantInsigniaHotKey = null; BoosterDashHotKey = null; DashHotkey = null; ExoChairSlowdownHotkey = null; diff --git a/CalamityLists.cs b/CalamityLists.cs index 92e3946b48..d611067855 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -713,7 +713,8 @@ namespace CalamityMod "Spirit Shield", "Briny_Coffee", "_Skeggy_", - "just akkolite" + "just akkolite", + "J.U.N.E.S", }; projectileDestroyExceptionList = new List() @@ -789,7 +790,7 @@ namespace CalamityMod ProjectileType(), ProjectileType(), ProjectileType(), - ProjectileType(), + ProjectileType(), ProjectileType(), ProjectileType(), @@ -1115,6 +1116,7 @@ namespace CalamityMod BuffType(), BuffType(), BuffType(), + BuffType(), BuffType(), BuffType(), BuffType(), @@ -1188,6 +1190,7 @@ namespace CalamityMod BuffType(), BuffType(), BuffType(), + BuffType(), BuffType(), BuffType(), BuffType(), @@ -1495,7 +1498,9 @@ namespace CalamityMod needsDebuffIconDisplayList = new List() { - NPCID.WallofFleshEye + NPCID.TargetDummy, + NPCID.WallofFleshEye, + NPCType() }; // TODO -- override HoldItem => Player.scope = true; on these items @@ -1957,6 +1962,7 @@ namespace CalamityMod { ProjectileID.Arkhalis, ProjectileID.ChargedBlasterLaser, + ProjectileID.ClingerStaff, ProjectileID.FinalFractal, ProjectileID.FlyingKnife, ProjectileID.LastPrismLaser, diff --git a/CalamityMod.cs b/CalamityMod.cs index f5340244a9..ba1d615544 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -49,7 +49,6 @@ using CalamityMod.NPCs.StormWeaver; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.NPCs.Yharon; using CalamityMod.Particles; -using CalamityMod.Particles.Metaballs; using CalamityMod.Projectiles; using CalamityMod.Projectiles.BaseProjectiles; using CalamityMod.Schematics; @@ -306,9 +305,6 @@ namespace CalamityMod Filters.Scene["CalamityMod:Leviathan"] = new Filter(new LevScreenShaderData("FilterMiniTower").UseColor(0f, 0f, 0.5f).UseOpacity(0.5f), EffectPriority.VeryHigh); SkyManager.Instance["CalamityMod:Leviathan"] = new LevSky(); - Filters.Scene["CalamityMod:Providence"] = new Filter(new ProvScreenShaderData("FilterMiniTower").UseColor(0.45f, 0.4f, 0.2f).UseOpacity(0.5f), EffectPriority.VeryHigh); - SkyManager.Instance["CalamityMod:Providence"] = new ProvSky(); - Filters.Scene["CalamityMod:SupremeCalamitas"] = new Filter(new SCalScreenShaderData("FilterMiniTower").UseColor(1.1f, 0.3f, 0.3f).UseOpacity(0.65f), EffectPriority.VeryHigh); SkyManager.Instance["CalamityMod:SupremeCalamitas"] = new SCalSky(); @@ -345,7 +341,6 @@ namespace CalamityMod // However, render targets and certain other graphical objects can only be created on the main thread. Main.QueueMainThreadAction(() => { - FusableParticleManager.LoadParticleRenderSets(); Main.OnPreDraw += PrepareRenderTargets; }); @@ -376,7 +371,7 @@ namespace CalamityMod GameShaders.Hair.BindShader(ModContent.ItemType(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(player.hairColor, new Color(0, 255, 171), ((float)player.Calamity().adrenaline / (float)player.Calamity().adrenalineMax)))); GameShaders.Hair.BindShader(ModContent.ItemType(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(player.hairColor, new Color(255, 83, 48), ((float)player.Calamity().rage / (float)player.Calamity().rageMax)))); GameShaders.Hair.BindShader(ModContent.ItemType(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => - { + { float flightTimeInterpolant = player.wingTime / player.wingTimeMax; if (player.mount.Active) flightTimeInterpolant = 1f; @@ -449,7 +444,6 @@ namespace CalamityMod Main.QueueMainThreadAction(() => { - FusableParticleManager.UnloadParticleRenderSets(); Main.OnPreDraw -= PrepareRenderTargets; }); @@ -499,7 +493,6 @@ namespace CalamityMod public static void PrepareRenderTargets(GameTime gameTime) { - FusableParticleManager.PrepareFusableParticleTargets(); DeathAshParticle.PrepareRenderTargets(); FluidFieldManager.Update(); } @@ -517,7 +510,8 @@ namespace CalamityMod saveMethodInfo.Invoke(null, new object[] { cfg }); else Instance.Logger.Error("TML ConfigManager.Save reflection failed. Method signature has changed. Notify Calamity Devs if you see this in your log."); - } catch + } + catch { Instance.Logger.Error("An error occurred while manually saving Calamity mod configuration. This may be due to a complex mod conflict. It is safe to ignore this error."); } diff --git a/CalamityNetcode.cs b/CalamityNetcode.cs index f2ef54de69..dd9088655a 100644 --- a/CalamityNetcode.cs +++ b/CalamityNetcode.cs @@ -162,6 +162,9 @@ namespace CalamityMod // Tile Entities // + case CalamityModMessageType.UnlockAbyssChests: + Abyss.UnlockAllAbyssChests(); + break; case CalamityModMessageType.PowerCellFactory: TEPowerCellFactory.ReadSyncPacket(mod, reader); break; @@ -359,6 +362,7 @@ namespace CalamityMod UpdateCodebreakerConstituents, UpdateCodebreakerContainedStuff, UpdateCodebreakerDecryptCountdown, + UnlockAbyssChests, // Draedon Summoner CodebreakerSummonStuff, diff --git a/Cooldowns/AscendEffect.cs b/Cooldowns/AscendEffect.cs new file mode 100644 index 0000000000..99a510e208 --- /dev/null +++ b/Cooldowns/AscendEffect.cs @@ -0,0 +1,21 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.Localization; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Cooldowns +{ + public class AscendEffect : CooldownHandler + { + public static new string ID => "AscendEffect"; + public override bool ShouldDisplay => true; + public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); + public override string Texture => "CalamityMod/Cooldowns/AscendEffect"; + public override Color OutlineColor => new Color(50, 50, 50); + public override Color CooldownStartColor => Color.LightGreen; + public override Color CooldownEndColor => Color.Khaki; + + public override SoundStyle? EndSound => new("CalamityMod/Sounds/Item/AscendantOff"); + } +} diff --git a/Cooldowns/AscendEffect.png b/Cooldowns/AscendEffect.png new file mode 100644 index 0000000000..a0ec3de756 Binary files /dev/null and b/Cooldowns/AscendEffect.png differ diff --git a/Cooldowns/AscendEffectOutline.png b/Cooldowns/AscendEffectOutline.png new file mode 100644 index 0000000000..4524cbc7df Binary files /dev/null and b/Cooldowns/AscendEffectOutline.png differ diff --git a/Cooldowns/AscendEffectOverlay.png b/Cooldowns/AscendEffectOverlay.png new file mode 100644 index 0000000000..2aab8eb604 Binary files /dev/null and b/Cooldowns/AscendEffectOverlay.png differ diff --git a/Cooldowns/CooldownInstance.cs b/Cooldowns/CooldownInstance.cs index d1d7542d1a..7a71c25f61 100644 --- a/Cooldowns/CooldownInstance.cs +++ b/Cooldowns/CooldownInstance.cs @@ -35,10 +35,19 @@ namespace CalamityMod.Cooldowns internal CooldownInstance(Player p, string id, TagCompound tag) { netID = (ushort)tag.GetAsInt(NetIDSaveKey); + Cooldown cd = CooldownRegistry.Get(id); + + // It is possible this cooldown does not exist. If this occurs, log it, even though it will be (mostly) harmless. + if (cd is null) + { + CalamityMod.Instance.Logger.Warn($"Cooldown \"{id}\" loaded from NBT, but was not found. This cooldown will not be applied to the player."); + return; + } + // Correct for netID mismatch if for some reason this occurs. // The string ID of the cooldown overrides whatever the netID may have been saved as. - Cooldown cd = CooldownRegistry.Get(id); ushort registeredNetID = cd.netID; + if (netID != registeredNetID) { // Log when this occurs, even though it should be harmless. diff --git a/Cooldowns/FleshTotem.cs b/Cooldowns/FleshTotem.cs index ef26722a05..878eb99bb5 100644 --- a/Cooldowns/FleshTotem.cs +++ b/Cooldowns/FleshTotem.cs @@ -25,6 +25,7 @@ namespace CalamityMod.Cooldowns { switch (skin) { + // TODO -- UNUSED, Core of the Blood God no longer exists. case "bloodgod": skinTexture = "BloodGodTotem"; outlineColor = new Color(255, 162, 205); diff --git a/Cooldowns/GaelsRage.cs b/Cooldowns/GaelsRage.cs new file mode 100644 index 0000000000..115d83a357 --- /dev/null +++ b/Cooldowns/GaelsRage.cs @@ -0,0 +1,19 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.Localization; + +namespace CalamityMod.Cooldowns +{ + public class GaelsRage : CooldownHandler + { + public static new string ID => "GaelsRage"; + + public override bool ShouldDisplay => true; + public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); + public override string Texture => "CalamityMod/Cooldowns/GaelsRage"; + public override Color OutlineColor => new Color(217, 106, 161); + public override Color CooldownStartColor => new Color(197, 134, 157); + public override Color CooldownEndColor => new Color(238, 151, 184); + } +} diff --git a/Cooldowns/GaelsRage.png b/Cooldowns/GaelsRage.png new file mode 100644 index 0000000000..77baf73e30 Binary files /dev/null and b/Cooldowns/GaelsRage.png differ diff --git a/Cooldowns/GaelsRageOutline.png b/Cooldowns/GaelsRageOutline.png new file mode 100644 index 0000000000..e665d675ab Binary files /dev/null and b/Cooldowns/GaelsRageOutline.png differ diff --git a/Cooldowns/GaelsRageOverlay.png b/Cooldowns/GaelsRageOverlay.png new file mode 100644 index 0000000000..e7d29f60d5 Binary files /dev/null and b/Cooldowns/GaelsRageOverlay.png differ diff --git a/DataStructures/GemTechArmorState.cs b/DataStructures/GemTechArmorState.cs index 7626e78b26..64bd7a6dca 100644 --- a/DataStructures/GemTechArmorState.cs +++ b/DataStructures/GemTechArmorState.cs @@ -7,6 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; using CalamityMod.Items.Armor.GemTech; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.DataStructures { @@ -146,6 +147,9 @@ namespace CalamityMod.DataStructures return; int damage = (int)Owner.GetTotalDamage().ApplyTo(GemTechHeadgear.MeleeShardBaseDamage); + if (Owner.Calamity().oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + for (int i = 0; i < 14; i++) { Vector2 shootVelocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(0.5f, 3.25f); @@ -162,6 +166,9 @@ namespace CalamityMod.DataStructures return; int damage = CalamityUtils.DamageSoftCap((int)(hitDamage * 0.32f), 400); + if (Owner.Calamity().oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + Vector2 spawnPosition = Owner.Center + Main.rand.NextVector2Circular(Owner.width, Owner.height) * 1.35f; Vector2 shootVelocity = (target.Center - spawnPosition) * 0.04f; if (shootVelocity.Length() < 6f) @@ -265,6 +272,8 @@ namespace CalamityMod.DataStructures // Softcap the damage. This is done primarily to dampen stealth interactions. gemDamage = CalamityUtils.DamageSoftCap(gemDamage, GemTechHeadgear.GemDamageSoftcapThreshold); + if (Owner.Calamity().oldFashioned) + gemDamage = CalamityUtils.CalcOldFashionedDamage(gemDamage); if (Main.myPlayer == OwnerIndex) Projectile.NewProjectile(Owner.GetSource_ItemUse(Owner.ActiveItem()), gemPosition, Vector2.Zero, ModContent.ProjectileType(), gemDamage, 0f, OwnerIndex, 0f, (int)GemThatShouldBeLost); diff --git a/DataStructures/NPCStats.cs b/DataStructures/NPCStats.cs index 031c041169..0166b9138e 100644 --- a/DataStructures/NPCStats.cs +++ b/DataStructures/NPCStats.cs @@ -352,6 +352,8 @@ namespace CalamityMod { NPCID.SkeletronHand, new int[] { 20, 44, 55, 66, 99 } }, { NPCID.ChaosBall, new int[] { -1, -1, -1, 40, 60 } }, + { NPCID.Deerclops, new int[] { 20, 40, 50, 60, 80 } }, + { ModContent.NPCType(), new int[] { 40, 80, 96, 104, 135 } }, { ModContent.NPCType(), new int[] { 45, 90, 108, 118, 150 } }, { ModContent.NPCType(), new int[] { 40, 80, 96, 104, 135 } }, @@ -578,6 +580,10 @@ namespace CalamityMod { new Tuple(NPCID.SkeletronHead, ProjectileID.Skull), new int[] { 46, 68, 84, 92, 126 } }, // 102 damage in non-rev master mode + { new Tuple(NPCID.Deerclops, ProjectileID.DeerclopsIceSpike), new int[] { 26, 52, 76, 84, 114 } }, // 78 damage in non-rev master mode + { new Tuple(NPCID.Deerclops, ProjectileID.DeerclopsRangedProjectile), new int[] { 36, 72, 88, 96, 132 } }, // 108 damage in non-rev master mode + { new Tuple(NPCID.Deerclops, ProjectileID.InsanityShadowHostile), new int[] { 20, 40, 60, 68, 90 } }, // 60 damage in non-rev master mode + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 42, 68, 84, 92, 126 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 38, 60, 76, 84, 114 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 42, 68, 84, 92, 126 } }, @@ -605,18 +611,18 @@ namespace CalamityMod { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 60, 100, 120, 132, 180 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 52, 92, 112, 124, 168 } }, - { new Tuple(NPCID.Retinazer, ProjectileID.EyeLaser), new int[] { 40, 76, 92, 100, 138 } }, // 114 damage in non-rev master mode + { new Tuple(NPCID.Retinazer, ProjectileID.EyeLaser), new int[] { 40, 76, 116, 128, 174 } }, // 114 damage in non-rev master mode { new Tuple(NPCID.Retinazer, ProjectileID.DeathLaser), new int[] { 50, // 36 in rapid fire 92, // 68 in rapid fire - 112, // 84 in rapid fire - 124, // 92 in rapid fire - 168 } }, // 126 in rapid fire; 138 in non-rev master mode, 102 in rapid fire in non-rev master mode + 124, // 93 in rapid fire + 136, // 102 in rapid fire + 186 } }, // 139 in rapid fire; 138 in non-rev master mode, 102 in rapid fire in non-rev master mode { new Tuple(NPCID.Retinazer, ModContent.ProjectileType()), new int[] { 70, 120, 136, 152, 210 } }, - { new Tuple(NPCID.Spazmatism, ProjectileID.CursedFlameHostile), new int[] { 50, 88, 108, 120, 162 } }, // 132 in non-rev master mode + { new Tuple(NPCID.Spazmatism, ProjectileID.CursedFlameHostile), new int[] { 50, 88, 120, 132, 180 } }, // 132 in non-rev master mode { new Tuple(NPCID.Spazmatism, ProjectileID.EyeFire), new int[] { 60, 108, 0, 0, 162 } }, // Only used in non-rev modes - { new Tuple(NPCID.Spazmatism, ModContent.ProjectileType()), new int[] { 70, 120, 136, 152, 210 } }, - { new Tuple(NPCID.Spazmatism, ModContent.ProjectileType()), new int[] { 60, 100, 120, 132, 180 } }, + { new Tuple(NPCID.Spazmatism, ModContent.ProjectileType()), new int[] { 70, 120, 148, 160, 222 } }, + { new Tuple(NPCID.Spazmatism, ModContent.ProjectileType()), new int[] { 60, 100, 128, 140, 192 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 60, 100, 120, 132, 180 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 120, 136, 152, 210 } }, @@ -627,6 +633,7 @@ namespace CalamityMod { new Tuple(NPCID.TheDestroyerBody, ProjectileID.DeathLaser), new int[] { 44, 72, 116, 128, 174 } }, // 108 in non-rev master mode { new Tuple(NPCID.TheDestroyerBody, ModContent.ProjectileType()), new int[] { 46, 76, 128, 140, 186 } }, { new Tuple(NPCID.TheDestroyerBody, ModContent.ProjectileType()), new int[] { 48, 80, 136, 152, 210 } }, + { new Tuple(NPCID.TheDestroyerBody, ProjectileID.EyeLaser), new int[] { 40, 68, 100, 112, 144 } }, { new Tuple(NPCID.Probe, ProjectileID.PinkLaser), new int[] { 50, 88, 100, 112, 144 } }, // 132 in non-rev master mode { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index 11ea63dea7..edd6b46474 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -1,5 +1,4 @@ using CalamityMod.Skies; -using Iced.Intel; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; @@ -121,17 +120,20 @@ namespace CalamityMod.Effects // Used by Acid Eels, presumably to have their snaking movements look more smooth. internal static Effect PrimTextureOverlayShader; + // Used as a default for primitive drawing when no specific shader is supplied. This shader simply renders the vertex color data without modification. + internal static Effect StandardPrimitiveShader; + // Used by Devourer of Gods. Renders the portal that he escapes through at the end of phase 1. internal static Effect DoGPortalShader; - // Fusable particles. See the FusableParticleManager for comments on how this system works. - // These shaders are leveraged to render the results of the fusable particle simulation to the screen. + // Metaballs. See the MetaballManager class for comments on how this system works. + // These shaders are leveraged to render the results of the metaball simulation to the screen. // The "Base" shader draws the particles themselves. // The "Additive" shader actually FUSES the particles into their blobby mess. // // Backing textures vary. The primary use of this system is Gruesome Eminence. - internal static Effect BaseFusableParticleEdgeShader; - internal static Effect AdditiveFusableParticleEdgeShader; + internal static Effect MetaballEdgeShader; + internal static Effect AdditiveMetaballEdgeShader; // Used to render the results of Navier-Stokes fluid simulations. internal static Effect FluidShaders; @@ -176,17 +178,20 @@ namespace CalamityMod.Effects #region Aqua's Shaders internal static Effect CircularGradientWithEdge; + internal static Effect WavyOpacity; #endregion - + // - // All below shaders were added by Amber - // Authorship goes to Toasty + // All below shaders were added or created by Amber + // Authorship for the PrimitiveClearShader goes to Toasty // #region Amber's Shaders internal static Effect PrimitiveClearShader; + internal static Effect HolyInfernoShader; + internal static Effect DeerclopsShadowShader; #endregion - + // Shorthand to register a loaded shader in Terraria's graphics engine // All shaders registered this way are accessible under GameShaders.Misc // They will use the prefix described above @@ -335,15 +340,18 @@ namespace CalamityMod.Effects PrimTextureOverlayShader = LoadShader("PrimTextureOverlayShader"); RegisterMiscShader(PrimTextureOverlayShader, "TrailPass", "PrimitiveTexture"); + StandardPrimitiveShader = LoadShader("StandardPrimitiveShader"); + RegisterMiscShader(StandardPrimitiveShader, "PrimitivePass", "StandardPrimitiveShader"); + DoGPortalShader = LoadShader("ScreenShaders/DoGPortalShader"); RegisterMiscShader(DoGPortalShader, "ScreenPass", "DoGPortal"); // These two shaders are often (but not always) used together. - BaseFusableParticleEdgeShader = LoadShader("ParticleFusion/BaseFusableParticleEdgeShader"); - RegisterMiscShader(BaseFusableParticleEdgeShader, "ParticlePass", "BaseFusableParticleEdge"); + MetaballEdgeShader = LoadShader("Metaballs/MetaballEdgeShader"); + RegisterMiscShader(MetaballEdgeShader, "ParticlePass", "MetaballEdge"); - AdditiveFusableParticleEdgeShader = LoadShader("ParticleFusion/AdditiveFusableParticleEdgeShader"); - RegisterMiscShader(AdditiveFusableParticleEdgeShader, "ParticlePass", "AdditiveFusableParticleEdge"); + AdditiveMetaballEdgeShader = LoadShader("Metaballs/AdditiveMetaballEdgeShader"); + RegisterMiscShader(AdditiveMetaballEdgeShader, "ParticlePass", "AdditiveMetaballEdge"); // This shader is not registered with the game but is invoked directly to render the results of fluid simulation. FluidShaders = LoadShader("FluidShaders"); @@ -383,11 +391,20 @@ namespace CalamityMod.Effects #region Loading Aqua's Shaders CircularGradientWithEdge = LoadShader("CircularGradientWithEdge"); RegisterMiscShader(CircularGradientWithEdge, "CircularGradientWithEdgePass", "CircularGradientWithEdge"); + WavyOpacity = LoadShader("WavyOpacity"); + RegisterMiscShader(WavyOpacity, "WavyOpacityPass", "WavyOpacity"); #endregion - + #region Loading Amber's Shaders PrimitiveClearShader = LoadShader("PrimitiveClearShader"); - RegisterScreenShader(PrimitiveClearShader, "SightLinePass", "PrimitiveClearShader"); + RegisterScreenShader(PrimitiveClearShader, "AutoloadPass", "PrimitiveClearShader"); + + HolyInfernoShader = LoadShader("ScreenShaders/HolyInfernoShader"); + RegisterMiscShader(HolyInfernoShader, "InfernoPass", "HolyInfernoShader"); + + DeerclopsShadowShader = LoadShader("ScreenShaders/DeerclopsShadowShader"); + RegisterMiscShader(DeerclopsShadowShader, "ShadowPass", "DeerclopsShadowShader"); + #endregion } } diff --git a/Effects/ParticleFusion/AdditiveFusableParticleEdgeShader.fx b/Effects/Metaballs/AdditiveMetaballEdgeShader.fx similarity index 76% rename from Effects/ParticleFusion/AdditiveFusableParticleEdgeShader.fx rename to Effects/Metaballs/AdditiveMetaballEdgeShader.fx index b7c98d0961..039e453228 100644 --- a/Effects/ParticleFusion/AdditiveFusableParticleEdgeShader.fx +++ b/Effects/Metaballs/AdditiveMetaballEdgeShader.fx @@ -12,25 +12,16 @@ float uDirection; float3 uLightSource; float2 uImageSize0; float2 uImageSize1; -float edgeBorderSize; -bool borderShouldBeSolid; -float3 edgeBorderColor; -float2 screenArea; -float2 renderTargetArea; -float2 screenMoveOffset; -float2 generalBackgroundOffset; -bool invertedScreen; -float2 upscaleFactor; float4 uShaderSpecificData; +float2 screenArea; +float2 layerOffset; +float2 singleFrameScreenOffset; + float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 { float2 originalCoords = coords; - if (invertedScreen) - coords.y = 1 - coords.y; - - // Account for screen movements. Not doing this causes the scene to move based on that. - coords += screenMoveOffset / renderTargetArea; + coords += layerOffset + singleFrameScreenOffset; float2 offset = 3 / screenArea; float4 color = tex2D(uImage0, coords); diff --git a/Effects/Metaballs/AdditiveMetaballEdgeShader.xnb b/Effects/Metaballs/AdditiveMetaballEdgeShader.xnb new file mode 100644 index 0000000000..504c6ffb0f Binary files /dev/null and b/Effects/Metaballs/AdditiveMetaballEdgeShader.xnb differ diff --git a/Effects/Metaballs/MetaballEdgeShader.fx b/Effects/Metaballs/MetaballEdgeShader.fx new file mode 100644 index 0000000000..3f04f11485 --- /dev/null +++ b/Effects/Metaballs/MetaballEdgeShader.fx @@ -0,0 +1,59 @@ +sampler metaballContents : register(s0); +sampler overlayTexture : register(s1); + +float2 screenSize; +float2 layerSize; +float2 layerOffset; +float4 edgeColor; +float2 singleFrameScreenOffset; + +// The usage of these two methods seemingly prevents imprecision problems for some reason. +float2 convertToScreenCoords(float2 coords) +{ + return coords * screenSize; +} + +float2 convertFromScreenCoords(float2 coords) +{ + return coords / screenSize; +} + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + // Calculate the base color. This is the calculated from the raw objects in the metaball render target. + float4 baseColor = tex2D(metaballContents, coords); + + // Used to negate the need for an inverted if (baseColor.a > 0) by ensuring all of the edge checks fail. + float alphaOffset = (1 - any(baseColor.a)); + + // Check if there are any empty pixels nearby. If there are, that means this pixel is at an edge, and should be colored accordingly. + float left = tex2D(metaballContents, convertFromScreenCoords(convertToScreenCoords(coords) + float2(-2, 0))).a + alphaOffset; + float right = tex2D(metaballContents, convertFromScreenCoords(convertToScreenCoords(coords) + float2(2, 0))).a + alphaOffset; + float top = tex2D(metaballContents, convertFromScreenCoords(convertToScreenCoords(coords) + float2(0, -2))).a + alphaOffset; + float bottom = tex2D(metaballContents, convertFromScreenCoords(convertToScreenCoords(coords) + float2(0, 2))).a + alphaOffset; + + // Use step instead of branching in order to determine whether neighboring pixels are invisible. + float leftHasNoAlpha = step(left, 0); + float rightHasNoAlpha = step(right, 0); + float topHasNoAlpha = step(top, 0); + float bottomHasNoAlpha = step(bottom, 0); + + // Use addition instead of the OR boolean operator to get a 0-1 value for whether an edge is invisible. + // The equivalent for AND would be multiplication. + float conditionOpacityFactor = 1 - saturate(leftHasNoAlpha + rightHasNoAlpha + topHasNoAlpha + bottomHasNoAlpha); + + // Calculate layer colors. + float4 layerColor = tex2D(overlayTexture, (coords + layerOffset + singleFrameScreenOffset) * screenSize / layerSize); + float4 defaultColor = layerColor * tex2D(metaballContents, coords) * sampleColor; + + // Lastly, use the aforementioned condition to switch between the colors. If conditionOpacityFactor is 1, the default color is + // zeroed out and the edge is toggled, and vice versa. + return (defaultColor * conditionOpacityFactor) + (edgeColor * sampleColor * (1 - conditionOpacityFactor)); +} +technique Technique1 +{ + pass ParticlePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Metaballs/MetaballEdgeShader.xnb b/Effects/Metaballs/MetaballEdgeShader.xnb new file mode 100644 index 0000000000..6ee03aac55 Binary files /dev/null and b/Effects/Metaballs/MetaballEdgeShader.xnb differ diff --git a/Effects/MiracleBlight.fx b/Effects/MiracleBlight.fx index a17b9f84e8..3f4e60c31f 100644 --- a/Effects/MiracleBlight.fx +++ b/Effects/MiracleBlight.fx @@ -35,15 +35,12 @@ float4 PixelShaderFunction(float2 coords : TEXCOORD0) : COLOR0 float4 color = tex2D(uImage0, coords); if (!any(color)) return color; - - // Framed coordinates -- a UV of the NPC's current framed sprite, instead of the whole sheet - float2 framedCoords = (coords * uImageSize0 - uSourceRect.xy) / uSourceRect.zw; - + // Temporal drift to make the sprite slide through the noise texture - float2 drift = float2(5 * sin(8.33 * uTime), 220 * uTime); + float2 drift = float2(5 * sin(0.04165 * uTime), 1.1 * uTime); - float2 noiseMapTexCoords = framedCoords * uSourceRect.zw + drift; - float4 noiseColor = tex2D(uImage1, noiseMapTexCoords / uImageSize1); + float2 noiseMapTexCoords = coords + drift + uWorldPosition; + float4 noiseColor = tex2D(uImage1, noiseMapTexCoords); // Define thresholds for total pixel erasure and glowing lines. // @@ -61,10 +58,12 @@ float4 PixelShaderFunction(float2 coords : TEXCOORD0) : COLOR0 { color.rgba = 0; } + // Otherwise, if it's over the slightly lower threshold, replace it with a bright color. else if (noiseColor.r > glowThreshold) { - color = float4(0.4902, 1, 0, 1); + // Ensure it accounts for the original alpha. + color = float4(0.4902, 1, 0, 1) * color.a; } return color; diff --git a/Effects/MiracleBlight.xnb b/Effects/MiracleBlight.xnb index a37ac5c837..2f31eff42b 100644 Binary files a/Effects/MiracleBlight.xnb and b/Effects/MiracleBlight.xnb differ diff --git a/Effects/ParticleFusion/AdditiveFusableParticleEdgeShader.xnb b/Effects/ParticleFusion/AdditiveFusableParticleEdgeShader.xnb deleted file mode 100644 index ca8ec969be..0000000000 Binary files a/Effects/ParticleFusion/AdditiveFusableParticleEdgeShader.xnb and /dev/null differ diff --git a/Effects/ParticleFusion/BaseFusableParticleEdgeShader.fx b/Effects/ParticleFusion/BaseFusableParticleEdgeShader.fx deleted file mode 100644 index e4155db9b9..0000000000 --- a/Effects/ParticleFusion/BaseFusableParticleEdgeShader.fx +++ /dev/null @@ -1,78 +0,0 @@ -sampler uImage0 : register(s0); -sampler uImage1 : register(s1); -float3 uColor; -float3 uSecondaryColor; -float uOpacity; -float uSaturation; -float uRotation; -float uTime; -float4 uSourceRect; -float2 uWorldPosition; -float uDirection; -float3 uLightSource; -float2 uImageSize0; -float2 uImageSize1; -float edgeBorderSize; -bool borderShouldBeSolid; -float3 edgeBorderColor; -float2 screenArea; -float2 renderTargetArea; -float2 screenMoveOffset; -float2 generalBackgroundOffset; -bool invertedScreen; -float2 upscaleFactor; -float4 uShaderSpecificData; - -float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 -{ - float2 originalCoords = coords; - if (invertedScreen) - coords.y = 1 - coords.y; - - // Account for screen movements. Not doing this causes the scene to move based on that. - coords += screenMoveOffset / renderTargetArea; - - float4 color = tex2D(uImage0, coords); - - // Determine how much downscaling is required to reasonably zoom in on things. - float downscaleFactor = float2(5, 5) / upscaleFactor / max(renderTargetArea.x, renderTargetArea.y) / 2; - float2 backgroundCoords = frac((renderTargetArea * (originalCoords + generalBackgroundOffset * upscaleFactor) + uWorldPosition) * downscaleFactor); - float4 backgroundColor = tex2D(uImage1, backgroundCoords); - - // Equivalent to edgeBorderSize pixels in both the X and Y direction. - float2 edgeOffset = float2(edgeBorderSize, edgeBorderSize) / renderTargetArea; - - // Check if the cardinal directions are not intersecting with any other active parts of the render target. - // If one of them isn't, that means that a border should be rendered. - float4 aboveColor = tex2D(uImage0, coords + float2(0, edgeOffset.y)); - float4 belowColor = tex2D(uImage0, coords - float2(0, edgeOffset.y)); - float4 leftColor = tex2D(uImage0, coords + float2(edgeOffset.x, 0)); - float4 rightColor = tex2D(uImage0, coords - float2(edgeOffset.x, 0)); - - // Invert color check thresholds based on whether the border should be solid when drawing. - float checkThreshold = 0.02; - if (!borderShouldBeSolid) - checkThreshold = 0.95; - - // If any cardinal color is sufficiently close to transparency choose an edge border color. - // Opacity multipliers ensure that this does not affect completely invisible areas of the render target. - if (aboveColor.r < checkThreshold || belowColor.r < checkThreshold || leftColor.r < checkThreshold || rightColor.r < checkThreshold) - { - float borderOpacity = color.a; - - // Use binary opacity if the border should be solid when drawing. - if (borderOpacity > 0 && borderShouldBeSolid) - borderOpacity = 1; - - return float4(edgeBorderColor, 1) * borderOpacity; - } - - return backgroundColor; -} -technique Technique1 -{ - pass ParticlePass - { - PixelShader = compile ps_2_0 PixelShaderFunction(); - } -} \ No newline at end of file diff --git a/Effects/ParticleFusion/BaseFusableParticleEdgeShader.xnb b/Effects/ParticleFusion/BaseFusableParticleEdgeShader.xnb deleted file mode 100644 index c544bbed01..0000000000 Binary files a/Effects/ParticleFusion/BaseFusableParticleEdgeShader.xnb and /dev/null differ diff --git a/Effects/ScreenShaders/DeerclopsShadowShader.fx b/Effects/ScreenShaders/DeerclopsShadowShader.fx new file mode 100644 index 0000000000..47273956fe --- /dev/null +++ b/Effects/ScreenShaders/DeerclopsShadowShader.fx @@ -0,0 +1,52 @@ +float minRadius; +float maxRadius; +float maxOpacity; + +float2 screenPosition; +float2 screenSize; +float2 anchorPoint; + +float InverseLerp(float a, float b, float t) +{ + return saturate((t - a) / (b - a)); +} + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 uv : TEXCOORD0) : COLOR0 +{ + float2 worldUV = screenPosition + screenSize * uv; + float2 deerclopsUV = anchorPoint / screenSize; + float worldDistance = distance(worldUV, anchorPoint); + + // Get the distance to the pixel from Deerclops + float distToDeerclops = distance(anchorPoint, worldUV); + // And get the correct opacity based on it. + float opacity = InverseLerp(0, maxRadius, distToDeerclops); + + // Define the border and mix the shadow and light for a smoother transition + bool border = worldDistance < minRadius && opacity > 0; + float colorMult = 1; + + if (worldDistance > minRadius && worldDistance < maxRadius) + opacity = lerp(opacity, maxOpacity, InverseLerp(minRadius, maxRadius, distToDeerclops)); + + opacity = clamp(opacity, 0, maxOpacity); + + if (border) + { + colorMult = InverseLerp(minRadius * 0.94, minRadius, worldDistance); + } + + // If the color multi has not been changed (not border pixel) and opacity is 0 OR it's within + if (colorMult == 1 && (opacity == 0 || worldDistance < minRadius)) + return sampleColor; + + return float4(0, 0, 0, 1) * colorMult * opacity; +} + +technique Technique1 +{ + pass ShadowPass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/ScreenShaders/DeerclopsShadowShader.xnb b/Effects/ScreenShaders/DeerclopsShadowShader.xnb new file mode 100644 index 0000000000..8703cff449 Binary files /dev/null and b/Effects/ScreenShaders/DeerclopsShadowShader.xnb differ diff --git a/Effects/ScreenShaders/HolyInfernoShader.fx b/Effects/ScreenShaders/HolyInfernoShader.fx new file mode 100644 index 0000000000..d96752fda1 --- /dev/null +++ b/Effects/ScreenShaders/HolyInfernoShader.fx @@ -0,0 +1,94 @@ +sampler diagonalNoise : register(s1); +sampler upwardNoise : register(s2); +sampler upwardPerlinTex : register(s3); + +bool day; + +float colorMult; +float time; +float radius; +float maxOpacity; +float burnIntensity; + +float2 screenPosition; +float2 screenSize; +float2 anchorPoint; +float2 playerPosition; + +float InverseLerp(float a, float b, float t) +{ + return saturate((t - a) / (b - a)); +} + +float3 firePalette(float noise) +{ + // Temperature range (in Kelvin). + float temperature = 1500. + 1500. * noise; + + float3 darkColor = float3(0.81, 0.45, 0.23) * colorMult; + float3 midColor = float3(1., 0.75, 0.29) * colorMult; + float3 brightColor = float3(1., 1., 0.95) * colorMult; + if (!day) + { + darkColor.rgb = darkColor.bgr; + midColor.rgb = midColor.bgr; + brightColor.rgb = brightColor.bgr; + } + float3 fireColor; + if (noise < 0.5) + fireColor = lerp(darkColor, midColor, noise * 2.); + else + fireColor = lerp(midColor, brightColor, (noise - 0.5) * 2.); + + fireColor = pow(fireColor, float3(5, 5, 5)) * (exp(1.43876719683e5 / (temperature * fireColor)) - 1.); + + // Exposure level. Set to "50." For "70," change the "5" to a "7," etc. + return 1. - exp(-1.3e8 / fireColor); +} + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 uv : TEXCOORD0) : COLOR0 +{ + float2 worldUV = screenPosition + screenSize * uv; + float2 provUV = anchorPoint / screenSize; + float worldDistance = distance(worldUV, anchorPoint); + float adjustedTime = time * 0.1; + + // Pixelate the uvs + float2 pixelatedUV = worldUV / screenSize; + pixelatedUV.x -= worldUV.x % (1 / screenSize.x); + pixelatedUV.y -= worldUV.y % (1 / (screenSize.y / 2) * 2); + + // Sample the noise textures + float noiseMesh1 = tex2D(upwardNoise, frac(pixelatedUV * 0.58 + float2(0, time * 0.25))).g; + float noiseMesh2 = tex2D(upwardPerlinTex, frac(pixelatedUV * 1.57 + float2(0, time * 0.35))).g; + float noiseMesh3 = tex2D(diagonalNoise, frac(pixelatedUV * 1.46 + float2(adjustedTime * 0.56, adjustedTime * 1.2))).g; + float noiseMesh4 = tex2D(diagonalNoise, frac(pixelatedUV * 1.57 + float2(adjustedTime * -0.56, adjustedTime * 1.2))).g; + float textureMesh = noiseMesh1 * 0.125 + noiseMesh2 * 0.2 + noiseMesh3 * 0.35 + noiseMesh4 * 0.35; + + // Get the distance to the pixel from the player. + float distToPlayer = distance(playerPosition, worldUV); + // And get the correct opacity based on it. + float opacity = burnIntensity; + // Fade in quickly as the player approaches the pixels + opacity += InverseLerp(800, 500, distToPlayer); + + // Define the border and mix the inferno for a smooth transition + bool border = worldDistance < radius && opacity > 0; + float colorMult = 1; + if (border) + colorMult = InverseLerp(radius * 0.94, radius, worldDistance); + opacity = clamp(opacity, 0, maxOpacity); + // If the color multi has not been changed (not border pixel) and opacity is 0 OR it's within + if (colorMult == 1 && (opacity == 0 || worldDistance < radius)) + return sampleColor; + + return float4(firePalette(textureMesh), 1) * colorMult * opacity; +} + +technique Technique1 +{ + pass InfernoPass + { + PixelShader = compile ps_3_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/ScreenShaders/HolyInfernoShader.xnb b/Effects/ScreenShaders/HolyInfernoShader.xnb new file mode 100644 index 0000000000..67b145b4f8 Binary files /dev/null and b/Effects/ScreenShaders/HolyInfernoShader.xnb differ diff --git a/Effects/StandardPrimitiveShader.fx b/Effects/StandardPrimitiveShader.fx new file mode 100644 index 0000000000..197b149592 --- /dev/null +++ b/Effects/StandardPrimitiveShader.fx @@ -0,0 +1,57 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +matrix uWorldViewProjection; +float4 uShaderSpecificData; + +struct VertexShaderInput +{ + float4 Position : POSITION0; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +struct VertexShaderOutput +{ + float4 Position : SV_POSITION; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +VertexShaderOutput VertexShaderFunction(in VertexShaderInput input) +{ + VertexShaderOutput output = (VertexShaderOutput) 0; + float4 pos = mul(input.Position, uWorldViewProjection); + output.Position = pos; + + output.Color = input.Color; + output.TextureCoordinates = input.TextureCoordinates; + + return output; +} + +// Returns the direct output from the primitive's specified color value. Nothing fancy. +float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 +{ + return input.Color; +} + +technique Technique1 +{ + pass PrimitivePass + { + VertexShader = compile vs_2_0 VertexShaderFunction(); + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/StandardPrimitiveShader.xnb b/Effects/StandardPrimitiveShader.xnb new file mode 100644 index 0000000000..513e94c70a Binary files /dev/null and b/Effects/StandardPrimitiveShader.xnb differ diff --git a/Effects/WavyOpacity.fx b/Effects/WavyOpacity.fx new file mode 100644 index 0000000000..fe08fcc4c6 --- /dev/null +++ b/Effects/WavyOpacity.fx @@ -0,0 +1,74 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity : register(C0); +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +float4 uShaderSpecificData; + +// Cosine does not work in shaders in Terraria 1.4. It returns incredibly corrupted values and nobody is sure why. +// This reimplements cosine using trigonometric identities. +// +// Discovery of malfunctioning cosine attributed to ScalarVector from SLR: +// https://discord.com/channels/103110554649894912/445276626352209920/979928448300634175 +float realCos(float value) +{ + return sin(value + 1.57079); +} + +//Shader overall based on Ozzatron's miracle blight shader. slightly edited for a different use case. +float4 PixelShaderFunction(float2 coords : TEXCOORD0) : COLOR0 +{ + float4 color = tex2D(uImage0, coords); + if (!any(color)) + return color; + + // Framed coordinates -- a UV of the Projectile's current framed sprite, instead of the whole sheet + float2 framedCoords = (coords * uImageSize0 - uSourceRect.xy) / uSourceRect.zw; + + // Temporal drift to make the sprite slide through the noise texture + float2 drift = float2(5 * sin(4 * uTime), 220 * -uTime); + + float2 noiseMapTexCoords = framedCoords * uSourceRect.zw + drift; + float4 noiseColor = tex2D(uImage1, noiseMapTexCoords / uImageSize1); + + // Define thresholds for total pixel erasure and glowing lines. + // + // Rapidly flickering sinewave produced by Desmos, loosely based on the Weierstrass function + // (infinitely sharp vague sinewave, periodic, continuous everywhere but differentiable nowhere) + // https://en.wikipedia.org/wiki/Weierstrass_function + float flickerOne = 0.05 * realCos(7 * uTime); + float flickerTwo = 0.06 * realCos(31 * uTime); + float flickerThree = 0.04 * sin(167 * uTime); + float fullErasureThreshold = uOpacity + flickerOne + flickerTwo + flickerThree; + float glowThreshold = fullErasureThreshold - 0.3; + + // If the noise over the erasure threshold, completely erase this pixel. + if (noiseColor.r > fullErasureThreshold) + { + color.rgba = 0; + } + // Otherwise, if it's over the slightly lower threshold, change the opacity relative to how close it was to erasure + else if (noiseColor.r > glowThreshold) + { + color.rgba = color.rgba * (1 - ((noiseColor.r - glowThreshold) / (fullErasureThreshold - glowThreshold))); + } + + return color; +} + +technique Technique1 +{ + pass WavyOpacityPass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/WavyOpacity.xnb b/Effects/WavyOpacity.xnb new file mode 100644 index 0000000000..fa908885e8 Binary files /dev/null and b/Effects/WavyOpacity.xnb differ diff --git a/Events/BossRushEvent.cs b/Events/BossRushEvent.cs index 286fb4bede..9b420d00f5 100644 --- a/Events/BossRushEvent.cs +++ b/Events/BossRushEvent.cs @@ -442,13 +442,6 @@ namespace CalamityMod.Events { CalamityUtils.KillAllHostileProjectiles(); HostileProjectileKillCounter = 3; - - // Mark Boss Rush as complete - DownedBossSystem.downedBossRush = true; - CalamityNetcode.SyncWorld(); - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(Source, npc.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer); } }; } @@ -744,7 +737,19 @@ namespace CalamityMod.Events HostileProjectileKillCounter = 3; if (BossDeathEffects.ContainsKey(npc.type)) + { BossDeathEffects[npc.type].Invoke(npc); + } + + if (npc.type == Bosses[Bosses.Count -1].EntityID) + { + // Mark Boss Rush as complete + DownedBossSystem.downedBossRush = true; + CalamityNetcode.SyncWorld(); + + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(Source, npc.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer); + } } // Sync the stage and progress of Boss Rush whenever a relevant boss dies. diff --git a/ExtraJumps/SulphurJump.cs b/ExtraJumps/SulphurJump.cs index aa6dc6a480..d49ebf6491 100644 --- a/ExtraJumps/SulphurJump.cs +++ b/ExtraJumps/SulphurJump.cs @@ -1,4 +1,5 @@ using CalamityMod.CalPlayer; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Particles; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; @@ -27,6 +28,7 @@ namespace CalamityMod.ExtraJumps int offset = player.height; if (player.gravDir == -1f) offset = 0; + for (int i = 0; i < 25; ++i) { Dust dust = Dust.NewDustPerfect(new Vector2(player.Center.X, player.Center.Y + offset), Main.rand.NextBool(3) ? 75 : 161, new Vector2(-player.velocity.X, 6).RotatedByRandom(MathHelper.ToRadians(50f)) * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(1.7f, 2.2f)); @@ -45,6 +47,9 @@ namespace CalamityMod.ExtraJumps { var source = player.GetSource_Misc("0"); int damage = (int)player.GetTotalDamage().ApplyTo(20); + if (modPlayer.oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + int bubble = Projectile.NewProjectile(source, new Vector2(player.position.X, player.position.Y + (player.gravDir == -1f ? 20 : -20)), Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 1f, 0f); if (bubble.WithinBounds(Main.maxProjectiles)) Main.projectile[bubble].DamageType = DamageClass.Generic; diff --git a/ExtraTextures/BasicCircle.png b/ExtraTextures/BasicCircle.png new file mode 100644 index 0000000000..a9f476c6f7 Binary files /dev/null and b/ExtraTextures/BasicCircle.png differ diff --git a/ExtraTextures/GreyscaleGradients/HarshNoise.png b/ExtraTextures/GreyscaleGradients/HarshNoise.png new file mode 100644 index 0000000000..05a38ce506 Binary files /dev/null and b/ExtraTextures/GreyscaleGradients/HarshNoise.png differ diff --git a/ExtraTextures/GreyscaleGradients/MeltyNoise.png b/ExtraTextures/GreyscaleGradients/MeltyNoise.png new file mode 100644 index 0000000000..1c71371ec8 Binary files /dev/null and b/ExtraTextures/GreyscaleGradients/MeltyNoise.png differ diff --git a/ExtraTextures/GreyscaleGradients/Perlin.png b/ExtraTextures/GreyscaleGradients/Perlin.png new file mode 100644 index 0000000000..2d55cf8942 Binary files /dev/null and b/ExtraTextures/GreyscaleGradients/Perlin.png differ diff --git a/Projectiles/Melee/Orbacle.png b/ExtraTextures/TinyGreyscaleCircle.png similarity index 100% rename from Projectiles/Melee/Orbacle.png rename to ExtraTextures/TinyGreyscaleCircle.png diff --git a/FluidSimulation/FluidField.cs b/FluidSimulation/FluidField.cs index 0c8d35d1aa..0e8b96419c 100644 --- a/FluidSimulation/FluidField.cs +++ b/FluidSimulation/FluidField.cs @@ -1,5 +1,7 @@ using System; using CalamityMod.Effects; +using CalamityMod.Graphics; +using CalamityMod.NPCs.TownNPCs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -12,11 +14,11 @@ namespace CalamityMod.FluidSimulation // Please do not change this system too much without contacting me first. -Dominic public class FluidField : IDisposable { - internal RenderTarget2D TemporaryAuxilaryTarget; + internal ManagedRenderTarget TemporaryAuxilaryTarget; - internal RenderTarget2D DivergenceField; + internal ManagedRenderTarget DivergenceField; - internal RenderTarget2D DivergencePoissonField; + internal ManagedRenderTarget DivergencePoissonField; internal FluidFieldState VelocityField; @@ -24,7 +26,7 @@ namespace CalamityMod.FluidSimulation internal FluidFieldState ColorField; - internal RenderTarget2D OutputTarget; + internal ManagedRenderTarget OutputTarget; public float Viscosity; @@ -70,6 +72,10 @@ namespace CalamityMod.FluidSimulation } } + // A surface format of Vector4 is used here to allow for both 0-1 ranged colors and other things at the same time. + public RenderTarget2D FluidCreateCondition(int screen, int height) => + new(Main.instance.GraphicsDevice, Size, Size, true, SurfaceFormat.Vector4, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents); + internal FluidField(int size, float scale, float viscosity, float diffusionFactor, float dissipationFactor) { Size = size; @@ -82,13 +88,12 @@ namespace CalamityMod.FluidSimulation DensityField = new(size); ColorField = new(size); - // A surface format of Vector4 is used here to allow for both 0-1 ranged colors and other things at the same time. - TemporaryAuxilaryTarget = new(Main.instance.GraphicsDevice, Size, Size, true, SurfaceFormat.Vector4, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents); + TemporaryAuxilaryTarget = new(false, FluidCreateCondition, false); - DivergenceField = new(Main.instance.GraphicsDevice, Size, Size, true, SurfaceFormat.Vector4, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents); - DivergencePoissonField = new(Main.instance.GraphicsDevice, Size, Size, true, SurfaceFormat.Vector4, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents); + DivergenceField = new(false, FluidCreateCondition, false); + DivergencePoissonField = new(false, FluidCreateCondition, false); - OutputTarget = new(Main.instance.GraphicsDevice, Size, Size, true, SurfaceFormat.Color, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents); + OutputTarget = new(false, FluidCreateCondition, false); } internal void ApplyThingToTarget(RenderTarget2D currentField, Action shaderPreparationsAction) @@ -293,13 +298,7 @@ namespace CalamityMod.FluidSimulation FluidFieldManager.Fields.Remove(this); Disposing = true; - TemporaryAuxilaryTarget?.Dispose(); - DivergenceField?.Dispose(); - DivergencePoissonField?.Dispose(); - VelocityField?.Dispose(); - ColorField?.Dispose(); - DensityField?.Dispose(); - OutputTarget?.Dispose(); + GC.SuppressFinalize(this); } public void CreateSource(int x, int y, float density, Color color, Vector2 velocity) @@ -326,7 +325,7 @@ namespace CalamityMod.FluidSimulation shaderPreparations?.Invoke(OutputTarget); - Main.spriteBatch.Draw(OutputTarget, drawPosition, null, Color.White, 0f, OutputTarget.Size() * 0.5f, Scale, 0, 0f); + Main.spriteBatch.Draw(OutputTarget, drawPosition, null, Color.White, 0f, OutputTarget.Size * 0.5f, Scale, 0, 0f); Main.spriteBatch.End(); if (needsToCallEnd) diff --git a/FluidSimulation/FluidFieldState.cs b/FluidSimulation/FluidFieldState.cs index 88749ea130..e2825f3fd3 100644 --- a/FluidSimulation/FluidFieldState.cs +++ b/FluidSimulation/FluidFieldState.cs @@ -1,5 +1,5 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; +using CalamityMod.Graphics; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; @@ -7,29 +7,33 @@ using Terraria.ID; namespace CalamityMod.FluidSimulation { // Calculations for these are done primarily on the GPU in shaders for performance-sake. - public class FluidFieldState : IDisposable + public class FluidFieldState { - public RenderTarget2D PreviousState; + public ManagedRenderTarget PreviousState; - public RenderTarget2D NextState; + public ManagedRenderTarget NextState; public Queue PendingChanges = new(); - public void Dispose() - { - PreviousState?.Dispose(); - NextState?.Dispose(); - } + public readonly int Size; + + public readonly SurfaceFormat FieldContents; public void SwapState() => Utils.Swap(ref PreviousState, ref NextState); + public RenderTarget2D FieldColorCreateCondition(int screen, int height) => + new(Main.instance.GraphicsDevice, Size, Size, true, FieldContents, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents); + public FluidFieldState(int size, SurfaceFormat fieldContents = SurfaceFormat.Color) { if (Main.netMode == NetmodeID.Server) return; - PreviousState = new(Main.instance.GraphicsDevice, size, size, true, fieldContents, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents); - NextState = new(Main.instance.GraphicsDevice, size, size, true, fieldContents, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents); + Size = size; + FieldContents = fieldContents; + + PreviousState = new(false, FieldColorCreateCondition, false); + NextState = new(false, FieldColorCreateCondition, false); } } } diff --git a/Gores/AstralWaterDroplet.cs b/Gores/AstralWaterDroplet.cs index 87a5e4f8e9..9eb6588b4d 100644 --- a/Gores/AstralWaterDroplet.cs +++ b/Gores/AstralWaterDroplet.cs @@ -28,52 +28,52 @@ namespace CalamityMod.Gores { gore.alpha = 100; } - int num = 4; + int goreFrameDelay = 4; gore.frameCounter++; if (gore.frame <= 4) { - int num2 = (int)(gore.position.X / 16f); - int num3 = (int)(gore.position.Y / 16f) - 1; - if (WorldGen.InWorld(num2, num3, 0) && !Main.tile[num2, num3].HasTile) + int goreXPos = (int)(gore.position.X / 16f); + int goreYPos = (int)(gore.position.Y / 16f) - 1; + if (WorldGen.InWorld(goreXPos, goreYPos, 0) && !Main.tile[goreXPos, goreYPos].HasTile) { gore.active = false; } if (gore.frame == 0) { - num = 24 + Main.rand.Next(256); + goreFrameDelay = 24 + Main.rand.Next(256); } if (gore.frame == 1) { - num = 24 + Main.rand.Next(256); + goreFrameDelay = 24 + Main.rand.Next(256); } if (gore.frame == 2) { - num = 24 + Main.rand.Next(256); + goreFrameDelay = 24 + Main.rand.Next(256); } if (gore.frame == 3) { - num = 24 + Main.rand.Next(96); + goreFrameDelay = 24 + Main.rand.Next(96); } if (gore.frame == 5) { - num = 16 + Main.rand.Next(64); + goreFrameDelay = 16 + Main.rand.Next(64); } - if ((int)gore.frameCounter >= num) + if ((int)gore.frameCounter >= goreFrameDelay) { gore.frameCounter = 0; gore.frame += 1; if (gore.frame == 5 && Main.netMode != NetmodeID.Server) { - int num4 = Gore.NewGore(new EntitySource_Misc("0"), gore.position, gore.velocity, gore.type, 1f); - Main.gore[num4].frame = 9; - Main.gore[num4].velocity *= 0f; + int astralWater = Gore.NewGore(new EntitySource_Misc("0"), gore.position, gore.velocity, gore.type, 1f); + Main.gore[astralWater].frame = 9; + Main.gore[astralWater].velocity *= 0f; } } } else if (gore.frame <= 6) { - num = 8; - if ((int)gore.frameCounter >= num) + goreFrameDelay = 8; + if ((int)gore.frameCounter >= goreFrameDelay) { gore.frameCounter = 0; gore.frame += 1; @@ -85,7 +85,7 @@ namespace CalamityMod.Gores } else if (gore.frame <= 9) { - num = 6; + goreFrameDelay = 6; gore.velocity.Y += 0.2f; if ((double)gore.velocity.Y < 0.5) { @@ -95,7 +95,7 @@ namespace CalamityMod.Gores { gore.velocity.Y = 12f; } - if ((int)gore.frameCounter >= num) + if ((int)gore.frameCounter >= goreFrameDelay) { gore.frameCounter = 0; gore.frame += 1; @@ -108,7 +108,7 @@ namespace CalamityMod.Gores else { gore.velocity.Y += 0.1f; - if ((int)gore.frameCounter >= num) + if ((int)gore.frameCounter >= goreFrameDelay) { gore.frameCounter = 0; gore.frame += 1; @@ -120,9 +120,9 @@ namespace CalamityMod.Gores } } - Vector2 value3 = gore.velocity; + Vector2 goreVelCheck = gore.velocity; gore.velocity = Collision.TileCollision(gore.position, gore.velocity, 16, 14, false, false, 1); - if (gore.velocity != value3) + if (gore.velocity != goreVelCheck) { if (gore.frame < 10) { @@ -146,12 +146,12 @@ namespace CalamityMod.Gores } ((WaterShaderData)Filters.Scene["WaterDistortion"].GetShader()).QueueRipple(gore.position + new Vector2(8f, 8f), 1f, RippleShape.Square, 0f); } - int num21 = (int)(gore.position.X + 8f) / 16; - int num22 = (int)(gore.position.Y + 14f) / 16; - if (Main.tile[num21, num22] != null && Main.tile[num21, num22].LiquidAmount > 0) + int goreTileX = (int)(gore.position.X + 8f) / 16; + int goreTileY = (int)(gore.position.Y + 14f) / 16; + if (Main.tile[goreTileX, goreTileY] != null && Main.tile[goreTileX, goreTileY].LiquidAmount > 0) { gore.velocity *= 0f; - gore.position.Y = (float)(num22 * 16 - (int)(Main.tile[num21, num22].LiquidAmount / 16)); + gore.position.Y = (float)(goreTileY * 16 - (int)(Main.tile[goreTileX, goreTileY].LiquidAmount / 16)); } } diff --git a/Graphics/Drawers/BaseDrawer.cs b/Graphics/Drawers/BaseDrawer.cs new file mode 100644 index 0000000000..8448be5335 --- /dev/null +++ b/Graphics/Drawers/BaseDrawer.cs @@ -0,0 +1,71 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Graphics.Drawers +{ + /// + /// A class to handle drawing a visual effect to a rendertarget, then drawing the target to the screen at selected layer. + /// + public abstract class BaseDrawer + { + #region Fields/Properties + /// + /// The layer that the target should be drawn at. + /// + public abstract DrawerLayer Layer { get; } + + /// + /// Whether the target should draw and be drawn to this frame. + /// + public abstract bool ShouldDraw { get; } + + /// + /// The target that the visual is drawn to. Automatically handled. + /// + public ManagedRenderTarget MainTarget + { + get; + private set; + } + #endregion + + #region Methods + public void Load() + { + MainTarget = new(true, ManagedRenderTarget.CreateScreenSizedTarget); + OnLoad(); + } + + /// + /// Called on mod load. + /// + public virtual void OnLoad() + { + + } + + /// + /// Called on mod unload. + /// + public virtual void OnUnload() + { + + } + + /// + /// Draw whatever needed to the target here. + /// + /// + public abstract void DrawToTarget(SpriteBatch spriteBatch); + + /// + /// Draw the target here. By default, just draws the target. + /// + /// + public virtual void DrawTarget(SpriteBatch spriteBatch) + { + spriteBatch.Draw(MainTarget, Vector2.Zero, Color.White); + } + #endregion + } +} diff --git a/Graphics/Drawers/DeerclopsShadowDrawer.cs b/Graphics/Drawers/DeerclopsShadowDrawer.cs new file mode 100644 index 0000000000..afe1284ed0 --- /dev/null +++ b/Graphics/Drawers/DeerclopsShadowDrawer.cs @@ -0,0 +1,69 @@ +using CalamityMod.NPCs.VanillaNPCOverrides.Bosses; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Rectangle = Microsoft.Xna.Framework.Rectangle; + +namespace CalamityMod.Graphics.Drawers +{ + public class DeerclopsShadowDrawer : BaseDrawer + { + #region Fields/Properties + + public override DrawerLayer Layer => DrawerLayer.AfterEverything; + + public NPC deerclops => Main.npc[NPC.deerclopsBoss]; + + //Should only draw if not in the main menu, deerclops is active or the border is fading post-death, + //it's rev+ and the boolean for drawing the border is true. + public override bool ShouldDraw => !Main.gameMenu && DeerclopsAI.borderScalar > 0f && DeerclopsAI.shouldDrawEnrageBorder; + #endregion + + #region Methods + public override void DrawToTarget(SpriteBatch spriteBatch) + { + bool shouldDraw; + bool deerclopsInactive = false; + if (NPC.deerclopsBoss >= 0 && NPC.deerclopsBoss.WithinBounds(Main.npc.Length)) + shouldDraw = deerclops.HasValidTarget; + else + { + shouldDraw = DeerclopsAI.borderScalar > 0f; + deerclopsInactive = true; + } + if (shouldDraw) + { + var minRadius = DeerclopsAI.innerBorder; + var maxRadius = DeerclopsAI.outerBorder; + + //Begin drawing the shadow + var blackTile = TextureAssets.MagicPixel; + + var shader = GameShaders.Misc["CalamityMod:DeerclopsShadowShader"].Shader; + shader.Parameters["minRadius"].SetValue(minRadius); + shader.Parameters["maxRadius"].SetValue(maxRadius); + shader.Parameters["anchorPoint"].SetValue(DeerclopsAI.lastDeerclopsPosition); + shader.Parameters["screenPosition"].SetValue(Main.screenPosition); + shader.Parameters["screenSize"].SetValue(Main.ScreenSize.ToVector2()); + shader.Parameters["maxOpacity"].SetValue(DeerclopsAI.borderScalar); + + + spriteBatch.EnterShaderRegion(BlendState.NonPremultiplied, shader); + Rectangle rekt = new(Main.screenWidth / 2, Main.screenHeight / 2, Main.screenWidth, Main.screenHeight); + spriteBatch.Draw(blackTile.Value, rekt, null, default, 0f, blackTile.Value.Size() * 0.5f, 0, 0f); + //Shadow drawing complete + spriteBatch.ExitShaderRegion(); + } + if (deerclopsInactive) + { + //Push the border away and fade out when deerclops is deadge + DeerclopsAI.borderScalar = MathHelper.Clamp(DeerclopsAI.borderScalar - 0.015f, 0f, 1f); + DeerclopsAI.innerBorder += 30f; + DeerclopsAI.outerBorder += 30f; + } + } + #endregion + } +} diff --git a/Graphics/Drawers/DrawerLayer.cs b/Graphics/Drawers/DrawerLayer.cs new file mode 100644 index 0000000000..9b628f88c4 --- /dev/null +++ b/Graphics/Drawers/DrawerLayer.cs @@ -0,0 +1,11 @@ +namespace CalamityMod.Graphics.Drawers +{ + public enum DrawerLayer + { + AfterEverything, + BeforeTiles, + NPC, + Player, + Projectile + } +} diff --git a/Graphics/Drawers/DrawerManager.cs b/Graphics/Drawers/DrawerManager.cs new file mode 100644 index 0000000000..f97909a487 --- /dev/null +++ b/Graphics/Drawers/DrawerManager.cs @@ -0,0 +1,186 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using log4net.Util; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Drawers +{ + public class DrawerManager : ModSystem + { + #region Fields/Properties + public static List Drawers + { + get; + private set; + } + #endregion + + #region Loading + public override void Load() + { + if (Main.netMode == NetmodeID.Server) + return; + + Drawers = new(); + + Main.QueueMainThreadAction(() => + { + // This hooks here, because doing it any sooner causes the screen position to be a frame behind. + On_Main.CheckMonoliths += DrawToTargets; + On_Main.DrawNPCs += DrawNPCDrawers; + On_Main.DrawProjectiles += DrawProjectileDrawers; + On_Main.DrawPlayers_AfterProjectiles += DrawPlayerDrawers; + On_Main.DrawBackgroundBlackFill += DrawBeforeTileDrawers; + On_Main.DrawInfernoRings += DrawAfterEverythingDrawers; + + var drawerType = typeof(BaseDrawer); + + foreach (var type in Mod.Code.GetTypes()) + { + if (!type.IsAbstract && type.IsSubclassOf(drawerType)) + { + var drawer = Activator.CreateInstance(type) as BaseDrawer; + drawer.Load(); + Drawers.Add(drawer); + } + } + }); + } + + public override void Unload() + { + if (Main.netMode == NetmodeID.Server) + return; + + Main.QueueMainThreadAction(() => + { + // Supposed to be auto-unloaded, but considering TMods poor track record with actually doing this, manually unload them. + On_Main.CheckMonoliths -= DrawToTargets; + On_Main.DrawNPCs -= DrawNPCDrawers; + On_Main.DrawProjectiles -= DrawProjectileDrawers; + On_Main.DrawPlayers_AfterProjectiles -= DrawPlayerDrawers; + On_Main.DrawBackgroundBlackFill -= DrawBeforeTileDrawers; + On_Main.DrawInfernoRings -= DrawAfterEverythingDrawers; + + foreach (var drawer in Drawers) + drawer.OnUnload(); + + Drawers = null; + }); + } + #endregion + + #region Drawing + private void DrawToTargets(On_Main.orig_CheckMonoliths orig) + { + orig(); + + if (Main.gameMenu) + return; + + foreach (var drawer in Drawers) + { + if (!drawer.ShouldDraw) + continue; + + drawer.MainTarget.SwapTo(Color.Transparent); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + drawer.DrawToTarget(Main.spriteBatch); + Main.spriteBatch.End(); + } + + Main.instance.GraphicsDevice.SetRenderTarget(null); + } + + private void DrawNPCDrawers(On_Main.orig_DrawNPCs orig, Main self, bool behindTiles) + { + orig(self, behindTiles); + + if (behindTiles) + return; + + var drawers = Drawers.Where(drawer => drawer.ShouldDraw && drawer.Layer is DrawerLayer.NPC); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer); + + foreach (var drawer in drawers) + drawer.DrawTarget(Main.spriteBatch); + + Main.spriteBatch.ExitShaderRegion(); + } + + private void DrawProjectileDrawers(On_Main.orig_DrawProjectiles orig, Main self) + { + orig(self); + + var drawers = Drawers.Where(drawer => drawer.ShouldDraw && drawer.Layer is DrawerLayer.Projectile); + + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer); + + foreach (var drawer in drawers) + drawer.DrawTarget(Main.spriteBatch); + + Main.spriteBatch.End(); + } + + private void DrawPlayerDrawers(On_Main.orig_DrawPlayers_AfterProjectiles orig, Main self) + { + orig(self); + + var drawers = Drawers.Where(drawer => drawer.ShouldDraw && drawer.Layer is DrawerLayer.Player); + + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer); + + foreach (var drawer in drawers) + drawer.DrawTarget(Main.spriteBatch); + + Main.spriteBatch.End(); + } + + private void DrawBeforeTileDrawers(On_Main.orig_DrawBackgroundBlackFill orig, Main self) + { + var drawers = Drawers.Where(drawer => drawer.ShouldDraw && drawer.Layer is DrawerLayer.BeforeTiles); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer); + foreach (var drawer in drawers) + drawer.DrawTarget(Main.spriteBatch); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.Transform); + + orig(self); + } + + private void DrawAfterEverythingDrawers(On_Main.orig_DrawInfernoRings orig, Main self) + { + var drawers = Drawers.Where(drawer => drawer.ShouldDraw && drawer.Layer is DrawerLayer.AfterEverything); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer); + foreach (var drawer in drawers) + drawer.DrawTarget(Main.spriteBatch); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.Transform); + orig(self); + } + #endregion + + #region Misc Methods + public static T GetDrawer() where T : BaseDrawer + { + if (!Drawers.Any()) + return null; + + return Drawers.First(drawer => drawer.GetType() == typeof(T)) as T; + } + #endregion + } +} diff --git a/Graphics/Drawers/HolyInfernoDrawer.cs b/Graphics/Drawers/HolyInfernoDrawer.cs new file mode 100644 index 0000000000..485db764bf --- /dev/null +++ b/Graphics/Drawers/HolyInfernoDrawer.cs @@ -0,0 +1,77 @@ +using CalamityMod.NPCs; +using CalamityMod.NPCs.Providence; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Terraria.ModLoader; +using Rectangle = Microsoft.Xna.Framework.Rectangle; + +namespace CalamityMod.Graphics.Drawers +{ + public class HolyInfernoDrawer : BaseDrawer + { + #region Fields/Properties + + public override DrawerLayer Layer => DrawerLayer.BeforeTiles; + + public Providence Provi => (Main.npc[CalamityGlobalNPC.holyBoss].ModNPC as Providence); + + //Should only draw if not in the main menu, provi is active and the boolean for drawing the border is true. + public override bool ShouldDraw => !Main.gameMenu && CalamityGlobalNPC.holyBoss != -1 && + Main.npc[CalamityGlobalNPC.holyBoss].active && Providence.shouldDrawInfernoBorder; + #endregion + + #region Methods + public override void DrawToTarget(SpriteBatch spriteBatch) + { + var npc = Main.npc[CalamityGlobalNPC.holyBoss]; + var borderDistance = Providence.borderRadius; + if (npc.HasValidTarget) + { + var target = Main.player[Main.myPlayer]; + var holyInfernoIntensity = target.Calamity().holyInfernoFadeIntensity; + var prov = Provi; + + //Begin drawing the inferno + var blackTile = TextureAssets.MagicPixel; + var diagonalNoise = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise"); + var upwardPerlinNoise = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Perlin"); + var upwardNoise = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/MeltyNoise"); + + var maxOpacity = 1f; + if (prov.Dying) + { + //Death animation timer ends at 345f. + maxOpacity = MathHelper.Lerp(1f, 0f, Utils.GetLerpValue(0f, 344f, prov.DeathAnimationTimer)); + } + + var shader = GameShaders.Misc["CalamityMod:HolyInfernoShader"].Shader; + shader.Parameters["colorMult"].SetValue(Main.dayTime ? 7.35f : 7.65f); //I want you to know it took considerable restraint to deliberately misspell colour. + shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); + shader.Parameters["radius"].SetValue(borderDistance); + shader.Parameters["anchorPoint"].SetValue(npc.Center); + shader.Parameters["screenPosition"].SetValue(Main.screenPosition); + shader.Parameters["screenSize"].SetValue(Main.ScreenSize.ToVector2()); + shader.Parameters["burnIntensity"].SetValue(holyInfernoIntensity); + shader.Parameters["playerPosition"].SetValue(target.Center); + shader.Parameters["maxOpacity"].SetValue(maxOpacity); + shader.Parameters["day"].SetValue(Main.dayTime); + + spriteBatch.GraphicsDevice.Textures[1] = diagonalNoise.Value; + spriteBatch.GraphicsDevice.Textures[2] = upwardNoise.Value; + spriteBatch.GraphicsDevice.Textures[3] = upwardPerlinNoise.Value; + + //Manual end begin for the sampler state + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, shader, Main.GameViewMatrix.TransformationMatrix); + Rectangle rekt = new(Main.screenWidth / 2, Main.screenHeight / 2, Main.screenWidth, Main.screenHeight); + spriteBatch.Draw(blackTile.Value, rekt, null, default, 0f, blackTile.Value.Size() * 0.5f, 0, 0f); + //Inferno drawing complete + spriteBatch.ExitShaderRegion(); + } + } + #endregion + } +} diff --git a/Graphics/Drawers/MiracleBlightDrawer.cs b/Graphics/Drawers/MiracleBlightDrawer.cs new file mode 100644 index 0000000000..1b4c936abe --- /dev/null +++ b/Graphics/Drawers/MiracleBlightDrawer.cs @@ -0,0 +1,93 @@ +using System.Collections.Generic; +using CalamityMod.NPCs.ExoMechs.Ares; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Drawers +{ + public class MiracleBlightDrawer : BaseDrawer + { + #region Fields/Properties + /// + /// Add NPCs to this if they break with the miracle blight shader. + /// + public static List ExcludedNPCs => new() + { + // List the reason why the NPC(s) are excluded :) + + // The particle sets break with the visuals and this is the easiest way to fix this that isn't stupidly complex. + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + + // Breaks with being behind tiles, and causes a funny interaction where his head goes behind his neck. + NPCID.MoonLordCore, + NPCID.MoonLordHand, + NPCID.MoonLordHead + }; + + /// + /// Used to determine whether the npc should return true in predraw or not, for exclusively drawing to the drawer target. + /// + public static bool ActuallyDoPreDraw + { + get; + private set; + } + + public override DrawerLayer Layer => DrawerLayer.NPC; + + // Unsure whether its more performant to always draw, or to check if any NPC actually has the debuff. + public override bool ShouldDraw => true; + #endregion + + #region Methods + // Only draw if: + // - A Vanilla or Calamity NPC OR another mod's non boss npc. + // - The NPC is active. + // - The NPC has miracle blight. + // - The current player does not have the shrooms effect. + // - The current NPC isnt in an excluded list of NPCs. + // - The current NPC does not have the polarity effect. + // If this seems really excessive, it's because global complex effects like this are a pain in the ass to implement without having a million + // broken edge cases. + public static bool ValidToDraw(NPC npc) => + (npc.ModNPC == null || npc.ModNPC.Mod == CalamityMod.Instance || !npc.boss) && npc.active && npc.Calamity().miracleBlight > 0 + && !(Main.LocalPlayer.Calamity().trippy && !npc.IsABestiaryIconDummy) && !ExcludedNPCs.Contains(npc.type) && npc.PolarityNPC().CurPolarity == 0; + + public override void DrawToTarget(SpriteBatch spriteBatch) + { + // Indicate that NPCs with miracle blight should draw. + ActuallyDoPreDraw = true; + + // Draw every npc to a single target that should have the miracle blight visual. + foreach (NPC npc in Main.npc) + { + if (ValidToDraw(npc)) + Main.instance.DrawNPC(npc.whoAmI, npc.behindTiles); + } + + // Indicate that NPCs with miracle blight should no longer draw. + ActuallyDoPreDraw = false; + } + + public override void DrawTarget(SpriteBatch spriteBatch) + { + // Apply the shader and draw the target. + MiscShaderData blightShader = GameShaders.Misc["CalamityMod:MiracleBlight"]; + blightShader.SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons"), 1); + blightShader.UseOpacity(0.7f); + blightShader.Shader.Parameters["uWorldPosition"]?.SetValue(Main.screenPosition); + blightShader.Apply(); + + Main.spriteBatch.Draw(MainTarget, Vector2.Zero, Color.White); + } + #endregion + } +} diff --git a/Graphics/ManagedRenderTarget.cs b/Graphics/ManagedRenderTarget.cs new file mode 100644 index 0000000000..2a3fea5dfe --- /dev/null +++ b/Graphics/ManagedRenderTarget.cs @@ -0,0 +1,107 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; + +namespace CalamityMod.Graphics +{ + /// + /// Wrapper class for that safely handles resizing, unloading and auto-disposal if not currently in use to save + /// on GPU memory. + /// + public class ManagedRenderTarget : IDisposable + { + private RenderTarget2D target; + + public readonly RenderTargetCreationCondition CreationCondition; + + public readonly bool ShouldResetUponScreenResize; + + public readonly bool ShouldAutoDispose; + + public bool WaitingForFirstInitialization + { + get; + private set; + } = true; + + public bool IsUninitialized => target is null || target.IsDisposed; + + public bool IsDisposed + { + get; + private set; + } + + /// + /// The actual instance that the wrapper contains. + /// + public RenderTarget2D Target + { + get + { + if (IsUninitialized) + { + target = CreationCondition(Main.screenWidth, Main.screenHeight); + WaitingForFirstInitialization = false; + IsDisposed = false; + } + + TimeSinceLastAccessed = 0; + return target; + } + private set => target = value; + } + + public int Width => Target.Width; + + public int Height => Target.Height; + + public Vector2 Size => new(Width, Height); + + /// + /// How many frames since this target has been gotten. Used to dispose of unused targets for the sake of performance. + /// + public int TimeSinceLastAccessed; + + public delegate RenderTarget2D RenderTargetCreationCondition(int screenWidth, int screenHeight); + + // For some reason, adding more arguments to this constructor causes really low end pcs to crash in FNA. I cannot figure out why, so do not use them. + public static RenderTarget2D CreateScreenSizedTarget(int screenWidth, int screenHeight) => new(Main.instance.GraphicsDevice, screenWidth, screenHeight); + + public ManagedRenderTarget(bool shouldResetUponScreenResize, RenderTargetCreationCondition creationCondition, bool shouldAutoDispose = true) + { + ShouldResetUponScreenResize = shouldResetUponScreenResize; + CreationCondition = creationCondition; + ShouldAutoDispose = shouldAutoDispose; + RenderTargetManager.ManagedTargets.Add(this); + } + + /// + /// Automatically called by , do not call! + /// + public void Dispose() + { + if (IsDisposed) + return; + + IsDisposed = true; + target?.Dispose(); + GC.SuppressFinalize(this); + } + + /// + /// Automatically called by , do not call! + /// + public void Recreate(int screenWidth, int screenHeight) + { + Dispose(); + IsDisposed = false; + + target = CreationCondition(screenWidth, screenHeight); + TimeSinceLastAccessed = 0; + } + + public static implicit operator RenderTarget2D(ManagedRenderTarget target) => target.Target; + } +} diff --git a/Graphics/Metaballs/BloodBoilerMetaball.cs b/Graphics/Metaballs/BloodBoilerMetaball.cs new file mode 100644 index 0000000000..d5d29fd0c8 --- /dev/null +++ b/Graphics/Metaballs/BloodBoilerMetaball.cs @@ -0,0 +1,104 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class BloodBoilerMetaball : Metaball + { + public class BloodBoilerParticle + { + public Vector2 Center; + public float Size; + + public BloodBoilerParticle(Vector2 center, float size) + { + Center = center; + Size = size; + } + + public void Update() + { + // Always slowly shrink the particles. + Size = MathHelper.Clamp(Size - 0.1f, 0f, 200f) * 0.91f; + + // Once sufficiently small, the particles very rapidly shrink. + if (Size < 20f) + Size = Size * 0.8f - 1f; + } + } + + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public override Color EdgeColor => Color.DarkRed; + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + + // Copied from Rancor Lava metaballs, since these need to be additive metaballs. + public override void PrepareShaderForTarget(int layerIndex) + { + // Store the shader in an easy to use local variable. + var metaballShader = CalamityShaders.AdditiveMetaballEdgeShader; + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + // Supply shader parameter values. + metaballShader.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public static void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); + + public override void DrawInstances() + { + float pureRedIntensity = 0.15f; + float opacity = 0.5f; + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value; + + foreach (BloodBoilerParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + var origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + + float pureRedInterpolant = Utils.GetLerpValue(25f, 60f, particle.Size, true) * pureRedIntensity; + Color drawColor = Color.Lerp(EdgeColor, Color.DarkRed, pureRedInterpolant).MultiplyRGBA(new Color(1f, 1f, 1f, opacity)); + + Main.spriteBatch.Draw(tex, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/BloodBoilerMetaball2.cs b/Graphics/Metaballs/BloodBoilerMetaball2.cs new file mode 100644 index 0000000000..873604126a --- /dev/null +++ b/Graphics/Metaballs/BloodBoilerMetaball2.cs @@ -0,0 +1,104 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class BloodBoilerMetaball2 : Metaball + { + public class BloodBoilerParticle2 + { + public Vector2 Center; + public float Size; + + public BloodBoilerParticle2(Vector2 center, float size) + { + Center = center; + Size = size; + } + + public void Update() + { + // Always slowly shrink the particles. + Size = MathHelper.Clamp(Size - 0.1f, 0f, 200f) * 0.91f; + + // Once sufficiently small, the particles very rapidly shrink. + if (Size < 20f) + Size = Size * 0.8f - 1f; + } + } + + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public override Color EdgeColor => Color.DarkRed; + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + + // Copied from Rancor Lava metaballs, since these need to be additive metaballs. + public override void PrepareShaderForTarget(int layerIndex) + { + // Store the shader in an easy to use local variable. + var metaballShader = CalamityShaders.AdditiveMetaballEdgeShader; + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + // Supply shader parameter values. + metaballShader.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public static void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); + + public override void DrawInstances() + { + float pureRedIntensity = 0.15f; + float opacity = 0.3f; + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value; + + foreach (BloodBoilerParticle2 particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + var origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + + float pureRedInterpolant = Utils.GetLerpValue(25f, 60f, particle.Size, true) * pureRedIntensity; + Color drawColor = Color.Lerp(EdgeColor, Color.DarkRed, pureRedInterpolant).MultiplyRGBA(new Color(1f, 1f, 1f, opacity)); + + Main.spriteBatch.Draw(tex, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/DragonsBreathMetaball.cs b/Graphics/Metaballs/DragonsBreathMetaball.cs new file mode 100644 index 0000000000..e041506bb2 --- /dev/null +++ b/Graphics/Metaballs/DragonsBreathMetaball.cs @@ -0,0 +1,127 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class DragonsBreathFlameMetaball : DragonsBreathMetaball + { + // OrangeRed is FF4500 + // new Color(0xFF, 0x3A, 0x0A); + public override Color EdgeColor => Color.Orange; + + // Flame metaballs never turn white + public override void DrawInstances() => DrawInstancesInternal(0.03f, -1f); + } + public class DragonsBreathBeamMetaball : DragonsBreathMetaball + { + private static float whiteSizeThreshold = 72f; + + public override Color EdgeColor => Color.Orange; + + // Laser metaballs very suddenly turn white at a specific size + public override void DrawInstances() => DrawInstancesInternal(0.4f, whiteSizeThreshold); + } + + public abstract class DragonsBreathMetaball : Metaball + { + // Identical behavior to Blood Boiler particles + public class DragonsBreathParticle + { + public Vector2 Center; + public float Size; + + public DragonsBreathParticle(Vector2 center, float size) + { + Center = center; + Size = size; + } + + public void Update() + { + // Always slowly shrink the particles. + Size = MathHelper.Clamp(Size - 0.1f, 0f, 200f) * 0.91f; + + // Once sufficiently small, the particles very rapidly shrink. + if (Size < 5f) + Size = Size * 0.8f - 1f; + } + } + + public List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + + // Copied from Rancor Lava metaballs, since these need to be additive metaballs. + public override void PrepareShaderForTarget(int layerIndex) + { + // Store the shader in an easy to use local variable. + var metaballShader = CalamityShaders.AdditiveMetaballEdgeShader; + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + // Supply shader parameter values. + metaballShader.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); + + internal void DrawInstancesInternal(float opacity, float whiteSizeThreshold) + { + float pureWhiteIntensity = 0.16f; + Texture2D tex = ModContent.Request("CalamityMod/Graphics/Metaballs/MetaballMessy").Value; + + foreach (DragonsBreathParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + var origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + + Color drawColor; + if (whiteSizeThreshold >= 0f) + { + float pureWhiteInterpolant = Utils.GetLerpValue(0.8f * whiteSizeThreshold, whiteSizeThreshold, particle.Size, true) * pureWhiteIntensity; + drawColor = Color.Lerp(EdgeColor, Color.DarkOrange, pureWhiteInterpolant) * opacity; + } + else + drawColor = Color.Lerp(EdgeColor, new Color(0xE0, 0x70, 0x10), Utils.GetLerpValue(60f, 100f, particle.Size, true) * 0.75f); + + Main.spriteBatch.Draw(tex, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/DragonsBreathMetaball2.cs b/Graphics/Metaballs/DragonsBreathMetaball2.cs new file mode 100644 index 0000000000..c07f13e894 --- /dev/null +++ b/Graphics/Metaballs/DragonsBreathMetaball2.cs @@ -0,0 +1,127 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class DragonsBreathFlameMetaball2 : DragonsBreathMetaball + { + // OrangeRed is FF4500 + // new Color(0xFF, 0x3A, 0x0A); + public override Color EdgeColor => Color.OrangeRed; + + // Flame metaballs never turn white + public override void DrawInstances() => DrawInstancesInternal(0.03f, -1f); + } + public class DragonsBreathBeamMetaball2 : DragonsBreathMetaball2 + { + private static float whiteSizeThreshold = 72f; + + public override Color EdgeColor => Color.OrangeRed * 1.2f; + + // Laser metaballs very suddenly turn white at a specific size + public override void DrawInstances() => DrawInstancesInternal(0.4f, whiteSizeThreshold); + } + + public abstract class DragonsBreathMetaball2 : Metaball + { + // Identical behavior to Blood Boiler particles + public class DragonsBreathParticle2 + { + public Vector2 Center; + public float Size; + + public DragonsBreathParticle2(Vector2 center, float size) + { + Center = center; + Size = size; + } + + public void Update() + { + // Always slowly shrink the particles. + Size = MathHelper.Clamp(Size - 0.1f, 0f, 200f) * 0.91f; + + // Once sufficiently small, the particles very rapidly shrink. + if (Size < 20f) + Size = Size * 0.8f - 1f; + } + } + + public List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + + // Copied from Rancor Lava metaballs, since these need to be additive metaballs. + public override void PrepareShaderForTarget(int layerIndex) + { + // Store the shader in an easy to use local variable. + var metaballShader = CalamityShaders.AdditiveMetaballEdgeShader; + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + // Supply shader parameter values. + metaballShader.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); + + internal void DrawInstancesInternal(float opacity, float whiteSizeThreshold) + { + float pureWhiteIntensity = 0.16f; + Texture2D tex = ModContent.Request("CalamityMod/Graphics/Metaballs/MetaballMessy").Value; + + foreach (DragonsBreathParticle2 particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + var origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + + Color drawColor; + if (whiteSizeThreshold >= 0f) + { + float pureWhiteInterpolant = Utils.GetLerpValue(0.8f * whiteSizeThreshold, whiteSizeThreshold, particle.Size, true) * pureWhiteIntensity; + drawColor = Color.Lerp(EdgeColor, Color.White, pureWhiteInterpolant) * opacity; + } + else + drawColor = Color.Lerp(EdgeColor, Color.DarkOrange, Utils.GetLerpValue(60f, 100f, particle.Size, true) * 0.3f); + + Main.spriteBatch.Draw(tex, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Particles/Metaballs/GruesomeEminence_Ghost_Layer1.png b/Graphics/Metaballs/GruesomeEminence_Ghost_Layer1.png similarity index 100% rename from Particles/Metaballs/GruesomeEminence_Ghost_Layer1.png rename to Graphics/Metaballs/GruesomeEminence_Ghost_Layer1.png diff --git a/Particles/Metaballs/GruesomeEminence_Ghost_Layer2.png b/Graphics/Metaballs/GruesomeEminence_Ghost_Layer2.png similarity index 100% rename from Particles/Metaballs/GruesomeEminence_Ghost_Layer2.png rename to Graphics/Metaballs/GruesomeEminence_Ghost_Layer2.png diff --git a/Particles/Metaballs/GruesomeEminence_Ghost_Layer3.png b/Graphics/Metaballs/GruesomeEminence_Ghost_Layer3.png similarity index 100% rename from Particles/Metaballs/GruesomeEminence_Ghost_Layer3.png rename to Graphics/Metaballs/GruesomeEminence_Ghost_Layer3.png diff --git a/Particles/Metaballs/GruesomeEminence_Ghost_Layer4.png b/Graphics/Metaballs/GruesomeEminence_Ghost_Layer4.png similarity index 100% rename from Particles/Metaballs/GruesomeEminence_Ghost_Layer4.png rename to Graphics/Metaballs/GruesomeEminence_Ghost_Layer4.png diff --git a/Particles/Metaballs/GruesomeEminence_Ghost_Layer5.png b/Graphics/Metaballs/GruesomeEminence_Ghost_Layer5.png similarity index 100% rename from Particles/Metaballs/GruesomeEminence_Ghost_Layer5.png rename to Graphics/Metaballs/GruesomeEminence_Ghost_Layer5.png diff --git a/Graphics/Metaballs/GruesomeMetaball.cs b/Graphics/Metaballs/GruesomeMetaball.cs new file mode 100644 index 0000000000..f1d273a344 --- /dev/null +++ b/Graphics/Metaballs/GruesomeMetaball.cs @@ -0,0 +1,143 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class GruesomeMetaball : Metaball + { + public class GruesomeParticle + { + public float Size; + + public Vector2 Velocity; + + public Vector2 Center; + + public GruesomeParticle(Vector2 center, Vector2 velocity, float size) + { + Center = center; + Velocity = velocity; + Size = size; + } + + public void Update() + { + Size *= 0.94f; + Center += Velocity; + Velocity *= 0.96f; + } + } + + private static List> layerAssets; + + public static List Particles + { + get; + private set; + } = new(); + + // Check if there are any extraneous particles or if the Gruesome Eminence projectile is present when deciding if this particle should be drawn. + public override bool AnythingToDraw => Particles.Any() || CalamityUtils.AnyProjectiles(ModContent.ProjectileType()); + + public override IEnumerable Layers + { + get + { + for (int i = 0; i < layerAssets.Count; i++) + yield return layerAssets[i].Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public override Color EdgeColor => new(61, 6, 2); + + public override void Load() + { + if (Main.netMode == NetmodeID.Server) + return; + + // Load layer assets. + layerAssets = new(); + + for (int i = 1; i <= 5; i++) + layerAssets.Add(ModContent.Request($"CalamityMod/Graphics/Metaballs/GruesomeEminence_Ghost_Layer{i}", AssetRequestMode.ImmediateLoad)); + } + + public override void ClearInstances() => Particles.Clear(); + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2.5f); + } + + public static void SpawnParticle(Vector2 position, Vector2 velocity, float size) => + Particles.Add(new(position, velocity, size)); + + public override Vector2 CalculateManualOffsetForLayer(int layerIndex) + { + switch (layerIndex) + { + // Background. + case 0: + return Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.03f; + + // Gaseous skulls. + case 1: + Vector2 offset = Vector2.One * (float)Math.Cos(Main.GlobalTimeWrappedHourly * 0.041f) * 2f; + offset = offset.RotatedBy((float)Math.Cos(Main.GlobalTimeWrappedHourly * 0.08f) * 0.97f); + return offset; + + // Spooky faces 1. + case 2: + offset = (Main.GlobalTimeWrappedHourly * 2.02f).ToRotationVector2() * 0.036f; + offset.Y += (float)Math.Cos(Main.GlobalTimeWrappedHourly * 0.161f) * 0.5f + 0.5f; + return offset; + + // Spooky faces 2. + case 3: + offset = Vector2.UnitX * Main.GlobalTimeWrappedHourly * -0.04f + (Main.GlobalTimeWrappedHourly * 1.89f).ToRotationVector2() * 0.03f; + offset.Y += CalamityUtils.PerlinNoise2D(Main.GlobalTimeWrappedHourly * 0.187f, Main.GlobalTimeWrappedHourly * 0.193f, 2, 466920161) * 0.025f; + return offset; + + // Spooky faces 3. + case 4: + offset = Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.037f + (Main.GlobalTimeWrappedHourly * 1.77f).ToRotationVector2() * 0.04725f; + offset.Y += CalamityUtils.PerlinNoise2D(Main.GlobalTimeWrappedHourly * 0.187f, Main.GlobalTimeWrappedHourly * 0.193f, 2, 577215664) * 0.05f; + return offset; + } + + return Vector2.Zero; + } + + public override void DrawInstances() + { + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; + + // Draw all particles. + foreach (GruesomeParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + Main.spriteBatch.Draw(tex, drawPosition, null, Color.White, 0f, origin, scale, 0, 0f); + } + + // Draw gruesome eminence ghost heads. + foreach (Projectile eminence in CalamityUtils.AllProjectilesByID(ModContent.ProjectileType())) + eminence.ModProjectile().DrawHeadForMetaball(); + } + } +} diff --git a/Graphics/Metaballs/Metaball.cs b/Graphics/Metaballs/Metaball.cs new file mode 100644 index 0000000000..0ad632f8ae --- /dev/null +++ b/Graphics/Metaballs/Metaball.cs @@ -0,0 +1,151 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public abstract class Metaball : ModType + { + internal List LayerTargets = new(); + + /// + /// Required utility that is used to determine whether this metaball has anything to draw.

+ /// This exists for efficiency, ensuring that as few operations are executed as possible when not required. + ///
+ public abstract bool AnythingToDraw + { + get; + } + + /// + /// The collection of all textures to draw on top of the metaball contents. + /// + public abstract IEnumerable Layers + { + get; + } + + /// + /// The draw layer in which metaballs should be drawn. + /// + public abstract MetaballDrawLayer DrawContext + { + get; + } + + /// + /// The color that metaballs should draw at the edge between air and particle contents. + /// + public abstract Color EdgeColor + { + get; + } + + /// + /// Whether the layer overlay contents from should be fixed to the screen.

+ /// When true, the texture will be statically drawn to the screen with no respect for world position. + ///
+ public virtual bool FixedToScreen => false; + + /// + /// Optionally overridable method for clearing particle instances as necessary. This is used automatically in contexts such as world unloads. + /// + public virtual void ClearInstances() { } + + /// + /// Optionally overridable method that can be used to update the metaball set. This can be useful for over-time update effects or for keeping special data particle types all updated. + /// + public virtual void Update() { } + + /// + /// Optionally overridable method that can be used to make layers offset when drawn, to allow for layer-specific animations. Defaults to , aka no animation. + /// + public virtual Vector2 CalculateManualOffsetForLayer(int layerIndex) => Vector2.Zero; + + /// + /// Optionally overridable method that allows for preparations prior to the drawing of the individual raw metaball instances (Not the final result).

+ /// An example of this could be having the metaball particles drawn with . + ///
+ /// Shorthand parameter for . + public virtual void PrepareSpriteBatch(SpriteBatch spriteBatch) { } + + /// + /// Optionally overridable method that defines for preparations for the render target. Defaults to using the typical texture overlay behavior. + /// + /// The layer index that should be prepared for. + public virtual void PrepareShaderForTarget(int layerIndex) + { + // Store the graphics device and shader in easy to use local variables. + var metaballShader = CalamityShaders.MetaballEdgeShader; + var gd = Main.instance.GraphicsDevice; + + // Fetch the layer texture. This is the texture that will be overlayed over the greyscale contents on the screen. + Texture2D layerTexture = Layers.ElementAt(layerIndex); + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + // This may be toggled off optionally by the metaball. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + Vector2 layerScrollOffset = Main.screenPosition / screenSize + CalculateManualOffsetForLayer(layerIndex); + if (FixedToScreen) + layerScrollOffset = Vector2.Zero; + + // Supply shader parameter values. + metaballShader.Parameters["layerSize"]?.SetValue(layerTexture.Size()); + metaballShader.Parameters["screenSize"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(layerScrollOffset); + metaballShader.Parameters["edgeColor"]?.SetValue(EdgeColor.ToVector4()); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue((Main.screenLastPosition - Main.screenPosition) / screenSize); + + // Supply the metaball's layer texture to the graphics device so that the shader can read it. + gd.Textures[1] = layerTexture; + gd.SamplerStates[1] = SamplerState.LinearWrap; + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + /// + /// Required overridable that is intended to draw all metaball instances. + /// + public abstract void DrawInstances(); + + protected sealed override void Register() + { + // Register this metaball mod TML's inbuilt ModType handlers. + ModTypeLookup.Register(this); + + // Store this metaball instance in the personalized manager so that it can be kept track of for rendering purposes. + if (!MetaballManager.metaballs.Contains(this)) + MetaballManager.metaballs.Add(this); + + // Disallow render target creation on servers. + if (Main.netMode == NetmodeID.Server) + return; + + // Generate render targets. + Main.QueueMainThreadAction(() => + { + // Load render targets. + int layerCount = Layers.Count(); + for (int i = 0; i < layerCount; i++) + LayerTargets.Add(new(true, ManagedRenderTarget.CreateScreenSizedTarget)); + }); + } + + /// + /// Disposes of all unmanaged GPU resources used up by the . This is called automatically on mod unload.

+ /// It is your responsibility to recreate layer targets later if you call this method manually. + ///
+ public void Dispose() + { + for (int i = 0; i < LayerTargets.Count; i++) + LayerTargets[i]?.Dispose(); + } + } +} diff --git a/Particles/Metaballs/FusableParticleBase.png b/Graphics/Metaballs/MetaballBase.png similarity index 100% rename from Particles/Metaballs/FusableParticleBase.png rename to Graphics/Metaballs/MetaballBase.png diff --git a/Graphics/Metaballs/MetaballDrawLayer.cs b/Graphics/Metaballs/MetaballDrawLayer.cs new file mode 100644 index 0000000000..d061aabe61 --- /dev/null +++ b/Graphics/Metaballs/MetaballDrawLayer.cs @@ -0,0 +1,9 @@ +namespace CalamityMod.Graphics.Metaballs +{ + public enum MetaballDrawLayer + { + BeforeNPCs, + BeforeProjectiles, + AfterProjectiles, + } +} diff --git a/Graphics/Metaballs/MetaballManager.cs b/Graphics/Metaballs/MetaballManager.cs new file mode 100644 index 0000000000..832785925e --- /dev/null +++ b/Graphics/Metaballs/MetaballManager.cs @@ -0,0 +1,135 @@ +using System.Collections.Generic; +using System.Linq; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class MetaballManager : ModSystem + { + internal static readonly List metaballs = new(); + + public override void OnModLoad() + { + // Prepare event subscribers. + RenderTargetManager.RenderTargetUpdateLoopEvent += PrepareMetaballTargets; + On_Main.DrawProjectiles += DrawMetaballsAfterProjectiles; + On_Main.DrawNPCs += DrawMetaballsBeforeNPCs; + } + + public override void OnModUnload() + { + // Clear all unmanaged metaball target resources on the GPU on mod unload. + Main.QueueMainThreadAction(() => + { + foreach (Metaball metaball in metaballs) + metaball?.Dispose(); + }); + } + + public override void OnWorldUnload() + { + foreach (Metaball metaball in metaballs) + metaball.ClearInstances(); + } + + private void PrepareMetaballTargets() + { + // Get a list of all metaballs currently in use. + var activeMetaballs = metaballs.Where(m => m.AnythingToDraw); + + // Don't bother wasting resources if metaballs are not in use at the moment. + if (!activeMetaballs.Any()) + return; + + // Prepare the sprite batch for drawing. Metaballs may restart the sprite batch via PrepareSpriteBatch if their implementation requires it. + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); + + var gd = Main.instance.GraphicsDevice; + foreach (Metaball metaball in activeMetaballs) + { + // Update the metaball collection. + if (!Main.gamePaused) + metaball.Update(); + + // Prepare the sprite batch in accordance to the needs of the metaball instance. By default this does nothing, + metaball.PrepareSpriteBatch(Main.spriteBatch); + + // Draw the raw contents of the metaball to each of its render targets. + foreach (ManagedRenderTarget target in metaball.LayerTargets) + { + gd.SetRenderTarget(target); + gd.Clear(Color.Transparent); + metaball.DrawInstances(); + + // Flush metaball contents to its render target and reset the sprite batch for the next iteration. + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); + } + } + + // Return to the backbuffer and end the sprite batch. + gd.SetRenderTarget(null); + Main.spriteBatch.End(); + } + + private void DrawMetaballsAfterProjectiles(On_Main.orig_DrawProjectiles orig, Main self) + { + if (AnyActiveMetaballsAtLayer(MetaballDrawLayer.BeforeProjectiles)) + { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + DrawMetaballs(MetaballDrawLayer.BeforeProjectiles); + Main.spriteBatch.End(); + } + + orig(self); + + if (AnyActiveMetaballsAtLayer(MetaballDrawLayer.AfterProjectiles)) + { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + DrawMetaballs(MetaballDrawLayer.AfterProjectiles); + Main.spriteBatch.End(); + } + } + + private void DrawMetaballsBeforeNPCs(On_Main.orig_DrawNPCs orig, Main self, bool behindTiles) + { + if (!behindTiles && AnyActiveMetaballsAtLayer(MetaballDrawLayer.BeforeNPCs)) + { + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + DrawMetaballs(MetaballDrawLayer.BeforeNPCs); + Main.spriteBatch.ExitShaderRegion(); + } + orig(self, behindTiles); + } + + /// + /// Checks if a metaball of a given layering type is currently in use. This is used to minimize needless restarts when there is nothing to draw. + /// + /// The metaball layer type to check against. + internal static bool AnyActiveMetaballsAtLayer(MetaballDrawLayer layerType) => + metaballs.Any(m => m.AnythingToDraw && m.DrawContext == layerType); + + /// + /// Draws all metaballs of a given . Used for layer ordering reasons. + /// + /// The layer type to draw with. + public static void DrawMetaballs(MetaballDrawLayer layerType) + { + foreach (Metaball metaball in metaballs.Where(m => m.DrawContext == layerType && m.AnythingToDraw)) + { + for (int i = 0; i < metaball.LayerTargets.Count; i++) + { + // Prepare shaders for the given layer target. + metaball.PrepareShaderForTarget(i); + + // Draw the metaball's raw contents with the shader. + Main.spriteBatch.Draw(metaball.LayerTargets[i], Main.screenLastPosition - Main.screenPosition, Color.White); + } + } + } + } +} diff --git a/Graphics/Metaballs/MetaballMessy.png b/Graphics/Metaballs/MetaballMessy.png new file mode 100644 index 0000000000..cee0b3c12f Binary files /dev/null and b/Graphics/Metaballs/MetaballMessy.png differ diff --git a/Graphics/Metaballs/PaintMetaballs.cs b/Graphics/Metaballs/PaintMetaballs.cs new file mode 100644 index 0000000000..bfe0fc2cc7 --- /dev/null +++ b/Graphics/Metaballs/PaintMetaballs.cs @@ -0,0 +1,132 @@ +using CalamityMod.Effects; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class CyanPaint : PaintMetaball + { + public override Color EdgeColor => Color.Cyan * 0.7f; + } + + public class BluePaint : PaintMetaball + { + public override Color EdgeColor => Color.Blue * 0.7f; + } + + public class MagentaPaint : PaintMetaball + { + public override Color EdgeColor => Color.Magenta * 0.7f; + } + + public class LimePaint : PaintMetaball + { + public override Color EdgeColor => Color.Lime * 0.7f; + } + + public class YellowPaint : PaintMetaball + { + public override Color EdgeColor => Color.Yellow * 0.7f; + } + + public abstract class PaintMetaball : Metaball + { + public class PaintParticle + { + public float Size; + + public Vector2 Center; + + public PaintParticle(Vector2 center, float size) + { + Center = center; + Size = size; + } + + public void Update() + { + Size = MathHelper.Clamp(Size - 0.1f, 0f, 200f) * 0.997f; + if (Size < 20f) + Size = Size * 0.8f - 1f; + } + } + + // This list is personalized between the various subclasses. + public List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public override void ClearInstances() => Particles.Clear(); + + public override void PrepareShaderForTarget(int layerIndex) + { + // Store the shader in an easy to use local variable. + var metaballShader = CalamityShaders.AdditiveMetaballEdgeShader; + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + // Supply shader parameter values. + metaballShader.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public void SpawnParticle(Vector2 position, float size) => + Particles.Add(new(position, size)); + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 3f); + } + + public override void PrepareSpriteBatch(SpriteBatch spriteBatch) + { + // Draw with additive blending. + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); + } + + public override void DrawInstances() + { + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value; + + // Draw all particles. + foreach (PaintParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + Color paintColor = Color.Lerp(EdgeColor, new Color(0f, 0f, 1f), Utils.GetLerpValue(50f, 100f, particle.Size, true) * 0.1f) * 1.2f; + + Main.spriteBatch.Draw(tex, drawPosition, null, paintColor, 0f, origin, scale, 0, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/PhotoMetaball.cs b/Graphics/Metaballs/PhotoMetaball.cs new file mode 100644 index 0000000000..528537a831 --- /dev/null +++ b/Graphics/Metaballs/PhotoMetaball.cs @@ -0,0 +1,122 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class PhotoMetaball : Metaball + { + public class PhotoParticle + { + public Vector2 Center; + public float Size; + public int Time = 0; + public float OrginSize; + + public PhotoParticle(Vector2 center, float size) + { + Center = center; + Size = size; + } + + public void Update() + { + Time++; + if (Time == 1) + OrginSize = Size; + // Always slowly shrink the particles. + Size = MathHelper.Clamp(Size - 0.8f, 0f, 1000f) * 0.96f; + + // Once sufficiently small, the particles very rapidly shrink. + if (Size < OrginSize * 0.15f) + Size = 2; + } + } + + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public Color sparkColor; + public int Time = 0; + public override Color EdgeColor => sparkColor; + + public override void Update() + { + Time++; + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + if (Time % 10 == 0) + { + sparkColor = Main.rand.Next(4) switch + { + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + } + } + + // Copied from Rancor Lava metaballs, since these need to be additive metaballs. + public override void PrepareShaderForTarget(int layerIndex) + { + // Store the shader in an easy to use local variable. + var metaballShader = CalamityShaders.AdditiveMetaballEdgeShader; + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + // Supply shader parameter values. + metaballShader.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public static void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); + + public override void DrawInstances() + { + float opacity = 1f; + Texture2D tex = ModContent.Request("CalamityMod/Graphics/Metaballs/MetaballMessy").Value; + + foreach (PhotoParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + var origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + + float Interpolant = Utils.GetLerpValue(25f, 60f, particle.Size * 0.6f, true); + Color drawColor = Color.Lerp(EdgeColor, Color.White * 0.9f, Interpolant).MultiplyRGBA(new Color(1f, 1f, 1f, opacity)); + + Main.spriteBatch.Draw(tex, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/PhotoMetaball2.cs b/Graphics/Metaballs/PhotoMetaball2.cs new file mode 100644 index 0000000000..98a189e8cf --- /dev/null +++ b/Graphics/Metaballs/PhotoMetaball2.cs @@ -0,0 +1,123 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class PhotoMetaball2 : Metaball + { + public class PhotoParticle2 + { + public Vector2 Center; + public float Size; + public int Time = 0; + public float OrginSize; + + public PhotoParticle2(Vector2 center, float size) + { + Center = center; + Size = size; + } + + public void Update() + { + Time++; + if (Time == 1) + OrginSize = Size; + // Always slowly shrink the particles. + Size = MathHelper.Clamp(Size - 0.8f, 0f, 1000f) * 0.96f; + + // Once sufficiently small, the particles very rapidly shrink. + if (Size < OrginSize * 0.15f) + Size = 2; + } + } + + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public Color sparkColor; + public int Time; + public override Color EdgeColor => sparkColor * 5; + + public override void Update() + { + Time++; + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + if (Time % 8 == 0) + { + sparkColor = Main.rand.Next(4) switch + { + 0 => Color.DarkRed, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + } + + } + + // Copied from Rancor Lava metaballs, since these need to be additive metaballs. + public override void PrepareShaderForTarget(int layerIndex) + { + // Store the shader in an easy to use local variable. + var metaballShader = CalamityShaders.AdditiveMetaballEdgeShader; + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + // Supply shader parameter values. + metaballShader.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public static void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); + + public override void DrawInstances() + { + float opacity = 1f; + Texture2D tex = ModContent.Request("CalamityMod/Graphics/Metaballs/MetaballMessy").Value; + + foreach (PhotoParticle2 particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + var origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + + float Interpolant = Utils.GetLerpValue(25f, 60f, particle.Size * 0.6f, true); + Color drawColor = Color.Lerp(Color.White, EdgeColor, Interpolant).MultiplyRGBA(new Color(1f, 1f, 1f, opacity)); + + Main.spriteBatch.Draw(tex, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/PhotoMetaball3.cs b/Graphics/Metaballs/PhotoMetaball3.cs new file mode 100644 index 0000000000..95f2645dfc --- /dev/null +++ b/Graphics/Metaballs/PhotoMetaball3.cs @@ -0,0 +1,116 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class PhotoMetaball3 : Metaball + { + public class PhotoParticle3 + { + public Vector2 Center; + public float Size; + public int Time = 0; + + public PhotoParticle3(Vector2 center, float size) + { + Center = center; + Size = size; + } + + public void Update() + { + Time++; + if (Time >= 6) + Size = 2; + } + } + + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public Color sparkColor; + public int Time = 0; + public override Color EdgeColor => sparkColor; + + public override void Update() + { + Time++; + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + + if (Time % 10 == 0) + { + sparkColor = Main.rand.Next(4) switch + { + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + } + } + + // Copied from Rancor Lava metaballs, since these need to be additive metaballs. + public override void PrepareShaderForTarget(int layerIndex) + { + // Store the shader in an easy to use local variable. + var metaballShader = CalamityShaders.AdditiveMetaballEdgeShader; + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + // Supply shader parameter values. + metaballShader.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public static void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); + + public override void DrawInstances() + { + float opacity = 1f; + Texture2D tex = ModContent.Request("CalamityMod/Graphics/Metaballs/MetaballMessy").Value; + + foreach (PhotoParticle3 particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + var origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + + float Interpolant = Utils.GetLerpValue(25f, 60f, particle.Size * 0.6f, true); + Color drawColor = Color.Lerp(EdgeColor, Color.White * 0.9f, Interpolant).MultiplyRGBA(new Color(1f, 1f, 1f, opacity)); + + Main.spriteBatch.Draw(tex, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/PhotoMetaball4.cs b/Graphics/Metaballs/PhotoMetaball4.cs new file mode 100644 index 0000000000..8aa4e991a5 --- /dev/null +++ b/Graphics/Metaballs/PhotoMetaball4.cs @@ -0,0 +1,117 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class PhotoMetaball4 : Metaball + { + public class PhotoParticle4 + { + public Vector2 Center; + public float Size; + public int Time = 0; + + public PhotoParticle4(Vector2 center, float size) + { + Center = center; + Size = size; + } + + public void Update() + { + Time++; + if (Time >= 6) + Size = 2; + } + } + + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public Color sparkColor; + public int Time; + public override Color EdgeColor => sparkColor * 5; + + public override void Update() + { + Time++; + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + + if (Time % 8 == 0) + { + sparkColor = Main.rand.Next(4) switch + { + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + } + + } + + // Copied from Rancor Lava metaballs, since these need to be additive metaballs. + public override void PrepareShaderForTarget(int layerIndex) + { + // Store the shader in an easy to use local variable. + var metaballShader = CalamityShaders.AdditiveMetaballEdgeShader; + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + // Supply shader parameter values. + metaballShader.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public static void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); + + public override void DrawInstances() + { + float opacity = 1f; + Texture2D tex = ModContent.Request("CalamityMod/Graphics/Metaballs/MetaballMessy").Value; + + foreach (PhotoParticle4 particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + var origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + + float Interpolant = Utils.GetLerpValue(25f, 60f, particle.Size * 0.6f, true); + Color drawColor = Color.Lerp(Color.White, EdgeColor, Interpolant).MultiplyRGBA(new Color(1f, 1f, 1f, opacity)); + + Main.spriteBatch.Draw(tex, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/RancorLavaMetaball.cs b/Graphics/Metaballs/RancorLavaMetaball.cs new file mode 100644 index 0000000000..60882cf578 --- /dev/null +++ b/Graphics/Metaballs/RancorLavaMetaball.cs @@ -0,0 +1,121 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria.ModLoader; +using Terraria; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using System; + +namespace CalamityMod.Graphics.Metaballs +{ + // CONSIDER -- Dominic 01NOV2023 This really should not be a metaball. Some sort of separately drawn fire effect would be far more suitable, and overall less awkward. + // However, for consistency with the previous effect, I'll leave it as is. + public class RancorLavaMetaball : Metaball + { + public class LavaParticle + { + public int Time; + + public float Size; + + public Vector2 Center; + + public LavaParticle(Vector2 center, float size) + { + Center = center; + Size = size; + } + + public void Update() + { + Time++; + Size = MathHelper.Clamp(Size - 0.24f, 0f, 200f) * 0.9956f; + if (Size < 15f) + Size = Size * 0.95f - 0.9f; + } + } + + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public override Color EdgeColor => new(255, 56, 3); + + public override void ClearInstances() => Particles.Clear(); + + public override void PrepareShaderForTarget(int layerIndex) + { + // Store the shader in an easy to use local variable. + var metaballShader = CalamityShaders.AdditiveMetaballEdgeShader; + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + // Supply shader parameter values. + metaballShader.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public static void SpawnParticle(Vector2 position, float size) => + Particles.Add(new(position, size)); + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 3f); + } + + public override void PrepareSpriteBatch(SpriteBatch spriteBatch) + { + // Draw with additive blending. + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); + } + + public override void DrawInstances() + { + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value; + + // Draw all particles. + foreach (LavaParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + Color lavaColor = EdgeColor * 1.2f; + + // Make the lava color vary slightly based on position, to make the effect less monotonous. + lavaColor.B = (byte)(lavaColor.B + (int)(MathF.Cos(particle.Center.Y * 0.015f + Main.GlobalTimeWrappedHourly * 0.1f) * 3f)); + + // Make the lava color bright for the first few frames of its existence. + float brightnessInterpolant = Utils.GetLerpValue(10f, 2f, particle.Time, true) * 0.67f; + lavaColor = Color.Lerp(lavaColor, Color.Wheat, brightnessInterpolant); + + Main.spriteBatch.Draw(tex, drawPosition, null, lavaColor, 0f, origin, scale, 0, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/StreamGougeLayer.png b/Graphics/Metaballs/StreamGougeLayer.png new file mode 100644 index 0000000000..826907fa0f Binary files /dev/null and b/Graphics/Metaballs/StreamGougeLayer.png differ diff --git a/Graphics/Metaballs/StreamGougeMetaball.cs b/Graphics/Metaballs/StreamGougeMetaball.cs new file mode 100644 index 0000000000..0099af636c --- /dev/null +++ b/Graphics/Metaballs/StreamGougeMetaball.cs @@ -0,0 +1,103 @@ +using System.Collections.Generic; +using System.Linq; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class StreamGougeMetaball : Metaball + { + public class CosmicParticle + { + public float Size; + + public Vector2 Velocity; + + public Vector2 Center; + + public CosmicParticle(Vector2 center, Vector2 velocity, float size) + { + Center = center; + Velocity = velocity; + Size = size; + } + + public void Update() + { + Center += Velocity; + Velocity *= 0.96f; + Size *= 0.91f; + } + } + + public static Asset LayerAsset + { + get; + private set; + } + + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return LayerAsset.Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public override Color EdgeColor => Color.Lerp(Color.DarkBlue, Color.Black, 0.75f); + + public override void Load() + { + if (Main.netMode == NetmodeID.Server) + return; + + // Load the layer asset wrapper. + LayerAsset = ModContent.Request($"CalamityMod/Graphics/Metaballs/StreamGougeLayer", AssetRequestMode.ImmediateLoad); + } + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + + public static void SpawnParticle(Vector2 position, Vector2 velocity, float size) => + Particles.Add(new(position, velocity, size)); + + // Make the texture scroll. + public override Vector2 CalculateManualOffsetForLayer(int layerIndex) + { + return Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.037f; + } + + public override void DrawInstances() + { + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; + + foreach (CosmicParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + Main.spriteBatch.Draw(tex, drawPosition, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/VoidGeneratorMetaball.cs b/Graphics/Metaballs/VoidGeneratorMetaball.cs new file mode 100644 index 0000000000..69029411f3 --- /dev/null +++ b/Graphics/Metaballs/VoidGeneratorMetaball.cs @@ -0,0 +1,69 @@ +using System.Collections.Generic; +using System.Linq; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; +using static CalamityMod.Graphics.Metaballs.StreamGougeMetaball; + +namespace CalamityMod.Graphics.Metaballs +{ + public class VoidGeneratorMetaball : Metaball + { + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return LayerAsset.Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.BeforeProjectiles; + + public override Color EdgeColor => Color.Lerp(Color.Purple, Color.Black, 0.75f); + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + + public static CosmicParticle SpawnParticle(Vector2 position, Vector2 velocity, float size) + { + CosmicParticle particle = new(position, velocity, size); + Particles.Add(particle); + + return particle; + } + + // Make the texture scroll. + public override Vector2 CalculateManualOffsetForLayer(int layerIndex) + { + return Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.037f; + } + + public override void DrawInstances() + { + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; + + foreach (CosmicParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + Main.spriteBatch.Draw(tex, drawPosition, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/TrailGeneration/PrimitiveTrail.cs b/Graphics/Primitives/PrimitiveTrail.cs similarity index 93% rename from TrailGeneration/PrimitiveTrail.cs rename to Graphics/Primitives/PrimitiveTrail.cs index 191571bc84..16e3b48dd7 100644 --- a/TrailGeneration/PrimitiveTrail.cs +++ b/Graphics/Primitives/PrimitiveTrail.cs @@ -39,7 +39,6 @@ namespace CalamityMod public VertexWidthFunction WidthFunction; public VertexColorFunction ColorFunction; - public static BasicEffect BaseEffect; public MiscShaderData SpecialShader; public TrailPointRetrievalFunction TrailPointFunction; @@ -61,24 +60,10 @@ namespace CalamityMod TrailPointFunction = pointFunction; + SpecialShader = specialShader ?? GameShaders.Misc["CalamityMod:StandardPrimitiveShader"]; + if (specialShader != null) SpecialShader = specialShader; - - if (BaseEffect is null) - BaseEffect = new BasicEffect(Main.instance.GraphicsDevice) - { - VertexColorEnabled = true, - TextureEnabled = false - }; - UpdateBaseEffect(out _, out _); - } - - public void UpdateBaseEffect(out Matrix effectProjection, out Matrix effectView) - { - CalamityUtils.CalculatePerspectiveMatricies(out effectView, out effectProjection); - - BaseEffect.View = effectView; - BaseEffect.Projection = effectProjection; } public static List RigidPointRetreivalFunction(IEnumerable originalPositions, Vector2 generalOffset, int totalTrailPoints, IEnumerable _ = null) @@ -253,7 +238,7 @@ namespace CalamityMod if (trailPoints.All(point => point == trailPoints[0])) return; - UpdateBaseEffect(out Matrix projection, out Matrix view); + CalamityUtils.CalculatePerspectiveMatricies(out Matrix view, out Matrix projection); VertexPosition2DColor[] vertices = GetVerticesFromTrailPoints(trailPoints); short[] triangleIndices = GetIndicesFromTrailPoints(trailPoints.Count); @@ -267,13 +252,8 @@ namespace CalamityMod Main.instance.GraphicsDevice.RasterizerState.ScissorTestEnable = true; Main.instance.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, Main.screenWidth, Main.screenHeight); //offscreen culling - if (SpecialShader != null) - { - SpecialShader.Shader.Parameters["uWorldViewProjection"].SetValue(view * projection); - SpecialShader.Apply(); - } - else - BaseEffect.CurrentTechnique.Passes[0].Apply(); + SpecialShader.Shader.Parameters["uWorldViewProjection"].SetValue(view * projection); + SpecialShader.Apply(); Main.instance.GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertices, 0, vertices.Length, triangleIndices, 0, triangleIndices.Length / 3); Main.pixelShader.CurrentTechnique.Passes[0].Apply(); diff --git a/Graphics/RenderTargetManager.cs b/Graphics/RenderTargetManager.cs new file mode 100644 index 0000000000..1234fe0490 --- /dev/null +++ b/Graphics/RenderTargetManager.cs @@ -0,0 +1,95 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System.Collections.Generic; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics +{ + /// + /// Manager class that handles all created instances of + /// + public class RenderTargetManager : ModSystem + { + internal static List ManagedTargets = new(); + + public delegate void RenderTargetUpdateDelegate(); + + /// + /// Use this event to update/draw things to the target before anything else is drawn to the game. + /// + public static event RenderTargetUpdateDelegate RenderTargetUpdateLoopEvent; + + /// + /// How many frames should pass since a target was last accessed before automatically disposing of it. + /// + public const int TimeBeforeAutoDispose = 600; + + internal static void ResetTargetSizes(Vector2 screenSize) + { + foreach (ManagedRenderTarget target in ManagedTargets) + { + // Don't attempt to recreate targets that are already initialized or shouldn't be recreated. + if (target is null || target.IsDisposed || target.WaitingForFirstInitialization) + continue; + + Main.QueueMainThreadAction(() => + { + target.Recreate((int)screenSize.X, (int)screenSize.Y); + }); + } + } + + internal static void DisposeOfTargets() + { + if (ManagedTargets is null) + return; + + Main.QueueMainThreadAction(() => + { + foreach (ManagedRenderTarget target in ManagedTargets) + target?.Dispose(); + ManagedTargets.Clear(); + }); + } + + public override void OnModLoad() + { + ManagedTargets = new(); + Main.OnPreDraw += HandleTargetUpdateLoop; + Main.OnResolutionChanged += ResetTargetSizes; + } + + public override void OnModUnload() + { + DisposeOfTargets(); + Main.OnPreDraw -= HandleTargetUpdateLoop; + Main.OnResolutionChanged -= ResetTargetSizes; + + if (RenderTargetUpdateLoopEvent != null) + { + foreach (var subscription in RenderTargetUpdateLoopEvent.GetInvocationList()) + RenderTargetUpdateLoopEvent -= (RenderTargetUpdateDelegate)subscription; + } + } + + private void HandleTargetUpdateLoop(GameTime obj) + { + // Auto-disposal of targets that havent been used in a while, to stop them hogging GPU memory. + if (ManagedTargets != null) + { + foreach (ManagedRenderTarget target in ManagedTargets) + { + if (target == null || target.IsDisposed || !target.ShouldAutoDispose) + continue; + + if (target.TimeSinceLastAccessed >= TimeBeforeAutoDispose) + target.Dispose(); + else + target.TimeSinceLastAccessed++; + } + } + RenderTargetUpdateLoopEvent?.Invoke(); + } + } +} diff --git a/ILEditing/BalancingILChanges.cs b/ILEditing/BalancingILChanges.cs index 58c334d8b9..421f094b6c 100644 --- a/ILEditing/BalancingILChanges.cs +++ b/ILEditing/BalancingILChanges.cs @@ -437,5 +437,22 @@ namespace CalamityMod.ILEditing cursor.Next.Operand = 1f; } #endregion + + #region Remove Frozen Infliction From Deerclops Ice Spikes + private static void RemoveFrozenInflictionFromDeerclopsIceSpikes(ILContext il) + { + // Prevent Deerclops from freezing players with Ice Spike projectiles. + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdcI4(ProjectileID.DeerclopsIceSpike))) + { + LogFailure("Remove Frozen Infliction From Deerclops Ice Spikes", "Could not locate the Deerclops Ice Spike projectile ID."); + return; + } + + // AND with 0 (false) so that the Ice Spike is never considered to be hitting the player and thus never trigger the Frozen debuff. + cursor.Emit(OpCodes.Ldc_I4_0); + cursor.Emit(OpCodes.And); + } + #endregion } } diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index adc92a662e..01bf647b33 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -38,7 +38,6 @@ namespace CalamityMod.ILEditing IL_Main.DoDraw += AdditiveDrawing; On_Main.DrawGore += DrawForegroundStuff; On_Main.DrawCursor += UseCoolFireCursorEffect; - On_Main.SetDisplayMode += ResetRenderTargetSizes; On_Main.SortDrawCacheWorms += DrawFusableParticles; On_Main.DrawInfernoRings += DrawForegroundParticles; On_TileDrawing.DrawPartialLiquid += DrawCustomLava; @@ -82,8 +81,8 @@ namespace CalamityMod.ILEditing IL_Wiring.HitWireSingle += AddTwinklersToStatue; On_Player.UpdateItemDye += FindCalamityItemDyeShader; - // Mana Burn - IL_Player.ApplyLifeAndOrMana += ConditionallyReplaceManaSickness; + // Mana Burn (Chaos Stone) and Chalice of the Blood God + IL_Player.ApplyLifeAndOrMana += ManaSicknessAndChaliceBufferHeal; // Custom grappling On_Player.GrappleMovement += CustomGrappleMovementCheck; @@ -112,6 +111,9 @@ namespace CalamityMod.ILEditing IL_Player.Update += ManaRegenDelayAdjustment; IL_Player.UpdateManaRegen += ManaRegenAdjustment; + // Debuff balancing + IL_Projectile.StatusPlayer += RemoveFrozenInflictionFromDeerclopsIceSpikes; + // World generation IL_WorldGen.Pyramid += ReplacePharaohSetInPyramids; IL_WorldGen.GrowLivingTree += BlockLivingTreesNearOcean; @@ -121,6 +123,9 @@ namespace CalamityMod.ILEditing IL_UIWorldCreation.SetDefaultOptions += ChangeDefaultWorldSize; IL_UIWorldCreation.AddWorldSizeOptions += SwapSmallDescriptionKey; Terraria.IO.On_WorldFile.ClearTempTiles += ClearModdedTempTiles; + On_WorldGen.MakeDungeon += LimitDungeonEntranceXPosition; + IL_WorldGen.DungeonHalls += LimitDungeonHallsXPosition; + IL_WorldGen.MakeDungeon += ChangeDungeonSpikeQuantities; // Removal of vanilla stupidity IL_Player.UpdateBuffs += RemoveFeralBiteRandomDebuffs; diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index d8e61090d9..7e2d9aeb95 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -16,7 +16,6 @@ using CalamityMod.NPCs.AstrumAureus; using CalamityMod.NPCs.Crabulon; using CalamityMod.NPCs.Ravager; using CalamityMod.Particles; -using CalamityMod.Particles.Metaballs; using CalamityMod.Projectiles; using CalamityMod.Projectiles.Typeless; using CalamityMod.Systems; @@ -38,6 +37,7 @@ using Terraria.Graphics; using Terraria.Graphics.Light; using Terraria.Graphics.Shaders; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; using Terraria.UI.Gamepad; @@ -261,7 +261,7 @@ namespace CalamityMod.ILEditing self.dashTime = 15; return; } - + dashing = true; self.dashTime = 0; self.timeSinceLastDashStarted = 0; @@ -298,7 +298,7 @@ namespace CalamityMod.ILEditing self.velocity = Collision.AdvancedTileCollision(TileID.Sets.ForAdvancedCollision.ForSandshark, cPosition, self.velocity, cWidth, cHeight, fall, fall, 1); return; } - + if (self.active && self.Calamity().ShouldFallThroughPlatforms) fall = true; @@ -494,11 +494,54 @@ namespace CalamityMod.ILEditing } #endregion - #region Mana Sickness Replacement for Chaos Stone - private static void ConditionallyReplaceManaSickness(ILContext il) + #region Chaos Stone and Chalice of the Blood God + private static void ManaSicknessAndChaliceBufferHeal(ILContext il) { ILCursor cursor = new ILCursor(il); + // + // The following section enables Chalice of the Blood God's feature of healing potions clearing 50% of its bleedout buffer. + // + + // Start by finding the moment where health is restored from a healing item. + if (!cursor.TryGotoNext(MoveType.After, c => c.MatchStfld("statLife"))) + { + LogFailure("Chalice of the Blood God Bleedout Heal", "Could not locate the player's health being restored"); + return; + } + + // Load the player onto the stack for use in the following delegate. + cursor.Emit(OpCodes.Ldarg_0); + + // Insert a delegate which applies Chalice of the Blood God's function as appropriate. + cursor.EmitDelegate>(player => + { + if (!player.active || player.dead) + return; + + CalamityPlayer modPlayer = player.Calamity(); + if (modPlayer is null) + return; + + if (modPlayer.chaliceOfTheBloodGod && modPlayer.chaliceBleedoutBuffer > 0D) + { + int amountOfBleedToClear = (int)(modPlayer.chaliceBleedoutBuffer * (1f - ChaliceOfTheBloodGod.HealingPotionBufferClear)); + modPlayer.chaliceBleedoutBuffer -= amountOfBleedToClear; + + // Display text indicating that damage was transferred to bleedout. + if (Main.netMode != NetmodeID.Server) + { + string text = $"(+{amountOfBleedToClear})"; + Rectangle location = new Rectangle((int)player.position.X + 4, (int)player.position.Y - 3, player.width - 4, player.height - 4); + CombatText.NewText(location, ChaliceOfTheBloodGod.BleedoutBufferDamageTextColor, Language.GetTextValue(text), dot: true); + } + } + }); + + // + // The following section enables Mana Burn for Chaos Stone by conditionally replacing Mana Sickness. + // + // Start by finding the vanilla code which applies Mana Sickness (buff ID 94). if (!cursor.TryGotoNext(c => c.MatchLdcI4(BuffID.ManaSickness))) { @@ -707,7 +750,6 @@ namespace CalamityMod.ILEditing private static void DrawFusableParticles(Terraria.On_Main.orig_SortDrawCacheWorms orig, Main self) { DeathAshParticle.DrawAll(); - FusableParticleManager.RenderAllFusableParticles(); if (Main.LocalPlayer.dye.Any(dyeItem => dyeItem.type == ModContent.ItemType())) Main.LocalPlayer.Calamity().ProfanedMoonlightAuroraDrawer?.Draw(Main.LocalPlayer.Center - Main.screenPosition, false, Main.GameViewMatrix.TransformationMatrix, Matrix.Identity); @@ -720,13 +762,6 @@ namespace CalamityMod.ILEditing GeneralParticleHandler.DrawAllParticles(Main.spriteBatch); orig(self); } - - private static void ResetRenderTargetSizes(Terraria.On_Main.orig_SetDisplayMode orig, int width, int height, bool fullscreen) - { - if (FusableParticleManager.HasBeenFormallyDefined) - FusableParticleManager.LoadParticleRenderSets(true, width, height); - orig(width, height, fullscreen); - } #endregion #region Custom Lava Visuals @@ -746,23 +781,23 @@ namespace CalamityMod.ILEditing Main.tileBatch.Draw(liquidTexture, position, liquidSize, colors, default(Vector2), 1f, SpriteEffects.None); return; } - + Texture2D slopeTexture = SelectLavaTexture(liquidType == 1 ? CustomLavaManagement.LavaSlopeTexture : TextureAssets.LiquidSlope[liquidType].Value, LiquidTileType.Slope); liquidSize.X += 18 * (slope - 1); switch (slope) { - case 1: - Main.tileBatch.Draw(slopeTexture, position, liquidSize, colors, Vector2.Zero, 1f, SpriteEffects.None); - break; - case 2: - Main.tileBatch.Draw(slopeTexture, position, liquidSize, colors, Vector2.Zero, 1f, SpriteEffects.None); - break; - case 3: - Main.tileBatch.Draw(slopeTexture, position, liquidSize, colors, Vector2.Zero, 1f, SpriteEffects.None); - break; - case 4: - Main.tileBatch.Draw(slopeTexture, position, liquidSize, colors, Vector2.Zero, 1f, SpriteEffects.None); - break; + case 1: + Main.tileBatch.Draw(slopeTexture, position, liquidSize, colors, Vector2.Zero, 1f, SpriteEffects.None); + break; + case 2: + Main.tileBatch.Draw(slopeTexture, position, liquidSize, colors, Vector2.Zero, 1f, SpriteEffects.None); + break; + case 3: + Main.tileBatch.Draw(slopeTexture, position, liquidSize, colors, Vector2.Zero, 1f, SpriteEffects.None); + break; + case 4: + Main.tileBatch.Draw(slopeTexture, position, liquidSize, colors, Vector2.Zero, 1f, SpriteEffects.None); + break; } } @@ -804,7 +839,7 @@ namespace CalamityMod.ILEditing { initialColor = SelectLavaQuadColor(initialTexture, ref initialColor, liquidType == 1); - if (liquidType == ModContent.Find("CalamityMod/SunkenSeaWater").Slot || + if (liquidType == ModContent.Find("CalamityMod/SunkenSeaWater").Slot || liquidType == ModContent.Find("CalamityMod/SulphuricWater").Slot || liquidType == ModContent.Find("CalamityMod/SulphuricDepthsWater").Slot || liquidType == ModContent.Find("CalamityMod/UpperAbyssWater").Slot || @@ -930,7 +965,7 @@ namespace CalamityMod.ILEditing return; Tile above = CalamityUtils.ParanoidTileRetrieval(x, y - 1); - if (!Main.gamePaused && !above.HasTile && above.LiquidAmount <= 0 && Main.rand.NextBool(9) && + if (!Main.gamePaused && !above.HasTile && above.LiquidAmount <= 0 && Main.rand.NextBool(9) && Main.waterStyle == SulphuricWater.Type) { MediumMistParticle acidFoam = new(new(x * 16f + Main.rand.NextFloat(16f), y * 16f + 8f), -Vector2.UnitY.RotatedByRandom(0.67f) * Main.rand.NextFloat(1f, 2.4f), Color.LightSeaGreen, Color.White, 0.16f, 128f, 0.02f); diff --git a/ILEditing/VanillaStupidityFixingILChanges.cs b/ILEditing/VanillaStupidityFixingILChanges.cs index 1e621a0da2..a6d129466d 100644 --- a/ILEditing/VanillaStupidityFixingILChanges.cs +++ b/ILEditing/VanillaStupidityFixingILChanges.cs @@ -162,13 +162,22 @@ namespace CalamityMod.ILEditing { // Find the Tile ID of Meteorite and change it to something that doesn't matter. var cursor = new ILCursor(il); + + // There are two checks for the Meteorite Tile ID. The first one is required for the switch cases to function properly, so we need to move past it. + ILLabel label = null; // pointless label for MatchBeq + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchBeq(out label))) + { + LogFailure("Make Meteorite Explodable", "Could not locate the branching instruction."); + return; + } + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(TileID.Meteorite))) // The Meteorite Tile ID check. { LogFailure("Make Meteorite Explodable", "Could not locate the Meteorite Tile ID variable."); return; } cursor.Remove(); - cursor.Emit(OpCodes.Ldc_I4, TileID.HellstoneBrick); // Change to Hellstone Brick. They're made of Hellstone, so it makes sense they can't be exploded until Hardmode starts :^) + cursor.Emit(OpCodes.Ldc_I4, TileID.HellstoneBrick); // This won't actually do anything since the ID is above Meteorite's and thus unreachable } #endregion diff --git a/ILEditing/WorldgenILChanges.cs b/ILEditing/WorldgenILChanges.cs index c8b4b5a478..c8e7266d16 100644 --- a/ILEditing/WorldgenILChanges.cs +++ b/ILEditing/WorldgenILChanges.cs @@ -14,6 +14,25 @@ namespace CalamityMod.ILEditing { public partial class ILChanges { + public static int DungeonHallXLimit => DungeonHallXLimitOverride ?? (SulphurousSea.BiomeWidth + 25); + + public static int DungeonBaseXLimit => DungeonBaseXLimitOverride ?? (SulphurousSea.BiomeWidth + 167); + + // This exists primarily for Infernum with its larger abyss, but other mods with a reference should be able to theoretically override it. + // Calamity by itself does not change its value. + public static int? DungeonHallXLimitOverride + { + get; + set; + } + + // Same idea as DungeonHallXLimitOverride. + public static int? DungeonBaseXLimitOverride + { + get; + set; + } + #region Replacement of Pharaoh Set in Pyramids // Note: There is no need to replace the other Pharaoh piece, due to how the vanilla code works. // The other Pharaoh vanity piece is added automatically if the mask is found in the chest. @@ -180,5 +199,126 @@ namespace CalamityMod.ILEditing } } #endregion + + #region Prevent Abyss/Dungeon Interactions + + private void LimitDungeonEntranceXPosition(On_WorldGen.orig_MakeDungeon orig, int x, int y) + { + // Ensure that the base X position stays within its required bounds. + x = Utils.Clamp(x, DungeonBaseXLimit, Main.maxTilesX - DungeonBaseXLimit); + + // Adjust the Y position of the dungeon to accomodate for the X shift, so that if the clamp shoves the dungeon into the air it has an + // opportunity to ground itself again. + WorldUtils.Find(new Point(x, y), Searches.Chain(new Searches.Down(9001), new Conditions.IsSolid()), out Point result); + y = result.Y - 10; + + orig(x, y); + } + + /// + /// Ensures that the position of dungeon halls do not exceed a certain horizontal range. + /// + private static void LimitDungeonHallsXPosition(ILContext il) + { + var c = new ILCursor(il); + + /* The code being altered is as follows: + * Vector2D vector2D = default(Vector2D); + * vector2D.X = (double)i; + * vector2D.Y = (double)j; + * + * In this context, i and j represent the X and Y position of the dungeon hall, and vector2D represents its position as a vector. + * The object is to to change the vector2D.X = (double)i; line to actually provide i but clamped. + */ + + if (!c.TryGotoNext(MoveType.After, x => x.MatchLdarg0())) + { + LogFailure("Limit Dungeon Hall X Positions", "Could not match the load of argument 0."); + return; + } + + // Since the above search specifies that the cursor should be placed after ldarg_0, but before the storage into the X component of the vector, it's + // possible to simply take in the value as an input for the clamp function and interpret the clamp's output as the true value being stored into the X component. + // In C#, this represents the following transformation: + // + // Original: vector2D.X = (double)i; + // + // Altered: vector2D.X = (double)Utils.Clamp(i, DungeonHallXLimit, Main.maxTilesX - DungeonHallXLimit); + c.EmitDelegate>(x => Utils.Clamp(x, DungeonHallXLimit, Main.maxTilesX - DungeonHallXLimit)); + } + + #endregion Prevent Abyss/Dungeon Interactions + + #region Change Dungeon Spike Quantities + + /// + /// Makes dungeon spikes more infrequent in the dungeon under normal circumstances. + /// + private static void ChangeDungeonSpikeQuantities(ILContext il) + { + var c = new ILCursor(il); + + /* The code being altered is as follows: + * int num16 = Main.maxTilesX / 100; + * if (WorldGen.getGoodWorldGen) + * { + * num16 *= 3; + * } + * + * The desired change is to halve num16 under typical circumstances but leave them unchanged on the meme seeds (Except for GFB, where it's even more ridiculous). + * This should result in the following logical output via this edit: + * + * int num16 = Main.maxTilesX / 200; + * if (WorldGen.getGoodWorldGen) + * { + * num16 *= 6; + * } + * if (Main.zenithWorld) + * { + * num16 *= 4; + * } + */ + + // WorldGen.getGoodWorldGen is only used once in this method, and as such is a reliable entrypoint for getting near the above code. + if (!c.TryGotoNext(MoveType.After, x => x.MatchLdsfld("getGoodWorldGen"))) + { + LogFailure("Change Dungeon Spike Quantities", "Could not match the load of Worldgen.getGoodWorldGen."); + return; + } + + // Go back to find the local index of num16, being sure to go right before it's stored. + if (!c.TryGotoPrev(MoveType.Before, x => x.MatchStloc(out _))) + { + LogFailure("Change Dungeon Spike Quantities", "Could not match the storage of num16."); + return; + } + + // Since we're right before the storage of num16, that means that its exact number is right above and available for manipulation. + // This will be accomplished via a division by 2 for the default condition and respective multiplications for the meme seeds. + // The reason this isn't done in a single multiplication/division is as a means of avoiding the annoyances of casting to floats and back. + + // Divide by two. + c.Emit(OpCodes.Ldc_I4_2); + c.Emit(OpCodes.Div); + + // Multiply by factors relative to the meme seed. + c.EmitDelegate(() => + { + int frequencyFactor = 1; + + // Undo the division by 2 in the FTW seed. It will be given the *= 3 after the placement of these edits. + if (WorldGen.getGoodWorldGen) + frequencyFactor *= 2; + + // GFB, where good game design dies. + if (Main.zenithWorld) + frequencyFactor *= 4; + + return frequencyFactor; + }); + c.Emit(OpCodes.Mul); + } + + #endregion Change Dungeon Spike Quantities } } diff --git a/Items/Accessories/AmalgamatedBrain.cs b/Items/Accessories/AmalgamatedBrain.cs index 6e2357bae8..f4f5d3475b 100644 --- a/Items/Accessories/AmalgamatedBrain.cs +++ b/Items/Accessories/AmalgamatedBrain.cs @@ -1,5 +1,6 @@ using CalamityMod.Balancing; using CalamityMod.CalPlayer; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Magic; using Terraria; using Terraria.ID; @@ -33,6 +34,9 @@ namespace CalamityMod.Items.Accessories if (player.whoAmI == Main.myPlayer) { int damage = (int)player.GetBestClassDamage().ApplyTo(60); + if (modPlayer.oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + Projectile rain = CalamityUtils.ProjectileRain(source, player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), damage, 2f, player.whoAmI); if (rain.whoAmI.WithinBounds(Main.maxProjectiles)) { diff --git a/Items/Accessories/AmidiasPendant.cs b/Items/Accessories/AmidiasPendant.cs index deec0c23ce..dde9c80092 100644 --- a/Items/Accessories/AmidiasPendant.cs +++ b/Items/Accessories/AmidiasPendant.cs @@ -3,6 +3,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; using Terraria.ID; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.Items.Accessories { @@ -69,6 +70,9 @@ namespace CalamityMod.Items.Accessories break; } int finalDamage = (int)player.GetBestClassDamage().ApplyTo(damage); + if (player.Calamity().oldFashioned) + finalDamage = CalamityUtils.CalcOldFashionedDamage(finalDamage); + Projectile.NewProjectile(source, spawn.X, spawn.Y, velocity.X / 3, velocity.Y / 2, type, finalDamage, 5f, Main.myPlayer); } } diff --git a/Items/Accessories/AscendantInsignia.cs b/Items/Accessories/AscendantInsignia.cs new file mode 100644 index 0000000000..1f721dc2a5 --- /dev/null +++ b/Items/Accessories/AscendantInsignia.cs @@ -0,0 +1,46 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; +using CalamityMod.Rarities; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using System; +using System.Collections.Generic; +using CalamityMod.Items.Placeables.Ores; +using CalamityMod.Items.Placeables; + +namespace CalamityMod.Items.Accessories +{ + [LegacyName("YharimsInsignia")] + public class AscendantInsignia : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Accessories"; + public override void ModifyTooltips(List list) => list.IntegrateHotkey(CalamityKeybinds.AscendantInsigniaHotKey); + public override void SetDefaults() + { + Item.width = 42; + Item.height = 42; + Item.value = CalamityGlobalItem.Rarity13BuyPrice; + Item.accessory = true; + Item.rare = ModContent.RarityType(); + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.ascendantInsignia = true; + player.empressBrooch = true; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.EmpressFlightBooster). + AddIngredient(5). + AddIngredient(ItemID.SoulofFlight, 10). + AddIngredient(5). + AddTile(TileID.LunarCraftingStation). + Register(); + } + } +} diff --git a/Items/Accessories/AscendantInsignia.png b/Items/Accessories/AscendantInsignia.png new file mode 100644 index 0000000000..52e747190b Binary files /dev/null and b/Items/Accessories/AscendantInsignia.png differ diff --git a/Items/Accessories/Baroclaw.cs b/Items/Accessories/Baroclaw.cs index e7c4cfc4ce..f7fa268081 100644 --- a/Items/Accessories/Baroclaw.cs +++ b/Items/Accessories/Baroclaw.cs @@ -11,8 +11,8 @@ namespace CalamityMod.Items.Accessories public new string LocalizationCategory => "Items.Accessories"; public override void SetDefaults() { - Item.width = 30; - Item.height = 44; + Item.width = 40; + Item.height = 26; Item.value = CalamityGlobalItem.Rarity7BuyPrice; Item.rare = ItemRarityID.Lime; Item.accessory = true; diff --git a/Items/Accessories/Baroclaw.png b/Items/Accessories/Baroclaw.png index 79f8c3c76d..5a4bcd7291 100644 Binary files a/Items/Accessories/Baroclaw.png and b/Items/Accessories/Baroclaw.png differ diff --git a/Items/Accessories/BlazingCore.cs b/Items/Accessories/BlazingCore.cs index 67fac06a10..5d918c405f 100644 --- a/Items/Accessories/BlazingCore.cs +++ b/Items/Accessories/BlazingCore.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Typeless; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -78,6 +79,9 @@ namespace CalamityMod.Items.Accessories { spinningPoint *= 1.5f; dmgAmt = (int)player.GetBestClassDamage().ApplyTo(dmgAmt); + if (player.Calamity().oldFashioned) + dmgAmt = CalamityUtils.CalcOldFashionedDamage(dmgAmt); + Projectile.NewProjectile(player.GetSource_FromThis(), player.Center, vector2, projectileType, dmgAmt, 0f, Main.myPlayer); } diff --git a/Items/Accessories/BloodPact.cs b/Items/Accessories/BloodPact.cs index abc4fd2199..62b606c59f 100644 --- a/Items/Accessories/BloodPact.cs +++ b/Items/Accessories/BloodPact.cs @@ -20,7 +20,8 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); - modPlayer.bloodPact = true; + modPlayer.bloodPact = true; // This applies the +25% health boost. + modPlayer.healingPotionMultiplier += 0.25f; } } } diff --git a/Items/Accessories/BloodflareCore.cs b/Items/Accessories/BloodflareCore.cs index a17fed4157..0fa24e92eb 100644 --- a/Items/Accessories/BloodflareCore.cs +++ b/Items/Accessories/BloodflareCore.cs @@ -1,13 +1,14 @@ using CalamityMod.CalPlayer; using CalamityMod.Rarities; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { public class BloodflareCore : ModItem, ILocalizedModType { + internal static readonly int HealFrameCooldown = 6; + public new string LocalizationCategory => "Items.Accessories"; public override void SetDefaults() { diff --git a/Items/Accessories/ChaliceOfTheBloodGod.cs b/Items/Accessories/ChaliceOfTheBloodGod.cs new file mode 100644 index 0000000000..2303243d48 --- /dev/null +++ b/Items/Accessories/ChaliceOfTheBloodGod.cs @@ -0,0 +1,184 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; +using CalamityMod.Particles; +using CalamityMod.Rarities; +using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + [LegacyName("CoreOfTheBloodGod")] + public class ChaliceOfTheBloodGod : ModItem, ILocalizedModType + { + // This value serves three purposes. + // 1 - If the player takes less damage than this post-mitigation, CotBG refuses to activate and will not make that damage a bleedout. + // 2 - CotBG reduces incoming damage to this value when it does activate. + // 3 - If there is less bleedout left than this number, the remainder is dealt instantly in a single frame. + // + // Dying to this sudden last few points of health loss has a special death message. + internal static readonly int MinAllowedDamage = 5; + + // Drinking a healing potion clears 50% of the bleedout buffer. + internal const float HealingPotionBufferClear = 0.5f; + + // This is per frame. The ideal is 50% per second, so it's 0.83% per frame. + internal static readonly double BleedoutExponentialDecay = 0.0083333333333; + internal static readonly Color BleedoutBufferDamageTextColor = new(230, 40, 100); + + public new string LocalizationCategory => "Items.Accessories"; + public override void SetStaticDefaults() + { + Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(6, 12)); + ItemID.Sets.AnimatesAsSoul[Type] = true; + } + + public override void SetDefaults() + { + Item.width = Item.height = 32; + Item.accessory = true; + Item.value = CalamityGlobalItem.Rarity14BuyPrice; + Item.rare = ModContent.RarityType(); + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + + // This applies the +25% health boost and the bleedout buffer effect. + // Health boost intentionally stacks with Blood Pact. + modPlayer.chaliceOfTheBloodGod = true; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(5). + AddIngredient(4). + AddTile(). + Register(); + } + + internal static void HandleBleedout(Player player) + { + CalamityPlayer modPlayer = player.Calamity(); + + // If the player has at least a few more points of damage to take, they are bleeding. + // This doesn't count down to exactly 1 point of damage because that could take an annoyingly long time. + if (modPlayer.chaliceOfTheBloodGod && modPlayer.chaliceBleedoutBuffer > MinAllowedDamage) + { + double amountBledThisFrame = modPlayer.chaliceBleedoutBuffer * BleedoutExponentialDecay; + modPlayer.chaliceDamagePointPartialProgress += amountBledThisFrame; + + int healthToLose = (int)modPlayer.chaliceDamagePointPartialProgress; + + // If more than one damage point is done this frame, reduce health appropriately + if (healthToLose > 0) + { + player.statLife -= healthToLose; + + // Take away the integer part of the partial progress when this occurs. + modPlayer.chaliceDamagePointPartialProgress -= healthToLose; + + // If this reduces the player's health to zero, make sure they actually die. + if (player.statLife <= 0) + { + player.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ChaliceOfTheBloodGod" + Main.rand.Next(1, 4 + 1)).Format(player.name)), modPlayer.chaliceBleedoutBuffer, 0, false); + } + } + + // Particles are spawned even if the bleed damage this frame is zero, so there's always a continuous trickle of blood. + SpawnBloodParticles(player, healthToLose); + + // Actually reduce the remaining buffer. + modPlayer.chaliceBleedoutBuffer *= 1f - BleedoutExponentialDecay; + } + + // This else is reached in 3 cases. + // + // 1. The player unequips Chalice of the Blood God while still bleeding. + // In this case, the rest of the bleed is dealt in a single frame as punishment. + // This prevents hotswapping accessories in while still benefitting from the bleedout survivability. + // + // 2. The player has Chalice of the Blood God equipped, but there are very few points of damage left to take. + // In this case, the rest of the bleed is dealt in a single frame for convenience. + // + // 3. The player doesn't have the accessory equipped at all, and isn't bleeding. + // In this case, nothing happens, because there's no bleed damage to take. + else + { + // Deal the entire remaining buffer as damage in a single frame. + if (modPlayer.chaliceBleedoutBuffer > 0) + { + int remainingDamage = (int)modPlayer.chaliceBleedoutBuffer + 1; + player.statLife -= remainingDamage; + + // Intentionally produces an extra burst of particles so it's more obvious when bleeding ends. + SpawnBloodParticles(player, remainingDamage * 4); + + // If this reduces the player's health to zero, make sure they actually die. + if (player.statLife <= 0) + { + // Death message changes depending on whether it was the last few drips of an "honored" bleed, or attempting to cheat by removing the accessory. + string deathMessageKey = modPlayer.chaliceOfTheBloodGod ? "Status.Death.ChaliceOfTheBloodGodClose" : "Status.Death.ChaliceOfTheBloodGodUnequip"; + player.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText(deathMessageKey).Format(player.name)), modPlayer.chaliceBleedoutBuffer, 0, false); + } + } + + // Regardless of what caused the buffer to flush, reset both variables. + modPlayer.chaliceBleedoutBuffer = 0D; + modPlayer.chaliceDamagePointPartialProgress = 0D; + } + } + + private static void SpawnBloodParticles(Player player, int bleedDamage) + { + CalamityPlayer modPlayer = player.Calamity(); + + // Spawn blood particles based on the amount of damage taken this frame. + // Some particles are always spawned even when bleeding slowly (aka not actually taking damage this frame). + float roughBloodCount = bleedDamage == 0 ? 0.4f : bleedDamage; + int exactBloodCount = (int)roughBloodCount; + + // Fractional chance is taken as a chance to spawn one final blood particle. + if (Main.rand.NextFloat() < roughBloodCount - exactBloodCount) + ++exactBloodCount; + + // Particles count is capped. This is primarily there to prevent particle spam when unequipping the accessory. + if (exactBloodCount > 18) + exactBloodCount = 18; + + // Code copied from Violence. + float bloodVelMult = 0.6f + MathHelper.Clamp((float)modPlayer.chaliceBleedoutBuffer * 0.01f, 0f, 3f); + for (int i = 0; i < exactBloodCount; ++i) + { + int bloodLifetime = Main.rand.Next(22, 36); + float bloodScale = Main.rand.NextFloat(0.6f, 0.8f); + Color bloodColor = Color.Lerp(Color.Red, Color.DarkRed, Main.rand.NextFloat()); + bloodColor = Color.Lerp(bloodColor, new Color(51, 22, 94), Main.rand.NextFloat(0.65f)); + + if (Main.rand.NextBool(20)) + bloodScale *= 2f; + + float randomSpeedMultiplier = Main.rand.NextFloat(1.25f, 2.25f); + Vector2 bloodVelocity = Main.rand.NextVector2Unit() * bloodVelMult * randomSpeedMultiplier; + bloodVelocity.Y -= 5f; + BloodParticle blood = new BloodParticle(player.Center, bloodVelocity, bloodLifetime, bloodScale, bloodColor); + GeneralParticleHandler.SpawnParticle(blood); + } + for (int i = 0; i < exactBloodCount / 3; ++i) + { + float bloodScale = Main.rand.NextFloat(0.2f, 0.33f); + Color bloodColor = Color.Lerp(Color.Red, Color.DarkRed, Main.rand.NextFloat(0.5f, 1f)); + Vector2 bloodVelocity = Main.rand.NextVector2Unit() * bloodVelMult * Main.rand.NextFloat(1f, 2f); + bloodVelocity.Y -= 2.3f; + BloodParticle2 blood = new BloodParticle2(player.Center, bloodVelocity, 20, bloodScale, bloodColor); + GeneralParticleHandler.SpawnParticle(blood); + } + } + } +} diff --git a/Items/Accessories/ChaliceOfTheBloodGod.png b/Items/Accessories/ChaliceOfTheBloodGod.png new file mode 100644 index 0000000000..84b6bedc16 Binary files /dev/null and b/Items/Accessories/ChaliceOfTheBloodGod.png differ diff --git a/Items/Accessories/CoreOfTheBloodGod.cs b/Items/Accessories/CoreOfTheBloodGod.cs deleted file mode 100644 index d9206d691d..0000000000 --- a/Items/Accessories/CoreOfTheBloodGod.cs +++ /dev/null @@ -1,48 +0,0 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using CalamityMod.Rarities; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Accessories -{ - public class CoreOfTheBloodGod : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Accessories"; - public override void SetStaticDefaults() - { - Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(6, 4)); - ItemID.Sets.AnimatesAsSoul[Type] = true; - } - - public override void SetDefaults() - { - Item.width = Item.height = 48; - Item.accessory = true; - Item.value = CalamityGlobalItem.Rarity14BuyPrice; - Item.rare = ModContent.RarityType(); - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.coreOfTheBloodGod = true; - modPlayer.fleshTotem = true; - modPlayer.healingPotBonus += 0.25f; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(). - AddIngredient(5). - AddIngredient(4). - AddTile(). - Register(); - } - } -} diff --git a/Items/Accessories/CoreOfTheBloodGod.png b/Items/Accessories/CoreOfTheBloodGod.png deleted file mode 100644 index 10d98d7cb2..0000000000 Binary files a/Items/Accessories/CoreOfTheBloodGod.png and /dev/null differ diff --git a/Items/Accessories/CorruptFlask.png b/Items/Accessories/CorruptFlask.png index 373c8d6896..55856d02fb 100644 Binary files a/Items/Accessories/CorruptFlask.png and b/Items/Accessories/CorruptFlask.png differ diff --git a/Items/Accessories/CounterScarf.cs b/Items/Accessories/CounterScarf.cs index 48d4e4e03b..dc226e9d17 100644 --- a/Items/Accessories/CounterScarf.cs +++ b/Items/Accessories/CounterScarf.cs @@ -12,8 +12,8 @@ namespace CalamityMod.Items.Accessories public new string LocalizationCategory => "Items.Accessories"; public override void SetDefaults() { - Item.width = 26; - Item.height = 26; + Item.width = 30; + Item.height = 38; Item.value = CalamityGlobalItem.Rarity3BuyPrice; Item.rare = ItemRarityID.Orange; Item.accessory = true; diff --git a/Items/Accessories/CounterScarf.png b/Items/Accessories/CounterScarf.png index af72f9a834..435650e711 100644 Binary files a/Items/Accessories/CounterScarf.png and b/Items/Accessories/CounterScarf.png differ diff --git a/Items/Accessories/CrimsonFlask.png b/Items/Accessories/CrimsonFlask.png index 9ab724f8a2..4e11feff1d 100644 Binary files a/Items/Accessories/CrimsonFlask.png and b/Items/Accessories/CrimsonFlask.png differ diff --git a/Items/Accessories/DraedonsHeart.cs b/Items/Accessories/DraedonsHeart.cs index 52a6af9b54..5f6523feba 100644 --- a/Items/Accessories/DraedonsHeart.cs +++ b/Items/Accessories/DraedonsHeart.cs @@ -59,6 +59,9 @@ namespace CalamityMod.Items.Accessories modPlayer.hadNanomachinesLastFrame = true; modPlayer.AdrenalineDuration = NanomachinesDuration; modPlayer.contactDamageReduction += ContactDamageReduction; + + // Multiplies the player's defense damage ratio directly, instead of being hardcoded into various places + modPlayer.defenseDamageRatio *= DefenseDamageMultiplier; } public override void ModifyTooltips(List list) diff --git a/Items/Accessories/DragonScales.cs b/Items/Accessories/DragonScales.cs index 25cfdf330e..7368dcb571 100644 --- a/Items/Accessories/DragonScales.cs +++ b/Items/Accessories/DragonScales.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Accessories public class DragonScales : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - public static int ShitBaseDamage = 55; + public static int ShitBaseDamage = 57; public static int TornadoBaseDamage = 210; public override void SetDefaults() diff --git a/Items/Accessories/ElementalGauntlet.cs b/Items/Accessories/ElementalGauntlet.cs index 7068bedd4f..54c6c96e52 100644 --- a/Items/Accessories/ElementalGauntlet.cs +++ b/Items/Accessories/ElementalGauntlet.cs @@ -28,15 +28,14 @@ namespace CalamityMod.Items.Accessories player.kbGlove = true; player.autoReuseGlove = true; player.meleeScaleGlove = true; - player.GetAttackSpeed() += 0.15f; - player.GetDamage() += 0.1f; + modPlayer.gloveLevel = 5; + player.GetDamage() += 0.10f; } public override void AddRecipes() { CreateRecipe(). AddIngredient(ItemID.FireGauntlet). - AddIngredient(). AddIngredient(ItemID.LunarBar, 8). AddIngredient(4). AddIngredient(4). diff --git a/Items/Accessories/EyeoftheStorm.cs b/Items/Accessories/EyeoftheStorm.cs index 18d6bc0a89..557ec963bd 100644 --- a/Items/Accessories/EyeoftheStorm.cs +++ b/Items/Accessories/EyeoftheStorm.cs @@ -5,6 +5,7 @@ using Terraria; using Terraria.ModLoader; using Terraria.ID; using Microsoft.Xna.Framework; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.Items.Accessories { @@ -43,9 +44,13 @@ namespace CalamityMod.Items.Accessories if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { var source = player.GetSource_Accessory(Item); - int damage = (int)player.GetTotalDamage().ApplyTo(45); + int baseDamage = 45; + if (modPlayer.oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + int damage = (int)player.GetTotalDamage().ApplyTo(baseDamage); var p = Projectile.NewProjectileDirect(source, player.Center, -Vector2.UnitY, ModContent.ProjectileType(), damage, 2f, Main.myPlayer, 0f, 0f); - p.originalDamage = 45; + p.originalDamage = baseDamage; } } } @@ -63,9 +68,13 @@ namespace CalamityMod.Items.Accessories if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { var source = player.GetSource_Accessory(Item); - int damage = (int)player.GetTotalDamage().ApplyTo(45); + int baseDamage = 45; + if (modPlayer.oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + int damage = (int)player.GetTotalDamage().ApplyTo(baseDamage); var p = Projectile.NewProjectileDirect(source, player.Center, -Vector2.UnitY, ModContent.ProjectileType(), damage, 2f, Main.myPlayer, 0f, 0f); - p.originalDamage = 45; + p.originalDamage = baseDamage; } } } diff --git a/Items/Accessories/FlameLickedShell.cs b/Items/Accessories/FlameLickedShell.cs index c7570e756d..93d15edc9f 100644 --- a/Items/Accessories/FlameLickedShell.cs +++ b/Items/Accessories/FlameLickedShell.cs @@ -8,6 +8,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; using Terraria.ID; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.Items.Accessories { @@ -55,6 +56,9 @@ namespace CalamityMod.Items.Accessories float offsetAngle = (float)Math.PI * radialOffset; int type = ModContent.ProjectileType(); int damage = (int)player.GetBestClassDamage().ApplyTo(60); + if (calPlayer.oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + if (player.whoAmI == Main.myPlayer) { if (empowered) @@ -70,6 +74,9 @@ namespace CalamityMod.Items.Accessories float radians2 = MathHelper.TwoPi / totalProjectiles; type = ModContent.ProjectileType(); damage = (int)player.GetBestClassDamage().ApplyTo(20); + if (calPlayer.oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + double angleA = radians2 * 0.5; double angleB = MathHelper.ToRadians(90f) - angleA; float velocityX = (float)(projectileSpeed * Math.Sin(angleA) / Math.Sin(angleB)); diff --git a/Items/Accessories/FrostBarrier.png b/Items/Accessories/FrostBarrier.png index 223d27f6da..28e16e2271 100644 Binary files a/Items/Accessories/FrostBarrier.png and b/Items/Accessories/FrostBarrier.png differ diff --git a/Items/Accessories/FungalClump.cs b/Items/Accessories/FungalClump.cs index 91fb2b0fd3..7349a0454f 100644 --- a/Items/Accessories/FungalClump.cs +++ b/Items/Accessories/FungalClump.cs @@ -1,5 +1,6 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Typeless; using Terraria; using Terraria.ID; @@ -34,13 +35,19 @@ namespace CalamityMod.Items.Accessories if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { var source = player.GetSource_Accessory(Item); - int damage = (int)player.GetBestClassDamage().ApplyTo(FungalClumpDamage); + + int baseDamage = FungalClumpDamage; + if (modPlayer.oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + int damage = (int)player.GetBestClassDamage().ApplyTo(baseDamage); int p = Projectile.NewProjectile(source, player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), damage, 1f, player.whoAmI); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = FungalClumpDamage; + Main.projectile[p].originalDamage = baseDamage; } } } + public override void UpdateVanity(Player player) { CalamityPlayer modPlayer = player.Calamity(); @@ -54,10 +61,15 @@ namespace CalamityMod.Items.Accessories if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { var source = player.GetSource_Accessory(Item); - int damage = (int)player.GetBestClassDamage().ApplyTo(FungalClumpDamage); + + int baseDamage = FungalClumpDamage; + if (modPlayer.oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + int damage = (int)player.GetBestClassDamage().ApplyTo(baseDamage); int p = Projectile.NewProjectile(source, player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), damage, 1f, player.whoAmI); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = FungalClumpDamage; + Main.projectile[p].originalDamage = baseDamage; } } } diff --git a/Items/Accessories/GloveOfRecklessness.cs b/Items/Accessories/GloveOfRecklessness.cs index 94bdebab89..d2293ed4b0 100644 --- a/Items/Accessories/GloveOfRecklessness.cs +++ b/Items/Accessories/GloveOfRecklessness.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Accessories modPlayer.stealthGenStandstill += 0.15f; modPlayer.stealthGenMoving += 0.15f; player.GetDamage() -= 0.10f; - player.GetCritChance() -= 10; + player.GetCritChance() -= 5; player.GetAttackSpeed() += 0.15f; } } diff --git a/Items/Accessories/HeartofDarkness.cs b/Items/Accessories/HeartofDarkness.cs index 9a6f05e082..1b8a76d29b 100644 --- a/Items/Accessories/HeartofDarkness.cs +++ b/Items/Accessories/HeartofDarkness.cs @@ -17,14 +17,15 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { - Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(6, 4)); + Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(6, 5)); ItemID.Sets.AnimatesAsSoul[Type] = true; + ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); } public override void SetDefaults() { - Item.width = 26; - Item.height = 26; + Item.width = 46; + Item.height = 66; Item.value = CalamityGlobalItem.Rarity3BuyPrice; Item.rare = ItemRarityID.Orange; Item.accessory = true; @@ -35,22 +36,5 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.heartOfDarkness = true; } - - public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) - { - CalamityUtils.DrawInventoryCustomScale( - spriteBatch, - texture: TextureAssets.Item[Type].Value, - position, - frame, - drawColor, - itemColor, - origin, - scale, - wantedScale: 0.8f, - drawOffset: new(-2f, -2f) - ); - return false; - } } } diff --git a/Items/Accessories/HeartofDarkness.png b/Items/Accessories/HeartofDarkness.png index b2b2517dd7..dace8e13b7 100644 Binary files a/Items/Accessories/HeartofDarkness.png and b/Items/Accessories/HeartofDarkness.png differ diff --git a/Items/Accessories/HeartoftheElements.cs b/Items/Accessories/HeartoftheElements.cs index 342811f679..aefb552dba 100644 --- a/Items/Accessories/HeartoftheElements.cs +++ b/Items/Accessories/HeartoftheElements.cs @@ -1,5 +1,6 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -57,7 +58,12 @@ namespace CalamityMod.Items.Accessories var source = player.GetSource_Accessory(Item); Vector2 velocity = new Vector2(0f, -1f); - int elementalDmg = (int)player.GetTotalDamage().ApplyTo(90); + + int baseDamage = 50; + if (modPlayer.oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + int elementalDmg = (int)player.GetTotalDamage().ApplyTo(baseDamage); float kBack = 2f + player.GetKnockback().Additive; if (player.ownedProjectileCounts[brimmy] > 1 || player.ownedProjectileCounts[siren] > 1 || @@ -76,31 +82,31 @@ namespace CalamityMod.Items.Accessories { int p = Projectile.NewProjectile(source, player.Center, velocity, brimmy, elementalDmg, kBack, player.whoAmI); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = 90; + Main.projectile[p].originalDamage = baseDamage; } if (player.ownedProjectileCounts[siren] < 1) { int p = Projectile.NewProjectile(source, player.Center, velocity, siren, elementalDmg, kBack, player.whoAmI); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = 90; + Main.projectile[p].originalDamage = baseDamage; } if (player.ownedProjectileCounts[healer] < 1) { int p = Projectile.NewProjectile(source, player.Center, velocity, healer, elementalDmg, kBack, player.whoAmI); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = 90; + Main.projectile[p].originalDamage = baseDamage; } if (player.ownedProjectileCounts[sandy] < 1) { int p = Projectile.NewProjectile(source, player.Center, velocity, sandy, elementalDmg, kBack, player.whoAmI); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = 90; + Main.projectile[p].originalDamage = baseDamage; } if (player.ownedProjectileCounts[cloudy] < 1) { int p = Projectile.NewProjectile(source, player.Center, velocity, cloudy, elementalDmg, kBack, player.whoAmI); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = 90; + Main.projectile[p].originalDamage = baseDamage; } } } @@ -119,7 +125,12 @@ namespace CalamityMod.Items.Accessories var source = player.GetSource_Accessory(Item); Vector2 velocity = new Vector2(0f, -1f); - int elementalDmg = (int)player.GetTotalDamage().ApplyTo(90); + + int baseDamage = 90; + if (modPlayer.oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + int elementalDmg = (int)player.GetTotalDamage().ApplyTo(baseDamage); float kBack = 2f + player.GetKnockback().Additive; if (player.ownedProjectileCounts[brimmy] > 1 || player.ownedProjectileCounts[siren] > 1 || @@ -138,31 +149,31 @@ namespace CalamityMod.Items.Accessories { int p = Projectile.NewProjectile(source, player.Center, velocity, brimmy, elementalDmg, kBack, player.whoAmI); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = 90; + Main.projectile[p].originalDamage = baseDamage; } if (player.ownedProjectileCounts[siren] < 1) { int p = Projectile.NewProjectile(source, player.Center, velocity, siren, elementalDmg, kBack, player.whoAmI); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = 90; + Main.projectile[p].originalDamage = baseDamage; } if (player.ownedProjectileCounts[healer] < 1) { int p = Projectile.NewProjectile(source, player.Center, velocity, healer, elementalDmg, kBack, player.whoAmI); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = 90; + Main.projectile[p].originalDamage = baseDamage; } if (player.ownedProjectileCounts[sandy] < 1) { int p = Projectile.NewProjectile(source, player.Center, velocity, sandy, elementalDmg, kBack, player.whoAmI); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = 90; + Main.projectile[p].originalDamage = baseDamage; } if (player.ownedProjectileCounts[cloudy] < 1) { int p = Projectile.NewProjectile(source, player.Center, velocity, cloudy, elementalDmg, kBack, player.whoAmI); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = 90; + Main.projectile[p].originalDamage = baseDamage; } } } diff --git a/Items/Accessories/HowlsHeart.cs b/Items/Accessories/HowlsHeart.cs index df2308cfff..d72dd6298a 100644 --- a/Items/Accessories/HowlsHeart.cs +++ b/Items/Accessories/HowlsHeart.cs @@ -10,6 +10,7 @@ using Terraria.ModLoader; using Terraria.GameContent; using static Terraria.ModLoader.ModContent; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.Items.Accessories { @@ -51,6 +52,9 @@ namespace CalamityMod.Items.Accessories if (player.ownedProjectileCounts[ProjectileType()] < 1) { int damage = (int)player.GetTotalDamage().ApplyTo(HowlDamage); + if (modPlayer.oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + Projectile howl = Projectile.NewProjectileDirect(source, player.Center, -Vector2.UnitY, ProjectileType(), damage, 1f, player.whoAmI, 0f, 1f); howl.originalDamage = damage; } @@ -77,6 +81,9 @@ namespace CalamityMod.Items.Accessories if (player.ownedProjectileCounts[ProjectileType()] < 1) { int damage = (int)player.GetTotalDamage().ApplyTo(HowlDamage); + if (player.Calamity().oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + int p = Projectile.NewProjectile(source, player.Center, -Vector2.UnitY, ProjectileType(), damage, 1f, player.whoAmI, 0f, 1f); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = HowlDamage; diff --git a/Items/Accessories/Laudanum.cs b/Items/Accessories/Laudanum.cs index fccdb39173..29eb533a53 100644 --- a/Items/Accessories/Laudanum.cs +++ b/Items/Accessories/Laudanum.cs @@ -8,6 +8,11 @@ namespace CalamityMod.Items.Accessories public class Laudanum : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + public override void SetStaticDefaults() + { + ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); + } + public override void SetDefaults() { Item.width = 26; diff --git a/Items/Accessories/MarniteRepulsionShield.cs b/Items/Accessories/MarniteRepulsionShield.cs index d03afe5221..b8f2499a6e 100644 --- a/Items/Accessories/MarniteRepulsionShield.cs +++ b/Items/Accessories/MarniteRepulsionShield.cs @@ -10,6 +10,7 @@ using ReLogic.Content; using System.Collections.Generic; using System.Linq; using static CalamityMod.CalamityUtils; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.Items.Accessories { @@ -37,6 +38,9 @@ namespace CalamityMod.Items.Accessories if (player.whoAmI == Main.myPlayer) { int baseDamage = 5; + if (player.Calamity().oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + var source = player.GetSource_Accessory(Item); if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { diff --git a/Items/Accessories/NebulousCore.cs b/Items/Accessories/NebulousCore.cs index 04f11cc140..7a16f79977 100644 --- a/Items/Accessories/NebulousCore.cs +++ b/Items/Accessories/NebulousCore.cs @@ -1,4 +1,5 @@ using CalamityMod.CalPlayer; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Typeless; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -22,9 +23,9 @@ namespace CalamityMod.Items.Accessories public override void Update(ref float gravity, ref float maxFallSpeed) { - float num = Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.35f * num, 0.05f * num, 0.35f * num); + float projLighting = Main.rand.Next(90, 111) * 0.01f; + projLighting *= Main.essScale; + Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.35f * projLighting, 0.05f * projLighting, 0.35f * projLighting); } public override void UpdateAccessory(Player player, bool hideVisual) @@ -36,62 +37,64 @@ namespace CalamityMod.Items.Accessories float knockBack = 3f; if (Main.rand.NextBool(15)) { - int num = 0; + int numProj = 0; for (int i = 0; i < Main.maxProjectiles; i++) { if (Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].type == ModContent.ProjectileType()) { - num++; + numProj++; } } var source = player.GetSource_Accessory(Item); - if (Main.rand.Next(15) >= num && num < 10) + if (Main.rand.Next(15) >= numProj && numProj < 10) { - int num2 = 50; - int num3 = 24; - int num4 = 90; - for (int j = 0; j < num2; j++) + int spawnRadius = 24; + int backupSpawnRadius = 90; + for (int j = 0; j < 50; j++) { - int num5 = Main.rand.Next(200 - j * 2, 400 + j * 2); + int randomProjOffset = Main.rand.Next(200 - j * 2, 400 + j * 2); Vector2 center = player.Center; - center.X += (float)Main.rand.Next(-num5, num5 + 1); - center.Y += (float)Main.rand.Next(-num5, num5 + 1); - if (!Collision.SolidCollision(center, num3, num3) && !Collision.WetCollision(center, num3, num3)) + center.X += (float)Main.rand.Next(-randomProjOffset, randomProjOffset + 1); + center.Y += (float)Main.rand.Next(-randomProjOffset, randomProjOffset + 1); + if (!Collision.SolidCollision(center, spawnRadius, spawnRadius) && !Collision.WetCollision(center, spawnRadius, spawnRadius)) { - center.X += (float)(num3 / 2); - center.Y += (float)(num3 / 2); + center.X += (float)(spawnRadius / 2); + center.Y += (float)(spawnRadius / 2); if (Collision.CanHit(new Vector2(player.Center.X, player.position.Y), 1, 1, center, 1, 1) || Collision.CanHit(new Vector2(player.Center.X, player.position.Y - 50f), 1, 1, center, 1, 1)) { - int num6 = (int)center.X / 16; - int num7 = (int)center.Y / 16; - bool flag = false; - if (Main.rand.NextBool(3) && Main.tile[num6, num7] != null && Main.tile[num6, num7].WallType > 0) + int projTileX = (int)center.X / 16; + int projTileY = (int)center.Y / 16; + bool canSpawnProj = false; + if (Main.rand.NextBool(3) && Main.tile[projTileX, projTileY] != null && Main.tile[projTileX, projTileY].WallType > 0) { - flag = true; + canSpawnProj = true; } else { - center.X -= (float)(num4 / 2); - center.Y -= (float)(num4 / 2); - if (Collision.SolidCollision(center, num4, num4)) + center.X -= (float)(backupSpawnRadius / 2); + center.Y -= (float)(backupSpawnRadius / 2); + if (Collision.SolidCollision(center, backupSpawnRadius, backupSpawnRadius)) { - center.X += (float)(num4 / 2); - center.Y += (float)(num4 / 2); - flag = true; + center.X += (float)(backupSpawnRadius / 2); + center.Y += (float)(backupSpawnRadius / 2); + canSpawnProj = true; } } - if (flag) + if (canSpawnProj) { for (int k = 0; k < Main.maxProjectiles; k++) { if (Main.projectile[k].active && Main.projectile[k].owner == player.whoAmI && Main.projectile[k].type == ModContent.ProjectileType() && (center - Main.projectile[k].Center).Length() < 48f) { - flag = false; + canSpawnProj = false; break; } } - if (flag && Main.myPlayer == player.whoAmI) + if (canSpawnProj && Main.myPlayer == player.whoAmI) { + if (modPlayer.oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + Projectile.NewProjectile(source, center.X, center.Y, 0f, 0f, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); return; } diff --git a/Items/Accessories/OceanCrest.cs b/Items/Accessories/OceanCrest.cs index 604654fa32..8fd47147aa 100644 --- a/Items/Accessories/OceanCrest.cs +++ b/Items/Accessories/OceanCrest.cs @@ -1,4 +1,5 @@ -using Terraria; +using CalamityMod.CalPlayer; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,12 +19,8 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.npcTypeNoAggro[NPCID.Shark] = true; - player.npcTypeNoAggro[NPCID.SeaSnail] = true; - player.npcTypeNoAggro[NPCID.PinkJellyfish] = true; - player.npcTypeNoAggro[NPCID.Crab] = true; - player.npcTypeNoAggro[NPCID.Squid] = true; - player.gills = true; + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.oceanCrest = true; } } } diff --git a/Items/Accessories/PearlofEnthrallment.cs b/Items/Accessories/PearlofEnthrallment.cs index 6172ffa364..5fd2d7e5f4 100644 --- a/Items/Accessories/PearlofEnthrallment.cs +++ b/Items/Accessories/PearlofEnthrallment.cs @@ -5,6 +5,7 @@ using Terraria; using Terraria.ModLoader; using Terraria.ID; using Microsoft.Xna.Framework; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.Items.Accessories { @@ -44,10 +45,14 @@ namespace CalamityMod.Items.Accessories } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - int damage = (int)player.GetTotalDamage().ApplyTo(65); + int baseDamage = 65; + if (modPlayer.oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + int damage = (int)player.GetTotalDamage().ApplyTo(baseDamage); int anahita = Projectile.NewProjectile(source, player.Center, -Vector2.UnitY, ModContent.ProjectileType(), damage, 2f, Main.myPlayer); if (Main.projectile.IndexInRange(anahita)) - Main.projectile[anahita].originalDamage = 65; + Main.projectile[anahita].originalDamage = baseDamage; } } } @@ -65,10 +70,14 @@ namespace CalamityMod.Items.Accessories } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - int damage = (int)player.GetTotalDamage().ApplyTo(65); + int baseDamage = 65; + if (modPlayer.oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + int damage = (int)player.GetTotalDamage().ApplyTo(baseDamage); int anahita = Projectile.NewProjectile(source, player.Center, -Vector2.UnitY, ModContent.ProjectileType(), damage, 2f, Main.myPlayer); if (Main.projectile.IndexInRange(anahita)) - Main.projectile[anahita].originalDamage = 65; + Main.projectile[anahita].originalDamage = baseDamage; } } } diff --git a/Items/Accessories/ProfanedSoulCrystal.cs b/Items/Accessories/ProfanedSoulCrystal.cs index e80364a9e3..5b98d9f708 100644 --- a/Items/Accessories/ProfanedSoulCrystal.cs +++ b/Items/Accessories/ProfanedSoulCrystal.cs @@ -14,6 +14,7 @@ using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.Items.Accessories { @@ -268,6 +269,9 @@ namespace CalamityMod.Items.Accessories int separation = (i * 4) - 8; int spearBaseDamage = 350; int spearDamage = (int)player.GetTotalDamage().ApplyTo(spearBaseDamage); + if (player.Calamity().oldFashioned) + spearDamage = CalamityUtils.CalcOldFashionedDamage(spearDamage); + int proj = Projectile.NewProjectile(source, player.Center.X, player.Center.Y - separation, perturbedspeed.X, perturbedspeed.Y, ModContent.ProjectileType(), spearDamage, 1f, player.whoAmI, Main.rand.NextBool(player.Calamity().profanedSoulWeaponUsage == 4 ? 5 : 7) ? 1f : 0f); if (proj.WithinBounds(Main.maxProjectiles)) { @@ -283,6 +287,9 @@ namespace CalamityMod.Items.Accessories { int spearBaseDamage = 250; int spearDamage = (int)player.GetTotalDamage().ApplyTo(spearBaseDamage); + if (player.Calamity().oldFashioned) + spearDamage = CalamityUtils.CalcOldFashionedDamage(spearDamage); + int proj = Projectile.NewProjectile(source, player.Center, correctedVelocity * 14f, ModContent.ProjectileType(), spearDamage, 1f, player.whoAmI, Main.rand.NextBool(player.Calamity().profanedSoulWeaponUsage == 4 ? 5 : 7) ? 1f : 0f, 1f); if (proj.WithinBounds(Main.maxProjectiles)) { @@ -307,6 +314,9 @@ namespace CalamityMod.Items.Accessories int projType = isSmallBoomer ? isThiccBoomer ? 1 : 2 : 3; int boomBaseDamage = 200; int boomDamage = (int)player.GetTotalDamage().ApplyTo(boomBaseDamage); + if (player.Calamity().oldFashioned) + boomDamage = CalamityUtils.CalcOldFashionedDamage(boomDamage); + switch (projType) { case 1: //big boomer @@ -354,13 +364,16 @@ namespace CalamityMod.Items.Accessories correctedVelocity *= 25f; SoundEngine.PlaySound(SoundID.Item20, player.Center); int magefireBaseDamage = 900; - int magefireDamage = (int)player.GetTotalDamage().ApplyTo(magefireBaseDamage); + int mageFireDamage = (int)player.GetTotalDamage().ApplyTo(magefireBaseDamage); if (player.HasBuff(BuffID.ManaSickness)) { - int sickPenalty = (int)(magefireDamage * (0.05f * ((player.buffTime[player.FindBuffIndex(BuffID.ManaSickness)] + 60) / 60))); - magefireDamage -= sickPenalty; + int sickPenalty = (int)(mageFireDamage * (0.05f * ((player.buffTime[player.FindBuffIndex(BuffID.ManaSickness)] + 60) / 60))); + mageFireDamage -= sickPenalty; } - int proj = Projectile.NewProjectile(source, player.position, correctedVelocity, ModContent.ProjectileType(), magefireDamage, 1f, player.whoAmI, empowered ? 1f : 0f); + if (player.Calamity().oldFashioned) + mageFireDamage = CalamityUtils.CalcOldFashionedDamage(mageFireDamage); + + int proj = Projectile.NewProjectile(source, player.position, correctedVelocity, ModContent.ProjectileType(), mageFireDamage, 1f, player.whoAmI, empowered ? 1f : 0f); if (proj.WithinBounds(Main.maxProjectiles)) { Main.projectile[proj].DamageType = DamageClass.Summon; @@ -386,6 +399,9 @@ namespace CalamityMod.Items.Accessories float angle = MathHelper.TwoPi / crystalCount * i; int shardBaseDamage = 176; int shardDamage = (int)player.GetTotalDamage().ApplyTo(shardBaseDamage); + if (player.Calamity().oldFashioned) + shardDamage = CalamityUtils.CalcOldFashionedDamage(shardDamage); + int proj = Projectile.NewProjectile(source, player.Center, angle.ToRotationVector2() * 12f, ModContent.ProjectileType(), shardDamage, 1f, player.whoAmI, 0f, 0f); if (proj.WithinBounds(Main.maxProjectiles)) { @@ -402,7 +418,9 @@ namespace CalamityMod.Items.Accessories int totalShardProjectiles = empowered ? 360 / 5 : 360 / 10; int shardBaseDamage = empowered ? 125 : 220; int shardDamage = (int)player.GetTotalDamage().ApplyTo(shardBaseDamage); - + if (player.Calamity().oldFashioned) + shardDamage = CalamityUtils.CalcOldFashionedDamage(shardDamage); + float interval = totalShardProjectiles / chains * (empowered ? 5f : 10f); double patternInterval = Math.Floor(player.Calamity().profanedSoulWeaponUsage / interval); if (patternInterval % 2 == 0) @@ -441,13 +459,16 @@ namespace CalamityMod.Items.Accessories { int whipBaseDamage = 250; int whipDamage = (int)player.GetTotalDamage().ApplyTo(whipBaseDamage); + if (player.Calamity().oldFashioned) + whipDamage = CalamityUtils.CalcOldFashionedDamage(whipDamage); + var buffed = player.HasBuff(); correctedVelocity *= buffed ? 10f : 8f; int permittedDistance = player.HasBuff() ? 10 : 8; correctedVelocity.X = Math.Clamp(correctedVelocity.X, -permittedDistance, permittedDistance); correctedVelocity.Y = Math.Clamp(correctedVelocity.Y, -permittedDistance, permittedDistance); - player.direction = correctedVelocity.X > 0 ? 1 : -1; + player.ChangeDir(MathF.Sign(correctedVelocity.X)); Projectile.NewProjectile(source, player.Center, correctedVelocity, ModContent.ProjectileType(), whipDamage, 1f, player.whoAmI); player.Calamity().profanedSoulWeaponUsage = 10; } diff --git a/Items/Accessories/RampartofDeities.cs b/Items/Accessories/RampartofDeities.cs index b3dfb4b051..24f98f4393 100644 --- a/Items/Accessories/RampartofDeities.cs +++ b/Items/Accessories/RampartofDeities.cs @@ -43,9 +43,9 @@ namespace CalamityMod.Items.Accessories int myPlayer = Main.myPlayer; if (Main.player[myPlayer].team == player.team && player.team != 0) { - float num = player.position.X - Main.player[myPlayer].position.X; - float num2 = player.position.Y - Main.player[myPlayer].position.Y; - if ((float)Math.Sqrt(num * num + num2 * num2) < 800f) + float teamPlayerXDist = player.position.X - Main.player[myPlayer].position.X; + float teamPlayerYDist = player.position.Y - Main.player[myPlayer].position.Y; + if ((float)Math.Sqrt(teamPlayerXDist * teamPlayerXDist + teamPlayerYDist * teamPlayerYDist) < 800f) Main.player[myPlayer].AddBuff(BuffID.PaladinsShield, 20); } } diff --git a/Items/Accessories/Regenator.cs b/Items/Accessories/Regenator.cs index 11898f474f..ccdcb40e89 100644 --- a/Items/Accessories/Regenator.cs +++ b/Items/Accessories/Regenator.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Accessories { player.statLife = (int)(player.statLifeMax2 * 0.5f); player.moonLeech = true; - modPlayer.healingPotBonus = 0; + modPlayer.healingPotionMultiplier = 0; if (player.lifeRegenCount > 0) player.lifeRegenCount = 0; diff --git a/Items/Accessories/RoseStone.cs b/Items/Accessories/RoseStone.cs index 01501a618c..bc5be1b333 100644 --- a/Items/Accessories/RoseStone.cs +++ b/Items/Accessories/RoseStone.cs @@ -4,6 +4,7 @@ using CalamityMod.Projectiles.Summon; using Terraria; using Terraria.ModLoader; using Terraria.ID; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.Items.Accessories { @@ -42,10 +43,14 @@ namespace CalamityMod.Items.Accessories } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - int damage = (int)player.GetTotalDamage().ApplyTo(60); + int baseDamage = 60; + if (modPlayer.oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + int damage = (int)player.GetTotalDamage().ApplyTo(baseDamage); int p = Projectile.NewProjectile(source, player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), damage, 2f, Main.myPlayer, 0f, 0f); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = 60; + Main.projectile[p].originalDamage = baseDamage; } } } @@ -63,10 +68,14 @@ namespace CalamityMod.Items.Accessories } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - int damage = (int)player.GetTotalDamage().ApplyTo(60); + int baseDamage = 60; + if (modPlayer.oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + int damage = (int)player.GetTotalDamage().ApplyTo(baseDamage); int p = Projectile.NewProjectile(source, player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), damage, 2f, Main.myPlayer, 0f, 0f); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = 60; + Main.projectile[p].originalDamage = baseDamage; } } } diff --git a/Items/Accessories/RottenBrain.cs b/Items/Accessories/RottenBrain.cs index a6e87462af..5fabf53f38 100644 --- a/Items/Accessories/RottenBrain.cs +++ b/Items/Accessories/RottenBrain.cs @@ -4,6 +4,7 @@ using Terraria; using Terraria.ModLoader; using Terraria.ID; using Terraria.Localization; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.Items.Accessories { @@ -29,6 +30,9 @@ namespace CalamityMod.Items.Accessories if (player.whoAmI == Main.myPlayer) { int damage = (int)player.GetBestClassDamage().ApplyTo(18); + if (player.Calamity().oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + Projectile rain = CalamityUtils.ProjectileRain(source, player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), damage, 2f, player.whoAmI); if (rain.whoAmI.WithinBounds(Main.maxProjectiles)) { diff --git a/Items/Accessories/SlagsplitterPauldron.cs b/Items/Accessories/SlagsplitterPauldron.cs index ea072683d2..51b372fa39 100644 --- a/Items/Accessories/SlagsplitterPauldron.cs +++ b/Items/Accessories/SlagsplitterPauldron.cs @@ -19,8 +19,8 @@ namespace CalamityMod.Items.Accessories public override void SetDefaults() { - Item.width = 46; - Item.height = 52; + Item.width = 54; + Item.height = 56; Item.value = CalamityGlobalItem.Rarity4BuyPrice; Item.rare = ItemRarityID.LightRed; Item.accessory = true; @@ -32,23 +32,6 @@ namespace CalamityMod.Items.Accessories modPlayer.Pauldron = true; } - public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) - { - //Helping the item look a bit better in inventory by being larger - CalamityUtils.DrawInventoryCustomScale( - spriteBatch, - texture: TextureAssets.Item[Type].Value, - position, - frame, - drawColor, - itemColor, - origin, - scale, - wantedScale: 0.85f, - drawOffset: new(0f, 0f) - ); - return false; - } public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Accessories/SlagsplitterPauldron.png b/Items/Accessories/SlagsplitterPauldron.png index e974d0a08d..f80c4876b9 100644 Binary files a/Items/Accessories/SlagsplitterPauldron.png and b/Items/Accessories/SlagsplitterPauldron.png differ diff --git a/Items/Accessories/StressPills.cs b/Items/Accessories/StressPills.cs index e75d1cb9cc..910e496684 100644 --- a/Items/Accessories/StressPills.cs +++ b/Items/Accessories/StressPills.cs @@ -8,6 +8,11 @@ namespace CalamityMod.Items.Accessories public class StressPills : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + public override void SetStaticDefaults() + { + ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); + } + public override void SetDefaults() { Item.width = 26; diff --git a/Items/Accessories/ToxicHeart.cs b/Items/Accessories/ToxicHeart.cs index e926e8c9b0..3ad3416261 100644 --- a/Items/Accessories/ToxicHeart.cs +++ b/Items/Accessories/ToxicHeart.cs @@ -5,6 +5,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; using Terraria.ID; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.Items.Accessories { @@ -27,10 +28,12 @@ namespace CalamityMod.Items.Accessories player.buffImmune[ModContent.BuffType()] = true; int plagueCounter = 0; Lighting.AddLight((int)(player.Center.X / 16f), (int)(player.Center.Y / 16f), 0.05f, 1f, 0.1f); - int num = ModContent.BuffType(); - float num2 = 300f; - bool flag = plagueCounter % 60 == 0; + int plagueDebuff = ModContent.BuffType(); + bool shouldInflictPlague = plagueCounter % 60 == 0; int auraDamage = (int)player.GetBestClassDamage().ApplyTo(50); + if (modPlayer.oldFashioned) + auraDamage = CalamityUtils.CalcOldFashionedDamage(auraDamage); + int random = Main.rand.Next(10); var source = player.GetSource_Accessory(Item); if (player.whoAmI == Main.myPlayer) @@ -40,13 +43,13 @@ namespace CalamityMod.Items.Accessories for (int l = 0; l < Main.maxNPCs; l++) { NPC nPC = Main.npc[l]; - if (nPC.IsAnEnemy() && !nPC.dontTakeDamage && !nPC.buffImmune[num] && Vector2.Distance(player.Center, nPC.Center) <= num2) + if (nPC.IsAnEnemy() && !nPC.dontTakeDamage && !nPC.buffImmune[plagueDebuff] && Vector2.Distance(player.Center, nPC.Center) <= 300f) { - if (nPC.FindBuffIndex(num) == -1) + if (nPC.FindBuffIndex(plagueDebuff) == -1) { - nPC.AddBuff(num, 120, false); + nPC.AddBuff(plagueDebuff, 120, false); } - if (flag) + if (shouldInflictPlague) { if (player.whoAmI == Main.myPlayer) { diff --git a/Items/Accessories/TrinketofChi.cs b/Items/Accessories/TrinketofChi.cs index 3ae74d4216..72fa81d1c4 100644 --- a/Items/Accessories/TrinketofChi.cs +++ b/Items/Accessories/TrinketofChi.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Items.Accessories public class TrinketofChi : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - internal const int ChiBuffTimerMax = 900; + internal const int ChiBuffTimerMax = 300; public override void SetDefaults() { diff --git a/Items/Accessories/VampiricTalisman.cs b/Items/Accessories/VampiricTalisman.cs index 2e344df9e1..6f1c62e81e 100644 --- a/Items/Accessories/VampiricTalisman.cs +++ b/Items/Accessories/VampiricTalisman.cs @@ -11,8 +11,8 @@ namespace CalamityMod.Items.Accessories public new string LocalizationCategory => "Items.Accessories"; public override void SetDefaults() { - Item.width = 58; - Item.height = 20; + Item.width = 86; + Item.height = 48; Item.value = CalamityGlobalItem.Rarity7BuyPrice; Item.accessory = true; Item.rare = ItemRarityID.Lime; diff --git a/Items/Accessories/VampiricTalisman.png b/Items/Accessories/VampiricTalisman.png index f04dc465cf..bee4ae83c0 100644 Binary files a/Items/Accessories/VampiricTalisman.png and b/Items/Accessories/VampiricTalisman.png differ diff --git a/Items/Accessories/Vanity/Birds_Head.png b/Items/Accessories/Vanity/Birds_Head.png index 69f37b43b8..e475326c77 100644 Binary files a/Items/Accessories/Vanity/Birds_Head.png and b/Items/Accessories/Vanity/Birds_Head.png differ diff --git a/Items/Accessories/Vanity/Birds_Head_Extension.png b/Items/Accessories/Vanity/Birds_Head_Extension.png new file mode 100644 index 0000000000..99dd209e3e Binary files /dev/null and b/Items/Accessories/Vanity/Birds_Head_Extension.png differ diff --git a/Items/Accessories/Vanity/CocosFeather.cs b/Items/Accessories/Vanity/CocosFeather.cs index 95cc235c7e..d19b6eafd7 100644 --- a/Items/Accessories/Vanity/CocosFeather.cs +++ b/Items/Accessories/Vanity/CocosFeather.cs @@ -4,10 +4,13 @@ using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using Microsoft.Xna.Framework; +using CalamityMod; + namespace CalamityMod.Items.Accessories.Vanity { - public class CocosFeather : ModItem, ILocalizedModType + public class CocosFeather : ModItem, IExtendedHat, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; public override void Load() @@ -42,7 +45,7 @@ namespace CalamityMod.Items.Accessories.Vanity Item.width = 42; Item.height = 38; Item.accessory = true; - Item.value = CalamityGlobalItem.Rarity1BuyPrice; + Item.value = CalamityGlobalItem.Rarity2BuyPrice; Item.rare = ItemRarityID.Green; Item.vanity = true; Item.Calamity().devItem = true; @@ -60,5 +63,7 @@ namespace CalamityMod.Items.Accessories.Vanity player.Calamity().cocosFeather = true; } } + public string ExtensionTexture => "CalamityMod/Items/Accessories/Vanity/Birds_Head_Extension"; + public Vector2 ExtensionSpriteOffset(PlayerDrawSet drawInfo) => new Vector2(0, -4f); } } diff --git a/Items/Accessories/Vanity/HapuFruit.cs b/Items/Accessories/Vanity/HapuFruit.cs index 34ff93086c..ab3e54ae9f 100644 --- a/Items/Accessories/Vanity/HapuFruit.cs +++ b/Items/Accessories/Vanity/HapuFruit.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Items.Accessories.Vanity Item.width = 22; Item.height = 30; Item.accessory = true; - Item.value = CalamityGlobalItem.Rarity1BuyPrice; + Item.value = CalamityGlobalItem.Rarity2BuyPrice; Item.rare = ItemRarityID.Green; Item.vanity = true; Item.Calamity().devItem = true; diff --git a/Items/Accessories/Vanity/OracleHeadphones.cs b/Items/Accessories/Vanity/OracleHeadphones.cs index d06022a3b0..ee34bff70b 100644 --- a/Items/Accessories/Vanity/OracleHeadphones.cs +++ b/Items/Accessories/Vanity/OracleHeadphones.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Items.Accessories.Vanity Item.width = 22; Item.height = 30; Item.accessory = true; - Item.value = Item.buyPrice(0, 1, 0, 0); + Item.value = CalamityGlobalItem.Rarity4BuyPrice; Item.rare = ItemRarityID.LightRed; Item.vanity = true; Item.Calamity().devItem = true; diff --git a/Items/Accessories/Vanity/RedBow.cs b/Items/Accessories/Vanity/RedBow.cs index 51831fbaa7..fb79ae25f4 100644 --- a/Items/Accessories/Vanity/RedBow.cs +++ b/Items/Accessories/Vanity/RedBow.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Items.Accessories.Vanity Item.width = 22; Item.height = 30; Item.accessory = true; - Item.value = CalamityGlobalItem.Rarity1BuyPrice; + Item.value = CalamityGlobalItem.Rarity2BuyPrice; Item.rare = ItemRarityID.Green; Item.vanity = true; Item.Calamity().devItem = true; diff --git a/Items/Accessories/VoidofCalamity.cs b/Items/Accessories/VoidofCalamity.cs index ebea2a71f3..803bdf6728 100644 --- a/Items/Accessories/VoidofCalamity.cs +++ b/Items/Accessories/VoidofCalamity.cs @@ -3,6 +3,7 @@ using CalamityMod.Projectiles.Typeless; using Terraria; using Terraria.ModLoader; using Terraria.ID; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.Items.Accessories { @@ -19,8 +20,6 @@ namespace CalamityMod.Items.Accessories Item.accessory = true; } - public override bool CanEquipAccessory(Player player, int slot, bool modded) => !player.Calamity().voidOfCalamity; - public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); @@ -34,6 +33,9 @@ namespace CalamityMod.Items.Accessories if (player.miscCounter % 10 == 0) { int damage = (int)player.GetBestClassDamage().ApplyTo(30); + if (modPlayer.oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + CalamityUtils.ProjectileRain(source, player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), damage, 5f, player.whoAmI); } } diff --git a/Items/Accessories/VoidofExtinction.cs b/Items/Accessories/VoidofExtinction.cs index 09171ca468..e21abda4b0 100644 --- a/Items/Accessories/VoidofExtinction.cs +++ b/Items/Accessories/VoidofExtinction.cs @@ -25,8 +25,6 @@ namespace CalamityMod.Items.Accessories Item.accessory = true; } - public override bool CanEquipAccessory(Player player, int slot, bool modded) => !player.Calamity().voidOfCalamity; - public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Accessories/WifeinaBottle.cs b/Items/Accessories/WifeinaBottle.cs index 6c22ff2c37..3b7a66147c 100644 --- a/Items/Accessories/WifeinaBottle.cs +++ b/Items/Accessories/WifeinaBottle.cs @@ -5,6 +5,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; using Terraria.ID; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.Items.Accessories { @@ -48,9 +49,13 @@ namespace CalamityMod.Items.Accessories } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - int damage = (int)player.GetTotalDamage().ApplyTo(ElementalDamage); + int baseDamage = ElementalDamage; + if (player.Calamity().oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + int damage = (int)player.GetTotalDamage().ApplyTo(baseDamage); var p = Projectile.NewProjectileDirect(player.GetSource_Accessory(Item), player.Center, -Vector2.UnitY, ModContent.ProjectileType(), damage, 2f, Main.myPlayer); - p.originalDamage = ElementalDamage; + p.originalDamage = baseDamage; } } } diff --git a/Items/Accessories/WifeinaBottlewithBoobs.cs b/Items/Accessories/WifeinaBottlewithBoobs.cs index 8f00649418..fbb40d82ed 100644 --- a/Items/Accessories/WifeinaBottlewithBoobs.cs +++ b/Items/Accessories/WifeinaBottlewithBoobs.cs @@ -5,6 +5,7 @@ using Terraria; using Terraria.ModLoader; using Terraria.ID; using Microsoft.Xna.Framework; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.Items.Accessories { @@ -43,9 +44,13 @@ namespace CalamityMod.Items.Accessories if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { var source = player.GetSource_Accessory(Item); - int damage = (int)player.GetTotalDamage().ApplyTo(45); + int baseDamage = 45; + if (modPlayer.oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + int damage = (int)player.GetTotalDamage().ApplyTo(baseDamage); Projectile sandy = Projectile.NewProjectileDirect(source, player.Center, -Vector2.UnitY, ModContent.ProjectileType(), damage, 2f, Main.myPlayer, 0f, 0f); - sandy.originalDamage = damage; + sandy.originalDamage = baseDamage; } } } @@ -63,9 +68,13 @@ namespace CalamityMod.Items.Accessories if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { var source = player.GetSource_Accessory(Item); - int damage = (int)player.GetTotalDamage().ApplyTo(45); + int baseDamage = 45; + if (modPlayer.oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + int damage = (int)player.GetTotalDamage().ApplyTo(baseDamage); Projectile sandy = Projectile.NewProjectileDirect(source, player.Center, -Vector2.UnitY, ModContent.ProjectileType(), damage, 2f, Main.myPlayer, 0f, 0f); - sandy.originalDamage = damage; + sandy.originalDamage = baseDamage; } } } diff --git a/Items/Accessories/Wings/AureateBooster.cs b/Items/Accessories/Wings/AureateBooster.cs index 9e2c91eebd..5e659207b6 100644 --- a/Items/Accessories/Wings/AureateBooster.cs +++ b/Items/Accessories/Wings/AureateBooster.cs @@ -38,12 +38,12 @@ namespace CalamityMod.Items.Accessories.Wings SoundEngine.PlaySound(SoundID.Item13, player.Center); player.rocketDelay2 = 60; } - int num66 = 2; + int dustAmt = 2; if (player.controlUp) { - num66 = 4; + dustAmt = 4; } - for (int num67 = 0; num67 < num66; num67++) + for (int i = 0; i < dustAmt; i++) { int type = 6; float scale = 1.75f; @@ -53,27 +53,27 @@ namespace CalamityMod.Items.Accessories.Wings { x = player.position.X + (float)(player.width / 2) - 26f; } - float num68 = player.position.Y + (float)player.height - 18f; - if (num67 == 1 || num67 == 3) + float dustYPos = player.position.Y + (float)player.height - 18f; + if (i == 1 || i == 3) { x = player.position.X + (float)(player.width / 2) + 8f; if (player.direction > 0) { x = player.position.X + (float)(player.width / 2) - 20f; } - num68 += 6f; + dustYPos += 6f; } - if (num67 > 1) + if (i > 1) { - num68 += player.velocity.Y; + dustYPos += player.velocity.Y; } - int num69 = Dust.NewDust(new Vector2(x, num68), 8, 8, type, 0f, 0f, alpha, default, scale); - Dust dust = Main.dust[num69]; + int boosterDust = Dust.NewDust(new Vector2(x, dustYPos), 8, 8, type, 0f, 0f, alpha, default, scale); + Dust dust = Main.dust[boosterDust]; dust.velocity.X *= 0.1f; - dust.velocity.Y = Main.dust[num69].velocity.Y * 1f + 2f * player.gravDir - player.velocity.Y * 0.3f; + dust.velocity.Y = Main.dust[boosterDust].velocity.Y * 1f + 2f * player.gravDir - player.velocity.Y * 0.3f; dust.noGravity = true; dust.shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); - if (num66 == 4) + if (dustAmt == 4) { dust.velocity.Y += 6f; } diff --git a/Items/Accessories/Wings/DrewsWings.cs b/Items/Accessories/Wings/DrewsWings.cs index 279ab88e13..cb05b0c66b 100644 --- a/Items/Accessories/Wings/DrewsWings.cs +++ b/Items/Accessories/Wings/DrewsWings.cs @@ -31,19 +31,19 @@ namespace CalamityMod.Items.Accessories.Wings { if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { - int num59 = 4; + int dustXOffset = 4; if (player.direction == 1) { - num59 = -40; + dustXOffset = -40; } - int num60 = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)num59, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 91, 0f, 0f, 100, default, 2.4f); - Main.dust[num60].noGravity = true; - Main.dust[num60].velocity *= 0.3f; + int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 91, 0f, 0f, 100, default, 2.4f); + Main.dust[flightDust].noGravity = true; + Main.dust[flightDust].velocity *= 0.3f; if (Main.rand.NextBool(10)) { - Main.dust[num60].fadeIn = 2f; + Main.dust[flightDust].fadeIn = 2f; } - Main.dust[num60].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } player.noFallDmg = true; } diff --git a/Items/Accessories/Wings/HadalMantle.cs b/Items/Accessories/Wings/HadalMantle.cs index aa76760ff8..a751b2333b 100644 --- a/Items/Accessories/Wings/HadalMantle.cs +++ b/Items/Accessories/Wings/HadalMantle.cs @@ -40,19 +40,19 @@ namespace CalamityMod.Items.Accessories.Wings if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { - int num59 = 4; + int dustXOffset = 4; if (player.direction == 1) { - num59 = -40; + dustXOffset = -40; } - int num60 = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)num59, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 6, 0f, 0f, 100, default, 2.4f); - Main.dust[num60].noGravity = true; - Main.dust[num60].velocity *= 0.3f; + int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 6, 0f, 0f, 100, default, 2.4f); + Main.dust[flightDust].noGravity = true; + Main.dust[flightDust].velocity *= 0.3f; if (Main.rand.NextBool(10)) { - Main.dust[num60].fadeIn = 2f; + Main.dust[flightDust].fadeIn = 2f; } - Main.dust[num60].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } player.noFallDmg = true; } diff --git a/Items/Accessories/Wings/MOAB.cs b/Items/Accessories/Wings/MOAB.cs index 37d6226b85..4fa0599fa1 100644 --- a/Items/Accessories/Wings/MOAB.cs +++ b/Items/Accessories/Wings/MOAB.cs @@ -69,10 +69,10 @@ namespace CalamityMod.Items.Accessories.Wings { yStart += player.velocity.Y; } - int num69 = Dust.NewDust(new Vector2(xStart, yStart), 8, 8, type, 0f, 0f, alpha, default, scale); - Dust dust = Main.dust[num69]; + int boosterDust = Dust.NewDust(new Vector2(xStart, yStart), 8, 8, type, 0f, 0f, alpha, default, scale); + Dust dust = Main.dust[boosterDust]; dust.velocity.X *= 0.1f; - dust.velocity.Y = Main.dust[num69].velocity.Y * 1f + 2f * player.gravDir - player.velocity.Y * 0.3f; + dust.velocity.Y = Main.dust[boosterDust].velocity.Y * 1f + 2f * player.gravDir - player.velocity.Y * 0.3f; dust.noGravity = true; dust.shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); if (dustAmt == 4) diff --git a/Items/Accessories/Wings/SilvaWings.cs b/Items/Accessories/Wings/SilvaWings.cs index de0edb4db6..0b24869c64 100644 --- a/Items/Accessories/Wings/SilvaWings.cs +++ b/Items/Accessories/Wings/SilvaWings.cs @@ -41,19 +41,19 @@ namespace CalamityMod.Items.Accessories.Wings if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { - int num59 = 4; + int dustXOffset = 4; if (player.direction == 1) { - num59 = -40; + dustXOffset = -40; } - int num60 = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)num59, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 157, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); - Main.dust[num60].noGravity = true; - Main.dust[num60].velocity *= 0.3f; + int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 157, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); + Main.dust[flightDust].noGravity = true; + Main.dust[flightDust].velocity *= 0.3f; if (Main.rand.NextBool(10)) { - Main.dust[num60].fadeIn = 2f; + Main.dust[flightDust].fadeIn = 2f; } - Main.dust[num60].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } player.noFallDmg = true; } diff --git a/Items/Accessories/Wings/SoulofCryogen.cs b/Items/Accessories/Wings/SoulofCryogen.cs index e1986d598f..05a6349279 100644 --- a/Items/Accessories/Wings/SoulofCryogen.cs +++ b/Items/Accessories/Wings/SoulofCryogen.cs @@ -7,6 +7,7 @@ using Terraria.ID; using Terraria.GameContent; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.Items.Accessories.Wings { @@ -33,9 +34,9 @@ namespace CalamityMod.Items.Accessories.Wings public override void Update(ref float gravity, ref float maxFallSpeed) { - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0f * num, 0.3f * num, 0.3f * num); + float lightOffset = (float)Main.rand.Next(90, 111) * 0.01f; + lightOffset *= Main.essScale; + Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0f * lightOffset, 0.3f * lightOffset, 0.3f * lightOffset); } public override void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) @@ -59,6 +60,9 @@ namespace CalamityMod.Items.Accessories.Wings { var source = player.GetSource_Accessory(Item); int damage = (int)player.GetBestClassDamage().ApplyTo(25); + if (modPlayer.oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + int p = Projectile.NewProjectile(source, player.Center.X, player.Center.Y, player.velocity.X * 0f, 2f, ModContent.ProjectileType(), damage, 3f, player.whoAmI, 1f); if (p.WithinBounds(Main.maxProjectiles)) { diff --git a/Items/Accessories/Wings/StarlightWings.cs b/Items/Accessories/Wings/StarlightWings.cs index e132c20b50..1f05487c5a 100644 --- a/Items/Accessories/Wings/StarlightWings.cs +++ b/Items/Accessories/Wings/StarlightWings.cs @@ -40,19 +40,19 @@ namespace CalamityMod.Items.Accessories.Wings if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { - int num59 = 4; + int dustXOffset = 4; if (player.direction == 1) { - num59 = -40; + dustXOffset = -40; } - int num60 = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)num59, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 173, 0f, 0f, 100, default, 2.4f); - Main.dust[num60].noGravity = true; - Main.dust[num60].velocity *= 0.3f; + int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 173, 0f, 0f, 100, default, 2.4f); + Main.dust[flightDust].noGravity = true; + Main.dust[flightDust].velocity *= 0.3f; if (Main.rand.NextBool(10)) { - Main.dust[num60].fadeIn = 2f; + Main.dust[flightDust].fadeIn = 2f; } - Main.dust[num60].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } player.noFallDmg = true; } diff --git a/Items/Accessories/Wings/TarragonWings.cs b/Items/Accessories/Wings/TarragonWings.cs index 6e44ccd393..b64b5c2d6e 100644 --- a/Items/Accessories/Wings/TarragonWings.cs +++ b/Items/Accessories/Wings/TarragonWings.cs @@ -43,19 +43,19 @@ namespace CalamityMod.Items.Accessories.Wings if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { - int num59 = 4; + int dustXOffset = 4; if (player.direction == 1) { - num59 = -40; + dustXOffset = -40; } - int num60 = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)num59, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 2.4f); - Main.dust[num60].noGravity = true; - Main.dust[num60].velocity *= 0.3f; + int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 2.4f); + Main.dust[flightDust].noGravity = true; + Main.dust[flightDust].velocity *= 0.3f; if (Main.rand.NextBool(10)) { - Main.dust[num60].fadeIn = 2f; + Main.dust[flightDust].fadeIn = 2f; } - Main.dust[num60].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } player.noFallDmg = true; } diff --git a/Items/Accessories/Wings/TracersCelestial.cs b/Items/Accessories/Wings/TracersCelestial.cs index 4ed7748604..c40e9d5f4a 100644 --- a/Items/Accessories/Wings/TracersCelestial.cs +++ b/Items/Accessories/Wings/TracersCelestial.cs @@ -34,19 +34,19 @@ namespace CalamityMod.Items.Accessories.Wings { if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { - int num59 = 4; + int dustXOffset = 4; if (player.direction == 1) { - num59 = -40; + dustXOffset = -40; } - int num60 = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)num59, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 107, 0f, 0f, 100, default, 2.4f); - Main.dust[num60].noGravity = true; - Main.dust[num60].velocity *= 0.3f; + int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 107, 0f, 0f, 100, default, 2.4f); + Main.dust[flightDust].noGravity = true; + Main.dust[flightDust].velocity *= 0.3f; if (Main.rand.NextBool(10)) { - Main.dust[num60].fadeIn = 2f; + Main.dust[flightDust].fadeIn = 2f; } - Main.dust[num60].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } CalamityPlayer modPlayer = player.Calamity(); player.accRunSpeed = 8f; diff --git a/Items/Accessories/Wings/TracersElysian.cs b/Items/Accessories/Wings/TracersElysian.cs index c09a119136..bf270f6390 100644 --- a/Items/Accessories/Wings/TracersElysian.cs +++ b/Items/Accessories/Wings/TracersElysian.cs @@ -37,19 +37,19 @@ namespace CalamityMod.Items.Accessories.Wings { if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { - int num59 = 4; + int dustXOffset = 4; if (player.direction == 1) { - num59 = -40; + dustXOffset = -40; } - int num60 = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)num59, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, Main.rand.NextBool() ? 206 : 173, 0f, 0f, 100, default, 2.4f); - Main.dust[num60].noGravity = true; - Main.dust[num60].velocity *= 0.3f; + int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, Main.rand.NextBool() ? 206 : 173, 0f, 0f, 100, default, 2.4f); + Main.dust[flightDust].noGravity = true; + Main.dust[flightDust].velocity *= 0.3f; if (Main.rand.NextBool(10)) { - Main.dust[num60].fadeIn = 2f; + Main.dust[flightDust].fadeIn = 2f; } - Main.dust[num60].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } CalamityPlayer modPlayer = player.Calamity(); player.accRunSpeed = 8.5f; diff --git a/Items/Accessories/Wings/TracersSeraph.cs b/Items/Accessories/Wings/TracersSeraph.cs index 6feb6dcf59..55063ce270 100644 --- a/Items/Accessories/Wings/TracersSeraph.cs +++ b/Items/Accessories/Wings/TracersSeraph.cs @@ -37,19 +37,19 @@ namespace CalamityMod.Items.Accessories.Wings { if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { - int num59 = 4; + int dustXOffset = 4; if (player.direction == 1) { - num59 = -40; + dustXOffset = -40; } - int num60 = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)num59, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 91, 0f, 0f, 100, default, 2.4f); - Main.dust[num60].noGravity = true; - Main.dust[num60].velocity *= 0.3f; + int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 91, 0f, 0f, 100, default, 2.4f); + Main.dust[flightDust].noGravity = true; + Main.dust[flightDust].velocity *= 0.3f; if (Main.rand.NextBool(10)) { - Main.dust[num60].fadeIn = 2f; + Main.dust[flightDust].fadeIn = 2f; } - Main.dust[num60].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } CalamityPlayer modPlayer = player.Calamity(); player.accRunSpeed = 9f; diff --git a/Items/Accessories/WulfrumBattery.cs b/Items/Accessories/WulfrumBattery.cs index c738506500..178922a042 100644 --- a/Items/Accessories/WulfrumBattery.cs +++ b/Items/Accessories/WulfrumBattery.cs @@ -36,7 +36,8 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { player.GetDamage() += 0.07f; - player.GetModPlayer().battery = true; + if (!hideVisual) + player.GetModPlayer().battery = true; } //Scrappable for 3-6 wulfrum scrap or a 20% chance to get an energy core @@ -66,20 +67,22 @@ namespace CalamityMod.Items.Accessories { if (!projectile.npcProj && !projectile.trap && projectile.minion && !ProjectileID.Sets.MinionShot[projectile.type] && Main.player[projectile.owner].GetModPlayer().battery) { - float lightMult = 2f; + float lightMult = 1f; if (Lighting.UpdateEveryFrame) //The light loks wayyy too bright in retro/trippy - lightMult *= 0.5f; + lightMult *= 0.25f; - Lighting.AddLight(projectile.Center, Color.DeepSkyBlue.ToVector3() * lightMult); + Lighting.AddLight(projectile.Center, Color.LightGreen.ToVector3() * lightMult); - if (Main.rand.NextBool(16)) + if (Main.rand.NextBool(15)) { float size = (projectile.Hitbox.Size() / 2f).Length(); - Dust zapDust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(1f, 1f) * size, 226, Main.rand.NextVector2Circular(1f, 1f) * Main.rand.NextFloat(1f, 2.3f)); + Dust zapDust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(1f, 1f) * size, 66, Main.rand.NextVector2Circular(1f, 1f) * Main.rand.NextFloat(0.5f, 1.3f)); zapDust.noGravity = true; + zapDust.color = Main.rand.NextBool() ? Color.SkyBlue : Color.LightGreen; + zapDust.velocity = projectile.velocity * 0.2f; } } } diff --git a/Items/Accessories/YharimsGift.cs b/Items/Accessories/YharimsGift.cs index 132fe3b466..57e3ed291d 100644 --- a/Items/Accessories/YharimsGift.cs +++ b/Items/Accessories/YharimsGift.cs @@ -5,6 +5,7 @@ using Terraria; using Terraria.ModLoader; using Terraria.ID; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.Items.Accessories { @@ -36,6 +37,9 @@ namespace CalamityMod.Items.Accessories if (player.whoAmI == Main.myPlayer) { int damage = (int)player.GetBestClassDamage().ApplyTo(175); + if (player.Calamity().oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + int projectile1 = Projectile.NewProjectile(source, player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 5f, player.whoAmI, 0f, 0f); Main.projectile[projectile1].timeLeft = 60; } @@ -53,6 +57,9 @@ namespace CalamityMod.Items.Accessories if (player.whoAmI == Main.myPlayer) { int damage = (int)player.GetBestClassDamage().ApplyTo(375); + if (player.Calamity().oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + CalamityUtils.ProjectileRain(source, player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), damage, 9f, player.whoAmI); } } diff --git a/Items/Accessories/YharimsInsignia.cs b/Items/Accessories/YharimsInsignia.cs deleted file mode 100644 index ed57a5b00b..0000000000 --- a/Items/Accessories/YharimsInsignia.cs +++ /dev/null @@ -1,40 +0,0 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using CalamityMod.Rarities; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Accessories -{ - public class YharimsInsignia : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Accessories"; - public override void SetDefaults() - { - Item.width = 22; - Item.height = 38; - Item.value = CalamityGlobalItem.Rarity12BuyPrice; - Item.accessory = true; - Item.rare = ModContent.RarityType(); - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.yInsignia = true; - player.GetDamage() += 0.15f; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.WarriorEmblem). - AddIngredient(). - AddIngredient(5). - AddIngredient(5). - AddTile(TileID.LunarCraftingStation). - Register(); - } - } -} diff --git a/Items/Accessories/YharimsInsignia.png b/Items/Accessories/YharimsInsignia.png deleted file mode 100644 index 2064208263..0000000000 Binary files a/Items/Accessories/YharimsInsignia.png and /dev/null differ diff --git a/Items/Ammo/MortarRound.cs b/Items/Ammo/MortarRound.cs index 7c3d361918..b4d74f867d 100644 --- a/Items/Ammo/MortarRound.cs +++ b/Items/Ammo/MortarRound.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Ranged; -using CalamityMod.Rarities; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,11 +8,13 @@ namespace CalamityMod.Items.Ammo { public class MortarRound : ModItem, ILocalizedModType { + internal static int TileBlastRadiusNormal = 3; + internal static int TileBlastRadiusGFB = 5; + public static int TileBlastRadius => Main.getGoodWorld ? TileBlastRadiusGFB : TileBlastRadiusNormal; + public static int HitboxBlastRadius => TileBlastRadius * 16 + 12; + public new string LocalizationCategory => "Items.Ammo"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 99; - } + public override void SetStaticDefaults() => Item.ResearchUnlockCount = 99; public override void SetDefaults() { @@ -23,9 +24,9 @@ namespace CalamityMod.Items.Ammo Item.height = 14; Item.maxStack = 9999; Item.consumable = true; - Item.knockBack = 7.5f; + Item.knockBack = 7f; Item.value = Item.sellPrice(copper: 20); - Item.rare = ModContent.RarityType(); + Item.rare = ItemRarityID.Yellow; Item.ammo = AmmoID.Bullet; Item.shoot = ModContent.ProjectileType(); } @@ -33,9 +34,10 @@ namespace CalamityMod.Items.Ammo public override void AddRecipes() { CreateRecipe(100). - AddIngredient(ItemID.RocketIV, 100). - AddIngredient(). - AddTile(TileID.LunarCraftingStation). + AddIngredient(ItemID.EmptyBullet, 100). + AddIngredient(ItemID.ExplosivePowder, 4). + AddIngredient(). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Ammo/RubberMortarRound.cs b/Items/Ammo/RubberMortarRound.cs index 3607df7033..0c328d44a9 100644 --- a/Items/Ammo/RubberMortarRound.cs +++ b/Items/Ammo/RubberMortarRound.cs @@ -1,5 +1,4 @@ using CalamityMod.Projectiles.Ranged; -using CalamityMod.Rarities; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,22 +8,19 @@ namespace CalamityMod.Items.Ammo public class RubberMortarRound : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Ammo"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 99; - } + public override void SetStaticDefaults() => Item.ResearchUnlockCount = 99; public override void SetDefaults() { - Item.damage = 25; + Item.damage = 20; Item.DamageType = DamageClass.Ranged; Item.width = 20; Item.height = 14; Item.maxStack = 9999; Item.consumable = true; - Item.knockBack = 7.5f; + Item.knockBack = 7f; Item.value = Item.sellPrice(copper: 20); - Item.rare = ModContent.RarityType(); + Item.rare = ItemRarityID.Yellow; Item.ammo = AmmoID.Bullet; Item.shoot = ModContent.ProjectileType(); } @@ -34,7 +30,7 @@ namespace CalamityMod.Items.Ammo CreateRecipe(100). AddIngredient(100). AddIngredient(ItemID.PinkGel, 5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Armor/Aerospec/AerospecHelmet.cs b/Items/Armor/Aerospec/AerospecHelmet.cs index bc1f4eb66c..6e4bfb4378 100644 --- a/Items/Armor/Aerospec/AerospecHelmet.cs +++ b/Items/Armor/Aerospec/AerospecHelmet.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Summon; using Terraria; using Terraria.ID; @@ -47,10 +48,14 @@ namespace CalamityMod.Items.Armor.Aerospec } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - var damage = (int)player.GetTotalDamage().ApplyTo(20); + int baseDamage = 20; + if (modPlayer.oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + var damage = (int)player.GetTotalDamage().ApplyTo(baseDamage); var p = Projectile.NewProjectile(source, player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = 20; + Main.projectile[p].originalDamage = baseDamage; } } player.GetDamage() += 0.11f; diff --git a/Items/Armor/Daedalus/DaedalusHeadSummon.cs b/Items/Armor/Daedalus/DaedalusHeadSummon.cs index 31d9d58f3b..e99ced0e62 100644 --- a/Items/Armor/Daedalus/DaedalusHeadSummon.cs +++ b/Items/Armor/Daedalus/DaedalusHeadSummon.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; @@ -48,9 +49,13 @@ namespace CalamityMod.Items.Armor.Daedalus } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - var damage = (int)player.GetTotalDamage().ApplyTo(95); + int baseDamage = 95; + if (modPlayer.oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + var damage = (int)player.GetTotalDamage().ApplyTo(baseDamage); var p = Projectile.NewProjectileDirect(source, player.Center, -Vector2.UnitY, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 50f, 0f); - p.originalDamage = 95; + p.originalDamage = baseDamage; } } player.GetDamage() += 0.2f; diff --git a/Items/Armor/Demonshade/DemonshadeHelm.cs b/Items/Armor/Demonshade/DemonshadeHelm.cs index 5b77dbe96d..bc5ea60245 100644 --- a/Items/Armor/Demonshade/DemonshadeHelm.cs +++ b/Items/Armor/Demonshade/DemonshadeHelm.cs @@ -9,6 +9,7 @@ using Terraria; using Terraria.Audio; using Terraria.ModLoader; using Terraria.DataStructures; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.Items.Armor.Demonshade { @@ -59,7 +60,10 @@ namespace CalamityMod.Items.Armor.Demonshade if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { var baseDamage = 10000; - var damage = (int)player.GetTotalDamage().ApplyTo(10000); + if (modPlayer.oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + var damage = (int)player.GetTotalDamage().ApplyTo(baseDamage); var devil = Projectile.NewProjectileDirect(source, player.Center, -Vector2.UnitY, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); devil.originalDamage = baseDamage; } diff --git a/Items/Armor/DesertProwler/DesertProwlerSet.cs b/Items/Armor/DesertProwler/DesertProwlerSet.cs index c65a5bc236..98c95440f8 100644 --- a/Items/Armor/DesertProwler/DesertProwlerSet.cs +++ b/Items/Armor/DesertProwler/DesertProwlerSet.cs @@ -15,6 +15,7 @@ using Terraria.Audio; using Terraria.DataStructures; using CalamityMod.Dusts; using ReLogic.Utilities; +using Terraria.Localization; namespace CalamityMod.Items.Armor.DesertProwler { @@ -47,7 +48,7 @@ namespace CalamityMod.Items.Armor.DesertProwler private void ActivateSetBonus(Terraria.On_Player.orig_KeyDoubleTap orig, Player player, int keyDir) { - if (keyDir == 0 && HasArmorSet(player) && !player.mount.Active) + if (keyDir == (Main.ReversedUpDownArmorSetBonuses ? 1 : 0) && HasArmorSet(player) && !player.mount.Active) { // The set bonus can only be activated if the player does not have the cooldown. if (!player.Calamity().cooldowns.TryGetValue(SandsmokeBomb.ID, out CooldownInstance cd)) @@ -166,7 +167,8 @@ namespace CalamityMod.Items.Armor.DesertProwler if (setBonusIndex != -1) { - TooltipLine setBonus1 = new TooltipLine(item.Mod, "CalamityMod:SetBonus1", CalamityUtils.GetTextValueFromModItem("AbilityBrief")); + string dir = Language.GetTextValue(Main.ReversedUpDownArmorSetBonuses ? "Key.UP" : "Key.DOWN"); + TooltipLine setBonus1 = new TooltipLine(item.Mod, "CalamityMod:SetBonus1", CalamityUtils.GetTextFromModItem("AbilityBrief").Format(dir)); setBonus1.OverrideColor = Color.Lerp(new Color(255, 229, 156), new Color(233, 225, 198), 0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 3f)); tooltips.Insert(setBonusIndex + 1, setBonus1); diff --git a/Items/Armor/Empyrean/EmpyreanMask.cs b/Items/Armor/Empyrean/EmpyreanMask.cs index 7f812503a7..3fef9a2634 100644 --- a/Items/Armor/Empyrean/EmpyreanMask.cs +++ b/Items/Armor/Empyrean/EmpyreanMask.cs @@ -1,4 +1,5 @@ -using CalamityMod.CalPlayer; +using CalamityMod.Buffs.StatBuffs; +using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; @@ -68,8 +69,8 @@ namespace CalamityMod.Items.Armor.Empyrean player.setBonus = this.GetLocalizedValue("SetBonus"); if (player.statLife <= (int)(player.statLifeMax2 * 0.5)) { - player.AddBuff(BuffID.Wrath, 2); - player.AddBuff(BuffID.Rage, 2); + player.AddBuff(ModContent.BuffType(), 2); + player.AddBuff(ModContent.BuffType(), 2); } player.GetDamage() += 0.09f; modPlayer.rogueVelocity += 0.09f; diff --git a/Items/Armor/Hydrothermic/HydrothermicHeadSummon.cs b/Items/Armor/Hydrothermic/HydrothermicHeadSummon.cs index a392bb7b0d..b1bfbf2a1b 100644 --- a/Items/Armor/Hydrothermic/HydrothermicHeadSummon.cs +++ b/Items/Armor/Hydrothermic/HydrothermicHeadSummon.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Summon; using Terraria; using Terraria.ID; @@ -48,10 +49,14 @@ namespace CalamityMod.Items.Armor.Hydrothermic } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - var damage = (int)player.GetTotalDamage().ApplyTo(190); + int baseDamage = 190; + if (modPlayer.oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + var damage = (int)player.GetTotalDamage().ApplyTo(baseDamage); var p = Projectile.NewProjectile(source, player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 38f, 0f); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = 190; + Main.projectile[p].originalDamage = baseDamage; } } player.GetDamage() += 0.4f; diff --git a/Items/Armor/Mollusk/MolluskShellmet.cs b/Items/Armor/Mollusk/MolluskShellmet.cs index 08e48e47cd..53b1d8c8fe 100644 --- a/Items/Armor/Mollusk/MolluskShellmet.cs +++ b/Items/Armor/Mollusk/MolluskShellmet.cs @@ -7,6 +7,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using Microsoft.Xna.Framework; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.Items.Armor.Mollusk { @@ -51,8 +52,12 @@ namespace CalamityMod.Items.Armor.Mollusk } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 2) { - Projectile clam = Projectile.NewProjectileDirect(source, player.Center, -Vector2.UnitY, ModContent.ProjectileType(), 140, 0f, player.whoAmI); - clam.originalDamage = 140; + int baseDamage = 140; + if (modPlayer.oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + Projectile clam = Projectile.NewProjectileDirect(source, player.Center, -Vector2.UnitY, ModContent.ProjectileType(), baseDamage, 0f, player.whoAmI); + clam.originalDamage = baseDamage; } } player.Calamity().wearingRogueArmor = true; diff --git a/Items/Armor/PlagueReaper/PlagueReaperMask.cs b/Items/Armor/PlagueReaper/PlagueReaperMask.cs index b6425b4595..708e2f33c2 100644 --- a/Items/Armor/PlagueReaper/PlagueReaperMask.cs +++ b/Items/Armor/PlagueReaper/PlagueReaperMask.cs @@ -6,6 +6,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.Items.Armor.PlagueReaper { @@ -60,6 +61,9 @@ namespace CalamityMod.Items.Armor.PlagueReaper if (player.miscCounter % 10 == 0) { var damage = (int)player.GetTotalDamage().ApplyTo(40); + if (modPlayer.oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + var cinder = CalamityUtils.ProjectileRain(source, player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), damage, 4f, player.whoAmI); if (cinder.whoAmI.WithinBounds(Main.maxProjectiles)) cinder.DamageType = DamageClass.Generic; diff --git a/Items/Armor/Plaguebringer/PlaguebringerCarapace.cs b/Items/Armor/Plaguebringer/PlaguebringerCarapace.cs index 56e55487f4..31b001d949 100644 --- a/Items/Armor/Plaguebringer/PlaguebringerCarapace.cs +++ b/Items/Armor/Plaguebringer/PlaguebringerCarapace.cs @@ -13,7 +13,6 @@ namespace CalamityMod.Items.Armor.Plaguebringer public new string LocalizationCategory => "Items.Armor.Hardmode"; public override void SetStaticDefaults() { - if (Main.netMode == NetmodeID.Server) return; @@ -36,7 +35,7 @@ namespace CalamityMod.Items.Armor.Plaguebringer public override void UpdateEquip(Player player) { player.Calamity().plaguebringerCarapace = true; - player.GetDamage() += 0.12f; + player.GetDamage() += 0.15f; player.buffImmune[ModContent.BuffType()] = true; } diff --git a/Items/Armor/Plaguebringer/PlaguebringerPistons.cs b/Items/Armor/Plaguebringer/PlaguebringerPistons.cs index d7b1382c6a..2c0b2541d0 100644 --- a/Items/Armor/Plaguebringer/PlaguebringerPistons.cs +++ b/Items/Armor/Plaguebringer/PlaguebringerPistons.cs @@ -9,7 +9,6 @@ namespace CalamityMod.Items.Armor.Plaguebringer public class PlaguebringerPistons : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; - public int counter = 0; public override void SetDefaults() { Item.width = 18; @@ -22,9 +21,8 @@ namespace CalamityMod.Items.Armor.Plaguebringer public override void UpdateEquip(Player player) { - player.GetDamage() += 0.13f; + player.GetDamage() += 0.15f; player.moveSpeed += 0.15f; - player.Calamity().plaguebringerPistons = true; //Flower Boots code if (player.whoAmI == Main.myPlayer && player.velocity.Y == 0f && player.grappling[0] == -1) diff --git a/Items/Armor/Plaguebringer/PlaguebringerVisor.cs b/Items/Armor/Plaguebringer/PlaguebringerVisor.cs index 48629edf23..f008ad6cd9 100644 --- a/Items/Armor/Plaguebringer/PlaguebringerVisor.cs +++ b/Items/Armor/Plaguebringer/PlaguebringerVisor.cs @@ -5,6 +5,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using CalamityMod.CalPlayer.Dashes; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.Items.Armor.Plaguebringer { @@ -57,10 +58,14 @@ namespace CalamityMod.Items.Armor.Plaguebringer } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - var damage = (int)player.GetTotalDamage().ApplyTo(80); + int baseDamage = 25; + if (player.Calamity().oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + var damage = (int)player.GetTotalDamage().ApplyTo(baseDamage); var p = Projectile.NewProjectile(source, player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 0f, 0f); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = 80; + Main.projectile[p].originalDamage = baseDamage; } } diff --git a/Items/Armor/Silva/SilvaArmor.cs b/Items/Armor/Silva/SilvaArmor.cs index 2179048508..ccfb997b04 100644 --- a/Items/Armor/Silva/SilvaArmor.cs +++ b/Items/Armor/Silva/SilvaArmor.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Armor.Silva public new string LocalizationCategory => "Items.Armor.PostMoonLord"; public override void SetDefaults() { - Item.width = 34; + Item.width = 24; Item.height = 24; Item.value = CalamityGlobalItem.Rarity14BuyPrice; Item.defense = 44; diff --git a/Items/Armor/Silva/SilvaArmor.png b/Items/Armor/Silva/SilvaArmor.png index a12120e2db..cec323c8f2 100644 Binary files a/Items/Armor/Silva/SilvaArmor.png and b/Items/Armor/Silva/SilvaArmor.png differ diff --git a/Items/Armor/Silva/SilvaHeadSummon.cs b/Items/Armor/Silva/SilvaHeadSummon.cs index 9e5b31111e..4a99df3f47 100644 --- a/Items/Armor/Silva/SilvaHeadSummon.cs +++ b/Items/Armor/Silva/SilvaHeadSummon.cs @@ -2,6 +2,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -55,10 +56,14 @@ namespace CalamityMod.Items.Armor.Silva } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - var damage = (int)player.GetTotalDamage().ApplyTo(600); + int baseDamage = 600; + if (modPlayer.oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + + var damage = (int)player.GetTotalDamage().ApplyTo(baseDamage); var p = Projectile.NewProjectile(source, player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, -20f, 0f); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = 600; + Main.projectile[p].originalDamage = baseDamage; } } player.GetDamage() += 0.65f; diff --git a/Items/Armor/Statigel/StatigelHeadSummon.cs b/Items/Armor/Statigel/StatigelHeadSummon.cs index 00396a94a3..fd43d34d8c 100644 --- a/Items/Armor/Statigel/StatigelHeadSummon.cs +++ b/Items/Armor/Statigel/StatigelHeadSummon.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.Summon; using CalamityMod.ExtraJumps; using CalamityMod.Items.Materials; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Summon; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; @@ -50,6 +51,9 @@ namespace CalamityMod.Items.Armor.Statigel var minionID = -1; var baseDamage = 33; + if (modPlayer.oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + var minionDamage = (int)player.GetTotalDamage().ApplyTo(baseDamage); if (WorldGen.crimson && player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) minionID = Projectile.NewProjectile(source, player.Center, -Vector2.UnitY, ModContent.ProjectileType(), minionDamage, 0f, Main.myPlayer); diff --git a/Items/Armor/Victide/VictideHeadSummon.cs b/Items/Armor/Victide/VictideHeadSummon.cs index 40f1a6571a..f3af00a25b 100644 --- a/Items/Armor/Victide/VictideHeadSummon.cs +++ b/Items/Armor/Victide/VictideHeadSummon.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; @@ -46,6 +47,9 @@ namespace CalamityMod.Items.Armor.Victide if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { var baseDamage = 7; + if (modPlayer.oldFashioned) + baseDamage = CalamityUtils.CalcOldFashionedDamage(baseDamage); + var minionDamage = (int)player.GetTotalDamage().ApplyTo(baseDamage); var p = Projectile.NewProjectile(source, player.Center, -Vector2.UnitY, ModContent.ProjectileType(), minionDamage, 0f, Main.myPlayer, 0f, 0f); if (Main.projectile.IndexInRange(p)) diff --git a/Items/Armor/Wulfrum/WulfrumFusionCannon.cs b/Items/Armor/Wulfrum/WulfrumFusionCannon.cs index a8fb341f8b..3ee9c43415 100644 --- a/Items/Armor/Wulfrum/WulfrumFusionCannon.cs +++ b/Items/Armor/Wulfrum/WulfrumFusionCannon.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Cooldowns; using CalamityMod.Items.BaseItems; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -79,6 +80,9 @@ namespace CalamityMod.Items.Armor.Wulfrum public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) { velocity = velocity.RotatedByRandom(MathHelper.PiOver4 * 0.1f); + + if (player.Calamity().oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); } public override bool CanUseItem(Player player) diff --git a/Items/Armor/Wulfrum/WulfrumSet.cs b/Items/Armor/Wulfrum/WulfrumSet.cs index 4329df01e5..ba09a085ab 100644 --- a/Items/Armor/Wulfrum/WulfrumSet.cs +++ b/Items/Armor/Wulfrum/WulfrumSet.cs @@ -10,6 +10,7 @@ using CalamityMod.Cooldowns; using Terraria.Audio; using System; using System.Collections.Generic; +using Terraria.Localization; using static Microsoft.Xna.Framework.Input.Keys; using static Terraria.ModLoader.ModContent; @@ -69,7 +70,7 @@ namespace CalamityMod.Items.Armor.Wulfrum private void ActivateSetBonus(Terraria.On_Player.orig_KeyDoubleTap orig, Player player, int keyDir) { - if (keyDir == 0 && HasArmorSet(player) && !player.mount.Active) + if (keyDir == (Main.ReversedUpDownArmorSetBonuses ? 1 : 0) && HasArmorSet(player) && !player.mount.Active) { //Only activate if no cooldown & available scrap. if (player.Calamity().cooldowns.TryGetValue(WulfrumBastion.ID, out CooldownInstance cd)) @@ -84,7 +85,7 @@ namespace CalamityMod.Items.Armor.Wulfrum else if (player.HasItem(ModContent.ItemType())) { player.ConsumeItem(ModContent.ItemType()); - //I Thiiiinnnk there's no need to add mp syncing packets sicne cooldowns get auto synced right. + //I Thiiiinnnk there's no need to add mp syncing packets since cooldowns get auto synced right. player.AddCooldown(WulfrumBastion.ID, BastionCooldown + BastionTime); //Though do i need to sync that or is the player inventory auto synced? DummyCannon.SetDefaults(ItemType()); @@ -228,7 +229,8 @@ namespace CalamityMod.Items.Armor.Wulfrum if (setBonusIndex != -1) { - TooltipLine setBonus1 = new TooltipLine(item.Mod, "CalamityMod:SetBonus1", CalamityUtils.GetTextValueFromModItem("AbilityBrief")); + string dir = Language.GetTextValue(Main.ReversedUpDownArmorSetBonuses ? "Key.UP" : "Key.DOWN"); + TooltipLine setBonus1 = new TooltipLine(item.Mod, "CalamityMod:SetBonus1", CalamityUtils.GetTextFromModItem("AbilityBrief").Format(dir)); setBonus1.OverrideColor = Color.Lerp(new Color(194, 255, 67), new Color(112, 244, 244), 0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 3f)); tooltips.Insert(setBonusIndex + 1, setBonus1); diff --git a/Items/BaseItems/HeldOnlyItem.cs b/Items/BaseItems/HeldOnlyItem.cs index 5acf595f35..80ddb78e85 100644 --- a/Items/BaseItems/HeldOnlyItem.cs +++ b/Items/BaseItems/HeldOnlyItem.cs @@ -22,7 +22,6 @@ namespace CalamityMod.Items.BaseItems Terraria.UI.On_ItemSlot.LeftClick_ItemArray_int_int += LockMouseToSpecialItem; Terraria.UI.On_ItemSlot.Draw_SpriteBatch_ItemArray_int_int_Vector2_Color += DrawSpecial; } - private void DrawSpecial(Terraria.UI.On_ItemSlot.orig_Draw_SpriteBatch_ItemArray_int_int_Vector2_Color orig, SpriteBatch sb, Item[] inv, int context, int slot, Vector2 position, Color color) { if (inv[slot].ModItem is HeldOnlyItem && !(inv[slot].ModItem as HeldOnlyItem).VisibleInUI) diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index cbce4e751d..7d65bb4e10 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -36,6 +36,7 @@ using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.IO; using Terraria.Utilities; +using CalamityMod.Items.Potions.Alcohol; namespace CalamityMod.Items { @@ -272,7 +273,7 @@ namespace CalamityMod.Items // useTime 9 = 0.9 useTime 2 = 0.2 double damageMult = 1.0; if (item.useTime < 10) - damageMult -= (10 - item.useTime) / 10.0; + damageMult -= (10 - item.useTime) / 10D; double newDamage = damage * damageMult; @@ -280,8 +281,11 @@ namespace CalamityMod.Items { if (item.CountsAsClass()) { - double meleeDamage = newDamage * 0.25; - if (meleeDamage >= 1D) + int meleeDamage = (int)(newDamage * 0.25f); + if (modPlayer.oldFashioned) + meleeDamage = CalamityUtils.CalcOldFashionedDamage(meleeDamage); + + if (meleeDamage >= 1) { int projectile = Projectile.NewProjectile(source, position, velocity * 0.5f, ModContent.ProjectileType(), (int)meleeDamage, 0f, player.whoAmI); if (projectile.WithinBounds(Main.maxProjectiles)) @@ -290,8 +294,11 @@ namespace CalamityMod.Items } else if (item.CountsAsClass()) { - double throwingDamage = newDamage * 0.2; - if (throwingDamage >= 1D) + int throwingDamage = (int)(newDamage * 0.2f); + if (modPlayer.oldFashioned) + throwingDamage = CalamityUtils.CalcOldFashionedDamage(throwingDamage); + + if (throwingDamage >= 1) { int projectile = Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), (int)throwingDamage, 0f, player.whoAmI); if (projectile.WithinBounds(Main.maxProjectiles)) @@ -306,8 +313,11 @@ namespace CalamityMod.Items // The projectile is fired inside of the scope's code instead if (type != ModContent.ProjectileType()) { - double rangedDamage = newDamage * 0.15; - if (rangedDamage >= 1D) + int rangedDamage = (int)(newDamage * 0.15f); + if (modPlayer.oldFashioned) + rangedDamage = CalamityUtils.CalcOldFashionedDamage(rangedDamage); + + if (rangedDamage >= 1) { int projectile = Projectile.NewProjectile(source, position, velocity * 1.5f, ModContent.ProjectileType(), (int)rangedDamage, 0f, player.whoAmI); if (projectile.WithinBounds(Main.maxProjectiles)) @@ -317,8 +327,11 @@ namespace CalamityMod.Items } else if (item.CountsAsClass()) { - double magicDamage = newDamage * 0.3; - if (magicDamage >= 1D) + int magicDamage = (int)(newDamage * 0.3f); + if (modPlayer.oldFashioned) + magicDamage = CalamityUtils.CalcOldFashionedDamage(magicDamage); + + if (magicDamage >= 1) { int projectile = Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), (int)magicDamage, 0f, player.whoAmI); if (projectile.WithinBounds(Main.maxProjectiles)) @@ -327,9 +340,13 @@ namespace CalamityMod.Items } else if (item.CountsAsClass() && player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - if (damage >= 1D) + if (damage >= 1) { - int projectile = Projectile.NewProjectile(source, position, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI); + int summonDamage = damage; + if (modPlayer.oldFashioned) + summonDamage = CalamityUtils.CalcOldFashionedDamage(summonDamage); + + int projectile = Projectile.NewProjectile(source, position, Vector2.Zero, ModContent.ProjectileType(), summonDamage, 0f, player.whoAmI); if (projectile.WithinBounds(Main.maxProjectiles)) { Main.projectile[projectile].DamageType = DamageClass.Generic; @@ -348,6 +365,9 @@ namespace CalamityMod.Items { // Bloodflare Mage Bolt: 130%, soft cap starts at 2000 base damage int bloodflareBoltDamage = CalamityUtils.DamageSoftCap(damage * 1.3, 2600); + if (modPlayer.oldFashioned) + bloodflareBoltDamage = CalamityUtils.CalcOldFashionedDamage(bloodflareBoltDamage); + Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), bloodflareBoltDamage, 1f, player.whoAmI); } } @@ -362,6 +382,9 @@ namespace CalamityMod.Items // Bloodflare Ranged Bloodsplosion: 80%, soft cap starts at 150 base damage // This is intentionally extremely low because this effect can be grossly overpowered with sniper rifles and the like. int bloodsplosionDamage = CalamityUtils.DamageSoftCap(damage * 0.8, 120); + if (modPlayer.oldFashioned) + bloodsplosionDamage = CalamityUtils.CalcOldFashionedDamage(bloodsplosionDamage); + Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), bloodsplosionDamage, 2f, player.whoAmI); } } @@ -374,6 +397,8 @@ namespace CalamityMod.Items // Tarragon Mage Leaves: (8-10) x 20%, soft cap starts at 200 base damage int leafAmt = 8 + Main.rand.Next(3); // 8, 9, or 10 int leafDamage = (int)(damage * 0.2); + if (modPlayer.oldFashioned) + leafDamage = CalamityUtils.CalcOldFashionedDamage(leafDamage); for (int l = 0; l < leafAmt; l++) { @@ -398,6 +423,9 @@ namespace CalamityMod.Items if (player.whoAmI == Main.myPlayer) { int ataxiaFlareDamage = (int)(damage * 0.25); + if (modPlayer.oldFashioned) + ataxiaFlareDamage = CalamityUtils.CalcOldFashionedDamage(ataxiaFlareDamage); + Projectile.NewProjectile(source, position, velocity * 1.25f, ModContent.ProjectileType(), ataxiaFlareDamage, 2f, player.whoAmI); } } @@ -411,6 +439,9 @@ namespace CalamityMod.Items { // God Slayer Ranged Shrapnel: 100%, soft cap starts at 800 base damage int shrapnelRoundDamage = CalamityUtils.DamageSoftCap(damage, 800); + if (modPlayer.oldFashioned) + shrapnelRoundDamage = CalamityUtils.CalcOldFashionedDamage(shrapnelRoundDamage); + Projectile.NewProjectile(source, position, velocity * 1.25f, ModContent.ProjectileType(), shrapnelRoundDamage, 2f, player.whoAmI); } } @@ -424,6 +455,9 @@ namespace CalamityMod.Items // Ataxia Rogue Flares: 8 x 50%, soft cap starts at 120 base damage int flareDamage = CalamityUtils.DamageSoftCap(damage * 0.5, 120); + if (modPlayer.oldFashioned) + flareDamage = CalamityUtils.CalcOldFashionedDamage(flareDamage); + if (player.whoAmI == Main.myPlayer) { SoundEngine.PlaySound(SoundID.Item20, player.Center); @@ -450,6 +484,9 @@ namespace CalamityMod.Items { // Victide All-class Seashells: 200%, soft cap starts at 46 base damage int seashellDamage = CalamityUtils.DamageSoftCap(damage * 2, 46); + if (modPlayer.oldFashioned) + seashellDamage = CalamityUtils.CalcOldFashionedDamage(seashellDamage); + Projectile.NewProjectile(source, position, velocity * 1.25f, ModContent.ProjectileType(), seashellDamage, 1f, player.whoAmI); } } @@ -463,6 +500,8 @@ namespace CalamityMod.Items damageMult = 0.35; int newDamage = (int)(damage * 2 * damageMult); + if (modPlayer.oldFashioned) + newDamage = CalamityUtils.CalcOldFashionedDamage(newDamage); if (player.whoAmI == Main.myPlayer) { @@ -946,8 +985,7 @@ namespace CalamityMod.Items if (set == "CrystalAssassin") { - player.setBonus = "Allows the ability to dash\n" + - "10% increased damage and critical strike chance"; + player.setBonus = CalamityUtils.GetTextValue("Vanilla.Armor.SetBonus.CrystalAssassin"); modPlayer.DashID = string.Empty; } else if (set == "SquireTier2") @@ -955,20 +993,19 @@ namespace CalamityMod.Items player.lifeRegen += 3; player.GetDamage() += 0.15f; player.GetCritChance() += 10; - player.setBonus += "\nIncreases your life regeneration\n" + - "15% increased minion damage and 10% increased melee critical strike chance"; + player.setBonus += $"\n{CalamityUtils.GetTextValue("Vanilla.Armor.SetBonus.SquireTier2")}"; } else if (set == "HuntressTier2") { player.GetDamage() += 0.1f; player.GetDamage() += 0.1f; - player.setBonus += "\n10% increased minion and ranged damage"; + player.setBonus += $"\n{CalamityUtils.GetTextValue("Vanilla.Armor.SetBonus.HuntressTier2")}"; } else if (set == "ApprenticeTier2") { player.GetDamage() += 0.05f; player.GetCritChance() += 15; - player.setBonus += "\n5% increased minion damage and 15% increased magic critical strike chance"; + player.setBonus += $"\n{CalamityUtils.GetTextValue("Vanilla.Armor.SetBonus.ApprenticeTier2")}"; } else if (set == "MonkTier3") { @@ -976,34 +1013,31 @@ namespace CalamityMod.Items player.GetAttackSpeed() += 0.1f; player.GetDamage() += 0.1f; player.GetCritChance() += 10; - player.setBonus += "\n10% increased melee damage, melee critical strike chance and melee speed\n" + - "30% increased minion damage"; + player.setBonus += $"\n{CalamityUtils.GetTextValue("Vanilla.Armor.SetBonus.MonkTier3")}"; } else if (set == "SquireTier3") { player.lifeRegen += 6; player.GetDamage() += 0.1f; player.GetCritChance() += 10; - player.setBonus += "\nMassively increased life regeneration\n" + - "10% increased minion damage and melee critical strike chance"; + player.setBonus += $"\n{CalamityUtils.GetTextValue("Vanilla.Armor.SetBonus.SquireTier3")}"; } else if (set == "HuntressTier3") { player.GetDamage() += 0.1f; player.GetDamage() += 0.1f; - player.setBonus += "\n10% increased minion and ranged damage"; + player.setBonus += $"\n{CalamityUtils.GetTextValue("Vanilla.Armor.SetBonus.HuntressTier3")}"; } else if (set == "ApprenticeTier3") { player.GetDamage() += 0.1f; player.GetCritChance() += 15; - player.setBonus += "\n10% increased minion damage and 15% increased magic critical strike chance"; + player.setBonus += $"\n{CalamityUtils.GetTextValue("Vanilla.Armor.SetBonus.ApprenticeTier3")}"; } else if (set == "SpectreHealing") { player.GetDamage() += 0.2f; - player.setBonus = "Reduces Magic damage by 20% and converts it to healing force\n" + - "Magic damage done to enemies heals the player with lowest health"; + player.setBonus = CalamityUtils.GetTextValue("Vanilla.Armor.SetBonus.SpectreHealing"); } else if (set == "SolarFlare") { @@ -1149,24 +1183,40 @@ namespace CalamityMod.Items if (item.type == ItemID.FireGauntlet) { player.GetDamage() += 0.02f; - player.GetAttackSpeed() += 0.02f; } - //Feral Claws line melee speed adjustments + // 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) { - player.GetAttackSpeed() -= 0.02f; + player.GetAttackSpeed() -= 0.12f; // Feral Claws 10% + if (modPlayer.gloveLevel < 1) + modPlayer.gloveLevel = 1; } - - if (item.type == ItemID.PowerGlove) + if (item.type == ItemID.PowerGlove) { - player.GetAttackSpeed() -= 0.02f; + player.GetAttackSpeed() -= 0.12f; // Power Glove 10% + if (modPlayer.gloveLevel < 2) + modPlayer.gloveLevel = 2; } - - if (item.type == ItemID.BerserkerGlove) + if (item.type == ItemID.BerserkerGlove) { - player.GetAttackSpeed() -= 0.12f; + player.GetAttackSpeed() -= 0.12f; // Berserker Glove 0% } + if (item.type == ItemID.MechanicalGlove) + { + player.GetAttackSpeed() -= 0.12f; // Mechanical Glove 12% + if (modPlayer.gloveLevel < 3) + modPlayer.gloveLevel = 3; + } + if (item.type == ItemID.FireGauntlet) + { + player.GetAttackSpeed() -= 0.12f; // Fire Gauntlet 14% + if (modPlayer.gloveLevel < 4) + modPlayer.gloveLevel = 4; + } + if (modPlayer.eGauntlet && modPlayer.gloveLevel < 5) // Elemental Gauntlet 15% + modPlayer.gloveLevel = 5; //Celestial Stone line melee speed removal if (item.type == ItemID.SunStone) @@ -1597,7 +1647,7 @@ namespace CalamityMod.Items public static bool HasEnoughAmmo(Player player, Item item, int ammoConsumed) { - bool flag = false; + bool hasEnoughAmmo = false; bool canShoot = false; for (int i = 54; i < Main.InventorySlotsTotal; i++) @@ -1605,12 +1655,12 @@ namespace CalamityMod.Items if (player.inventory[i].ammo == item.useAmmo && (player.inventory[i].stack >= ammoConsumed || !player.inventory[i].consumable)) { canShoot = true; - flag = true; + hasEnoughAmmo = true; break; } } - if (!flag) + if (!hasEnoughAmmo) { for (int j = 0; j < 54; j++) { @@ -1627,7 +1677,7 @@ namespace CalamityMod.Items public static void ConsumeAdditionalAmmo(Player player, Item item, int ammoConsumed) { Item itemAmmo = new Item(); - bool flag = false; + bool hasEnoughAmmo = false; bool dontConsumeAmmo = false; for (int i = 54; i < Main.InventorySlotsTotal; i++) @@ -1635,12 +1685,12 @@ namespace CalamityMod.Items if (player.inventory[i].ammo == item.useAmmo && (player.inventory[i].stack >= ammoConsumed || !player.inventory[i].consumable)) { itemAmmo = player.inventory[i]; - flag = true; + hasEnoughAmmo = true; break; } } - if (!flag) + if (!hasEnoughAmmo) { for (int j = 0; j < 54; j++) { diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index 50cbb27ae1..d30d1425f6 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -355,9 +355,9 @@ namespace CalamityMod.Items int cost = (int)(item.mana * Main.LocalPlayer.manaCost * 0.5f); EditTooltipByName("UseMana", (line) => line.Text = $"Uses {cost} mana"); } - if (item.healLife > 0 && Main.LocalPlayer.Calamity().healingPotBonus != 1f) + if (item.healLife > 0 && Main.LocalPlayer.Calamity().healingPotionMultiplier != 1f) { - int healAmt = (int)(item.healLife * Main.LocalPlayer.Calamity().healingPotBonus); + int healAmt = (int)(item.healLife * Main.LocalPlayer.Calamity().healingPotionMultiplier); EditTooltipByName("HealLife", (line) => line.Text = $"Restores {healAmt} life"); } #endregion @@ -670,7 +670,7 @@ namespace CalamityMod.Items if (item.type == ItemID.PowerGlove) { - EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("12%", "10%")); + EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("12% increased melee speed", "10% increased melee speed, does not stack with downgrades")); EditTooltipByNum(0, (line) => line.Text += "\n10% increased true melee damage"); } @@ -680,13 +680,19 @@ namespace CalamityMod.Items } if (item.type == ItemID.MechanicalGlove) + { + string extraLine = "\n12% increased melee speed, does not stack with downgrades"; + EditTooltipByNum(1, (line) => line.Text = "12% increased melee damage" + extraLine); + EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("12% increased melee speed", "12% increased melee speed, does not stack with downgrades")); EditTooltipByNum(0, (line) => line.Text += "\n10% increased true melee damage"); + } if (item.type == ItemID.FireGauntlet) { EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("fire damage", "Hellfire")); string extraLine = "\n10% increased true melee damage"; - EditTooltipByNum(1, (line) => line.Text = "14% increased melee damage and speed" + extraLine); + string extraLine2 = "\n14% increased melee speed, does not stack with downgrades" + extraLine; + EditTooltipByNum(1, (line) => line.Text = "14% increased melee damage" + extraLine2); } // On Fire! debuff immunities @@ -699,10 +705,8 @@ namespace CalamityMod.Items if (item.type == ItemID.TerrasparkBoots) EditTooltipByNum(3, (line) => line.Text += "\nImmunity to the On Fire! debuff"); - // IT'S HELLFIRE!!! - if (item.type == ItemID.MagmaStone || item.type == ItemID.LavaSkull || item.type == ItemID.MoltenSkullRose) - EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("fire damage", "Hellfire")); - + // Ozzatron 23NOV2023: Removed tooltip edits for Magma Skull and Molten Skull Rose, as they were invalid after vanilla tooltip changes. + // Yoyo Glove/Bag apply a 0.5x damage multiplier on the second yoyo if (item.type == ItemID.YoyoBag || item.type == ItemID.YoYoGlove) EditTooltipByNum(0, (line) => line.Text += "\nSecondary yoyos will do 50% less damage"); @@ -797,9 +801,9 @@ namespace CalamityMod.Items // Palladium if (item.type == ItemID.PalladiumBreastplate) - EditTooltipByNum(0, (line) => line.Text = $"{PalladiumArmorSetChange.ChestplateDamagePercentageBoost + 3}% increased damage."); + EditTooltipByNum(0, (line) => line.Text = $"{PalladiumArmorSetChange.ChestplateDamagePercentageBoost + 3}% increased damage"); if (item.type == ItemID.PalladiumLeggings) - EditTooltipByNum(0, (line) => line.Text = $"{PalladiumArmorSetChange.LeggingsDamagePercentageBoost + 2}% increased damage."); + EditTooltipByNum(0, (line) => line.Text = $"{PalladiumArmorSetChange.LeggingsDamagePercentageBoost + 2}% increased damage"); // Mythril if (item.type == ItemID.MythrilHood) @@ -1128,6 +1132,64 @@ namespace CalamityMod.Items AddGrappleStats(37.5f, 16f, 24f, 0f); #endregion + #region Herbs and Seeds Tooltips + + void AddHerbTooltips(string text) + { + int materialIndex = 0; + for (int i = 0; i < tooltips.Count; ++i) + if (tooltips[i].Name == "Material") + { + materialIndex = i; + break; + } + tooltips.Insert(materialIndex + 1, new TooltipLine(CalamityMod.Instance, "Tooltip0", text)); + } + + if (item.type == ItemID.Daybloom) + AddHerbTooltips(CalamityUtils.GetTextValue("Vanilla.HerbTooltips.Daybloom")); + if (item.type == ItemID.Moonglow) + AddHerbTooltips(CalamityUtils.GetTextValue("Vanilla.HerbTooltips.Moonglow")); + if (item.type == ItemID.Waterleaf) + AddHerbTooltips(CalamityUtils.GetTextValue("Vanilla.HerbTooltips.Waterleaf")); + if (item.type == ItemID.Blinkroot) + AddHerbTooltips(CalamityUtils.GetTextValue("Vanilla.HerbTooltips.Blinkroot")); + if (item.type == ItemID.Shiverthorn) + AddHerbTooltips(CalamityUtils.GetTextValue("Vanilla.HerbTooltips.Shiverthorn")); + if (item.type == ItemID.Deathweed) + AddHerbTooltips(CalamityUtils.GetTextValue("Vanilla.HerbTooltips.Deathweed")); + if (item.type == ItemID.Fireblossom) + AddHerbTooltips(CalamityUtils.GetTextValue("Vanilla.HerbTooltips.Fireblossom")); + + void AddSeedTooltips(string text) + { + int materialIndex = 0; + for (int i = 0; i < tooltips.Count; ++i) + if (tooltips[i].Name == "Placeable") + { + materialIndex = i; + break; + } + tooltips.Insert(materialIndex + 1, new TooltipLine(CalamityMod.Instance, "Tooltip0", text)); + } + + if (item.type == ItemID.DaybloomSeeds) + AddSeedTooltips(CalamityUtils.GetTextValue("Vanilla.SeedTooltips.Daybloom")); + if (item.type == ItemID.MoonglowSeeds) + AddSeedTooltips(CalamityUtils.GetTextValue("Vanilla.SeedTooltips.Moonglow")); + if (item.type == ItemID.WaterleafSeeds) + AddSeedTooltips(CalamityUtils.GetTextValue("Vanilla.SeedTooltips.Waterleaf")); + if (item.type == ItemID.BlinkrootSeeds) + AddSeedTooltips(CalamityUtils.GetTextValue("Vanilla.SeedTooltips.Blinkroot")); + if (item.type == ItemID.ShiverthornSeeds) + AddSeedTooltips(CalamityUtils.GetTextValue("Vanilla.SeedTooltips.Shiverthorn")); + if (item.type == ItemID.DeathweedSeeds) + AddSeedTooltips(CalamityUtils.GetTextValue("Vanilla.SeedTooltips.Deathweed")); + if (item.type == ItemID.FireblossomSeeds) + AddSeedTooltips(CalamityUtils.GetTextValue("Vanilla.SeedTooltips.Fireblossom")); + + #endregion + // Beyond this point all code only applies to accessories. Skip it all if the item is not an accessory. if (!item.accessory) return; diff --git a/Items/CalamityGlobalItemTweaks.cs b/Items/CalamityGlobalItemTweaks.cs index 858b259970..a89edf5cad 100644 --- a/Items/CalamityGlobalItemTweaks.cs +++ b/Items/CalamityGlobalItemTweaks.cs @@ -67,11 +67,12 @@ namespace CalamityMod.Items { ItemID.ChlorophytePartisan, Do(AutoReuse, UseMeleeSpeed, UseRatio(0.8f), DamageExact(70)) }, { ItemID.ChlorophyteSaber, Do(UseMeleeSpeed, DamageExact(80), UseExact(10)) }, { ItemID.ChristmasTreeSword, Do(AutoReuse, UseTurn, UseMeleeSpeed, DamageExact(80), UseExact(30)) }, - { ItemID.ClingerStaff, Do(DamageExact(118)) }, + { ItemID.ClingerStaff, Do(DamageExact(96)) }, { ItemID.ClockworkAssaultRifle, Do(PointBlank, DamageExact(21)) }, { ItemID.CobaltNaginata, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(90)) }, { ItemID.CobaltRepeater, Do(PointBlank, UseExact(18)) }, { ItemID.CobaltSword, Do(UseTurn, ScaleRatio(1.4f), DamageExact(80)) }, + { ItemID.Code2, Do(AutoReuse, DamageExact(43)) }, { ItemID.CorruptYoyo, Do(AutoReuse, DamageExact(20)) }, // Malaise { ItemID.CrimsonYoyo, Do(AutoReuse, DamageExact(20)) }, // Artery { ItemID.CrystalDart, Do(DamageExact(20)) }, @@ -83,6 +84,7 @@ namespace CalamityMod.Items { ItemID.DaoofPow, Do(DamageExact(160)) }, { ItemID.DarkLance, Do(AutoReuse, TrueMelee, DamageExact(45)) }, { ItemID.DartRifle, Do(PointBlank, DamageExact(58)) }, + { ItemID.DayBreak, Do(DamageExact(125), UseExact(20)) }, { ItemID.DD2BetsyBow, Do(DamageRatio(1.1f)) }, // Aerial Bane's ridiculous multiplier is removed, so this compensates for that { ItemID.DD2SquireBetsySword, Do(UseMeleeSpeed, DamageExact(150)) }, // Flying Dragon { ItemID.DD2SquireDemonSword, Do(DamageExact(110), UseExact(25)) }, // Brand of the Inferno @@ -91,29 +93,31 @@ namespace CalamityMod.Items { ItemID.DemonScythe, Do(AutoReuse, DamageExact(33)) }, { ItemID.DyeTradersScimitar, Do(AutoReuse, UseTurn, DamageExact(24)) }, // Exotic Scimitar { ItemID.ElectrosphereLauncher, Do(DamageRatio(1.1f)) }, - { ItemID.ElfMelter, Do(DamageExact(94), ShootSpeedDelta(+3f)) }, + { ItemID.ElfMelter, Do(ShootSpeedDelta(+5f)) }, { ItemID.EmeraldStaff, Do(DamageExact(27)) }, { ItemID.EmpressBlade, Do(AutoReuse, DamageExact(60), UseExact(20)) }, // Terraprisma { ItemID.EnchantedBoomerang, Do(DamageExact(24)) }, { ItemID.EnchantedSword, Do(UseMeleeSpeed, DamageExact(30), ShootSpeedExact(15f)) }, { ItemID.Excalibur, Do(TrueMelee, ScaleRatio(1.2f), UseRatio(0.8f), DamageExact(125), UseAnimationExact(45)) }, { ItemID.FairyQueenMagicItem, Do(DamageExact(54)) }, // Nightglow + { ItemID.FairyQueenRangedItem, Do(PointBlank, DamageExact(42))}, //Eventide { ItemID.FalconBlade, Do(UseTurn, UseExact(15)) }, // Unsure what to do with Celebration. Should it be treated as a serious weapon or not? Currently not changing it from vanilla. // { ItemID.FireworksLauncher, Do(DamageRatio(2f)) }, // Celebration { ItemID.Flairon, Do(DamageExact(73)) }, { ItemID.Flamarang, Do(DamageExact(43)) }, { ItemID.Flamelash, Do(DamageRatio(1.25f)) }, - { ItemID.Flamethrower, Do(ShootSpeedDelta(+3f)) }, - { ItemID.FlowerofFire, Do(AutoReuse, ManaExact(7), UseRatio(0.88f)) }, // Uses ratios due to remix seed - { ItemID.FlowerofFrost, Do(AutoReuse, ManaExact(7), UseExact(30), DamageExact(70), ShootSpeedExact(14)) }, - { ItemID.FlyingKnife, Do(DamageExact(70)) }, + { ItemID.Flamethrower, Do(DamageExact(21), ShootSpeedDelta(+3f)) }, + { ItemID.FlowerofFire, Do(AutoReuse, ManaExact(7), UseRatio(0.88f), DamageRatio(0.65f)) }, // Uses ratios due to remix seed + { ItemID.FlowerofFrost, Do(AutoReuse, ManaExact(7), UseExact(22), DamageExact(70), ShootSpeedExact(14)) }, + { ItemID.FlyingKnife, Do(DamageExact(53)) }, { ItemID.Frostbrand, Do(UseMeleeSpeed, DamageExact(88)) }, { ItemID.FrostStaff, Do(DamageExact(160), UseExact(37), ShootSpeedExact(20f)) }, // has 1 extra update { ItemID.Gatligator, Do(PointBlank, UseExact(6)) }, { ItemID.GoldenShower, Do(DamageExact(44)) }, { ItemID.GoldShortsword, Do(AutoReuse, TrueMelee, DamageExact(17)) }, { ItemID.GolemFist, Do(DamageExact(150)) }, + { ItemID.Gradient, Do(AutoReuse, DamageExact(39)) }, { ItemID.GreenPhaseblade, Do(AutoReuse, UseTurn, DamageExact(32)) }, { ItemID.GreenPhasesaber, Do(ScaleRatio(1.5f), DamageExact(60)) }, { ItemID.GrenadeLauncher, Do(DamageRatio(1.5f)) }, @@ -126,11 +130,13 @@ namespace CalamityMod.Items { ItemID.IceBoomerang, Do(UseExact(25), ShootSpeedExact(9)) }, { ItemID.IceRod, Do(UseExact(6), DamageExact(30), ShootSpeedExact(20)) }, { ItemID.IceSickle, Do(AutoReuse, UseMeleeSpeed, DamageExact(75), ShootSpeedExact(20f)) }, + { ItemID.ImpStaff, Do(AutoReuse, UseExact(30), DamageExact(25)) }, { ItemID.InfernoFork, Do(DamageRatio(1.2f)) }, { ItemID.InfluxWaver, Do(UseMeleeSpeed, DamageExact(80), UseExact(25)) }, { ItemID.IronShortsword, Do(AutoReuse, TrueMelee, DamageExact(10)) }, { ItemID.JestersArrow, Do(DamageExact(6)) }, { ItemID.Keybrand, Do(UseTurn, ScaleRatio(1.5f)) }, // Uses ratios due to remix seed + { ItemID.Kraken, Do(AutoReuse, DamageExact(85)) }, { ItemID.KOCannon, Do(DamageRatio(2.65f)) }, // Uses ratios due to remix seed { ItemID.LaserRifle, Do(DamageExact(46), UseExact(10), ManaExact(4)) }, { ItemID.LastPrism, Do(DamageExact(57), ManaExact(10)) }, @@ -170,6 +176,7 @@ namespace CalamityMod.Items { ItemID.PearlwoodBow, Do(AutoReuse, PointBlank, DamageRatio(2.31f), UseDelta(+8), ShootSpeedDelta(+3.4f), KnockbackDelta(+1f)) }, { ItemID.PearlwoodSword, Do(UseTurn, DamageRatio(1.5f)) }, { ItemID.PewMaticHorn, Do(DamageExact(24)) }, + { ItemID.Phantasm, Do(PointBlank, DamageExact(48)) }, { ItemID.PhoenixBlaster, Do(AutoReuse, PointBlank, UseExact(18)) }, { ItemID.PiranhaGun, Do(DamageExact(48)) }, { ItemID.PlatinumBow, Do(PointBlank, DamageExact(12)) }, @@ -182,15 +189,20 @@ namespace CalamityMod.Items { ItemID.PurplePhasesaber, Do(ScaleRatio(1.5f), DamageExact(60)) }, { ItemID.RainbowRod, Do(DamageExact(35), ManaExact(15)) }, { ItemID.Rally, Do(AutoReuse, DamageExact(18)) }, + { ItemID.RainbowGun, Do(DamageExact(60), ManaExact(40)) }, + { ItemID.RavenStaff, Do(AutoReuse, UseExact(20), DamageExact(36)) }, + { ItemID.RazorbladeTyphoon, Do(DamageExact(103)) }, { ItemID.Razorpine, Do(DamageExact(40)) }, { ItemID.RedPhaseblade, Do(AutoReuse, UseTurn, DamageExact(32)) }, { ItemID.RedPhasesaber, Do(ScaleRatio(1.5f), DamageExact(60)) }, { ItemID.RedRyder, Do(PointBlank, DamageExact(24)) }, + { ItemID.RedsYoyo, Do(AutoReuse, DamageExact(48)) }, // Red's throw and valkyrie's yoyo are the same weapon { ItemID.RocketIII, Do(DamageRatio(0.75f)) }, { ItemID.RocketIV, Do(DamageRatio(0.75f)) }, { ItemID.Sandgun, Do(PointBlank, DamageExact(22), UseExact(20)) }, { ItemID.SapphireStaff, Do(DamageExact(25)) }, - { ItemID.Seedler, Do(UseMeleeSpeed, DamageRatio(1.5f)) }, + { 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)) }, @@ -224,6 +236,7 @@ namespace CalamityMod.Items // Vanilla damage 190. After fixing iframes so yoyo and shots can hit simultaneously, // Terrarian is extremely overpowered and requires a heavy nerf. { ItemID.Terrarian, Do(AutoReuse, DamageExact(86)) }, + { ItemID.TheEyeOfCthulhu, Do(AutoReuse, DamageExact(90)) }, { ItemID.TheRottedFork, Do(AutoReuse, TrueMelee, DamageExact(20)) }, { ItemID.TheUndertaker, Do(PointBlank, AutoReuse, DamageExact(15)) }, { ItemID.ThunderSpear, Do(AutoReuse, UseMeleeSpeed) }, // Storm Spear @@ -239,14 +252,16 @@ namespace CalamityMod.Items { ItemID.Tsunami, Do(PointBlank, DamageExact(49)) }, { ItemID.TungstenShortsword, Do(AutoReuse, TrueMelee, DamageExact(15)) }, { ItemID.UnholyArrow, Do(DamageExact(11)) }, - { ItemID.UnholyTrident, Do(ManaRatio(0.78f), DamageRatio(1.25f)) }, // Uses ratios due to remix seed + { ItemID.UnholyTrident, Do(ManaRatio(0.78f), DamageRatio(0.91f)) }, // Uses ratios due to remix seed { ItemID.VampireKnives, Do(DamageRatio(1.33f)) }, - { ItemID.VenomStaff, Do(DamageRatio(1.5f)) }, + { ItemID.ValkyrieYoyo, Do(AutoReuse, DamageExact(48)) }, // Red's Throw and Valkyrie Yoyo are the same weapon basically + { ItemID.VenomStaff, Do(DamageRatio(1.25f)) }, { ItemID.WaspGun, Do(UseExact(11)) }, { ItemID.WaterBolt, Do(DamageExact(23)) }, { ItemID.WhitePhaseblade, Do(AutoReuse, UseTurn, DamageExact(32)) }, { ItemID.WhitePhasesaber, Do(ScaleRatio(1.5f), DamageExact(60)) }, { ItemID.WoodenBoomerang, Do(DamageRatio(2f), Value(Item.sellPrice(copper: 20))) }, + { ItemID.Yelets, Do(AutoReuse, DamageExact(53)) }, { ItemID.YellowPhaseblade, Do(AutoReuse, UseTurn, DamageExact(32)) }, { ItemID.YellowPhasesaber, Do(ScaleRatio(1.5f), DamageExact(60)) }, { ItemID.Zenith, Do(DamageExact(210)) }, @@ -417,7 +432,6 @@ namespace CalamityMod.Items { ItemID.DartPistol, pointBlank }, { ItemID.DD2PhoenixBow, pointBlank }, // Phantom Phoenix { ItemID.EbonwoodBow, pointBlank }, - { ItemID.FairyQueenRangedItem, pointBlank }, // Eventide { ItemID.FlintlockPistol, pointBlank }, { ItemID.FlareGun, Do(PointBlank, Value(Item.sellPrice(silver: 10))) }, { ItemID.GoldBow, pointBlank }, @@ -428,12 +442,10 @@ namespace CalamityMod.Items { ItemID.Megashark, pointBlank }, { ItemID.OnyxBlaster, pointBlank }, { ItemID.PalmWoodBow, pointBlank }, - { ItemID.Phantasm, pointBlank }, { ItemID.PulseBow, pointBlank }, { ItemID.QuadBarrelShotgun, pointBlank }, { ItemID.Revolver, Do(PointBlank, AutoReuse) }, { ItemID.RichMahoganyBow, pointBlank }, - { ItemID.SDMG, pointBlank }, { ItemID.ShadewoodBow, pointBlank }, { ItemID.SilverBow, pointBlank }, { ItemID.SniperRifle, pointBlank }, @@ -469,7 +481,6 @@ namespace CalamityMod.Items { ItemID.FireWhip, autoReuse }, // Firecracker { ItemID.FlinxStaff, Do(AutoReuse, UseExact(35)) }, { ItemID.HornetStaff, Do(AutoReuse, UseExact(30)) }, - { ItemID.ImpStaff, Do(AutoReuse, UseExact(30)) }, { ItemID.MaceWhip, autoReuse }, // Morning Star { ItemID.MoonlordTurretStaff, Do(UseExact(15)) }, // Lunar Portal Staff { ItemID.OpticStaff, Do(AutoReuse, UseExact(25)) }, @@ -478,7 +489,6 @@ namespace CalamityMod.Items { ItemID.QueenSpiderStaff, Do(UseExact(25)) }, { ItemID.RainbowCrystalStaff, Do(UseExact(15)) }, { ItemID.RainbowWhip, autoReuse }, // Kaleidoscope - { ItemID.RavenStaff, Do(AutoReuse, UseExact(20)) }, { ItemID.SanguineStaff, Do(AutoReuse, UseExact(25)) }, { ItemID.ScytheWhip, autoReuse }, // Dark Harvest { ItemID.SlimeStaff, Do(AutoReuse, UseExact(30)) }, @@ -504,18 +514,15 @@ namespace CalamityMod.Items { ItemID.CandyCaneSword, Do(AutoReuse, UseTurn) }, { ItemID.Chik, autoReuse }, { ItemID.Code1, autoReuse }, - { ItemID.Code2, autoReuse }, { ItemID.CopperBroadsword, Do(AutoReuse, UseTurn) }, { ItemID.EbonwoodSword, Do(AutoReuse, UseTurn) }, { ItemID.FieryGreatsword, Do(AutoReuse, UseTurn) }, // Volcano { ItemID.FormatC, autoReuse }, { ItemID.GoldBroadsword, Do(AutoReuse, UseTurn) }, - { ItemID.Gradient, autoReuse }, { ItemID.HelFire, autoReuse }, { ItemID.HiveFive, autoReuse }, { ItemID.IronBroadsword, Do(AutoReuse, UseTurn) }, { ItemID.JungleYoyo, autoReuse }, // Amazon - { ItemID.Kraken, autoReuse }, { ItemID.LifeCrystal, autoReuse }, { ItemID.LeadBroadsword, Do(AutoReuse, UseTurn) }, { ItemID.LifeFruit, autoReuse }, @@ -525,25 +532,21 @@ namespace CalamityMod.Items { ItemID.PaperAirplaneA, autoReuse }, { ItemID.PaperAirplaneB, autoReuse }, // White Paper Airplane { ItemID.PlatinumBroadsword, Do(AutoReuse, UseTurn) }, - { ItemID.RedsYoyo, autoReuse }, { ItemID.RichMahoganySword, Do(AutoReuse, UseTurn) }, { ItemID.ShadewoodSword, Do(AutoReuse, UseTurn) }, { ItemID.SilverBroadsword, Do(AutoReuse, UseTurn) }, { ItemID.Starfury, autoReuse }, { ItemID.TentacleSpike, autoReuse }, { ItemID.TinBroadsword, Do(AutoReuse, UseTurn) }, - { ItemID.TheEyeOfCthulhu, autoReuse }, { ItemID.TragicUmbrella, autoReuse }, { ItemID.TungstenBroadsword, Do(AutoReuse, UseTurn) }, { ItemID.Umbrella, autoReuse }, - { ItemID.ValkyrieYoyo, autoReuse }, { ItemID.Valor, autoReuse }, { ItemID.WandofFrosting, autoReuse }, { ItemID.WandofSparking, autoReuse }, { ItemID.WeatherPain, autoReuse }, { ItemID.WoodenSword, Do(AutoReuse, UseTurn) }, { ItemID.WoodYoyo, autoReuse }, - { ItemID.Yelets, autoReuse }, { ItemID.ZapinatorGray, autoReuse }, { ItemID.ZapinatorOrange, autoReuse }, #endregion diff --git a/Items/Fishing/BrimstoneCragCatches/DragoonDrizzlefish.cs b/Items/Fishing/BrimstoneCragCatches/DragoonDrizzlefish.cs index bdbdcf864b..4b57794be1 100644 --- a/Items/Fishing/BrimstoneCragCatches/DragoonDrizzlefish.cs +++ b/Items/Fishing/BrimstoneCragCatches/DragoonDrizzlefish.cs @@ -1,6 +1,10 @@ -using CalamityMod.Projectiles.Ranged; +using System.Collections.Generic; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -10,6 +14,9 @@ namespace CalamityMod.Items.Fishing.BrimstoneCragCatches public class DragoonDrizzlefish : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Fishing"; + + public bool ballShot = true; + public int shotCounter = 0; public override void SetStaticDefaults() { Item.staff[Item.type] = true; //so it doesn't look weird af when holding it @@ -17,7 +24,7 @@ namespace CalamityMod.Items.Fishing.BrimstoneCragCatches public override void SetDefaults() { - Item.damage = 20; + Item.damage = 18; Item.DamageType = DamageClass.Ranged; Item.width = 42; Item.height = 38; @@ -25,31 +32,108 @@ namespace CalamityMod.Items.Fishing.BrimstoneCragCatches Item.useAnimation = 20; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.knockBack = 2f; + Item.knockBack = 1.1f; Item.value = CalamityGlobalItem.Rarity3BuyPrice; Item.rare = ItemRarityID.Orange; Item.UseSound = SoundID.Item20; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 11f; + Item.useAmmo = AmmoID.Gel; // for GFB + } + public override void ModifyTooltips(List list) => list.FindAndReplace("[GFB]", this.GetLocalizedValue(Main.zenithWorld ? "TooltipGFB" : "TooltipNormal")); + public override bool CanUseItem(Player player) + { + if (!Main.zenithWorld) + { + return true; + } + if (player.altFunctionUse == 2) + { + if (Main.zenithWorld) + { + CalamityGlobalItem.HasEnoughAmmo(player, Item, 5); + return true; + } + else + return false; + } + else + return true; } - //so it looks normal when holding - public override Vector2? HoldoutOrigin() => new Vector2(10, 10); + public override Vector2? HoldoutOrigin() => new Vector2(7, 7); + public override bool AltFunctionUse(Player player) => Main.zenithWorld ? true : false; + public override bool CanConsumeAmmo(Item ammo, Player player) + { + if (Main.zenithWorld && player.altFunctionUse == 2 && player.Calamity().dragoonDrizzlefishGelBoost < 6) + return true; + else + return false; + } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - velocity = velocity.RotatedByRandom(MathHelper.ToRadians(10f)); - int shotType = ModContent.ProjectileType(); - if (Main.rand.NextBool()) + if (Main.zenithWorld && player.altFunctionUse == 2) { - shotType = ModContent.ProjectileType(); + //GFB stuff + if (player.Calamity().dragoonDrizzlefishGelBoost < 6) + { + player.Calamity().dragoonDrizzlefishGelBoost++; + SoundStyle roar = Sunskater.DeathSound; + SoundEngine.PlaySound(roar with { Pitch = 0.3f }, player.Center); + SoundEngine.PlaySound(SoundID.Item2 with { Pitch = 0.3f }, player.Center); + CombatText.NewText(player.Hitbox, Color.OrangeRed, ":)"); + for (int i = 0; i <= 11; i++) + { + Vector2 hVelocity = Main.rand.NextVector2Unit(); + hVelocity.X *= 0.66f; + hVelocity *= Main.rand.NextFloat(1f, 2f); + + int heart = Gore.NewGore(player.GetSource_FromThis(), player.Center + Main.rand.NextVector2Circular(14, 14), hVelocity, 331, Main.rand.NextFloat(0.2f, 1.3f)); + Main.gore[heart].sticky = false; + Main.gore[heart].velocity *= 0.4f; + Main.gore[heart].velocity.Y -= 0.7f; + } + } } else { - shotType = ModContent.ProjectileType(); + if (Main.zenithWorld) + { + if (Main.rand.NextBool(25) && player.Calamity().dragoonDrizzlefishGelBoost > 1) + { + SoundStyle roar = Sunskater.DeathSound; + SoundEngine.PlaySound(roar, player.Center); + player.Calamity().dragoonDrizzlefishGelBoost--; + } + if (player.Calamity().dragoonDrizzlefishGelBoost == 1 && Main.rand.NextBool(3)) + { + bool MADFISH = Main.rand.NextBool(4) ? true : false; + CombatText.NewText(player.Hitbox, Color.OrangeRed, MADFISH ? ">:(" : ":("); + SoundStyle roar = Sunskater.DeathSound; + SoundEngine.PlaySound(roar with { Pitch = -0.3f }, player.Center); + if (MADFISH) + player.AddBuff(ModContent.BuffType(), 240, true); + return false; + } + } + + velocity = velocity.RotatedByRandom(MathHelper.ToRadians(5.5f)); + int shotType = ModContent.ProjectileType(); + if (shotCounter < 3) + { + shotType = ModContent.ProjectileType(); + shotCounter++; + } + else + { + shotType = ModContent.ProjectileType(); + shotCounter = 0; + } + Projectile.NewProjectile(source, position, velocity, shotType, damage, knockback, player.whoAmI, 0f, Main.rand.Next(2)); } - Projectile.NewProjectile(source, position, velocity, shotType, damage, knockback, player.whoAmI, 0f, Main.rand.Next(2)); + return false; } } diff --git a/Items/Materials/AshesofCalamity.cs b/Items/Materials/AshesofCalamity.cs index ea39c61987..4edb13ab97 100644 --- a/Items/Materials/AshesofCalamity.cs +++ b/Items/Materials/AshesofCalamity.cs @@ -26,9 +26,9 @@ namespace CalamityMod.Items.Materials } public override void Update(ref float gravity, ref float maxFallSpeed) { - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.25f * num, 0.05f * num, 0.25f * num); + float brightness = (float)Main.rand.Next(90, 111) * 0.01f; + brightness *= Main.essScale; + Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.25f * brightness, 0.05f * brightness, 0.25f * brightness); } } } diff --git a/Items/Materials/BloodOrb.cs b/Items/Materials/BloodOrb.cs index a0619ff5dc..5360c10ad9 100644 --- a/Items/Materials/BloodOrb.cs +++ b/Items/Materials/BloodOrb.cs @@ -1,4 +1,5 @@ using Terraria; +using Terraria.DataStructures; using Terraria.ModLoader; using Terraria.ID; @@ -10,12 +11,13 @@ namespace CalamityMod.Items.Materials public override void SetStaticDefaults() { Item.ResearchUnlockCount = 100; + Main.RegisterItemAnimation(Type, new DrawAnimationVertical(6, 4)); } public override void SetDefaults() { - Item.width = 18; - Item.height = 18; + Item.width = 16; + Item.height = 28; Item.maxStack = 9999; Item.value = Item.sellPrice(silver: 1, copper: 20); Item.rare = ItemRarityID.Blue; @@ -23,9 +25,9 @@ namespace CalamityMod.Items.Materials public override void Update(ref float gravity, ref float maxFallSpeed) { - float num = Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight((int)((Item.position.X + (Item.width / 2)) / 16f), (int)((Item.position.Y + (Item.height / 2)) / 16f), 0.75f * num, 0f, 0f); + float brightness = Main.rand.Next(90, 111) * 0.01f; + brightness *= Main.essScale; + Lighting.AddLight((int)((Item.position.X + (Item.width / 2)) / 16f), (int)((Item.position.Y + (Item.height / 2)) / 16f), 0.75f * brightness, 0f, 0f); } public override void AddRecipes() diff --git a/Items/Materials/BloodOrb.png b/Items/Materials/BloodOrb.png index c1d024d4a7..f78d4d5b4c 100644 Binary files a/Items/Materials/BloodOrb.png and b/Items/Materials/BloodOrb.png differ diff --git a/Items/Materials/DarkPlasma.cs b/Items/Materials/DarkPlasma.cs index c162b90612..ca39e1fd37 100644 --- a/Items/Materials/DarkPlasma.cs +++ b/Items/Materials/DarkPlasma.cs @@ -28,9 +28,9 @@ namespace CalamityMod.Items.Materials } public override void Update(ref float gravity, ref float maxFallSpeed) { - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0f * num, 0.45f * num, 0.7f * num); + float brightness = (float)Main.rand.Next(90, 111) * 0.01f; + brightness *= Main.essScale; + Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0f * brightness, 0.45f * brightness, 0.7f * brightness); } } } diff --git a/Items/Materials/DivineGeode.cs b/Items/Materials/DivineGeode.cs index a94403cae5..2f6acbc13d 100644 --- a/Items/Materials/DivineGeode.cs +++ b/Items/Materials/DivineGeode.cs @@ -24,9 +24,9 @@ namespace CalamityMod.Items.Materials } public override void Update(ref float gravity, ref float maxFallSpeed) { - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.45f * num, 0.3f * num, 0f * num); + float brightness = (float)Main.rand.Next(90, 111) * 0.01f; + brightness *= Main.essScale; + Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.45f * brightness, 0.3f * brightness, 0f * brightness); } } } diff --git a/Items/Materials/GalacticaSingularity.cs b/Items/Materials/GalacticaSingularity.cs index 52631ea105..5dc2bc2dd8 100644 --- a/Items/Materials/GalacticaSingularity.cs +++ b/Items/Materials/GalacticaSingularity.cs @@ -38,9 +38,9 @@ namespace CalamityMod.Items.Materials public override void Update(ref float gravity, ref float maxFallSpeed) { - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 1f * num, 0.3f * num, 0.3f * num); + float brightness = (float)Main.rand.Next(90, 111) * 0.01f; + brightness *= Main.essScale; + Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 1f * brightness, 0.3f * brightness, 0.3f * brightness); } } } diff --git a/Items/Materials/GrandScale.cs b/Items/Materials/GrandScale.cs index 54cc985b0e..555313d41d 100644 --- a/Items/Materials/GrandScale.cs +++ b/Items/Materials/GrandScale.cs @@ -14,8 +14,8 @@ namespace CalamityMod.Items.Materials public override void SetDefaults() { - Item.width = 15; - Item.height = 12; + Item.width = 28; + Item.height = 32; Item.maxStack = 9999; Item.value = Item.buyPrice(0, 4, 50, 0); Item.rare = ItemRarityID.Lime; diff --git a/Items/Materials/GrandScale.png b/Items/Materials/GrandScale.png index d88d52f878..88e26c49ac 100644 Binary files a/Items/Materials/GrandScale.png and b/Items/Materials/GrandScale.png differ diff --git a/Items/Materials/Polterplasm.cs b/Items/Materials/Polterplasm.cs index b976bece02..6a55c5c4f0 100644 --- a/Items/Materials/Polterplasm.cs +++ b/Items/Materials/Polterplasm.cs @@ -14,15 +14,15 @@ namespace CalamityMod.Items.Materials public override void SetStaticDefaults() { Item.ResearchUnlockCount = 25; - Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(5, 5)); + Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(5, 6)); ItemID.Sets.AnimatesAsSoul[Type] = true; ItemID.Sets.SortingPriorityMaterials[Type] = 110; } public override void SetDefaults() { - Item.width = 12; - Item.height = 12; + Item.width = 24; + Item.height = 52; Item.maxStack = 9999; Item.value = Item.sellPrice(gold: 1); Item.rare = ItemRarityID.Purple; diff --git a/Items/Materials/Polterplasm.png b/Items/Materials/Polterplasm.png index e80d69386d..eacff5f4f7 100644 Binary files a/Items/Materials/Polterplasm.png and b/Items/Materials/Polterplasm.png differ diff --git a/Items/Materials/PurifiedGel.cs b/Items/Materials/PurifiedGel.cs index e847110929..5698ffcbac 100644 --- a/Items/Materials/PurifiedGel.cs +++ b/Items/Materials/PurifiedGel.cs @@ -15,8 +15,8 @@ namespace CalamityMod.Items.Materials public override void SetDefaults() { - Item.width = 16; - Item.height = 14; + Item.width = 20; + Item.height = 36; Item.maxStack = 9999; Item.value = Item.buyPrice(0, 2, 50, 0); Item.rare = ItemRarityID.LightRed; diff --git a/Items/Materials/PurifiedGel.png b/Items/Materials/PurifiedGel.png index 37e2e34df9..d470fd7935 100644 Binary files a/Items/Materials/PurifiedGel.png and b/Items/Materials/PurifiedGel.png differ diff --git a/Items/Materials/TwistingNether.cs b/Items/Materials/TwistingNether.cs index e293ea5378..e8b3336095 100644 --- a/Items/Materials/TwistingNether.cs +++ b/Items/Materials/TwistingNether.cs @@ -26,9 +26,9 @@ namespace CalamityMod.Items.Materials } public override void Update(ref float gravity, ref float maxFallSpeed) { - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.5f * num, 0.1f * num, 0.7f * num); + float brightness = (float)Main.rand.Next(90, 111) * 0.01f; + brightness *= Main.essScale; + Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.5f * brightness, 0.1f * brightness, 0.7f * brightness); } } } diff --git a/Items/Materials/UnholyCore.cs b/Items/Materials/UnholyCore.cs index 34b8c96da5..4962d54429 100644 --- a/Items/Materials/UnholyCore.cs +++ b/Items/Materials/UnholyCore.cs @@ -16,8 +16,8 @@ namespace CalamityMod.Items.Materials public override void SetDefaults() { - Item.width = 15; - Item.height = 12; + Item.width = 26; + Item.height = 46; Item.maxStack = 9999; Item.value = Item.sellPrice(silver: 80); Item.rare = ItemRarityID.Pink; diff --git a/Items/Materials/UnholyCore.png b/Items/Materials/UnholyCore.png index d13404b0e2..a69a956e27 100644 Binary files a/Items/Materials/UnholyCore.png and b/Items/Materials/UnholyCore.png differ diff --git a/Items/Materials/UnholyEssence.cs b/Items/Materials/UnholyEssence.cs index 1e1d21a7f2..217be5e725 100644 --- a/Items/Materials/UnholyEssence.cs +++ b/Items/Materials/UnholyEssence.cs @@ -27,9 +27,9 @@ namespace CalamityMod.Items.Materials } public override void Update(ref float gravity, ref float maxFallSpeed) { - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.45f * num, 0.3f * num, 0f * num); + float brightness = (float)Main.rand.Next(90, 111) * 0.01f; + brightness *= Main.essScale; + Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.45f * brightness, 0.3f * brightness, 0f * brightness); } } } diff --git a/Items/Materials/WulfrumMetalScrap.cs b/Items/Materials/WulfrumMetalScrap.cs index 0cd885b9fe..5752684df2 100644 --- a/Items/Materials/WulfrumMetalScrap.cs +++ b/Items/Materials/WulfrumMetalScrap.cs @@ -68,6 +68,7 @@ namespace CalamityMod.Items.Materials } public override void Load() => Terraria.On_Item.CanFillEmptyAmmoSlot += AvoidDefaultingToAmmoSlot; + private bool AvoidDefaultingToAmmoSlot(Terraria.On_Item.orig_CanFillEmptyAmmoSlot orig, Item self) { if (self.type == Type) diff --git a/Items/Materials/YharonSoulFragment.cs b/Items/Materials/YharonSoulFragment.cs index bf450c0800..f2b986749b 100644 --- a/Items/Materials/YharonSoulFragment.cs +++ b/Items/Materials/YharonSoulFragment.cs @@ -18,9 +18,9 @@ namespace CalamityMod.Items.Materials public override void Update(ref float gravity, ref float maxFallSpeed) { - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.5f * num, 0.3f * num, 0.05f * num); + float brightness = (float)Main.rand.Next(90, 111) * 0.01f; + brightness *= Main.essScale; + Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.5f * brightness, 0.3f * brightness, 0.05f * brightness); } public override void SetDefaults() diff --git a/Items/Mounts/RimehoundMount.cs b/Items/Mounts/RimehoundMount.cs index f03f050846..6d7bc3e580 100644 --- a/Items/Mounts/RimehoundMount.cs +++ b/Items/Mounts/RimehoundMount.cs @@ -64,9 +64,9 @@ namespace CalamityMod.Items.Mounts public override bool UpdateFrame(Player mountedPlayer, int state, Vector2 velocity) { bool speed = Math.Abs(velocity.X) > mountedPlayer.mount.RunSpeed / 2f; - float num10 = (float)Math.Sign(mountedPlayer.velocity.X); - float num11 = 12f; - float num12 = 40f; + float direction = (float)Math.Sign(mountedPlayer.velocity.X); + float dustYOffset = 12f; + float dustXOffset = 40f; if (!speed) { mountedPlayer.basiliskCharge = 0f; @@ -92,19 +92,19 @@ namespace CalamityMod.Items.Mounts } if (mountedPlayer.cMount == 0) { - mountedPlayer.position += new Vector2(num10 * 24f, 0f); + mountedPlayer.position += new Vector2(direction * 24f, 0f); mountedPlayer.FloorVisuals(true); - mountedPlayer.position -= new Vector2(num10 * 24f, 0f); + mountedPlayer.position -= new Vector2(direction * 24f, 0f); } } - if (num10 == (float)mountedPlayer.direction) + if (direction == (float)mountedPlayer.direction) { for (int j = 0; j < (int)(3f * mountedPlayer.basiliskCharge); j++) { Dust dust = Main.dust[Dust.NewDust(mountedPlayer.BottomLeft, mountedPlayer.width, 6, 67, 0f, 0f, 0, default, 1f)]; - Vector2 value2 = mountedPlayer.Center + new Vector2(num10 * num12, num11); - dust.position = mountedPlayer.Center + new Vector2(num10 * (num12 - 2f), num11 - 6f + Main.rand.NextFloat() * 12f); - dust.velocity = (dust.position - value2).SafeNormalize(Vector2.Zero) * (3.5f + Main.rand.NextFloat() * 0.5f); + Vector2 dustVel = mountedPlayer.Center + new Vector2(direction * dustXOffset, dustYOffset); + dust.position = mountedPlayer.Center + new Vector2(direction * (dustXOffset - 2f), dustYOffset - 6f + Main.rand.NextFloat() * 12f); + dust.velocity = (dust.position - dustVel).SafeNormalize(Vector2.Zero) * (3.5f + Main.rand.NextFloat() * 0.5f); if (dust.velocity.Y < 0f) { Dust expr_808_cp_0_cp_0 = dust; diff --git a/Items/Placeables/Banners/ArmoredDiggerBanner.cs b/Items/Placeables/Banners/ArmoredDiggerBanner.cs index e1b3d78252..b42b229429 100644 --- a/Items/Placeables/Banners/ArmoredDiggerBanner.cs +++ b/Items/Placeables/Banners/ArmoredDiggerBanner.cs @@ -3,5 +3,6 @@ namespace CalamityMod.Items.Placeables.Banners public class ArmoredDiggerBanner : BaseBanner { public override int BannerTileStyle => 77; + public override int BannerKillRequirement => 25; } } diff --git a/Items/Placeables/Banners/AstralSlimeBanner.png b/Items/Placeables/Banners/AstralSlimeBanner.png index f0b29d9d7e..eb3e963b44 100644 Binary files a/Items/Placeables/Banners/AstralSlimeBanner.png and b/Items/Placeables/Banners/AstralSlimeBanner.png differ diff --git a/Items/Placeables/Banners/ChaoticPufferBanner.png b/Items/Placeables/Banners/ChaoticPufferBanner.png index a70e888557..ba025e7e53 100644 Binary files a/Items/Placeables/Banners/ChaoticPufferBanner.png and b/Items/Placeables/Banners/ChaoticPufferBanner.png differ diff --git a/Items/Placeables/Banners/CloudElementalBanner.cs b/Items/Placeables/Banners/CloudElementalBanner.cs index 38fbab9200..5e3d31df33 100644 --- a/Items/Placeables/Banners/CloudElementalBanner.cs +++ b/Items/Placeables/Banners/CloudElementalBanner.cs @@ -3,5 +3,6 @@ namespace CalamityMod.Items.Placeables.Banners public class CloudElementalBanner : BaseBanner { public override int BannerTileStyle => 58; + public override int BannerKillRequirement => 25; } } diff --git a/Items/Placeables/Banners/CnidrionBanner.cs b/Items/Placeables/Banners/CnidrionBanner.cs index 7839ccaf2b..bcae4f4e2b 100644 --- a/Items/Placeables/Banners/CnidrionBanner.cs +++ b/Items/Placeables/Banners/CnidrionBanner.cs @@ -3,5 +3,6 @@ namespace CalamityMod.Items.Placeables.Banners public class CnidrionBanner : BaseBanner { public override int BannerTileStyle => 63; + public override int BannerKillRequirement => 25; } } diff --git a/Items/Placeables/Banners/ColossalSquidBanner.cs b/Items/Placeables/Banners/ColossalSquidBanner.cs index f421fc2405..f87154aa5b 100644 --- a/Items/Placeables/Banners/ColossalSquidBanner.cs +++ b/Items/Placeables/Banners/ColossalSquidBanner.cs @@ -3,5 +3,6 @@ namespace CalamityMod.Items.Placeables.Banners public class ColossalSquidBanner : BaseBanner { public override int BannerTileStyle => 23; + public override int BannerKillRequirement => 10; } } diff --git a/Items/Placeables/Banners/EarthElementalBanner.cs b/Items/Placeables/Banners/EarthElementalBanner.cs index 6e6f0a2ed8..5be6e71eb5 100644 --- a/Items/Placeables/Banners/EarthElementalBanner.cs +++ b/Items/Placeables/Banners/EarthElementalBanner.cs @@ -3,5 +3,6 @@ namespace CalamityMod.Items.Placeables.Banners public class EarthElementalBanner : BaseBanner { public override int BannerTileStyle => 76; + public override int BannerKillRequirement => 25; } } diff --git a/Items/Placeables/Banners/EbonianBlightSlimeBanner.png b/Items/Placeables/Banners/EbonianBlightSlimeBanner.png index 4c69e8c99b..75628235b1 100644 Binary files a/Items/Placeables/Banners/EbonianBlightSlimeBanner.png and b/Items/Placeables/Banners/EbonianBlightSlimeBanner.png differ diff --git a/Items/Placeables/Banners/EidolonWyrmJuvenileBanner.cs b/Items/Placeables/Banners/EidolonWyrmJuvenileBanner.cs index a78e7c5f3d..20d5216297 100644 --- a/Items/Placeables/Banners/EidolonWyrmJuvenileBanner.cs +++ b/Items/Placeables/Banners/EidolonWyrmJuvenileBanner.cs @@ -3,5 +3,6 @@ namespace CalamityMod.Items.Placeables.Banners public class EidolonWyrmJuvenileBanner : BaseBanner { public override int BannerTileStyle => 27; + public override int BannerKillRequirement => 10; } } diff --git a/Items/Placeables/Banners/IceClasperBanner.cs b/Items/Placeables/Banners/IceClasperBanner.cs index 7311773a7c..397b3a748f 100644 --- a/Items/Placeables/Banners/IceClasperBanner.cs +++ b/Items/Placeables/Banners/IceClasperBanner.cs @@ -3,5 +3,6 @@ namespace CalamityMod.Items.Placeables.Banners public class IceClasperBanner : BaseBanner { public override int BannerTileStyle => 61; + public override int BannerKillRequirement => 25; } } diff --git a/Items/Placeables/Banners/ReaperSharkBanner.cs b/Items/Placeables/Banners/ReaperSharkBanner.cs index f8b6c16554..ff8163cfec 100644 --- a/Items/Placeables/Banners/ReaperSharkBanner.cs +++ b/Items/Placeables/Banners/ReaperSharkBanner.cs @@ -3,5 +3,6 @@ namespace CalamityMod.Items.Placeables.Banners public class ReaperSharkBanner : BaseBanner { public override int BannerTileStyle => 96; + public override int BannerKillRequirement => 10; } } diff --git a/Items/Placeables/Banners/RimehoundBanner.png b/Items/Placeables/Banners/RimehoundBanner.png index 5c1a18f578..2e079be130 100644 Binary files a/Items/Placeables/Banners/RimehoundBanner.png and b/Items/Placeables/Banners/RimehoundBanner.png differ diff --git a/Items/Placeables/Banners/ViperfishBanner.png b/Items/Placeables/Banners/ViperfishBanner.png index e247f7fc38..2bebb599c9 100644 Binary files a/Items/Placeables/Banners/ViperfishBanner.png and b/Items/Placeables/Banners/ViperfishBanner.png differ diff --git a/Items/Placeables/BaseTiles/BaseBanner.cs b/Items/Placeables/BaseTiles/BaseBanner.cs index eee06fb57c..33e9def6c3 100644 --- a/Items/Placeables/BaseTiles/BaseBanner.cs +++ b/Items/Placeables/BaseTiles/BaseBanner.cs @@ -12,6 +12,7 @@ namespace CalamityMod.Items.Placeables // We may decide to change this sooner or later. But for now, the only essential value to override is style for generic enemy banners. public virtual int BannerTileID => ModContent.TileType(); public virtual int BannerTileStyle => 0; + public virtual int BannerKillRequirement => ItemID.Sets.DefaultKillsForBannerNeeded; // Associated Modded NPC public virtual int BonusNPCID => MonsterBanner.GetBannerNPC(BannerTileStyle); @@ -22,6 +23,7 @@ namespace CalamityMod.Items.Placeables public override LocalizedText DisplayName => CalamityUtils.GetText($"{LocalizationCategory}.FormattedBannerName").WithFormatArgs(NPCName.ToString()); public override LocalizedText Tooltip => CalamityUtils.GetText($"{LocalizationCategory}.FormattedBannerTooltip").WithFormatArgs(NPCName.ToString()); + public override void SetStaticDefaults() => ItemID.Sets.KillsToBanner[Type] = BannerKillRequirement; public override void SetDefaults() { Item.DefaultToPlaceableTile(BannerTileID, BannerTileStyle); diff --git a/Items/Placeables/DraedonStructures/SecurityChest.cs b/Items/Placeables/DraedonStructures/SecurityChest.cs index e0a2f3a6a1..188c8816b4 100644 --- a/Items/Placeables/DraedonStructures/SecurityChest.cs +++ b/Items/Placeables/DraedonStructures/SecurityChest.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Placeables.DraedonStructures public override void SetDefaults() { Item.width = 32; - Item.height = 26; + Item.height = 28; Item.maxStack = 9999; Item.useTurn = true; Item.autoReuse = true; diff --git a/Items/Placeables/DraedonStructures/SecurityChest.png b/Items/Placeables/DraedonStructures/SecurityChest.png index 43a639bd2f..bd2a587549 100644 Binary files a/Items/Placeables/DraedonStructures/SecurityChest.png and b/Items/Placeables/DraedonStructures/SecurityChest.png differ diff --git a/Items/Placeables/Furniture/AbyssTreasureChest.cs b/Items/Placeables/Furniture/AbyssTreasureChest.cs index 1a2d7f22a7..d6b6a6191a 100644 --- a/Items/Placeables/Furniture/AbyssTreasureChest.cs +++ b/Items/Placeables/Furniture/AbyssTreasureChest.cs @@ -10,8 +10,8 @@ namespace CalamityMod.Items.Placeables.Furniture public new string LocalizationCategory => "Items.Placeables"; public override void SetDefaults() { - Item.width = 26; - Item.height = 22; + Item.width = 32; + Item.height = 26; Item.maxStack = 9999; Item.useTurn = true; Item.autoReuse = true; diff --git a/Items/Placeables/Furniture/AbyssTreasureChest.png b/Items/Placeables/Furniture/AbyssTreasureChest.png index 2998dd9962..dc831b93a2 100644 Binary files a/Items/Placeables/Furniture/AbyssTreasureChest.png and b/Items/Placeables/Furniture/AbyssTreasureChest.png differ diff --git a/Items/Placeables/Furniture/CraftingStations/AncientAltar.cs b/Items/Placeables/Furniture/CraftingStations/AncientAltar.cs index d042161323..1bb10b81a0 100644 --- a/Items/Placeables/Furniture/CraftingStations/AncientAltar.cs +++ b/Items/Placeables/Furniture/CraftingStations/AncientAltar.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Items.Placeables.Furniture.CraftingStations public override void SetDefaults() { Item.width = 26; - Item.height = 26; + Item.height = 28; Item.maxStack = 9999; Item.useTurn = true; Item.autoReuse = true; diff --git a/Items/Placeables/Furniture/CraftingStations/AncientAltar.png b/Items/Placeables/Furniture/CraftingStations/AncientAltar.png index 7b629db093..1ee432c0a8 100644 Binary files a/Items/Placeables/Furniture/CraftingStations/AncientAltar.png and b/Items/Placeables/Furniture/CraftingStations/AncientAltar.png differ diff --git a/Items/Placeables/Furniture/CraftingStations/AshenAltar.cs b/Items/Placeables/Furniture/CraftingStations/AshenAltar.cs index 7f398b4025..a09bb66da5 100644 --- a/Items/Placeables/Furniture/CraftingStations/AshenAltar.cs +++ b/Items/Placeables/Furniture/CraftingStations/AshenAltar.cs @@ -9,8 +9,8 @@ namespace CalamityMod.Items.Placeables.Furniture.CraftingStations public new string LocalizationCategory => "Items.Placeables"; public override void SetDefaults() { - Item.width = 26; - Item.height = 26; + Item.width = 30; + Item.height = 28; Item.maxStack = 9999; Item.useTurn = true; Item.autoReuse = true; diff --git a/Items/Placeables/Furniture/CraftingStations/AshenAltar.png b/Items/Placeables/Furniture/CraftingStations/AshenAltar.png index 76cb7064a7..4221686c9d 100644 Binary files a/Items/Placeables/Furniture/CraftingStations/AshenAltar.png and b/Items/Placeables/Furniture/CraftingStations/AshenAltar.png differ diff --git a/Items/Placeables/Furniture/CraftingStations/EutrophicShelf.cs b/Items/Placeables/Furniture/CraftingStations/EutrophicShelf.cs index 3ea29c0e85..6331ae04f9 100644 --- a/Items/Placeables/Furniture/CraftingStations/EutrophicShelf.cs +++ b/Items/Placeables/Furniture/CraftingStations/EutrophicShelf.cs @@ -10,8 +10,8 @@ namespace CalamityMod.Items.Placeables.Furniture.CraftingStations public new string LocalizationCategory => "Items.Placeables"; public override void SetDefaults() { - Item.width = 28; - Item.height = 20; + Item.width = 30; + Item.height = 26; Item.maxStack = 9999; Item.useTurn = true; Item.autoReuse = true; diff --git a/Items/Placeables/Furniture/CraftingStations/EutrophicShelf.png b/Items/Placeables/Furniture/CraftingStations/EutrophicShelf.png index 698c2ce903..4d852a8e44 100644 Binary files a/Items/Placeables/Furniture/CraftingStations/EutrophicShelf.png and b/Items/Placeables/Furniture/CraftingStations/EutrophicShelf.png differ diff --git a/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs b/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs index 6b86d860fd..7fbec72628 100644 --- a/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs +++ b/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs @@ -61,14 +61,17 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings { "Fabsol, the mod's founder and owner", // Fabsol gets a line to himself "Altix", + "Angel", "apotofkoolaid", "AquaSG", "Atalya", "Ben-TK", "Cei", - "CongratsIsTrash", + "CongratsIsTrash", "Cooper", + "CosmaticMango", "CrabBar", + "Dia", "Done", "DylanDoe21", "Fluffi", @@ -79,8 +82,8 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings "LordMetarex", "Memes", "Mercutio 'Merkalto' Takle", - "Mishiro Usui", - "Moonburn", + "Mishiro Usui", + "Moonburn", "Mr.Small", "nalyddd", "Nycro", diff --git a/Items/Placeables/Furniture/ResilientCandle.cs b/Items/Placeables/Furniture/ResilientCandle.cs index f490abe505..87c79ac75d 100644 --- a/Items/Placeables/Furniture/ResilientCandle.cs +++ b/Items/Placeables/Furniture/ResilientCandle.cs @@ -10,8 +10,8 @@ namespace CalamityMod.Items.Placeables.Furniture public new string LocalizationCategory => "Items.Placeables"; public override void SetDefaults() { - Item.width = 28; - Item.height = 40; + Item.width = 26; + Item.height = 34; Item.maxStack = 9999; Item.useTurn = true; Item.autoReuse = true; diff --git a/Items/Placeables/Furniture/ResilientCandle.png b/Items/Placeables/Furniture/ResilientCandle.png index d05ce51406..29c5480f8c 100644 Binary files a/Items/Placeables/Furniture/ResilientCandle.png and b/Items/Placeables/Furniture/ResilientCandle.png differ diff --git a/Items/Placeables/Furniture/SpitefulCandle.cs b/Items/Placeables/Furniture/SpitefulCandle.cs index 57568ede21..cef61b3d9b 100644 --- a/Items/Placeables/Furniture/SpitefulCandle.cs +++ b/Items/Placeables/Furniture/SpitefulCandle.cs @@ -10,8 +10,8 @@ namespace CalamityMod.Items.Placeables.Furniture public new string LocalizationCategory => "Items.Placeables"; public override void SetDefaults() { - Item.width = 28; - Item.height = 40; + Item.width = 26; + Item.height = 42; Item.maxStack = 9999; Item.useTurn = true; Item.autoReuse = true; diff --git a/Items/Placeables/Furniture/SpitefulCandle.png b/Items/Placeables/Furniture/SpitefulCandle.png index 2c512cef6c..48403fea34 100644 Binary files a/Items/Placeables/Furniture/SpitefulCandle.png and b/Items/Placeables/Furniture/SpitefulCandle.png differ diff --git a/Items/Placeables/Furniture/VigorousCandle.cs b/Items/Placeables/Furniture/VigorousCandle.cs index 83a994bcf7..f5457c0f4a 100644 --- a/Items/Placeables/Furniture/VigorousCandle.cs +++ b/Items/Placeables/Furniture/VigorousCandle.cs @@ -10,8 +10,8 @@ namespace CalamityMod.Items.Placeables.Furniture public new string LocalizationCategory => "Items.Placeables"; public override void SetDefaults() { - Item.width = 28; - Item.height = 40; + Item.width = 26; + Item.height = 38; Item.maxStack = 9999; Item.useTurn = true; Item.autoReuse = true; diff --git a/Items/Placeables/Furniture/VigorousCandle.png b/Items/Placeables/Furniture/VigorousCandle.png index fb18c15f40..ca1f8a3523 100644 Binary files a/Items/Placeables/Furniture/VigorousCandle.png and b/Items/Placeables/Furniture/VigorousCandle.png differ diff --git a/Items/Placeables/Furniture/WeightlessCandle.cs b/Items/Placeables/Furniture/WeightlessCandle.cs index 437f6f7bbc..76d6f8db0c 100644 --- a/Items/Placeables/Furniture/WeightlessCandle.cs +++ b/Items/Placeables/Furniture/WeightlessCandle.cs @@ -10,8 +10,8 @@ namespace CalamityMod.Items.Placeables.Furniture public new string LocalizationCategory => "Items.Placeables"; public override void SetDefaults() { - Item.width = 28; - Item.height = 40; + Item.width = 26; + Item.height = 36; Item.maxStack = 9999; Item.useTurn = true; Item.autoReuse = true; diff --git a/Items/Placeables/Furniture/WeightlessCandle.png b/Items/Placeables/Furniture/WeightlessCandle.png index c0168bcada..bf005cfb95 100644 Binary files a/Items/Placeables/Furniture/WeightlessCandle.png and b/Items/Placeables/Furniture/WeightlessCandle.png differ diff --git a/Items/Placeables/FurnitureAbyss/SmoothAbyssGravelPlatform.cs b/Items/Placeables/FurnitureAbyss/SmoothAbyssGravelPlatform.cs index 97fe389b13..d8c7cb36d2 100644 --- a/Items/Placeables/FurnitureAbyss/SmoothAbyssGravelPlatform.cs +++ b/Items/Placeables/FurnitureAbyss/SmoothAbyssGravelPlatform.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Items.Placeables.FurnitureAbyss public override void SetDefaults() { - Item.width = 8; - Item.height = 10; + Item.width = 24; + Item.height = 14; Item.maxStack = 9999; Item.useTurn = true; Item.autoReuse = true; diff --git a/Items/Placeables/FurnitureAbyss/SmoothAbyssGravelPlatform.png b/Items/Placeables/FurnitureAbyss/SmoothAbyssGravelPlatform.png index 5399f388c3..7a3152f290 100644 Binary files a/Items/Placeables/FurnitureAbyss/SmoothAbyssGravelPlatform.png and b/Items/Placeables/FurnitureAbyss/SmoothAbyssGravelPlatform.png differ diff --git a/Items/Placeables/FurnitureAncient/AncientBathtub.png b/Items/Placeables/FurnitureAncient/AncientBathtub.png index 218b48d7a6..866c0e80ab 100644 Binary files a/Items/Placeables/FurnitureAncient/AncientBathtub.png and b/Items/Placeables/FurnitureAncient/AncientBathtub.png differ diff --git a/Items/Placeables/FurnitureAncient/AncientBed.png b/Items/Placeables/FurnitureAncient/AncientBed.png index a3f0c270cd..a18adabc0f 100644 Binary files a/Items/Placeables/FurnitureAncient/AncientBed.png and b/Items/Placeables/FurnitureAncient/AncientBed.png differ diff --git a/Items/Placeables/FurnitureAncient/AncientBookcase.png b/Items/Placeables/FurnitureAncient/AncientBookcase.png index ebcc4e7b67..4a197acec5 100644 Binary files a/Items/Placeables/FurnitureAncient/AncientBookcase.png and b/Items/Placeables/FurnitureAncient/AncientBookcase.png differ diff --git a/Items/Placeables/FurnitureAncient/AncientChair.png b/Items/Placeables/FurnitureAncient/AncientChair.png index 24a548a067..932d96267b 100644 Binary files a/Items/Placeables/FurnitureAncient/AncientChair.png and b/Items/Placeables/FurnitureAncient/AncientChair.png differ diff --git a/Items/Placeables/FurnitureAncient/AncientChandelier.png b/Items/Placeables/FurnitureAncient/AncientChandelier.png index 5022594757..244bf1df06 100644 Binary files a/Items/Placeables/FurnitureAncient/AncientChandelier.png and b/Items/Placeables/FurnitureAncient/AncientChandelier.png differ diff --git a/Items/Placeables/FurnitureAncient/AncientDoor.png b/Items/Placeables/FurnitureAncient/AncientDoor.png index a0c68e1120..366e553c5b 100644 Binary files a/Items/Placeables/FurnitureAncient/AncientDoor.png and b/Items/Placeables/FurnitureAncient/AncientDoor.png differ diff --git a/Items/Placeables/FurnitureAncient/AncientLamp.png b/Items/Placeables/FurnitureAncient/AncientLamp.png index 0f3e6cb3bb..6d933bc767 100644 Binary files a/Items/Placeables/FurnitureAncient/AncientLamp.png and b/Items/Placeables/FurnitureAncient/AncientLamp.png differ diff --git a/Items/Placeables/FurnitureAncient/AncientLantern.png b/Items/Placeables/FurnitureAncient/AncientLantern.png index 19ca3c65e4..9d979d8758 100644 Binary files a/Items/Placeables/FurnitureAncient/AncientLantern.png and b/Items/Placeables/FurnitureAncient/AncientLantern.png differ diff --git a/Items/Placeables/FurnitureAncient/AncientPipeOrgan.png b/Items/Placeables/FurnitureAncient/AncientPipeOrgan.png index c5ef3c39b7..38ed47b17c 100644 Binary files a/Items/Placeables/FurnitureAncient/AncientPipeOrgan.png and b/Items/Placeables/FurnitureAncient/AncientPipeOrgan.png differ diff --git a/Items/Placeables/FurnitureAncient/AncientSink.png b/Items/Placeables/FurnitureAncient/AncientSink.png index bc54cb6146..3cf8ae23d7 100644 Binary files a/Items/Placeables/FurnitureAncient/AncientSink.png and b/Items/Placeables/FurnitureAncient/AncientSink.png differ diff --git a/Items/Placeables/FurnitureAncient/AncientSofa.png b/Items/Placeables/FurnitureAncient/AncientSofa.png index 3d596b65e9..38e7b5dcdd 100644 Binary files a/Items/Placeables/FurnitureAncient/AncientSofa.png and b/Items/Placeables/FurnitureAncient/AncientSofa.png differ diff --git a/Items/Placeables/FurnitureAncient/AncientTable.png b/Items/Placeables/FurnitureAncient/AncientTable.png index 12e287f60c..439143f957 100644 Binary files a/Items/Placeables/FurnitureAncient/AncientTable.png and b/Items/Placeables/FurnitureAncient/AncientTable.png differ diff --git a/Items/Placeables/FurnitureAshen/AshenBathtub.png b/Items/Placeables/FurnitureAshen/AshenBathtub.png index 98f272a89a..9e975ce04a 100644 Binary files a/Items/Placeables/FurnitureAshen/AshenBathtub.png and b/Items/Placeables/FurnitureAshen/AshenBathtub.png differ diff --git a/Items/Placeables/FurnitureAshen/AshenBed.png b/Items/Placeables/FurnitureAshen/AshenBed.png index 632783e60a..459b633343 100644 Binary files a/Items/Placeables/FurnitureAshen/AshenBed.png and b/Items/Placeables/FurnitureAshen/AshenBed.png differ diff --git a/Items/Placeables/FurnitureAshen/AshenCandelabra.png b/Items/Placeables/FurnitureAshen/AshenCandelabra.png index 6e5a098472..bfbb78efad 100644 Binary files a/Items/Placeables/FurnitureAshen/AshenCandelabra.png and b/Items/Placeables/FurnitureAshen/AshenCandelabra.png differ diff --git a/Items/Placeables/FurnitureAshen/AshenCandle.cs b/Items/Placeables/FurnitureAshen/AshenCandle.cs index a37ccc6dd2..cb77030cb3 100644 --- a/Items/Placeables/FurnitureAshen/AshenCandle.cs +++ b/Items/Placeables/FurnitureAshen/AshenCandle.cs @@ -9,8 +9,8 @@ namespace CalamityMod.Items.Placeables.FurnitureAshen public new string LocalizationCategory => "Items.Placeables"; public override void SetDefaults() { - Item.width = 26; - Item.height = 26; + Item.width = 16; + Item.height = 20; Item.maxStack = 9999; Item.useTurn = true; Item.autoReuse = true; diff --git a/Items/Placeables/FurnitureAshen/AshenCandle.png b/Items/Placeables/FurnitureAshen/AshenCandle.png index 4605a30a26..acb8e5f5ca 100644 Binary files a/Items/Placeables/FurnitureAshen/AshenCandle.png and b/Items/Placeables/FurnitureAshen/AshenCandle.png differ diff --git a/Items/Placeables/FurnitureAshen/AshenChair.png b/Items/Placeables/FurnitureAshen/AshenChair.png index 7772a4c575..b5790f15c0 100644 Binary files a/Items/Placeables/FurnitureAshen/AshenChair.png and b/Items/Placeables/FurnitureAshen/AshenChair.png differ diff --git a/Items/Placeables/FurnitureAshen/AshenPlatform.png b/Items/Placeables/FurnitureAshen/AshenPlatform.png index 6ab2c5ab18..2c349f8c05 100644 Binary files a/Items/Placeables/FurnitureAshen/AshenPlatform.png and b/Items/Placeables/FurnitureAshen/AshenPlatform.png differ diff --git a/Items/Placeables/FurnitureAshen/AshenSink.png b/Items/Placeables/FurnitureAshen/AshenSink.png index 60b2bf5b4c..63fd42f71d 100644 Binary files a/Items/Placeables/FurnitureAshen/AshenSink.png and b/Items/Placeables/FurnitureAshen/AshenSink.png differ diff --git a/Items/Placeables/FurnitureBotanic/BotanicBathtub.png b/Items/Placeables/FurnitureBotanic/BotanicBathtub.png index 4c3846bf7a..9da9b905b2 100644 Binary files a/Items/Placeables/FurnitureBotanic/BotanicBathtub.png and b/Items/Placeables/FurnitureBotanic/BotanicBathtub.png differ diff --git a/Items/Placeables/FurnitureBotanic/BotanicBed.png b/Items/Placeables/FurnitureBotanic/BotanicBed.png index 3da0811d34..010e60eb8c 100644 Binary files a/Items/Placeables/FurnitureBotanic/BotanicBed.png and b/Items/Placeables/FurnitureBotanic/BotanicBed.png differ diff --git a/Items/Placeables/FurnitureBotanic/BotanicPlatform.png b/Items/Placeables/FurnitureBotanic/BotanicPlatform.png index 1b886edafb..07f2021c29 100644 Binary files a/Items/Placeables/FurnitureBotanic/BotanicPlatform.png and b/Items/Placeables/FurnitureBotanic/BotanicPlatform.png differ diff --git a/Items/Placeables/FurnitureBotanic/BotanicSink.png b/Items/Placeables/FurnitureBotanic/BotanicSink.png index 19cfc9dd09..4671173ded 100644 Binary files a/Items/Placeables/FurnitureBotanic/BotanicSink.png and b/Items/Placeables/FurnitureBotanic/BotanicSink.png differ diff --git a/Items/Placeables/FurnitureCosmilite/CosmiliteCandle.png b/Items/Placeables/FurnitureCosmilite/CosmiliteCandle.png index 0ca75a29e5..ad097997e3 100644 Binary files a/Items/Placeables/FurnitureCosmilite/CosmiliteCandle.png and b/Items/Placeables/FurnitureCosmilite/CosmiliteCandle.png differ diff --git a/Items/Placeables/FurnitureCosmilite/CosmiliteLantern.png b/Items/Placeables/FurnitureCosmilite/CosmiliteLantern.png index e76b0ac466..a3748c4e88 100644 Binary files a/Items/Placeables/FurnitureCosmilite/CosmiliteLantern.png and b/Items/Placeables/FurnitureCosmilite/CosmiliteLantern.png differ diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicChest.png b/Items/Placeables/FurnitureEutrophic/EutrophicChest.png index 3337de552f..7fa3661cdf 100644 Binary files a/Items/Placeables/FurnitureEutrophic/EutrophicChest.png and b/Items/Placeables/FurnitureEutrophic/EutrophicChest.png differ diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicPlatform.png b/Items/Placeables/FurnitureEutrophic/EutrophicPlatform.png index 829454bdf3..2d8a1d9957 100644 Binary files a/Items/Placeables/FurnitureEutrophic/EutrophicPlatform.png and b/Items/Placeables/FurnitureEutrophic/EutrophicPlatform.png differ diff --git a/Items/Placeables/FurnitureMonolith/MonolithChest.png b/Items/Placeables/FurnitureMonolith/MonolithChest.png index 1e52409c99..1a0be40c15 100644 Binary files a/Items/Placeables/FurnitureMonolith/MonolithChest.png and b/Items/Placeables/FurnitureMonolith/MonolithChest.png differ diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyBathtub.png b/Items/Placeables/FurnitureOtherworldly/OtherworldlyBathtub.png index 49cc88a643..330719985a 100644 Binary files a/Items/Placeables/FurnitureOtherworldly/OtherworldlyBathtub.png and b/Items/Placeables/FurnitureOtherworldly/OtherworldlyBathtub.png differ diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyBed.png b/Items/Placeables/FurnitureOtherworldly/OtherworldlyBed.png index c36b3f5fa5..e47295baf6 100644 Binary files a/Items/Placeables/FurnitureOtherworldly/OtherworldlyBed.png and b/Items/Placeables/FurnitureOtherworldly/OtherworldlyBed.png differ diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyChair.png b/Items/Placeables/FurnitureOtherworldly/OtherworldlyChair.png index 2434cd1bb2..74368df9d5 100644 Binary files a/Items/Placeables/FurnitureOtherworldly/OtherworldlyChair.png and b/Items/Placeables/FurnitureOtherworldly/OtherworldlyChair.png differ diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyChest.png b/Items/Placeables/FurnitureOtherworldly/OtherworldlyChest.png index fc8f3bfde4..09db040dcf 100644 Binary files a/Items/Placeables/FurnitureOtherworldly/OtherworldlyChest.png and b/Items/Placeables/FurnitureOtherworldly/OtherworldlyChest.png differ diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyPlatform.png b/Items/Placeables/FurnitureOtherworldly/OtherworldlyPlatform.png index ab6f2860b6..858af7f419 100644 Binary files a/Items/Placeables/FurnitureOtherworldly/OtherworldlyPlatform.png and b/Items/Placeables/FurnitureOtherworldly/OtherworldlyPlatform.png differ diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlySink.png b/Items/Placeables/FurnitureOtherworldly/OtherworldlySink.png index 35580549e2..a1b00fdd87 100644 Binary files a/Items/Placeables/FurnitureOtherworldly/OtherworldlySink.png and b/Items/Placeables/FurnitureOtherworldly/OtherworldlySink.png differ diff --git a/Items/Placeables/FurnitureSilva/SilvaBathtub.png b/Items/Placeables/FurnitureSilva/SilvaBathtub.png index 722081457c..d001d59c03 100644 Binary files a/Items/Placeables/FurnitureSilva/SilvaBathtub.png and b/Items/Placeables/FurnitureSilva/SilvaBathtub.png differ diff --git a/Items/Placeables/FurnitureSilva/SilvaBed.png b/Items/Placeables/FurnitureSilva/SilvaBed.png index 43096eca42..8239f4d7f5 100644 Binary files a/Items/Placeables/FurnitureSilva/SilvaBed.png and b/Items/Placeables/FurnitureSilva/SilvaBed.png differ diff --git a/Items/Placeables/FurnitureSilva/SilvaChair.png b/Items/Placeables/FurnitureSilva/SilvaChair.png index ba6118b630..f23097889b 100644 Binary files a/Items/Placeables/FurnitureSilva/SilvaChair.png and b/Items/Placeables/FurnitureSilva/SilvaChair.png differ diff --git a/Items/Placeables/FurnitureSilva/SilvaChandelier.png b/Items/Placeables/FurnitureSilva/SilvaChandelier.png index 464566cc65..1753d693fe 100644 Binary files a/Items/Placeables/FurnitureSilva/SilvaChandelier.png and b/Items/Placeables/FurnitureSilva/SilvaChandelier.png differ diff --git a/Items/Placeables/FurnitureSilva/SilvaChest.png b/Items/Placeables/FurnitureSilva/SilvaChest.png index 6a2a66ce0e..d61fc5cbe0 100644 Binary files a/Items/Placeables/FurnitureSilva/SilvaChest.png and b/Items/Placeables/FurnitureSilva/SilvaChest.png differ diff --git a/Items/Placeables/FurnitureSilva/SilvaPlatform.png b/Items/Placeables/FurnitureSilva/SilvaPlatform.png index 41b774fdfb..c5a800d276 100644 Binary files a/Items/Placeables/FurnitureSilva/SilvaPlatform.png and b/Items/Placeables/FurnitureSilva/SilvaPlatform.png differ diff --git a/Items/Placeables/FurnitureSilva/SilvaSink.png b/Items/Placeables/FurnitureSilva/SilvaSink.png index 38e40fa5a3..61dbebe8aa 100644 Binary files a/Items/Placeables/FurnitureSilva/SilvaSink.png and b/Items/Placeables/FurnitureSilva/SilvaSink.png differ diff --git a/Items/Placeables/FurnitureVoid/SmoothVoidstonePlatform.png b/Items/Placeables/FurnitureVoid/SmoothVoidstonePlatform.png index fa07bcd54f..647ea6512e 100644 Binary files a/Items/Placeables/FurnitureVoid/SmoothVoidstonePlatform.png and b/Items/Placeables/FurnitureVoid/SmoothVoidstonePlatform.png differ diff --git a/Items/Potions/Alcohol/BloodyMary.png b/Items/Potions/Alcohol/BloodyMary.png index 935c52c03a..333f4ab986 100644 Binary files a/Items/Potions/Alcohol/BloodyMary.png and b/Items/Potions/Alcohol/BloodyMary.png differ diff --git a/Items/Potions/Alcohol/CinnamonRoll.png b/Items/Potions/Alcohol/CinnamonRoll.png index 6fb460058f..66f03882a4 100644 Binary files a/Items/Potions/Alcohol/CinnamonRoll.png and b/Items/Potions/Alcohol/CinnamonRoll.png differ diff --git a/Items/Potions/Alcohol/Fireball.png b/Items/Potions/Alcohol/Fireball.png index 2c90f8f28c..48ba41816b 100644 Binary files a/Items/Potions/Alcohol/Fireball.png and b/Items/Potions/Alcohol/Fireball.png differ diff --git a/Items/Potions/Alcohol/MoscowMule.png b/Items/Potions/Alcohol/MoscowMule.png index 602654af71..9a3a129c08 100644 Binary files a/Items/Potions/Alcohol/MoscowMule.png and b/Items/Potions/Alcohol/MoscowMule.png differ diff --git a/Items/Potions/Alcohol/OddMushroom.cs b/Items/Potions/Alcohol/OddMushroom.cs index b90ad15881..6bb6eab159 100644 --- a/Items/Potions/Alcohol/OddMushroom.cs +++ b/Items/Potions/Alcohol/OddMushroom.cs @@ -15,8 +15,8 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.width = 42; - Item.height = 48; + Item.width = 38; + Item.height = 50; Item.useTurn = true; Item.maxStack = 9999; Item.useAnimation = 17; diff --git a/Items/Potions/Alcohol/OddMushroom.png b/Items/Potions/Alcohol/OddMushroom.png index 81c156989f..947d323e19 100644 Binary files a/Items/Potions/Alcohol/OddMushroom.png and b/Items/Potions/Alcohol/OddMushroom.png differ diff --git a/Items/Potions/Alcohol/OldFashioned.cs b/Items/Potions/Alcohol/OldFashioned.cs new file mode 100644 index 0000000000..59455bc6d3 --- /dev/null +++ b/Items/Potions/Alcohol/OldFashioned.cs @@ -0,0 +1,36 @@ +using CalamityMod.Buffs.Alcohol; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Potions.Alcohol +{ + public class OldFashioned : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Potions"; + public const float AccessoryAndSetBonusDamageMultiplier = 1.5f; + public const float DamageStatReduction = 0.25f; + + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 5; + } + + public override void SetDefaults() + { + Item.width = 28; + Item.height = 40; + Item.useTurn = true; + Item.maxStack = 9999; + Item.rare = ItemRarityID.Lime; + Item.useAnimation = 17; + Item.useTime = 17; + Item.useStyle = ItemUseStyleID.DrinkLiquid; + Item.UseSound = SoundID.Item3; + Item.consumable = true; + Item.buffType = ModContent.BuffType(); + Item.buffTime = CalamityUtils.SecondsToFrames(360f); + Item.value = Item.buyPrice(0, 5, 30, 0); + } + } +} diff --git a/Items/Potions/Alcohol/OldFashioned.png b/Items/Potions/Alcohol/OldFashioned.png new file mode 100644 index 0000000000..fddbd65368 Binary files /dev/null and b/Items/Potions/Alcohol/OldFashioned.png differ diff --git a/Items/Potions/Alcohol/Screwdriver.png b/Items/Potions/Alcohol/Screwdriver.png index 8a6347e141..e499f35d90 100644 Binary files a/Items/Potions/Alcohol/Screwdriver.png and b/Items/Potions/Alcohol/Screwdriver.png differ diff --git a/Items/Potions/Alcohol/Tequila.png b/Items/Potions/Alcohol/Tequila.png index fbc599e369..8ef6726cd6 100644 Binary files a/Items/Potions/Alcohol/Tequila.png and b/Items/Potions/Alcohol/Tequila.png differ diff --git a/Items/Potions/Alcohol/TequilaSunrise.png b/Items/Potions/Alcohol/TequilaSunrise.png index 481020aafa..30974d148a 100644 Binary files a/Items/Potions/Alcohol/TequilaSunrise.png and b/Items/Potions/Alcohol/TequilaSunrise.png differ diff --git a/Items/Potions/Alcohol/Vodka.png b/Items/Potions/Alcohol/Vodka.png index 2e89309b90..f1e7333959 100644 Binary files a/Items/Potions/Alcohol/Vodka.png and b/Items/Potions/Alcohol/Vodka.png differ diff --git a/Items/Potions/Fabsoup.cs b/Items/Potions/Fabsoup.cs index 228d1c22c4..e532b991b1 100644 --- a/Items/Potions/Fabsoup.cs +++ b/Items/Potions/Fabsoup.cs @@ -1,5 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Rarities; +using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -11,7 +12,8 @@ namespace CalamityMod.Items.Potions { public new string LocalizationCategory => "Items.Potions"; public static readonly SoundStyle UseSound = new("CalamityMod/Sounds/Item/SoupConsumption"); - + public SlotId DrinkSoundSlot; + public override void SetDefaults() { Item.width = 56; @@ -22,10 +24,15 @@ namespace CalamityMod.Items.Potions Item.consumable = false; Item.useAnimation = 901; Item.useTime = 901; - Item.UseSound = UseSound; + Item.UseSound = null; Item.useStyle = ItemUseStyleID.DrinkLiquid; Item.useTurn = true; } + public override bool? UseItem(Player player) + { + DrinkSoundSlot = SoundEngine.PlaySound(UseSound, player.Center); + return true; + } public override void UseItemFrame(Player player) { @@ -48,6 +55,9 @@ namespace CalamityMod.Items.Potions player.AddBuff(ModContent.BuffType(), time); player.AddBuff(ModContent.BuffType(), time); } + + if (SoundEngine.TryGetActiveSound(DrinkSoundSlot, out var drinkSound) && drinkSound.IsPlaying) + drinkSound.Position = player.Center; } } } diff --git a/Items/Potions/ZergPotion.png b/Items/Potions/ZergPotion.png index 97f584e5cd..fc00a342b0 100644 Binary files a/Items/Potions/ZergPotion.png and b/Items/Potions/ZergPotion.png differ diff --git a/Items/SummonItems/AstralChunk.cs b/Items/SummonItems/AstralChunk.cs index cce1eb4737..42625f3778 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] = 14; // Frost Moon } public override void SetDefaults() @@ -28,10 +28,10 @@ namespace CalamityMod.Items.SummonItems Item.consumable = false; } - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = ContentSamples.CreativeHelper.ItemGroup.BossItem; - } + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + itemGroup = ContentSamples.CreativeHelper.ItemGroup.BossItem; + } public override bool CanUseItem(Player player) { @@ -58,7 +58,7 @@ namespace CalamityMod.Items.SummonItems CreateRecipe(). AddIngredient(30). AddIngredient(ItemID.FallenStar, 20). - AddTile(TileID.MythrilAnvil). + AddTile(TileID.Anvils). Register(); } } diff --git a/Items/SummonItems/EyeofDesolation.cs b/Items/SummonItems/EyeofDesolation.cs index 96e352eb89..dab9ba5b48 100644 --- a/Items/SummonItems/EyeofDesolation.cs +++ b/Items/SummonItems/EyeofDesolation.cs @@ -67,31 +67,31 @@ namespace CalamityMod.Items.SummonItems safeBox.Height = 2500; spawnYAdd = 125; - int num52 = (int)(safeBox.X + (float)(safeBox.Width / 2)) / 16; - int num53 = (int)(safeBox.Y + (float)(safeBox.Height / 2)) / 16; - int num54 = safeBox.Width / 2 / 16 + 1; - for (int num55 = num52 - num54; num55 <= num52 + num54; num55++) + int safeBoxTilesX = (int)(safeBox.X + (float)(safeBox.Width / 2)) / 16; + int safeBoxTilesY = (int)(safeBox.Y + (float)(safeBox.Height / 2)) / 16; + int safeBoxTilesWidth = safeBox.Width / 2 / 16 + 1; + for (int i = safeBoxTilesX - safeBoxTilesWidth; i <= safeBoxTilesX + safeBoxTilesWidth; i++) { - for (int num56 = num53 - num54; num56 <= num53 + num54; num56++) + for (int j = safeBoxTilesY - safeBoxTilesWidth; j <= safeBoxTilesY + safeBoxTilesWidth; j++) { - if (!WorldGen.InWorld(num55, num56, 2)) + if (!WorldGen.InWorld(i, j, 2)) continue; int xoffset = 0; int yoffset = 0; - if ((num55 == num52 - num54 || num55 == num52 + num54 || num56 == num53 - num54 || num56 == num53 + num54) && !Main.tile[num55 + xoffset, num56 + yoffset].HasTile) + if ((i == safeBoxTilesX - safeBoxTilesWidth || i == safeBoxTilesX + safeBoxTilesWidth || j == safeBoxTilesY - safeBoxTilesWidth || j == safeBoxTilesY + safeBoxTilesWidth) && !Main.tile[i + xoffset, j + yoffset].HasTile) { - Main.tile[num55 + xoffset, num56 + yoffset].TileType = (ushort)ModContent.TileType(); - Main.tile[num55 + xoffset, num56 + yoffset].Get().HasTile = true; + Main.tile[i + xoffset, j + yoffset].TileType = (ushort)ModContent.TileType(); + Main.tile[i + xoffset, j + yoffset].Get().HasTile = true; } if (Main.netMode == NetmodeID.Server) { - NetMessage.SendTileSquare(-1, num55 + xoffset, num56 + yoffset, 1, TileChangeType.None); + NetMessage.SendTileSquare(-1, i + xoffset, j + yoffset, 1, TileChangeType.None); } else { - WorldGen.SquareTileFrame(num55 + xoffset, num56 + yoffset, true); + WorldGen.SquareTileFrame(i + xoffset, j + yoffset, true); } } } diff --git a/Items/SummonItems/Invasion/CausticTear.cs b/Items/SummonItems/Invasion/CausticTear.cs index 30642ff827..849c8f6749 100644 --- a/Items/SummonItems/Invasion/CausticTear.cs +++ b/Items/SummonItems/Invasion/CausticTear.cs @@ -16,8 +16,8 @@ namespace CalamityMod.Items.SummonItems.Invasion public override void SetDefaults() { - Item.width = 28; - Item.height = 18; + Item.width = 16; + Item.height = 28; Item.maxStack = 1; Item.rare = ItemRarityID.Green; Item.useAnimation = 10; diff --git a/Items/SummonItems/Invasion/CausticTear.png b/Items/SummonItems/Invasion/CausticTear.png index 9d91f64691..92376bd7de 100644 Binary files a/Items/SummonItems/Invasion/CausticTear.png and b/Items/SummonItems/Invasion/CausticTear.png differ diff --git a/Items/SummonItems/OldPowerCell.cs b/Items/SummonItems/OldPowerCell.cs index 119eb4cb92..8195e52b80 100644 --- a/Items/SummonItems/OldPowerCell.cs +++ b/Items/SummonItems/OldPowerCell.cs @@ -39,9 +39,9 @@ namespace CalamityMod.Items.SummonItems bool canSummon = false; if (player.Center.Y > Main.worldSurface * 16.0) { - int num = (int)player.Center.X / 16; - int num2 = (int)player.Center.Y / 16; - Tile tile = Framing.GetTileSafely(num, num2); + int playerTileX = (int)player.Center.X / 16; + int playerTileY = (int)player.Center.Y / 16; + Tile tile = Framing.GetTileSafely(playerTileX, playerTileY); if (tile.WallType == 87) canSummon = true; } diff --git a/Items/Tools/FellerofEvergreens.cs b/Items/Tools/FellerofEvergreens.cs index 9e885081ba..8a4c67347f 100644 --- a/Items/Tools/FellerofEvergreens.cs +++ b/Items/Tools/FellerofEvergreens.cs @@ -16,8 +16,8 @@ namespace CalamityMod.Items.Tools Item.axe = 100 / 5; Item.DamageType = DamageClass.Melee; - Item.width = 36; - Item.height = 36; + Item.width = 50; + Item.height = 46; Item.scale = 1.5f; Item.useTurn = true; Item.useStyle = ItemUseStyleID.Swing; diff --git a/Items/Tools/FellerofEvergreens.png b/Items/Tools/FellerofEvergreens.png index 0c51f191c2..322c229f2e 100644 Binary files a/Items/Tools/FellerofEvergreens.png and b/Items/Tools/FellerofEvergreens.png differ diff --git a/Items/Tools/Gelpick.cs b/Items/Tools/Gelpick.cs index ffb866e656..b4494aea18 100644 --- a/Items/Tools/Gelpick.cs +++ b/Items/Tools/Gelpick.cs @@ -12,16 +12,16 @@ namespace CalamityMod.Items.Tools public new string LocalizationCategory => "Items.Tools"; public override void SetDefaults() { - Item.damage = 12; + Item.damage = 19; Item.knockBack = 2.5f; - Item.useTime = 10; + Item.useTime = 9; Item.useAnimation = 20; - Item.pick = 100; + Item.pick = 105; Item.tileBoost += 1; Item.DamageType = DamageClass.Melee; Item.width = 46; - Item.height = 46; + Item.height = 48; Item.useStyle = ItemUseStyleID.Swing; Item.value = CalamityGlobalItem.Rarity4BuyPrice; Item.rare = ItemRarityID.LightRed; diff --git a/Items/Tools/Gelpick.png b/Items/Tools/Gelpick.png index 8ebec5de95..026c5359a1 100644 Binary files a/Items/Tools/Gelpick.png and b/Items/Tools/Gelpick.png differ diff --git a/Items/Tools/InfernaCutter.cs b/Items/Tools/InfernaCutter.cs index 15984d4cd9..227ccb8a6f 100644 --- a/Items/Tools/InfernaCutter.cs +++ b/Items/Tools/InfernaCutter.cs @@ -59,64 +59,64 @@ namespace CalamityMod.Items.Tools player.itemAnimation == (int)(player.itemAnimationMax * 0.7) || player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) { - float num339 = 0f; - float num340 = 0f; - float num341 = 0f; - float num342 = 0f; + float sparkYVel = 0f; + float sparkXVel = 0f; + float sparkYSpawn = 0f; + float sparkXSpawn = 0f; if (player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) { - num339 = -7f; + sparkYVel = -7f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) { - num339 = -6f; - num340 = 2f; + sparkYVel = -6f; + sparkXVel = 2f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.5)) { - num339 = -4f; - num340 = 4f; + sparkYVel = -4f; + sparkXVel = 4f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.3)) { - num339 = -2f; - num340 = 6f; + sparkYVel = -2f; + sparkXVel = 6f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.1)) { - num340 = 7f; + sparkXVel = 7f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) { - num342 = 26f; + sparkXSpawn = 26f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.3)) { - num342 -= 4f; - num341 -= 20f; + sparkXSpawn -= 4f; + sparkYSpawn -= 20f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.1)) { - num341 += 6f; + sparkYSpawn += 6f; } if (player.direction == -1) { if (player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) { - num342 -= 8f; + sparkXSpawn -= 8f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) { - num342 -= 6f; + sparkXSpawn -= 6f; } } - num339 *= 1.5f; - num340 *= 1.5f; - num342 *= (float)player.direction; - num341 *= player.gravDir; + sparkYVel *= 1.5f; + sparkXVel *= 1.5f; + sparkXSpawn *= (float)player.direction; + sparkYSpawn *= player.gravDir; var source = player.GetSource_ItemUse(Item); int damage = (int)player.GetTotalDamage().ApplyTo(Item.damage * 0.2f); - int spark = Projectile.NewProjectile(source, (float)(hitbox.X + hitbox.Width / 2) + num342, (float)(hitbox.Y + hitbox.Height / 2) + num341, (float)player.direction * num340, num339 * player.gravDir, ProjectileID.Spark, damage, 0f, player.whoAmI); + int spark = Projectile.NewProjectile(source, (float)(hitbox.X + hitbox.Width / 2) + sparkXSpawn, (float)(hitbox.Y + hitbox.Height / 2) + sparkYSpawn, (float)player.direction * sparkXVel, sparkYVel * player.gravDir, ProjectileID.Spark, damage, 0f, player.whoAmI); if (spark.WithinBounds(Main.maxProjectiles)) Main.projectile[spark].DamageType = DamageClass.Melee; } diff --git a/Items/Tools/SkyfringePickaxe.cs b/Items/Tools/SkyfringePickaxe.cs index c4b3c3350d..9e9a90cdab 100644 --- a/Items/Tools/SkyfringePickaxe.cs +++ b/Items/Tools/SkyfringePickaxe.cs @@ -13,9 +13,9 @@ namespace CalamityMod.Items.Tools { Item.damage = 12; Item.knockBack = 2.5f; - Item.useTime = 9; + Item.useTime = 12; Item.useAnimation = 16; - Item.pick = 75; + Item.pick = 105; Item.tileBoost += 1; Item.DamageType = DamageClass.Melee; diff --git a/Items/TreasureBags/BrimstoneWaifuBag.cs b/Items/TreasureBags/BrimstoneWaifuBag.cs index f3308de4fb..be530b66c0 100644 --- a/Items/TreasureBags/BrimstoneWaifuBag.cs +++ b/Items/TreasureBags/BrimstoneWaifuBag.cs @@ -76,7 +76,7 @@ namespace CalamityMod.Items.TreasureBags { ModContent.ItemType(), })); - itemLoot.Add(ModContent.ItemType(), 10); + itemLoot.Add(ModContent.ItemType()); itemLoot.AddRevBagAccessories(); // Vanity diff --git a/Items/TreasureBags/DesertScourgeBag.cs b/Items/TreasureBags/DesertScourgeBag.cs index 4b946bcd0c..f0198e955d 100644 --- a/Items/TreasureBags/DesertScourgeBag.cs +++ b/Items/TreasureBags/DesertScourgeBag.cs @@ -68,10 +68,10 @@ namespace CalamityMod.Items.TreasureBags // Weapons itemLoot.Add(DropHelper.CalamityStyle(DropHelper.BagWeaponDropRateFraction, new int[] { - ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType() })); diff --git a/Items/TreasureBags/DesertScourgeBag.png b/Items/TreasureBags/DesertScourgeBag.png index a9c824361c..97999d7536 100644 Binary files a/Items/TreasureBags/DesertScourgeBag.png and b/Items/TreasureBags/DesertScourgeBag.png differ diff --git a/Items/TreasureBags/OldDukeBag.cs b/Items/TreasureBags/OldDukeBag.cs index 75b92792fd..d391163214 100644 --- a/Items/TreasureBags/OldDukeBag.cs +++ b/Items/TreasureBags/OldDukeBag.cs @@ -67,14 +67,14 @@ namespace CalamityMod.Items.TreasureBags ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType() })); itemLoot.Add(ModContent.ItemType(), 10); // Equipment - itemLoot.Add(ModContent.ItemType(), DropHelper.BagWeaponDropRateFraction); - itemLoot.Add(ModContent.ItemType()); + itemLoot.Add(ModContent.ItemType()); itemLoot.AddRevBagAccessories(); // Vanity diff --git a/Items/VanillaArmorChanges/AdamantiteArmorSetChange.cs b/Items/VanillaArmorChanges/AdamantiteArmorSetChange.cs index 0cfc87bd60..206ba17b4e 100644 --- a/Items/VanillaArmorChanges/AdamantiteArmorSetChange.cs +++ b/Items/VanillaArmorChanges/AdamantiteArmorSetChange.cs @@ -30,11 +30,13 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void UpdateSetBonusText(ref string setBonusText) { - setBonusText = setBonusText.Replace("20% increased melee and movement speed", "15% increased melee speed and 20% increased movement speed"); - setBonusText += "\nHalf of your current DR is added to your critical strike chance\n" + - $"Continuously doing damage makes you gradually gain more and more defense, up to a maximum of {DefenseBoostMax}\n" + - "When not doing damage, this bonus gradually decays\n" + - "This added defense can be broken by defense damage"; + Player player = Main.LocalPlayer; + if (player.armor[0].type == ItemID.AdamantiteHelmet) + { + setBonusText = CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}.Melee"); + } + + setBonusText += $"\n{CalamityUtils.GetText($"Vanilla.Armor.SetBonus.{ArmorSetName}").Format(DefenseBoostMax)}"; } public override void ApplyArmorSetBonus(Player player) diff --git a/Items/VanillaArmorChanges/ChlorophyteArmorSetChange.cs b/Items/VanillaArmorChanges/ChlorophyteArmorSetChange.cs index a200eb5311..6748ee267d 100644 --- a/Items/VanillaArmorChanges/ChlorophyteArmorSetChange.cs +++ b/Items/VanillaArmorChanges/ChlorophyteArmorSetChange.cs @@ -24,11 +24,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void UpdateSetBonusText(ref string setBonusText) { - setBonusText = $"Summons a powerful leaf crystal to shoot pulses of life every {PulseReleaseRate / 60f} seconds\n" + - $"The pulses do a base damage of {BaseDamageToEnemies} to enemies within its range\n" + - $"The pulses also provide a {AmountToHealPerPulse} health boost to you and all players on your team\n" + - $"Players healed by pulses cannot be healed by another pulse until {DelayBetweenHeals / 60f} seconds have passed\n" + - "Both the health boost and the damage scale based on your strongest class"; + setBonusText = $"{CalamityUtils.GetText($"Vanilla.Armor.SetBonus.{ArmorSetName}").Format(PulseReleaseRate / 60f, BaseDamageToEnemies, AmountToHealPerPulse, DelayBetweenHeals / 60f)}"; } } } diff --git a/Items/VanillaArmorChanges/CobaltArmorSetChange.cs b/Items/VanillaArmorChanges/CobaltArmorSetChange.cs index 786170ac37..738392cb4e 100644 --- a/Items/VanillaArmorChanges/CobaltArmorSetChange.cs +++ b/Items/VanillaArmorChanges/CobaltArmorSetChange.cs @@ -30,9 +30,13 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void UpdateSetBonusText(ref string setBonusText) { - setBonusText = setBonusText.Replace("15", "10"); - setBonusText += $"\n{SpeedBoostSetBonusPercentage}% increased max speed and acceleration\n" + - $"You gain a damage and critical strike chance boost relative to your current movement speed, up to {SpeedBoostSetBonusPercentage}%"; + Player player = Main.LocalPlayer; + if (player.armor[0].type == ItemID.CobaltHelmet) + { + setBonusText = CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}.Melee"); + } + + setBonusText += $"\n{CalamityUtils.GetText($"Vanilla.Armor.SetBonus.{ArmorSetName}").Format(SpeedBoostSetBonusPercentage)}"; } public static float CalculateMovementSpeedInterpolant(Player player) diff --git a/Items/VanillaArmorChanges/CopperArmorSetChange.cs b/Items/VanillaArmorChanges/CopperArmorSetChange.cs index fa2f673f9b..fbf35b1549 100644 --- a/Items/VanillaArmorChanges/CopperArmorSetChange.cs +++ b/Items/VanillaArmorChanges/CopperArmorSetChange.cs @@ -28,9 +28,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void UpdateSetBonusText(ref string setBonusText) { - StringBuilder sb = new StringBuilder(256); - sb.Append("\nIncreases all damage by 2"); - setBonusText += sb.ToString(); + setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; } public override void ApplyArmorSetBonus(Player player) diff --git a/Items/VanillaArmorChanges/EskimoArmorSetChange.cs b/Items/VanillaArmorChanges/EskimoArmorSetChange.cs index e59e43831b..94f7ed96f4 100644 --- a/Items/VanillaArmorChanges/EskimoArmorSetChange.cs +++ b/Items/VanillaArmorChanges/EskimoArmorSetChange.cs @@ -20,16 +20,11 @@ namespace CalamityMod.Items.VanillaArmorChanges public override int[] AlternativeLegPieceIDs => new int[] { ItemID.PinkEskimoPants }; - public override bool NeedsToCreateSetBonusTextManually => true; - public override string ArmorSetName => "Eskimo"; public override void UpdateSetBonusText(ref string setBonusText) { - // Not sure why it doesn't say Set bonus automatically - setBonusText = "Set bonus: Multiplies all cold-based debuff damage by 1.25\n" + - "Cold enemies will deal reduced contact damage to the player\n" + - "Provides immunity to the Chilled, Frozen, Frostburn and Glacial State debuffs"; + setBonusText = $"{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; } public override void ApplyArmorSetBonus(Player player) diff --git a/Items/VanillaArmorChanges/FrostArmorSetChange.cs b/Items/VanillaArmorChanges/FrostArmorSetChange.cs index d594391856..c3a71e8264 100644 --- a/Items/VanillaArmorChanges/FrostArmorSetChange.cs +++ b/Items/VanillaArmorChanges/FrostArmorSetChange.cs @@ -22,9 +22,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void UpdateSetBonusText(ref string setBonusText) { int PercentBoost = (int)Math.Round(ProximityBoost * 100); - setBonusText = "Melee and ranged attacks inflict Frostbite\n" + - $"{PercentBoost}% increased damage which scales based on how far the target is from you\n" + - "Closer range grants melee damage, while farther range grants ranged damage"; + setBonusText = $"{CalamityUtils.GetText($"Vanilla.Armor.SetBonus.{ArmorSetName}").Format(PercentBoost)}"; } public override void ApplyArmorSetBonus(Player player) diff --git a/Items/VanillaArmorChanges/GladiatorArmorSetChange.cs b/Items/VanillaArmorChanges/GladiatorArmorSetChange.cs index 8ce17c7ecd..d1ebc8a41b 100644 --- a/Items/VanillaArmorChanges/GladiatorArmorSetChange.cs +++ b/Items/VanillaArmorChanges/GladiatorArmorSetChange.cs @@ -20,9 +20,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void UpdateSetBonusText(ref string setBonusText) { - setBonusText += "\n+3 defense\n" + - "+60 maximum stealth\n" + - "5% increased rogue damage and 10% increased velocity"; + setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; } public override void ApplyHeadPieceEffect(Player player) diff --git a/Items/VanillaArmorChanges/GoldArmorSetChange.cs b/Items/VanillaArmorChanges/GoldArmorSetChange.cs index de69a79da7..d77ca4fd66 100644 --- a/Items/VanillaArmorChanges/GoldArmorSetChange.cs +++ b/Items/VanillaArmorChanges/GoldArmorSetChange.cs @@ -32,9 +32,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void UpdateSetBonusText(ref string setBonusText) { - StringBuilder sb = new StringBuilder(256); - sb.Append("\nAll enemies have a 4% chance to drop 1 gold. All bosses killed drop 3 gold\nYou gain 1% critical strike chance for every 5 gold in your inventory, capped at 10%"); - setBonusText += sb.ToString(); + setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; } public override void ApplyArmorSetBonus(Player player) diff --git a/Items/VanillaArmorChanges/IronArmorSetChange.cs b/Items/VanillaArmorChanges/IronArmorSetChange.cs index a5af707c1c..ea739abcf5 100644 --- a/Items/VanillaArmorChanges/IronArmorSetChange.cs +++ b/Items/VanillaArmorChanges/IronArmorSetChange.cs @@ -28,9 +28,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void UpdateSetBonusText(ref string setBonusText) { - StringBuilder sb = new StringBuilder(256); - sb.Append("\nIncreases damage reduction by 6%\n+1 HP/s life regen"); - setBonusText += sb.ToString(); + setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; } public override void ApplyArmorSetBonus(Player player) diff --git a/Items/VanillaArmorChanges/LeadArmorSetChange.cs b/Items/VanillaArmorChanges/LeadArmorSetChange.cs index 0f35ce35f1..fccf0e14f1 100644 --- a/Items/VanillaArmorChanges/LeadArmorSetChange.cs +++ b/Items/VanillaArmorChanges/LeadArmorSetChange.cs @@ -26,9 +26,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void UpdateSetBonusText(ref string setBonusText) { - StringBuilder sb = new StringBuilder(256); - sb.Append("\nIncreases damage reduction by 3%\n+0.5 HP/s life regen\nGrants immunity to knockback"); - setBonusText += sb.ToString(); + setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; } public override void ApplyArmorSetBonus(Player player) diff --git a/Items/VanillaArmorChanges/MeteorArmorSetChange.cs b/Items/VanillaArmorChanges/MeteorArmorSetChange.cs index bdf7ee8a6b..2bc9b5f104 100644 --- a/Items/VanillaArmorChanges/MeteorArmorSetChange.cs +++ b/Items/VanillaArmorChanges/MeteorArmorSetChange.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.VanillaArmorChanges // Meteor Armor only makes space gun cost 50% instead of zero mana. public override void UpdateSetBonusText(ref string setBonusText) { - setBonusText = setBonusText.Replace("0", "50%"); + setBonusText = $"{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; } public override void ApplyArmorSetBonus(Player player) diff --git a/Items/VanillaArmorChanges/MiningArmorSetChange.cs b/Items/VanillaArmorChanges/MiningArmorSetChange.cs index ba6bafc054..1330cc51f3 100644 --- a/Items/VanillaArmorChanges/MiningArmorSetChange.cs +++ b/Items/VanillaArmorChanges/MiningArmorSetChange.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void UpdateSetBonusText(ref string setBonusText) { - setBonusText += "\nMining ore will sometimes have additional yield"; + setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; } public override void ApplyArmorSetBonus(Player player) diff --git a/Items/VanillaArmorChanges/MoltenArmorSetChange.cs b/Items/VanillaArmorChanges/MoltenArmorSetChange.cs index fb505233e8..f0504d0a97 100644 --- a/Items/VanillaArmorChanges/MoltenArmorSetChange.cs +++ b/Items/VanillaArmorChanges/MoltenArmorSetChange.cs @@ -17,8 +17,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void UpdateSetBonusText(ref string setBonusText) { - string extraLine = "\n20% extra true melee damage\nGrants immunity to fire blocks and temporary immunity to lava"; - setBonusText += extraLine; + setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; } public override void ApplyArmorSetBonus(Player player) diff --git a/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs b/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs index 329159e5a5..1da19b5973 100644 --- a/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs +++ b/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs @@ -16,8 +16,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void UpdateSetBonusText(ref string setBonusText) { - setBonusText += "\n10% increased melee speed, crit, and damage\n" + - "15% increased minion damage"; + setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; } public override void ApplyHeadPieceEffect(Player player) diff --git a/Items/VanillaArmorChanges/MythrilArmorSetChange.cs b/Items/VanillaArmorChanges/MythrilArmorSetChange.cs index f9da6d3217..3a497c8f54 100644 --- a/Items/VanillaArmorChanges/MythrilArmorSetChange.cs +++ b/Items/VanillaArmorChanges/MythrilArmorSetChange.cs @@ -24,8 +24,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void UpdateSetBonusText(ref string setBonusText) { - setBonusText += "\nEnemy hits release mythril flares, which home in on enemies after a short delay\n" + - $"Once a flare is created, there is a {FlareFrameSpawnDelay} frame delay before another one can appear"; + setBonusText += $"\n{CalamityUtils.GetText($"Vanilla.Armor.SetBonus.{ArmorSetName}").Format(FlareFrameSpawnDelay)}"; } public override void ApplyHeadPieceEffect(Player player) @@ -53,6 +52,9 @@ namespace CalamityMod.Items.VanillaArmorChanges owner.Calamity().MythrilFlareSpawnCountdown = FlareFrameSpawnDelay; int flareDamage = CalamityUtils.DamageSoftCap(originalDamage * 0.4, FlareDamageSoftcap); + if (owner.Calamity().oldFashioned) + flareDamage = CalamityUtils.CalcOldFashionedDamage(flareDamage); + Vector2 flareSpawnPosition = victim.Center + Main.rand.NextVector2Circular(10f, 10f); Projectile.NewProjectile(owner.GetSource_ItemUse(owner.ActiveItem()), flareSpawnPosition, Vector2.Zero, ModContent.ProjectileType(), flareDamage, 0f, owner.whoAmI); } diff --git a/Items/VanillaArmorChanges/NecroArmorSetChange.cs b/Items/VanillaArmorChanges/NecroArmorSetChange.cs index 74a3401914..dc0b171ace 100644 --- a/Items/VanillaArmorChanges/NecroArmorSetChange.cs +++ b/Items/VanillaArmorChanges/NecroArmorSetChange.cs @@ -22,9 +22,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void UpdateSetBonusText(ref string setBonusText) { - string extraLines = "\nAllows you to temporarily survive fatal damage\n" + - $"Grants up to {PostMortemDuration} seconds of life before imminent death"; - setBonusText += extraLines; + setBonusText += $"\n{CalamityUtils.GetText($"Vanilla.Armor.SetBonus.{ArmorSetName}").Format(PostMortemDuration)}"; } public override void ApplyArmorSetBonus(Player player) => player.Calamity().necroSet = true; diff --git a/Items/VanillaArmorChanges/ObsidianArmorSetChange.cs b/Items/VanillaArmorChanges/ObsidianArmorSetChange.cs index 63b595a2bf..8b9a11367c 100644 --- a/Items/VanillaArmorChanges/ObsidianArmorSetChange.cs +++ b/Items/VanillaArmorChanges/ObsidianArmorSetChange.cs @@ -13,13 +13,9 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "Obsidian"; - public override bool NeedsToCreateSetBonusTextManually => true; - public override void UpdateSetBonusText(ref string setBonusText) { - setBonusText = "Set Bonus: Increases whip range by 50% and speed by 35%\n" + - "Increases minion damage by 15%\n" + - "Grants immunity to fire blocks and temporary immunity to lava"; + setBonusText = $"{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; } public override void ApplyArmorSetBonus(Player player) diff --git a/Items/VanillaArmorChanges/PlatinumArmorSetChange.cs b/Items/VanillaArmorChanges/PlatinumArmorSetChange.cs index bdfc2e50d1..64a39bf6cb 100644 --- a/Items/VanillaArmorChanges/PlatinumArmorSetChange.cs +++ b/Items/VanillaArmorChanges/PlatinumArmorSetChange.cs @@ -31,9 +31,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void UpdateSetBonusText(ref string setBonusText) { - StringBuilder sb = new StringBuilder(256); - sb.Append("\nEvery 10 defense gives you +0.5 HP/s life regen, 1% increased damage and 1% increased critical strike chance\nThese effects cap at 40 defense"); - setBonusText += sb.ToString(); + setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; } public override void ApplyArmorSetBonus(Player player) diff --git a/Items/VanillaArmorChanges/ShadowArmorSetChange.cs b/Items/VanillaArmorChanges/ShadowArmorSetChange.cs index 731ae70bc1..65a8fe70b1 100644 --- a/Items/VanillaArmorChanges/ShadowArmorSetChange.cs +++ b/Items/VanillaArmorChanges/ShadowArmorSetChange.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Items.VanillaArmorChanges private void ApplyAnyPieceEffect(Player player) { - // Remove the vanilla melee speed buff and replace it with damage - player.GetAttackSpeed() -= 0.07f; + // Remove the vanilla crit chance buff and replace it with damage + player.GetCritChance() -= 0.05f; player.GetDamage() += ArmorPieceDamage; // Give jump boost @@ -38,7 +38,10 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void ApplyLegPieceEffect(Player player) => ApplyAnyPieceEffect(player); - public override void UpdateSetBonusText(ref string setBonusText) => setBonusText = "Set bonus: 15% increased max movement speed and acceleration"; + public override void UpdateSetBonusText(ref string setBonusText) + { + setBonusText = $"{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; + } public override void ApplyArmorSetBonus(Player player) { diff --git a/Items/VanillaArmorChanges/SilverArmorSetChange.cs b/Items/VanillaArmorChanges/SilverArmorSetChange.cs index c9e6246e0f..a2c696ced8 100644 --- a/Items/VanillaArmorChanges/SilverArmorSetChange.cs +++ b/Items/VanillaArmorChanges/SilverArmorSetChange.cs @@ -33,9 +33,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void UpdateSetBonusText(ref string setBonusText) { - StringBuilder sb = new StringBuilder(256); - sb.Append("\n+0.5 HP/s life regen\nTwo seconds after getting hit for 20 or more damage, you heal for 10\nGetting hit again resets the timer, delaying the heal"); - setBonusText += sb.ToString(); + setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; } public override void ApplyArmorSetBonus(Player player) diff --git a/Items/VanillaArmorChanges/TinArmorSetChange.cs b/Items/VanillaArmorChanges/TinArmorSetChange.cs index 2d7c838e2b..12a2c7f88e 100644 --- a/Items/VanillaArmorChanges/TinArmorSetChange.cs +++ b/Items/VanillaArmorChanges/TinArmorSetChange.cs @@ -28,9 +28,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void UpdateSetBonusText(ref string setBonusText) { - StringBuilder sb = new StringBuilder(256); - sb.Append("\nIncreases armor penetration by 5"); - setBonusText += sb.ToString(); + setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; } public override void ApplyArmorSetBonus(Player player) diff --git a/Items/VanillaArmorChanges/TungstenArmorSetChange.cs b/Items/VanillaArmorChanges/TungstenArmorSetChange.cs index 597efa2bfa..8ce52b2088 100644 --- a/Items/VanillaArmorChanges/TungstenArmorSetChange.cs +++ b/Items/VanillaArmorChanges/TungstenArmorSetChange.cs @@ -34,16 +34,9 @@ namespace CalamityMod.Items.VanillaArmorChanges float kb = player.GetWeaponKnockback(player.ActiveItem()); float bonus = MathHelper.Clamp(kb, 0f, MaxKnockbackCritConversion); - StringBuilder sb = new StringBuilder(256); - sb.Append("\nIncreases your critical strike chance by 100% of the knockback of your held weapon"); - sb.Append("\nThis effect caps at Insane knockback, which gives 10% increased critical strike chance"); - sb.Append("\nIncreases all knockback by 33%, this counts for the above boost"); - sb.Append("\nCurrent bonus: "); - sb.Append(bonus.ToString("n2")); - sb.Append("% critical strike chance from "); - sb.Append(kb.ToString("n2")); - sb.Append(" knockback"); - setBonusText += sb.ToString(); + string bonusText = bonus.ToString("n2"); + string kbText = kb.ToString("n2"); + setBonusText += $"\n{CalamityUtils.GetText($"Vanilla.Armor.SetBonus.{ArmorSetName}").Format(bonusText, kbText)}"; } public override void ApplyArmorSetBonus(Player player) diff --git a/Items/VanillaArmorChanges/VanillaArmorChange.cs b/Items/VanillaArmorChanges/VanillaArmorChange.cs index 811e73a8c8..52e756c7b2 100644 --- a/Items/VanillaArmorChanges/VanillaArmorChange.cs +++ b/Items/VanillaArmorChanges/VanillaArmorChange.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public virtual string ArmorSetName => null; - public virtual bool NeedsToCreateSetBonusTextManually => false; + public virtual bool NeedsToCreateSetBonusTextManually => true; public virtual void UpdateSetBonusText(ref string setBonusText) { } diff --git a/Items/VanillaArmorChanges/VanillaArmorChangeManager.cs b/Items/VanillaArmorChanges/VanillaArmorChangeManager.cs index 9de535f8ee..ae22039d7d 100644 --- a/Items/VanillaArmorChanges/VanillaArmorChangeManager.cs +++ b/Items/VanillaArmorChanges/VanillaArmorChangeManager.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Items.VanillaArmorChanges ArmorChanges[i].AlternativeBodyPieceIDs.Contains(checkItem.type); bool isValidLegPiece = (ArmorChanges[i].LegPieceID ?? ItemID.None) == checkItem.type || ArmorChanges[i].AlternativeLegPieceIDs.Contains(checkItem.type); - if (isValidHeadPiece || isValidBodyPiece || isValidLegPiece) + if ((isValidHeadPiece || isValidBodyPiece || isValidLegPiece) && !ArmorChanges[i].NeedsToCreateSetBonusTextManually) ArmorChanges[i].UpdateSetBonusText(ref setBonusText); } } diff --git a/Items/Weapons/DraedonsArsenal/GatlingLaser.cs b/Items/Weapons/DraedonsArsenal/GatlingLaser.cs index 50d42f7e54..39862cc24f 100644 --- a/Items/Weapons/DraedonsArsenal/GatlingLaser.cs +++ b/Items/Weapons/DraedonsArsenal/GatlingLaser.cs @@ -30,14 +30,14 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.width = 43; Item.height = 24; Item.DamageType = DamageClass.Magic; - Item.damage = 50; + Item.damage = 43; Item.knockBack = 1f; Item.useTime = 2; Item.useAnimation = 2; Item.noUseGraphic = true; Item.autoReuse = false; Item.channel = true; - Item.mana = 6; + Item.mana = 4; Item.useStyle = ItemUseStyleID.Shoot; Item.UseSound = FireSound; diff --git a/Items/Weapons/Magic/AcidGun.cs b/Items/Weapons/Magic/AcidGun.cs index f5c749caee..b432f99433 100644 --- a/Items/Weapons/Magic/AcidGun.cs +++ b/Items/Weapons/Magic/AcidGun.cs @@ -35,14 +35,11 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float angle = MathHelper.Lerp(-0.145f, 0.145f, 1f / 3f); - int acid1 = Projectile.NewProjectile(source, position, velocity.RotatedBy(angle), type, damage, knockback, player.whoAmI); + int acid1 = Projectile.NewProjectile(source, position, velocity.RotatedBy(MathHelper.ToRadians(-8f)), type, damage, knockback, player.whoAmI); - angle = MathHelper.Lerp(-0.145f, 0.145f, 2f / 3f); - int acid2 = Projectile.NewProjectile(source, position, velocity.RotatedBy(angle), type, damage, knockback, player.whoAmI); + int acid2 = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); - angle = MathHelper.Lerp(-0.145f, 0.145f, 1f); - int acid3 = Projectile.NewProjectile(source, position, velocity.RotatedBy(angle), type, damage, knockback, player.whoAmI); + int acid3 = Projectile.NewProjectile(source, position, velocity.RotatedBy(MathHelper.ToRadians(8f)), type, damage, knockback, player.whoAmI); // Keep track of the other 2 acid streams if (Main.projectile.IndexInRange(acid1)) diff --git a/Items/Weapons/Magic/AlphaRay.cs b/Items/Weapons/Magic/AlphaRay.cs index 14350ef07e..b4e96df9b2 100644 --- a/Items/Weapons/Magic/AlphaRay.cs +++ b/Items/Weapons/Magic/AlphaRay.cs @@ -59,23 +59,23 @@ namespace CalamityMod.Items.Weapons.Magic } else { - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num117 = 0.314159274f; - int num118 = 3; - Vector2 vector7 = velocity; - vector7.Normalize(); - vector7 *= 80f; - bool flag11 = Collision.CanHit(vector2, 0, 0, vector2 + vector7, 0, 0); - for (int num119 = 0; num119 < num118; num119++) + Vector2 laserSpawnPos = player.RotatedRelativePoint(player.MountedCenter, true); + float tenthPi = 0.314159274f; + int laserAmt = 3; + Vector2 laserVelocity = velocity; + laserVelocity.Normalize(); + laserVelocity *= 80f; + bool laserHitsTiles = Collision.CanHit(laserSpawnPos, 0, 0, laserSpawnPos + laserVelocity, 0, 0); + for (int i = 0; i < laserAmt; i++) { - float num120 = (float)num119 - ((float)num118 - 1f) / 2f; - Vector2 value9 = vector7.RotatedBy((double)(num117 * num120), default); - if (!flag11) + float laserOffset = (float)i - ((float)laserAmt - 1f) / 2f; + Vector2 offsetSpawnPos = laserVelocity.RotatedBy((double)(tenthPi * laserOffset), default); + if (!laserHitsTiles) { - value9 -= vector7; + offsetSpawnPos -= laserVelocity; } - Projectile.NewProjectile(source, vector2.X + value9.X, vector2.Y + value9.Y, velocity.X * 1.5f, velocity.Y * 1.5f, type, (int)(damage * 0.8), knockback, player.whoAmI); - int laser = Projectile.NewProjectile(source, vector2.X + value9.X, vector2.Y + value9.Y, velocity.X * 2f, velocity.Y * 2f, ProjectileID.LaserMachinegunLaser, (int)(damage * 0.4), knockback * 0.4f, player.whoAmI); + Projectile.NewProjectile(source, laserSpawnPos.X + offsetSpawnPos.X, laserSpawnPos.Y + offsetSpawnPos.Y, velocity.X * 1.5f, velocity.Y * 1.5f, type, (int)(damage * 0.8), knockback, player.whoAmI); + int laser = Projectile.NewProjectile(source, laserSpawnPos.X + offsetSpawnPos.X, laserSpawnPos.Y + offsetSpawnPos.Y, velocity.X * 2f, velocity.Y * 2f, ProjectileID.LaserMachinegunLaser, (int)(damage * 0.4), knockback * 0.4f, player.whoAmI); Main.projectile[laser].timeLeft = 120; Main.projectile[laser].tileCollide = false; } diff --git a/Items/Weapons/Magic/ArchAmaryllis.cs b/Items/Weapons/Magic/ArchAmaryllis.cs index cf022ba0b0..80e5623abd 100644 --- a/Items/Weapons/Magic/ArchAmaryllis.cs +++ b/Items/Weapons/Magic/ArchAmaryllis.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - Item.damage = 75; + Item.damage = 58; Item.DamageType = DamageClass.Magic; Item.mana = 10; Item.width = 66; diff --git a/Items/Weapons/Magic/AsteroidStaff.cs b/Items/Weapons/Magic/AsteroidStaff.cs index bc438bcdaa..ae19993ce5 100644 --- a/Items/Weapons/Magic/AsteroidStaff.cs +++ b/Items/Weapons/Magic/AsteroidStaff.cs @@ -39,49 +39,49 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float meteorSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float meteorSpawnXPos = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float meteorSpawnYPos = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + meteorSpawnYPos = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float meteorSpawnDist = (float)Math.Sqrt((double)(meteorSpawnXPos * meteorSpawnXPos + meteorSpawnYPos * meteorSpawnYPos)); + if ((float.IsNaN(meteorSpawnXPos) && float.IsNaN(meteorSpawnYPos)) || (meteorSpawnXPos == 0f && meteorSpawnYPos == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + meteorSpawnXPos = (float)player.direction; + meteorSpawnYPos = 0f; + meteorSpawnDist = meteorSpeed; } else { - num80 = num72 / num80; + meteorSpawnDist = meteorSpeed / meteorSpawnDist; } int asteroidAmt = 3; - for (int num113 = 0; num113 < asteroidAmt; num113++) + for (int i = 0; i < asteroidAmt; i++) { - vector2 = new Vector2(player.Center.X + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num113); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X + (float)Main.rand.Next(-40, 41) * 0.03f; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.Center.X + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + meteorSpawnXPos = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X + (float)Main.rand.Next(-40, 41) * 0.03f; + meteorSpawnYPos = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (meteorSpawnYPos < 0f) { - num79 *= -1f; + meteorSpawnYPos *= -1f; } - if (num79 < 20f) + if (meteorSpawnYPos < 20f) { - num79 = 20f; + meteorSpawnYPos = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float num114 = num78; - float num115 = num79 + (float)Main.rand.Next(-40, 41) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, num114 * 0.75f, num115 * 0.75f, type, damage, knockback, player.whoAmI, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f); + meteorSpawnDist = (float)Math.Sqrt((double)(meteorSpawnXPos * meteorSpawnXPos + meteorSpawnYPos * meteorSpawnYPos)); + meteorSpawnDist = meteorSpeed / meteorSpawnDist; + meteorSpawnXPos *= meteorSpawnDist; + meteorSpawnYPos *= meteorSpawnDist; + float meteorSpawnXOffset = meteorSpawnXPos; + float meteorSpawnYOffset = meteorSpawnYPos + (float)Main.rand.Next(-40, 41) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, meteorSpawnXOffset * 0.75f, meteorSpawnYOffset * 0.75f, type, damage, knockback, player.whoAmI, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f); } return false; } diff --git a/Items/Weapons/Magic/AstralStaff.cs b/Items/Weapons/Magic/AstralStaff.cs index 9d77ed4689..e657810bd8 100644 --- a/Items/Weapons/Magic/AstralStaff.cs +++ b/Items/Weapons/Magic/AstralStaff.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - Item.damage = 270; + Item.damage = 245; Item.DamageType = DamageClass.Magic; Item.mana = 26; Item.width = 86; diff --git a/Items/Weapons/Magic/AstralachneaStaff.cs b/Items/Weapons/Magic/AstralachneaStaff.cs index 1c1724dfee..0469e4db18 100644 --- a/Items/Weapons/Magic/AstralachneaStaff.cs +++ b/Items/Weapons/Magic/AstralachneaStaff.cs @@ -38,14 +38,12 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - int i = Main.myPlayer; - float num72 = Item.shootSpeed; - int num73 = damage; - float num74 = knockback; - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + int j = Main.myPlayer; + float fangSpeed = Item.shootSpeed; + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); int spikeAmount = 4; if (Main.rand.NextBool(3)) { @@ -59,20 +57,20 @@ namespace CalamityMod.Items.Weapons.Magic { spikeAmount += 2; } - for (int num131 = 0; num131 < spikeAmount; num131++) + for (int i = 0; i < spikeAmount; i++) { - float num132 = num78; - float num133 = num79; - float num134 = 0.05f * (float)num131; - num132 += (float)Main.rand.Next(-400, 400) * num134; - num133 += (float)Main.rand.Next(-400, 400) * num134; - num80 = (float)Math.Sqrt((double)(num132 * num132 + num133 * num133)); - num80 = num72 / num80; - num132 *= num80; - num133 *= num80; - float x2 = vector2.X; - float y2 = vector2.Y; - Projectile.NewProjectile(source, x2, y2, num132, num133, ModContent.ProjectileType(), num73, num74, i, 0f, 0f); + float fangSpawnX = mouseXDist; + float fangSpawnY = mouseYDist; + float offsetDampener = 0.05f * (float)i; + fangSpawnX += (float)Main.rand.Next(-400, 400) * offsetDampener; + fangSpawnY += (float)Main.rand.Next(-400, 400) * offsetDampener; + float fangDistance = (float)Math.Sqrt((double)(fangSpawnX * fangSpawnX + fangSpawnY * fangSpawnY)); + fangDistance = fangSpeed / fangDistance; + fangSpawnX *= fangDistance; + fangSpawnY *= fangDistance; + float x2 = realPlayerPos.X; + float y2 = realPlayerPos.Y; + Projectile.NewProjectile(source, x2, y2, fangSpawnX, fangSpawnY, ModContent.ProjectileType(), damage, knockback, i, 0f, 0f); } return false; } diff --git a/Items/Weapons/Magic/Atlantis.cs b/Items/Weapons/Magic/Atlantis.cs index c0087adfb4..fd7d2b965d 100644 --- a/Items/Weapons/Magic/Atlantis.cs +++ b/Items/Weapons/Magic/Atlantis.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - Item.damage = 70; + Item.damage = 82; Item.DamageType = DamageClass.Magic; Item.mana = 12; Item.width = 28; @@ -41,7 +41,7 @@ namespace CalamityMod.Items.Weapons.Magic if (Main.zenithWorld) { bool devourer = DownedBossSystem.downedDoG; - float damageMult = 1f + (devourer ? (418f / 70f - 1f) : 0f); + float damageMult = 1f + (devourer ? (430f / 82f - 1f) : 0f); damage *= damageMult; } } diff --git a/Items/Weapons/Magic/AuguroftheElements.cs b/Items/Weapons/Magic/AuguroftheElements.cs index 50bfc5e410..72f04b7502 100644 --- a/Items/Weapons/Magic/AuguroftheElements.cs +++ b/Items/Weapons/Magic/AuguroftheElements.cs @@ -35,27 +35,27 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - Vector2 value2 = new Vector2(num78, num79); - value2.Normalize(); - Vector2 value3 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - value3.Normalize(); - value2 = value2 * 6f + value3; - value2.Normalize(); - value2 *= Item.shootSpeed; - float num91 = (float)Main.rand.Next(10, 50) * 0.001f; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + Vector2 tentacleVelocity = new Vector2(mouseXDist, mouseYDist); + tentacleVelocity.Normalize(); + Vector2 tentacleRandVelocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + tentacleRandVelocity.Normalize(); + tentacleVelocity = tentacleVelocity * 6f + tentacleRandVelocity; + tentacleVelocity.Normalize(); + tentacleVelocity *= Item.shootSpeed; + float tentacleYDirection = (float)Main.rand.Next(10, 50) * 0.001f; if (Main.rand.NextBool()) { - num91 *= -1f; + tentacleYDirection *= -1f; } - float num92 = (float)Main.rand.Next(10, 50) * 0.001f; + float tentacleXDirection = (float)Main.rand.Next(10, 50) * 0.001f; if (Main.rand.NextBool()) { - num92 *= -1f; + tentacleXDirection *= -1f; } - Projectile.NewProjectile(source, vector2, value2, type, damage, knockback, player.whoAmI, num92, num91); + Projectile.NewProjectile(source, realPlayerPos, tentacleVelocity, type, damage, knockback, player.whoAmI, tentacleXDirection, tentacleYDirection); return false; } diff --git a/Items/Weapons/Magic/BloodBath.cs b/Items/Weapons/Magic/BloodBath.cs index 43c702f8c4..7f291993cd 100644 --- a/Items/Weapons/Magic/BloodBath.cs +++ b/Items/Weapons/Magic/BloodBath.cs @@ -40,57 +40,57 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float bloodSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXPos = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYPos = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYPos = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXPos * mouseXPos + mouseYPos * mouseYPos)); + if ((float.IsNaN(mouseXPos) && float.IsNaN(mouseYPos)) || (mouseXPos == 0f && mouseYPos == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXPos = (float)player.direction; + mouseYPos = 0f; + mouseDistance = bloodSpeed; } else { - num80 = num72 / num80; + mouseDistance = bloodSpeed / mouseDistance; } - int num107 = 2; + int bloodAmt = 2; if (Main.rand.NextBool(3)) { - num107++; + bloodAmt++; } if (Main.rand.NextBool(3)) { - num107++; + bloodAmt++; } - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < bloodAmt; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXPos = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYPos = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYPos < 0f) { - num79 *= -1f; + mouseYPos *= -1f; } - if (num79 < 20f) + if (mouseYPos < 20f) { - num79 = 20f; + mouseYPos = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-30, 31) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-30, 31) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, (float)Main.rand.Next(15)); + mouseDistance = (float)Math.Sqrt((double)(mouseXPos * mouseXPos + mouseYPos * mouseYPos)); + mouseDistance = bloodSpeed / mouseDistance; + mouseXPos *= mouseDistance; + mouseYPos *= mouseDistance; + float speedX4 = mouseXPos + (float)Main.rand.Next(-30, 31) * 0.02f; + float speedY5 = mouseYPos + (float)Main.rand.Next(-30, 31) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, (float)Main.rand.Next(15)); } return false; } diff --git a/Items/Weapons/Magic/ClamorNoctus.cs b/Items/Weapons/Magic/ClamorNoctus.cs index ec774f15c5..fc307c109e 100644 --- a/Items/Weapons/Magic/ClamorNoctus.cs +++ b/Items/Weapons/Magic/ClamorNoctus.cs @@ -42,28 +42,28 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float projSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - int num107 = 3; - for (int num108 = 0; num108 < num107; num108++) + int projAmt = 3; + for (int i = 0; i < projAmt; i++) { float damageMult = 1f; float kbMult = 1f; @@ -76,26 +76,26 @@ namespace CalamityMod.Items.Weapons.Magic damageMult = 25f; kbMult = 1.5f; } - vector2 = new Vector2(player.Center.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.Center.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.Center.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.Center.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-30, 31) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-30, 31) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, (int)(damage * damageMult), (int)(knockback * kbMult), player.whoAmI, 0f, (float)Main.rand.Next(15)); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = projSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-30, 31) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-30, 31) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, (int)(damage * damageMult), (int)(knockback * kbMult), player.whoAmI, 0f, (float)Main.rand.Next(15)); } return false; } diff --git a/Items/Weapons/Magic/CosmicRainbow.cs b/Items/Weapons/Magic/CosmicRainbow.cs index 7a247f4a57..b12a27a960 100644 --- a/Items/Weapons/Magic/CosmicRainbow.cs +++ b/Items/Weapons/Magic/CosmicRainbow.cs @@ -34,66 +34,66 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { Vector2 vector = player.RotatedRelativePoint(player.MountedCenter, true); - float num117 = 0.314159274f; - int num118 = 3; - Vector2 vector7 = velocity; - vector7.Normalize(); - vector7 *= 60f; - bool flag11 = Collision.CanHit(vector, 0, 0, vector + vector7, 0, 0); - for (int num119 = 0; num119 < num118; num119++) + float tenthPi = 0.314159274f; + int directRainbowAmt = 3; + Vector2 directRainbowVel = velocity; + directRainbowVel.Normalize(); + directRainbowVel *= 60f; + bool rainbowHitsTiles = Collision.CanHit(vector, 0, 0, vector + directRainbowVel, 0, 0); + for (int i = 0; i < directRainbowAmt; i++) { - float num120 = (float)num119 - ((float)num118 - 1f) / 2f; - Vector2 value9 = vector7.RotatedBy((double)(num117 * num120), default); - if (!flag11) + float rainbowOffset = (float)i - ((float)directRainbowAmt - 1f) / 2f; + Vector2 offsetSpawnPos = directRainbowVel.RotatedBy((double)(tenthPi * rainbowOffset), default); + if (!rainbowHitsTiles) { - value9 -= vector7; + offsetSpawnPos -= directRainbowVel; } - int rainbow = Projectile.NewProjectile(source, vector.X + value9.X, vector.Y + value9.Y, velocity.X, velocity.Y, type, damage, knockback, player.whoAmI); + int rainbow = Projectile.NewProjectile(source, vector.X + offsetSpawnPos.X, vector.Y + offsetSpawnPos.Y, velocity.X, velocity.Y, type, damage, knockback, player.whoAmI); Main.projectile[rainbow].usesLocalNPCImmunity = true; Main.projectile[rainbow].localNPCHitCooldown = 10; } - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float skyRainbowSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = skyRainbowSpeed; } else { - num80 = num72 / num80; + mouseDistance = skyRainbowSpeed / mouseDistance; } - for (int num108 = 0; num108 < 2; num108++) + for (int j = 0; j < 2; j++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * j); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-15, 16) * 0.01f; - float speedY5 = num79 + (float)Main.rand.Next(-15, 16) * 0.01f; - int rainbow2 = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = skyRainbowSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-15, 16) * 0.01f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-15, 16) * 0.01f; + int rainbow2 = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI); Main.projectile[rainbow2].usesLocalNPCImmunity = true; Main.projectile[rainbow2].localNPCHitCooldown = 10; } diff --git a/Items/Weapons/Magic/DeathhailStaff.cs b/Items/Weapons/Magic/DeathhailStaff.cs index 05d3b24171..16c43c5660 100644 --- a/Items/Weapons/Magic/DeathhailStaff.cs +++ b/Items/Weapons/Magic/DeathhailStaff.cs @@ -45,56 +45,53 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int i = Main.myPlayer; - float num72 = Item.shootSpeed; - int num73 = damage; - float num74 = knockback; - num74 = player.GetWeaponKnockback(Item, num74); + int j = Main.myPlayer; + float beamSpeed = Item.shootSpeed; + float beamKnockback = knockback; + beamKnockback = player.GetWeaponKnockback(Item, beamKnockback); player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - Vector2 value = Vector2.UnitX.RotatedBy((double)player.fullRotation, default); - Vector2 vector3 = Main.MouseWorld - vector2; - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = beamSpeed; } else { - num80 = num72 / num80; + mouseDistance = beamSpeed / mouseDistance; } int numLasers = 2; - for (int num108 = 0; num108 < numLasers; num108++) + for (int i = 0; i < numLasers; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(91) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(91) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-50, 51) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-50, 51) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, num73, num74, i, 0f, 0f); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = beamSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-50, 51) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-50, 51) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, beamKnockback, i, 0f, 0f); } return false; } diff --git a/Items/Weapons/Magic/DivineRetribution.cs b/Items/Weapons/Magic/DivineRetribution.cs index bbba73c6a0..3393d825bf 100644 --- a/Items/Weapons/Magic/DivineRetribution.cs +++ b/Items/Weapons/Magic/DivineRetribution.cs @@ -44,47 +44,47 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float spearSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; + mouseXDist = (float)player.direction; } else { - num80 = num72 / num80; + mouseDistance = spearSpeed / mouseDistance; } int numProjectiles = 5; for (int i = 0; i < numProjectiles; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(51) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - /* - */ player.position.X), player.MountedCenter.Y + 600f); //- - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-50, 51); //200 - vector2.Y += (float)(100 * i); //-= - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; //+ - - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; //+ - - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(51) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - /* - */ player.position.X), player.MountedCenter.Y + 600f); //- + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-50, 51); //200 + realPlayerPos.Y += (float)(100 * i); //-= + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; //+ - + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; //+ - + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX6 = num78 + (float)Main.rand.Next(-60, 61) * 0.02f; - float speedY7 = num79 + (float)Main.rand.Next(-60, 61) * 0.02f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = spearSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX6 = mouseXDist + (float)Main.rand.Next(-60, 61) * 0.02f; + float speedY7 = mouseYDist + (float)Main.rand.Next(-60, 61) * 0.02f; float ai1 = Main.rand.NextFloat() + 0.5f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX6, -speedY7, type, damage, knockback, player.whoAmI, 0.0f, ai1); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX6, -speedY7, type, damage, knockback, player.whoAmI, 0.0f, ai1); } return false; } diff --git a/Items/Weapons/Magic/Downpour.cs b/Items/Weapons/Magic/Downpour.cs index 39601d3aba..de58aebfd5 100644 --- a/Items/Weapons/Magic/Downpour.cs +++ b/Items/Weapons/Magic/Downpour.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.rare = ItemRarityID.Pink; Item.UseSound = SoundID.Item13; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); + Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 14f; } diff --git a/Items/Weapons/Magic/EidolicWail.cs b/Items/Weapons/Magic/EidolicWail.cs index f50b908aac..20906423f7 100644 --- a/Items/Weapons/Magic/EidolicWail.cs +++ b/Items/Weapons/Magic/EidolicWail.cs @@ -13,9 +13,9 @@ namespace CalamityMod.Items.Weapons.Magic public new string LocalizationCategory => "Items.Weapons.Magic"; public override void SetDefaults() { - Item.damage = 126; + Item.damage = 1248; Item.DamageType = DamageClass.Magic; - Item.mana = 10; + Item.mana = 30; Item.width = 60; Item.height = 60; Item.useTime = 12; @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.value = CalamityGlobalItem.Rarity13BuyPrice; Item.UseSound = CommonCalamitySounds.WyrmScreamSound; Item.autoReuse = true; - Item.shootSpeed = 8f; + Item.shootSpeed = 14.5f; Item.shoot = ModContent.ProjectileType(); Item.rare = ModContent.RarityType(); } diff --git a/Items/Weapons/Magic/EidolonStaff.cs b/Items/Weapons/Magic/EidolonStaff.cs index c76b80157c..b64847055f 100644 --- a/Items/Weapons/Magic/EidolonStaff.cs +++ b/Items/Weapons/Magic/EidolonStaff.cs @@ -41,35 +41,35 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num72 = Item.shootSpeed; - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float projSpeed = Item.shootSpeed; + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); int stardustAmt = 5; - float num132 = num78; - float num133 = num79; - num80 = (float)Math.Sqrt((double)(num132 * num132 + num133 * num133)); - num80 = num72 / num80; - num132 *= num80; - num133 *= num80; - float x2 = vector2.X; - float y2 = vector2.Y; - Projectile.NewProjectile(source, x2, y2, num132, num133, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + float mouseXCopy = mouseXDist; + float mouseYCopy = mouseYDist; + mouseDistance = (float)Math.Sqrt((double)(mouseXCopy * mouseXCopy + mouseYCopy * mouseYCopy)); + mouseDistance = projSpeed / mouseDistance; + mouseXCopy *= mouseDistance; + mouseYCopy *= mouseDistance; + float x2 = realPlayerPos.X; + float y2 = realPlayerPos.Y; + Projectile.NewProjectile(source, x2, y2, mouseXCopy, mouseYCopy, ModContent.ProjectileType(), damage, knockback, player.whoAmI); for (int i = 0; i < stardustAmt; i++) { - num132 = num78; - num133 = num79; - float num134 = 0.05f * (float)i; - num132 += (float)Main.rand.Next(-90, 91) * num134; - num133 += (float)Main.rand.Next(-90, 91) * num134; - num80 = (float)Math.Sqrt((double)(num132 * num132 + num133 * num133)); - num80 = num72 / num80; - num132 *= num80; - num133 *= num80; - x2 = vector2.X; - y2 = vector2.Y; - Projectile.NewProjectile(source, x2, y2, num132, num133, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + mouseXCopy = mouseXDist; + mouseYCopy = mouseYDist; + float randOffsetDampener = 0.05f * (float)i; + mouseXCopy += (float)Main.rand.Next(-90, 91) * randOffsetDampener; + mouseYCopy += (float)Main.rand.Next(-90, 91) * randOffsetDampener; + mouseDistance = (float)Math.Sqrt((double)(mouseXCopy * mouseXCopy + mouseYCopy * mouseYCopy)); + mouseDistance = projSpeed / mouseDistance; + mouseXCopy *= mouseDistance; + mouseYCopy *= mouseDistance; + x2 = realPlayerPos.X; + y2 = realPlayerPos.Y; + Projectile.NewProjectile(source, x2, y2, mouseXCopy, mouseYCopy, ModContent.ProjectileType(), damage, knockback, player.whoAmI); } return false; } diff --git a/Items/Weapons/Magic/EldritchTome.cs b/Items/Weapons/Magic/EldritchTome.cs index a3d0c6b179..f22178553a 100644 --- a/Items/Weapons/Magic/EldritchTome.cs +++ b/Items/Weapons/Magic/EldritchTome.cs @@ -36,31 +36,30 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { int i = Main.myPlayer; - int num73 = damage; - float num74 = knockback; - num74 = player.GetWeaponKnockback(Item, num74); + float playerKnockback = knockback; + playerKnockback = player.GetWeaponKnockback(Item, playerKnockback); player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - Vector2 value2 = new Vector2(num78, num79); - value2.Normalize(); - Vector2 value3 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - value3.Normalize(); - value2 = value2 * 4f + value3; - value2.Normalize(); - value2 *= Item.shootSpeed; - float num91 = (float)Main.rand.Next(10, 80) * 0.001f; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + Vector2 tentacleVelocity = new Vector2(mouseXDist, mouseYDist); + tentacleVelocity.Normalize(); + Vector2 tentacleRandVelocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + tentacleRandVelocity.Normalize(); + tentacleVelocity = tentacleVelocity * 4f + tentacleRandVelocity; + tentacleVelocity.Normalize(); + tentacleVelocity *= Item.shootSpeed; + float tentacleYDirection = (float)Main.rand.Next(10, 80) * 0.001f; if (Main.rand.NextBool()) { - num91 *= -1f; + tentacleYDirection *= -1f; } - float num92 = (float)Main.rand.Next(10, 80) * 0.001f; + float tentacleXDirection = (float)Main.rand.Next(10, 80) * 0.001f; if (Main.rand.NextBool()) { - num92 *= -1f; + tentacleXDirection *= -1f; } - Projectile.NewProjectile(source, vector2, value2, ModContent.ProjectileType(), num73, num74, i, num92, num91); + Projectile.NewProjectile(source, realPlayerPos, tentacleVelocity, ModContent.ProjectileType(), damage, playerKnockback, i, tentacleXDirection, tentacleYDirection); return false; } } diff --git a/Items/Weapons/Magic/FatesReveal.cs b/Items/Weapons/Magic/FatesReveal.cs index 138e10d3fa..07be0fb55d 100644 --- a/Items/Weapons/Magic/FatesReveal.cs +++ b/Items/Weapons/Magic/FatesReveal.cs @@ -46,33 +46,33 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Vector2 vector = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = Item.shootSpeed; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = Item.shootSpeed; } else { - num80 = Item.shootSpeed / num80; + mouseDistance = Item.shootSpeed / mouseDistance; } - vector += new Vector2(num78, num79); + realPlayerPos += new Vector2(mouseXDist, mouseYDist); int numProjectiles = 5; for (int i = 0; i < numProjectiles; i++) { - vector.X += (float)Main.rand.Next(-100, 101); - vector.Y += (float)(Main.rand.Next(-25, 26) * i); - float spawnX = vector.X; - float spawnY = vector.Y; + realPlayerPos.X += (float)Main.rand.Next(-100, 101); + realPlayerPos.Y += (float)(Main.rand.Next(-25, 26) * i); + float spawnX = realPlayerPos.X; + float spawnY = realPlayerPos.Y; Projectile.NewProjectile(source, spawnX, spawnY, 0f, 0f, type, damage, knockback, player.whoAmI, 0f, (float)Main.rand.Next(3)); } return false; diff --git a/Items/Weapons/Magic/Genisis.cs b/Items/Weapons/Magic/Genisis.cs index fcc7207011..401e372148 100644 --- a/Items/Weapons/Magic/Genisis.cs +++ b/Items/Weapons/Magic/Genisis.cs @@ -36,10 +36,9 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, 0f); - int num6 = 3; float SpeedX = velocity.X + (float)Main.rand.Next(-20, 21) * 0.05f; float SpeedY = velocity.Y + (float)Main.rand.Next(-20, 21) * 0.05f; - for (int index = 0; index < num6; ++index) + for (int index = 0; index < 3; ++index) { int projectile = Projectile.NewProjectile(source, position.X, position.Y, SpeedX * 1.05f, SpeedY * 1.05f, ProjectileID.LaserMachinegunLaser, (int)(damage * 0.65), knockback * 0.6f, player.whoAmI, 0f, 0f); Main.projectile[projectile].timeLeft = 120; diff --git a/Items/Weapons/Magic/HellwingStaff.cs b/Items/Weapons/Magic/HellwingStaff.cs index c15d2fbaf6..016d50affe 100644 --- a/Items/Weapons/Magic/HellwingStaff.cs +++ b/Items/Weapons/Magic/HellwingStaff.cs @@ -39,49 +39,48 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = velocity.Length(); - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X + vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y + vector2.Y; + float projSpeed = velocity.Length(); + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X + realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y + realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight + (float)Main.mouseY + vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight + (float)Main.mouseY + realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - int num130 = 4; - for (int num131 = 0; num131 < num130; num131++) + for (int i = 0; i < 4; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num131); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-40, 41) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-40, 41) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, 0f); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = projSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-40, 41) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-40, 41) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, 0f); } return false; } diff --git a/Items/Weapons/Magic/IceBarrage.cs b/Items/Weapons/Magic/IceBarrage.cs index bb6737bed0..59d80d7201 100644 --- a/Items/Weapons/Magic/IceBarrage.cs +++ b/Items/Weapons/Magic/IceBarrage.cs @@ -46,10 +46,10 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - vector2.X = Main.mouseX + Main.screenPosition.X; - vector2.Y = Main.mouseY + Main.screenPosition.Y; - Projectile.NewProjectile(source, vector2, Vector2.Zero, type, damage, knockback, player.whoAmI, 0f, 0f); + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + realPlayerPos.X = Main.mouseX + Main.screenPosition.X; + realPlayerPos.Y = Main.mouseY + Main.screenPosition.Y; + Projectile.NewProjectile(source, realPlayerPos, Vector2.Zero, type, damage, knockback, player.whoAmI, 0f, 0f); CalamityGlobalItem.ConsumeAdditionalAmmo(player, Item, 2); diff --git a/Items/Weapons/Magic/IcicleStaff.cs b/Items/Weapons/Magic/IcicleStaff.cs index 9a9f8d0d2e..82a5db852d 100644 --- a/Items/Weapons/Magic/IcicleStaff.cs +++ b/Items/Weapons/Magic/IcicleStaff.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Items.Weapons.Magic Item.damage = 10; Item.DamageType = DamageClass.Magic; Item.mana = 6; - Item.width = 44; - Item.height = 44; + Item.width = 38; + Item.height = 42; Item.useTime = 7; Item.useAnimation = 14; Item.useStyle = ItemUseStyleID.Shoot; @@ -40,49 +40,48 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { int i = Main.myPlayer; - float num72 = velocity.Length(); - int num73 = damage; - float num74 = knockback; - num74 = player.GetWeaponKnockback(Item, num74); + float icicleSpeed = velocity.Length(); + float playerKnockback = knockback; + playerKnockback = player.GetWeaponKnockback(Item, playerKnockback); player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX - Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY - Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX - Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY - Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = icicleSpeed; } else { - num80 = num72 / num80; + mouseDistance = icicleSpeed / mouseDistance; } - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78; - float speedY5 = num79 + (float)Main.rand.Next(-40, 41) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), num73, num74, i, 0f, (float)Main.rand.Next(10)); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = icicleSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist; + float speedY5 = mouseYDist + (float)Main.rand.Next(-40, 41) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), damage, playerKnockback, i, 0f, (float)Main.rand.Next(10)); return false; } diff --git a/Items/Weapons/Magic/IcicleStaff.png b/Items/Weapons/Magic/IcicleStaff.png index 3d0dfd3b9a..0fbbbae95f 100644 Binary files a/Items/Weapons/Magic/IcicleStaff.png and b/Items/Weapons/Magic/IcicleStaff.png differ diff --git a/Items/Weapons/Magic/InfernalRift.cs b/Items/Weapons/Magic/InfernalRift.cs index 9131f0cc1c..0b024aef5b 100644 --- a/Items/Weapons/Magic/InfernalRift.cs +++ b/Items/Weapons/Magic/InfernalRift.cs @@ -44,29 +44,29 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num72 = Item.shootSpeed; - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float projSpeed = Item.shootSpeed; + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; float f = Main.rand.NextFloat() * MathHelper.TwoPi; - float value12 = 20f; - float value13 = 60f; - Vector2 vector13 = vector2 + f.ToRotationVector2() * MathHelper.Lerp(value12, value13, Main.rand.NextFloat()); - for (int num202 = 0; num202 < 50; num202++) + float lowerLerpValue = 20f; + float upperLerpValue = 60f; + Vector2 projSpawnOffset = realPlayerPos + f.ToRotationVector2() * MathHelper.Lerp(lowerLerpValue, upperLerpValue, Main.rand.NextFloat()); + for (int i = 0; i < 50; i++) { - vector13 = vector2 + f.ToRotationVector2() * MathHelper.Lerp(value12, value13, Main.rand.NextFloat()); - if (Collision.CanHit(vector2, 0, 0, vector13 + (vector13 - vector2).SafeNormalize(Vector2.UnitX) * 8f, 0, 0)) + projSpawnOffset = realPlayerPos + f.ToRotationVector2() * MathHelper.Lerp(lowerLerpValue, upperLerpValue, Main.rand.NextFloat()); + if (Collision.CanHit(realPlayerPos, 0, 0, projSpawnOffset + (projSpawnOffset - realPlayerPos).SafeNormalize(Vector2.UnitX) * 8f, 0, 0)) { break; } f = Main.rand.NextFloat() * MathHelper.TwoPi; } Vector2 mouseWorld = Main.MouseWorld; - Vector2 vector14 = mouseWorld - vector13; - Vector2 vector15 = new Vector2(num78, num79).SafeNormalize(Vector2.UnitY) * num72; - vector14 = vector14.SafeNormalize(vector15) * num72; - vector14 = Vector2.Lerp(vector14, vector15, 0.25f); - Projectile.NewProjectile(source, vector13, vector14, type, damage, knockback, player.whoAmI, 0f, 0f); + Vector2 projSpawnPos = mouseWorld - projSpawnOffset; + Vector2 projVelocity = new Vector2(mouseXDist, mouseYDist).SafeNormalize(Vector2.UnitY) * projSpeed; + projSpawnPos = projSpawnPos.SafeNormalize(projVelocity) * projSpeed; + projSpawnPos = Vector2.Lerp(projSpawnPos, projVelocity, 0.25f); + Projectile.NewProjectile(source, projSpawnOffset, projSpawnPos, type, damage, knockback, player.whoAmI, 0f, 0f); return false; } diff --git a/Items/Weapons/Magic/Lazhar.cs b/Items/Weapons/Magic/Lazhar.cs index c7de8e024e..50b80c1261 100644 --- a/Items/Weapons/Magic/Lazhar.cs +++ b/Items/Weapons/Magic/Lazhar.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Weapons.Magic public new string LocalizationCategory => "Items.Weapons.Magic"; public override void SetDefaults() { - Item.damage = 80; + Item.damage = 76; Item.DamageType = DamageClass.Magic; Item.mana = 4; Item.width = 42; diff --git a/Items/Weapons/Magic/Mistlestorm.cs b/Items/Weapons/Magic/Mistlestorm.cs index 306f5055be..e4675f7a01 100644 --- a/Items/Weapons/Magic/Mistlestorm.cs +++ b/Items/Weapons/Magic/Mistlestorm.cs @@ -39,17 +39,17 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int num106 = 2 + Main.rand.Next(3); - for (int num107 = 0; num107 < num106; num107++) + int projAmt = 2 + Main.rand.Next(3); + for (int i = 0; i < projAmt; i++) { - float num110 = 0.025f * (float)num107; - velocity.X += (float)Main.rand.Next(-35, 36) * num110; - velocity.Y += (float)Main.rand.Next(-35, 36) * num110; - float num84 = velocity.Length(); - num84 = Item.shootSpeed / num84; - velocity.X *= num84; - velocity.Y *= num84; - Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, (float)Main.rand.Next(0, 10 * (num107 + 1)), 0f); + float randVelocityDampener = 0.025f * (float)i; + velocity.X += (float)Main.rand.Next(-35, 36) * randVelocityDampener; + velocity.Y += (float)Main.rand.Next(-35, 36) * randVelocityDampener; + float projDistance = velocity.Length(); + projDistance = Item.shootSpeed / projDistance; + velocity.X *= projDistance; + velocity.Y *= projDistance; + Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, (float)Main.rand.Next(0, 10 * (i + 1)), 0f); Projectile.NewProjectile(source, position, velocity, ProjectileID.Leaf, damage, knockback, player.whoAmI); } return false; diff --git a/Items/Weapons/Magic/GrandStaffoftheNebulaMage.cs b/Items/Weapons/Magic/NebulousCataclysm.cs similarity index 91% rename from Items/Weapons/Magic/GrandStaffoftheNebulaMage.cs rename to Items/Weapons/Magic/NebulousCataclysm.cs index f0e3b2863c..499c9b7599 100644 --- a/Items/Weapons/Magic/GrandStaffoftheNebulaMage.cs +++ b/Items/Weapons/Magic/NebulousCataclysm.cs @@ -9,7 +9,8 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class GrandStaffoftheNebulaMage : ModItem, ILocalizedModType + [LegacyName("GrandStaffoftheNebulaMage")] + public class NebulousCataclysm : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Magic"; public override void SetDefaults() @@ -30,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.value = CalamityGlobalItem.Rarity14BuyPrice; Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; - Item.shoot = ModContent.ProjectileType(); + Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 3f; } diff --git a/Items/Weapons/Magic/GrandStaffoftheNebulaMage.png b/Items/Weapons/Magic/NebulousCataclysm.png similarity index 100% rename from Items/Weapons/Magic/GrandStaffoftheNebulaMage.png rename to Items/Weapons/Magic/NebulousCataclysm.png diff --git a/Items/Weapons/Magic/NuclearFury.cs b/Items/Weapons/Magic/NuclearFury.cs index afa88f6865..b66ab1b7f3 100644 --- a/Items/Weapons/Magic/NuclearFury.cs +++ b/Items/Weapons/Magic/NuclearFury.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Magic for (int i = 0; i < 8; i++) { Vector2 ringVelocity = ((MathHelper.TwoPi * i / 8f) + velocity.ToRotation()).ToRotationVector2() * velocity.Length() * 0.5f; - Projectile.NewProjectile(source, position, ringVelocity, type, damage, knockback, Main.myPlayer); + Projectile.NewProjectile(source, position, ringVelocity, type, damage, knockback, Main.myPlayer, 0f, 0f); } return false; } diff --git a/Items/Weapons/Magic/PhoenixFlameBarrage.cs b/Items/Weapons/Magic/PhoenixFlameBarrage.cs index 130180ddb8..8f2a6f1573 100644 --- a/Items/Weapons/Magic/PhoenixFlameBarrage.cs +++ b/Items/Weapons/Magic/PhoenixFlameBarrage.cs @@ -40,58 +40,58 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; + float flameSpeed = Item.shootSpeed; player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = flameSpeed; } else { - num80 = num72 / num80; + mouseDistance = flameSpeed / mouseDistance; } - int num107 = 30; + int flameAmt = 30; if (Main.rand.NextBool(3)) { - num107++; + flameAmt++; } if (Main.rand.NextBool(3)) { - num107++; + flameAmt++; } - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < flameAmt; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-30, 31) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-30, 31) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, (float)Main.rand.Next(15)); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = flameSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-30, 31) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-30, 31) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, (float)Main.rand.Next(15)); } return false; } diff --git a/Items/Weapons/Magic/PlagueStaff.cs b/Items/Weapons/Magic/PlagueStaff.cs index 78dcc167f7..8340e7a905 100644 --- a/Items/Weapons/Magic/PlagueStaff.cs +++ b/Items/Weapons/Magic/PlagueStaff.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - Item.damage = 78; + Item.damage = 70; Item.DamageType = DamageClass.Magic; Item.mana = 22; Item.width = 46; diff --git a/Items/Weapons/Magic/StormSpray.cs b/Items/Weapons/Magic/SandstreamScepter.cs similarity index 61% rename from Items/Weapons/Magic/StormSpray.cs rename to Items/Weapons/Magic/SandstreamScepter.cs index e89082b240..373bad9e2e 100644 --- a/Items/Weapons/Magic/StormSpray.cs +++ b/Items/Weapons/Magic/SandstreamScepter.cs @@ -7,7 +7,8 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class StormSpray : ModItem, ILocalizedModType + [LegacyName("StormSpray")] + public class SandstreamScepter : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Magic"; public override void SetStaticDefaults() @@ -17,27 +18,27 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - Item.damage = 14; + Item.damage = 16; Item.DamageType = DamageClass.Magic; - Item.mana = 8; - Item.width = 42; - Item.height = 42; - Item.useTime = 33; - Item.useAnimation = 33; + Item.mana = 4; + Item.width = 46; + Item.height = 40; + Item.useTime = 20; + Item.useAnimation = 20; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.knockBack = 2f; + Item.knockBack = 1f; Item.value = CalamityGlobalItem.Rarity2BuyPrice; Item.rare = ItemRarityID.Green; - Item.UseSound = SoundID.Item13; + Item.UseSound = SoundID.Item72; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 11f; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0.0f, 0.0f); + Projectile.NewProjectile(source, position + velocity * 5, velocity, type, damage, knockback, player.whoAmI, 0.0f, 0.0f); return false; } } diff --git a/Items/Weapons/Magic/SandstreamScepter.png b/Items/Weapons/Magic/SandstreamScepter.png new file mode 100644 index 0000000000..c85eec12d1 Binary files /dev/null and b/Items/Weapons/Magic/SandstreamScepter.png differ diff --git a/Items/Weapons/Magic/Serpentine.cs b/Items/Weapons/Magic/Serpentine.cs index 2b1ff6d602..79be20f88e 100644 --- a/Items/Weapons/Magic/Serpentine.cs +++ b/Items/Weapons/Magic/Serpentine.cs @@ -13,13 +13,13 @@ namespace CalamityMod.Items.Weapons.Magic public new string LocalizationCategory => "Items.Weapons.Magic"; public override void SetDefaults() { - Item.damage = 14; + Item.damage = 10; Item.DamageType = DamageClass.Magic; Item.mana = 20; Item.width = 28; Item.height = 32; - Item.useTime = 20; - Item.useAnimation = 20; + Item.useTime = 35; + Item.useAnimation = 35; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 3f; @@ -34,31 +34,31 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { int owner = player.whoAmI; - float num72 = Item.shootSpeed; + float projSpeed = Item.shootSpeed; player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - Vector2 value = Vector2.UnitX.RotatedBy((double)player.fullRotation, default); - Vector2 vector3 = Main.MouseWorld - vector2; - float velX = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float velY = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + Vector2 projRotation = Vector2.UnitX.RotatedBy((double)player.fullRotation, default); + Vector2 projSpawnPos = Main.MouseWorld - realPlayerPos; + float velX = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float velY = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - velY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + velY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } float dist = (float)Math.Sqrt((double)(velX * velX + velY * velY)); if ((float.IsNaN(velX) && float.IsNaN(velY)) || (velX == 0f && velY == 0f)) { velX = (float)player.direction; velY = 0f; - dist = num72; + dist = projSpeed; } else { - dist = num72 / dist; + dist = projSpeed / dist; } - float num77 = Vector2.Dot(value, vector3); - if (num77 > 0f) + float projDirection = Vector2.Dot(projRotation, projSpawnPos); + if (projDirection > 0f) { player.ChangeDir(1); } @@ -68,8 +68,8 @@ namespace CalamityMod.Items.Weapons.Magic } //velX = 0f; //velY = 0f; - //vector2.X = (float)Main.mouseX + Main.screenPosition.X; - //vector2.Y = (float)Main.mouseY + Main.screenPosition.Y; + //realPlayerPos.X = (float)Main.mouseX + Main.screenPosition.X; + //realPlayerPos.Y = (float)Main.mouseY + Main.screenPosition.Y; int curr = Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, owner); int prev = curr; diff --git a/Items/Weapons/Magic/ShadecrystalTome.cs b/Items/Weapons/Magic/ShadecrystalTome.cs index a1eeec8c64..974d0ea9f7 100644 --- a/Items/Weapons/Magic/ShadecrystalTome.cs +++ b/Items/Weapons/Magic/ShadecrystalTome.cs @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int num6 = Main.rand.Next(1, 3); - for (int index = 0; index < num6; ++index) + int projAmt = Main.rand.Next(1, 3); + for (int index = 0; index < projAmt; ++index) { float SpeedX = velocity.X + Main.rand.Next(-40, 41) * 0.05f; float SpeedY = velocity.Y + Main.rand.Next(-40, 41) * 0.05f; diff --git a/Items/Weapons/Magic/ShadowboltStaff.cs b/Items/Weapons/Magic/ShadowboltStaff.cs index e348261959..755f497ea1 100644 --- a/Items/Weapons/Magic/ShadowboltStaff.cs +++ b/Items/Weapons/Magic/ShadowboltStaff.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - Item.damage = 250; + Item.damage = 280; Item.DamageType = DamageClass.Magic; Item.mana = 20; Item.width = 58; diff --git a/Items/Weapons/Magic/SkyGlaze.cs b/Items/Weapons/Magic/SkyGlaze.cs index 28062701e3..73c4148597 100644 --- a/Items/Weapons/Magic/SkyGlaze.cs +++ b/Items/Weapons/Magic/SkyGlaze.cs @@ -38,49 +38,49 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float featherSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = featherSpeed; } else { - num80 = num72 / num80; + mouseDistance = featherSpeed / mouseDistance; } int featherAmt = 3; - for (int num108 = 0; num108 < featherAmt; num108++) + for (int i = 0; i < featherAmt; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-30, 31) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-30, 31) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, (float)Main.rand.Next(15)); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = featherSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-30, 31) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-30, 31) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, (float)Main.rand.Next(15)); } return false; } diff --git a/Items/Weapons/Magic/StarShower.cs b/Items/Weapons/Magic/StarShower.cs index 942cd99b4c..f18d8c054c 100644 --- a/Items/Weapons/Magic/StarShower.cs +++ b/Items/Weapons/Magic/StarShower.cs @@ -36,29 +36,29 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float starSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; + mouseXDist = (float)player.direction; + mouseYDist = 0f; } - float num208 = num78; - float num209 = num79; - num208 += (float)Main.rand.Next(-1, 2) * 0.5f; - num209 += (float)Main.rand.Next(-1, 2) * 0.5f; - vector2 += new Vector2(num208, num209); - for (int num108 = 0; num108 < 5; num108++) + float randXOffset = mouseXDist; + float randYOffset = mouseYDist; + randXOffset += (float)Main.rand.Next(-1, 2) * 0.5f; + randYOffset += (float)Main.rand.Next(-1, 2) * 0.5f; + realPlayerPos += new Vector2(randXOffset, randYOffset); + for (int i = 0; i < 5; i++) { float speedX4 = 2f + (float)Main.rand.Next(-8, 5); float speedY5 = 15f + (float)Main.rand.Next(1, 6); - int star = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, 0f); + int star = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, 0f); } return false; } diff --git a/Items/Weapons/Magic/StormSpray.png b/Items/Weapons/Magic/StormSpray.png deleted file mode 100644 index 33e5033a62..0000000000 Binary files a/Items/Weapons/Magic/StormSpray.png and /dev/null differ diff --git a/Items/Weapons/Magic/ThornBlossom.cs b/Items/Weapons/Magic/ThornBlossom.cs index 80eaf74098..8000a88fa3 100644 --- a/Items/Weapons/Magic/ThornBlossom.cs +++ b/Items/Weapons/Magic/ThornBlossom.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - Item.damage = 60; + Item.damage = 90; Item.DamageType = DamageClass.Magic; Item.mana = 10; Item.width = 66; @@ -46,7 +46,7 @@ namespace CalamityMod.Items.Weapons.Magic } for (int index = 0; index < 3; ++index) { - Projectile.NewProjectile(source, position, velocity.RotatedByRandom(MathHelper.ToRadians(30f)) * 1.5f, ModContent.ProjectileType(), (int)(damage * 1.5), knockback, player.whoAmI); + Projectile.NewProjectile(source, position, velocity.RotatedByRandom(MathHelper.ToRadians(30f)) * 1.5f, ModContent.ProjectileType(), (int)(damage * 1.10), knockback, player.whoAmI); } Projectile.NewProjectile(source, position, velocity * 0.66f, type, damage, knockback, player.whoAmI, 1f); return false; diff --git a/Items/Weapons/Magic/TomeofFates.cs b/Items/Weapons/Magic/TomeofFates.cs index ce91cbf567..d8c61b2b77 100644 --- a/Items/Weapons/Magic/TomeofFates.cs +++ b/Items/Weapons/Magic/TomeofFates.cs @@ -37,38 +37,37 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { int i = Main.myPlayer; - int num73 = damage; - float num74 = knockback; - num74 = player.GetWeaponKnockback(Item, num74); + float playerKnockback = knockback; + playerKnockback = player.GetWeaponKnockback(Item, playerKnockback); player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - Vector2 value2 = new Vector2(num78, num79); - value2.Normalize(); - Vector2 value3 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - value3.Normalize(); - value2 = value2 * 4f + value3; - value2.Normalize(); - value2 *= Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + Vector2 tentacleVelocity = new Vector2(mouseXDist, mouseYDist); + tentacleVelocity.Normalize(); + Vector2 tentacleRandVelocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + tentacleRandVelocity.Normalize(); + tentacleVelocity = tentacleVelocity * 4f + tentacleRandVelocity; + tentacleVelocity.Normalize(); + tentacleVelocity *= Item.shootSpeed; int projChoice = Main.rand.Next(7); - float num91 = (float)Main.rand.Next(10, 160) * 0.001f; + float tentacleYDirection = (float)Main.rand.Next(10, 160) * 0.001f; if (Main.rand.NextBool()) { - num91 *= -1f; + tentacleYDirection *= -1f; } - float num92 = (float)Main.rand.Next(10, 160) * 0.001f; + float tentacleXDirection = (float)Main.rand.Next(10, 160) * 0.001f; if (Main.rand.NextBool()) { - num92 *= -1f; + tentacleXDirection *= -1f; } if (projChoice == 0) { - Projectile.NewProjectile(source, vector2.X, vector2.Y, value2.X, value2.Y, ModContent.ProjectileType(), (int)((double)num73 * 1.5f), num74, i, num92, num91); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, tentacleVelocity.X, tentacleVelocity.Y, ModContent.ProjectileType(), (int)((double)damage * 1.5f), playerKnockback, i, tentacleXDirection, tentacleYDirection); } else { - Projectile.NewProjectile(source, vector2.X, vector2.Y, value2.X, value2.Y, ModContent.ProjectileType(), num73, num74, i, num92, num91); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, tentacleVelocity.X, tentacleVelocity.Y, ModContent.ProjectileType(), damage, playerKnockback, i, tentacleXDirection, tentacleYDirection); } return false; } diff --git a/Items/Weapons/Magic/UndinesRetribution.cs b/Items/Weapons/Magic/UndinesRetribution.cs index 43834b2533..e075d8a142 100644 --- a/Items/Weapons/Magic/UndinesRetribution.cs +++ b/Items/Weapons/Magic/UndinesRetribution.cs @@ -40,46 +40,46 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float spearSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; + mouseXDist = (float)player.direction; } else { - num80 = num72 / num80; + mouseDistance = spearSpeed / mouseDistance; } - for (int num108 = 0; num108 < 3; num108++) + for (int i = 0; i < 3; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(51) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - /* - */ player.position.X), player.MountedCenter.Y + 600f); //- - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-50, 51); //200 - vector2.Y += (float)(100 * num108); //-= - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; //+ - - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; //+ - - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(51) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - /* - */ player.position.X), player.MountedCenter.Y + 600f); //- + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-50, 51); //200 + realPlayerPos.Y += (float)(100 * i); //-= + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; //+ - + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; //+ - + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX6 = num78 + (float)Main.rand.Next(-60, 61) * 0.02f; - float speedY7 = num79 + (float)Main.rand.Next(-60, 61) * 0.02f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = spearSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX6 = mouseXDist + (float)Main.rand.Next(-60, 61) * 0.02f; + float speedY7 = mouseYDist + (float)Main.rand.Next(-60, 61) * 0.02f; float ai1 = Main.rand.NextFloat() + 0.5f; - int bullet2 = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX6, -speedY7, type, damage, knockback, player.whoAmI, 0.0f, ai1); + int bullet2 = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX6, -speedY7, type, damage, knockback, player.whoAmI, 0.0f, ai1); } return false; } diff --git a/Items/Weapons/Magic/VenusianTrident.cs b/Items/Weapons/Magic/VenusianTrident.cs index ece69ac19a..7f47f63025 100644 --- a/Items/Weapons/Magic/VenusianTrident.cs +++ b/Items/Weapons/Magic/VenusianTrident.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Weapons.Magic public class VenusianTrident : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Magic"; - public static int BaseDamage = 108; + public static int BaseDamage = 256; public override void SetStaticDefaults() { diff --git a/Items/Weapons/Magic/Vesuvius.cs b/Items/Weapons/Magic/Vesuvius.cs index 4f9e1cf925..ce81f4bfb9 100644 --- a/Items/Weapons/Magic/Vesuvius.cs +++ b/Items/Weapons/Magic/Vesuvius.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 62; Item.damage = 50; - Item.mana = 6; + Item.mana = 7; Item.DamageType = DamageClass.Magic; Item.useAnimation = Item.useTime = 15; Item.noMelee = true; @@ -56,7 +56,7 @@ namespace CalamityMod.Items.Weapons.Magic { if (player.altFunctionUse == 2) { - int meteorAmt = Main.rand.Next(3, 4 + 1); + int meteorAmt = Main.rand.Next(2, 4); for (int i = 0; i < meteorAmt; ++i) { float SpeedX = velocity.X + (float)Main.rand.Next(-30, 31) * 0.05f; @@ -68,49 +68,49 @@ namespace CalamityMod.Items.Weapons.Magic } else { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float meteorSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = meteorSpeed; } else { - num80 = num72 / num80; + mouseDistance = meteorSpeed / mouseDistance; } - for (int num113 = 0; num113 < 4; num113++) + for (int i = 0; i < 4; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num113); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X + (float)Main.rand.Next(-40, 41) * 0.03f; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X + (float)Main.rand.Next(-40, 41) * 0.03f; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float num114 = num78; - float num115 = num79 + (float)Main.rand.Next(-40, 41) * 0.02f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = meteorSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float meteorSpawnXOffset = mouseXDist; + float meteorSpawnYOffset = mouseYDist + (float)Main.rand.Next(-40, 41) * 0.02f; float ai0 = (float)Main.rand.Next(6); - Projectile.NewProjectile(source, vector2.X, vector2.Y, num114 * 0.75f, num115 * 0.75f, type, damage, knockback, player.whoAmI, ai0, 0.5f + (float)Main.rand.NextDouble() * 0.9f); //0.3 + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, meteorSpawnXOffset * 0.75f, meteorSpawnYOffset * 0.75f, type, damage, knockback, player.whoAmI, ai0, 0.5f + (float)Main.rand.NextDouble() * 0.9f); //0.3 } return false; } diff --git a/Items/Weapons/Magic/VividClarity.cs b/Items/Weapons/Magic/VividClarity.cs index aa4956a485..209bd54617 100644 --- a/Items/Weapons/Magic/VividClarity.cs +++ b/Items/Weapons/Magic/VividClarity.cs @@ -54,7 +54,7 @@ namespace CalamityMod.Items.Weapons.Magic float sourceVariationLow = 20f; float sourceVariationHigh = 60f; Vector2 source = playerPos + f.ToRotationVector2() * MathHelper.Lerp(sourceVariationLow, sourceVariationHigh, Main.rand.NextFloat()); - for (int num202 = 0; num202 < 50; num202++) + for (int i = 0; i < 50; i++) { source = playerPos + f.ToRotationVector2() * MathHelper.Lerp(sourceVariationLow, sourceVariationHigh, Main.rand.NextFloat()); if (Collision.CanHit(playerPos, 0, 0, source + (source - playerPos).SafeNormalize(Vector2.UnitX) * 8f, 0, 0)) diff --git a/Items/Weapons/Magic/VoidVortex.cs b/Items/Weapons/Magic/VoidVortex.cs index db4a6bd179..b7b245e478 100644 --- a/Items/Weapons/Magic/VoidVortex.cs +++ b/Items/Weapons/Magic/VoidVortex.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Magic public class VoidVortex : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Magic"; - public const int OrbFireRate = 20; + public const int OrbFireRate = 15; public override void SetStaticDefaults() { @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - Item.damage = 106; + Item.damage = 110; Item.DamageType = DamageClass.Magic; Item.mana = 60; Item.width = 130; diff --git a/Items/Weapons/Magic/VoltaicClimax.cs b/Items/Weapons/Magic/VoltaicClimax.cs index 69fc4223af..76e22c7213 100644 --- a/Items/Weapons/Magic/VoltaicClimax.cs +++ b/Items/Weapons/Magic/VoltaicClimax.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - Item.damage = 123; + Item.damage = 104; Item.DamageType = DamageClass.Magic; Item.mana = 30; Item.width = 78; diff --git a/Items/Weapons/Magic/WyvernsCall.cs b/Items/Weapons/Magic/WyvernsCall.cs index a761ac63b7..05717f3b85 100644 --- a/Items/Weapons/Magic/WyvernsCall.cs +++ b/Items/Weapons/Magic/WyvernsCall.cs @@ -38,28 +38,27 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float projSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - int num107 = 3; - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 3; i++) { float damageMult = 1f; float kbMult = 1f; @@ -85,26 +84,26 @@ namespace CalamityMod.Items.Weapons.Magic damageMult = 1.2f; kbMult = 2f; } - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-30, 31) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-30, 31) * 0.02f; - int feather = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, (int)(damage * damageMult), (int)(knockback * kbMult), player.whoAmI, 0f, (float)Main.rand.Next(15)); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = projSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-30, 31) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-30, 31) * 0.02f; + int feather = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, (int)(damage * damageMult), (int)(knockback * kbMult), player.whoAmI, 0f, (float)Main.rand.Next(15)); } return false; } diff --git a/Items/Weapons/Melee/Aftershock.cs b/Items/Weapons/Melee/Aftershock.cs index ae5f6cde92..52de9634c0 100644 --- a/Items/Weapons/Melee/Aftershock.cs +++ b/Items/Weapons/Melee/Aftershock.cs @@ -34,94 +34,94 @@ namespace CalamityMod.Items.Weapons.Melee { var source = player.GetSource_ItemUse(Item); target.AddBuff(ModContent.BuffType(), 300); - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX - Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY - Main.screenPosition.Y - vector2.Y; + float rockSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX - Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY - Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = rockSpeed; } else { - num80 = num72 / num80; + mouseDistance = rockSpeed / mouseDistance; } - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)100; - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)100; + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78; - float speedY5 = num79 + (float)Main.rand.Next(-10, 11) * 0.02f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = rockSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist; + float speedY5 = mouseYDist + (float)Main.rand.Next(-10, 11) * 0.02f; int rockDamage = player.CalcIntDamage(Item.damage); - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), rockDamage, hit.Knockback, player.whoAmI, 0f, (float)Main.rand.Next(10)); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), rockDamage, hit.Knockback, player.whoAmI, 0f, (float)Main.rand.Next(10)); } public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) { var source = player.GetSource_ItemUse(Item); target.AddBuff(ModContent.BuffType(), 300); - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX - Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY - Main.screenPosition.Y - vector2.Y; + float rockSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX - Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY - Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = rockSpeed; } else { - num80 = num72 / num80; + mouseDistance = rockSpeed / mouseDistance; } - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)100; - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)100; + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78; - float speedY5 = num79 + (float)Main.rand.Next(-10, 11) * 0.02f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = rockSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist; + float speedY5 = mouseYDist + (float)Main.rand.Next(-10, 11) * 0.02f; int rockDamage = player.CalcIntDamage(Item.damage); - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), rockDamage, Item.knockBack, player.whoAmI, 0f, (float)Main.rand.Next(10)); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), rockDamage, Item.knockBack, player.whoAmI, 0f, (float)Main.rand.Next(10)); } public override void MeleeEffects(Player player, Rectangle hitbox) diff --git a/Items/Weapons/Melee/AquaticDischarge.cs b/Items/Weapons/Melee/AquaticDischarge.cs deleted file mode 100644 index f97af39d82..0000000000 --- a/Items/Weapons/Melee/AquaticDischarge.cs +++ /dev/null @@ -1,32 +0,0 @@ -using CalamityMod.Projectiles.Melee.Shortswords; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Melee -{ - public class AquaticDischarge : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Melee"; - public override void SetDefaults() - { - Item.width = 32; - Item.height = 32; - Item.noMelee = true; - Item.noUseGraphic = true; - Item.autoReuse = true; - Item.useStyle = ItemUseStyleID.Rapier; - Item.damage = 23; - Item.DamageType = TrueMeleeDamageClass.Instance; - Item.useAnimation = Item.useTime = 18; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 2f; - Item.knockBack = 5.5f; - Item.UseSound = SoundID.Item1; - Item.value = CalamityGlobalItem.Rarity2BuyPrice; - Item.rare = ItemRarityID.Green; - } - - public override bool MeleePrefix() => true; - } -} diff --git a/Items/Weapons/Melee/AquaticDischarge.png b/Items/Weapons/Melee/AquaticDischarge.png deleted file mode 100644 index ecebc39c4e..0000000000 Binary files a/Items/Weapons/Melee/AquaticDischarge.png and /dev/null differ diff --git a/Items/Weapons/Melee/ArkoftheCosmos.cs b/Items/Weapons/Melee/ArkoftheCosmos.cs index 89855a04eb..a87334a2db 100644 --- a/Items/Weapons/Melee/ArkoftheCosmos.cs +++ b/Items/Weapons/Melee/ArkoftheCosmos.cs @@ -23,10 +23,10 @@ namespace CalamityMod.Items.Weapons.Melee public float Charge = 0f; public static float NeedleDamageMultiplier = 0.7f; //Damage on the non-homing needle projectile - public static float MaxThrowReach = 650; + public static float MaxThrowReach = 760; public static float snapDamageMultiplier = 1.2f; //Extra damage from making the scissors snap - public static float chargeDamageMultiplier = 1.2f; //Extra damage from charge + public static float chargeDamageMultiplier = 1.4f; //Extra damage from charge public static float chainDamageMultiplier = 0.1f; public static int DashIframes = 10; @@ -74,7 +74,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { Item.width = Item.height = 136; - Item.damage = 1770; + Item.damage = 1700; Item.DamageType = DamageClass.MeleeNoSpeed; Item.noMelee = true; Item.noUseGraphic = true; diff --git a/Items/Weapons/Melee/Avalanche.cs b/Items/Weapons/Melee/Avalanche.cs index 933b67c18d..679c49f80c 100644 --- a/Items/Weapons/Melee/Avalanche.cs +++ b/Items/Weapons/Melee/Avalanche.cs @@ -42,8 +42,8 @@ namespace CalamityMod.Items.Weapons.Melee Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); for (int k = 0; k < totalProjectiles; k++) { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(source, target.Center, vector255, type, bombDamage, hit.Knockback, Main.myPlayer); + Vector2 projRotation = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(source, target.Center, projRotation, type, bombDamage, hit.Knockback, Main.myPlayer); } } @@ -61,8 +61,8 @@ namespace CalamityMod.Items.Weapons.Melee Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); for (int k = 0; k < totalProjectiles; k++) { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(source, target.Center, vector255, type, bombDamage, 0f, Main.myPlayer); + Vector2 projRotation = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(source, target.Center, projRotation, type, bombDamage, 0f, Main.myPlayer); } } @@ -70,8 +70,8 @@ namespace CalamityMod.Items.Weapons.Melee { if (Main.rand.NextBool(3)) { - int num250 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 67, (float)(player.direction * 2), 0f, 150, default, 1.5f); - Main.dust[num250].velocity *= 0.2f; + int iceDust = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 67, (float)(player.direction * 2), 0f, 150, default, 1.5f); + Main.dust[iceDust].velocity *= 0.2f; } } } diff --git a/Items/Weapons/Melee/BalefulHarvester.cs b/Items/Weapons/Melee/BalefulHarvester.cs index c7e42b4d80..35015038ad 100644 --- a/Items/Weapons/Melee/BalefulHarvester.cs +++ b/Items/Weapons/Melee/BalefulHarvester.cs @@ -12,8 +12,8 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { Item.damage = 90; - Item.width = 66; - Item.height = 66; + Item.width = 74; + Item.height = 86; Item.scale = 1.5f; Item.DamageType = DamageClass.Melee; Item.useAnimation = 22; diff --git a/Items/Weapons/Melee/BalefulHarvester.png b/Items/Weapons/Melee/BalefulHarvester.png index d27a4c375f..7b97d34b12 100644 Binary files a/Items/Weapons/Melee/BalefulHarvester.png and b/Items/Weapons/Melee/BalefulHarvester.png differ diff --git a/Items/Weapons/Melee/BansheeHook.cs b/Items/Weapons/Melee/BansheeHook.cs index c28f054d5e..9e3568bbbd 100644 --- a/Items/Weapons/Melee/BansheeHook.cs +++ b/Items/Weapons/Melee/BansheeHook.cs @@ -49,27 +49,27 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num82 = (float)Main.mouseX + Main.screenPosition.X - position.X; - float num83 = (float)Main.mouseY + Main.screenPosition.Y - position.Y; + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - position.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - position.Y; if (player.gravDir == -1f) { - num83 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - position.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - position.Y; } - float num84 = (float)Math.Sqrt((double)(num82 * num82 + num83 * num83)); - if ((float.IsNaN(num82) && float.IsNaN(num83)) || (num82 == 0f && num83 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num82 = (float)player.direction; - num83 = 0f; - num84 = Item.shootSpeed; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = Item.shootSpeed; } else { - num84 = Item.shootSpeed / num84; + mouseDistance = Item.shootSpeed / mouseDistance; } - num82 *= num84; - num83 *= num84; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; float ai4 = Main.rand.NextFloat() * Item.shootSpeed * 0.75f * (float)player.direction; - velocity = new Vector2(num82, num83); + velocity = new Vector2(mouseXDist, mouseYDist); Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, ai4, 0.0f); return false; } diff --git a/Items/Weapons/Melee/BladecrestOathsword.cs b/Items/Weapons/Melee/BladecrestOathsword.cs index e08424c505..931e3562c0 100644 --- a/Items/Weapons/Melee/BladecrestOathsword.cs +++ b/Items/Weapons/Melee/BladecrestOathsword.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 56; Item.height = 56; - Item.damage = 25; + Item.damage = 26; Item.DamageType = DamageClass.Melee; Item.useAnimation = 21; Item.useTime = 21; @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.UseSound = SoundID.Item1; Item.autoReuse = true; Item.noUseGraphic = true; - Item.useTurn = true; + Item.useTurn = false; Item.channel = true; Item.value = CalamityGlobalItem.Rarity3BuyPrice; Item.rare = ItemRarityID.Orange; diff --git a/Items/Weapons/Melee/BlightedCleaver.cs b/Items/Weapons/Melee/BlightedCleaver.cs index e377edbac6..d75e8fb973 100644 --- a/Items/Weapons/Melee/BlightedCleaver.cs +++ b/Items/Weapons/Melee/BlightedCleaver.cs @@ -40,13 +40,13 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { - player.AddBuff(ModContent.BuffType(), 180); + player.AddBuff(ModContent.BuffType(), 180); target.AddBuff(BuffID.Venom, 150); } public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) { - player.AddBuff(ModContent.BuffType(), 180); + player.AddBuff(ModContent.BuffType(), 180); target.AddBuff(BuffID.Venom, 150); } diff --git a/Items/Weapons/Melee/Bonebreaker.cs b/Items/Weapons/Melee/Bonebreaker.cs index 3c258921c4..c87cfa238a 100644 --- a/Items/Weapons/Melee/Bonebreaker.cs +++ b/Items/Weapons/Melee/Bonebreaker.cs @@ -9,13 +9,13 @@ namespace CalamityMod.Items.Weapons.Melee public class Bonebreaker : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; - public const int BaseDamage = 60; + public const int BaseDamage = 45; public override void SetDefaults() { Item.useStyle = ItemUseStyleID.Swing; - Item.useAnimation = 15; - Item.useTime = 15; + Item.useAnimation = 20; + Item.useTime = 20; Item.width = 32; Item.height = 32; Item.damage = BaseDamage; @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.shoot = ModContent.ProjectileType(); Item.noMelee = true; Item.noUseGraphic = true; - Item.shootSpeed = 12f; + Item.shootSpeed = 16f; } public override void AddRecipes() diff --git a/Items/Weapons/Melee/Brimlance.cs b/Items/Weapons/Melee/Brimlance.cs index c67c41ea2a..bda81404f9 100644 --- a/Items/Weapons/Melee/Brimlance.cs +++ b/Items/Weapons/Melee/Brimlance.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { Item.width = 56; - Item.damage = 58; + Item.damage = 50; Item.DamageType = TrueMeleeDamageClass.Instance; Item.noMelee = true; Item.useTurn = true; diff --git a/Items/Weapons/Melee/BrinyBaron.cs b/Items/Weapons/Melee/BrinyBaron.cs index bad1bc5860..ba1a0f1a9b 100644 --- a/Items/Weapons/Melee/BrinyBaron.cs +++ b/Items/Weapons/Melee/BrinyBaron.cs @@ -17,9 +17,9 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { - Item.damage = 180; + Item.damage = 182; Item.knockBack = 4f; - Item.useAnimation = Item.useTime = 30; + Item.useAnimation = Item.useTime = 20; Item.DamageType = DamageClass.Melee; Item.useTurn = true; Item.autoReuse = true; diff --git a/Items/Weapons/Melee/CelestialClaymore.cs b/Items/Weapons/Melee/CelestialClaymore.cs index e0f0631535..6e959d4e24 100644 --- a/Items/Weapons/Melee/CelestialClaymore.cs +++ b/Items/Weapons/Melee/CelestialClaymore.cs @@ -32,44 +32,43 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X + vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y + vector2.Y; + float projSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X + realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y + realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight + (float)Main.mouseY + vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight + (float)Main.mouseY + realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - int num107 = 3; - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 3; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = projSpeed / mouseDistance; switch (Main.rand.Next(3)) { case 0: @@ -84,7 +83,7 @@ namespace CalamityMod.Items.Weapons.Melee default: break; } - Projectile.NewProjectile(source, vector2.X, vector2.Y, 0f, 0f, type, (int)(damage * 0.8), knockback, player.whoAmI, 0f, (float)Main.rand.Next(3)); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, 0f, 0f, type, (int)(damage * 0.8), knockback, player.whoAmI, 0f, (float)Main.rand.Next(3)); } return false; } @@ -93,21 +92,21 @@ namespace CalamityMod.Items.Weapons.Melee { if (Main.rand.NextBool(4)) { - int num249 = Main.rand.Next(2); - if (num249 == 0) + int dustType = Main.rand.Next(2); + if (dustType == 0) { - num249 = 15; + dustType = 15; } - else if (num249 == 1) + else if (dustType == 1) { - num249 = 73; + dustType = 73; } else { - num249 = 244; + dustType = 244; } - int num250 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, num249, (float)(player.direction * 2), 0f, 150, default, 1.3f); - Main.dust[num250].velocity *= 0.2f; + int swingDust = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, dustType, (float)(player.direction * 2), 0f, 150, default, 1.3f); + Main.dust[swingDust].velocity *= 0.2f; } } } diff --git a/Items/Weapons/Melee/CometQuasher.cs b/Items/Weapons/Melee/CometQuasher.cs index 74d7f09561..142394b369 100644 --- a/Items/Weapons/Melee/CometQuasher.cs +++ b/Items/Weapons/Melee/CometQuasher.cs @@ -36,48 +36,48 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { var source = player.GetSource_ItemUse(Item); - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float cometSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = cometSpeed; } else { - num80 = num72 / num80; + mouseDistance = cometSpeed / mouseDistance; } - for (int num113 = 0; num113 < 2; num113++) + for (int i = 0; i < 2; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num113); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X + (float)Main.rand.Next(-40, 41) * 0.03f; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X + (float)Main.rand.Next(-40, 41) * 0.03f; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float num114 = num78; - float num115 = num79 + (float)Main.rand.Next(-40, 41) * 0.02f; - int proj = Projectile.NewProjectile(source, vector2.X, vector2.Y, num114 * 0.75f, num115 * 0.75f, ModContent.ProjectileType(), (int)(Item.damage * 0.5f), Item.knockBack, player.whoAmI, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = cometSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float cometSpawnXOffset = mouseXDist; + float cometSpawnYOffset = mouseYDist + (float)Main.rand.Next(-40, 41) * 0.02f; + int proj = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, cometSpawnXOffset * 0.75f, cometSpawnYOffset * 0.75f, ModContent.ProjectileType(), (int)(Item.damage * 0.5f), Item.knockBack, player.whoAmI, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f); Main.projectile[proj].Calamity().lineColor = Main.rand.Next(3); } } @@ -85,48 +85,48 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) { var source = player.GetSource_ItemUse(Item); - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float cometSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = cometSpeed; } else { - num80 = num72 / num80; + mouseDistance = cometSpeed / mouseDistance; } - for (int num113 = 0; num113 < 2; num113++) + for (int i = 0; i < 2; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num113); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X + (float)Main.rand.Next(-40, 41) * 0.03f; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X + (float)Main.rand.Next(-40, 41) * 0.03f; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float num114 = num78; - float num115 = num79 + (float)Main.rand.Next(-40, 41) * 0.02f; - int proj = Projectile.NewProjectile(source, vector2.X, vector2.Y, num114 * 0.75f, num115 * 0.75f, ModContent.ProjectileType(), (int)(Item.damage * 0.5f), Item.knockBack, player.whoAmI, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = cometSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float cometSpawnXOffset = mouseXDist; + float cometSpawnYOffset = mouseYDist + (float)Main.rand.Next(-40, 41) * 0.02f; + int proj = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, cometSpawnXOffset * 0.75f, cometSpawnYOffset * 0.75f, ModContent.ProjectileType(), (int)(Item.damage * 0.5f), Item.knockBack, player.whoAmI, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f); Main.projectile[proj].Calamity().lineColor = Main.rand.Next(3); } } diff --git a/Items/Weapons/Melee/CosmicShiv.cs b/Items/Weapons/Melee/CosmicShiv.cs index 4d57f8c809..e67e36ebfc 100644 --- a/Items/Weapons/Melee/CosmicShiv.cs +++ b/Items/Weapons/Melee/CosmicShiv.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.noUseGraphic = true; Item.autoReuse = true; Item.useStyle = ItemUseStyleID.Rapier; - Item.damage = 109; + Item.damage = 98; Item.DamageType = DamageClass.Melee; Item.useAnimation = Item.useTime = 18; Item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Melee/DarklightGreatsword.cs b/Items/Weapons/Melee/DarklightGreatsword.cs index 3d4820dad3..6d96aa6292 100644 --- a/Items/Weapons/Melee/DarklightGreatsword.cs +++ b/Items/Weapons/Melee/DarklightGreatsword.cs @@ -15,9 +15,9 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 92; Item.height = 100; - Item.damage = 72; + Item.damage = 75; Item.DamageType = DamageClass.Melee; - Item.useAnimation = Item.useTime = 36; + Item.useAnimation = Item.useTime = 30; Item.useStyle = ItemUseStyleID.Swing; Item.useTurn = true; Item.knockBack = 5; @@ -44,12 +44,12 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(BuffID.Frostburn, 180); + target.AddBuff(BuffID.Frostburn2, 180); } public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) { - target.AddBuff(BuffID.Frostburn, 180); + target.AddBuff(BuffID.Frostburn2, 180); } public override void AddRecipes() diff --git a/Items/Weapons/Melee/DefiledGreatsword.cs b/Items/Weapons/Melee/DefiledGreatsword.cs index eb3eff5fb9..ce3095e430 100644 --- a/Items/Weapons/Melee/DefiledGreatsword.cs +++ b/Items/Weapons/Melee/DefiledGreatsword.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { Item.width = 102; - Item.damage = 112; + Item.damage = 124; Item.DamageType = DamageClass.Melee; Item.useAnimation = 18; Item.useStyle = ItemUseStyleID.Swing; @@ -63,13 +63,13 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { - player.AddBuff(ModContent.BuffType(), 300); + player.AddBuff(ModContent.BuffType(), 300); target.AddBuff(BuffID.Venom, 150); } public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) { - player.AddBuff(ModContent.BuffType(), 300); + player.AddBuff(ModContent.BuffType(), 300); target.AddBuff(BuffID.Venom, 150); } diff --git a/Items/Weapons/Melee/Devastation.cs b/Items/Weapons/Melee/Devastation.cs index 4b49d7298c..01d6dee779 100644 --- a/Items/Weapons/Melee/Devastation.cs +++ b/Items/Weapons/Melee/Devastation.cs @@ -54,51 +54,50 @@ namespace CalamityMod.Items.Weapons.Melee break; } Projectile.NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, type, damage, knockback, Main.myPlayer); - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float projSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - int num107 = 4; - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 4; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-40, 41) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-40, 41) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), damage / 2, knockback, player.whoAmI, 0f, (float)Main.rand.Next(5)); - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), damage / 2, knockback, player.whoAmI, 0f, (float)Main.rand.Next(3)); - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), damage / 2, knockback, player.whoAmI, 0f, (float)Main.rand.Next(1)); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = projSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-40, 41) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-40, 41) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), damage / 2, knockback, player.whoAmI, 0f, (float)Main.rand.Next(5)); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), damage / 2, knockback, player.whoAmI, 0f, (float)Main.rand.Next(3)); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), damage / 2, knockback, player.whoAmI, 0f, (float)Main.rand.Next(1)); } return false; } diff --git a/Items/Weapons/Melee/DevilsDevastation.cs b/Items/Weapons/Melee/DevilsDevastation.cs index 81d91c3562..4243649280 100644 --- a/Items/Weapons/Melee/DevilsDevastation.cs +++ b/Items/Weapons/Melee/DevilsDevastation.cs @@ -119,39 +119,39 @@ namespace CalamityMod.Items.Weapons.Melee target.AddBuff(BuffID.ShadowFlame, 450); target.AddBuff(BuffID.OnFire, 900); player.ApplyDamageToNPC(target, Item.damage * 4, 0f, 0, false); - float scalar1 = 1.7f; - float scalar2 = 0.8f; - float scalar3 = 2f; - Vector2 value3 = (target.rotation - MathHelper.PiOver2).ToRotationVector2(); - Vector2 value4 = value3 * target.velocity.Length(); + float firstDustScale = 1.7f; + float secondDustScale = 0.8f; + float thirdDustScale = 2f; + Vector2 dustRotation = (target.rotation - MathHelper.PiOver2).ToRotationVector2(); + Vector2 dustVelocity = dustRotation * target.velocity.Length(); SoundEngine.PlaySound(SoundID.Item14, target.Center); for (int i = 0; i < 40; i++) { - int dustInt = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 200, default, scalar1); + int dustInt = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 200, default, firstDustScale); Dust dust = Main.dust[dustInt]; dust.position = target.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * Main.rand.NextFloat() * target.width / 2f; dust.noGravity = true; dust.velocity.Y -= 4.5f; dust.velocity *= 3f; - dust.velocity += value4 * Main.rand.NextFloat(); - dustInt = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 100, default, scalar2); + dust.velocity += dustVelocity * Main.rand.NextFloat(); + dustInt = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 100, default, secondDustScale); dust.position = target.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * Main.rand.NextFloat() * target.width / 2f; dust.velocity.Y -= 3f; dust.velocity *= 2f; dust.noGravity = true; dust.fadeIn = 1f; dust.color = Color.Crimson * 0.5f; - dust.velocity += value4 * Main.rand.NextFloat(); + dust.velocity += dustVelocity * Main.rand.NextFloat(); } for (int j = 0; j < 20; j++) { - int dustInt = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 0, default, scalar3); + int dustInt = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 0, default, thirdDustScale); Dust dust = Main.dust[dustInt]; dust.position = target.Center + Vector2.UnitX.RotatedByRandom(Math.PI).RotatedBy((double)target.velocity.ToRotation(), default) * target.width / 3f; dust.noGravity = true; dust.velocity.Y -= 1.5f; dust.velocity *= 0.5f; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); + dust.velocity += dustVelocity * (0.6f + 0.6f * Main.rand.NextFloat()); } } } diff --git a/Items/Weapons/Melee/Earth.cs b/Items/Weapons/Melee/Earth.cs index 9d741c2c96..773eabba6f 100644 --- a/Items/Weapons/Melee/Earth.cs +++ b/Items/Weapons/Melee/Earth.cs @@ -36,51 +36,50 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { var source = player.GetSource_ItemUse(Item); - float num72 = 25f; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX - Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY - Main.screenPosition.Y - vector2.Y; + float projSpeed = 25f; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX - Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY - Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - int num107 = 3; - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 3; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78; - float speedY5 = num79 + (float)Main.rand.Next(-180, 181) * 0.02f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = projSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist; + float speedY5 = mouseYDist + (float)Main.rand.Next(-180, 181) * 0.02f; int projDamage = player.CalcIntDamage(Item.damage); - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), projDamage, hit.Knockback, player.whoAmI, 0f, (float)Main.rand.Next(10)); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), projDamage, hit.Knockback, player.whoAmI, 0f, (float)Main.rand.Next(10)); } if (target.Calamity().miscDefenseLoss < target.defense) @@ -97,50 +96,49 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) { var source = player.GetSource_ItemUse(Item); - float num72 = 25f; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX - Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY - Main.screenPosition.Y - vector2.Y; + float projSpeed = 25f; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX - Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY - Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - int num107 = 3; - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 3; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78; - float speedY5 = num79 + (float)Main.rand.Next(-180, 181) * 0.02f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = projSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist; + float speedY5 = mouseYDist + (float)Main.rand.Next(-180, 181) * 0.02f; int earthDamage = player.CalcIntDamage(Item.damage); - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), earthDamage, Item.knockBack, player.whoAmI, 0f, (float)Main.rand.Next(10)); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), earthDamage, Item.knockBack, player.whoAmI, 0f, (float)Main.rand.Next(10)); } if (player.moonLeech) diff --git a/Items/Weapons/Melee/EmpyreanKnives.cs b/Items/Weapons/Melee/EmpyreanKnives.cs index 5a4c74effc..49cea27978 100644 --- a/Items/Weapons/Melee/EmpyreanKnives.cs +++ b/Items/Weapons/Melee/EmpyreanKnives.cs @@ -36,60 +36,58 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - Vector2 value = Vector2.UnitX.RotatedBy((double)player.fullRotation, default); - Vector2 vector3 = Main.MouseWorld - vector2; - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float knifeSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = knifeSpeed; } else { - num80 = num72 / num80; + mouseDistance = knifeSpeed / mouseDistance; } - num78 *= num80; - num79 *= num80; - int num146 = 4; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + int knifeAmt = 4; if (Main.rand.NextBool()) { - num146++; + knifeAmt++; } if (Main.rand.NextBool(4)) { - num146++; + knifeAmt++; } if (Main.rand.NextBool(8)) { - num146++; + knifeAmt++; } if (Main.rand.NextBool(16)) { - num146++; + knifeAmt++; } - for (int num147 = 0; num147 < num146; num147++) + for (int i = 0; i < knifeAmt; i++) { - float num148 = num78; - float num149 = num79; - float num150 = 0.05f * (float)num147; - num148 += (float)Main.rand.Next(-25, 26) * num150; - num149 += (float)Main.rand.Next(-25, 26) * num150; - num80 = (float)Math.Sqrt((double)(num148 * num148 + num149 * num149)); - num80 = num72 / num80; - num148 *= num80; - num149 *= num80; - float x4 = vector2.X; - float y4 = vector2.Y; - Projectile.NewProjectile(source, x4, y4, num148, num149, type, damage, knockback, player.whoAmI, 0f, 0f); + float knifeSpawnXPos = mouseXDist; + float knifeSpawnYPos = mouseYDist; + float randOffsetDampener = 0.05f * (float)i; + knifeSpawnXPos += (float)Main.rand.Next(-25, 26) * randOffsetDampener; + knifeSpawnYPos += (float)Main.rand.Next(-25, 26) * randOffsetDampener; + mouseDistance = (float)Math.Sqrt((double)(knifeSpawnXPos * knifeSpawnXPos + knifeSpawnYPos * knifeSpawnYPos)); + mouseDistance = knifeSpeed / mouseDistance; + knifeSpawnXPos *= mouseDistance; + knifeSpawnYPos *= mouseDistance; + float x4 = realPlayerPos.X; + float y4 = realPlayerPos.Y; + Projectile.NewProjectile(source, x4, y4, knifeSpawnXPos, knifeSpawnYPos, type, damage, knockback, player.whoAmI, 0f, 0f); } return false; } diff --git a/Items/Weapons/Melee/EntropicClaymore.cs b/Items/Weapons/Melee/EntropicClaymore.cs index 11ff310684..d9a820585d 100644 --- a/Items/Weapons/Melee/EntropicClaymore.cs +++ b/Items/Weapons/Melee/EntropicClaymore.cs @@ -38,8 +38,8 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int num6 = Main.rand.Next(4, 6); - for (int index = 0; index < num6; ++index) + int projAmt = Main.rand.Next(4, 6); + for (int index = 0; index < projAmt; ++index) { float SpeedX = velocity.X + (float)Main.rand.Next(-20, 21) * 0.05f; float SpeedY = velocity.Y + (float)Main.rand.Next(-20, 21) * 0.05f; diff --git a/Items/Weapons/Melee/ExaltedOathblade.cs b/Items/Weapons/Melee/ExaltedOathblade.cs index 4750c5f0c4..935f03de6c 100644 --- a/Items/Weapons/Melee/ExaltedOathblade.cs +++ b/Items/Weapons/Melee/ExaltedOathblade.cs @@ -60,39 +60,39 @@ namespace CalamityMod.Items.Weapons.Melee target.AddBuff(BuffID.ShadowFlame, 450); target.AddBuff(BuffID.OnFire, 900); player.ApplyDamageToNPC(target, player.GetWeaponDamage(player.ActiveItem()) * 2, 0f, 0, false); - float num50 = 1.7f; - float num51 = 0.8f; - float num52 = 2f; - Vector2 value3 = (target.rotation - MathHelper.PiOver2).ToRotationVector2(); - Vector2 value4 = value3 * target.velocity.Length(); + float firstDustScale = 1.7f; + float secondDustScale = 0.8f; + float thirdDustScale = 2f; + Vector2 dustRotation = (target.rotation - MathHelper.PiOver2).ToRotationVector2(); + Vector2 dustVelocity = dustRotation * target.velocity.Length(); SoundEngine.PlaySound(SoundID.Item14, target.Center); - for (int num53 = 0; num53 < 40; num53++) + for (int i = 0; i < 40; i++) { - int num54 = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 200, default, num50); - Dust dust = Main.dust[num54]; + int swingDust = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 200, default, firstDustScale); + Dust dust = Main.dust[swingDust]; dust.position = target.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * (float)Main.rand.NextDouble() * (float)target.width / 2f; dust.noGravity = true; dust.velocity.Y -= 4.5f; dust.velocity *= 3f; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 100, default, num51); + dust.velocity += dustVelocity * Main.rand.NextFloat(); + swingDust = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 100, default, secondDustScale); dust.position = target.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * (float)Main.rand.NextDouble() * (float)target.width / 2f; dust.velocity.Y -= 3f; dust.velocity *= 2f; dust.noGravity = true; dust.fadeIn = 1f; dust.color = Color.Crimson * 0.5f; - dust.velocity += value4 * Main.rand.NextFloat(); + dust.velocity += dustVelocity * Main.rand.NextFloat(); } - for (int num55 = 0; num55 < 20; num55++) + for (int j = 0; j < 20; j++) { - int num56 = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 0, default, num52); - Dust dust = Main.dust[num56]; + int swingDust2 = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 0, default, thirdDustScale); + Dust dust = Main.dust[swingDust2]; dust.position = target.Center + Vector2.UnitX.RotatedByRandom(Math.PI).RotatedBy((double)target.velocity.ToRotation(), default) * (float)target.width / 3f; dust.noGravity = true; dust.velocity.Y -= 1.5f; dust.velocity *= 0.5f; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); + dust.velocity += dustVelocity * (0.6f + 0.6f * Main.rand.NextFloat()); } } } diff --git a/Items/Weapons/Melee/FlarefrostBlade.cs b/Items/Weapons/Melee/FlarefrostBlade.cs index 4e06ea04d8..1cafd81d66 100644 --- a/Items/Weapons/Melee/FlarefrostBlade.cs +++ b/Items/Weapons/Melee/FlarefrostBlade.cs @@ -13,9 +13,9 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { Item.width = 64; - Item.damage = 104; + Item.damage = 125; Item.DamageType = DamageClass.Melee; - Item.useAnimation = Item.useTime = 36; + Item.useAnimation = Item.useTime = 29; Item.useTurn = true; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 6.25f; diff --git a/Items/Weapons/Melee/ForbiddenOathblade.cs b/Items/Weapons/Melee/ForbiddenOathblade.cs index cae1a22330..83822db3c7 100644 --- a/Items/Weapons/Melee/ForbiddenOathblade.cs +++ b/Items/Weapons/Melee/ForbiddenOathblade.cs @@ -46,42 +46,42 @@ namespace CalamityMod.Items.Weapons.Melee target.AddBuff(BuffID.OnFire, 720); int onHitDamage = player.CalcIntDamage(2 * Item.damage); player.ApplyDamageToNPC(target, onHitDamage, 0f, 0, false); - float num50 = 1.7f; - float num51 = 0.8f; - float num52 = 2f; - Vector2 value3 = (target.rotation - 1.57079637f).ToRotationVector2(); - Vector2 value4 = value3 * target.velocity.Length(); + float firstDustScale = 1.7f; + float secondDustScale = 0.8f; + float thirdDustScale = 2f; + Vector2 dustRotation = (target.rotation - 1.57079637f).ToRotationVector2(); + Vector2 dustVelocity = dustRotation * target.velocity.Length(); SoundEngine.PlaySound(SoundID.Item14, target.Center); - int num3; - for (int num53 = 0; num53 < 40; num53 = num3 + 1) + int dustIncr; + for (int i = 0; i < 40; i = dustIncr + 1) { - int num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 173, 0f, 0f, 200, default, num50); - Dust dust = Main.dust[num54]; + int swingDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 173, 0f, 0f, 200, default, firstDustScale); + Dust dust = Main.dust[swingDust]; dust.position = target.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)target.width / 2f; dust.noGravity = true; dust.velocity.Y -= 4.5f; dust.velocity *= 3f; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 173, 0f, 0f, 100, default, num51); + dust.velocity += dustVelocity * Main.rand.NextFloat(); + swingDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 173, 0f, 0f, 100, default, secondDustScale); dust.position = target.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)target.width / 2f; dust.velocity.Y -= 3f; dust.velocity *= 2f; dust.noGravity = true; dust.fadeIn = 1f; dust.color = Color.Crimson * 0.5f; - dust.velocity += value4 * Main.rand.NextFloat(); - num3 = num53; + dust.velocity += dustVelocity * Main.rand.NextFloat(); + dustIncr = i; } - for (int num55 = 0; num55 < 20; num55 = num3 + 1) + for (int j = 0; j < 20; j = dustIncr + 1) { - int num56 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 173, 0f, 0f, 0, default, num52); - Dust dust = Main.dust[num56]; + int swingDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 173, 0f, 0f, 0, default, thirdDustScale); + Dust dust = Main.dust[swingDust2]; dust.position = target.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)target.velocity.ToRotation(), default) * (float)target.width / 3f; dust.noGravity = true; dust.velocity.Y -= 1.5f; dust.velocity *= 0.5f; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); - num3 = num55; + dust.velocity += dustVelocity * (0.6f + 0.6f * Main.rand.NextFloat()); + dustIncr = j; } } } diff --git a/Items/Weapons/Melee/ForsakenSaber.cs b/Items/Weapons/Melee/ForsakenSaber.cs index d583f2fc6f..b12b697618 100644 --- a/Items/Weapons/Melee/ForsakenSaber.cs +++ b/Items/Weapons/Melee/ForsakenSaber.cs @@ -13,9 +13,9 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { Item.width = 46; - Item.damage = 65; + Item.damage = 80; Item.DamageType = DamageClass.Melee; - Item.useAnimation = Item.useTime = 18; + Item.useAnimation = Item.useTime = 15; Item.useStyle = ItemUseStyleID.Swing; Item.useTurn = true; Item.knockBack = 6; diff --git a/Items/Weapons/Melee/FourSeasonsGalaxia.cs b/Items/Weapons/Melee/FourSeasonsGalaxia.cs index 6be6c9ba33..0930ec074c 100644 --- a/Items/Weapons/Melee/FourSeasonsGalaxia.cs +++ b/Items/Weapons/Melee/FourSeasonsGalaxia.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Melee #region stats public static int BaseDamage = 800; - public static int PhoenixAttunement_BaseDamage = 1050; + public static int PhoenixAttunement_BaseDamage = 1200; public static int PhoenixAttunement_LocalIFrames = 30; //Remember its got one extra update public static float PhoenixAttunement_BoltDamageReduction = 0.5f; public static float PhoenixAttunement_BoltThrowDamageMultiplier = 1f; diff --git a/Items/Weapons/Melee/FracturedArk.cs b/Items/Weapons/Melee/FracturedArk.cs index 9200b4a641..eaba78acbd 100644 --- a/Items/Weapons/Melee/FracturedArk.cs +++ b/Items/Weapons/Melee/FracturedArk.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { Item.width = Item.height = 60; - Item.damage = 60; + Item.damage = 35; Item.DamageType = DamageClass.MeleeNoSpeed; Item.noUseGraphic = true; Item.noMelee = true; diff --git a/Items/Weapons/Melee/GaelsGreatsword.cs b/Items/Weapons/Melee/GaelsGreatsword.cs index f67c782dab..6e344a3f31 100644 --- a/Items/Weapons/Melee/GaelsGreatsword.cs +++ b/Items/Weapons/Melee/GaelsGreatsword.cs @@ -20,7 +20,6 @@ namespace CalamityMod.Items.Weapons.Melee // Weapon projectile attribute constants public static readonly int SearchDistance = 1450; public static readonly int ImmunityFrames = 10; - public static readonly int SkullsplosionCooldownSeconds = 30; // Skull ring attribute constants public static readonly float SkullsplosionDamageMultiplier = 1.5f; diff --git a/Items/Weapons/Melee/GalactusBlade.cs b/Items/Weapons/Melee/GalactusBlade.cs index f462729e04..a2e0c6ceab 100644 --- a/Items/Weapons/Melee/GalactusBlade.cs +++ b/Items/Weapons/Melee/GalactusBlade.cs @@ -37,49 +37,48 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float cometSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = cometSpeed; } else { - num80 = num72 / num80; + mouseDistance = cometSpeed / mouseDistance; } - int num107 = 5; - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 5; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-100, 101) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-100, 101) * 0.02f; - int projectile = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, (float)Main.rand.Next(10)); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = cometSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-100, 101) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-100, 101) * 0.02f; + int projectile = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, (float)Main.rand.Next(10)); } return false; } diff --git a/Items/Weapons/Melee/GalileoGladius.cs b/Items/Weapons/Melee/GalileoGladius.cs index 4d9e7bd258..edae7ebf82 100644 --- a/Items/Weapons/Melee/GalileoGladius.cs +++ b/Items/Weapons/Melee/GalileoGladius.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.useStyle = ItemUseStyleID.Rapier; Item.damage = 92; Item.DamageType = DamageClass.Melee; - Item.useAnimation = Item.useTime = 10; + Item.useAnimation = Item.useTime = 12; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 0.9f; Item.knockBack = 10f; diff --git a/Items/Weapons/Melee/GeliticBlade.cs b/Items/Weapons/Melee/GeliticBlade.cs index be196feb1c..c1fd155865 100644 --- a/Items/Weapons/Melee/GeliticBlade.cs +++ b/Items/Weapons/Melee/GeliticBlade.cs @@ -13,7 +13,8 @@ namespace CalamityMod.Items.Weapons.Melee public new string LocalizationCategory => "Items.Weapons.Melee"; public override void SetDefaults() { - Item.width = 62; + Item.width = 44; + Item.height = 70; Item.damage = 38; Item.DamageType = DamageClass.Melee; Item.useAnimation = 30; @@ -23,7 +24,6 @@ namespace CalamityMod.Items.Weapons.Melee Item.knockBack = 5.25f; Item.UseSound = SoundID.Item1; Item.autoReuse = true; - Item.height = 62; Item.value = CalamityGlobalItem.Rarity4BuyPrice; Item.rare = ItemRarityID.LightRed; Item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Melee/GeliticBlade.png b/Items/Weapons/Melee/GeliticBlade.png index 0369a046ba..130809d1e9 100644 Binary files a/Items/Weapons/Melee/GeliticBlade.png and b/Items/Weapons/Melee/GeliticBlade.png differ diff --git a/Items/Weapons/Melee/GreatswordofJudgement.cs b/Items/Weapons/Melee/GreatswordofJudgement.cs index 69b33a45f1..c53160bd91 100644 --- a/Items/Weapons/Melee/GreatswordofJudgement.cs +++ b/Items/Weapons/Melee/GreatswordofJudgement.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { Item.width = 78; - Item.damage = 48; + Item.damage = 40; Item.DamageType = DamageClass.Melee; Item.useAnimation = 18; Item.useStyle = ItemUseStyleID.Swing; diff --git a/Items/Weapons/Melee/Greentide.cs b/Items/Weapons/Melee/Greentide.cs index 615f365490..056f573a04 100644 --- a/Items/Weapons/Melee/Greentide.cs +++ b/Items/Weapons/Melee/Greentide.cs @@ -32,107 +32,106 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { var source = player.GetSource_ItemUse(Item); - int i = Main.myPlayer; - float num72 = Item.shootSpeed; - float num74 = hit.Knockback; - num74 = player.GetWeaponKnockback(Item, num74); + int j = Main.myPlayer; + float projSpeed = Item.shootSpeed; + float playerKnockback = hit.Knockback; + playerKnockback = player.GetWeaponKnockback(Item, playerKnockback); player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX - Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY - Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX - Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY - Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - for (int num108 = 0; num108 < 3; num108++) + for (int i = 0; i < 3; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78; - float speedY5 = num79 + (float)Main.rand.Next(-180, 181) * 0.02f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = projSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist; + float speedY5 = mouseYDist + (float)Main.rand.Next(-180, 181) * 0.02f; int greenWaterDamage = player.CalcIntDamage(Item.damage); - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), greenWaterDamage, num74, i, 0f, (float)Main.rand.Next(10)); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), greenWaterDamage, playerKnockback, i, 0f, (float)Main.rand.Next(10)); } } public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) { var source = player.GetSource_ItemUse(Item); - int i = Main.myPlayer; - float num72 = Item.shootSpeed; - float num74 = Item.knockBack; - num74 = player.GetWeaponKnockback(Item, num74); + int j = Main.myPlayer; + float projSpeed = Item.shootSpeed; + float playerKnockback = Item.knockBack; + playerKnockback = player.GetWeaponKnockback(Item, playerKnockback); player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX - Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY - Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX - Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY - Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - int num107 = 4; - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 4; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78; - float speedY5 = num79 + (float)Main.rand.Next(-180, 181) * 0.02f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = projSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist; + float speedY5 = mouseYDist + (float)Main.rand.Next(-180, 181) * 0.02f; int greenWaterDamage = player.CalcIntDamage(Item.damage); - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), greenWaterDamage, num74, i, 0f, (float)Main.rand.Next(10)); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), greenWaterDamage, playerKnockback, i, 0f, (float)Main.rand.Next(10)); } } diff --git a/Items/Weapons/Melee/Hellkite.cs b/Items/Weapons/Melee/Hellkite.cs index 14f1befc1b..9b0f324446 100644 --- a/Items/Weapons/Melee/Hellkite.cs +++ b/Items/Weapons/Melee/Hellkite.cs @@ -55,42 +55,42 @@ namespace CalamityMod.Items.Weapons.Melee target.AddBuff(BuffID.OnFire3, 300); int onHitDamage = player.CalcIntDamage(Item.damage); player.ApplyDamageToNPC(target, onHitDamage, 0f, 0, false); - float num50 = 1.7f; - float num51 = 0.8f; - float num52 = 2f; - Vector2 value3 = (target.rotation - 1.57079637f).ToRotationVector2(); - Vector2 value4 = value3 * target.velocity.Length(); + float firstDustScale = 1.7f; + float secondDustScale = 0.8f; + float thirdDustScale = 2f; + Vector2 dustRotation = (target.rotation - 1.57079637f).ToRotationVector2(); + Vector2 dustVelocity = dustRotation * target.velocity.Length(); SoundEngine.PlaySound(SoundID.Item14, target.Center); - int num3; - for (int num53 = 0; num53 < 40; num53 = num3 + 1) + int increment; + for (int i = 0; i < 40; i = increment + 1) { - int num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 200, default, num50); - Dust dust = Main.dust[num54]; + int swingDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 200, default, firstDustScale); + Dust dust = Main.dust[swingDust]; dust.position = target.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)target.width / 2f; dust.noGravity = true; dust.velocity.Y -= 6f; dust.velocity *= 3f; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 100, default, num51); + dust.velocity += dustVelocity * Main.rand.NextFloat(); + swingDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 100, default, secondDustScale); dust.position = target.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)target.width / 2f; dust.velocity.Y -= 6f; dust.velocity *= 2f; dust.noGravity = true; dust.fadeIn = 1f; dust.color = Color.Crimson * 0.5f; - dust.velocity += value4 * Main.rand.NextFloat(); - num3 = num53; + dust.velocity += dustVelocity * Main.rand.NextFloat(); + increment = i; } - for (int num55 = 0; num55 < 20; num55 = num3 + 1) + for (int j = 0; j < 20; j = increment + 1) { - int num56 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 0, default, num52); - Dust dust = Main.dust[num56]; + int swingDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 0, default, thirdDustScale); + Dust dust = Main.dust[swingDust2]; dust.position = target.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)target.velocity.ToRotation(), default) * (float)target.width / 3f; dust.noGravity = true; dust.velocity.Y -= 6f; dust.velocity *= 0.5f; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); - num3 = num55; + dust.velocity += dustVelocity * (0.6f + 0.6f * Main.rand.NextFloat()); + increment = j; } } } diff --git a/Items/Weapons/Melee/IllustriousKnives.cs b/Items/Weapons/Melee/IllustriousKnives.cs index 5e2ee3cefd..6fe1669c29 100644 --- a/Items/Weapons/Melee/IllustriousKnives.cs +++ b/Items/Weapons/Melee/IllustriousKnives.cs @@ -40,60 +40,58 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - Vector2 value = Vector2.UnitX.RotatedBy((double)player.fullRotation, default); - Vector2 vector3 = Main.MouseWorld - vector2; - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float knifeSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = knifeSpeed; } else { - num80 = num72 / num80; + mouseDistance = knifeSpeed / mouseDistance; } - num78 *= num80; - num79 *= num80; - int num146 = 4; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + int knifeAmt = 4; if (Main.rand.NextBool()) { - num146++; + knifeAmt++; } if (Main.rand.NextBool(4)) { - num146++; + knifeAmt++; } if (Main.rand.NextBool(6)) { - num146++; + knifeAmt++; } if (Main.rand.NextBool(8)) { - num146++; + knifeAmt++; } - for (int num147 = 0; num147 < num146; num147++) + for (int i = 0; i < knifeAmt; i++) { - float num148 = num78; - float num149 = num79; - float num150 = 0.05f * (float)num147; - num148 += (float)Main.rand.Next(-35, 36) * num150; - num149 += (float)Main.rand.Next(-35, 36) * num150; - num80 = (float)Math.Sqrt((double)(num148 * num148 + num149 * num149)); - num80 = num72 / num80; - num148 *= num80; - num149 *= num80; - float x4 = vector2.X; - float y4 = vector2.Y; - Projectile.NewProjectile(source, x4, y4, num148, num149, type, damage, knockback, player.whoAmI, 0f, 0f); + float knifeSpawnXPos = mouseXDist; + float knifeSpawnYPos = mouseYDist; + float randOffsetDampener = 0.05f * (float)i; + knifeSpawnXPos += (float)Main.rand.Next(-35, 36) * randOffsetDampener; + knifeSpawnYPos += (float)Main.rand.Next(-35, 36) * randOffsetDampener; + mouseDistance = (float)Math.Sqrt((double)(knifeSpawnXPos * knifeSpawnXPos + knifeSpawnYPos * knifeSpawnYPos)); + mouseDistance = knifeSpeed / mouseDistance; + knifeSpawnXPos *= mouseDistance; + knifeSpawnYPos *= mouseDistance; + float x4 = realPlayerPos.X; + float y4 = realPlayerPos.Y; + Projectile.NewProjectile(source, x4, y4, knifeSpawnXPos, knifeSpawnYPos, type, damage, knockback, player.whoAmI, 0f, 0f); } return false; } diff --git a/Items/Weapons/Melee/IridescentExcalibur.cs b/Items/Weapons/Melee/IridescentExcalibur.cs index ed6fd22ea4..21c7469d36 100644 --- a/Items/Weapons/Melee/IridescentExcalibur.cs +++ b/Items/Weapons/Melee/IridescentExcalibur.cs @@ -133,8 +133,8 @@ namespace CalamityMod.Items.Weapons.Melee break; } - Dust dust24 = Main.dust[Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 267, 0f, 0f, alpha, color, 1.2f)]; - dust24.noGravity = true; + Dust swingDust = Main.dust[Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 267, 0f, 0f, alpha, color, 1.2f)]; + swingDust.noGravity = true; } } diff --git a/Items/Weapons/Melee/Murasama.cs b/Items/Weapons/Melee/Murasama.cs index 7a409e5a71..3208cb9c07 100644 --- a/Items/Weapons/Melee/Murasama.cs +++ b/Items/Weapons/Melee/Murasama.cs @@ -3,6 +3,7 @@ using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -14,8 +15,12 @@ namespace CalamityMod.Items.Weapons.Melee public new string LocalizationCategory => "Items.Weapons.Melee"; public int frameCounter = 0; public int frame = 0; - public bool IDUnlocked(Player player) => DownedBossSystem.downedYharon || player.name == "Jetstream Sam" || player.name == "Samuel Rodrigues"; + public bool IDUnlocked(Player player) => DownedBossSystem.downedDoG; + public static readonly SoundStyle OrganicHit = new("CalamityMod/Sounds/Item/MurasamaHitOrganic") { Volume = 0.6f }; + public static readonly SoundStyle InorganicHit = new("CalamityMod/Sounds/Item/MurasamaHitInorganic") { Volume = 0.65f }; + public static readonly SoundStyle Swing = new("CalamityMod/Sounds/Item/MurasamaSwing") { Volume = 0.3f }; + public static readonly SoundStyle BigSwing = new("CalamityMod/Sounds/Item/MurasamaBigSwing") { Volume = 0.35f }; public override void SetStaticDefaults() { Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(6, 13)); @@ -26,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.height = 128; Item.width = 56; - Item.damage = 3001; + Item.damage = 2222; Item.DamageType = TrueMeleeNoSpeedDamageClass.Instance; Item.noMelee = true; Item.noUseGraphic = true; @@ -44,7 +49,7 @@ namespace CalamityMod.Items.Weapons.Melee } // Terraria seems to really dislike high crit values in SetDefaults - public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 30; + public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 61; public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) { diff --git a/Items/Weapons/Melee/RedSun.cs b/Items/Weapons/Melee/RedSun.cs index 37d2bb4282..49e558c3ee 100644 --- a/Items/Weapons/Melee/RedSun.cs +++ b/Items/Weapons/Melee/RedSun.cs @@ -40,51 +40,48 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - Vector2 value = Vector2.UnitX.RotatedBy((double)player.fullRotation, default); - Vector2 vector3 = Main.MouseWorld - vector2; - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float flareSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = flareSpeed; } else { - num80 = num72 / num80; + mouseDistance = flareSpeed / mouseDistance; } - int num107 = 3; - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 3; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-1000, 1001) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-1000, 1001) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), (int)((double)damage * 0.7), knockback, player.whoAmI, 0f, (float)Main.rand.Next(10)); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = flareSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-1000, 1001) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-1000, 1001) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), (int)((double)damage * 0.7), knockback, player.whoAmI, 0f, (float)Main.rand.Next(10)); } return false; } diff --git a/Items/Weapons/Melee/Roxcalibur.cs b/Items/Weapons/Melee/Roxcalibur.cs index 7ab068bbbf..5c0637ddcb 100644 --- a/Items/Weapons/Melee/Roxcalibur.cs +++ b/Items/Weapons/Melee/Roxcalibur.cs @@ -1,303 +1,70 @@ -using Terraria.DataStructures; +using System.Collections.Generic; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; -using System.Collections.Generic; using Terraria; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; + namespace CalamityMod.Items.Weapons.Melee { - public class Roxcalibur : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Melee"; - private int Roxcooldown = 901; - private int RoxCanUse = 0; - private int RoxCanAlt = 0; - private bool RoxAlt = false; - private bool Didrefresh = false; + public class Roxcalibur : ModItem, ILocalizedModType + { - public override void SetStaticDefaults() - { - ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; - } + public string LocalizationCategory => "Items.Weapons.Melee"; - public override void SetDefaults() - { - Item.damage = 150; - Item.knockBack = 13; + public static int BaseUseTime = 40; + public override void SetDefaults() + { + Item.damage = 180; + Item.knockBack = 13f; Item.DamageType = DamageClass.Melee; - Item.useStyle = ItemUseStyleID.Swing; - Item.UseSound = SoundID.NPCHit42; - Item.width = 100; - Item.height = 100; - Item.autoReuse = true; - Item.useAnimation = Item.useTime = 64; - - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; - - Item.value = CalamityGlobalItem.Rarity4BuyPrice; - Item.rare = ItemRarityID.LightRed; + Item.useStyle = ItemUseStyleID.Shoot; + Item.UseSound = SoundID.NPCHit42; + Item.width = 100; + Item.height = 100; + Item.useAnimation = Item.useTime = BaseUseTime; + Item.reuseDelay = 10; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 4f; + Item.value = CalamityGlobalItem.Rarity4BuyPrice; + Item.rare = ItemRarityID.LightRed; Item.Calamity().donorItem = true; + + Item.noUseGraphic = true; + Item.noMelee = true; + Item.autoReuse = false; + Item.channel = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 8; + public override void ModifyWeaponCrit(Player player, ref float crit) + { + crit += 8f; + } + public override bool CanUseItem(Player player) => Main.hardMode && player.ownedProjectileCounts[Item.shoot] < 1; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + Projectile.NewProjectile(source, position, velocity, type, damage, knockback, ai2: player.itemTimeMax); //needed to set ai2 + return false; + } + public override void ModifyTooltips(List list) + { + list.FindAndReplace("[WOF]", Main.hardMode ? string.Empty : this.GetLocalizedValue("LockedInfo") + "\n"); + } - public override void UpdateInventory(Player player) - { - //Timers for the cooldown and usage of the weapon - Roxcooldown++; - RoxCanUse++; - RoxCanAlt++; - if (Roxcooldown == 600) - { - for (int i = 0; i < 50; i++) - { - int d = Dust.NewDust(player.Center, player.width, player.height, 191, Main.rand.Next(-8, 9), Main.rand.Next(-8, 9), 100, default, 1); - Main.dust[d].noGravity = true; - Main.dust[d].position = player.Center; - } - SoundEngine.PlaySound(SoundID.Item70, player.Center); - } - // Resets the weapon usage if the alt fire collides with the ground - if (RoxAlt && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0) - { - player.itemAnimation = 0; - player.itemTime = 0; - RoxCanUse = 0; - RoxAlt = false; - Didrefresh = false; - } - // Controls what happens when the alt fire is active - if (RoxAlt && player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) - { - if (player.mount.Active) - { - player.mount.Dismount(player); - } - player.maxFallSpeed = 22f; - player.controlJump = false; - player.controlUp = false; - player.dashDelay = 60; - } - } - - public override bool CanUseItem(Player player) - { - //Only useable in hardmode and if a second has passed after the alt fire ended - return Main.hardMode && RoxCanUse >= 60; - } - - public override bool AltFunctionUse(Player player) - { - return RoxCanAlt >= Item.useAnimation + 5 && player.position.Y != player.oldPosition.Y && !player.mount.Active && player.gravDir != -1; - } - - public override void UseStyle(Player player, Rectangle heldItemFrame) - { - //Modifies the altfire use style and the location of the sprite of the weapon - if (player.altFunctionUse == 2) - { - player.itemLocation.X -= 32f * player.direction; - player.itemLocation.Y -= 60f; - Item.useStyle = ItemUseStyleID.HoldUp; - RoxAlt = true; - } - //Modifies to use style and hold out of the main fire mode - else - { - player.itemLocation += new Vector2(-7.5f * player.direction, 8.5f * player.gravDir).RotatedBy(player.itemRotation); - Item.useStyle = ItemUseStyleID.Swing; - RoxAlt = false; - } - } - - //Makes the alt fire only spawn the projectile once - // TODO -- Fix this, because tmod removed this function - //public override bool OnlyShootOnSwing => RoxAlt; - - public override void UseItemHitbox(Player player, ref Rectangle hitbox, ref bool noHitbox) - { - //Changes the hitbox of the alt fire to fit the sprite - if (player.altFunctionUse == 2) - { - if (player.direction == 1) - { - hitbox.X = (int)player.position.X - 9; - } - else - { - hitbox.X = (int)player.position.X - 22; - } - hitbox.Y = (int)player.position.Y + 20; - hitbox.Width = 52; - } - //Why did i need to fix this hitbox i have no clue - else - { - if (player.direction == -1) - { - hitbox.X += 16; - } - hitbox.Width -= 15; - } - } - - public override float UseSpeedMultiplier(Player player) - { - //If you use alt fire it can hold the sword for way longer - if (player.altFunctionUse == 2) - { - //Use animation 40/0.1 = 400 - return 0.1f; - } - else - { - return 1f; - } - } - - public override void MeleeEffects(Player player, Rectangle hitbox) - { - if (player.altFunctionUse == 2) - { - //Prevents the player from getting stuck on tiles like platforms - if (player.position.Y == player.oldPosition.Y) - { - player.itemAnimation = 0; - player.itemTime = 0; - RoxAlt = false; - RoxCanUse = 0; - if (Didrefresh) - { - Roxcooldown = 600; - Didrefresh = false; - } - } - // Makes the player forcefully dive down - if (CalamityUtils.CountHookProj() <= 0) - player.velocity.Y = player.maxFallSpeed; - //Rotates the sprite of the item on alt fire to have it point downwards - player.itemRotation = player.direction * MathHelper.ToRadians(135f); - //Dust trail - int dusty = hitbox.Y + (hitbox.Height / 2); - Dust.NewDust(new Vector2(hitbox.X, dusty), hitbox.Width, hitbox.Height / 2, 191, player.velocity.X * 0.25f, player.velocity.Y * 0.25f, 160, default, 0.7f); - } - else - { - Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 191, 0f, 0f, 160, default, 0.7f); - } - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - if (Item.useStyle == ItemUseStyleID.HoldUp) - { - //Spawns a projectile on the tip of the sword in the alt fire - float positionx; - float positiony = position.Y + (Item.height / 2) + 23; - - int cooldown = 0; - //Check if the entire cooldown has passed - if (Roxcooldown >= 600) - { - cooldown = 1; - } - // Makes the projectile spawn in the proper position on the X axis - if (player.direction == 1) - { - positionx = position.X + 6; - } - else - { - positionx = position.X - 8; - } - Projectile.NewProjectile(source, positionx, positiony - (player.height / 10f), player.velocity.X, player.velocity.Y, ModContent.ProjectileType(), 0, 0, player.whoAmI, cooldown); - //Resets the cooldown after shooting - if (Roxcooldown >= 600) - { - Roxcooldown = 0; - //"Why yes i did refresh the cooldown whatcha gonna do about it?" -continues on OnHitNPC - Didrefresh = true; - } - return false; - } - else - { - for (int i = 0; i < 2; i++) - { - Vector2 pertubedspeed = new Vector2(velocity.X / 2, -10f * player.gravDir).RotatedByRandom(MathHelper.ToRadians(10f)); - Projectile.NewProjectile(source, position.X, position.Y, pertubedspeed.X, pertubedspeed.Y, ModContent.ProjectileType(), (int)(damage * 0.5), 1f, player.whoAmI, Main.rand.Next(3)); - } - RoxCanAlt = 0; - - return false; - } - } - - public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) - { - if (Item.useStyle == ItemUseStyleID.HoldUp) - { - if (player.whoAmI == Main.myPlayer) - { - //"Well you did refresh the cooldown but like i dont want it to be wasted on an enemy hit so imma ask you for a refund" - if (Didrefresh) - { - Roxcooldown = 600; - Didrefresh = false; - } - //End the alt attack - player.itemAnimation = 0; - player.itemTime = 0; - RoxAlt = false; - RoxCanUse = 0; - player.velocity.Y = -16f; - player.fallStart = (int)(player.position.Y / 16f); - } - } - } - - public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) - { - if (Item.useStyle == ItemUseStyleID.HoldUp) - { - if (player.whoAmI == Main.myPlayer) - { - //"Well you did refresh the cooldown but like i dont want it to be wasted on a player hit so imma ask you for a refund" - if (Didrefresh) - { - Roxcooldown = 600; - Didrefresh = false; - } - //End the alt attack - player.itemAnimation = 0; - player.itemTime = 0; - RoxAlt = false; - RoxCanUse = 0; - player.velocity.Y = -16f; - player.fallStart = (int)(player.position.Y / 16f); - } - } - } - - public override void ModifyTooltips(List list) => list.FindAndReplace("[WOF]", Main.hardMode ? string.Empty : this.GetLocalizedValue("LockedInfo") + "\n"); - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.HellstoneBar, 25). - AddIngredient(ItemID.SoulofNight, 10). - AddIngredient(5). - AddIngredient(ItemID.Obsidian, 10). - AddIngredient(ItemID.StoneBlock, 100). - AddIngredient(ItemID.Amethyst, 2). - AddTile(TileID.Anvils). - Register(); - } - } + public override void AddRecipes() + { + CreateRecipe() + .AddIngredient(ItemID.HellstoneBar, 25) + .AddIngredient(ItemID.SoulofNight, 10) + .AddIngredient(5) + .AddIngredient(ItemID.Obsidian, 10) + .AddIngredient(ItemID.StoneBlock, 100) + .AddIngredient(ItemID.Amethyst, 2) + .AddTile(TileID.Anvils) + .Register(); + } + } } diff --git a/Items/Weapons/Melee/SaharaSlicers.cs b/Items/Weapons/Melee/SaharaSlicers.cs new file mode 100644 index 0000000000..b71443d55f --- /dev/null +++ b/Items/Weapons/Melee/SaharaSlicers.cs @@ -0,0 +1,78 @@ +using CalamityMod.Projectiles.Melee.Shortswords; +using CalamityMod.Projectiles.Rogue; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.DataStructures; +using CalamityMod.Projectiles.Melee; + +namespace CalamityMod.Items.Weapons.Melee +{ + [LegacyName("AquaticDischarge")] + public class SaharaSlicers : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Melee"; + public bool AltProjectile = true; + public override void SetStaticDefaults() + { + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; + } + public override void SetDefaults() + { + Item.width = 43; + Item.height = 34; + Item.noMelee = true; + Item.noUseGraphic = true; + Item.autoReuse = true; + Item.useStyle = ItemUseStyleID.Shoot; + Item.damage = 23; + Item.DamageType = TrueMeleeDamageClass.Instance; + Item.useTime = 12; + Item.useAnimation = 12; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 3.3f; + Item.knockBack = 6f; + Item.UseSound = null; + Item.channel = true; + Item.value = CalamityGlobalItem.Rarity2BuyPrice; + Item.rare = ItemRarityID.Green; + } + public override bool AltFunctionUse(Player player) => true; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + if (player.altFunctionUse == 2) // Bolts + { + Item.useStyle = ItemUseStyleID.Swing; + if (player.Calamity().saharaSlicersBolts > 0) + { + SoundEngine.PlaySound(SoundID.DD2_GhastlyGlaivePierce with { Pitch = 1.5f }, player.Center); + Projectile.NewProjectile(source, position, velocity * 2, ModContent.ProjectileType(), (int)(damage * 1.2), knockback * 1.2f, player.whoAmI, 1); + player.Calamity().saharaSlicersBolts--; + } + else + { + SoundEngine.PlaySound(SoundID.Item7 with { Pitch = 0.2f }, player.Center); + } + } + else // Shortswords + { + Item.useStyle = ItemUseStyleID.Shoot; + if (AltProjectile) + { + SoundEngine.PlaySound(SoundID.Item1 with { Pitch = 0.4f }, player.Center); + Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + } + else + { + SoundEngine.PlaySound(SoundID.Item1 with { Pitch = 0.9f }, player.Center); + Projectile.NewProjectile(source, position, velocity * 0.75f, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + } + AltProjectile = !AltProjectile; + } + return false; + } + public override bool MeleePrefix() => true; + } +} diff --git a/Items/Weapons/Melee/SaharaSlicers.png b/Items/Weapons/Melee/SaharaSlicers.png new file mode 100644 index 0000000000..aecbe93345 Binary files /dev/null and b/Items/Weapons/Melee/SaharaSlicers.png differ diff --git a/Items/Weapons/Melee/SeekingScorcher.cs b/Items/Weapons/Melee/SeekingScorcher.cs index 9de2ff5f31..ae9b2f28c1 100644 --- a/Items/Weapons/Melee/SeekingScorcher.cs +++ b/Items/Weapons/Melee/SeekingScorcher.cs @@ -12,7 +12,8 @@ namespace CalamityMod.Items.Weapons.Melee public new string LocalizationCategory => "Items.Weapons.Melee"; public override void SetDefaults() { - Item.width = 60; + Item.width = 86; + Item.height = 64; Item.damage = 232; Item.noMelee = true; Item.noUseGraphic = true; @@ -23,7 +24,6 @@ namespace CalamityMod.Items.Weapons.Melee Item.knockBack = 8.5f; Item.UseSound = SoundID.Item1; Item.DamageType = DamageClass.MeleeNoSpeed; - Item.height = 62; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 14f; Item.value = CalamityGlobalItem.Rarity12BuyPrice; diff --git a/Items/Weapons/Melee/SeekingScorcher.png b/Items/Weapons/Melee/SeekingScorcher.png index 991e07cd78..7f965ae3fe 100644 Binary files a/Items/Weapons/Melee/SeekingScorcher.png and b/Items/Weapons/Melee/SeekingScorcher.png differ diff --git a/Items/Weapons/Melee/SoulHarvester.cs b/Items/Weapons/Melee/SoulHarvester.cs index 6039f8ddb1..92b7c7d045 100644 --- a/Items/Weapons/Melee/SoulHarvester.cs +++ b/Items/Weapons/Melee/SoulHarvester.cs @@ -47,23 +47,23 @@ namespace CalamityMod.Items.Weapons.Melee SoundEngine.PlaySound(SoundID.Item14, target.Center); int onHitDamage = player.CalcIntDamage(Item.damage); player.ApplyDamageToNPC(target, onHitDamage, 0f, 0, false); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int plagueDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 2f); + Main.dust[plagueDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[plagueDust].scale = 0.5f; + Main.dust[plagueDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int plagueDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 3f); + Main.dust[plagueDust2].noGravity = true; + Main.dust[plagueDust2].velocity *= 5f; + plagueDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 2f); + Main.dust[plagueDust2].velocity *= 2f; } } } @@ -75,23 +75,23 @@ namespace CalamityMod.Items.Weapons.Melee if (target.statLife <= (target.statLifeMax * 0.15f)) { SoundEngine.PlaySound(SoundID.Item14, target.Center); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int plagueDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 2f); + Main.dust[plagueDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[plagueDust].scale = 0.5f; + Main.dust[plagueDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int plagueDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 3f); + Main.dust[plagueDust2].noGravity = true; + Main.dust[plagueDust2].velocity *= 5f; + plagueDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 2f); + Main.dust[plagueDust2].velocity *= 2f; } } } diff --git a/Items/Weapons/Melee/StellarStriker.cs b/Items/Weapons/Melee/StellarStriker.cs index cabf413e86..cd7fc08fbf 100644 --- a/Items/Weapons/Melee/StellarStriker.cs +++ b/Items/Weapons/Melee/StellarStriker.cs @@ -45,53 +45,52 @@ namespace CalamityMod.Items.Weapons.Melee { var source = player.GetSource_ItemUse(Item); SoundEngine.PlaySound(SoundID.Item88, player.Center); - int i = Main.myPlayer; - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + int j = Main.myPlayer; + float cometSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = cometSpeed; } else { - num80 = num72 / num80; + mouseDistance = cometSpeed / mouseDistance; } if (crit) damage /= 2; - int num112 = 2; - for (int num113 = 0; num113 < num112; num113++) + for (int i = 0; i < 2; i++) { - vector2 = new Vector2(player.Center.X + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num113); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X + (float)Main.rand.Next(-40, 41) * 0.03f; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.Center.X + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X + (float)Main.rand.Next(-40, 41) * 0.03f; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float num114 = num78; - float num115 = num79 + (float)Main.rand.Next(-80, 81) * 0.02f; - int proj = Projectile.NewProjectile(source, vector2.X, vector2.Y, num114, num115, ProjectileID.LunarFlare, (int)(damage * 0.5), knockback, i, 0f, (float)Main.rand.Next(3)); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = cometSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX = mouseXDist; + float speedY = mouseYDist + (float)Main.rand.Next(-80, 81) * 0.02f; + int proj = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX, speedY, ProjectileID.LunarFlare, (int)(damage * 0.5), knockback, i, 0f, (float)Main.rand.Next(3)); if (proj.WithinBounds(Main.maxProjectiles)) Main.projectile[proj].DamageType = DamageClass.Melee; } diff --git a/Items/Weapons/Melee/StormRuler.cs b/Items/Weapons/Melee/StormRuler.cs index 81f51e2b91..7014194781 100644 --- a/Items/Weapons/Melee/StormRuler.cs +++ b/Items/Weapons/Melee/StormRuler.cs @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Melee { if (Main.rand.NextBool(5)) { - int num250 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 187, (float)(player.direction * 2), 0f, 150, default, 1.3f); - Main.dust[num250].velocity *= 0.2f; + int swingDust = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 187, (float)(player.direction * 2), 0f, 150, default, 1.3f); + Main.dust[swingDust].velocity *= 0.2f; } } diff --git a/Items/Weapons/Melee/StormSaber.cs b/Items/Weapons/Melee/StormSaber.cs index 6a80e16a4c..b95302eb72 100644 --- a/Items/Weapons/Melee/StormSaber.cs +++ b/Items/Weapons/Melee/StormSaber.cs @@ -47,8 +47,8 @@ namespace CalamityMod.Items.Weapons.Melee { if (Main.rand.NextBool(5)) { - int num250 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 187, (float)(player.direction * 2), 0f, 150, default, 1.3f); - Main.dust[num250].velocity *= 0.2f; + int swingDust = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 187, (float)(player.direction * 2), 0f, 150, default, 1.3f); + Main.dust[swingDust].velocity *= 0.2f; } } } diff --git a/Items/Weapons/Melee/SulphurousGrabber.cs b/Items/Weapons/Melee/SulphurousGrabber.cs index 5e7f18f83c..d7179f663d 100644 --- a/Items/Weapons/Melee/SulphurousGrabber.cs +++ b/Items/Weapons/Melee/SulphurousGrabber.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.width = 50; Item.height = 36; Item.DamageType = DamageClass.MeleeNoSpeed; - Item.damage = 55; + Item.damage = 40; Item.knockBack = 3.5f; Item.useTime = 25; Item.useAnimation = 25; diff --git a/Items/Weapons/Melee/Swordsplosion.cs b/Items/Weapons/Melee/Swordsplosion.cs index dec805925a..b0f1d4aa32 100644 --- a/Items/Weapons/Melee/Swordsplosion.cs +++ b/Items/Weapons/Melee/Swordsplosion.cs @@ -48,41 +48,40 @@ namespace CalamityMod.Items.Weapons.Melee type = ModContent.ProjectileType(); break; } - float num72 = Main.rand.Next(22, 30); - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X + vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y + vector2.Y; + float projSpeed = Main.rand.Next(22, 30); + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X + realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y + realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight + (float)Main.mouseY + vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight + (float)Main.mouseY + realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - int num107 = 16; - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 16; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)-(float)player.direction + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); - vector2.X = (vector2.X + player.Center.X) / 2f; - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-360, 361) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-360, 361) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 2f, 0f); + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)-(float)player.direction + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f; + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = projSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-360, 361) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-360, 361) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 2f, 0f); } return false; } @@ -91,9 +90,9 @@ namespace CalamityMod.Items.Weapons.Melee { if (Main.rand.NextBool(5)) { - int num250 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 66, (float)(player.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); - Main.dust[num250].velocity *= 0.2f; - Main.dust[num250].noGravity = true; + int swingDust = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 66, (float)(player.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); + Main.dust[swingDust].velocity *= 0.2f; + Main.dust[swingDust].noGravity = true; } } } diff --git a/Items/Weapons/Melee/TenebreusTides.cs b/Items/Weapons/Melee/TenebreusTides.cs index e6e93840bc..f982321710 100644 --- a/Items/Weapons/Melee/TenebreusTides.cs +++ b/Items/Weapons/Melee/TenebreusTides.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { - Item.damage = 80; + Item.damage = 120; Item.knockBack = 4.5f; Item.DamageType = DamageClass.Melee; Item.useAnimation = Item.useTime = 14; diff --git a/Items/Weapons/Melee/Terratomere.cs b/Items/Weapons/Melee/Terratomere.cs index 1c8e2d744d..73678c2313 100644 --- a/Items/Weapons/Melee/Terratomere.cs +++ b/Items/Weapons/Melee/Terratomere.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 60; Item.height = 66; - Item.damage = 303; + Item.damage = 370; Item.DamageType = DamageClass.Melee; Item.useAnimation = 21; Item.useTime = 21; diff --git a/Items/Weapons/Melee/TheEnforcer.cs b/Items/Weapons/Melee/TheEnforcer.cs index c0826412bb..0805acfa6f 100644 --- a/Items/Weapons/Melee/TheEnforcer.cs +++ b/Items/Weapons/Melee/TheEnforcer.cs @@ -42,48 +42,47 @@ namespace CalamityMod.Items.Weapons.Melee { var source = player.GetSource_ItemUse(Item); SoundEngine.PlaySound(SoundID.Item73, player.Center); - int i = Main.myPlayer; - float num72 = 3f; + int j = Main.myPlayer; + float flameSpeed = 3f; player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = Main.mouseX + Main.screenPosition.X + vector2.X; - float num79 = Main.mouseY + Main.screenPosition.Y + vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = Main.mouseX + Main.screenPosition.X + realPlayerPos.X; + float mouseYDist = Main.mouseY + Main.screenPosition.Y + realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + Main.screenHeight + Main.mouseY + vector2.Y; + mouseYDist = Main.screenPosition.Y + Main.screenHeight + Main.mouseY + realPlayerPos.Y; } - float num80 = (float)Math.Sqrt(num78 * num78 + num79 * num79); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt(mouseXDist * mouseXDist + mouseYDist * mouseYDist); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = player.direction; + mouseYDist = 0f; + mouseDistance = flameSpeed; } else { - num80 = num72 / num80; + mouseDistance = flameSpeed / mouseDistance; } - int num107 = 5; int essenceDamage = player.CalcIntDamage(0.25f * Item.damage); - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 5; i++) { - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(401) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-400, 401); - vector2.Y -= 100 * num108; - num78 = Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(401) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + Main.rand.Next(-400, 401); + realPlayerPos.Y -= 100 * i; + mouseXDist = Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt(num78 * num78 + num79 * num79); - num80 = num72 / num80; - Projectile.NewProjectile(source, vector2, Vector2.Zero, ModContent.ProjectileType(), essenceDamage, 0f, i, 0f, Main.rand.Next(3)); + mouseDistance = (float)Math.Sqrt(mouseXDist * mouseXDist + mouseYDist * mouseYDist); + mouseDistance = flameSpeed / mouseDistance; + Projectile.NewProjectile(source, realPlayerPos, Vector2.Zero, ModContent.ProjectileType(), essenceDamage, 0f, i, 0f, Main.rand.Next(3)); } } @@ -91,48 +90,47 @@ namespace CalamityMod.Items.Weapons.Melee { var source = player.GetSource_ItemUse(Item); SoundEngine.PlaySound(SoundID.Item73, player.Center); - int i = Main.myPlayer; - float num72 = 3f; + int j = Main.myPlayer; + float flameSpeed = 3f; player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = Main.mouseX + Main.screenPosition.X + vector2.X; - float num79 = Main.mouseY + Main.screenPosition.Y + vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = Main.mouseX + Main.screenPosition.X + realPlayerPos.X; + float mouseYDist = Main.mouseY + Main.screenPosition.Y + realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + Main.screenHeight + Main.mouseY + vector2.Y; + mouseYDist = Main.screenPosition.Y + Main.screenHeight + Main.mouseY + realPlayerPos.Y; } - float num80 = (float)Math.Sqrt(num78 * num78 + num79 * num79); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt(mouseXDist * mouseXDist + mouseYDist * mouseYDist); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = player.direction; + mouseYDist = 0f; + mouseDistance = flameSpeed; } else { - num80 = num72 / num80; + mouseDistance = flameSpeed / mouseDistance; } - int num107 = 5; int essenceDamage = player.CalcIntDamage(0.25f * Item.damage); - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 5; i++) { - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(401) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-400, 401); - vector2.Y -= 100 * num108; - num78 = Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(401) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + Main.rand.Next(-400, 401); + realPlayerPos.Y -= 100 * i; + mouseXDist = Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt(num78 * num78 + num79 * num79); - num80 = num72 / num80; - Projectile.NewProjectile(source, vector2, Vector2.Zero, ModContent.ProjectileType(), essenceDamage, 0f, i, 0f, Main.rand.Next(3)); + mouseDistance = (float)Math.Sqrt(mouseXDist * mouseXDist + mouseYDist * mouseYDist); + mouseDistance = flameSpeed / mouseDistance; + Projectile.NewProjectile(source, realPlayerPos, Vector2.Zero, ModContent.ProjectileType(), essenceDamage, 0f, i, 0f, Main.rand.Next(3)); } } diff --git a/Items/Weapons/Melee/TheGodsGambit.cs b/Items/Weapons/Melee/TheGodsGambit.cs index a462d5b460..c447f7e2fe 100644 --- a/Items/Weapons/Melee/TheGodsGambit.cs +++ b/Items/Weapons/Melee/TheGodsGambit.cs @@ -19,8 +19,8 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { - Item.width = 40; - Item.height = 26; + Item.width = 36; + Item.height = 38; Item.DamageType = DamageClass.MeleeNoSpeed; Item.damage = 29; Item.knockBack = 3.5f; diff --git a/Items/Weapons/Melee/TheGodsGambit.png b/Items/Weapons/Melee/TheGodsGambit.png index 2d8201ded6..05addcdf2e 100644 Binary files a/Items/Weapons/Melee/TheGodsGambit.png and b/Items/Weapons/Melee/TheGodsGambit.png differ diff --git a/Items/Weapons/Melee/TheMutilator.cs b/Items/Weapons/Melee/TheMutilator.cs index 57afc04611..da73273a8d 100644 --- a/Items/Weapons/Melee/TheMutilator.cs +++ b/Items/Weapons/Melee/TheMutilator.cs @@ -49,23 +49,23 @@ namespace CalamityMod.Items.Weapons.Melee target.position.Y += target.height / 2; target.position.X -= target.width / 2; target.position.Y -= target.height / 2; - for (int num621 = 0; num621 < 30; num621++) + for (int i = 0; i < 30; i++) { - int num622 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 5, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int bloodDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 5, 0f, 0f, 100, default, 2f); + Main.dust[bloodDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[bloodDust].scale = 0.5f; + Main.dust[bloodDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 50; num623++) + for (int j = 0; j < 50; j++) { - int num624 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 5, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 5, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int bloodDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 5, 0f, 0f, 100, default, 3f); + Main.dust[bloodDust2].noGravity = true; + Main.dust[bloodDust2].velocity *= 5f; + bloodDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 5, 0f, 0f, 100, default, 2f); + Main.dust[bloodDust2].velocity *= 2f; } } } diff --git a/Items/Weapons/Melee/TyphonsGreed.cs b/Items/Weapons/Melee/TyphonsGreed.cs index c4daab56c8..bbcc1bc36e 100644 --- a/Items/Weapons/Melee/TyphonsGreed.cs +++ b/Items/Weapons/Melee/TyphonsGreed.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Melee public new string LocalizationCategory => "Items.Weapons.Melee"; public override void SetDefaults() { - Item.damage = 84; + Item.damage = 102; Item.DamageType = DamageClass.Melee; Item.width = 16; Item.height = 16; diff --git a/Items/Weapons/Melee/UltimusCleaver.cs b/Items/Weapons/Melee/UltimusCleaver.cs index 4d0845dc34..31df9995be 100644 --- a/Items/Weapons/Melee/UltimusCleaver.cs +++ b/Items/Weapons/Melee/UltimusCleaver.cs @@ -34,42 +34,42 @@ namespace CalamityMod.Items.Weapons.Melee target.AddBuff(BuffID.OnFire3, 360); int onHitDamage = player.CalcIntDamage(Item.damage); player.ApplyDamageToNPC(target, onHitDamage, 0f, 0, false); - float num50 = 1.7f; - float num51 = 0.8f; - float num52 = 2f; - Vector2 value3 = (target.rotation - 1.57079637f).ToRotationVector2(); - Vector2 value4 = value3 * target.velocity.Length(); + float firstDustScale = 1.7f; + float secondDustScale = 0.8f; + float thirdDustScale = 2f; + Vector2 dustRotation = (target.rotation - 1.57079637f).ToRotationVector2(); + Vector2 dustVelocity = dustRotation * target.velocity.Length(); SoundEngine.PlaySound(SoundID.Item14, target.Center); - int num3; - for (int num53 = 0; num53 < 40; num53 = num3 + 1) + int increment; + for (int i = 0; i < 40; i = increment + 1) { - int num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 200, default, num50); - Dust dust = Main.dust[num54]; + int swingDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 200, default, firstDustScale); + Dust dust = Main.dust[swingDust]; dust.position = target.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)target.width / 2f; dust.noGravity = true; dust.velocity.Y -= 6f; dust.velocity *= 3f; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 100, default, num51); + dust.velocity += dustVelocity * Main.rand.NextFloat(); + swingDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 100, default, secondDustScale); dust.position = target.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)target.width / 2f; dust.velocity.Y -= 6f; dust.velocity *= 2f; dust.noGravity = true; dust.fadeIn = 1f; dust.color = Color.Crimson * 0.5f; - dust.velocity += value4 * Main.rand.NextFloat(); - num3 = num53; + dust.velocity += dustVelocity * Main.rand.NextFloat(); + increment = i; } - for (int num55 = 0; num55 < 20; num55 = num3 + 1) + for (int j = 0; j < 20; j = increment + 1) { - int num56 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 0, default, num52); - Dust dust = Main.dust[num56]; + int swingDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 0, default, thirdDustScale); + Dust dust = Main.dust[swingDust2]; dust.position = target.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)target.velocity.ToRotation(), default) * (float)target.width / 3f; dust.noGravity = true; dust.velocity.Y -= 6f; dust.velocity *= 0.5f; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); - num3 = num55; + dust.velocity += dustVelocity * (0.6f + 0.6f * Main.rand.NextFloat()); + increment = j; } } @@ -83,65 +83,65 @@ namespace CalamityMod.Items.Weapons.Melee player.itemAnimation == (int)(player.itemAnimationMax * 0.7) || player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) { - float num339 = 0f; - float num340 = 0f; - float num341 = 0f; - float num342 = 0f; + float sparkYVel = 0f; + float sparkXVel = 0f; + float sparkYSpawn = 0f; + float sparkXSpawn = 0f; if (player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) { - num339 = -7f; + sparkYVel = -7f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) { - num339 = -6f; - num340 = 2f; + sparkYVel = -6f; + sparkXVel = 2f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.5)) { - num339 = -4f; - num340 = 4f; + sparkYVel = -4f; + sparkXVel = 4f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.3)) { - num339 = -2f; - num340 = 6f; + sparkYVel = -2f; + sparkXVel = 6f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.1)) { - num340 = 7f; + sparkXVel = 7f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) { - num342 = 26f; + sparkXSpawn = 26f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.3)) { - num342 -= 4f; - num341 -= 20f; + sparkXSpawn -= 4f; + sparkYSpawn -= 20f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.1)) { - num341 += 6f; + sparkYSpawn += 6f; } if (player.direction == -1) { if (player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) { - num342 -= 8f; + sparkXSpawn -= 8f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) { - num342 -= 6f; + sparkXSpawn -= 6f; } } - num339 *= 1.5f; - num340 *= 1.5f; - num342 *= (float)player.direction; - num341 *= player.gravDir; + sparkYVel *= 1.5f; + sparkXVel *= 1.5f; + sparkXSpawn *= (float)player.direction; + sparkYSpawn *= player.gravDir; var source = player.GetSource_ItemUse(Item); int damage = (int)player.GetTotalDamage().ApplyTo(Item.damage * 0.1f); - Projectile.NewProjectile(source, (float)(hitbox.X + hitbox.Width / 2) + num342, (float)(hitbox.Y + hitbox.Height / 2) + num341, - (float)player.direction * num340, num339 * player.gravDir, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(source, (float)(hitbox.X + hitbox.Width / 2) + sparkXSpawn, (float)(hitbox.Y + hitbox.Height / 2) + sparkYSpawn, + (float)player.direction * sparkXVel, sparkYVel * player.gravDir, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 0f, 0f); } } } diff --git a/Items/Weapons/Melee/Violence.cs b/Items/Weapons/Melee/Violence.cs index f041aec66d..e4640a714f 100644 --- a/Items/Weapons/Melee/Violence.cs +++ b/Items/Weapons/Melee/Violence.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { Item.height = Item.width = 142; - Item.damage = 404; + Item.damage = 435; Item.DamageType = DamageClass.MeleeNoSpeed; Item.noMelee = true; Item.useTurn = true; diff --git a/Items/Weapons/Ranged/Alluvion.cs b/Items/Weapons/Ranged/Alluvion.cs index 37a443be04..80bdc77a98 100644 --- a/Items/Weapons/Ranged/Alluvion.cs +++ b/Items/Weapons/Ranged/Alluvion.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo spawnSource, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { Vector2 source = player.RotatedRelativePoint(player.MountedCenter); - float num117 = MathHelper.Pi * 0.1f; + float tenthPi = MathHelper.Pi * 0.1f; int totalProjectiles = 6; velocity.Normalize(); @@ -46,8 +46,8 @@ namespace CalamityMod.Items.Weapons.Ranged bool canHit = Collision.CanHit(source, 0, 0, source + velocity, 0, 0); for (int i = 0; i < totalProjectiles; i++) { - float num120 = i - (totalProjectiles - 1f) / 2f; - Vector2 offset = velocity.RotatedBy(num117 * num120); + float arrowOffset = i - (totalProjectiles - 1f) / 2f; + Vector2 offset = velocity.RotatedBy(tenthPi * arrowOffset); if (!canHit) offset -= velocity; diff --git a/Items/Weapons/Ranged/AquashardShotgun.cs b/Items/Weapons/Ranged/AquashardShotgun.cs index 45bf04d4c1..412e321103 100644 --- a/Items/Weapons/Ranged/AquashardShotgun.cs +++ b/Items/Weapons/Ranged/AquashardShotgun.cs @@ -40,8 +40,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) { - int num6 = Main.rand.Next(2, 4); - for (int index = 0; index < num6; ++index) + int projAmt = Main.rand.Next(2, 4); + for (int index = 0; index < projAmt; ++index) { float SpeedX = velocity.X + Main.rand.Next(-40, 41) * 0.05f; float SpeedY = velocity.Y + Main.rand.Next(-40, 41) * 0.05f; diff --git a/Items/Weapons/Ranged/ArterialAssault.cs b/Items/Weapons/Ranged/ArterialAssault.cs index 0d6dab7648..ee342f4866 100644 --- a/Items/Weapons/Ranged/ArterialAssault.cs +++ b/Items/Weapons/Ranged/ArterialAssault.cs @@ -37,46 +37,46 @@ 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) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float arrowSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = arrowSpeed; } else { - num80 = num72 / num80; + mouseDistance = arrowSpeed / mouseDistance; } - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (-(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f; - vector2.Y -= 100f; - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (-(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f; + realPlayerPos.Y -= 100f; + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78; - float speedY5 = num79; - int shotArrow = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = arrowSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist; + float speedY5 = mouseYDist; + int shotArrow = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI); Main.projectile[shotArrow].noDropItem = true; Main.projectile[shotArrow].tileCollide = false; Main.projectile[shotArrow].timeLeft = (int)(Main.projectile[shotArrow].timeLeft * Main.projectile[shotArrow].MaxUpdates * 0.75f); @@ -93,4 +93,4 @@ namespace CalamityMod.Items.Weapons.Ranged Register(); } } -} \ No newline at end of file +} diff --git a/Items/Weapons/Ranged/AuroraBlazer.cs b/Items/Weapons/Ranged/AuroraBlazer.cs index 00c45e3909..79b5115960 100644 --- a/Items/Weapons/Ranged/AuroraBlazer.cs +++ b/Items/Weapons/Ranged/AuroraBlazer.cs @@ -13,15 +13,16 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public override void SetDefaults() { - Item.damage = 49; + Item.damage = 74; Item.DamageType = DamageClass.Ranged; - Item.useTime = 18; - Item.useAnimation = 18; + Item.useTime = 5; + Item.useAnimation = 30; Item.knockBack = 2f; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 7.5f; Item.useAmmo = AmmoID.Gel; + Item.consumeAmmoOnFirstShotOnly = true; Item.width = 68; Item.height = 36; @@ -32,21 +33,8 @@ namespace CalamityMod.Items.Weapons.Ranged Item.rare = ItemRarityID.Lime; } - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - float SpeedX = velocity.X + Main.rand.NextFloat(-15f, 15f) * 0.05f; - float SpeedY = velocity.Y + Main.rand.NextFloat(-15f, 15f) * 0.05f; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI, Main.rand.Next(4, 11), 0f); - return false; - } - - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request("CalamityMod/Items/Weapons/Ranged/AuroraBlazerGlow").Value); - } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) => Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request(Texture + "Glow").Value); public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= 60; } } diff --git a/Items/Weapons/Ranged/Barinade.cs b/Items/Weapons/Ranged/Barinade.cs index ce42ab3e46..73754654d7 100644 --- a/Items/Weapons/Ranged/Barinade.cs +++ b/Items/Weapons/Ranged/Barinade.cs @@ -12,32 +12,29 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public override void SetDefaults() { - Item.damage = 9; + Item.damage = 4; Item.DamageType = DamageClass.Ranged; Item.width = 30; Item.height = 44; - Item.useTime = 26; - Item.useAnimation = 26; + Item.useTime = 22; + Item.useAnimation = 22; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.knockBack = 2f; + Item.knockBack = 2.2f; Item.value = CalamityGlobalItem.Rarity2BuyPrice; Item.rare = ItemRarityID.Green; Item.UseSound = SoundID.Item5; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 14f; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 15f; Item.useAmmo = AmmoID.Arrow; Item.Calamity().canFirePointBlankShots = true; } - + public override Vector2? HoldoutOffset() => new Vector2(0, 4); public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (CalamityUtils.CheckWoodenAmmo(type, player)) - Projectile.NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI); - else - Projectile.NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, type, damage, knockback, player.whoAmI); - + Projectile.NewProjectile(source, position + velocity.RotatedBy(-0.55f), velocity.RotatedBy(0.025f), ModContent.ProjectileType(), damage, knockback, player.whoAmI); + Projectile.NewProjectile(source, position + velocity.RotatedBy(0.55f), velocity.RotatedBy(-0.025f), ModContent.ProjectileType(), damage, knockback, player.whoAmI); return false; } } diff --git a/Items/Weapons/Ranged/Barinade.png b/Items/Weapons/Ranged/Barinade.png index 724b21915d..0d4a6b1bf8 100644 Binary files a/Items/Weapons/Ranged/Barinade.png and b/Items/Weapons/Ranged/Barinade.png differ diff --git a/Items/Weapons/Ranged/BladedgeGreatbow.cs b/Items/Weapons/Ranged/BladedgeGreatbow.cs index 00d8ab463a..3db7c451d2 100644 --- a/Items/Weapons/Ranged/BladedgeGreatbow.cs +++ b/Items/Weapons/Ranged/BladedgeGreatbow.cs @@ -45,21 +45,21 @@ namespace CalamityMod.Items.Weapons.Ranged int index = Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI); Main.projectile[index].noDropItem = true; } - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); float PiOver10 = MathHelper.Pi * 0.1f; - Vector2 vector7 = velocity; - vector7.Normalize(); - vector7 *= 10f; - bool flag11 = Collision.CanHit(vector2, 0, 0, vector2 + vector7, 0, 0); - for (int num119 = 0; num119 < 2; num119++) + Vector2 arrowVel = velocity; + arrowVel.Normalize(); + arrowVel *= 10f; + bool arrowHitsTiles = Collision.CanHit(realPlayerPos, 0, 0, realPlayerPos + arrowVel, 0, 0); + for (int i = 0; i < 2; i++) { - float num120 = (float)num119 - 1f / 2f; - Vector2 value9 = vector7.RotatedBy((double)(PiOver10 * num120), default); - if (!flag11) + float arrowOffset = (float)i - 1f / 2f; + Vector2 offsetSpawn = arrowVel.RotatedBy((double)(PiOver10 * arrowOffset), default); + if (!arrowHitsTiles) { - value9 -= vector7; + offsetSpawn -= arrowVel; } - int projectile = Projectile.NewProjectile(source, vector2.X + value9.X, vector2.Y + value9.Y, velocity.X, velocity.Y, ProjectileID.Leaf, damage, 0f, player.whoAmI); + int projectile = Projectile.NewProjectile(source, realPlayerPos.X + offsetSpawn.X, realPlayerPos.Y + offsetSpawn.Y, velocity.X, velocity.Y, ProjectileID.Leaf, damage, 0f, player.whoAmI); if (projectile.WithinBounds(Main.maxProjectiles)) Main.projectile[projectile].DamageType = DamageClass.Ranged; } diff --git a/Items/Weapons/Ranged/BlightSpewer.cs b/Items/Weapons/Ranged/BlightSpewer.cs index ec4708815f..472d0d2b02 100644 --- a/Items/Weapons/Ranged/BlightSpewer.cs +++ b/Items/Weapons/Ranged/BlightSpewer.cs @@ -1,6 +1,7 @@ using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -10,26 +11,33 @@ namespace CalamityMod.Items.Weapons.Ranged public class BlightSpewer : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static readonly SoundStyle Nanomachines = new("CalamityMod/Sounds/Item/NanoSwarm") { PitchVariance = 0.45f, Volume = 0.4f }; public override void SetDefaults() { - Item.damage = 110; + Item.damage = 52; Item.DamageType = DamageClass.Ranged; Item.width = 76; Item.height = 36; - Item.useTime = 10; - Item.useAnimation = 30; + Item.useTime = 19; + Item.useAnimation = 19; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.knockBack = 2f; + Item.knockBack = 1.5f; Item.UseSound = SoundID.Item34; Item.value = CalamityGlobalItem.Rarity8BuyPrice; Item.rare = ItemRarityID.Yellow; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 7.5f; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 7f; Item.useAmmo = AmmoID.Gel; } - + public override bool CanConsumeAmmo(Item ammo, Player player) + { + if (Main.rand.Next(0, 100) < 50) + return false; + return true; + } public override Vector2? HoldoutOffset() { return new Vector2(-10, 0); diff --git a/Items/Weapons/Ranged/BlissfulBombardier.cs b/Items/Weapons/Ranged/BlissfulBombardier.cs index 54b1a90196..1351bf6e8a 100644 --- a/Items/Weapons/Ranged/BlissfulBombardier.cs +++ b/Items/Weapons/Ranged/BlissfulBombardier.cs @@ -33,9 +33,13 @@ namespace CalamityMod.Items.Weapons.Ranged public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + // Figure out which rocket is used + public int RocketType; + public override void OnConsumeAmmo(Item ammo, Player player) => RocketType = ammo.type; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile.NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, RocketType); return false; } } diff --git a/Items/Weapons/Ranged/BloodBoiler.cs b/Items/Weapons/Ranged/BloodBoiler.cs index 9348f54939..3764bf9fc5 100644 --- a/Items/Weapons/Ranged/BloodBoiler.cs +++ b/Items/Weapons/Ranged/BloodBoiler.cs @@ -3,6 +3,7 @@ using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -12,21 +13,26 @@ namespace CalamityMod.Items.Weapons.Ranged public class BloodBoiler : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static readonly SoundStyle Heartbeat = new("CalamityMod/Sounds/Item/Heartbeat") { PitchVariance = 0.2f, Volume = 0.55f }; + + public bool shotReturn = false; public override void SetDefaults() { - Item.damage = 145; + Item.damage = 115; Item.DamageType = DamageClass.Ranged; Item.width = 60; Item.height = 30; Item.useTime = 5; - Item.useAnimation = 15; + Item.useAnimation = 25; Item.autoReuse = true; + Item.UseSound = Heartbeat; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 4f; Item.value = CalamityGlobalItem.Rarity12BuyPrice; Item.rare = ModContent.RarityType(); - Item.shootSpeed = 12f; + Item.shootSpeed = 9.5f; Item.shoot = ModContent.ProjectileType(); } @@ -34,15 +40,18 @@ 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) { - if (Main.rand.NextFloat() > 0.75f) - --player.statLife; + shotReturn = !shotReturn; + if (Main.rand.NextFloat() > 0.60f) + player.statLife -= 1; if (player.statLife <= 0) { PlayerDeathReason pdr = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.BloodBoiler" + Main.rand.Next(1, 2 + 1)).Format(player.name)); player.KillMe(pdr, 1000.0, 0, false); return false; } - return true; + Vector2 newVel = velocity.RotatedBy(shotReturn ? 0.03f : -0.03f); + Projectile.NewProjectile(source, position, newVel, type, damage, knockback, player.whoAmI, 0, 0, shotReturn ? 5 : 0); + return false; } public override void AddRecipes() diff --git a/Items/Weapons/Ranged/CleansingBlaze.cs b/Items/Weapons/Ranged/CleansingBlaze.cs index 19e4d8004b..c63bc6e7df 100644 --- a/Items/Weapons/Ranged/CleansingBlaze.cs +++ b/Items/Weapons/Ranged/CleansingBlaze.cs @@ -16,12 +16,12 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public override void SetDefaults() { - Item.damage = 130; + Item.damage = 290; Item.DamageType = DamageClass.Ranged; - Item.width = 64; - Item.height = 32; + Item.width = 108; + Item.height = 38; Item.useTime = 3; - Item.useAnimation = 12; + Item.useAnimation = 24; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 4f; @@ -29,39 +29,26 @@ namespace CalamityMod.Items.Weapons.Ranged Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 14f; + Item.shootSpeed = 11f; Item.useAmmo = AmmoID.Gel; + Item.consumeAmmoOnFirstShotOnly = true; Item.rare = ModContent.RarityType(); } - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request("CalamityMod/Items/Weapons/Ranged/CleansingBlazeGlow").Value); - } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) => Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request(Texture + "Glow").Value); public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int num6 = Main.rand.Next(2, 4); - for (int index = 0; index < num6; ++index) + Vector2 newPos = position + velocity.SafeNormalize(Vector2.UnitX) * 36f; + for (int i = 0; i < 3; i++) { - float SpeedX = velocity.X + (float)Main.rand.Next(-15, 16) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-15, 16) * 0.05f; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI, 0f, 0f); + Vector2 newVel = velocity.RotatedByRandom(MathHelper.ToRadians(5f)); + Projectile.NewProjectile(source, newPos, newVel, type, damage, knockback, player.whoAmI); } return false; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-5, 0); - } - - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 90) - return false; - return true; - } + public override Vector2? HoldoutOffset() => new Vector2(-20, 0); public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/CleansingBlaze.png b/Items/Weapons/Ranged/CleansingBlaze.png index e185d1db7e..bdf253d486 100644 Binary files a/Items/Weapons/Ranged/CleansingBlaze.png and b/Items/Weapons/Ranged/CleansingBlaze.png differ diff --git a/Items/Weapons/Ranged/CleansingBlazeGlow.png b/Items/Weapons/Ranged/CleansingBlazeGlow.png index a09f3d2248..3a8bdd621d 100644 Binary files a/Items/Weapons/Ranged/CleansingBlazeGlow.png and b/Items/Weapons/Ranged/CleansingBlazeGlow.png differ diff --git a/Items/Weapons/Ranged/ConferenceCall.cs b/Items/Weapons/Ranged/ConferenceCall.cs index 3359b6c12f..87052ebb5e 100644 --- a/Items/Weapons/Ranged/ConferenceCall.cs +++ b/Items/Weapons/Ranged/ConferenceCall.cs @@ -79,18 +79,18 @@ namespace CalamityMod.Items.Weapons.Ranged if (targetArrayIndex == 0) return false; - Vector2 vector2; + Vector2 targetPosition; int extraBulletDamage = (int)(damage * 0.8); for (int j = 0; j < targetArrayIndex; j++) { - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); - vector2.Y -= 100 * j; + targetPosition = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + targetPosition.X = (targetPosition.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); + targetPosition.Y -= 100 * j; - Vector2 velocity2 = CalamityUtils.CalculatePredictiveAimToTarget(vector2, Main.npc[targets[j]], Item.shootSpeed); + Vector2 extraBulletVel = CalamityUtils.CalculatePredictiveAimToTarget(targetPosition, Main.npc[targets[j]], Item.shootSpeed); - int proj = Projectile.NewProjectile(source, vector2, velocity2, type, extraBulletDamage, knockback, player.whoAmI); + int proj = Projectile.NewProjectile(source, targetPosition, extraBulletVel, type, extraBulletDamage, knockback, player.whoAmI); Main.projectile[proj].extraUpdates += 2; Main.projectile[proj].tileCollide = false; Main.projectile[proj].timeLeft /= 2; @@ -104,13 +104,13 @@ namespace CalamityMod.Items.Weapons.Ranged { int randomTarget = Main.rand.Next(targetArrayIndex); - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); - vector2.Y -= 100 * randomTarget; + targetPosition = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + targetPosition.X = (targetPosition.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); + targetPosition.Y -= 100 * randomTarget; - Vector2 velocity2 = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - vector2) * Item.shootSpeed; + Vector2 extraBulletVel = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - targetPosition) * Item.shootSpeed; - int proj = Projectile.NewProjectile(source, vector2, velocity2, type, extraBulletDamage, knockback, player.whoAmI); + int proj = Projectile.NewProjectile(source, targetPosition, extraBulletVel, type, extraBulletDamage, knockback, player.whoAmI); Main.projectile[proj].extraUpdates += 2; Main.projectile[proj].tileCollide = false; Main.projectile[proj].timeLeft /= 2; diff --git a/Items/Weapons/Ranged/ContinentalGreatbow.cs b/Items/Weapons/Ranged/ContinentalGreatbow.cs index ffeb621ef6..77f85f7128 100644 --- a/Items/Weapons/Ranged/ContinentalGreatbow.cs +++ b/Items/Weapons/Ranged/ContinentalGreatbow.cs @@ -53,8 +53,8 @@ namespace CalamityMod.Items.Weapons.Ranged { type = ProjectileID.FireArrow; } - int num121 = Projectile.NewProjectile(spawnSource, source + offset, velocity, type, damage, knockback, player.whoAmI); - Main.projectile[num121].noDropItem = true; + int baseArrow = Projectile.NewProjectile(spawnSource, source + offset, velocity, type, damage, knockback, player.whoAmI); + Main.projectile[baseArrow].noDropItem = true; } for (int i = 0; i < 2; i++) { diff --git a/Items/Weapons/Ranged/CrackshotColt.cs b/Items/Weapons/Ranged/CrackshotColt.cs index 3db17a652c..6134480b24 100644 --- a/Items/Weapons/Ranged/CrackshotColt.cs +++ b/Items/Weapons/Ranged/CrackshotColt.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Ranged { public new string LocalizationCategory => "Items.Weapons.Ranged"; // Crackshot Colt uses the same sound as Midas Prime, just quieter. - private static SoundStyle ShootSound => MidasPrime.ShootSound with { Volume = 0.6f }; + private static SoundStyle ShootSound => MidasPrime.ShootSound with { Volume = 0.4f }; public override void SetDefaults() { @@ -114,7 +114,7 @@ namespace CalamityMod.Items.Weapons.Ranged #region Firing Animation public override void UseStyle(Player player, Rectangle heldItemFrame) { - player.direction = Math.Sign((player.Calamity().mouseWorld - player.Center).X); + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); float itemRotation = player.compositeFrontArm.rotation + MathHelper.PiOver2 * player.gravDir; Vector2 itemPosition = player.MountedCenter + itemRotation.ToRotationVector2() * 7f; @@ -128,7 +128,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void UseItemFrame(Player player) { - player.direction = Math.Sign((player.Calamity().mouseWorld - player.Center).X); + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); float animProgress = 1 - player.itemTime / (float)player.itemTimeMax; float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; diff --git a/Items/Weapons/Ranged/DeadSunsWind.cs b/Items/Weapons/Ranged/DeadSunsWind.cs index b107626c62..89296548fd 100644 --- a/Items/Weapons/Ranged/DeadSunsWind.cs +++ b/Items/Weapons/Ranged/DeadSunsWind.cs @@ -2,6 +2,7 @@ using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -11,18 +12,21 @@ namespace CalamityMod.Items.Weapons.Ranged public class DeadSunsWind : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static readonly SoundStyle Shoot = new("CalamityMod/Sounds/Item/DeadSunShot") { PitchVariance = 0.35f, Volume = 0.4f }; + public static readonly SoundStyle Ricochet = new("CalamityMod/Sounds/Item/DeadSunRicochet") { Volume = 0.35f }; + public static readonly SoundStyle Explosion = new("CalamityMod/Sounds/Item/DeadSunExplosion") { Volume = 0.5f }; public override void SetDefaults() { - Item.damage = 80; + Item.damage = 100; Item.DamageType = DamageClass.Ranged; Item.width = 70; Item.height = 24; - Item.useTime = 6; - Item.useAnimation = 18; + Item.useTime = Item.useAnimation = 22; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 3.5f; - Item.UseSound = SoundID.Item34; + Item.UseSound = Shoot; Item.value = CalamityGlobalItem.Rarity9BuyPrice; Item.rare = ItemRarityID.Cyan; Item.autoReuse = true; @@ -31,17 +35,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.useAmmo = AmmoID.Gel; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-10, 0); - } - - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 70) - return false; - return true; - } + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/Deathwind.cs b/Items/Weapons/Ranged/Deathwind.cs index f53623d067..9b38ae885c 100644 --- a/Items/Weapons/Ranged/Deathwind.cs +++ b/Items/Weapons/Ranged/Deathwind.cs @@ -50,8 +50,8 @@ namespace CalamityMod.Items.Weapons.Ranged } else { - int num121 = Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, (int)(damage * 0.8), knockback, player.whoAmI); - Main.projectile[num121].noDropItem = true; + int baseArrow = Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, (int)(damage * 0.8), knockback, player.whoAmI); + Main.projectile[baseArrow].noDropItem = true; } } return false; diff --git a/Items/Weapons/Ranged/Disseminator.cs b/Items/Weapons/Ranged/Disseminator.cs index a90fb1e83c..d96ddb02bd 100644 --- a/Items/Weapons/Ranged/Disseminator.cs +++ b/Items/Weapons/Ranged/Disseminator.cs @@ -12,12 +12,12 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public override void SetDefaults() { - Item.damage = 52; + Item.damage = 48; Item.DamageType = DamageClass.Ranged; Item.width = 66; Item.height = 24; - Item.useTime = 30; - Item.useAnimation = 30; + Item.useTime = 35; + Item.useAnimation = 35; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 4.5f; @@ -79,29 +79,29 @@ namespace CalamityMod.Items.Weapons.Ranged if (targetArrayIndex == 0) return false; - Vector2 vector2; + Vector2 targetPosition; int extraBulletDamage = (int)(damage * 0.7); for (int j = 0; j < targetArrayIndex; j++) { - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); - vector2.Y -= 100 * j; + targetPosition = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + targetPosition.X = (targetPosition.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); + targetPosition.Y -= 100 * j; - Vector2 velocity2 = Vector2.Normalize(Main.npc[targets[j]].Center - vector2) * Item.shootSpeed; + Vector2 extraBulletVel = Vector2.Normalize(Main.npc[targets[j]].Center - targetPosition) * Item.shootSpeed; - int proj = Projectile.NewProjectile(source, vector2, velocity2, type, extraBulletDamage, knockback, player.whoAmI); + int proj = Projectile.NewProjectile(source, targetPosition, extraBulletVel, type, extraBulletDamage, knockback, player.whoAmI); Main.projectile[proj].extraUpdates += 2; Main.projectile[proj].tileCollide = false; Main.projectile[proj].timeLeft /= 2; - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y + 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); - vector2.Y += 100 * j; + targetPosition = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y + 600f); + targetPosition.X = (targetPosition.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); + targetPosition.Y += 100 * j; - velocity2 = Vector2.Normalize(Main.npc[targets[j]].Center - vector2) * Item.shootSpeed; + extraBulletVel = Vector2.Normalize(Main.npc[targets[j]].Center - targetPosition) * Item.shootSpeed; - proj = Projectile.NewProjectile(source, vector2, velocity2, type, extraBulletDamage, knockback, player.whoAmI); + proj = Projectile.NewProjectile(source, targetPosition, extraBulletVel, type, extraBulletDamage, knockback, player.whoAmI); Main.projectile[proj].extraUpdates += 2; Main.projectile[proj].tileCollide = false; Main.projectile[proj].timeLeft /= 2; @@ -115,24 +115,24 @@ namespace CalamityMod.Items.Weapons.Ranged { int randomTarget = Main.rand.Next(targetArrayIndex); - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); - vector2.Y -= 100 * randomTarget; + targetPosition = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + targetPosition.X = (targetPosition.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); + targetPosition.Y -= 100 * randomTarget; - Vector2 velocity2 = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - vector2) * Item.shootSpeed; + Vector2 extraBulletVel = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - targetPosition) * Item.shootSpeed; - int proj = Projectile.NewProjectile(source, vector2, velocity2, type, extraBulletDamage, knockback, player.whoAmI); + int proj = Projectile.NewProjectile(source, targetPosition, extraBulletVel, type, extraBulletDamage, knockback, player.whoAmI); Main.projectile[proj].extraUpdates += 2; Main.projectile[proj].tileCollide = false; Main.projectile[proj].timeLeft /= 2; - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y + 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); - vector2.Y += 100 * randomTarget; + targetPosition = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y + 600f); + targetPosition.X = (targetPosition.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); + targetPosition.Y += 100 * randomTarget; - velocity2 = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - vector2) * Item.shootSpeed; + extraBulletVel = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - targetPosition) * Item.shootSpeed; - proj = Projectile.NewProjectile(source, vector2, velocity2, type, extraBulletDamage, knockback, player.whoAmI); + proj = Projectile.NewProjectile(source, targetPosition, extraBulletVel, type, extraBulletDamage, knockback, player.whoAmI); Main.projectile[proj].extraUpdates += 2; Main.projectile[proj].tileCollide = false; Main.projectile[proj].timeLeft /= 2; diff --git a/Items/Weapons/Ranged/DragonsBreath.cs b/Items/Weapons/Ranged/DragonsBreath.cs index 7998f6fe0d..df1eb431a1 100644 --- a/Items/Weapons/Ranged/DragonsBreath.cs +++ b/Items/Weapons/Ranged/DragonsBreath.cs @@ -1,6 +1,8 @@ -using CalamityMod.Projectiles.Ranged; +using System; +using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Microsoft.Xna.Framework; +using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.DataStructures; @@ -12,154 +14,130 @@ namespace CalamityMod.Items.Weapons.Ranged public class DragonsBreath : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; - public const int BetweenShotsPause = 15; - public const int PelletsPerShot = 6; - public const float FullAutoFireRateMult = 0.8f; - public const float FullAutoDamageMult = 0.8f; - // note this is extremely low because it's per pellet - public const float Spread = 0.018f; + + public static readonly SoundStyle FireballSound = new("CalamityMod/Sounds/Custom/Yharon/YharonFireball", 3) { PitchVariance = 0.3f, Volume = 0.75f }; + public static readonly SoundStyle WeldingBurn = new("CalamityMod/Sounds/Item/WeldingBurn") { Volume = 0.65f }; + public static readonly SoundStyle WeldingShoot = new("CalamityMod/Sounds/Item/WeldingShoot") { Volume = 0.45f }; - public override void SetStaticDefaults() - { - ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; - } + public SlotId WeldSoundSlot; + + public int BetweenShotsPause = 14; + public float Counter = 2; + public float MaxFirerateShots = 20; + public float WeldingShots = 50; + public bool StrongShotMode = false; + public int DragonsBreathSetUseTime = 5; + public int DragonsBreathSetUseAnimation = 9; public override void SetDefaults() { - Item.damage = 162; + Item.damage = 454; Item.DamageType = DamageClass.Ranged; - Item.width = 124; - Item.height = 78; - Item.useTime = 9; - Item.useAnimation = 18; + Item.width = 94; + Item.height = 72; + Item.useTime = DragonsBreathSetUseTime; + Item.useAnimation = DragonsBreathSetUseAnimation; Item.reuseDelay = BetweenShotsPause; - Item.useLimitPerAnimation = 2; Item.autoReuse = true; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.knockBack = 6.5f; - // item.UseSound = SoundID.Item38; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 12f; - Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; + Item.knockBack = 4.5f; + Item.UseSound = null; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 3.5f; + Item.useAmmo = AmmoID.Gel; Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.Rarity15BuyPrice; } - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextFloat() > 0.66f; + public override bool CanConsumeAmmo(Item ammo, Player player) => !StrongShotMode && Main.rand.NextFloat() > 0.80f; - public override Vector2? HoldoutOffset() => new Vector2(-5, 5); - - public override bool AltFunctionUse(Player player) => true; - - public override bool CanUseItem(Player player) - { - Item.reuseDelay = player.altFunctionUse == 2 ? 0 : BetweenShotsPause; - return base.CanUseItem(player); - } - - public override float UseSpeedMultiplier(Player player) => player.altFunctionUse == 2 ? FullAutoFireRateMult : 1f; + public override Vector2? HoldoutOffset() => new Vector2(18, 10.5f); public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - SoundEngine.PlaySound(SoundID.Item38, position); - bool doDust = false; - Vector2 vel = velocity; - int[] bulletIDs = new int[PelletsPerShot]; - float spreadFactor = 1f; - - // Right click full auto: Randomly intermix three regular bullets and three Dragon's Breath Rounds in a wider spread - if (player.altFunctionUse == 2) + if (!StrongShotMode) { - damage = (int)(damage * FullAutoDamageMult); + if (Counter == 2) + SoundEngine.PlaySound(FireballSound, player.Center); + Vector2 newVel = velocity.RotatedByRandom(MathHelper.ToRadians(2.5f)); + Projectile.NewProjectile(source, position, newVel * Main.rand.NextFloat(1.2f, 0.8f), type, damage, knockback, player.whoAmI); + Counter--; + if (MaxFirerateShots > 0 && BetweenShotsPause == 4) + MaxFirerateShots--; - for (int i = 0; i < PelletsPerShot; ++i) - bulletIDs[i] = type; - int dragonsBreathAdded = 0; - while (dragonsBreathAdded < PelletsPerShot / 2) + if (Counter <= 0) { - int i = Main.rand.Next(PelletsPerShot); - if (bulletIDs[i] == Item.shoot) - continue; - bulletIDs[i] = Item.shoot; - ++dragonsBreathAdded; + if (BetweenShotsPause > 4) + { + BetweenShotsPause -= 1; + Item.reuseDelay = BetweenShotsPause; + } + Counter = 2; + } + if (BetweenShotsPause <= 4 && MaxFirerateShots == 0) + { + BetweenShotsPause = 0; + Item.reuseDelay = BetweenShotsPause; + StrongShotMode = true; + DragonsBreathSetUseTime = 2; + DragonsBreathSetUseAnimation = 2; + SoundEngine.PlaySound(ScorchedEarth.ShootSound, player.Center); } - - spreadFactor = 1.52f; } - // Left click first shot: Six regular bullets, low spread - else if (player.itemAnimation == player.itemAnimationMax - 1) + else if (StrongShotMode) { - for (int i = 0; i < PelletsPerShot; ++i) - bulletIDs[i] = type; - } - // Left click second shot: Six Dragon's Breath Rounds, very low spread. Extra sound and dust blast. - else - { - SoundEngine.PlaySound(SoundID.Item74, position); - for (int i = 0; i < PelletsPerShot; ++i) - bulletIDs[i] = Item.shoot; - - spreadFactor = 0.5f; - doDust = true; - } - - // Actually fire the chosen bullets. - float angleOffset = Spread * -0.5f * (PelletsPerShot - 1) * spreadFactor; - for (int i = 0; i < PelletsPerShot; ++i) - { - Vector2 rotatedVel = vel.RotatedBy(angleOffset); - Projectile.NewProjectile(source, position, rotatedVel, bulletIDs[i], damage, knockback, player.whoAmI); - angleOffset += Spread * spreadFactor; - - if (doDust) - SpawnDragonsBreathDust(position, rotatedVel); + if (SoundEngine.TryGetActiveSound(WeldSoundSlot, out var WeldSound) && WeldSound.IsPlaying) + WeldSound.Position = player.Center; + if (player.Calamity().DragonsBreathAudioCooldown2 == 0) + { + player.Calamity().DragonsBreathAudioCooldown2 = 30; + WeldSoundSlot = SoundEngine.PlaySound(WeldingShoot, player.Center); + } + Projectile.NewProjectile(source, position, velocity * 1.5f, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 1); + WeldingShots--; + if (WeldingShots <= 0) + { + Counter = 2; + BetweenShotsPause = 14; + Item.reuseDelay = BetweenShotsPause; + SoundEngine.PlaySound(SpeedBlaster.Empty, player.Center); + Projectile.NewProjectile(source, player.Center, new Vector2(5 * -player.direction, -5), ModContent.ProjectileType(), Main.zenithWorld ? 250000 : 1, knockback, player.whoAmI); + MaxFirerateShots = 20; + WeldingShots = 50; + WeldSound?.Stop(); + StrongShotMode = false; + DragonsBreathSetUseTime = 5; + DragonsBreathSetUseAnimation = 9; + } } return false; } - - private void SpawnDragonsBreathDust(Vector2 pos, Vector2 velocity) + public override void UseStyle(Player player, Rectangle heldItemFrame) { - pos += velocity.SafeNormalize(Vector2.Zero) * Item.width * Item.scale * 0.71f; - for (int i = 0; i < 30; ++i) - { - // Pick a random type of smoke (there's a little fire mixed in) - int dustID; - switch (Main.rand.Next(6)) - { - case 0: - dustID = 262; - break; - case 1: - case 2: - dustID = 54; - break; - default: - dustID = 53; - break; - } + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); + float itemRotation = player.compositeFrontArm.rotation + MathHelper.PiOver2 * player.gravDir; - // Choose a random speed and angle to belch out the smoke - float dustSpeed = Main.rand.NextFloat(3.0f, 13.0f); - float angleRandom = 0.06f; - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); + Vector2 itemPosition = player.MountedCenter + itemRotation.ToRotationVector2() * 7f; + Vector2 itemSize = new Vector2(94, 72); + Vector2 itemOrigin = new Vector2(-17, 3); - // Sometimes make smoke fly upward instead of outward. - if (Main.rand.NextBool(4)) - dustVel = Vector2.Lerp(dustVel, -Vector2.UnitY * dustVel.Length(), Main.rand.NextFloat(0.6f, 0.85f)) * 0.6f; + CalamityUtils.CleanHoldStyle(player, itemRotation, itemPosition, itemSize, itemOrigin); - // Pick a size for the smoke particle - float scale = Main.rand.NextFloat(0.5f, 1.6f); + base.UseStyle(player, heldItemFrame); + } - // Actually spawn the smoke - int idx = Dust.NewDust(pos, 1, 1, dustID, dustVel.X, dustVel.Y, 0, default, scale); - Main.dust[idx].noGravity = true; - Main.dust[idx].position = pos; - } + public override void UseItemFrame(Player player) + { + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); + + float animProgress = 0.5f - player.itemTime / (float)player.itemTimeMax; + float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; + if (animProgress < 0.4f) + rotation += StrongShotMode && WeldingShots == 1 ? -0.25f * (float)Math.Pow((0.6f - animProgress) / 0.6f, 2) * player.direction : 0; + + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); } } } diff --git a/Items/Weapons/Ranged/DragonsBreath.png b/Items/Weapons/Ranged/DragonsBreath.png index afb0f0ec98..3ff2a5ca01 100644 Binary files a/Items/Weapons/Ranged/DragonsBreath.png and b/Items/Weapons/Ranged/DragonsBreath.png differ diff --git a/Items/Weapons/Ranged/Drataliornus.cs b/Items/Weapons/Ranged/Drataliornus.cs index f455891ab1..2fb5edea6c 100644 --- a/Items/Weapons/Ranged/Drataliornus.cs +++ b/Items/Weapons/Ranged/Drataliornus.cs @@ -75,15 +75,15 @@ namespace CalamityMod.Items.Weapons.Ranged const int numFlames = 5; int flameDamage = (int)(damage * RightClickDamageRatio); - const float num3 = 0.471238898f; + const float fifteenHundredthPi = 0.471238898f; Vector2 spinningpoint = velocity; spinningpoint.Normalize(); spinningpoint *= 36f; - for (int index1 = 0; index1 < numFlames; ++index1) + for (int i = 0; i < numFlames; ++i) { - float num8 = index1 - (numFlames - 1) / 2; - Vector2 vector2_5 = spinningpoint.RotatedBy(num3 * num8, new Vector2()); - Projectile.NewProjectile(source, position.X + vector2_5.X, position.Y + vector2_5.Y, velocity.X, velocity.Y, flameID, flameDamage, knockback, player.whoAmI, 1f, 0f); + float piArrowOffset = i - (numFlames - 1) / 2; + Vector2 offsetSpawn = spinningpoint.RotatedBy(fifteenHundredthPi * piArrowOffset, new Vector2()); + Projectile.NewProjectile(source, position.X + offsetSpawn.X, position.Y + offsetSpawn.Y, velocity.X, velocity.Y, flameID, flameDamage, knockback, player.whoAmI, 1f, 0f); } } else diff --git a/Items/Weapons/Ranged/ElementalEruption.cs b/Items/Weapons/Ranged/ElementalEruption.cs index 07b4755e46..9a90f7f16e 100644 --- a/Items/Weapons/Ranged/ElementalEruption.cs +++ b/Items/Weapons/Ranged/ElementalEruption.cs @@ -11,48 +11,50 @@ namespace CalamityMod.Items.Weapons.Ranged public class ElementalEruption : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public int FlareCounter = 0; + + public override void SetStaticDefaults() + { + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; + } + public override void SetDefaults() { - Item.damage = 77; + Item.damage = 94; Item.DamageType = DamageClass.Ranged; Item.width = 64; Item.height = 34; - Item.useTime = 14; - Item.useAnimation = 14; + Item.useAnimation = Item.useTime = 6; Item.useStyle = ItemUseStyleID.Shoot; + Item.noUseGraphic = true; Item.noMelee = true; Item.knockBack = 3.5f; Item.UseSound = SoundID.Item34; Item.value = CalamityGlobalItem.Rarity11BuyPrice; Item.rare = ItemRarityID.Purple; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 9f; Item.useAmmo = AmmoID.Gel; + Item.channel = true; } public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + + // Spawning the holdout cannot consume ammo + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int numFirestreams = Main.rand.Next(3, 5); - for (int index = 0; index < numFirestreams; ++index) - { - float SpeedX = velocity.X + Main.rand.Next(-20, 21) * 0.05f; - float SpeedY = velocity.Y + Main.rand.Next(-20, 21) * 0.05f; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI, 0f, 0f); - } + Projectile.NewProjectile(source, position, Vector2.Zero, type, 0, 0f, player.whoAmI); return false; } - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextFloat() > 0.9f; - public override void AddRecipes() { CreateRecipe(). AddIngredient(). - AddIngredient(). - AddIngredient(). AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). AddIngredient(5). diff --git a/Items/Weapons/Ranged/FirestormCannon.cs b/Items/Weapons/Ranged/FirestormCannon.cs index 78c4f01c40..0238256994 100644 --- a/Items/Weapons/Ranged/FirestormCannon.cs +++ b/Items/Weapons/Ranged/FirestormCannon.cs @@ -53,8 +53,8 @@ namespace CalamityMod.Items.Weapons.Ranged if (player.altFunctionUse == 2) { velocity *= 2f; - int num6 = Main.rand.Next(4, 6); - for (int index = 0; index < num6; ++index) + int flareAmt = Main.rand.Next(4, 6); + for (int index = 0; index < flareAmt; ++index) { float SpeedX = velocity.X + (float)Main.rand.Next(-50, 51) * 0.05f; float SpeedY = velocity.Y + (float)Main.rand.Next(-50, 51) * 0.05f; @@ -70,8 +70,8 @@ namespace CalamityMod.Items.Weapons.Ranged } else { - int num6 = Main.rand.Next(1, 3); - for (int index = 0; index < num6; ++index) + int flareAmt = Main.rand.Next(1, 3); + for (int index = 0; index < flareAmt; ++index) { float SpeedX = velocity.X + (float)Main.rand.Next(-40, 41) * 0.05f; float SpeedY = velocity.Y + (float)Main.rand.Next(-40, 41) * 0.05f; diff --git a/Items/Weapons/Ranged/FlarewingBow.cs b/Items/Weapons/Ranged/FlarewingBow.cs index 5cde932d3d..dbc0a5d0f3 100644 --- a/Items/Weapons/Ranged/FlarewingBow.cs +++ b/Items/Weapons/Ranged/FlarewingBow.cs @@ -35,29 +35,28 @@ 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) { Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num117 = 0.314159274f; - int num118 = 3; - Vector2 vector7 = velocity; - vector7.Normalize(); - vector7 *= 50f; - bool flag11 = Collision.CanHit(vector2, 0, 0, vector2 + vector7, 0, 0); - for (int num119 = 0; num119 < num118; num119++) + float tenthPi = 0.314159274f; + Vector2 arrowVel = velocity; + arrowVel.Normalize(); + arrowVel *= 50f; + bool arrowHitsTiles = Collision.CanHit(vector2, 0, 0, vector2 + arrowVel, 0, 0); + for (int i = 0; i < 3; i++) { - float num120 = (float)num119 - ((float)num118 - 1f) / 2f; - Vector2 value9 = vector7.RotatedBy((double)(num117 * num120), default); - if (!flag11) + float piOffsetValue = (float)i - 1f; + Vector2 offsetSpawn = arrowVel.RotatedBy((double)(tenthPi * piOffsetValue), default); + if (!arrowHitsTiles) { - value9 -= vector7; + offsetSpawn -= arrowVel; } if (CalamityUtils.CheckWoodenAmmo(type, player)) { - int num123 = Projectile.NewProjectile(source, vector2.X + value9.X, vector2.Y + value9.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI); - Main.projectile[num123].noDropItem = true; + int arrowSpawn = Projectile.NewProjectile(source, vector2.X + offsetSpawn.X, vector2.Y + offsetSpawn.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + Main.projectile[arrowSpawn].noDropItem = true; } else { - int num123 = Projectile.NewProjectile(source, vector2.X + value9.X, vector2.Y + value9.Y, velocity.X, velocity.Y, type, damage, knockback, player.whoAmI); - Main.projectile[num123].noDropItem = true; + int arrowSpawn = Projectile.NewProjectile(source, vector2.X + offsetSpawn.X, vector2.Y + offsetSpawn.Y, velocity.X, velocity.Y, type, damage, knockback, player.whoAmI); + Main.projectile[arrowSpawn].noDropItem = true; } } return false; diff --git a/Items/Weapons/Ranged/Goobow.cs b/Items/Weapons/Ranged/Goobow.cs index 228c05c4fc..0b0183fbe7 100644 --- a/Items/Weapons/Ranged/Goobow.cs +++ b/Items/Weapons/Ranged/Goobow.cs @@ -16,8 +16,8 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.damage = 33; Item.DamageType = DamageClass.Ranged; - Item.width = 30; - Item.height = 50; + Item.width = 32; + Item.height = 96; Item.useTime = 31; Item.useAnimation = 31; Item.useStyle = ItemUseStyleID.Shoot; diff --git a/Items/Weapons/Ranged/Goobow.png b/Items/Weapons/Ranged/Goobow.png index fbec958fc9..7acb164d32 100644 Binary files a/Items/Weapons/Ranged/Goobow.png and b/Items/Weapons/Ranged/Goobow.png differ diff --git a/Items/Weapons/Ranged/GunkShot.cs b/Items/Weapons/Ranged/GunkShot.cs index 290e75df07..cc9c9c0543 100644 --- a/Items/Weapons/Ranged/GunkShot.cs +++ b/Items/Weapons/Ranged/GunkShot.cs @@ -15,8 +15,8 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.damage = 23; Item.DamageType = DamageClass.Ranged; - Item.width = 44; - Item.height = 30; + Item.width = 76; + Item.height = 28; Item.useTime = 32; Item.useAnimation = 32; Item.useStyle = ItemUseStyleID.Shoot; @@ -39,8 +39,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) { - int num6 = Main.rand.Next(3, 5); - for (int index = 0; index < num6; ++index) + int bulletAmt = Main.rand.Next(3, 5); + for (int index = 0; index < bulletAmt; ++index) { float SpeedX = velocity.X + (float)Main.rand.Next(-25, 26) * 0.05f; float SpeedY = velocity.Y + (float)Main.rand.Next(-25, 26) * 0.05f; diff --git a/Items/Weapons/Ranged/GunkShot.png b/Items/Weapons/Ranged/GunkShot.png index c8f9979b94..1c82d85b8d 100644 Binary files a/Items/Weapons/Ranged/GunkShot.png and b/Items/Weapons/Ranged/GunkShot.png differ diff --git a/Items/Weapons/Ranged/HalleysInferno.cs b/Items/Weapons/Ranged/HalleysInferno.cs index 974dbfc314..e4f88f346f 100644 --- a/Items/Weapons/Ranged/HalleysInferno.cs +++ b/Items/Weapons/Ranged/HalleysInferno.cs @@ -4,6 +4,7 @@ using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -12,22 +13,31 @@ namespace CalamityMod.Items.Weapons.Ranged public class HalleysInferno : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static readonly SoundStyle Shoot = new("CalamityMod/Sounds/Item/HalleysInfernoShoot") { Volume = 0.68f }; + public static readonly SoundStyle Hit = new("CalamityMod/Sounds/Item/HalleysInfernoHit") { Volume = 0.75f }; public override void SetDefaults() { - Item.damage = 1125; - Item.knockBack = 5f; + Item.damage = 444; + Item.knockBack = 5.5f; Item.DamageType = DamageClass.Ranged; - Item.useTime = Item.useAnimation = 30; + + // Burst of 5, one every 5 frames for 25 total. Cooldown of 39 frames. + Item.useTime = 5; + Item.useAnimation = 25; + Item.reuseDelay = 39; + Item.useLimitPerAnimation = 5; Item.autoReuse = true; + Item.useAmmo = AmmoID.Gel; - Item.shootSpeed = 14.6f; + Item.shootSpeed = 12f; Item.shoot = ModContent.ProjectileType(); Item.width = 84; Item.height = 34; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.UseSound = SoundID.Item34; + Item.UseSound = Shoot; Item.value = CalamityGlobalItem.Rarity13BuyPrice; Item.rare = ModContent.RarityType(); } diff --git a/Items/Weapons/Ranged/HavocsBreath.cs b/Items/Weapons/Ranged/HavocsBreath.cs index 7c5e9546fe..37e0f9ea2e 100644 --- a/Items/Weapons/Ranged/HavocsBreath.cs +++ b/Items/Weapons/Ranged/HavocsBreath.cs @@ -1,6 +1,7 @@ using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -12,12 +13,13 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public override void SetDefaults() { - Item.damage = 67; + Item.damage = 60; Item.DamageType = DamageClass.Ranged; - Item.width = 50; - Item.height = 18; - Item.useTime = 9; - Item.useAnimation = 30; + Item.width = 68; + Item.height = 26; + Item.useTime = 5; + Item.useAnimation = 35; + Item.reuseDelay = 20; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 1.5f; @@ -28,13 +30,18 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 8.5f; Item.useAmmo = AmmoID.Gel; + Item.consumeAmmoOnFirstShotOnly = true; } - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextBool(); + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - public override Vector2? HoldoutOffset() + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - return new Vector2(-10, 0); + for (int i = 0; i <= 2; i++) + { + Projectile.NewProjectile(source, position + velocity * 4f, velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.9f, 1.25f), type, damage , knockback, player.whoAmI); + } + return false; } } } diff --git a/Items/Weapons/Ranged/HavocsBreath.png b/Items/Weapons/Ranged/HavocsBreath.png index 14e3c4e4ba..83b53585ab 100644 Binary files a/Items/Weapons/Ranged/HavocsBreath.png and b/Items/Weapons/Ranged/HavocsBreath.png differ diff --git a/Items/Weapons/Ranged/Hellborn.cs b/Items/Weapons/Ranged/Hellborn.cs index 3100f92ab5..941688b083 100644 --- a/Items/Weapons/Ranged/Hellborn.cs +++ b/Items/Weapons/Ranged/Hellborn.cs @@ -76,39 +76,39 @@ namespace CalamityMod.Items.Weapons.Ranged modifiers.SourceDamage *= ExplosionDamageMultiplier; int touchDamage = player.CalcIntDamage(Item.damage); player.ApplyDamageToNPC(target, touchDamage, 0f, 0, false); - float num50 = 3.4f; - float num51 = 1.6f; - float num52 = 4f; - Vector2 value3 = (target.rotation - MathHelper.PiOver2).ToRotationVector2(); - Vector2 value4 = value3 * target.velocity.Length(); + float firstDustScale = 3.4f; + float secondDustScale = 1.6f; + float thirdDustScale = 4f; + Vector2 dustRotation = (target.rotation - MathHelper.PiOver2).ToRotationVector2(); + Vector2 dustVelocity = dustRotation * target.velocity.Length(); SoundEngine.PlaySound(SoundID.Item14, target.Center); - for (int num53 = 0; num53 < 80; num53++) + for (int i = 0; i < 80; i++) { - int num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 200, default, num50); - Dust dust = Main.dust[num54]; + int contactDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 200, default, firstDustScale); + Dust dust = Main.dust[contactDust]; dust.position = target.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * target.width / 2f; dust.noGravity = true; dust.velocity.Y -= 6f; dust.velocity *= 3f; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 100, default, num51); + dust.velocity += dustVelocity * Main.rand.NextFloat(); + contactDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 100, default, secondDustScale); dust.position = target.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * target.width / 2f; dust.velocity.Y -= 6f; dust.velocity *= 2f; dust.noGravity = true; dust.fadeIn = 1f; dust.color = Color.Crimson * 0.5f; - dust.velocity += value4 * Main.rand.NextFloat(); + dust.velocity += dustVelocity * Main.rand.NextFloat(); } - for (int num55 = 0; num55 < 40; num55++) + for (int j = 0; j < 40; j++) { - int num56 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 0, default, num52); - Dust dust = Main.dust[num56]; + int contactDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 0, default, thirdDustScale); + Dust dust = Main.dust[contactDust2]; dust.position = target.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(target.velocity.ToRotation()) * target.width / 3f; dust.noGravity = true; dust.velocity.Y -= 6f; dust.velocity *= 0.5f; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); + dust.velocity += dustVelocity * (0.6f + 0.6f * Main.rand.NextFloat()); } } diff --git a/Items/Weapons/Ranged/Hydra.cs b/Items/Weapons/Ranged/Hydra.cs index 12d033b774..e3605d5f86 100644 --- a/Items/Weapons/Ranged/Hydra.cs +++ b/Items/Weapons/Ranged/Hydra.cs @@ -124,7 +124,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void UseStyle(Player player, Rectangle heldItemFrame) { - player.direction = Math.Sign((player.Calamity().mouseWorld - player.Center).X); + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); float itemRotation = player.compositeFrontArm.rotation + MathHelper.PiOver2 * player.gravDir; Vector2 itemPosition = player.MountedCenter + itemRotation.ToRotationVector2() * 7f; @@ -136,7 +136,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void UseItemFrame(Player player) { - player.direction = Math.Sign((player.Calamity().mouseWorld - player.Center).X); + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); float animProgress = 1 - player.itemTime / (float)player.itemTimeMax; float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; diff --git a/Items/Weapons/Ranged/Infinity.cs b/Items/Weapons/Ranged/Infinity.cs index 1ad1076a95..0d806aa604 100644 --- a/Items/Weapons/Ranged/Infinity.cs +++ b/Items/Weapons/Ranged/Infinity.cs @@ -57,12 +57,12 @@ namespace CalamityMod.Items.Weapons.Ranged { if (player.altFunctionUse == 2) { - //If you right click, shoots an helix of normal bullets - Vector2 num7 = velocity.RotatedBy(MathHelper.ToRadians(rotation)); - Vector2 num8 = velocity.RotatedBy(MathHelper.ToRadians(-rotation)); - int shot1 = Projectile.NewProjectile(source, position.X, position.Y, num7.X, num7.Y, type, damage, knockback, player.whoAmI, 0f, 0f); + //If you right click, shoots a helix of normal bullets + Vector2 helixVel1 = velocity.RotatedBy(MathHelper.ToRadians(rotation)); + Vector2 helixVel2 = velocity.RotatedBy(MathHelper.ToRadians(-rotation)); + int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, type, damage, knockback, player.whoAmI, 0f, 0f); Main.projectile[shot1].timeLeft = 180; - int shot2 = Projectile.NewProjectile(source, position.X, position.Y, num8.X, num8.Y, type, damage, knockback, player.whoAmI, 0f, 0f); + int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, type, damage, knockback, player.whoAmI, 0f, 0f); Main.projectile[shot2].timeLeft = 180; //Code to constantly make the shooting go side to side to make the helix if (limit) @@ -86,11 +86,11 @@ namespace CalamityMod.Items.Weapons.Ranged else { //If left click, do the same as above but spawn Charged Blasts instead - Vector2 num7 = velocity.RotatedBy(MathHelper.ToRadians(rotation)); - Vector2 num8 = velocity.RotatedBy(MathHelper.ToRadians(-rotation)); - int shot1 = Projectile.NewProjectile(source, position.X, position.Y, num7.X, num7.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); + Vector2 helixVel1 = velocity.RotatedBy(MathHelper.ToRadians(rotation)); + Vector2 helixVel2 = velocity.RotatedBy(MathHelper.ToRadians(-rotation)); + int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); Main.projectile[shot1].timeLeft = 180; - int shot2 = Projectile.NewProjectile(source, position.X, position.Y, num8.X, num8.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); + int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); Main.projectile[shot2].timeLeft = 180; if (limit) { diff --git a/Items/Weapons/Ranged/Minigun.cs b/Items/Weapons/Ranged/Kingsbane.cs similarity index 65% rename from Items/Weapons/Ranged/Minigun.cs rename to Items/Weapons/Ranged/Kingsbane.cs index b542031d6c..b17c0e57c0 100644 --- a/Items/Weapons/Ranged/Minigun.cs +++ b/Items/Weapons/Ranged/Kingsbane.cs @@ -1,58 +1,53 @@ using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class Minigun : ModItem, ILocalizedModType + [LegacyName("Minigun")] + public class Kingsbane : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; public override void SetDefaults() { - Item.damage = 275; + Item.damage = 245; Item.DamageType = DamageClass.Ranged; Item.width = 92; Item.height = 44; Item.useTime = 3; Item.useAnimation = 3; + Item.channel = true; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 2.5f; Item.value = CalamityGlobalItem.Rarity15BuyPrice; - Item.UseSound = SoundID.Item41; + Item.UseSound = null; Item.autoReuse = true; - Item.shoot = ProjectileID.PurificationPowder; - Item.shootSpeed = 22f; + Item.noUseGraphic = true; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 2f; Item.useAmmo = AmmoID.Bullet; Item.rare = ModContent.RarityType(); - Item.Calamity().canFirePointBlankShots = true; } - - public override Vector2? HoldoutOffset() - { - return new Vector2(-10, 0); - } - + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextFloat() > 0.95f && 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) { - float SpeedX = velocity.X + Main.rand.Next(-15, 16) * 0.05f; - float SpeedY = velocity.Y + Main.rand.Next(-15, 16) * 0.05f; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI); + Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); return false; } - - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextFloat() > 0.8f; - public override void AddRecipes() { CreateRecipe(). AddIngredient(ItemID.ChainGun). - AddIngredient(). + AddIngredient(). AddIngredient(5). AddTile(). Register(); diff --git a/Items/Weapons/Ranged/Minigun.png b/Items/Weapons/Ranged/Kingsbane.png similarity index 100% rename from Items/Weapons/Ranged/Minigun.png rename to Items/Weapons/Ranged/Kingsbane.png diff --git a/Items/Weapons/Ranged/Meowthrower.cs b/Items/Weapons/Ranged/Meowthrower.cs index a8b2a0b9ab..b26cda021c 100644 --- a/Items/Weapons/Ranged/Meowthrower.cs +++ b/Items/Weapons/Ranged/Meowthrower.cs @@ -10,7 +10,9 @@ namespace CalamityMod.Items.Weapons.Ranged public class Meowthrower : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; - private bool Fire2 = false; + + public int CatCounter = 0; + public override void SetDefaults() { Item.damage = 37; @@ -18,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.width = 74; Item.height = 24; Item.useTime = 8; - Item.useAnimation = 8; + Item.useAnimation = 32; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 1.25f; @@ -27,29 +29,32 @@ namespace CalamityMod.Items.Weapons.Ranged Item.rare = ItemRarityID.LightRed; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 5.5f; + Item.shootSpeed = 8f; Item.useAmmo = AmmoID.Gel; + Item.consumeAmmoOnFirstShotOnly = true; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-10, 0); - } - - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 85) - return false; - return true; - } + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float SpeedX = velocity.X + (float)Main.rand.Next(-15, 16) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-15, 16) * 0.05f; - int projType = Fire2 ? ModContent.ProjectileType() : type; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, projType, damage, knockback, player.whoAmI, 0.0f, 0.0f); - Fire2 = !Fire2; + // Fires a homing cat... thing + CatCounter++; + if (CatCounter >= 4) + { + CatCounter = 0; + // They prefer to avoid the smokes + Vector2 newPos = position + velocity.SafeNormalize(Vector2.UnitX) * 38f; + Vector2 newVel = velocity.RotatedBy(MathHelper.ToRadians(Main.rand.NextFloat(6f, 15f) * Main.rand.NextBool().ToDirectionInt())) * 1.5f; + Projectile.NewProjectile(source, newPos, newVel, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + } + + // Fires two flames, blue and pink, slightly randomly spread + for (int i = 0; i < 2; i++) + { + Vector2 newVel = velocity.RotatedByRandom(MathHelper.ToRadians(6f)); + Projectile.NewProjectile(source, position, newVel, type, damage, knockback, player.whoAmI, i); + } return false; } } diff --git a/Items/Weapons/Ranged/MidasPrime.cs b/Items/Weapons/Ranged/MidasPrime.cs index 8722abd566..56c5ff6acd 100644 --- a/Items/Weapons/Ranged/MidasPrime.cs +++ b/Items/Weapons/Ranged/MidasPrime.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Ranged public class MidasPrime : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; - internal static readonly SoundStyle ShootSound = new("CalamityMod/Sounds/Item/CrackshotColtShot") { PitchVariance = 0.1f }; + internal static readonly SoundStyle ShootSound = new("CalamityMod/Sounds/Item/CrackshotColtShot") { Volume = 0.5f, PitchVariance = 0.1f }; // Internal storage used to keep track between UseItem and Shoot hooks whether a gold coin was queued up private bool nextShotGoldCoin = false; @@ -150,7 +150,7 @@ namespace CalamityMod.Items.Weapons.Ranged #region Firing Animation public override void UseStyle(Player player, Rectangle heldItemFrame) { - player.direction = Math.Sign((player.Calamity().mouseWorld - player.Center).X); + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); float itemRotation = player.compositeFrontArm.rotation + MathHelper.PiOver2 * player.gravDir; Vector2 itemPosition = player.MountedCenter + itemRotation.ToRotationVector2() * 7f; @@ -164,7 +164,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void UseItemFrame(Player player) { - player.direction = Math.Sign((player.Calamity().mouseWorld - player.Center).X); + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); float animProgress = 1 - player.itemTime / (float)player.itemTimeMax; float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; diff --git a/Items/Weapons/Ranged/MineralMortar.cs b/Items/Weapons/Ranged/MineralMortar.cs index 8f9160ca2e..c899c03a88 100644 --- a/Items/Weapons/Ranged/MineralMortar.cs +++ b/Items/Weapons/Ranged/MineralMortar.cs @@ -1,7 +1,8 @@ -using Terraria.DataStructures; -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -10,34 +11,43 @@ namespace CalamityMod.Items.Weapons.Ranged public class MineralMortar : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + public override void SetDefaults() { - Item.damage = 30; + Item.damage = 85; Item.DamageType = DamageClass.Ranged; - Item.width = 58; - Item.height = 26; - Item.useTime = 33; - Item.useAnimation = 33; - Item.useStyle = ItemUseStyleID.Shoot; + Item.shoot = ModContent.ProjectileType(); + Item.useTime = Item.useAnimation = 60; + Item.shootSpeed = 25f; + Item.knockBack = 20f; + + Item.width = 68; + Item.height = 32; Item.noMelee = true; - Item.knockBack = 5f; + Item.noUseGraphic = true; + Item.channel = true; + Item.useAmmo = AmmoID.Rocket; Item.value = CalamityGlobalItem.Rarity5BuyPrice; Item.rare = ItemRarityID.Pink; - Item.UseSound = SoundID.Item11; - Item.autoReuse = true; - Item.shootSpeed = 14f; - Item.shoot = ModContent.ProjectileType(); - Item.useAmmo = AmmoID.Rocket; + Item.useStyle = ItemUseStyleID.Shoot; + Item.UseSound = new SoundStyle("CalamityMod/Sounds/Item/DudFire") with { Volume = .4f, Pitch = -.9f, PitchVariance = 0.1f }; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-10, 0); - } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] == 0; + + // Spawning the holdout won't consume ammo. + public override bool CanConsumeAmmo(Item ammo, 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.NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); + 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(); + return false; } diff --git a/Items/Weapons/Ranged/NettlevineGreatbow.cs b/Items/Weapons/Ranged/NettlevineGreatbow.cs index fd53d37d1b..186a929722 100644 --- a/Items/Weapons/Ranged/NettlevineGreatbow.cs +++ b/Items/Weapons/Ranged/NettlevineGreatbow.cs @@ -36,22 +36,21 @@ 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) { Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num117 = 0.314159274f; - int num118 = 4; - Vector2 vector7 = velocity; - vector7.Normalize(); - vector7 *= 40f; - bool flag11 = Collision.CanHit(vector2, 0, 0, vector2 + vector7, 0, 0); - for (int num119 = 0; num119 < num118; num119++) + float tenthPi = 0.314159274f; + Vector2 arrowVel = velocity; + arrowVel.Normalize(); + arrowVel *= 40f; + bool arrowHitsTiles = Collision.CanHit(vector2, 0, 0, vector2 + arrowVel, 0, 0); + for (int i = 0; i < 4; i++) { - float num120 = (float)num119 - ((float)num118 - 1f) / 2f; - Vector2 value9 = vector7.RotatedBy((double)(num117 * num120), default); - if (!flag11) + float piOffsetAmt = (float)i - 3f / 2f; + Vector2 offsetSpawn = arrowVel.RotatedBy((double)(tenthPi * piOffsetAmt), default); + if (!arrowHitsTiles) { - value9 -= vector7; + offsetSpawn -= arrowVel; } - int num121 = Projectile.NewProjectile(source, vector2.X + value9.X, vector2.Y + value9.Y, velocity.X, velocity.Y, type, damage, knockback, player.whoAmI); - Main.projectile[num121].noDropItem = true; + int arrowSpawn = Projectile.NewProjectile(source, vector2.X + offsetSpawn.X, vector2.Y + offsetSpawn.Y, velocity.X, velocity.Y, type, damage, knockback, player.whoAmI); + Main.projectile[arrowSpawn].noDropItem = true; } for (int i = 0; i < 2; i++) { diff --git a/Items/Weapons/Ranged/OpalStriker.cs b/Items/Weapons/Ranged/OpalStriker.cs index 20455f108d..0f1ce7f401 100644 --- a/Items/Weapons/Ranged/OpalStriker.cs +++ b/Items/Weapons/Ranged/OpalStriker.cs @@ -25,8 +25,8 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.damage = 37; Item.DamageType = DamageClass.Ranged; - Item.width = 46; - Item.height = 30; + Item.width = 48; + Item.height = 24; Item.useTime = Item.useAnimation = AftershotCooldownFrames; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; diff --git a/Items/Weapons/Ranged/OpalStriker.png b/Items/Weapons/Ranged/OpalStriker.png index 4f8e18f1cb..de860ae9c5 100644 Binary files a/Items/Weapons/Ranged/OpalStriker.png and b/Items/Weapons/Ranged/OpalStriker.png differ diff --git a/Items/Weapons/Ranged/OverloadedBlaster.cs b/Items/Weapons/Ranged/OverloadedBlaster.cs index 923c7eed5d..873af079aa 100644 --- a/Items/Weapons/Ranged/OverloadedBlaster.cs +++ b/Items/Weapons/Ranged/OverloadedBlaster.cs @@ -12,12 +12,11 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public override void SetDefaults() { - Item.damage = 16; + Item.damage = 19; Item.DamageType = DamageClass.Ranged; Item.width = 42; Item.height = 34; - Item.useTime = 16; - Item.useAnimation = 16; + Item.useAnimation = Item.useTime = 22; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 1.5f; @@ -25,30 +24,22 @@ namespace CalamityMod.Items.Weapons.Ranged Item.rare = ItemRarityID.LightRed; Item.UseSound = SoundID.Item9; Item.autoReuse = true; - Item.shootSpeed = 6.5f; + Item.shootSpeed = 5f; Item.shoot = ModContent.ProjectileType(); Item.useAmmo = AmmoID.Gel; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-4, -5); - } + public override Vector2? HoldoutOffset() => new Vector2(-4, -5); - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 33) - return false; - return true; - } + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= 25; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - for (int index = 0; index < 5; ++index) + Vector2 newPos = position + velocity * 6f; + for (int i = 0; i < 3; i++) { - float SpeedX = velocity.X + (float)Main.rand.Next(-40, 41) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-40, 41) * 0.05f; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI, 0f, 0f); + Vector2 newVel = velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.8f, 1.2f); + Projectile.NewProjectile(source, newPos, newVel, type, damage, knockback, player.whoAmI); } return false; } diff --git a/Items/Weapons/Ranged/P90.cs b/Items/Weapons/Ranged/P90.cs index 14234663aa..a855c5766d 100644 --- a/Items/Weapons/Ranged/P90.cs +++ b/Items/Weapons/Ranged/P90.cs @@ -3,29 +3,33 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using CalamityMod.Projectiles.Ranged; +using Terraria.Audio; +using CalamityMod.Projectiles.Turret; namespace CalamityMod.Items.Weapons.Ranged { public class P90 : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public bool fireShot = true; public override void SetDefaults() { - Item.damage = 8; + Item.damage = 5; Item.DamageType = DamageClass.Ranged; Item.width = 60; Item.height = 28; - Item.useTime = 5; - Item.useAnimation = 5; + Item.useTime = Item.useAnimation = 2; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 1.5f; Item.value = CalamityGlobalItem.Rarity4BuyPrice; Item.rare = ItemRarityID.LightRed; - Item.UseSound = SoundID.Item11; + Item.UseSound = SoundID.Item11 with { Volume = 0.6f}; Item.autoReuse = true; - Item.shoot = ProjectileID.Bullet; - Item.shootSpeed = 7f; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 9f; Item.useAmmo = AmmoID.Bullet; Item.Calamity().canFirePointBlankShots = true; } @@ -37,12 +41,12 @@ 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) { - float SpeedX = velocity.X + Main.rand.Next(-15, 16) * 0.05f; - float SpeedY = velocity.Y + Main.rand.Next(-15, 16) * 0.05f; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI, 0f, 0f); + if (fireShot) + Projectile.NewProjectile(source, position, velocity.RotatedByRandom(0.03f), ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); + fireShot = !fireShot; return false; } - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextFloat() < 0.5f; + public override bool CanConsumeAmmo(Item ammo, Player player) => fireShot && Main.rand.NextFloat() < 0.25f; } } diff --git a/Items/Weapons/Ranged/PearlGod.cs b/Items/Weapons/Ranged/PearlGod.cs index a165d38638..28688d5b84 100644 --- a/Items/Weapons/Ranged/PearlGod.cs +++ b/Items/Weapons/Ranged/PearlGod.cs @@ -70,14 +70,14 @@ namespace CalamityMod.Items.Weapons.Ranged for (int i = 0; i < totalLoops; i++) { - int proj = Projectile.NewProjectile(source, position, velocity.RotatedBy(-rotation * (i + 1)), type, (int)(damage * 0.5), knockback * 0.5f, player.whoAmI); - Main.projectile[proj].extraUpdates += spread; - int proj2 = Projectile.NewProjectile(source, position, velocity.RotatedBy(+rotation * (i + 1)), type, (int)(damage * 0.5), knockback * 0.5f, player.whoAmI); - Main.projectile[proj2].extraUpdates += spread; + int bullet1 = Projectile.NewProjectile(source, position, velocity.RotatedBy(-rotation * (i + 1)), type, (int)(damage * 0.5), knockback * 0.5f, player.whoAmI); + Main.projectile[bullet1].extraUpdates += spread; + int bullet2 = Projectile.NewProjectile(source, position, velocity.RotatedBy(+rotation * (i + 1)), type, (int)(damage * 0.5), knockback * 0.5f, player.whoAmI); + Main.projectile[bullet2].extraUpdates += spread; } - int proj3 = Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, spread); - Main.projectile[proj3].extraUpdates += spread; + int shockblast = Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, spread); + Main.projectile[shockblast].extraUpdates += spread; spread++; } @@ -85,8 +85,8 @@ namespace CalamityMod.Items.Weapons.Ranged { for (int i = 0; i < 3; i++) { - int proj = Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage * 2, knockback * 2f, player.whoAmI, 0f, 10f); - Main.projectile[proj].extraUpdates += 9; + int bigShockblast = Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage * 2, knockback * 2f, player.whoAmI, 0f, 10f); + Main.projectile[bigShockblast].extraUpdates += 9; } finalShot = false; diff --git a/Items/Weapons/Ranged/PestilentDefiler.cs b/Items/Weapons/Ranged/PestilentDefiler.cs index 84c15ce0c1..d21091f92f 100644 --- a/Items/Weapons/Ranged/PestilentDefiler.cs +++ b/Items/Weapons/Ranged/PestilentDefiler.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public override void SetDefaults() { - Item.damage = 110; + Item.damage = 105; Item.DamageType = DamageClass.Ranged; Item.width = 46; Item.height = 20; diff --git a/Items/Weapons/Ranged/Photoviscerator.cs b/Items/Weapons/Ranged/Photoviscerator.cs index 8067539b54..2eb28d7c5d 100644 --- a/Items/Weapons/Ranged/Photoviscerator.cs +++ b/Items/Weapons/Ranged/Photoviscerator.cs @@ -3,7 +3,9 @@ using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; +using System.Linq; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -12,30 +14,34 @@ namespace CalamityMod.Items.Weapons.Ranged { public class Photoviscerator : ModItem, ILocalizedModType { + public static readonly SoundStyle UseSound = new("CalamityMod/Sounds/Item/PhotoUseSound") { Volume = 0.55f }; + public static readonly SoundStyle HitSound = new("CalamityMod/Sounds/Item/PhotoHitSound") { Volume = 0.45f }; public new string LocalizationCategory => "Items.Weapons.Ranged"; - public const float AmmoNotConsumeChance = 0.9f; - private const float AltFireShootSpeed = 17f; - public override void SetStaticDefaults() - { - ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; - } + // Left-click stats + public static float AmmoNotConsumeChance = 0.95f; + public static int LightBombCooldown = 10; + + // Right-click stats + public static float RightClickVelocityMult = 2.5f; + public static int RightClickCooldown = 20; public override void SetDefaults() { - Item.damage = 130; + Item.width = 208; + Item.height = 66; + + Item.damage = 445; Item.DamageType = DamageClass.Ranged; - Item.width = 84; - Item.height = 30; - Item.useTime = 2; - Item.useAnimation = 10; - Item.useStyle = ItemUseStyleID.Shoot; - Item.noMelee = true; + Item.useTime = Item.useAnimation = LightBombCooldown; + Item.shootSpeed = 6f; Item.knockBack = 2f; - Item.UseSound = SoundID.Item34; - Item.autoReuse = true; - Item.shootSpeed = 18f; + Item.shoot = ModContent.ProjectileType(); Item.useAmmo = AmmoID.Gel; + Item.useStyle = ItemUseStyleID.Shoot; + Item.channel = true; + Item.noMelee = true; + Item.noUseGraphic = true; Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityVioletBuyPrice; @@ -43,69 +49,47 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool AltFunctionUse(Player player) => true; - public override bool CanUseItem(Player player) - { - if (player.altFunctionUse == 2) - { - Item.shoot = ModContent.ProjectileType(); - Item.useTime = Item.useAnimation = 27; - } - else - { - Item.useTime = 2; - Item.useAnimation = 10; - Item.shoot = ModContent.ProjectileType(); - } - return base.CanUseItem(player); - } + // Spawning the holdout cannot consume ammo + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0; - public override Vector2? HoldoutOffset() + public override void HoldItem(Player player) { - return new Vector2(-15, 0); + if (player.whoAmI != Main.myPlayer) + return; + + // Right-click channeling + player.Calamity().rightClickListener = true; + + if (player.Calamity().mouseRight && CanUseItem(player) && !Main.mapFullscreen && !Main.blockMouse) + { + // Only one out at a time + if (Main.projectile.Any(n => n.active && n.type == Item.shoot && n.owner == player.whoAmI)) + return; + // If you don't have any Gel don't even spawn the holdout + if (!player.HasAmmo(Item)) + return; + + var source = player.GetSource_ItemUse_WithPotentialAmmo(Item, ItemID.Gel); + Projectile.NewProjectile(source, player.Center, Vector2.Zero, Item.shoot, 0, 0f, player.whoAmI); + } } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - // Alt fire: Shoot an Exo Flare Cluster. - if (player.altFunctionUse == 2) - { - int projID = ModContent.ProjectileType(); - - position += velocity.ToRotation().ToRotationVector2() * 80f; - Projectile.NewProjectile(source, position, velocity.SafeNormalize(Vector2.Zero) * AltFireShootSpeed, projID, damage, knockback, player.whoAmI); + // The holdout will initially double up when right clicking otherwise + if (player.altFunctionUse == 2f) return false; - } - - // Left click: Exo Fire, with a chance of Exo Light Bombs. - for (int i = 0; i < 2; i++) - { - Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, 0f); - } - if (player.itemAnimation == 2) - { - for (int i = 0; i < 2; i++) - { - - position += velocity.ToRotation().ToRotationVector2() * 64f; - int yDirection = (i == 0).ToDirectionInt(); - velocity = velocity.RotatedBy(0.2f * yDirection); - Projectile lightBomb = Projectile.NewProjectileDirect(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI); - - lightBomb.localAI[1] = yDirection; - lightBomb.netUpdate = true; - } - } + + Projectile.NewProjectile(source, position, Vector2.Zero, type, 0, 0f, player.whoAmI); return false; } - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextFloat() > AmmoNotConsumeChance; - public override void AddRecipes() { CreateRecipe(). AddIngredient(). - AddIngredient(). AddIngredient(). + AddIngredient(). AddIngredient(). AddTile(). Register(); diff --git a/Items/Weapons/Ranged/Photoviscerator.png b/Items/Weapons/Ranged/Photoviscerator.png index e48518e0e3..904aa35731 100644 Binary files a/Items/Weapons/Ranged/Photoviscerator.png and b/Items/Weapons/Ranged/Photoviscerator.png differ diff --git a/Items/Weapons/Ranged/PlanetaryAnnihilation.cs b/Items/Weapons/Ranged/PlanetaryAnnihilation.cs index 05690d6d98..56c1ce7263 100644 --- a/Items/Weapons/Ranged/PlanetaryAnnihilation.cs +++ b/Items/Weapons/Ranged/PlanetaryAnnihilation.cs @@ -39,59 +39,59 @@ 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) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = Main.mouseY + Main.screenPosition.Y - vector2.Y; + float arrowSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt(num78 * num78 + num79 * num79); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt(mouseXDist * mouseXDist + mouseYDist * mouseYDist); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = player.direction; + mouseYDist = 0f; + mouseDistance = arrowSpeed; } else { - num80 = num72 / num80; + mouseDistance = arrowSpeed / mouseDistance; } - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); - vector2.Y -= 100f; - num78 = Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); + realPlayerPos.Y -= 100f; + mouseXDist = Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt(num78 * num78 + num79 * num79); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; + mouseDistance = (float)Math.Sqrt(mouseXDist * mouseXDist + mouseYDist * mouseYDist); + mouseDistance = arrowSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; if (CalamityUtils.CheckWoodenAmmo(type, player)) { for (int i = 0; i < 7; i++) { - float speedX4 = num78 + Main.rand.Next(-120, 121) * 0.02f; - float speedY5 = num79 + Main.rand.Next(-120, 121) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, i); + float speedX4 = mouseXDist + Main.rand.Next(-120, 121) * 0.02f; + float speedY5 = mouseYDist + Main.rand.Next(-120, 121) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, i); } } else { for (int i = 0; i < 7; i++) { - float speedX4 = num78 + Main.rand.Next(-120, 121) * 0.02f; - float speedY5 = num79 + Main.rand.Next(-120, 121) * 0.02f; - int num121 = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI); + float speedX4 = mouseXDist + Main.rand.Next(-120, 121) * 0.02f; + float speedY5 = mouseYDist + Main.rand.Next(-120, 121) * 0.02f; + int num121 = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI); Main.projectile[num121].noDropItem = true; } } diff --git a/Items/Weapons/Ranged/PridefulHuntersPlanarRipper.cs b/Items/Weapons/Ranged/PridefulHuntersPlanarRipper.cs index ce3f872c99..80c4521c87 100644 --- a/Items/Weapons/Ranged/PridefulHuntersPlanarRipper.cs +++ b/Items/Weapons/Ranged/PridefulHuntersPlanarRipper.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - Item.damage = 86; + Item.damage = 74; Item.DamageType = DamageClass.Ranged; Item.width = 68; Item.height = 32; diff --git a/Items/Weapons/Ranged/PristineFury.cs b/Items/Weapons/Ranged/PristineFury.cs index c22a3032c0..eb73a2cc53 100644 --- a/Items/Weapons/Ranged/PristineFury.cs +++ b/Items/Weapons/Ranged/PristineFury.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -14,11 +15,12 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public int frameCounter = 0; public int frame = 0; - public static int BaseDamage = 77; + public static int BaseDamage = 80; + public bool Trail = true; public override void SetStaticDefaults() { - ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; } public override void SetDefaults() @@ -37,6 +39,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 11f; Item.useAmmo = AmmoID.Gel; + Item.consumeAmmoOnFirstShotOnly = true; Item.value = CalamityGlobalItem.Rarity12BuyPrice; Item.rare = ModContent.RarityType(); @@ -46,59 +49,51 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool AltFunctionUse(Player player) => true; - public override bool CanUseItem(Player player) - { - if (player.altFunctionUse == 2) - { - Item.useTime = 5; - Item.useAnimation = 20; - } - else - { - Item.useTime = 3; - Item.useAnimation = 15; - } - return base.CanUseItem(player); - } + // Right click consumes ammo at the same rate but faster at spewing + public override float UseTimeMultiplier(Player player) => player.altFunctionUse == 2 ? 0.5f : 1f; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { if (player.altFunctionUse == 2) { - int flameAmt = 3; - damage = (int)(damage * 1.2); - for (int index = 0; index < flameAmt; ++index) + for (int i = 0; i < 2; i++) { - float SpeedX = velocity.X + Main.rand.NextFloat(-1.25f, 1.25f); - float SpeedY = velocity.Y + Main.rand.NextFloat(-1.25f, 1.25f); - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), (int)(damage * 0.8f), knockback, player.whoAmI); + Vector2 newVel = velocity.RotatedByRandom(MathHelper.ToRadians(5f)); + Projectile.NewProjectile(source, position, newVel, ModContent.ProjectileType(), damage, knockback, player.whoAmI); } } else { - damage = (int)(damage * 0.94); - Projectile.NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, Trail ? 1 : 0); + Trail = !Trail; + for (int i = 0; i <= 2; i++) + { + Dust dust = Dust.NewDustPerfect(position + velocity * 3f + new Vector2(0, -3), 158, velocity.RotatedBy(0.25f * player.direction).RotatedByRandom(0.35f) * Main.rand.NextFloat(0.5f, 2.5f), 0, default, Main.rand.NextFloat(1.6f, 2f)); + dust.noGravity = true; + } + CritSpark spark = new CritSpark(position + velocity * 3f + new Vector2(0, -3), velocity.RotatedBy(0.25f * player.direction).RotatedByRandom(0.25f) * Main.rand.NextFloat(0.2f, 1.8f), Main.rand.NextBool() ? Color.DarkOrange : Color.OrangeRed, Color.OrangeRed, 0.9f, 18, 2f, 1.9f); + GeneralParticleHandler.SpawnParticle(spark); } return false; } public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) { - Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Ranged/PristineFury_Animated").Value; + Texture2D texture = ModContent.Request(Texture + "_Animated").Value; spriteBatch.Draw(texture, position, Item.GetCurrentFrame(ref frame, ref frameCounter, 5, 4), Color.White, 0f, origin, scale, SpriteEffects.None, 0); return false; } public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) { - Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Ranged/PristineFury_Animated").Value; + Texture2D texture = ModContent.Request(Texture + "_Animated").Value; spriteBatch.Draw(texture, Item.position - Main.screenPosition, Item.GetCurrentFrame(ref frame, ref frameCounter, 5, 4), lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); return false; } public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) { - Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Ranged/PristineFuryGlow").Value; + Texture2D texture = ModContent.Request(Texture + "Glow").Value; spriteBatch.Draw(texture, Item.position - Main.screenPosition, Item.GetCurrentFrame(ref frame, ref frameCounter, 5, 4, false), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); } } diff --git a/Items/Weapons/Ranged/Scorpio.cs b/Items/Weapons/Ranged/Scorpio.cs index 7f8879e6e7..2af8610d1e 100644 --- a/Items/Weapons/Ranged/Scorpio.cs +++ b/Items/Weapons/Ranged/Scorpio.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public override void SetStaticDefaults() { - ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; } public override void SetDefaults() @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.knockBack = 6.5f; Item.value = CalamityGlobalItem.Rarity10BuyPrice; Item.rare = ItemRarityID.Red; - Item.UseSound = null; + Item.UseSound = SoundID.Item11; Item.autoReuse = true; Item.shootSpeed = 20f; Item.shoot = ModContent.ProjectileType(); @@ -38,35 +38,22 @@ namespace CalamityMod.Items.Weapons.Ranged public override Vector2? HoldoutOffset() => new Vector2(-20, 10); - public override bool AltFunctionUse(Player player) - { - return true; - } + public override bool AltFunctionUse(Player player) => true; - public override bool CanUseItem(Player player) - { - return base.CanUseItem(player); - } + public override float UseSpeedMultiplier(Player player) => player.altFunctionUse == 2 ? 0.3333f : 1f; - public override float UseSpeedMultiplier(Player player) - { - if (player.altFunctionUse == 2) - return 1 / 3f; - return 1f; - } + // Figure out which rocket is used + public int RocketType; + public override void OnConsumeAmmo(Item ammo, Player player) => RocketType = ammo.type; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { if (player.altFunctionUse == 2) - { - Projectile.NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), (int)(damage * 1.85), knockback * 2f, player.whoAmI); - return false; - } + Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), (int)(damage * 1.85), knockback * 2f, player.whoAmI, RocketType); else - { - Projectile.NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI); - return false; - } + Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, RocketType); + + return false; } public override void AddRecipes() diff --git a/Items/Weapons/Ranged/Shadethrower.cs b/Items/Weapons/Ranged/Shadethrower.cs index d2a11f603b..af4bccaec2 100644 --- a/Items/Weapons/Ranged/Shadethrower.cs +++ b/Items/Weapons/Ranged/Shadethrower.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.width = 76; Item.height = 30; Item.useTime = 10; - Item.useAnimation = 10; + Item.useAnimation = 30; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 1.5f; @@ -28,19 +28,10 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 8f; Item.useAmmo = AmmoID.Gel; + Item.consumeAmmoOnFirstShotOnly = true; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-5, 0); - } - - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 66) - return false; - return true; - } + public override Vector2? HoldoutOffset() => new Vector2(-5, 0); public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/Shredder.cs b/Items/Weapons/Ranged/Shredder.cs index 5ce8c27cb6..b39984c764 100644 --- a/Items/Weapons/Ranged/Shredder.cs +++ b/Items/Weapons/Ranged/Shredder.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - Item.damage = 27; + Item.damage = 24; Item.DamageType = DamageClass.Ranged; Item.width = 56; Item.height = 24; diff --git a/Items/Weapons/Ranged/SomaPrime.cs b/Items/Weapons/Ranged/SomaPrime.cs index 403970afe2..5e4953c113 100644 --- a/Items/Weapons/Ranged/SomaPrime.cs +++ b/Items/Weapons/Ranged/SomaPrime.cs @@ -64,8 +64,8 @@ namespace CalamityMod.Items.Weapons.Ranged public override void AddRecipes() { CreateRecipe(). - AddIngredient(). - AddIngredient(). + AddIngredient(). + AddIngredient(). AddIngredient(5). AddTile(). Register(); diff --git a/Items/Weapons/Ranged/SparkSpreader.cs b/Items/Weapons/Ranged/SparkSpreader.cs index 712c328ddf..847b5e039c 100644 --- a/Items/Weapons/Ranged/SparkSpreader.cs +++ b/Items/Weapons/Ranged/SparkSpreader.cs @@ -11,14 +11,15 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public override void SetDefaults() { - Item.damage = 7; + Item.damage = 10; Item.knockBack = 1f; Item.DamageType = DamageClass.Ranged; Item.autoReuse = true; - Item.useTime = 10; - Item.useAnimation = 30; + Item.useTime = 12; + Item.useAnimation = 36; Item.useAmmo = AmmoID.Gel; - Item.shootSpeed = 5f; + Item.consumeAmmoOnFirstShotOnly = true; + Item.shootSpeed = 6f; Item.shoot = ModContent.ProjectileType(); Item.width = 52; @@ -32,8 +33,6 @@ namespace CalamityMod.Items.Weapons.Ranged public override Vector2? HoldoutOffset() => new Vector2(-4, 0); - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= 70; - public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Ranged/SpeedBlaster.cs b/Items/Weapons/Ranged/SpeedBlaster.cs index 793fc210c8..59c4a6efcd 100644 --- a/Items/Weapons/Ranged/SpeedBlaster.cs +++ b/Items/Weapons/Ranged/SpeedBlaster.cs @@ -34,8 +34,8 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.damage = 40; Item.DamageType = DamageClass.Ranged; - Item.width = 54; - Item.height = 26; + Item.width = 52; + Item.height = 30; Item.useTime = Item.useAnimation = 10; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; diff --git a/Items/Weapons/Ranged/SpeedBlaster.png b/Items/Weapons/Ranged/SpeedBlaster.png index df74da69d0..173acf24b5 100644 Binary files a/Items/Weapons/Ranged/SpeedBlaster.png and b/Items/Weapons/Ranged/SpeedBlaster.png differ diff --git a/Items/Weapons/Ranged/Starfleet.cs b/Items/Weapons/Ranged/Starfleet.cs index 16d43056eb..28f752ecb9 100644 --- a/Items/Weapons/Ranged/Starfleet.cs +++ b/Items/Weapons/Ranged/Starfleet.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public override void SetDefaults() { - Item.damage = 68; + Item.damage = 56; Item.DamageType = DamageClass.Ranged; Item.width = 76; Item.height = 36; diff --git a/Items/Weapons/Ranged/Starmageddon.cs b/Items/Weapons/Ranged/Starmageddon.cs index f62569ad77..59015b2587 100644 --- a/Items/Weapons/Ranged/Starmageddon.cs +++ b/Items/Weapons/Ranged/Starmageddon.cs @@ -56,9 +56,9 @@ namespace CalamityMod.Items.Weapons.Ranged CreateRecipe(). AddIngredient(). AddIngredient(). - AddIngredient(5). - AddIngredient(10). AddIngredient(15). + AddIngredient(8). + AddIngredient(8). AddTile(). Register(); } diff --git a/Items/Weapons/Ranged/Svantechnical.cs b/Items/Weapons/Ranged/Svantechnical.cs index 72e2affe92..8fa8a9ba9a 100644 --- a/Items/Weapons/Ranged/Svantechnical.cs +++ b/Items/Weapons/Ranged/Svantechnical.cs @@ -55,38 +55,38 @@ namespace CalamityMod.Items.Weapons.Ranged int i = Main.myPlayer; float sSpeed = Item.shootSpeed; player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; + mouseXDist = (float)player.direction; + mouseYDist = 0f; } else { - num80 = sSpeed / num80; + mouseDistance = sSpeed / mouseDistance; } - float num208 = num78; - float num209 = num79; - num208 += (float)Main.rand.Next(-1, 2) * 0.5f; - num209 += (float)Main.rand.Next(-1, 2) * 0.5f; - if (Collision.CanHitLine(player.Center, 0, 0, vector2 + new Vector2(num208, num209) * 2f, 0, 0)) + float randXOffset = mouseXDist; + float randYOffset = mouseYDist; + randXOffset += (float)Main.rand.Next(-1, 2) * 0.5f; + randYOffset += (float)Main.rand.Next(-1, 2) * 0.5f; + if (Collision.CanHitLine(player.Center, 0, 0, realPlayerPos + new Vector2(randXOffset, randYOffset) * 2f, 0, 0)) { - vector2 += new Vector2(num208, num209); + realPlayerPos += new Vector2(randXOffset, randYOffset); } - Projectile.NewProjectile(source, position.X, position.Y - player.gravDir * 4f, num208, num209, type, damage, knockback, i, 0f, (float)Main.rand.Next(12) / 6f); - int num6 = Main.rand.Next(2, 4); - for (int index = 0; index < num6; ++index) + Projectile.NewProjectile(source, position.X, position.Y - player.gravDir * 4f, randXOffset, randYOffset, type, damage, knockback, i, 0f, (float)Main.rand.Next(12) / 6f); + int bulletAmt = Main.rand.Next(2, 4); + for (int index = 0; index < bulletAmt; ++index) { float SpeedX = velocity.X + (float)Main.rand.Next(-60, 61) * 0.05f; float SpeedY = velocity.Y + (float)Main.rand.Next(-60, 61) * 0.05f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI, 0f, 0f); } return false; } diff --git a/Items/Weapons/Ranged/TerraFlameburster.cs b/Items/Weapons/Ranged/TerraFlameburster.cs index 301887cddb..ae353fb655 100644 --- a/Items/Weapons/Ranged/TerraFlameburster.cs +++ b/Items/Weapons/Ranged/TerraFlameburster.cs @@ -2,6 +2,7 @@ using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -10,36 +11,40 @@ namespace CalamityMod.Items.Weapons.Ranged public class TerraFlameburster : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public int FlareCounter = 0; + public int TerraUseTime = 8; + public override void SetDefaults() { - Item.damage = 55; + Item.damage = 78; Item.DamageType = DamageClass.Ranged; Item.width = 68; Item.height = 22; - Item.useTime = 3; - Item.useAnimation = 15; + Item.useTime = TerraUseTime; + Item.useAnimation = TerraUseTime; Item.useStyle = ItemUseStyleID.Shoot; + Item.noUseGraphic = true; Item.noMelee = true; Item.knockBack = 3.25f; - Item.UseSound = SoundID.Item34; Item.value = CalamityGlobalItem.Rarity9BuyPrice; Item.rare = ItemRarityID.Yellow; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 7.5f; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 10f; Item.useAmmo = AmmoID.Gel; + Item.channel = true; } - public override Vector2? HoldoutOffset() + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + + // Spawning the holdout cannot consume ammo + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - return new Vector2(-10, 0); - } - - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 80) - return false; - return true; + Projectile.NewProjectile(source, position, Vector2.Zero, type, 0, 0f, player.whoAmI); + return false; } public override void AddRecipes() diff --git a/Items/Weapons/Ranged/TheHive.cs b/Items/Weapons/Ranged/TheHive.cs index 1816264b40..dea035d6b0 100644 --- a/Items/Weapons/Ranged/TheHive.cs +++ b/Items/Weapons/Ranged/TheHive.cs @@ -32,6 +32,10 @@ namespace CalamityMod.Items.Weapons.Ranged public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + // Figure out which rocket is used + public int RocketType; + public override void OnConsumeAmmo(Item ammo, Player player) => RocketType = ammo.type; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { int rocket = Utils.SelectRandom(Main.rand, new int[] @@ -41,7 +45,7 @@ namespace CalamityMod.Items.Weapons.Ranged ModContent.ProjectileType(), ModContent.ProjectileType() }); - Projectile.NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, rocket, damage, knockback, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(source, position, velocity, rocket, damage, knockback, player.whoAmI, RocketType); return false; } } diff --git a/Items/Weapons/Ranged/TheSevensStriker.cs b/Items/Weapons/Ranged/TheSevensStriker.cs index 3c1d6764d0..8e096e6b91 100644 --- a/Items/Weapons/Ranged/TheSevensStriker.cs +++ b/Items/Weapons/Ranged/TheSevensStriker.cs @@ -26,8 +26,9 @@ namespace CalamityMod.Items.Weapons.Ranged public static readonly float RightClickSilverMultiplier = 0.08f; public static readonly float RightClickGoldMultiplier = 0.16f; - public static readonly float DoublesMultiplier = 2f; // Doubles means double damage! + public static readonly float DoublesMultiplier = 1f; // Unfortunately doubles can't be doubles. Balancing! public static readonly float TriplesCherryMultiplier = 1f; + public static readonly float TriplesCherrySplitMultiplier = 0.333f; public static readonly float TriplesGrapeMultiplier = 0.333f; // fixed the grapes interfering with each other's iframes public static readonly float JackpotMultiplier = 0.5f; // Jackpot fires 49 shots total and thus needs to be reduced somehow diff --git a/Items/Weapons/Ranged/TheStorm.cs b/Items/Weapons/Ranged/TheStorm.cs index 48073d36a5..a2b44e1444 100644 --- a/Items/Weapons/Ranged/TheStorm.cs +++ b/Items/Weapons/Ranged/TheStorm.cs @@ -12,12 +12,18 @@ namespace CalamityMod.Items.Weapons.Ranged public class TheStorm : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public override void SetStaticDefaults() + { + ItemID.Sets.AnimatesAsSoul[Type] = true; + Main.RegisterItemAnimation(Type, new DrawAnimationVertical(5, 9)); + } public override void SetDefaults() { Item.damage = 35; Item.DamageType = DamageClass.Ranged; - Item.width = 34; - Item.height = 50; + Item.width = 54; + Item.height = 90; Item.useTime = 7; Item.useAnimation = 14; Item.useStyle = ItemUseStyleID.Shoot; @@ -32,61 +38,66 @@ namespace CalamityMod.Items.Weapons.Ranged Item.useAmmo = AmmoID.Arrow; } + public override Vector2? HoldoutOffset() + { + return new Vector2(-10, 0); + } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { int i = Main.myPlayer; - float num72 = Main.rand.Next(25, 30); + float arrowSpeed = Main.rand.Next(25, 30); player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = arrowSpeed; } else { - num80 = num72 / num80; + mouseDistance = arrowSpeed / mouseDistance; } for (int j = 0; j < 3; j++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * j); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * j); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-120, 121) * 0.01f; - float speedY5 = num79 + (float)Main.rand.Next(-120, 121) * 0.01f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = arrowSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-120, 121) * 0.01f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-120, 121) * 0.01f; if (CalamityUtils.CheckWoodenAmmo(type, player)) { - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5 * 0.9f, ModContent.ProjectileType(), damage, knockback, i); - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5 * 0.8f, ModContent.ProjectileType(), damage, knockback, i); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5 * 0.9f, ModContent.ProjectileType(), damage, knockback, i); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5 * 0.8f, ModContent.ProjectileType(), damage, knockback, i); } else { - int arrow1 = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5 * 0.9f, type, damage, knockback, i); + int arrow1 = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5 * 0.9f, type, damage, knockback, i); Main.projectile[arrow1].noDropItem = true; - int arrow2 = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5 * 0.8f, type, damage, knockback, i); + int arrow2 = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5 * 0.8f, type, damage, knockback, i); Main.projectile[arrow2].noDropItem = true; } } diff --git a/Items/Weapons/Ranged/TheStorm.png b/Items/Weapons/Ranged/TheStorm.png index 813babc1ff..9344fef25d 100644 Binary files a/Items/Weapons/Ranged/TheStorm.png and b/Items/Weapons/Ranged/TheStorm.png differ diff --git a/Items/Weapons/Ranged/Toxibow.cs b/Items/Weapons/Ranged/Toxibow.cs index 7d5829ccf1..6661d05861 100644 --- a/Items/Weapons/Ranged/Toxibow.cs +++ b/Items/Weapons/Ranged/Toxibow.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.damage = 15; Item.DamageType = DamageClass.Ranged; - Item.width = 20; + Item.width = 26; Item.height = 54; Item.useTime = Item.useAnimation = 28; Item.useStyle = ItemUseStyleID.Shoot; diff --git a/Items/Weapons/Ranged/Toxibow.png b/Items/Weapons/Ranged/Toxibow.png index ea00ae318e..099dd434e0 100644 Binary files a/Items/Weapons/Ranged/Toxibow.png and b/Items/Weapons/Ranged/Toxibow.png differ diff --git a/Items/Weapons/Ranged/TyrannysEnd.cs b/Items/Weapons/Ranged/TyrannysEnd.cs index d870e52b0c..b248eee6d2 100644 --- a/Items/Weapons/Ranged/TyrannysEnd.cs +++ b/Items/Weapons/Ranged/TyrannysEnd.cs @@ -18,15 +18,15 @@ namespace CalamityMod.Items.Weapons.Ranged Item.damage = 2000; Item.knockBack = 9.5f; Item.DamageType = DamageClass.Ranged; - Item.useTime = 65; - Item.useAnimation = 65; + Item.useTime = 60; + Item.useAnimation = 60; Item.shoot = ProjectileID.BulletHighVelocity; Item.shootSpeed = 12f; Item.useAmmo = AmmoID.Bullet; Item.autoReuse = true; - Item.width = 94; - Item.height = 32; + Item.width = 150; + Item.height = 48; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.UseSound = CommonCalamitySounds.LargeWeaponFireSound; @@ -40,7 +40,7 @@ namespace CalamityMod.Items.Weapons.Ranged // Terraria seems to really dislike high crit values in SetDefaults public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 35; - public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + public override Vector2? HoldoutOffset() => new Vector2(-28, 0); public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/TyrannysEnd.png b/Items/Weapons/Ranged/TyrannysEnd.png index 557bea8b22..df8a87b0f9 100644 Binary files a/Items/Weapons/Ranged/TyrannysEnd.png and b/Items/Weapons/Ranged/TyrannysEnd.png differ diff --git a/Items/Weapons/Ranged/Vortexpopper.cs b/Items/Weapons/Ranged/Vortexpopper.cs index c9599b7efb..361a17f5f3 100644 --- a/Items/Weapons/Ranged/Vortexpopper.cs +++ b/Items/Weapons/Ranged/Vortexpopper.cs @@ -14,8 +14,8 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.damage = 30; Item.DamageType = DamageClass.Ranged; - Item.width = 46; - Item.height = 22; + Item.width = 92; + Item.height = 36; Item.useTime = 21; Item.useAnimation = 21; Item.useStyle = ItemUseStyleID.Shoot; @@ -37,65 +37,65 @@ 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) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float bulletSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = bulletSpeed; } else { - num80 = num72 / num80; + mouseDistance = bulletSpeed / mouseDistance; } - num78 *= num80; - num79 *= num80; - Vector2 value6 = Vector2.Normalize(new Vector2(num78, num79)) * 40f * Item.scale; - if (Collision.CanHit(vector2, 0, 0, vector2 + value6, 0, 0)) + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + Vector2 bulletVel = Vector2.Normalize(new Vector2(mouseXDist, mouseYDist)) * 40f * Item.scale; + if (Collision.CanHit(realPlayerPos, 0, 0, realPlayerPos + bulletVel, 0, 0)) { } - float ai = new Vector2(num78, num79).ToRotation(); - float num96 = 2.09439516f; - for (int num98 = 0; num98 < 6; num98++) + float ai = new Vector2(mouseXDist, mouseYDist).ToRotation(); + float twoThirdsPi = 2.09439516f; + for (int i = 0; i < 6; i++) { - float scaleFactor2 = (float)Main.rand.NextDouble() * 0.2f + 0.05f; - Vector2 vector6 = new Vector2(num78, num79).RotatedBy((double)(num96 * (float)Main.rand.NextDouble() - num96 / 2f), default) * scaleFactor2; - int num99 = Projectile.NewProjectile(source, position.X, position.Y, vector6.X, vector6.Y, ProjectileID.Xenopopper, damage, knockback, player.whoAmI, ai, 0f); - Main.projectile[num99].localAI[0] = (float)type; - Main.projectile[num99].localAI[1] = 12f; + float randVelMult = (float)Main.rand.NextDouble() * 0.2f + 0.05f; + Vector2 bulletSpawnVelocity = new Vector2(mouseXDist, mouseYDist).RotatedBy((double)(twoThirdsPi * (float)Main.rand.NextDouble() - twoThirdsPi / 2f), default) * randVelMult; + int initialBullet = Projectile.NewProjectile(source, position.X, position.Y, bulletSpawnVelocity.X, bulletSpawnVelocity.Y, ProjectileID.Xenopopper, damage, knockback, player.whoAmI, ai, 0f); + Main.projectile[initialBullet].localAI[0] = (float)type; + Main.projectile[initialBullet].localAI[1] = 12f; } - for (int num108 = 0; num108 < 6; num108++) + for (int j = 0; j < 6; j++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-800, 801); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-800, 801); + realPlayerPos.Y -= (float)(100 * j); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-1000, 1001) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-1000, 1001) * 0.02f; - int projectile = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ProjectileID.Xenopopper, damage, knockback, player.whoAmI, ai, 0f); - Main.projectile[projectile].localAI[0] = (float)type; - Main.projectile[projectile].localAI[1] = 12f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = bulletSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-1000, 1001) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-1000, 1001) * 0.02f; + int extraBullet = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ProjectileID.Xenopopper, damage, knockback, player.whoAmI, ai, 0f); + Main.projectile[extraBullet].localAI[0] = (float)type; + Main.projectile[extraBullet].localAI[1] = 12f; } return false; } diff --git a/Items/Weapons/Ranged/Vortexpopper.png b/Items/Weapons/Ranged/Vortexpopper.png index 356d469aa6..943c9b983f 100644 Binary files a/Items/Weapons/Ranged/Vortexpopper.png and b/Items/Weapons/Ranged/Vortexpopper.png differ diff --git a/Items/Weapons/Ranged/WulfrumBlunderbuss.cs b/Items/Weapons/Ranged/WulfrumBlunderbuss.cs index d9b9cbf2a8..5534fe6345 100644 --- a/Items/Weapons/Ranged/WulfrumBlunderbuss.cs +++ b/Items/Weapons/Ranged/WulfrumBlunderbuss.cs @@ -125,7 +125,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void UseStyle(Player player, Rectangle heldItemFrame) { - player.direction = Math.Sign((player.Calamity().mouseWorld - player.Center).X); + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); float itemRotation = player.compositeFrontArm.rotation + MathHelper.PiOver2 * player.gravDir; Vector2 itemPosition = player.MountedCenter + itemRotation.ToRotationVector2() * 7f; @@ -139,7 +139,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void UseItemFrame(Player player) { - player.direction = Math.Sign((player.Calamity().mouseWorld - player.Center).X); + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); float animProgress = 1 - player.itemTime / (float)player.itemTimeMax; float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; diff --git a/Items/Weapons/Rogue/CobaltKunai.cs b/Items/Weapons/Rogue/CobaltKunai.cs index 3ef978228e..b86b1724ce 100644 --- a/Items/Weapons/Rogue/CobaltKunai.cs +++ b/Items/Weapons/Rogue/CobaltKunai.cs @@ -43,9 +43,9 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - for (int i = 0; i < 3; i++) + for (int i = -1; i <= 1; i++) { - Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.ToRadians(i*9)); + Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.ToRadians(i * 9f)); int stealth = Projectile.NewProjectile(source, position, perturbedSpeed, ModContent.ProjectileType(), damage, knockback, player.whoAmI); if (stealth.WithinBounds(Main.maxProjectiles)) Main.projectile[stealth].Calamity().stealthStrike = true; diff --git a/Items/Weapons/Rogue/DesecratedWater.png b/Items/Weapons/Rogue/DesecratedWater.png index e9fbc43d8c..0ebe05d929 100644 Binary files a/Items/Weapons/Rogue/DesecratedWater.png and b/Items/Weapons/Rogue/DesecratedWater.png differ diff --git a/Items/Weapons/Rogue/DynamicPursuer.cs b/Items/Weapons/Rogue/DynamicPursuer.cs index b1bc3330b9..4f16d0a645 100644 --- a/Items/Weapons/Rogue/DynamicPursuer.cs +++ b/Items/Weapons/Rogue/DynamicPursuer.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Rogue { CalamityGlobalItem modItem = Item.Calamity(); - Item.damage = 2550; + Item.damage = 2850; Item.DamageType = RogueDamageClass.Instance; Item.width = 30; @@ -41,11 +41,11 @@ namespace CalamityMod.Items.Weapons.Rogue Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 18f; + Item.shootSpeed = 17f; modItem.UsesCharge = true; modItem.MaxCharge = 300f; // Tesla Cannon = 250f - modItem.ChargePerUse = 0.5f; // Tesla Cannon = 0.9f + modItem.ChargePerUse = 0.4f; // Tesla Cannon = 0.9f } public static float StealthDmgMult = 0.3f; //So I can edit it directly via DragonLens instead of having to do math with CalTestHelpers public override float StealthDamageMultiplier => StealthDmgMult; @@ -56,7 +56,7 @@ namespace CalamityMod.Items.Weapons.Rogue public static float ReturnMaxSpeed = 24f; public static float RicochetShootingCooldown = 1000f; public static float RicochetVelocityCap = 28f; - public static float ElectricityDmgMult = 0.3f; + public static float ElectricityDmgMult = 0.4f; public static float ElectricityCooldown = 500f; public static float LaserDmgMult = 0.25f; public static float LaserCooldown = 300f; diff --git a/Items/Weapons/Rogue/ElementalDisk.cs b/Items/Weapons/Rogue/ElementalDisk.cs index da1a68cc74..6adb111910 100644 --- a/Items/Weapons/Rogue/ElementalDisk.cs +++ b/Items/Weapons/Rogue/ElementalDisk.cs @@ -11,27 +11,29 @@ namespace CalamityMod.Items.Weapons.Rogue [LegacyName("AccretionDisk")] public class ElementalDisk : RogueWeapon { + public static int stealthTimeMult = 2; public override void SetDefaults() { Item.width = 38; - Item.damage = 100; + Item.damage = 92; Item.noMelee = true; Item.noUseGraphic = true; Item.autoReuse = true; - Item.useAnimation = 15; + Item.useAnimation = 16; Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 15; + Item.useTime = 16; Item.knockBack = 9f; Item.UseSound = SoundID.Item1; Item.height = 38; Item.value = CalamityGlobalItem.Rarity11BuyPrice; Item.rare = ItemRarityID.Purple; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 13f; + Item.shootSpeed = 15f; Item.DamageType = RogueDamageClass.Instance; } public override float StealthVelocityMultiplier => 0.7f; + public override float StealthDamageMultiplier => 0.75f; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { @@ -41,8 +43,7 @@ namespace CalamityMod.Items.Weapons.Rogue if (proj.WithinBounds(Main.maxProjectiles)) { Main.projectile[proj].Calamity().stealthStrike = true; - Main.projectile[proj].timeLeft *= 3; - Main.projectile[proj].localNPCHitCooldown *= 2; + Main.projectile[proj].timeLeft *= stealthTimeMult; } return false; } diff --git a/Items/Weapons/Rogue/ExecutionersBlade.cs b/Items/Weapons/Rogue/ExecutionersBlade.cs index 26aea6c1b8..565bdbbcf5 100644 --- a/Items/Weapons/Rogue/ExecutionersBlade.cs +++ b/Items/Weapons/Rogue/ExecutionersBlade.cs @@ -13,8 +13,6 @@ namespace CalamityMod.Items.Weapons.Rogue { public class ExecutionersBlade : RogueWeapon { - private int counter = 0; - public override void SetDefaults() { Item.width = 64; diff --git a/Items/Weapons/Rogue/Exorcism.png b/Items/Weapons/Rogue/Exorcism.png index b2cd5cf9a8..0011f65c8d 100644 Binary files a/Items/Weapons/Rogue/Exorcism.png and b/Items/Weapons/Rogue/Exorcism.png differ diff --git a/Items/Weapons/Rogue/FinalDawn.cs b/Items/Weapons/Rogue/FinalDawn.cs index d1c890d385..3f20d5361a 100644 --- a/Items/Weapons/Rogue/FinalDawn.cs +++ b/Items/Weapons/Rogue/FinalDawn.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Rogue public static readonly SoundStyle UseSound = new("CalamityMod/Sounds/Item/FinalDawnSlash"); public override void SetDefaults() { - Item.damage = 1500; + Item.damage = 2500; Item.DamageType = RogueDamageClass.Instance; Item.width = 78; Item.height = 66; @@ -34,6 +34,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.noUseGraphic = true; } + public override float StealthDamageMultiplier => 0.6f; public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] + player.ownedProjectileCounts[ProjectileType()] + player.ownedProjectileCounts[ProjectileType()] + diff --git a/Items/Weapons/Rogue/GelDart.cs b/Items/Weapons/Rogue/GelDart.cs index c672674075..1ae4eeb49b 100644 --- a/Items/Weapons/Rogue/GelDart.cs +++ b/Items/Weapons/Rogue/GelDart.cs @@ -18,8 +18,8 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SetDefaults() { - Item.width = 14; - Item.damage = 28; + Item.width = 26; + Item.damage = 54; Item.noMelee = true; Item.consumable = true; Item.noUseGraphic = true; diff --git a/Items/Weapons/Rogue/GelDart.png b/Items/Weapons/Rogue/GelDart.png index f01a1c46a1..b410b9e0c9 100644 Binary files a/Items/Weapons/Rogue/GelDart.png and b/Items/Weapons/Rogue/GelDart.png differ diff --git a/Items/Weapons/Rogue/HellsSun.cs b/Items/Weapons/Rogue/HellsSun.cs index cb024ae524..7ce3e20739 100644 --- a/Items/Weapons/Rogue/HellsSun.cs +++ b/Items/Weapons/Rogue/HellsSun.cs @@ -11,13 +11,9 @@ namespace CalamityMod.Items.Weapons.Rogue { public class HellsSun : RogueWeapon { - private static int damage = 240; - private static int knockBack = 5; - private static float SdamageMult = 0.12f; - public override void SetDefaults() { - Item.damage = damage; + Item.damage = 200; Item.DamageType = RogueDamageClass.Instance; Item.noMelee = true; Item.noUseGraphic = true; @@ -26,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.useTime = 15; Item.useAnimation = 15; Item.useStyle = ItemUseStyleID.Swing; - Item.knockBack = knockBack; + Item.knockBack = 5; Item.value = CalamityGlobalItem.Rarity11BuyPrice; Item.rare = ItemRarityID.Purple; Item.UseSound = SoundID.Item1; @@ -50,7 +46,7 @@ namespace CalamityMod.Items.Weapons.Rogue } } - public override float StealthDamageMultiplier => SdamageMult; + public override float StealthDamageMultiplier => 0.10f; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Rogue/LunarKunai.cs b/Items/Weapons/Rogue/LunarKunai.cs index 78c82ac42b..f0a52d7d84 100644 --- a/Items/Weapons/Rogue/LunarKunai.cs +++ b/Items/Weapons/Rogue/LunarKunai.cs @@ -39,42 +39,42 @@ namespace CalamityMod.Items.Weapons.Rogue public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float kunaiSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = kunaiSpeed; } else { - num80 = num72 / num80; + mouseDistance = kunaiSpeed / mouseDistance; } - num78 *= num80; - num79 *= num80; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; int projAmt = player.Calamity().StealthStrikeAvailable() ? 8 : 3; for (int i = 0; i < projAmt; i++) { - float num148 = num78; - float num149 = num79; - float num150 = 0.05f * (float)i; - num148 += (float)Main.rand.Next(-35, 36) * num150; - num149 += (float)Main.rand.Next(-35, 36) * num150; - num80 = (float)Math.Sqrt((double)(num148 * num148 + num149 * num149)); - num80 = num72 / num80; - num148 *= num80; - num149 *= num80; - float x4 = vector2.X; - float y4 = vector2.Y; - int stealth = Projectile.NewProjectile(source, x4, y4, num148, num149, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); + float randXOffset = mouseXDist; + float randYOffset = mouseYDist; + float randOffsetDampener = 0.05f * (float)i; + randXOffset += (float)Main.rand.Next(-35, 36) * randOffsetDampener; + randYOffset += (float)Main.rand.Next(-35, 36) * randOffsetDampener; + mouseDistance = (float)Math.Sqrt((double)(randXOffset * randXOffset + randYOffset * randYOffset)); + mouseDistance = kunaiSpeed / mouseDistance; + randXOffset *= mouseDistance; + randYOffset *= mouseDistance; + float x4 = realPlayerPos.X; + float y4 = realPlayerPos.Y; + int stealth = Projectile.NewProjectile(source, x4, y4, randXOffset, randYOffset, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); if (stealth.WithinBounds(Main.maxProjectiles) && player.Calamity().StealthStrikeAvailable()) Main.projectile[stealth].Calamity().stealthStrike = true; } diff --git a/Items/Weapons/Rogue/MeteorFist.cs b/Items/Weapons/Rogue/MeteorFist.cs index f7b646e028..8b04b13f45 100644 --- a/Items/Weapons/Rogue/MeteorFist.cs +++ b/Items/Weapons/Rogue/MeteorFist.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.DamageType = RogueDamageClass.Instance; } - public override float StealthDamageMultiplier => 7f; + public override float StealthDamageMultiplier => 3.6f; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Rogue/Penumbra.cs b/Items/Weapons/Rogue/Penumbra.cs index cca4ae7b1f..a8e33bf71f 100644 --- a/Items/Weapons/Rogue/Penumbra.cs +++ b/Items/Weapons/Rogue/Penumbra.cs @@ -44,20 +44,20 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - realPlayerPos.Y; } - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = player.direction; - num79 = 0f; + mouseXDist = player.direction; + mouseYDist = 0f; } - vector2 += new Vector2(num78, num79); - int proj = Projectile.NewProjectile(source, vector2, new Vector2(0f,-0.5f), ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 1f); + realPlayerPos += new Vector2(mouseXDist, mouseYDist); + int proj = Projectile.NewProjectile(source, realPlayerPos, new Vector2(0f,-0.5f), ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 1f); if (proj.WithinBounds(Main.maxProjectiles)) Main.projectile[proj].Calamity().stealthStrike = true; return false; diff --git a/Items/Weapons/Rogue/PhantasmalRuin.cs b/Items/Weapons/Rogue/PhantasmalRuin.cs index f0996ca299..2e941e5d92 100644 --- a/Items/Weapons/Rogue/PhantasmalRuin.cs +++ b/Items/Weapons/Rogue/PhantasmalRuin.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Weapons.Rogue Item.damage = 145; Item.knockBack = 8f; - Item.width = 102; - Item.height = 98; + Item.width = 108; + Item.height = 114; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.noUseGraphic = true; diff --git a/Items/Weapons/Rogue/PhantasmalRuin.png b/Items/Weapons/Rogue/PhantasmalRuin.png index 337b8ecc7d..63c6a9893d 100644 Binary files a/Items/Weapons/Rogue/PhantasmalRuin.png and b/Items/Weapons/Rogue/PhantasmalRuin.png differ diff --git a/Items/Weapons/Rogue/RealityRupture.cs b/Items/Weapons/Rogue/RealityRupture.cs index 7267ef024b..e6fff98dfd 100644 --- a/Items/Weapons/Rogue/RealityRupture.cs +++ b/Items/Weapons/Rogue/RealityRupture.cs @@ -24,9 +24,9 @@ namespace CalamityMod.Items.Weapons.Rogue Item.damage = 225; Item.noMelee = true; Item.noUseGraphic = true; - Item.useAnimation = 43; + Item.useAnimation = 37; Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 43; + Item.useTime = 37; Item.knockBack = 9f; Item.UseSound = SoundID.Item1; Item.autoReuse = true; diff --git a/Items/Weapons/Rogue/ScourgeoftheDesert.cs b/Items/Weapons/Rogue/ScourgeoftheDesert.cs index 86fb08fe63..f3c9976c85 100644 --- a/Items/Weapons/Rogue/ScourgeoftheDesert.cs +++ b/Items/Weapons/Rogue/ScourgeoftheDesert.cs @@ -11,17 +11,16 @@ namespace CalamityMod.Items.Weapons.Rogue { public override void SetDefaults() { - Item.width = 44; - Item.damage = 16; + Item.width = 82; + Item.height = 82; + Item.damage = 12; Item.noMelee = true; Item.noUseGraphic = true; - Item.useAnimation = 20; Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 20; + Item.useTime = Item.useAnimation = 24; Item.knockBack = 3.5f; Item.UseSound = SoundID.Item1; Item.autoReuse = true; - Item.height = 44; Item.value = CalamityGlobalItem.Rarity2BuyPrice; Item.rare = ItemRarityID.Green; Item.shoot = ModContent.ProjectileType(); @@ -29,13 +28,20 @@ namespace CalamityMod.Items.Weapons.Rogue Item.DamageType = RogueDamageClass.Instance; } + public override float StealthDamageMultiplier => 0.65f; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.Calamity().StealthStrikeAvailable()) + if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + int index = 5; + for (int i = -index; i <= index; i += index) + { + Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.ToRadians(i)); + int stealth = Projectile.NewProjectile(source, position, perturbedSpeed, type, damage, knockback, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + } return false; } return true; diff --git a/Items/Weapons/Rogue/ScourgeoftheDesert.png b/Items/Weapons/Rogue/ScourgeoftheDesert.png index bf471717cd..8e86310af5 100644 Binary files a/Items/Weapons/Rogue/ScourgeoftheDesert.png and b/Items/Weapons/Rogue/ScourgeoftheDesert.png differ diff --git a/Items/Weapons/Rogue/Seraphim.cs b/Items/Weapons/Rogue/Seraphim.cs index 4668d94a33..05f34b2484 100644 --- a/Items/Weapons/Rogue/Seraphim.cs +++ b/Items/Weapons/Rogue/Seraphim.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 82; Item.height = 82; - Item.damage = 300; + Item.damage = 320; Item.noMelee = true; Item.noUseGraphic = true; Item.useAnimation = 13; diff --git a/Items/Weapons/Rogue/ShardofAntumbra.cs b/Items/Weapons/Rogue/ShardofAntumbra.cs index a4ad7e5e84..d75d59cc2c 100644 --- a/Items/Weapons/Rogue/ShardofAntumbra.cs +++ b/Items/Weapons/Rogue/ShardofAntumbra.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SetDefaults() { Item.width = 48; - Item.damage = 450; + Item.damage = 240; Item.noMelee = true; Item.consumable = true; Item.noUseGraphic = true; diff --git a/Items/Weapons/Rogue/SpearofDestiny.cs b/Items/Weapons/Rogue/SpearofDestiny.cs index f920fdbf3f..d4fd9c8be5 100644 --- a/Items/Weapons/Rogue/SpearofDestiny.cs +++ b/Items/Weapons/Rogue/SpearofDestiny.cs @@ -21,9 +21,9 @@ namespace CalamityMod.Items.Weapons.Rogue Item.damage = 50; Item.noMelee = true; Item.noUseGraphic = true; - Item.useAnimation = 45; + Item.useAnimation = 40; Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 45; + Item.useTime = 40; Item.knockBack = 2f; Item.UseSound = ThrowSound; Item.autoReuse = true; diff --git a/Items/Weapons/Rogue/StormfrontRazor.cs b/Items/Weapons/Rogue/StormfrontRazor.cs index ff1ef37f07..f41fe6dce1 100644 --- a/Items/Weapons/Rogue/StormfrontRazor.cs +++ b/Items/Weapons/Rogue/StormfrontRazor.cs @@ -23,8 +23,8 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SetDefaults() { - Item.width = 38; - Item.height = 38; + Item.width = 56; + Item.height = 64; Item.noMelee = true; Item.noUseGraphic = true; Item.UseSound = SoundID.Item1; diff --git a/Items/Weapons/Rogue/StormfrontRazor.png b/Items/Weapons/Rogue/StormfrontRazor.png index bce22e87ec..4818e4a5de 100644 Binary files a/Items/Weapons/Rogue/StormfrontRazor.png and b/Items/Weapons/Rogue/StormfrontRazor.png differ diff --git a/Items/Weapons/Rogue/TheOldReaper.cs b/Items/Weapons/Rogue/TheOldReaper.cs index be448633b6..9c8f188a27 100644 --- a/Items/Weapons/Rogue/TheOldReaper.cs +++ b/Items/Weapons/Rogue/TheOldReaper.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Rogue for (int i = 0; i < 3; i++) { Vector2 perturbedspeed = new Vector2(velocity.X + Main.rand.Next(-2,3), velocity.Y + Main.rand.Next(-2,3)).RotatedBy(MathHelper.ToRadians(spread)); - int proj = Projectile.NewProjectile(source, position, perturbedspeed, type, damage, knockback, player.whoAmI); + int proj = Projectile.NewProjectile(source, position, perturbedspeed, type, (int)(damage*0.45), knockback, player.whoAmI); if (proj.WithinBounds(Main.maxProjectiles)) { Main.projectile[proj].Calamity().stealthStrike = true; diff --git a/Items/Weapons/Rogue/Wrathwing.cs b/Items/Weapons/Rogue/Wrathwing.cs index 0701c4b7f5..c75d32c93d 100644 --- a/Items/Weapons/Rogue/Wrathwing.cs +++ b/Items/Weapons/Rogue/Wrathwing.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.DamageType = RogueDamageClass.Instance; } - public override float StealthDamageMultiplier => 0.85f; + public override float StealthDamageMultiplier => 0.9f; 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/Summon/AncientIceChunk.cs b/Items/Weapons/Summon/AncientIceChunk.cs index f89c10f34a..2f9eec8aac 100644 --- a/Items/Weapons/Summon/AncientIceChunk.cs +++ b/Items/Weapons/Summon/AncientIceChunk.cs @@ -1,7 +1,7 @@ -using Terraria.DataStructures; -using CalamityMod.Projectiles.Summon; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -9,10 +9,9 @@ namespace CalamityMod.Items.Weapons.Summon { public class AncientIceChunk : ModItem, ILocalizedModType { - #region Other stats + #region Other Stats public static int IFrames = 20; - public static float EnemyDistanceDetection = 1200f; public static float MaxDistanceFromOwner = 400f; // Max distance the minions can be while shooting or idling. public static float DistanceToDash = 250f; // Min distance to start dashing. public static float DistanceToStopDash = 800f; // Max distance the player can be so the minions continue dashing. @@ -21,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Summon public static float ProjectileDMGMultiplier = 1.5f; // They're kinda' weak. #endregion - + public new string LocalizationCategory => "Items.Weapons.Summon"; public override void SetStaticDefaults() @@ -29,31 +28,29 @@ namespace CalamityMod.Items.Weapons.Summon Main.RegisterItemAnimation(Type, new DrawAnimationVertical(6, 6)); ItemID.Sets.AnimatesAsSoul[Type] = true; } - + public override void SetDefaults() { Item.damage = 25; - Item.mana = 10; - Item.width = 30; - Item.height = 30; - Item.useTime = Item.useAnimation = 25; - Item.useStyle = ItemUseStyleID.Swing; - Item.noMelee = true; + Item.DamageType = DamageClass.Summon; + Item.shoot = ModContent.ProjectileType(); Item.knockBack = 2f; + + Item.useTime = Item.useAnimation = 25; + Item.mana = 10; + Item.width = 38; + Item.height = 50; + Item.noMelee = true; + Item.autoReuse = true; Item.value = CalamityGlobalItem.Rarity4BuyPrice; Item.rare = ItemRarityID.LightRed; + Item.useStyle = ItemUseStyleID.Swing; Item.UseSound = SoundID.Item30; - Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.DamageType = DamageClass.Summon; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int clasper = Projectile.NewProjectile(source, Main.MouseWorld, new Vector2(Main.rand.NextFloat(-1f, 1f), Main.rand.NextFloat(-1f, 1f)), type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(clasper)) - Main.projectile[clasper].originalDamage = Item.damage; - + Projectile.NewProjectileDirect(source, Main.MouseWorld, Main.rand.NextVector2Circular(1f, 1f), type, damage, knockback, player.whoAmI); return false; } } diff --git a/Items/Weapons/Summon/AquasScepter.cs b/Items/Weapons/Summon/AquasScepter.cs index 5d3ab670b2..3e8f4c70d8 100644 --- a/Items/Weapons/Summon/AquasScepter.cs +++ b/Items/Weapons/Summon/AquasScepter.cs @@ -25,8 +25,8 @@ namespace CalamityMod.Items.Weapons.Summon Item.mana = 50; Item.DamageType = DamageClass.Summon; Item.sentry = true; - Item.width = 48; - Item.height = 48; + Item.width = 56; + Item.height = 56; Item.useTime = 30; Item.useAnimation = 30; Item.useStyle = 1; diff --git a/Items/Weapons/Summon/AquasScepter.png b/Items/Weapons/Summon/AquasScepter.png index 8c62607bb7..5cf53f4288 100644 Binary files a/Items/Weapons/Summon/AquasScepter.png and b/Items/Weapons/Summon/AquasScepter.png differ diff --git a/Items/Weapons/Summon/AresExoskeleton.cs b/Items/Weapons/Summon/AresExoskeleton.cs index 30bc3e1e81..cbf43d0fc4 100644 --- a/Items/Weapons/Summon/AresExoskeleton.cs +++ b/Items/Weapons/Summon/AresExoskeleton.cs @@ -89,7 +89,7 @@ namespace CalamityMod.Items.Weapons.Summon public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) { Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Summon/AresExoskeleton").Value; - if (ArmExists(Main.LocalPlayer)) + if (!Main.gameMenu && ArmExists(Main.LocalPlayer)) { texture = ModContent.Request("CalamityMod/Items/Weapons/Summon/AresExoskeletonRemote").Value; position.X += scale * 6f; diff --git a/Items/Weapons/Summon/BrittleStarStaff.cs b/Items/Weapons/Summon/BrittleStarStaff.cs new file mode 100644 index 0000000000..662054a9d7 --- /dev/null +++ b/Items/Weapons/Summon/BrittleStarStaff.cs @@ -0,0 +1,73 @@ +using Terraria.DataStructures; +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using CalamityMod.Projectiles.Typeless; +using static Humanizer.In; + +namespace CalamityMod.Items.Weapons.Summon +{ + [LegacyName("SeaboundStaff")] + public class BrittleStarStaff : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Summon"; + public float Knockback = 2f; + public override void SetDefaults() + { + Item.damage = 10; + Item.mana = 10; + Item.width = Item.height = 44; + Item.useTime = Item.useAnimation = 32; + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.knockBack = Knockback; + Item.value = CalamityGlobalItem.Rarity2BuyPrice; + Item.rare = ItemRarityID.Green; + Item.UseSound = SoundID.Item44 with { Pitch = 0.5f}; + Item.autoReuse = true; + Item.shootSpeed = 5; + Item.shoot = ModContent.ProjectileType(); + Item.DamageType = DamageClass.Summon; + } + public override void SetStaticDefaults() + { + Item.staff[Item.type] = true; + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; + } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + if (player.altFunctionUse != 2) + { + Item.noUseGraphic = false; + position = Main.MouseWorld; + velocity = Vector2.Zero; + int SummonNumber = player.ownedProjectileCounts[type]; + int p = Projectile.NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, type, damage, knockback, player.whoAmI, 0, 0, SummonNumber); + if (Main.projectile.IndexInRange(p)) + Main.projectile[p].originalDamage = Item.damage; + } + if (player.altFunctionUse == 2) + { + Item.noUseGraphic = true; + } + int bladeIndex = 0; + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].type == type && Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI) + { + Main.projectile[i].ModProjectile().StarIndex = bladeIndex++; + Main.projectile[i].ModProjectile().AITimer = 0f; + Main.projectile[i].netUpdate = true; + } + } + return false; + } + public override void HoldItem(Player player) + { + //player.Calamity().rightClickListener = true; + //player.Calamity().mouseWorldListener = true; + } + } +} diff --git a/Items/Weapons/Summon/BrittleStarStaff.png b/Items/Weapons/Summon/BrittleStarStaff.png new file mode 100644 index 0000000000..782d3eb149 Binary files /dev/null and b/Items/Weapons/Summon/BrittleStarStaff.png differ diff --git a/Items/Weapons/Summon/EnchantedConch.cs b/Items/Weapons/Summon/EnchantedConch.cs index 910403a22a..3e9c7b9671 100644 --- a/Items/Weapons/Summon/EnchantedConch.cs +++ b/Items/Weapons/Summon/EnchantedConch.cs @@ -34,30 +34,29 @@ 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) { int i = Main.myPlayer; - float num72 = Item.shootSpeed; - int num73 = damage; + float projSpeed = Item.shootSpeed; player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; + mouseXDist = (float)player.direction; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - num78 = 0f; - num79 = 0f; - vector2.X = (float)Main.mouseX + Main.screenPosition.X; - vector2.Y = (float)Main.mouseY + Main.screenPosition.Y; - int p = Projectile.NewProjectile(source, vector2.X, vector2.Y, num78, num79, ModContent.ProjectileType(), num73, knockback, i, 0f, 0f); + mouseXDist = 0f; + mouseYDist = 0f; + realPlayerPos.X = (float)Main.mouseX + Main.screenPosition.X; + realPlayerPos.Y = (float)Main.mouseY + Main.screenPosition.Y; + int p = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, mouseXDist, mouseYDist, ModContent.ProjectileType(), damage, knockback, i, 0f, 0f); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; return false; diff --git a/Items/Weapons/Summon/EntropysVigil.cs b/Items/Weapons/Summon/EntropysVigil.cs index 581fb72238..ec80ab9fe7 100644 --- a/Items/Weapons/Summon/EntropysVigil.cs +++ b/Items/Weapons/Summon/EntropysVigil.cs @@ -34,41 +34,41 @@ 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) { int i = Main.myPlayer; - float num72 = Item.shootSpeed; + float projSpeed = Item.shootSpeed; player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - num78 *= num80; - num79 *= num80; - vector2.X = (float)Main.mouseX + Main.screenPosition.X; - vector2.Y = (float)Main.mouseY + Main.screenPosition.Y; - Vector2 spinningpoint = new Vector2(num78, num79); + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + realPlayerPos.X = (float)Main.mouseX + Main.screenPosition.X; + realPlayerPos.Y = (float)Main.mouseY + Main.screenPosition.Y; + Vector2 spinningpoint = new Vector2(mouseXDist, mouseYDist); spinningpoint = spinningpoint.RotatedBy(1.5707963705062866, default); - int p = Projectile.NewProjectile(source, vector2.X + spinningpoint.X, vector2.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, ModContent.ProjectileType(), damage, knockback, i, 0f, 1f); + int p = Projectile.NewProjectile(source, realPlayerPos.X + spinningpoint.X, realPlayerPos.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, ModContent.ProjectileType(), damage, knockback, i, 0f, 1f); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; spinningpoint = spinningpoint.RotatedBy(-3.1415927410125732, default); - p = Projectile.NewProjectile(source, vector2.X + spinningpoint.X, vector2.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, ModContent.ProjectileType(), damage, knockback, i, 0f, 0f); + p = Projectile.NewProjectile(source, realPlayerPos.X + spinningpoint.X, realPlayerPos.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, ModContent.ProjectileType(), damage, knockback, i, 0f, 0f); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; spinningpoint = spinningpoint.RotatedBy(-5.1415927410125732, default); - p = Projectile.NewProjectile(source, vector2.X + spinningpoint.X, vector2.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, ModContent.ProjectileType(), damage, knockback, i, 0f, 1f); + p = Projectile.NewProjectile(source, realPlayerPos.X + spinningpoint.X, realPlayerPos.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, ModContent.ProjectileType(), damage, knockback, i, 0f, 1f); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; return false; diff --git a/Items/Weapons/Summon/EtherealSubjugator.cs b/Items/Weapons/Summon/EtherealSubjugator.cs index 362c2b5eed..362b210822 100644 --- a/Items/Weapons/Summon/EtherealSubjugator.cs +++ b/Items/Weapons/Summon/EtherealSubjugator.cs @@ -42,33 +42,33 @@ namespace CalamityMod.Items.Weapons.Summon if (player.altFunctionUse != 2) { int i = Main.myPlayer; - float num72 = Item.shootSpeed; + float projSpeed = Item.shootSpeed; player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - num78 *= num80; - num79 *= num80; - vector2.X = (float)Main.mouseX + Main.screenPosition.X; - vector2.Y = (float)Main.mouseY + Main.screenPosition.Y; - Vector2 spinningpoint = new Vector2(num78, num79); + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + realPlayerPos.X = (float)Main.mouseX + Main.screenPosition.X; + realPlayerPos.Y = (float)Main.mouseY + Main.screenPosition.Y; + Vector2 spinningpoint = new Vector2(mouseXDist, mouseYDist); spinningpoint = spinningpoint.RotatedBy(1.5707963705062866, default); - int p = Projectile.NewProjectile(source, vector2.X + spinningpoint.X, vector2.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, type, damage, knockback, i, 0f, 1f); + int p = Projectile.NewProjectile(source, realPlayerPos.X + spinningpoint.X, realPlayerPos.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, type, damage, knockback, i, 0f, 1f); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; } diff --git a/Items/Weapons/Summon/FuelCellBundle.cs b/Items/Weapons/Summon/FuelCellBundle.cs index 7be7461dc3..6914b94088 100644 --- a/Items/Weapons/Summon/FuelCellBundle.cs +++ b/Items/Weapons/Summon/FuelCellBundle.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { Item.mana = 10; - Item.damage = 20; + Item.damage = 25; Item.useStyle = ItemUseStyleID.Swing; Item.width = 32; Item.height = 32; diff --git a/Items/Weapons/Summon/HauntedScroll.cs b/Items/Weapons/Summon/HauntedScroll.cs index 5a5c76d627..65d293808f 100644 --- a/Items/Weapons/Summon/HauntedScroll.cs +++ b/Items/Weapons/Summon/HauntedScroll.cs @@ -10,12 +10,18 @@ namespace CalamityMod.Items.Weapons.Summon public class HauntedScroll : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Summon"; + public override void SetStaticDefaults() + { + ItemID.Sets.AnimatesAsSoul[Type] = true; + Main.RegisterItemAnimation(Type, new DrawAnimationVertical(6, 6)); + } + public override void SetDefaults() { Item.damage = 25; Item.mana = 10; - Item.width = 52; - Item.height = 52; + Item.width = 36; + Item.height = 48; Item.useTime = Item.useAnimation = 24; Item.useStyle = ItemUseStyleID.HoldUp; Item.noMelee = true; diff --git a/Items/Weapons/Summon/HauntedScroll.png b/Items/Weapons/Summon/HauntedScroll.png index f6199e1553..8ddebbd5cc 100644 Binary files a/Items/Weapons/Summon/HauntedScroll.png and b/Items/Weapons/Summon/HauntedScroll.png differ diff --git a/Items/Weapons/Summon/ResurrectionButterfly.cs b/Items/Weapons/Summon/ResurrectionButterfly.cs index b7cc95f0d7..f4ef5c48dd 100644 --- a/Items/Weapons/Summon/ResurrectionButterfly.cs +++ b/Items/Weapons/Summon/ResurrectionButterfly.cs @@ -37,37 +37,37 @@ 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) { int i = Main.myPlayer; - float num72 = Item.shootSpeed; + float projSpeed = Item.shootSpeed; player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - num78 *= num80; - num79 *= num80; - vector2.X = (float)Main.mouseX + Main.screenPosition.X; - vector2.Y = (float)Main.mouseY + Main.screenPosition.Y; - Vector2 spinningpoint = new Vector2(num78, num79); + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + realPlayerPos.X = (float)Main.mouseX + Main.screenPosition.X; + realPlayerPos.Y = (float)Main.mouseY + Main.screenPosition.Y; + Vector2 spinningpoint = new Vector2(mouseXDist, mouseYDist); spinningpoint = spinningpoint.RotatedBy(1.5707963705062866, default); - int p = Projectile.NewProjectile(source, vector2.X + spinningpoint.X, vector2.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, ModContent.ProjectileType(), damage, knockback, i, 0f, 0f); + int p = Projectile.NewProjectile(source, realPlayerPos.X + spinningpoint.X, realPlayerPos.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, ModContent.ProjectileType(), damage, knockback, i, 0f, 0f); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; spinningpoint = spinningpoint.RotatedBy(-3.1415927410125732, default); - p = Projectile.NewProjectile(source, vector2.X + spinningpoint.X, vector2.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, ModContent.ProjectileType(), damage, knockback, i, 0f, 0f); + p = Projectile.NewProjectile(source, realPlayerPos.X + spinningpoint.X, realPlayerPos.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, ModContent.ProjectileType(), damage, knockback, i, 0f, 0f); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; return false; diff --git a/Items/Weapons/Summon/SeaboundStaff.cs b/Items/Weapons/Summon/SeaboundStaff.cs deleted file mode 100644 index 0f20efdeba..0000000000 --- a/Items/Weapons/Summon/SeaboundStaff.cs +++ /dev/null @@ -1,43 +0,0 @@ -using Terraria.DataStructures; -using CalamityMod.Projectiles.Summon; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Summon -{ - public class SeaboundStaff : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Summon"; - public override void SetDefaults() - { - Item.damage = 11; - Item.mana = 10; - Item.width = Item.height = 44; - Item.useTime = Item.useAnimation = 35; - Item.useStyle = ItemUseStyleID.Swing; - Item.noMelee = true; - Item.knockBack = 2f; - Item.value = CalamityGlobalItem.Rarity2BuyPrice; - Item.rare = ItemRarityID.Green; - Item.UseSound = SoundID.Item44; - Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.DamageType = DamageClass.Summon; - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - if (player.altFunctionUse != 2) - { - position = Main.MouseWorld; - velocity = Vector2.Zero; - int p = Projectile.NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } - return false; - } - } -} diff --git a/Items/Weapons/Summon/SeaboundStaff.png b/Items/Weapons/Summon/SeaboundStaff.png deleted file mode 100644 index 6af047ee40..0000000000 Binary files a/Items/Weapons/Summon/SeaboundStaff.png and /dev/null differ diff --git a/Items/Weapons/Summon/SlimePuppetStaff.cs b/Items/Weapons/Summon/SlimePuppetStaff.cs index 31195f4d96..0dcb95fb2b 100644 --- a/Items/Weapons/Summon/SlimePuppetStaff.cs +++ b/Items/Weapons/Summon/SlimePuppetStaff.cs @@ -13,20 +13,14 @@ namespace CalamityMod.Items.Weapons.Summon public class SlimePuppetStaff : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Summon"; - public override void SetStaticDefaults() - { - // In other words, bootleg mage :TaxEvasion: - Item.staff[Item.type] = true; - } - public override void SetDefaults() { Item.damage = 26; Item.mana = 10; - Item.width = 48; - Item.height = 56; + Item.width = 32; + Item.height = 34; Item.useTime = Item.useAnimation = 29; - Item.useStyle = ItemUseStyleID.Shoot; + Item.useStyle = ItemUseStyleID.HoldUp; Item.noMelee = true; Item.knockBack = 3.6f; Item.value = CalamityGlobalItem.Rarity4BuyPrice; diff --git a/Items/Weapons/Summon/SlimePuppetStaff.png b/Items/Weapons/Summon/SlimePuppetStaff.png index 119db86506..f53f142963 100644 Binary files a/Items/Weapons/Summon/SlimePuppetStaff.png and b/Items/Weapons/Summon/SlimePuppetStaff.png differ diff --git a/Items/Weapons/Summon/VileFeeder.cs b/Items/Weapons/Summon/VileFeeder.cs index c42b8e20d1..22cdd84e12 100644 --- a/Items/Weapons/Summon/VileFeeder.cs +++ b/Items/Weapons/Summon/VileFeeder.cs @@ -37,33 +37,33 @@ namespace CalamityMod.Items.Weapons.Summon if (player.altFunctionUse != 2) { int i = Main.myPlayer; - float num72 = Item.shootSpeed; + float projSpeed = Item.shootSpeed; player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - num78 *= num80; - num79 *= num80; - vector2.X = (float)Main.mouseX + Main.screenPosition.X; - vector2.Y = (float)Main.mouseY + Main.screenPosition.Y; - Vector2 spinningpoint = new Vector2(num78, num79); + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + realPlayerPos.X = (float)Main.mouseX + Main.screenPosition.X; + realPlayerPos.Y = (float)Main.mouseY + Main.screenPosition.Y; + Vector2 spinningpoint = new Vector2(mouseXDist, mouseYDist); spinningpoint = spinningpoint.RotatedBy(MathHelper.PiOver2, default); - int p = Projectile.NewProjectile(source, vector2.X + spinningpoint.X, vector2.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, type, damage, knockback, i, 0f, 0f); + int p = Projectile.NewProjectile(source, realPlayerPos.X + spinningpoint.X, realPlayerPos.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, type, damage, knockback, i, 0f, 0f); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; } diff --git a/Items/Weapons/Summon/ViralSprout.cs b/Items/Weapons/Summon/ViralSprout.cs index cf731329dd..822d0453c7 100644 --- a/Items/Weapons/Summon/ViralSprout.cs +++ b/Items/Weapons/Summon/ViralSprout.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Summon public new string LocalizationCategory => "Items.Weapons.Summon"; public override void SetDefaults() { - Item.damage = 24; + Item.damage = 30; Item.mana = 10; Item.width = 48; Item.height = 56; diff --git a/Localization/en-US/Mods.CalamityMod.Bestiary.hjson b/Localization/en-US/Mods.CalamityMod.Bestiary.hjson index 695fc84d5b..a3201816ea 100644 --- a/Localization/en-US/Mods.CalamityMod.Bestiary.hjson +++ b/Localization/en-US/Mods.CalamityMod.Bestiary.hjson @@ -1,46 +1,45 @@ //Abyss Enemies BabyCannonballJellyfish: These creatures have been hunted for centuries now. They are widely used as ammunition in ships or even as normal bombs. Despite this, they never truly vanish, as if an external power kept this species alive. Bloatfish: More geological than biological, bloatfish have sticky glue-like skin that they use to cover their bodies in voidstone. Though it protects them from predators, their immense weight has sunk them to the deepest parts of the Abyss. -BobbitWorm: Hiding away in the darkest corners of the void to strike at unsuspecting prey, bobbit worms take full advantage of the Abyss’ darkness. To live here, in the most extreme environment in the world, a creature must either be truly mighty, learn to use the environment to survive, or both. +BobbitWorm: Hiding away in the darkest corners of the void to strike at unsuspecting prey, bobbit worms take full advantage of the Abyss' darkness. To live here, in the most extreme environment in the world, a creature must either be truly mighty, learn to use the environment to survive, or both. BoxJellyfish: Larger than the average jellyfish, the sting of these persistent pests packs a powerful punch. Though they can be found in most large bodies of water, they are locally extinct around Ilmeris after the Brimstone Witch turned her hexes against the kingdom. CannonballJellyfish: These jellyfishes help keep the Abyss clean from the sulphuric poisoning. Unlike most hard-skinned creatures in the Sulphurous Sea, they instead use their stingers to drain the acid near them to later use it for self-defense. ChaoticPuffer: These creatures inhale trace amounts of scoria in the water while inflating, heating the liquid inside of them immensely. Hot enough to melt iron in this state, they cause horrific burns to those they make contact with, and predators attempting to consume them are boiled from the inside out. -ColossalSquid: This species of squid has grown immensely in size and strength due to the effects Silva’s essence has had on them. As they are able to consume the growths she caused directly due to being herbivores in the past, more life flows within them than nearly every other Abyss creature. +ColossalSquid: This species of squid has grown immensely in size and strength due to the effects Silva's essence has had on them. As they are able to consume the growths she caused directly due to being herbivores in the past, more life flows within them than nearly every other Abyss creature. Cuttlefish: Using natural camouflage to hide from greater predators and catch unsuspecting prey, cuttlefish wait patiently on the ground for their time to strike. They chase other creatures relentlessly once disturbed, with ferocity enough to scare off any of their would-be predators. -DevilFish: So called for their demonic horns, devilfish absorb the fumes left behind by Azafure’s pollution, using the flames to empower themselves. The Abyss’ lower layers are largely unmarred by waste and toxins thanks to these enigmatic creatures. -DevilFishAlt: So called for their demonic horns, devilfish absorb the fumes left behind by Azafure’s pollution, using the flames to empower themselves. The Abyss’ lower layers are largely unmarred by waste and toxins thanks to these enigmatic creatures. +DevilFish: So called for their demonic horns, devilfish absorb the fumes left behind by Azafure's pollution, using the flames to empower themselves. The Abyss' lower layers are largely unmarred by waste and toxins thanks to these enigmatic creatures. EidolonWyrm: Relatives of the auric dragons, they adapted to hide away in a forgotten corner of the world to survive the great purges. And yet even without auric souls, the power of eidolon wyrms rivals many of their brethren who possessed them. -GiantSquid: Squid are known to be cannibalistic animals, having few qualms with consuming their own kind when in need of food. Quite ironically, this creature’s main predator is itself. +GiantSquid: Squid are known to be cannibalistic animals, having few qualms with consuming their own kind when in need of food. Quite ironically, this creature's main predator is itself. GulperEel: Though sluggish and bulky, these eels traverse the abyss with surprising ease. They blend into the darkness, with a mouth that can stretch abnormally wide used to slowly swallow prey whole. Their meals are left unaware of their predicament until it is far too late. Laserfish: Its eyes are blinded by bacteria that gather in large sacs on its head. As it swims through the waters, relying on primitive echolocation, the bacteria are able to release concussive blasts to clear its path. LuminousCorvina: Lumenyl grows on the fins of these exotic corvina, making these creatures one of the few sources of light in the Abyss. It survives by guiding what would be its predators to other prey, signaling where it is by emitting a shrill pulse. MirageJelly: Using the light refracted from lumenyl crystals and water warmed by the scorching heat of scoria, these jellyfish can create afterimages of themselves to confuse predators, or catch prey of their own. -MorayEel: When a fish bites your heel and it looks like an eel, that’s a moray. When it swims in the reef and has two sets of teeth, that’s a moray. When you’re slapped in the face with a slimy embrace, that’s a moray. +MorayEel: When a fish bites your heel and it looks like an eel, that's a moray. When it swims in the reef and has two sets of teeth, that's a moray. When you're slapped in the face with a slimy embrace, that's a moray. Oarfish: Oarfish are known for laying thousands or even millions of eggs in astonishingly quick gestation cycles. These eggs are the most abundant source of food in the Abyss, being part of the reason even the smallest and least threatening creatures can live in the otherwise near inhospitable depths of the sea. -ReaperShark: Apex predators of the void, these sharks take advantage of both their stealthiness and might to hunt anything and everything that comes near. Using their arms for purposes from hurling colossal squids into the Abyss’ walls to crushing the heavily armored heads of eidolon wyrms, few can match their raw strength. +ReaperShark: Apex predators of the void, these sharks take advantage of both their stealthiness and might to hunt anything and everything that comes near. Using their arms for purposes from hurling colossal squids into the Abyss' walls to crushing the heavily armored heads of eidolon wyrms, few can match their raw strength. ToxicMinnow: These abnormally large minnows have evolved to use nutrients from plants they consume to create toxins inside their body, which is then released after they die. They have next to no predators due to this, and contribute nearly nothing to their environment. Viperfish: Omnivorous fish that dwell in the middle sections of the Abyss, viperfish rest firmly near the bottom of the food chain. Their wide mouth normally reserved for filter feeding can double as a means to scare off predators by mimicking the much more threatening gulper eels. //Acid Rain Enemies -AcidEel: Though they are predators themselves, acid eels lay near the bottom of the Sulphur Sea’s food chain. Their diet largely consists of mollusks, thanks to their ability to squirm into tight crevices. This paired with their speed and camouflage assist them in avoiding becoming meals for others. +AcidEel: Though they are predators themselves, acid eels lay near the bottom of the Sulphur Sea's food chain. Their diet largely consists of mollusks, thanks to their ability to squirm into tight crevices. This paired with their speed and camouflage assist them in avoiding becoming meals for others. BabyFlakCrab: Adolescent flak crabs make no attempt to fight off predators, and simply flee from any threats. Their species only learns to pelt their targets from afar later in life, leaving the adolescents defenseless and dependent on their parents. Bloodworm: Bloodworms are an exceedingly rare creature to stumble upon, as they burrow at the first sign of danger. It takes both exceedingly great patience, wisdom, and agility to catch one, leaving the worms ever having but a single natural predator. CragmawMire: A mostly immobile creature that dwells in the depths of the radioactive wasteland, it boasts an exoskeleton harder than titanium to defend its core. To compensate for its lack of movement, it has formed a symbiotic relationship with a worm that reels in prey in exchange for protection. FlakCrab: Needing to hide themselves from the roaming creatures, flak crabs disguise themselves as the sulfurous gas vents scattered across the Sulphurous Sea. As they reproduce quickly, stumbling upon these and their offspring is a rather common occurrence. -GammaSlime: A slime overloaded with radiation from Draedon’s long-since abandoned experiments with nuclear energy. Though methods of generating power involving nuclear energy surpassed all others that came before in terms of raw efficiency, not even these advancements were enough to satisfy the enigmatic engineer. -IrradiatedSlime: Though slime is known to fall from the sky on occasion, slime in the sky condenses far quicker here in the Sulphurous Sea, as its air is thick with sulfur and radiation. It isn’t uncommon for full sized slimes to fall from the heavens during acid rain storms, never mind a fully-fledged slime rain. +GammaSlime: A slime overloaded with radiation from Draedon's long-since abandoned experiments with nuclear energy. Though methods of generating power involving nuclear energy surpassed all others that came before in terms of raw efficiency, not even these advancements were enough to satisfy the enigmatic engineer. +IrradiatedSlime: Though slime is known to fall from the sky on occasion, slime in the sky condenses far quicker here in the Sulphurous Sea, as its air is thick with sulfur and radiation. It isn't uncommon for full sized slimes to fall from the heavens during acid rain storms, never mind a fully-fledged slime rain. Mauler: Powerful radiation has caused prehistoric genes to reawaken in this shark, granting it overwhelming speed and strength. The insatiable hunger of this beast draws it to the shoreline during acidic rainstorms for a feeding frenzy. NuclearTerror: The effects of our actions are never immediately obvious. Centuries of poison and constant fighting for its own life created such monstrosity, now dragged to the shore by the unrelenting torrents. Whatever it may have been before, all that is left now is its will to survive. NuclearToad: These toads expand like a pufferfish when creatures are near and burst when in danger. The otherwise terrifying inhabitants of the sea have learned well to avoid these critters due to their particularly explosive nature. -Orthocera: Though radiation normally slowly kills living things, thanks to Silva’s influence keeping creatures in the Sulphurous Sea alive, mutations caused by radiation will rarely reawaken lost genes and traits. These creatures are but one such example. +Orthocera: Though radiation normally slowly kills living things, thanks to Silva's influence keeping creatures in the Sulphurous Sea alive, mutations caused by radiation will rarely reawaken lost genes and traits. These creatures are but one such example. Radiator: A species of once near-extinct sea slugs that have learned to carry crystallized depleted plutonium on their backs to dissuade predators, rather than relying on toxins that most creatures in the Sulphurous Sea are now immune to. Though radiation is detrimental to most life, it has curiously been an opportunity for some. Skyfin: Too weak to hunt in the waters below, skyfins instead use their wing-like fins to take to the sky and generally feast on insects or even small birds that dare wander near the sea. However, they are also able to hunt larger prey on land by fighting in packs and using hit and run tactics. SulphurousSkater: Though their exoskeleton provides minimal protection, their deceptively light weight allows them to run on water. These curious insects are even known to ride acidic bubbles for better vantage points and to escape being devoured by surfacing sea creatures. -Trilobite: These aquatic arthropods make leaps and bounds in both water and air despite possessing shells like stone, both in texture and weight. Thanks to their immense shells, they are capable of passing through predators’ digestion systems unscathed. +Trilobite: These aquatic arthropods make leaps and bounds in both water and air despite possessing shells like stone, both in texture and weight. Thanks to their immense shells, they are capable of passing through predators' digestion systems unscathed. //Astral Enemies -Aries: These creatures bound across the landscape endlessly, chasing down any intruders that dare enter the hive mind’s home. The star’s power has bestowed them limitless stamina, rendering them unable to feel exhaustion. +Aries: These creatures bound across the landscape endlessly, chasing down any intruders that dare enter the hive mind's home. The star's power has bestowed them limitless stamina, rendering them unable to feel exhaustion. Astralachnea: Once black widows, they have now been reduced to their most basic functions. The effects of the Astral Infection are far more intense underground than it is on the surface, the air heavy with the thick fog and vestiges of the star burrowed deeply into the earth. AstralProbe: What were once simply common birds have been transmuted by the overwhelming amounts of mana. Though weak on their own, they choose to harass those who are unassimilated while the victim attempts to fight off other infected beasts. -AstralSlime: With slimes already acclimated to absorbing both matter and energy from the environment, it is a trivial matter for the star’s mana to overtake the gelatinous creatures of this land. But the slimes care not, for little about their existence is changed. +AstralSlime: With slimes already acclimated to absorbing both matter and energy from the environment, it is a trivial matter for the star's mana to overtake the gelatinous creatures of this land. But the slimes care not, for little about their existence is changed. Atlas: Knights of the infection, these fusions of creatures pack an immense punch. Though slow due to their overbearing weight, a single blow from an atlas is easily able to pulverize a monolith. Their hearts continue to slowly beat even after being ripped from their bodies, for their lives seemingly cannot truly end. FusionFeeder: Bloated with mana, the immense amount of magical power has dulled the instincts of these former sand sharks, their movements now slow and sluggish. Their need for food has been permanently sated, and they now thirst only for distant stars. Hadarian: Once mere desert vultures, they have been metamorphosed into new beings, their feathers stripped and replaced with gooey tissue and stone-like plating. They sit still as a statue, with eyes seemingly staring at both everything, and nothing at all. @@ -53,60 +52,60 @@ SightseerSpitter: What once were wandering eyes have been transformed into somet StellarCulex: Their pincers work not only as a weapon, but as a means of spreading the star further. By digging their claws into the ground, they are capable of infecting nearby caves with the help of their supercharged cores. Twinkler: These infected fireflies exist solely as prey, guiding unsuspecting creatures to the star for assimilation that would not be driven to it otherwise. //Brimstone Crags Enemies -CalamityEye: Born from the ashes of the battle between the witch and the elemental, these eye-like creatures are the weakest and most mundane of the Crag’s new inhabitants. Yet even they pose a threat to those who intrude upon their sacred grounds. -DespairStone: Constructs created from slabs of Brimstone, given life by warlocks that remain in Azafure. Able to accelerate to blistering speeds thanks to their wheel-like design, their sole purpose is to make sure that none dare trespass on their masters’ lands. -HeatSpirit: Citizens of Azafure who committed heinous crimes were cast out of the city and forced to don unremovable obsidian skulls as a mark of their sins, to let all know of their vile acts. Now the lost souls of those who were exiled are finally able to return home after the city’s fall, the skulls they wore being all that remains of them. -InfernalCongealment: A lava slime that has absorbed pieces of the charred stone left behind by the Brimstone Elemental. Despite its simple nature, these creatures are just as much of a threat as the rest of the Crag’s current inhabitants. +CalamityEye: Born from the ashes of the battle between the witch and the elemental, these eye-like creatures are the weakest and most mundane of the Crag's new inhabitants. Yet even they pose a threat to those who intrude upon their sacred grounds. +DespairStone: Constructs created from slabs of Brimstone, given life by warlocks that remain in Azafure. Able to accelerate to blistering speeds thanks to their wheel-like design, their sole purpose is to make sure that none dare trespass on their masters' lands. +HeatSpirit: Citizens of Azafure who committed heinous crimes were cast out of the city and forced to don unremovable obsidian skulls as a mark of their sins, to let all know of their vile acts. Now the lost souls of those who were exiled are finally able to return home after the city's fall, the skulls they wore being all that remains of them. +InfernalCongealment: A lava slime that has absorbed pieces of the charred stone left behind by the Brimstone Elemental. Despite its simple nature, these creatures are just as much of a threat as the rest of the Crag's current inhabitants. RenegadeWarlock: Victims caught in the crossfire during the battle between Calamitas and the Brimstone Elemental, cursed to wander the ruins of their former home for all eternity. Their final moments were spent clinging to life, and in death they seek survival by using the very magicks that slaughtered them. -Scryllar: Vengeful spirits of those who lost their lives during the clash between Calamitas and the elemental, now forever bound to their home. Those who were close enough to bear witness to the battle perished in it, leaving few to know the truth of the battle’s outcome. -SoulSlurper: An early form of Calamitas’ Soul Seekers, summoned by the Witch during her conflict with the Brimstone Elemental. Unlike the refined form that would follow it, she possessed very little control of them, leading to her creations going rogue shortly after the arduous battle was finally over. +Scryllar: Vengeful spirits of those who lost their lives during the clash between Calamitas and the elemental, now forever bound to their home. Those who were close enough to bear witness to the battle perished in it, leaving few to know the truth of the battle's outcome. +SoulSlurper: An early form of Calamitas' Soul Seekers, summoned by the Witch during her conflict with the Brimstone Elemental. Unlike the refined form that would follow it, she possessed very little control of them, leading to her creations going rogue shortly after the arduous battle was finally over. //Draedon Lab Critters -Androomba: One of the most mundane of Draedon’s creations, the directive of Androombas is simply to tidy up his labs and domiciles. He and his scientists could not afford to waste time on menial labor when there was endless research to be done. +Androomba: One of the most mundane of Draedon's creations, the directive of Androombas is simply to tidy up his labs and domiciles. He and his scientists could not afford to waste time on menial labor when there was endless research to be done. Nanodroid: Ambient lighting, total surveillance, instantaneous repair… With enough of these tiny machines working in unison, any problem is solvable. -RepairUnitCritter: These handy little helpers are the reason that Draedon’s decades-old labs stand to this day. Though bulkier and less energy efficient than nanodroids, having to take what power they need from the labs’ generators, they can easily clean up the dust, though struggle with the rust. +RepairUnitCritter: These handy little helpers are the reason that Draedon's decades-old labs stand to this day. Though bulkier and less energy efficient than nanodroids, having to take what power they need from the labs' generators, they can easily clean up the dust, though struggle with the rust. //Normal Uncategorized Enemies AeroSlime: Previously mundane slimes that have absorbed trace amounts of draconic essence from the outpour of energy caused by the re-enchantment of Aerialite. They now soar the skies with their newly sprouted wings, reaching heights few of their gelatinous kind ever have. -ArmoredDigger: Despite being relatively primitive compared to Draedon’s current technology, armored diggers continue to see use to this day. Though their primary directive is mining and delivering minerals, they also once cleared room for the numerous underground laboratories. -AuroraSpirit: Thought to be no more than an old wives’ tale, sightings of aurora spirits have become commonplace since the defeat of the wall of flesh. Upon closer inspection, it appears these “spirits” are rather wisp-like entities clad in a cryonic shell, a sure sign that these were created by Archmage Permafrost. +ArmoredDigger: Despite being relatively primitive compared to Draedon's current technology, armored diggers continue to see use to this day. Though their primary directive is mining and delivering minerals, they also once cleared room for the numerous underground laboratories. +AuroraSpirit: Thought to be no more than an old wives' tale, sightings of aurora spirits have become commonplace since the defeat of the wall of flesh. Upon closer inspection, it appears these "spirits" are rather wisp-like entities clad in a cryonic shell, a sure sign that these were created by Archmage Permafrost. BloomSlime: Imbued with profaned energy, this slime wishes to see the world reduced to ashes to ensure the suffering it brings is no more. However, the simplicity of their form makes it difficult for the slain goddess to fully impose her will onto them. Bohldohr: Bohldohrs were made to serve the lihzahrds, being crafted from ancient stone and brought to life with magical power in the twilight of the great Lihzahrd Dynasty. But the sun sets on every civilization, and once their deity abandoned them, they were left to fend for themselves. Cnidrion: Once trained to be the steeds of honored Ilmerian warriors, cnidrions survived the Incineration due to their sheer might. They continue to defend what was once the heart of the sea kingdom from intruders, maintaining a fierce loyalty to their masters even after they have passed on. -GemCrawler: Relatives to the Ilmeran Sea’s prismbacks. The aquatic lizards ended up in the wild after being taken in as pets, though without the proper nutrients to grow prisms on their back, many grew the next best thing– precious gems. +GemCrawler: Relatives to the Ilmeran Sea's prismbacks. The aquatic lizards ended up in the wild after being taken in as pets, though without the proper nutrients to grow prisms on their back, many grew the next best thing– precious gems. BlightSlime: Slimes that have absorbed some of the blighted godly essence. Riddled with impurity, they are now more putrid flesh than gelatin and, having taken in such an amount that they seem ready to burst. Yet unlike most slimes which have relatively basic minds, these seem to be collecting mass with a purpose. Cryon: Archmage Permafrost went through great pains to not take part in combat himself, instead molding cryons to act as his personal guardians. Noticing the spread of godly essence just as many other creatures have, they have come out of stasis to combat any signs of it so that they may defend their master. -CryoSlime: Slimes enchanted by the Archmage, as a host to crystallize the frozen power of the tundra into a magical metal. He cast a spell to hide away most of his creations and research soon after leaving the Godseeeker’s side, well aware that Yharim may attempt to exploit his previous work. +CryoSlime: Slimes enchanted by the Archmage, as a host to crystallize the frozen power of the tundra into a magical metal. He cast a spell to hide away most of his creations and research soon after leaving the Godseeeker's side, well aware that Yharim may attempt to exploit his previous work. Eidolist: Once members of the dragon cult, they now beg the favor of a new master. They are able to live in the abyss indefinitely thanks to their wyrm-like form, allowing them to serve a new purpose. FearlessGoldfishWarrior: Though Goldfish thrive in their ponds and lakes, many take to land during storms to feed on the worms that have also surfaced. There are even accounts of aquatic warriors who carry daggers of shimmering gold, though most consider these tales far too fishy to be credible. Frogfish: Well-camouflaged and prepared to strike at any moment, Frogfish show that the ocean is rarely as serene as it seems. There are few places where one can find true peace here in the heart of what once was an empire unrivaled. Horse: After the Brimstone Elemental became dormant, the forgemasters of Azafure used clockwork and crystal to bind the powers of an elemental to a mechanical body. While formidable, it seems the dream of creating a true replacement for an elemental died unfulfilled with Azafure itself. -IceClasper: Though their exact origins are an enigma, what is known is that these ethereal beings seek to stamp out any and all sources of warmth that exist in their home. Due to this fact, and taking into account the fossil record, many speculate that ice claspers may have played a vital role in the tundra’s creation. -ImpiousImmolator: An idol carved in the image of Her, it is lit ablaze with the crafter’s lifeforce. After all, what weight does one’s life hold when one wishes to see the world wreathed in Her holy flames? +IceClasper: Though their exact origins are an enigma, what is known is that these ethereal beings seek to stamp out any and all sources of warmth that exist in their home. Due to this fact, and taking into account the fossil record, many speculate that ice claspers may have played a vital role in the tundra's creation. +ImpiousImmolator: An idol carved in the image of Her, it is lit ablaze with the crafter's lifeforce. After all, what weight does one's life hold when one wishes to see the world wreathed in Her holy flames? MantisShrimp: Though a variety of answers are given when one asks adventurers about dangerous creatures, few aside from sailors will mention the small yet mighty Mantis Shrimp. Their strikes are so swift that the energy generated from them heats the water to temperatures rivaling the magma of Azafure. OverloadedSoldier: A body given life again, overflowing with the souls of warriors that perished during the Crusade who were unable to find peace. Their ravenous hunger for battle has been reignited due to sensing godly essences in the land once more. -PerennialSlime: These slimes have seized a small amount of the Goddess of Life’s essence. Despite her reimprisonment in the deepest depths of the Abyss, the tendrils of her influence now stretch far into the world beyond. +PerennialSlime: These slimes have seized a small amount of the Goddess of Life's essence. Despite her reimprisonment in the deepest depths of the Abyss, the tendrils of her influence now stretch far into the world beyond. PhantomSpirit: The spirits within the Dungeon only vaguely recall their lives, and yet there is one thing each and all clearly remember, that drives them to chaos: the man responsible for locking them in these cursed walls, and his overwhelming power– power that they have been reminded of, due to one ever growing in strength roaming their halls. Piggy: These little swines waddle their little legs across these lands with little purpose, but they are happy with just that. Yet, little is known about how their little stomach carries a not-so-little amount of coins. ProfanedEnergyBody: Those most devout to Her travel the world, being planted into societies and acting as spies and assassins. Among their duties is constructing shrines in Her honor infused with Her divine power, that She might bless pagans blinded by darkness with visions of Her new age of light. -Rimehound: These hounds were bred and trained to survive in the tundra’s hostile conditions by Yharim’s forces, so that they may act as scouts. Most were simply abandoned by their masters out of either necessity or choice, and were resigned to roam forever without purpose. +Rimehound: These hounds were bred and trained to survive in the tundra's hostile conditions by Yharim's forces, so that they may act as scouts. Most were simply abandoned by their masters out of either necessity or choice, and were resigned to roam forever without purpose. Rotdog: Fast and furious, these hounds prowl the night, hunting prey with their razor sharp teeth. They are similar in nature to the demon eyes, both being spawned from the same vile mire, yet these creatures are tailored made to end those who have proven themselves a threat to it. ScornEater: For one to be weak of will does not inherently mean they are weak of body. Within these powerful individuals does a powerful fire burn, and She is all too willing to fan the flames. All one need give in return for Her gracious blessing is their free will, and they shall be gifted Her enlightenment. -SeaUrchin: Massive urchins that roll and hop their way across the sea floor, catching both fish hiding in the sand thanks to their spikes that allow them to comb the sea floor and those far above with their incredible leaps. Their surprising size is due to this species’ carnivorous diet, rather than consuming plants like most types of urchins. +SeaUrchin: Massive urchins that roll and hop their way across the sea floor, catching both fish hiding in the sand thanks to their spikes that allow them to comb the sea floor and those far above with their incredible leaps. Their surprising size is due to this species' carnivorous diet, rather than consuming plants like most types of urchins. ShockstormShuttle: Mining devices and scouts for a civilization from a long lost world. They now seek whatever resources are left on other nearby planets, and perhaps even this world as a potential replacement for their ruined home. -Stormlion: Some survivors of Ilmeris’ downfall claim that enough magical lightning surged through the sea during its final days that there existed not a single drop of water without levin coursing through it. Even now, electricity from the battle remains buried in the sands, with several antlions having learned to both channel and harness the former kingdom’s power. -Sunskater: To the civilization that lived far above clouds, sunskaters were seen as a good omen. These creatures inspired hope in those who saw them, that their society might live on for as long as the sun’s light bathes the world. -ThiccWaifu: Part of a solitary elemental that rarely appears aside from when her domain is at its strongest. Many attempts were made by what remained of Yharim’s forces to hunt down the elementals after Azafure fell. Only now that the war has passed do the weaker elementals dare return. +Stormlion: Some survivors of Ilmeris' downfall claim that enough magical lightning surged through the sea during its final days that there existed not a single drop of water without levin coursing through it. Even now, electricity from the battle remains buried in the sands, with several antlions having learned to both channel and harness the former kingdom's power. +Sunskater: To the civilization that lived far above clouds, sunskaters were seen as a good omen. These creatures inspired hope in those who saw them, that their society might live on for as long as the sun's light bathes the world. +ThiccWaifu: Part of a solitary elemental that rarely appears aside from when her domain is at its strongest. Many attempts were made by what remained of Yharim's forces to hunt down the elementals after Azafure fell. Only now that the war has passed do the weaker elementals dare return. WildBumblefuck: Though but an adolescent dragonfolly, it poses a great threat to all around it regardless of its age. Their species survived the draconic purges by reproducing rapidly and becoming highly reclusive, alongside developing a hyper-aggressive nature. WulfrumAmplifier: These amplifiers empower fellow wulfrum machines through a surprisingly advanced tesla field. While the field is harmless to any organic beings that pass through it, wulfrum machines are designed to receive energy from it which allows them to run at peak efficiency. -WulfrumDrone: The purpose the wulfrum machines once fulfilled can most clearly be seen through the drones: to harass the basic troopers of Yharim’s forces. They were not threatening enough to be a priority target, though their laser attacks could be quite deadly if allowed to fully power up. +WulfrumDrone: The purpose the wulfrum machines once fulfilled can most clearly be seen through the drones: to harass the basic troopers of Yharim's forces. They were not threatening enough to be a priority target, though their laser attacks could be quite deadly if allowed to fully power up. WulfrumGyrator: One of the more advanced Wulfrum machines, they hop and roll unpredictably in an attempt to throw off any attacks from afar. Gyrators are not very threatening on their own, and were mostly deployed to defend other more important machines. -WulfrumHovercraft: Though they may seem advanced, even a novice engineer can create hovercrafts such as these. They can’t pack much firepower, and their armor may be thin, but these Wulfrum creations' true strength lies in being versatile and easy to repurpose into other projects. +WulfrumHovercraft: Though they may seem advanced, even a novice engineer can create hovercrafts such as these. They can't pack much firepower, and their armor may be thin, but these Wulfrum creations' true strength lies in being versatile and easy to repurpose into other projects. WulfrumRover: The most simple of the Wulfrum Machines, and the honorary mascot of those who rebelled against Yharim. Its small stature and eager movements may remind some of a dog, but don't be deceived; in the chaos of battle, a Rover is still dangerous. //Plague Enemies Melter: While its frailty compared to other plague creatures appears to be a rather glaring weakness, the melters are able to spread the plague quicker than any other creature. Though it may cost them their lives, melters contain a mechanism that causes them to explode upon death, leaving little uninfected in their wake. -PestilentSlime: The virus hunts for any openings within one’s body to reprogramme all to serve the enigmatic engineer. The gelatinous body of slimes are particularly easy to infest, yet with no neural system, slimes are unable to receive direct orders, processing them as vague suggestions at best. +PestilentSlime: The virus hunts for any openings within one's body to reprogramme all to serve the enigmatic engineer. The gelatinous body of slimes are particularly easy to infest, yet with no neural system, slimes are unable to receive direct orders, processing them as vague suggestions at best. PlaguebringerMiniboss: Nothing can escape the Plague; everything is either assimilated or culled. Such is the case of queen bees. While strong enough to stave off plagued creatures, they are often forced to abandon their hives due to their subjects becoming infected. This leaves their larvae to be overtaken by nanites, and soon after, a plaguebringer is born. -PlagueCharger: Spawn of the plaguebringers, these were born already taken by Draedon’s nanomachines. Nanites ensure they reach adulthood in a matter of hours by supercharging their aging process, even if this means their lifespan can be counted in days. Yet, this is exactly what makes them the perfect dispensable soldiers. -Plagueshell: A turtle’s shell and nervous system are intertwined, making giant tortoises ideal targets for the Plague. Whatever pain is caused by the process of drilling into their shells is rapidly anesthetized, putting the tortoises under control without a single protest. +PlagueCharger: Spawn of the plaguebringers, these were born already taken by Draedon's nanomachines. Nanites ensure they reach adulthood in a matter of hours by supercharging their aging process, even if this means their lifespan can be counted in days. Yet, this is exactly what makes them the perfect dispensable soldiers. +Plagueshell: A turtle's shell and nervous system are intertwined, making giant tortoises ideal targets for the Plague. Whatever pain is caused by the process of drilling into their shells is rapidly anesthetized, putting the tortoises under control without a single protest. Viruling: Unlike derplings, who use their proboscis to drain the blood of other creatures, virulings use theirs to inject the plague directly into their victims. Aside from the plaguebringers themselves, no creature is nearly as efficient at contaminating the local wildlife. //Sulphur Sea Enemies AnthozoanCrab: Though disguised as simple rocks, they are capable of hurling entire boulders at creatures with ease, and will retreat swiftly if approached. Elsewhere, a creature such as this would thrive due to its might; yet in such a hostile environment as this, this much is required merely to survive. @@ -114,81 +113,81 @@ AquaticUrchin: Closely related to sea urchins, aquatic urchins have been forced BelchingCoral: Although all coral is alive to some extent, this species possesses above average intelligence. They are capable of fending off creatures attempting to consume them by releasing pressurized bursts of sulfuric gas when approached. Occasionally, this process makes a noise resembling music. Gnasher: Though gnashers are relatively slow, these mutated snapping turtles boast an unnaturally strong shell. Attempting to kill and eat one would injure most creatures greatly due to its terrifying biting power and spiked shell easily capable of impaling flesh. Sulflounder: A relative to certain hadopelagic creatures living in the depths, the Sulflounders are a branch in their evolution with a fragile exterior. This allowed them not to sink to the bottom of the Abyss, though their flesh is barely enough to withstand the acidic water. -Toxicatfish: Though these fish once threatened none other than their prey, the radiation from nuclear waste generated from Draedon’s old experiments has rotted both their bodies and minds. Attacking anything that comes near, this once flourishing species is now on the verge of extinction. -Trasher: Despite being equipped with a mouth large enough to swallow a child whole, these crocodiles simply act as scavengers, devouring scraps and bones left over from predators’ meals. Needing to conserve energy due to eating relatively little, they rarely move at their full speed unless they feel threatened. +Toxicatfish: Though these fish once threatened none other than their prey, the radiation from nuclear waste generated from Draedon's old experiments has rotted both their bodies and minds. Attacking anything that comes near, this once flourishing species is now on the verge of extinction. +Trasher: Despite being equipped with a mouth large enough to swallow a child whole, these crocodiles simply act as scavengers, devouring scraps and bones left over from predators' meals. Needing to conserve energy due to eating relatively little, they rarely move at their full speed unless they feel threatened. //Sunken Sea Enemies BabyGhostBell: Ghost Bells were bred in large numbers during the Ilmeran war, due to the Ilmerian army needing a staggering amount of electricity to keep Yharim and his forces at bay. Alas, their efforts were for naught, and the kingdom collapsed after the Great Incineration. -BlindedAngler: Lacking most normal senses, these predators use a form of biological sonar to ‘see’ their surroundings. The glowing crystals on their backs draw in prey that use the sea’s shimmering prisms as their guiding light, like a moth to the flame. +BlindedAngler: Lacking most normal senses, these predators use a form of biological sonar to 'see' their surroundings. The glowing crystals on their backs draw in prey that use the sea's shimmering prisms as their guiding light, like a moth to the flame. Clam: Clams once lived in the upper portion of the Ilmeran Sea before the Incineration, being forced to relocate after the battle. Though it was thanks in part to their adaptability and hardiness that their species survived, luck was also certainly on their side. EutrophicRay: Eutrophic Rays have formed a commensalistic relationship with Ghost Bells. The rays can store energy given by the Ghost Bells for electrical muscle stimulation, allowing for great bursts of speed. -GhostBell: These high-voltage jellyfish can incapacitate most with a single touch, and were a major factor in the Ilmerian army’s strength. The sea kingdom used the electricity produced by Ghost Bells to drive back Yharim’s forces, electrifying the waters so that none could cross their borders. +GhostBell: These high-voltage jellyfish can incapacitate most with a single touch, and were a major factor in the Ilmerian army's strength. The sea kingdom used the electricity produced by Ghost Bells to drive back Yharim's forces, electrifying the waters so that none could cross their borders. GiantClam: Clams slowly crystalise ambient magic around themselves into pearls, and as they grow larger, so too do their pearls. Upon growing to their full size, they are classified as Giant Clams, and gain the ability to use the magic stored in their pearls to some degree. PrismBack: Due to the beautiful prisms and calm behavior, these animals have been taken in as pets by many over the course of centuries, even outside of Ilmeris. Though far too slow and bulky to hunt normally, the sea prisms on their back act as a lure for small fish. -SeaFloaty: Flatworms can be found in many seas and oceans across the world, and are exceptional at fitting through cracks or crevices due to their thin bodies. These particular flatworms only ever inhabited the lower sea, and were left entirely unthreatened by the carnage that annihilated most species’ homes. +SeaFloaty: Flatworms can be found in many seas and oceans across the world, and are exceptional at fitting through cracks or crevices due to their thin bodies. These particular flatworms only ever inhabited the lower sea, and were left entirely unthreatened by the carnage that annihilated most species' homes. SeaMinnow: Schools of sea minnows were one of the most beautiful things one could witness during the days when Ilmeris was unshattered. Those permitted into the kingdom would gather to see these fish swimming in the open sea… yet, this is but a distant past now, even for the minnows themselves. SeaSerpent: Despite being one of the few carnivorous creatures to have ever existed in the Ilmeran Sea, even these serpents are unusually passive towards those they do not consider prey by the standards of elsewhere. The sea has only ever known one truly aggressive predator, and it abandoned a life of calming solitude years ago. //Town NPCs -AndroombaFriendly: Reverse-engineered Androombas that have been retrofitted to spread the Steampunker’s solutions rather than clean dust and debris off of floors. They can be used to purify the world– or ruin it further, if one so desires. -DILF: One of the world’s foremost experts on magical theory, he is renowned for his skill with the arcane arts. In his days when he traveled with Yharim’s entourage, he acted as the Godseeker’s advisor, due to both his status and his distaste for actively participating in battle. +AndroombaFriendly: Reverse-engineered Androombas that have been retrofitted to spread the Steampunker's solutions rather than clean dust and debris off of floors. They can be used to purify the world– or ruin it further, if one so desires. +DILF: One of the world's foremost experts on magical theory, he is renowned for his skill with the arcane arts. In his days when he traveled with Yharim's entourage, he acted as the Godseeker's advisor, due to both his status and his distaste for actively participating in battle. FAP: A princess from an unknown land. She drinks constantly in a vain attempt to escape the memories of her past, but is practically immune to alcohol. She makes a business of selling her mixtures, alcoholic and alchemic alike. SEAHOE: The seventeenth ruler of the constitutional monarchy of Ilmeris since the tribes of the Ilmeran Sea unified, under the Electric Goddess, Otonilou, and the elusive God of the Seas. Alas, one cannot be a ruler without subjects, and while he remains respected by those who opposed Godseeker Yharim, his kingdom is no more. -THIEF: The bandit may have a bad habit of looting battlefields and taking what isn’t theirs, but their actions are mostly motivated by their hatred of the obscenely rich who haven’t truly earned the wealth they possess. Their methods are somewhat shady, but can always be relied upon to get a job done. -WITCH: Recruited to Yharim’s forces late into the war, her magic overflows with such power that she is largely incapable of casting normal spells. Yet despite her great power, Calamitas prefers not to use it, as it takes a heavy toll on her psyche. +THIEF: The bandit may have a bad habit of looting battlefields and taking what isn't theirs, but their actions are mostly motivated by their hatred of the obscenely rich who haven't truly earned the wealth they possess. Their methods are somewhat shady, but can always be relied upon to get a job done. +WITCH: Recruited to Yharim's forces late into the war, her magic overflows with such power that she is largely incapable of casting normal spells. Yet despite her great power, Calamitas prefers not to use it, as it takes a heavy toll on her psyche. //Boss Minions Brimling: Extensions of the Brimstone Elemental herself, and part of her very being. Both she and her Brimlings are of a single mind, so she naturally cares for them just as she cares for herself. When heavily wounded, they withdraw into a cocoon to protect themselves from further harm. -SoulSeeker: The Clone’s attempt at wielding the souls of the damned as weapons, these retain slightly more autonomy than their Azafurian brethren. And yet given the striking resemblance the bear to the Clone’s shell, it’s arguable that they might be further from Calamitas’ current soul seekers than those found in Azafure’s ruins. +SoulSeeker: The Clone's attempt at wielding the souls of the damned as weapons, these retain slightly more autonomy than their Azafurian brethren. And yet given the striking resemblance the bear to the Clone's shell, it's arguable that they might be further from Calamitas' current soul seekers than those found in Azafure's ruins. DarkEnergy: - -DesertNuisance: Though these serpents are of the Desert Scourge’s species, they are notably younger and less developed. Choosing to hunt in a pack with the large scourge due to this weakness, many have seen them tear apart prey not unlike the piranhas that once populated the former sea. +DesertNuisance: Though these serpents are of the Desert Scourge's species, they are notably younger and less developed. Choosing to hunt in a pack with the large scourge due to this weakness, many have seen them tear apart prey not unlike the piranhas that once populated the former sea. CosmicGuardian: Though of the same species as the nameless serpent, their minds and functions are far more basic. They possess very little will of their own and blindly follow the orders of their gluttonous master. HiveTumor: This tumor acts as the brain of the putrid wasteland, being all that is left of the minds of the slain gods that lay there. The creatures of the Corruption exist to protect it, and those who attempt to harm it rarely live to tell the tale. AquaticAberration: A spawn of the immense Leviathan, their lifespan can be measured in hours. All they know is how to hunt for their masters. Even non-aquatic life is well within their reach, due to their uncanny ability to fly through air just as easily as swimming through water. -LeviathanStart: A lure created by the Water Elemental, Anahita. It sings so sweetly, its voice full of promise and warmth, but beware: follow the siren’s call at your own peril. +LeviathanStart: A lure created by the Water Elemental, Anahita. It sings so sweetly, its voice full of promise and warmth, but beware: follow the siren's call at your own peril. PerforatorCyst: This twitching and convulsing pile of gore acts as the heart of the Perforator Hive, harvesting what small amount of diluted Ichor flowing through the Crimson is left and feeding it to the Hive. Little else is known about it, for those who dare to disturb it have become indistinguishable from the landscape. CosmicLantern: These lanterns possess a magical, distorted flame that radiates no heat whatsoever. If one looks closely into their fire, they may see another world entirely. CorruptSlimeSpawn: Slimes are extraordinarily hardy creatures: if a large slime has chunks of living gelatin severed from it, the chunks tend to continue on, albeit as their own beings. Even as gel, a slime is still technically alive– it simply exists in a state where it cannot function in any meaningful way. -CrimsonSlimeSpawn: Slimes are extraordinarily hardy creatures: if a large slime has chunks of living gelatin severed from it, the chunks tend to continue on, albeit as their own beings.They even retain the memories of the original slime, and so continue to work in the interest of their “parent”. +CrimsonSlimeSpawn: Slimes are extraordinarily hardy creatures: if a large slime has chunks of living gelatin severed from it, the chunks tend to continue on, albeit as their own beings.They even retain the memories of the original slime, and so continue to work in the interest of their "parent". CrimsonSlimeSpawn2: Though many slimes may get objects stuck partway inside of it and learn to use them as weapons, these slimes are a unique case. The spikes of these slimes are a natural part of them, heavily sharpened so that they may impale those who dare defy their god. -Sepulcher: An amalgamation of souls and flesh given new form and purpose via necromancy. This twisted perversion of life is inspired by the auric dragons’ method of revival, though it is plain to see that any grace the dragons may have had is not present here. The school of magic used to create Sepulcher was forbidden in the Deific Era, yet many still practiced it in secrecy. -SoulSeekerSupreme: Created through a marriage of brimstone magic and necromancy, these foul beings serve their master’s whims unflinchingly. What they lack in sheer power they make up for in both sheer numbers and suprising amount of coordination. +Sepulcher: An amalgamation of souls and flesh given new form and purpose via necromancy. This twisted perversion of life is inspired by the auric dragons' method of revival, though it is plain to see that any grace the dragons may have had is not present here. The school of magic used to create Sepulcher was forbidden in the Deific Era, yet many still practiced it in secrecy. +SoulSeekerSupreme: Created through a marriage of brimstone magic and necromancy, these foul beings serve their master's whims unflinchingly. What they lack in sheer power they make up for in both sheer numbers and suprising amount of coordination. //Bosses AquaticScourge: A peaceful yet intimidating being that roamed the Sulphurous Sea, its mere existence was enough to scare away most creatures from the shore. Without its presence to act as a deterrent, fearsome predators now feel safe to prowl during the acidic storms. -AstrumAureus: Once meant for returning equipment from and surveying sites of prior battles, this creation of Draedon’s was overtaken by the Astral Infection. Unfortunately, its defeat has released what power it possessed, granting it instead to the star’s other warriors. +AstrumAureus: Once meant for returning equipment from and surveying sites of prior battles, this creation of Draedon's was overtaken by the Astral Infection. Unfortunately, its defeat has released what power it possessed, granting it instead to the star's other warriors. AstrumDeus: When a star begins to die, under normal circumstances, its power simply fades as it falls to the nearest celestial body. However, some dying stars bloat and fester before falling. Astrum Deus exists to consume these stars before the Astral Infection manifests in them, and it has been revered for its sacred duty since time immemorial. -BrimstoneElemental: Roused from her deep slumber in relatively recent years, her awakening set into motion the downfall of Azafure. Most blame her unexpected revival on the city’s overzealous mining of Brimstone, while a few blame the city’s pollution, and some fewer cite dubious prophecies. But behind closed doors, there are whisperings that she was revived deliberately as part of a plot by opposing forces. +BrimstoneElemental: Roused from her deep slumber in relatively recent years, her awakening set into motion the downfall of Azafure. Most blame her unexpected revival on the city's overzealous mining of Brimstone, while a few blame the city's pollution, and some fewer cite dubious prophecies. But behind closed doors, there are whisperings that she was revived deliberately as part of a plot by opposing forces. Bumblefuck: Long ago, these siblings of the auric dragons hid themselves away in the depths of the jungle. They hunt prey using the immense static electricity generated by the flapping of their wings against their feathery bodies, manifesting as deadly bolts of red lightning. -Calamitas: This machine which stalks the night carries the failed clone of the Supreme Witch. Though lacking her hexes and black magic, even a fragment of Calamitas’ brimstone power was enough to drive the clone to insanity. Nothing human remains. -Cataclysm: A pitiable creation of the clone, made in an attempt to imitate one of the Supreme Witch’s brothers. Yet this and the clone’s other creations have no will of their own, amounting to little more than puppets she controls. -Catastrophe: A pitiable creation of the clone, made in an attempt to imitate one of the Supreme Witch’s brothers. Not many would recognize them as such despite her efforts, though a few key characteristics have managed to survive in these abhorrent amalgamations. +Calamitas: This machine which stalks the night carries the failed clone of the Supreme Witch. Though lacking her hexes and black magic, even a fragment of Calamitas' brimstone power was enough to drive the clone to insanity. Nothing human remains. +Cataclysm: A pitiable creation of the clone, made in an attempt to imitate one of the Supreme Witch's brothers. Yet this and the clone's other creations have no will of their own, amounting to little more than puppets she controls. +Catastrophe: A pitiable creation of the clone, made in an attempt to imitate one of the Supreme Witch's brothers. Not many would recognize them as such despite her efforts, though a few key characteristics have managed to survive in these abhorrent amalgamations. CeaselessVoid: - Crabulon: A crustacean that once made its home in the heart of the Ilmeran Sea, managing to escape during the Great Incineration. Crabulon fled underground, enjoying the familiar blue glow given off by glowing mushrooms. Though it succumbed to the spores, it died in peace, reminded of its home. Cryogen: When Yharim realized that the Archmage had defected, Calamitas was ordered to hunt down and kill her former mentor. After a tearful confrontation, she decided to instead seal him away, and fake his death. The spellwork present in this living seal is inspired, and a tragic homage to every lesson Permafrost taught his student. -DesertScourge: A sea serpent that once swam through the waters of the Ilmeran Sea, it curiously chose to stay in its home rather than find a new one deep below. Quickly taking to a diet of antlion and cactus, it was able to take the place of possibly the desert’s apex predator after its only competition went into hiding. +DesertScourge: A sea serpent that once swam through the waters of the Ilmeran Sea, it curiously chose to stay in its home rather than find a new one deep below. Quickly taking to a diet of antlion and cactus, it was able to take the place of possibly the desert's apex predator after its only competition went into hiding. DevourerofGods: An entity of many titles and reputations, it is easy to conflate the truth and myths of its many legendary deeds. Though Yharim once believed that the essence he devours is utterly and completely erased from existence, it is a fundamental rule of creation that energy cannot be destroyed– it can only be transferred from one form to another. -Draedon: One of the many recon bodies made by, and created in the image of, the enigmatic engineer, Draedon. The scientist has become increasingly reclusive since leaving the Godseeker’s side, devoting every waking moment to his never-ending research. -Apollo: With plasma cannons that rival the heat of Calamitas’ own flames and trained in advanced simulations against the world’s strongest, few can match this machine of war. Though the chassis consumes incredible amounts of energy, its power demands are easily met by its Exo Prism power core. To gaze upon the oracle is to know its unwavering stare. +Draedon: One of the many recon bodies made by, and created in the image of, the enigmatic engineer, Draedon. The scientist has become increasingly reclusive since leaving the Godseeker's side, devoting every waking moment to his never-ending research. +Apollo: With plasma cannons that rival the heat of Calamitas' own flames and trained in advanced simulations against the world's strongest, few can match this machine of war. Though the chassis consumes incredible amounts of energy, its power demands are easily met by its Exo Prism power core. To gaze upon the oracle is to know its unwavering stare. Ares: The first of the superweapons Draedon created, Ares is capable of both widespread destruction and concentrated attacks with its deadly cannons. His goal in making the Exo Mechs was to forge war machines that could rival even the vaunted strength of Yharim when last they saw one another. To gaze upon this diabolical monstrosity is to know fear. -Artemis: The final superweapon to be created, Artemis only needed a single revision to its original blueprints. Draedon’s perfectionist nature allowed him to raise his skill in engineering to new heights, culminating with a machine possessed of unbelievable nimbleness and precision. To gaze upon the archer is to gaze a second too late. -Thanatos: A mechanical serpent built using a revised variant of the Devourer’s armor plating, it was intended to be utterly invincible. Even its weakness of needing to vent due to overheating was turned to a strength, for no creature of flesh or metal can survive such temperatures. To gaze upon this serpentine terror is to know true power. +Artemis: The final superweapon to be created, Artemis only needed a single revision to its original blueprints. Draedon's perfectionist nature allowed him to raise his skill in engineering to new heights, culminating with a machine possessed of unbelievable nimbleness and precision. To gaze upon the archer is to gaze a second too late. +Thanatos: A mechanical serpent built using a revised variant of the Devourer's armor plating, it was intended to be utterly invincible. Even its weakness of needing to vent due to overheating was turned to a strength, for no creature of flesh or metal can survive such temperatures. To gaze upon this serpentine terror is to know true power. HiveMind: Although Yharim's campaign would one day span the entire world, it all started in these lands with the massacre of ruthless dictator deities. As soon as their leaders fell at the hands of the Godseeker, their armies toppled like dominos. A hive mind cannot function without its brain, after all. -Anahita: Once a resident of the Abyss, she left it long ago due to Silva’s influence spreading through her former home. She wishes to see all overtaken by the ocean, so that her domain may encompass the world. Such is the nature of all elementals. +Anahita: Once a resident of the Abyss, she left it long ago due to Silva's influence spreading through her former home. She wishes to see all overtaken by the ocean, so that her domain may encompass the world. Such is the nature of all elementals. Leviathan: A gargantuan marine reptile that lurks the ocean depths along with the Water Elemental, Anahita. It is unknown if she is the last of her kind, or was simply manifested into existence like her master. -GreatSandShark: These intelligent predators once swam the shores of the upper Ilmeran Sea, with many being trained to hold back Yharim’s forces. Yet when the day came, the sand sharks were barely even a distraction for the Supreme Witch, with this particular specimen surviving only by making a hasty retreat. -OldDuke: One of the original draconic offshoots who were born in the Draconic Era. Dragons who were born after all the auric souls had been gifted to their kind were forced to make do without, forever outside of the cycle of rebirth. Yet in a twist of fate, the auric dragons’ age would end, and those rejected would be the survivors in this new world. +GreatSandShark: These intelligent predators once swam the shores of the upper Ilmeran Sea, with many being trained to hold back Yharim's forces. Yet when the day came, the sand sharks were barely even a distraction for the Supreme Witch, with this particular specimen surviving only by making a hasty retreat. +OldDuke: One of the original draconic offshoots who were born in the Draconic Era. Dragons who were born after all the auric souls had been gifted to their kind were forced to make do without, forever outside of the cycle of rebirth. Yet in a twist of fate, the auric dragons' age would end, and those rejected would be the survivors in this new world. Perforator: A living embodiment of some of the worst this world has to offer, these parasites made full use of their hive. Using it to seek ever more to gorge themselves upon, they sought to grow even larger, that they may one day perhaps regain what they lost. PerforatorHive: To tear and consume, taking for only themselves until there is nothing left– this was the primal instinct left behind by the gods which now form the Crimson. Their selfish desires coalesced into this hive, infested by ravenous worms whose sole desire is to devour. -PlaguebringerGoliath: The Plague’s creation initially began after the unsatisfactory results the soul-power machines provided, with Draedon seeking absolute control. After testing many different variants for decades, both the Plague and its goliath were born, with its spread allowing for an amount of control over life once thought impossible. +PlaguebringerGoliath: The Plague's creation initially began after the unsatisfactory results the soul-power machines provided, with Draedon seeking absolute control. After testing many different variants for decades, both the Plague and its goliath were born, with its spread allowing for an amount of control over life once thought impossible. Polterghast: The feral amalgamation that drove out the cult that once dwelled here, and inadvertently broke an alliance thought to be eternal. Many have delved into the dungeon in search of riches and knowledge long since lost, yet most simply join the spirits that have claimed this place as their own. PrimordialWyrm: The first Wyrm, blessed by the Goddess of Life, held staggering power that surpassed nearly all of its auric brethren. It held a deep hatred for any sign of usurped light, and would have attempted to strike down even the wielder of Primordial Light had they returned to reclaim their artifact. And yet, despite its immense power, it never would have stood a chance. -ProfanedGuardianCommander: In a time lost to memory, there were four soldiers who used their wits and teamwork to slay a dragon, that one might gorge themself upon its auric soul. “I am the wisest,” declared their commander, “I should be the one.” There was silence, until Providence spoke: “You need temper your wisdom with action, that we might impose our will upon this world.” -ProfanedGuardianDefender: In a time lost to memory, there were four champions who used their loyalty to one another to slay a dragon, that one might gorge themself upon its auric soul. “I am the strongest,” declared their shieldmaiden, “I should be the one.” There was silence, until Providence spoke: “You lack strength of conviction, that you might try to pluck the stars from the sky.” -ProfanedGuardianHealer: In a time lost to memory, there were four champions who used their fathomless determination to slay a dragon, that one might gorge themself upon its auric soul. “I am the most courageous,” declared their cleric, “I should be the one.” There was silence, until Providence spoke: “Your courage blinds you to the truth, that your overconfidence would doom you.” -Providence: In a time lost to memory, there were four visionaries. With righteous fury, they slew a dragon, and their leader gorged Herself upon its auric soul of Flame. “The world is without guidance, and its people are filled with darkness.” She said. There was silence, until Providence spoke once more. “Let us go forth, and light the world anew.” And it was so. +ProfanedGuardianCommander: In a time lost to memory, there were four soldiers who used their wits and teamwork to slay a dragon, that one might gorge themself upon its auric soul. "I am the wisest," declared their commander, "I should be the one." There was silence, until Providence spoke: "You need temper your wisdom with action, that we might impose our will upon this world." +ProfanedGuardianDefender: In a time lost to memory, there were four champions who used their loyalty to one another to slay a dragon, that one might gorge themself upon its auric soul. "I am the strongest," declared their shieldmaiden, "I should be the one." There was silence, until Providence spoke: "You lack strength of conviction, that you might try to pluck the stars from the sky." +ProfanedGuardianHealer: In a time lost to memory, there were four champions who used their fathomless determination to slay a dragon, that one might gorge themself upon its auric soul. "I am the most courageous," declared their cleric, "I should be the one." There was silence, until Providence spoke: "Your courage blinds you to the truth, that your overconfidence would doom you." +Providence: In a time lost to memory, there were four visionaries. With righteous fury, they slew a dragon, and their leader gorged Herself upon its auric soul of Flame. "The world is without guidance, and its people are filled with darkness." She said. There was silence, until Providence spoke once more. "Let us go forth, and light the world anew." And it was so. Ravager: The mangled reincarnation of the God of Sacrifices, given life once more. Necromancers sworn to his faith returned his broken body to his temple, offering the only sacrifices they could to reverse his Death– their own lives. Yet, necromancy is an imperfect art, and the god has very little of his mind left, simply destroying all it comes across. -Signus: ‘For any desire, there is a price’. A deal bound in Onyx and sealed in blood, and one can have any wish granted– a gateway, a promise, a betrayal. Curiously, there is no recorded history of Signus before the age of gods, and very little recorded to this day. Perhaps, for the right price, one might find out the truth of Signus for oneself. +Signus: "'For any desire, there is a price'. A deal bound in Onyx and sealed in blood, and one can have any wish granted– a gateway, a promise, a betrayal. Curiously, there is no recorded history of Signus before the age of gods, and very little recorded to this day. Perhaps, for the right price, one might find out the truth of Signus for oneself." SlimeGodPaladin: The Slime God avoids direct combat due to its weakness, instead choosing to mold guardians to protect it. These guardians were created from countless blight slimes, their filth acting as a counterweight to the purity of their god. SlimeGodCore: Despite being a Gluttonous slime, the Slime God forbids itself from growing out of control to maintain the balance of the world. It was still pursued during the Crusade, but it managed to survive through countless strategic retreats. The duty it upholds and the methods it employs are the reason the Onyx Kinsmen worship such a puny deity. StormWeaver: An invasive pest from another dimension crowned by many as king of the skies, soaring across the upper atmosphere at near unmatched speed. Unlike the other beings from the Distortion, the Storm Weaver lacks higher purpose, feasting upon the remnants of the civilization that once dwelled in the skies. -SupremeCalamitas: After inheriting nigh limitless magical power as a mere teenager, she was recruited into Yharim’s army, where she served for nearly a decade. She reveled in the violence of it all, the endless dance of madness and death, allowing the Godseeker to wield her as a weapon in his endless war against the gods. But now that the fire inside her has died, all that remains are the smoldering embers of regret. +SupremeCalamitas: After inheriting nigh limitless magical power as a mere teenager, she was recruited into Yharim's army, where she served for nearly a decade. She reveled in the violence of it all, the endless dance of madness and death, allowing the Godseeker to wield her as a weapon in his endless war against the gods. But now that the fire inside her has died, all that remains are the smoldering embers of regret. SupremeCataclysm: The eldest of the three siblings, this brother was a brawler of great renown in Azafure, with few in the city being capable of matching his raw strength. He was protective of his sister, vowing to always be there for her in her times of need. The brother continues to fulfill this promise, even in death. SupremeCatastrophe: The middle child of the three siblings was a skilled swordsman in life, taking up mercenary work to put food on the table. Despite his rather bloody career choice, he did his best to be kind to his sister and keep her out of any danger his occupation could have put his remaining family in. He continues to defend her, even in death. Yharon: Each dragon once wielded nigh limitless power over their domain, a fundamental power drawn directly from the world's fragmented soul. The dragons were masters of all; life, death, even the great Primordial Light that banishes the eternal night beyond. And yet, one of these majestic beings reached a height of power possibly second only to their king. He who made his kind eternal through his powers of Rebirth... and yet, even eternity did not last. diff --git a/Localization/en-US/Mods.CalamityMod.Buffs.hjson b/Localization/en-US/Mods.CalamityMod.Buffs.hjson index e0bba0d241..33803350fd 100644 --- a/Localization/en-US/Mods.CalamityMod.Buffs.hjson +++ b/Localization/en-US/Mods.CalamityMod.Buffs.hjson @@ -58,6 +58,11 @@ MoscowMuleBuff: { Description: Damage, critical strike chance, and knockback increased, life regen reduced } +OldFashionedBuff: { + DisplayName: Old Fashioned + Description: Accessory and set bonus damage multiplied, damage reduced +} + RedWineBuff: { DisplayName: Red Wine Description: Life regen reduced @@ -138,6 +143,11 @@ BrainRot: { Description: Your neurons are popping like corn kernels } +ElementalMix: { + DisplayName: Elemental Mix + Description: A beautiful elemental symphony is flaying you alive +} + CrushDepth: { DisplayName: Crush Depth Description: Crushed by aquatic pressure @@ -662,15 +672,6 @@ BloodflareBloodFrenzy: { Description: Contact damage is reduced and melee stats are greatly increased } -BloodyBoost: { - DisplayName: Bloody Boost - Description: - ''' - Increased offensive and defensive stats - Healing potions grant more health - ''' -} - BossEffects: { DisplayName: Boss Effects Description: @@ -687,6 +688,11 @@ BrimflameFrenzyBuff: { Description: Dark magic empowers your attacks at the cost of your life } +BrutalCarnage: { + DisplayName: Brutal Carnage + Description: 25% increased melee damage and 10% increased melee crit chance +} + ChiBuff: { DisplayName: Chi Description: You are more resilient @@ -828,11 +834,6 @@ ReaverRage: { Description: You are angry } -ShellBoost: { - DisplayName: Shell Speed Boost - Description: Speed is boosted -} - SilvaRevival: { DisplayName: Silva Immunity Description: You are unkillable and immune to most debuffs @@ -868,11 +869,6 @@ TarraLifeRegen: { Description: Rapid healing } -TyrantsFury: { - DisplayName: Tyrant's Fury - Description: 30% increased melee damage and 10% increased melee crit chance -} - AndromedaCripple: { DisplayName: Andromeda Cripple Description: You're slow diff --git a/Localization/en-US/Mods.CalamityMod.Configs.hjson b/Localization/en-US/Mods.CalamityMod.Configs.hjson index 21199ff589..7974e0ae05 100644 --- a/Localization/en-US/Mods.CalamityMod.Configs.hjson +++ b/Localization/en-US/Mods.CalamityMod.Configs.hjson @@ -260,6 +260,7 @@ CalamityConfig: { Sets the maximum of particle effects that can exist at once. Particles are separate from dust and gores. Turn down to improve performance. + [c/F05A5A:Turning this below 300 may cause some things to not display correctly.] ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index 7fa3e04516..a3032788f3 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -66,6 +66,17 @@ AbyssalMirror: { ''' } +AscendantInsignia: { + DisplayName: Ascendant Insignia + Tooltip: + ''' + Increases wing flight time by 30% + Increases movement and jump speed by 10% and acceleration by 1.1x + Pressing [KEY] will give you the power of ascension, providing infinite flight time for 4 seconds + Ascension has a 40 second cooldown + ''' +} + AeroStone: { DisplayName: Aero Stone Tooltip: @@ -229,7 +240,6 @@ AsgardianAegis: { Immune to most debuffs +40 max life and +0.5 HP/s life regen Grants a cosmic inferno dash which can slam through enemies without taking damage - Can be used to ram enemies +20 defense while submerged in liquid ''' } @@ -274,9 +284,9 @@ BloodflareCore: { DisplayName: Bloodflare Core Tooltip: ''' - You lose up to half your defense after taking damage - Lost defense regenerates over time - You gain 1 health for every 1 defense gained as it regenerates + Taking defense damage heals you over time + You gain 1 health for every 1 defense damage recovered + Taking damage always deals at least half of your total defense in defense damage ''' } @@ -284,10 +294,8 @@ BloodPact: { DisplayName: Blood Pact Tooltip: ''' - Doubles your max HP - Causes you to take critical damage 25% of the time - After a critical hit, you gain various buffs for ten seconds - Any healing potions consumed during this time period heal 50% more health + Increases max HP by 25% + Healing Potions are 25% more effective ''' } @@ -346,6 +354,19 @@ Calamity: { ''' } +ChaliceOfTheBloodGod: { + DisplayName: Chalice of the Blood God + Tooltip: + ''' + Increases max HP by 25% + Taking more than 5 damage converts the hit into a damage over time bleed debuff + This bleeding does not interfere with life regeneration + Drinking a Healing Potion removes half of the remaining bleed damage + Unequipping this accessory while bleeding inflicts the remaining damage instantly + 'All that for a drop of blood...' + ''' +} + ChaosStone: { DisplayName: Chaos Stone Tooltip: @@ -366,17 +387,6 @@ CoinofDeceit: { ''' } -CoreOfTheBloodGod: { - DisplayName: Core of the Blood God - Tooltip: - ''' - Boosts your max HP by 15% - Healing Potions are 25% more effective - Halves enemy contact damage - When you take contact damage this effect has a 20 second cooldown - ''' -} - CorrosiveSpine: { DisplayName: Corrosive Spine Tooltip: @@ -537,7 +547,7 @@ DimensionalSoulArtifact: { Tooltip: ''' Power - Boosts all damage by 25%, but at the cost of increasing damage taken by 15% + Multiplies all damage by 1.2x, but at the cost of increasing damage taken by 15% ''' } @@ -627,8 +637,9 @@ ElementalGauntlet: { DisplayName: Elemental Gauntlet Tooltip: ''' - Melee attacks and projectiles inflict Hellfire - 15% increased melee speed, damage, and 5% increased melee critical strike chance + Melee attacks and projectiles inflict Elemental Mix + 15% increased melee damage and 5% increased melee critical strike chance + 15% increased melee speed, does not stack with downgrades 20% increased true melee damage Increased melee knockback Enables auto swing for melee weapons @@ -653,7 +664,6 @@ ElysianAegis: { Grants immunity to knockback and the Burning, On Fire!, and Holy Flames debuffs +30 max life Grants an enhanced holy flame dash which can slam through enemies without taking damage - Can be used to ram enemies Blessed by the Profaned Flame ''' } @@ -826,7 +836,7 @@ GloveOfRecklessness: { DisplayName: Glove of Recklessness Tooltip: ''' - Increases rogue attack speed by 15%, but decreases damage by 10% and crit by 10% + Increases rogue attack speed by 15%, but decreases damage by 10% and crit by 5% 15% increased stealth regeneration Adds inaccuracy to rogue weapons ''' @@ -990,8 +1000,8 @@ LeviathanAmbergris: { DisplayName: Leviathan Ambergris Tooltip: ''' - 15% increased dash velocity - You gain 5% damage reduction while dashing + 20% increased dash velocity + Delay after dashing is reduced by 33% Your dashes are empowered by water, knocking back and damaging nearby enemies with viscous currents ''' } @@ -1160,7 +1170,11 @@ OccultSkullCrown: { OceanCrest: { DisplayName: Ocean Crest - Tooltip: Most ocean enemies become friendly and provides waterbreathing + Tooltip: + ''' + You recover air while standing still underwater + 15% increased mining speed while wet + ''' } OldDie: { @@ -1532,7 +1546,8 @@ SlagsplitterPauldron: { DisplayName: Slagsplitter Pauldron Tooltip: ''' - You gain 5% damage reduction while dashing + You gain 10% damage reduction while dashing + Enemies you dash through are afflicted with Armor Crunch Your dashes are empowered by fire, shredding enemies near you with violent explosions ''' } @@ -1856,7 +1871,7 @@ TrinketofChi: { DisplayName: Trinket of Chi Tooltip: ''' - Provides 10% damage reduction after not being hit for 15 seconds, this is removed when you are hit + Provides 4% damage reduction after not being hit for 5 seconds, this is removed when you are hit +1 HP/s life regen for you and everyone on your team ''' } @@ -1962,7 +1977,7 @@ WulfrumBattery: { DisplayName: Wulfrum Battery Tooltip: ''' - Empowers your summons with wulfrum energy, letting them emit light around them + Empowers your summons with wulfrum energy, letting them emit light around them if visibility is enabled 7% increased summon damage 50% chance to get an extra scrap when killing wulfrum robots Can also be scrapped at an extractinator @@ -1980,17 +1995,6 @@ YharimsGift: { ''' } -YharimsInsignia: { - DisplayName: Yharim's Insignia - Tooltip: - ''' - 10% increased damage when under 50% life - 15% increased melee and true melee damage - All melee attacks inflict Holy Flames - Increased melee knockback - ''' -} - // Vanity Accessories AbandonedWulfrumHelmet: { DisplayName: Abandoned Wulfrum Helmet diff --git a/Localization/en-US/Mods.CalamityMod.Items.Ammo.hjson b/Localization/en-US/Mods.CalamityMod.Items.Ammo.hjson index b7f31471a3..d33e0a3686 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Ammo.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Ammo.hjson @@ -115,7 +115,8 @@ MortarRound: { DisplayName: Mortar Round Tooltip: ''' - Large blast radius. Will destroy tiles + Specialized high explosive rounds with a large blast radius + Will destroy tiles Used by normal guns ''' } @@ -129,7 +130,7 @@ RubberMortarRound: { DisplayName: Rubber Mortar Round Tooltip: ''' - Large blast radius + Specialized high explosive rounds with a large blast radius Will destroy tiles on each bounce Used by normal guns ''' diff --git a/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson b/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson index db336b4d3b..391c40f022 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson @@ -382,7 +382,7 @@ PlaguebringerCarapace: { Tooltip: ''' Grants immunity to the Plague - 12% increased summon damage + 15% increased summon damage Friendly bees inflict the plague ''' } @@ -391,9 +391,8 @@ PlaguebringerPistons: { DisplayName: Plaguebringer Pistons Tooltip: ''' - 13% increased summon damage and 15% increased movement speed + 15% increased summon damage and 15% increased movement speed You grow flowers on the grass beneath you, chance to grow very random dye plants on grassless dirt - You spawn bees while sprinting or dashing ''' } @@ -407,7 +406,7 @@ PlaguebringerVisor: { SetBonus: ''' Grants a plague dash which can slam through enemies without taking damage - Summons a lil' plaguebringer to protect you and empower nearby minions + Summons a lil' plaguebringer which swarms your foes with little bees +3 max minions ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson b/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson index cad61ccd6c..37fa7981d0 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson @@ -59,7 +59,7 @@ DesertProwlerHat: { DisplayName: Desert Prowler Hat Tooltip: 4% increased ranged critical strike chance and 20% chance to not consume ammo SetBonus: Ranged attacks deal an extra {0} flat damage - AbilityBrief: Sandsmoke Bomb - Double tap DOWN to shroud yourself in a small cloud of sand + AbilityBrief: Sandsmoke Bomb - Double tap {0} to shroud yourself in a small cloud of sand AbilityDescription: ''' While the sand cloud is active, gain increased mobility but heavily reduced defense @@ -296,7 +296,7 @@ WulfrumHat: { Comes equipped with hair extensions ''' SetBonus: +1 max minion - AbilityBrief: Wulfrum Bastion - Double tap DOWN while dismounted to equip wulfrum power armor + AbilityBrief: Wulfrum Bastion - Double tap {0} while dismounted to equip wulfrum power armor AbilityDescription: ''' While the armor is active, you can only use the integrated fusion cannon, but your defensive stats are increased diff --git a/Localization/en-US/Mods.CalamityMod.Items.DraedonItems.hjson b/Localization/en-US/Mods.CalamityMod.Items.DraedonItems.hjson index b396a8efe1..3badbec5b8 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.DraedonItems.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.DraedonItems.hjson @@ -72,9 +72,9 @@ DraedonsLogHell: { [Environment Log] - Pollution and 'Wall of Flesh' Click to view its contents ''' - ContentPage1: The Underworld is a realm with history dating back more than a millenia when the Crags were first settled, and acts as a glance into both the modern and ancient world simultaneously. Prior to my joining of Yharim’s forces, Azafure was the center of scientific advancement in this world. Explosives, firearms, smithing techniques, and even entire schools of magic have roots in the city. It is doubtless that the city has been largely aided by the fact that forging is trivial in the Underworld, along with an abundance of food due to Silva’s essence dripping down from the Abyss above. Due to this, it has prospered even with the occasional attack from Demons. + ContentPage1: The Underworld is a realm with history dating back more than a millenia when the Crags were first settled, and acts as a glance into both the modern and ancient world simultaneously. Prior to my joining of Yharim's forces, Azafure was the center of scientific advancement in this world. Explosives, firearms, smithing techniques, and even entire schools of magic have roots in the city. It is doubtless that the city has been largely aided by the fact that forging is trivial in the Underworld, along with an abundance of food due to Silva's essence dripping down from the Abyss above. Due to this, it has prospered even with the occasional attack from Demons. ContentPage2: Azafure has not existed without consequence, of course. Any society on such a large scale leaves an ecological footprint behind. This can be seen most clearly in the sea far above the city, appropriately known as the Sulphurous Sea. Brimstone fumes became intense enough in the city that they began rising up through the Abyss via a process akin to osmosis, and eventually reached the sea. Reducing the pollution the city creates, particularly from forging, is a goal Yharim wishes for me to prioritize. I see little need in it, yet it is a field of study few in this world have delved into. I refuse to squander an opportunity for scientific breakthrough. - ContentPage3: A particular being here has been the subject of my interest: a massive wall created from biological material lies in this place created many years ago by the greatest mages Azafure has to offer. It is a living being, though only just. It lacks both pain and emotion, and brings terror to all who lay their eyes upon it. It is kept protected via high security by the city, and so few aside from the Godseeker’s closest allies have had the opportunity to observe it. For as long as Azafure continues to stand, it is unlikely to ever be truly released. Yet, I do not deny that I would be fascinated to see the effects its release would have on the world. + ContentPage3: A particular being here has been the subject of my interest: a massive wall created from biological material lies in this place created many years ago by the greatest mages Azafure has to offer. It is a living being, though only just. It lacks both pain and emotion, and brings terror to all who lay their eyes upon it. It is kept protected via high security by the city, and so few aside from the Godseeker's closest allies have had the opportunity to observe it. For as long as Azafure continues to stand, it is unlikely to ever be truly released. Yet, I do not deny that I would be fascinated to see the effects its release would have on the world. } DraedonsLogJungle: { diff --git a/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson b/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson index 1ce0cc040c..13a8b24a11 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson @@ -83,12 +83,21 @@ CragBullhead: { DragoonDrizzlefish: { DisplayName: Dragoon Drizzlefish - Tooltip: + Tooltip: "[GFB]" + TooltipNormal: ''' - Fires an inaccurate spread of fireballs + Fires an assortment of hellfire and brimstone fireballs + Sometimes fires a larger splitting fireball The brimstone sac appears to contain fuel 'Revenge is a dish best served flaming hot' ''' + TooltipGFB: + ''' + Fires an assortment of hellfire and brimstone fireballs + Sometimes fires a larger splitting fireball + Right click to feed the little boy some tasty gel + 'He is a hungry boy' + ''' } Havocfish: { diff --git a/Localization/en-US/Mods.CalamityMod.Items.Lore.hjson b/Localization/en-US/Mods.CalamityMod.Items.Lore.hjson index 875a9289ce..b08c49fe33 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Lore.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Lore.hjson @@ -281,7 +281,7 @@ LoreDragonfolly: { DisplayName: Dragonfolly Lore: ''' - Near the close of the Draconic Era, there are records of the “impure” Dragon species. + Near the close of the Draconic Era, there are records of the "impure" Dragon species. Wyverns, basilisks, Pigrons and the like are documented. Though none are sure how exactly they came to be. To this day, scholars argue over the true names and lineages of these creatures. Names aside: it is clear the first offshoots are pure enough to retain the great strength of their forebears. @@ -407,7 +407,7 @@ LoreMechs: { These unwieldy beasts of steel were the experiments of Draedon, my former colleague and prodigious engineer. His intent was to fuel a war machine with soul energy, allowing it to fight with purpose and zeal. The creations were a success, perhaps too much of one as the souls continued to express their own free will. - Dreadon was displeased with the results. However these were my soldiers with their loyalty forged anew in iron. + Draedon was displeased with the results. However these were my soldiers with their loyalty forged anew in iron. I dismissed them from duty, yet they linger here still. Scouring the land for evidence of the divine. Unfortunately for you that puts you in their crosshairs. Give them a battle worth dying in. ''' @@ -430,7 +430,7 @@ LorePerforators: { DisplayName: The Perforators and Their Hive Lore: ''' - These creatures were unique. They wielded the slain Gods' power are purely as possible, veins flowing with spilt ichor. + These creatures were unique. They wielded the slain Gods' power as purely as possible, veins flowing with spilt ichor. All that exists in the Crimson is truly the divine turned inside out; their gore now glistens with perverse treachery for all to bear witness. The mire reeks of centuries of vile manipulation and callous domination of the hapless. Judgment has long passed and only extinction is left waiting. diff --git a/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson b/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson index 774c8b860b..a0ab4391af 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson @@ -281,7 +281,7 @@ MoscowMule: { ''' Increases damage by 9%, knockback by 50% and critical strike chance by 3% Reduces life regen by 2 HP/s - [c/B00BA5:'I once heard the copper mug can be toxic and I told 'em, 'listen dummy, I'm already poisoning myself!''] + [c/B00BA5:'I once heard the copper mug can be toxic and I told 'em, 'listen, dummy, I'm already poisoning myself!''] ''' } @@ -295,6 +295,16 @@ OddMushroom: { ''' } +OldFashioned: { + DisplayName: Old Fashioned + Tooltip: + ''' + Multiplies all accessory and set bonus damage by 1.5x + Decreases all damage by 25% + [c/B00BA5:'An old favorite of mine.'] + ''' +} + RedWine: { DisplayName: Red Wine Tooltip: diff --git a/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson b/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson index b029e8151e..4e26275b5b 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson @@ -16,7 +16,7 @@ AstralChunk: { Summons Astrum Aureus when used in the Astral Infection Enrages during the day while outside the Astral Infection Not consumable - 'The Infection’s fortress has found another target.' + 'The Infection's fortress has found another target.' ''' } @@ -36,7 +36,7 @@ BloodyWormFood: { Summons the Perforator Hive when used in the Crimson Enrages outside the Underground Crimson Not consumable - 'Do not play with your food, they won’t play with theirs.' + 'Do not play with your food, they won't play with theirs.' ''' } @@ -174,7 +174,6 @@ NecroplasmicBeacon: { Tooltip: ''' Summons Polterghast when used in the Dungeon - Enrages in large spaces Not consumable 'The wails of the spirits disturbed something far more terrifying.' ''' diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson index 319b6f7d26..bfc4384341 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson @@ -106,7 +106,7 @@ AstralachneaStaff: { AstralStaff: { DisplayName: Astral Staff - Tooltip: Summons a large crystal from the sky that has a large area of effect on impact. + Tooltip: Summons a large crystal from the sky that has a large area of effect on impact } Atlantis: { @@ -368,11 +368,6 @@ GloriousEnd: { ''' } -GrandStaffoftheNebulaMage: { - DisplayName: Grand Staff of the Nebula Mage - Tooltip: "'The true power of the Nebula Mage rests in your hands...'" -} - GruesomeEminence: { DisplayName: Gruesome Eminence Tooltip: @@ -530,6 +525,11 @@ NanoPurge: { Tooltip: Fires a barrage of nano lasers } +NebulousCataclysm: { + DisplayName: Nebulous Cataclysm + Tooltip: "'The true power of the Nebula Mage rests in your hands...'" +} + NightsRay: { DisplayName: Night's Ray Tooltip: @@ -643,6 +643,15 @@ RougeSlash: { Tooltip: Fires a wave of 3 rouge air slashes } +SandstreamScepter: { + DisplayName: Sandstream Scepter + Tooltip: + ''' + Fires an explosive stream of sand that falls after hitting an enemy + The explosion only occurs when the projectile expires + ''' +} + SanguineFlare: { DisplayName: Sanguine Flare Tooltip: Fires a blast of sanguine flares that drain enemy life @@ -655,7 +664,11 @@ SeethingDischarge: { Serpentine: { DisplayName: Serpentine - Tooltip: Casts a serpent that follows the mouse cursor + Tooltip: + ''' + Casts a serpent that follows the mouse cursor + Ignores 15 points of enemy Defense + ''' } ShadecrystalTome: { @@ -719,11 +732,6 @@ StarShower: { Tooltip: Casts a spread of astral stars at the mouse cursor } -StormSpray: { - DisplayName: Storm Spray - Tooltip: Fires a spray of water that drips extra trails of water -} - SubsumingVortex: { DisplayName: Subsuming Vortex Tooltip: @@ -792,7 +800,7 @@ ThornBlossom: { DisplayName: Thorn Blossom Tooltip: ''' - Casts a beaming flower that explodes into homing petals alongisde a deadly thorn + Casts a beaming flower that explodes into homing petals alongside a deadly thorn Costs 3 HP to fire 'Every rose has its thorn' ''' diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson index 4abded74f8..86dfa23ba2 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson @@ -65,11 +65,6 @@ Aorta: { ''' } -AquaticDischarge: { - DisplayName: Aquatic Discharge - Tooltip: Enemies release electric sparks on hit -} - ArkoftheCosmos: { DisplayName: Ark of the Cosmos Tooltip: @@ -549,6 +544,7 @@ GaelsGreatsword: { Swings leave behind exploding blood trails when below 50% health Occasionally summons a barrage of lightning bolts when below 50% health Replaces Rage Mode with an enormous barrage of skulls + This attack has a 30 second cooldown 'Hand it over, that thing. Your dark soul' ''' } @@ -756,7 +752,8 @@ Murasama: { Tooltip: ''' A high-frequency blade that can cleanly slice through even the mightiest foe - Prove your worth by slaying Yharon, Dragon of Rebirth to unsheath this sword + Every third swing deals immense damage + Prove your worth by slaying The Devourer of Gods to unsheath this sword [c/F41A31:'There will be blood!'] ''' } @@ -964,14 +961,25 @@ Roxcalibur: { // The WOF tag generates a new line above when placed at the start of a line Tooltip: ''' - [WOF]Press to shoot several rock shards - Press to dive downwards and bounce off enemies + [WOF]Hold to charge up a strike + Release with the cursor above you to swing normally, releasing rock shards + Release with the cursor below you to dive downwards and bounce off enemies Diving into blocks creates a shockwave You couldn't get it out of the rock, so you just brought the rock instead ''' LockedInfo: The hellish Wall of Flesh holds the key to this weapon's power } +SaharaSlicers: { + DisplayName: Sahara Slicers + Tooltip: + ''' + A pair of dual daggers with short range + Hitting enemies with the daggers will give you two bolts for each hit, up to 10 + Pressing will allow you to toss collected bolts at enemies + ''' +} + SausageMaker: { DisplayName: Sausage Maker Tooltip: Sprays homing blood on hit @@ -1294,8 +1302,8 @@ DefiledGreatsword: { Tooltip: ''' Fires blazing, hyper, and sunlight blades - Gives the player the tyrant's fury buff on enemy hits - This buff increases melee damage by 30% and melee crit chance by 10% + Gives the player the Brutal Carnage buff on enemy hits + This buff increases melee damage by 25% and melee crit chance by 10% ''' } @@ -1314,8 +1322,8 @@ BlightedCleaver: { Tooltip: ''' Fires homing blazing blades - Gives the player the tyrant's fury buff on enemy hits - This buff increases melee damage by 30% and melee crit chance by 10% + Gives the player the Brutal Carnage buff on enemy hits + This buff increases melee damage by 25% and melee crit chance by 10% ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index 769d984596..337ee1304b 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -115,14 +115,14 @@ AuroraBlazer: { DisplayName: Aurora Blazer Tooltip: ''' - Spews astral flames that travel in a star-shaped patterns - 60% chance to save ammo + Spews a nebula stream which forms a star shaped pattern + Uses gel for ammo ''' } Barinade: { DisplayName: Barinade - Tooltip: Converts wooden arrows into electric bolt arrows that explode + Tooltip: Fires two converging high-velocity fin arrows that easily soar through the air } Barinautical: { @@ -142,7 +142,12 @@ BladedgeGreatbow: { BlightSpewer: { DisplayName: Blight Spewer - Tooltip: "" + Tooltip: + ''' + Fires clouds of plague nanomachines that stick to tiles + Nanomachines aggressively lock onto nearby enemies + 40% chance to save ammo + ''' } BlissfulBombardier: { @@ -158,9 +163,8 @@ BloodBoiler: { DisplayName: Blood Boiler Tooltip: ''' - Fires a stream of lifestealing bloodfire + Fires twin streams of life stealing bloodfire that returns to you Uses your health as ammo - 25% chance to save ammo ''' } @@ -222,7 +226,11 @@ ClaretCannon: { CleansingBlaze: { DisplayName: Cleansing Blaze - Tooltip: 90% chance to save ammo + Tooltip: + ''' + Unleashes a torrent of flames which can pass through tiles + Uses gel for ammo + ''' } ClockGatlignum: { @@ -274,7 +282,7 @@ ContinentalGreatbow: { ''' Wooden arrows are set alight with fire Fires 3 arrows at once - Fires 2 additional cursed, hellfire, or ichor arrows + Fires 2 additional hellfire or ichor arrows ''' } @@ -349,7 +357,13 @@ DarkechoGreatbow: { DeadSunsWind: { DisplayName: Dead Sun's Wind - Tooltip: 70% chance to save ammo + Tooltip: + ''' + Fires a concentrated blast of superheated cosmic plasma that explodes and can ricochet off blocks + Shots aggressively home in on enemies after being ricocheted + Consecutive hits cause larger explosions + Uses gel for ammo + ''' } Deathwind: { @@ -393,12 +407,11 @@ DragonsBreath: { DisplayName: Dragon's Breath Tooltip: ''' - Press to fire in two-shot bursts - The first shot is a spread of 6 normal bullets - The second shot is a tight spread of 6 Dragon's Breath rounds - Press to fire full auto and mix the bullets randomly, but deal 20% less damage - This weapon has no randomness to its spread pattern - 66% chance to save ammo + Fires dragon fireballs at an accelerating pace + Upon firing for long enough, you will begin using a cartridge of energy + While using a cartridge you will shoot a draconic beam of fire that doesn't consume ammo + Once a cartridge has been ejected you will return to the original fire rate + 80% chance to save ammo ''' } @@ -427,8 +440,9 @@ ElementalEruption: { DisplayName: Elemental Eruption Tooltip: ''' - Fires a spread of rainbow flames - 90% chance to save ammo + Charges up to spew rainbow flames and pairs of homing elemental flares + Uses gel for ammo + 70% chance to save ammo ''' } @@ -549,8 +563,9 @@ HalleysInferno: { DisplayName: Halley's Inferno Tooltip: ''' - Fires a flaming blue comet + Fires a burst of intensely concentrated lunar fire jets Press to zoom out + Uses gel for ammo 50% chance to save ammo 'Halley came sooner than expected' ''' @@ -563,7 +578,11 @@ HandheldTank: { HavocsBreath: { DisplayName: Havoc's Breath - Tooltip: 50% chance to save ammo + Tooltip: + ''' + Projects cone-shaped blasts of scorching brimstone fire + Uses gel for ammo + ''' } HeavenlyGale: { @@ -698,8 +717,9 @@ Meowthrower: { DisplayName: Meowthrower Tooltip: ''' - Fires blue and pink flames that emit meows on enemy hits - 85% chance to save ammo + Cooks your foes to purrfection with catty smoke + Occasionally launches homing feline entities + Uses gel for ammo ''' } @@ -722,12 +742,19 @@ MidasPrime: { MineralMortar: { DisplayName: Mineral Mortar - Tooltip: Shoots an onyx bomb that explodes into sand sharks on death + Tooltip: Shoots an onyx bomb that explodes into huge area damage } -Minigun: { - DisplayName: Minigun - Tooltip: 80% chance to save ammo +Kingsbane: { + DisplayName: Kingsbane + Tooltip: + ''' + After revving up, rapidly fire bullets + When you stop firing you will release a barrage of auric bullets + Auric bullets aggressively home in on enemies and ignore 50 points of defense + Constantly consumes ammo while in use + 90% chance to save ammo + ''' } MolecularManipulator: { @@ -807,8 +834,11 @@ OverloadedBlaster: { DisplayName: Overloaded Blaster Tooltip: ''' - Fires a large spread of bouncing slime - 33% chance to save ammo + Converts gel into a spread of energized slime pearls that overload when they come to a stop + Overloaded slime pearls deal double damage but no longer pierce + Slime pearls bounce off of walls at very high speed + Uses gel for ammo + 25% chance to save ammo ''' } @@ -816,8 +846,9 @@ P90: { DisplayName: P90 Tooltip: ''' - Unleashes a stream of bullets at an incredible rate - 50% chance to save ammo + Unleashes a stream of armor-piercing rounds at an incredible rate + Armor-piercing rounds ignore 15 defense + 75% chance to save ammo 'It's a bullet hose' ''' } @@ -850,9 +881,10 @@ Photoviscerator: { DisplayName: Photoviscerator Tooltip: ''' - Fires a stream of exo flames and light that explodes into homing sparks - Press to fire homing flares which stick to enemies and incinerate them - 90% chance to save ammo + Emits a continuous beam of exo radiation that disintegrates everything + Press to fire homing exo flares which stick to and incinerate enemies + Uses gel for ammo + 95% chance to save ammo ''' } @@ -862,7 +894,7 @@ PlagueTaintedSMG: { ''' Shoots plague bullets that spawn drones on critical hits Bullets deal more damage and knockback the closer the enemy is - Drones always crit upon hitting a plagued enemy + Drones have a much higher crit chance upon hitting a plagued enemy Press to fire a drone swarm ''' } @@ -904,8 +936,9 @@ PristineFury: { DisplayName: Pristine Fury Tooltip: ''' - Fires an intense helix of flames that explode into a column of fire - Press to fire a short ranged cloud of lingering flames + Fires an intense helix of flames that explode into a column of smoke + Press to disperse intense clouds of profaned heat + Uses gel for ammo ''' } @@ -1011,7 +1044,11 @@ SepticSkewer: { Shadethrower: { DisplayName: Shadethrower - Tooltip: 66% chance to save ammo + Tooltip: + ''' + Spits clouds of shade which afflict enemies with brain rot + Uses gel for ammo + ''' } Shellshooter: { @@ -1058,7 +1095,11 @@ SomaPrime: { SparkSpreader: { DisplayName: Spark Spreader - Tooltip: 70% chance to save ammo + Tooltip: + ''' + Ignites your foe with flaming sparks + Uses gel for ammo + ''' } SpectralstormCannon: { @@ -1075,7 +1116,7 @@ SpeedBlaster: { Tooltip: ''' Rapidly fires phosphorescent paintball shots - to eject a powerful glob which propels you while moving + Press to eject a powerful glob which propels you while moving This ability has a cooldown of {0} seconds While under cooldown, you fire more rapidly with greater accuracy ''' @@ -1169,7 +1210,12 @@ TelluricGlare: { TerraFlameburster: { DisplayName: Terra Flameburster - Tooltip: 80% chance to save ammo + Tooltip: + ''' + Charges up to emit a stream of energized flames and pairs of homing terra flares + Uses gel for ammo + 50% chance to save ammo + ''' } TheBallista: { diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson index 5db3d9cd5a..ad52545260 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson @@ -977,8 +977,8 @@ ScourgeoftheDesert: { DisplayName: Scourge of the Desert Tooltip: ''' - Gains velocity over time - Stealth strikes gain damage as they damage enemies + A javelin that will burrow through the ground and launch itself at enemies + Stealth strikes throw three javelins that will burrow multiple times ''' } @@ -1172,7 +1172,7 @@ StormfrontRazor: { DisplayName: Stormfront Razor Tooltip: ''' - Throws a knife that summons lightning on hit. + Throws a knife that summons lightning on hit Stealth strikes cause the knife to be faster and summon multiple lightning bolts on hit [c/24C7F0:'Strike and stem the flow'] ''' diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson index 59733c0d49..5e5f7d3dbe 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson @@ -88,6 +88,17 @@ BorealisBomber: { ''' } +BrittleStarStaff: { + DisplayName: Brittle Star Staff + Tooltip: + ''' + Summons a small brittle starfish that will dash through enemies until it shatters + Starfish will quickly regenerate after shattering + Holding right click will swap starfish between dashing and circling you + When the starfish are circling, each one provides you with 3 defense + ''' +} + CadaverousCarrion: { DisplayName: Cadaverous Carrion Tooltip: Summons a gross, shark-puking Old Duke head on the ground @@ -520,7 +531,7 @@ PlantationStaff: { DisplayName: Plantation Staff Tooltip: ''' - Summons a minature Plantera to devastate enemies with floral fury + Summons a miniature Plantera to devastate enemies with floral fury Occupies 3 minion slots and there can only be one Mini Plantera at a time ''' } @@ -580,11 +591,6 @@ ScabRipper: { Tooltip: Summons a baby blood crawler to protect you } -SeaboundStaff: { - DisplayName: Seabound Staff - Tooltip: Summons a brittle star to fight for you -} - ShellfishStaff: { DisplayName: Shellfish Staff Tooltip: diff --git a/Localization/en-US/Mods.CalamityMod.Keybinds.hjson b/Localization/en-US/Mods.CalamityMod.Keybinds.hjson index f25c2f4eb7..6adae130f7 100644 --- a/Localization/en-US/Mods.CalamityMod.Keybinds.hjson +++ b/Localization/en-US/Mods.CalamityMod.Keybinds.hjson @@ -2,11 +2,12 @@ ActivateAccessoryParry.DisplayName: Activate Accessory Parry AdrenalineMode.DisplayName: Adrenaline Mode AngelicAllianceBlessing.DisplayName: Angelic Alliance Blessing ArmorSetBonus.DisplayName: Armor Set Bonus +AscendantInsigniaHotKey.DisplayName: Ascendant Insignia Flight BoosterDash.DisplayName: Booster Dash DashDoubleTapOverride.DisplayName: Dash Double Tap Override ExoChairSlowDown.DisplayName: Exo Chair Slow Down GodSlayerDash.DisplayName: God Slayer Dash -GravistarSabatonHotkey.DisplayName: Gravistar Sabaton Hotkey +GravistarSabatonHotkey.DisplayName: Gravistar Sabaton Slam NormalityRelocator.DisplayName: Normality Relocator RageMode.DisplayName: Rage Mode SandCloakEffect.DisplayName: Sand Cloak Effect diff --git a/Localization/en-US/Mods.CalamityMod.NPCs.hjson b/Localization/en-US/Mods.CalamityMod.NPCs.hjson index b73d6ee086..50fe92f84d 100644 --- a/Localization/en-US/Mods.CalamityMod.NPCs.hjson +++ b/Localization/en-US/Mods.CalamityMod.NPCs.hjson @@ -388,8 +388,8 @@ FAP: { Content: It's 5 o'clock somewhere. NoHome: I need a place to crash! My drinks need to be properly cooled before they can be served! LoveSpace: Finally, some peace and quiet. Large quantities of people tend to piss me off. - FarFromHome: I'm used to running away from home, but this is a little ridculous. - DislikeCrowded: If one more person tells me ‘it's happy hour somewhere' to try and get a discount, I'm going to snap! + FarFromHome: I'm used to running away from home, but this is a little ridiculous. + DislikeCrowded: If one more person tells me 'it's happy hour somewhere' to try and get a discount, I'm going to snap! HateCrowded: No amount of alcohol can drown out the noise these people make! LoveBiome: Other unicorns? Never thought I'd see the day! This place is incredible! LikeBiome: A good breeze to cool some heads, that's the way to deal with customers who've had a few too many drinks! diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson index 2627a93f2c..51894526bd 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson @@ -178,6 +178,8 @@ RedirectingVengefulSoul.DisplayName: Soul RougeSlashLarge.DisplayName: Rouge Slash RougeSlashMedium.DisplayName: Rouge Slash RougeSlashSmall.DisplayName: Rouge Slash +Sandstream.DisplayName: Sandstream +SandstreamScepterExplosion.DisplayName: Sandstream Blast SanguineFlareProj.DisplayName: Sanguine Flare SeethingDischargeBrimstoneBarrage.DisplayName: Seething Brimstone SeethingDischargeBrimstoneHellblast.DisplayName: Seething Hellblast @@ -243,8 +245,6 @@ VoidVortexProj.DisplayName: Void Vortex VolatileStarcore.DisplayName: Volatile Starcore VortexElementalBeam.DisplayName: Vortex Lightning WaterLeechProj.DisplayName: Water Leech -WaterStream.DisplayName: Water Stream -WaterStream2.DisplayName: Water Stream WaywasherProj.DisplayName: Waywasher Blast WulfrumBolt.DisplayName: Wulfrum Bolt WulfrumManaDrain.DisplayName: Mana Drain diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson index 14f7b3ad03..fa544b5594 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson @@ -207,9 +207,9 @@ RedtideWhirlpool.DisplayName: Whirlpool RemsRevengeProj.DisplayName: Rem's Revenge RendingNeedle.DisplayName: Rending Needle Rox1.DisplayName: Rock -RoxShockwave.DisplayName: Rox Shockwave -RoxSlam.DisplayName: Rox Slam +RoxcaliburProj.DisplayName: Roxcalibur RSSolarFlare.DisplayName: Flare +SaharaSlicersBolt.DisplayName: Dagger Bolt SandBlade.DisplayName: Sand Blade SandFire.DisplayName: Fire SanguineFury.DisplayName: Sanguine Fury diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson index 5504304759..80f1e22303 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson @@ -16,11 +16,14 @@ AstralSandgun.DisplayName: Astral Sandgun AstrealArrow.DisplayName: Astreal Arrow AstrealFlame.DisplayName: Astreal Flame AuralisBullet.DisplayName: Auralis Bullet +AuricBullet.DisplayName: Auric Bullet AuroraFire.DisplayName: Aurora Blaze BallistaGreatArrow.DisplayName: Ballista Great Arrow +BarinadeArrow.DisplayName: Fin Arrow BeeRPG.DisplayName: Bee RPG BigCoral.DisplayName: Big Coral BigNuke.DisplayName: Big Nuke +BlightFlames.DisplayName: Blight Flames BlissfulBombardierDustProjectile.DisplayName: Holy Flare Dust BloodBoilerFire.DisplayName: Blood Fire BloodClotFriendly.DisplayName: Blood Clot @@ -51,10 +54,10 @@ ContagionArrow.DisplayName: Contagion Arrow ContagionBall.DisplayName: Contagion Ball CorinthPrimeAirburst.DisplayName: Airburst CorinthPrimeAirburstGrenade.DisplayName: Corinth Prime Airburst Shot -CorossiveFlames.DisplayName: Plagued Flames CorrodedShell.DisplayName: Corroded Shell CosmicFire.DisplayName: Dead Sun's Fire DaemonsFlameArrow.DisplayName: Daemon's Arrow +DeadSunExplosion.DisplayName: Dead Sun's Explosion DragonsBreathRound.DisplayName: Dragon's Breath Round DrataliornusExoArrow.DisplayName: Drataliornus Arrow DrataliornusFlame.DisplayName: Drataliornus Arrow @@ -63,6 +66,7 @@ DrizzlefishFireball.DisplayName: Drizzlefish Fireball DrizzlefishFireSplit.DisplayName: Drizzlefish Flames DWArrow.DisplayName: Death's Arrow ElementalFire.DisplayName: Elemental Fire +ElementalFlare.DisplayName: Elemental Flare ElysianArrowProj.DisplayName: Elysian Arrow EmesisGore.DisplayName: Rotten Gore EnhancedNanoRoundProj.DisplayName: Enhanced Nano Round @@ -118,8 +122,9 @@ MagnomalyExplosion.DisplayName: Explosion MagnomalyRocket.DisplayName: Nuke MarksmanShot.DisplayName: Marksman Shot MechanicalBarracuda.DisplayName: Barracuda +MeowCreature.DisplayName: the creature :3 MeowFire.DisplayName: Purr Fire -MeowFire2.DisplayName: Purr Fire +MineralMortarProjectile.DisplayName: Onyx Bomb MiniatureFolly.DisplayName: Miniature Folly MiniRocket.DisplayName: Rocket MiniSharkron.DisplayName: Mini Sharkron @@ -135,7 +140,6 @@ NovaShot.DisplayName: Nova Bolt Nuke.DisplayName: Nuke NullShot.DisplayName: Null NullShot2.DisplayName: Null -OnyxSharkBomb.DisplayName: Onyx Shark OpalChargedStrike.DisplayName: Charged Plasma Bolt OpalStrike.DisplayName: Heated Bolt PiercingBullet.DisplayName: Piercing Blow @@ -160,6 +164,7 @@ PrismMine.DisplayName: Mine PristineFire.DisplayName: Pristine Fire PristineSecondary.DisplayName: Pristine Lingering Fire PumplerGrenade.DisplayName: Squash Shell +P90Round.DisplayName: Armor-piercing Round RainbowBlast.DisplayName: Blast RainbowFront.DisplayName: Rainbow RainbowTrail.DisplayName: Rainbow @@ -168,7 +173,6 @@ RicoshotCoin.DisplayName: Ricoshot Coin RocketFire.DisplayName: Fire RubberMortarRoundProj.DisplayName: Rubber Mortar SandstormBullet.DisplayName: Sandstorm -SandyWaifuShark.DisplayName: Shark ScorchedEarthBlast.DisplayName: Earth Scorcher ScorchedEarthClusterBomb.DisplayName: Cluster Bomb ScorchedEarthRocket.DisplayName: Rocket @@ -213,7 +217,8 @@ TerraArrowMain.DisplayName: Terra Arrow TerraArrowSplit.DisplayName: Terra Arrow TerraBulletMain.DisplayName: Terra Bullet TerraBulletSplit.DisplayName: Terra Bullet -TerraFireGreen.DisplayName: Terra Fire +TerraFire.DisplayName: Terra Fire +TerraFlare.DisplayName: Terra Flare TheMaelstromExplosion.DisplayName: Reaper Explosion TheMaelstromShark.DisplayName: Reaper Shark ThePackMinissile.DisplayName: Pack Minissile @@ -237,3 +242,5 @@ Voidragon.DisplayName: Voidragon Blast VoidragonTentacle.DisplayName: Voidragon Tentacle WaterSpout.DisplayName: Spout WulfrumScrapBullet.DisplayName: High Speed Scrap +DragonsBreathFlames.DisplayName: Draconic Flames +DragonsBreathMag.DisplayName: Dragons Breath Cartridge diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson index 46bed1a0ac..58f52947f7 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson @@ -24,6 +24,7 @@ AtlasMunitionsLaserOverdrive.DisplayName: Exo Pulse Laser AureusBomber.DisplayName: Aureus Bomber BabyBloodCrawler.DisplayName: Baby Blood Crawler BabyPlaguebringer.DisplayName: Baby Plaguebringer +BetterHornetStinger.DisplayName: Stinger BelladonnaPetal.DisplayName: Belladonna Petal BelladonnaSpirit.DisplayName: Belladonna Spirit BlackDragonBody.DisplayName: Black Celestial Dragon diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson index 2523dbffd6..c5c0ddf5e6 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson @@ -131,3 +131,4 @@ WulfrumHook.DisplayName: Wulfrum Slingshot WulfrumLureSignal.DisplayName: Signal YanmeisKnifeSlash.DisplayName: Yanmei's Knife YellowLabSeeker.DisplayName: Seeking Mechanism +AscendantAura.DisplayName: Ascendant Aura diff --git a/Localization/en-US/Mods.CalamityMod.Status.Death.hjson b/Localization/en-US/Mods.CalamityMod.Status.Death.hjson index 9526f98dc2..83be802451 100644 --- a/Localization/en-US/Mods.CalamityMod.Status.Death.hjson +++ b/Localization/en-US/Mods.CalamityMod.Status.Death.hjson @@ -21,6 +21,26 @@ BrimstoneFlames2: "{0} was charred by the brimstone inferno." BrimstoneFlames3: "{0}'s soul burned to cursed soot." BurningBlood1: "{0} became a blood geyser." BurningBlood2: "{0} burst into high temperature hemorrhage." +ChaliceOfTheBloodGod1: "{0} drank too deeply from the Chalice of the Blood God." +ChaliceOfTheBloodGod2: "{0} was drained to the last drop." +ChaliceOfTheBloodGod3: "{0} bit off more of their health bar than they could chew." +ChaliceOfTheBloodGod4: "{0} was abruptly reminded of their mortality." +ChaliceOfTheBloodGod5: "{0} choked on a tithe of blood." +ChaliceOfTheBloodGod6: "{0} collapsed, pale and gaunt, still clutching the Chalice." +ChaliceOfTheBloodGod7: "{0} expertly demonstrated the art of life stealing from themselves." +ChaliceOfTheBloodGod8: "{0} ran out of borrowed time." +ChaliceOfTheBloodGod9: "{0} brought the Chalice to their lips, only to find it empty." +ChaliceOfTheBloodGod10: "{0}'s careless injuries caught up with them." +ChaliceOfTheBloodGod11: "{0} suffered a death most grisly and predictable." +ChaliceOfTheBloodGod12: "{0} was thoroughly exsanguinated by the Chalice of the Blood God." +ChaliceOfTheBloodGod13: "{0} could only give their life in exchange for the blood price." +ChaliceOfTheBloodGod14: "{0} sank to their knees, dissolving in a pool of their own blood." +ChaliceOfTheBloodGod15: "{0} lost it all in their petty gamble with the Blood God." +ChaliceOfTheBloodGod16: "{0} did not live to see another day." +ChaliceOfTheBloodGod17: "{0} crumpled, weakly reaching for their already-stopped heart." +ChaliceOfTheBloodGod18: "{0} was reduced to a dry husk by the Chalice of the Blood God." +ChaliceOfTheBloodGodClose: "{0} almost made it. Almost." +ChaliceOfTheBloodGodUnequip: "{0} violated their pact with the Blood God." ChibiiDoggo: "{0} couldn't stand the sharp objects." CirrusSlap1: "{0} was slapped too hard." CirrusSlap2: "{0} forked around and found out." @@ -34,6 +54,9 @@ Dragonfire1: "{0}'s ashes scatter in the wind." Dragonfire2: "{0}'s embers fade away in a warm glow." Dragonfire3: "{0} can no longer feel the heat of the dragonfire." Dragonfire4: This was a fight {0} could not win. +ElementalMix1: "{0} was reduced to technicolor confetti." +ElementalMix2: "{0} was blasted apart by a harmonized elemental onslaught." +ElementalMix3: "{0} was overwhelmed by elemental turbulence." GodSlayerInferno1: "{0} imploded into nothingness." GodSlayerInferno2: "{0}'s body slipped into oblivion." GodSlayerInferno3: "{0} ceased being a part of our universe." diff --git a/Localization/en-US/Mods.CalamityMod.UI.hjson b/Localization/en-US/Mods.CalamityMod.UI.hjson index 7b7a1b82a8..36d93f7516 100644 --- a/Localization/en-US/Mods.CalamityMod.UI.hjson +++ b/Localization/en-US/Mods.CalamityMod.UI.hjson @@ -74,6 +74,7 @@ ExtensionName: { // Cooldowns Cooldowns: { AquaticHeartIceShield: Ice Shield Cooldown + AscendEffect: Ascension Cooldown BloodflareFrenzy: Blood Frenzy Cooldown BloodflareRangedSet: Bloodflare Soul Cooldown BrimflameFrenzy: Brimflame Frenzy Cooldown @@ -85,6 +86,7 @@ Cooldowns: { ParryCooldown: Parry Ability Cooldown EvasionScarf: Scarf Cooldown FleshTotem: Contact Damage Halving Cooldown + GaelsRage: Gael's Greatsword Rage Cooldown GlobalDodge: Dodge Cooldown GodSlayerDash: God Slayer Dash Cooldown InkBomb: Ink Bomb Cooldown @@ -235,7 +237,7 @@ Disenchant: Disenchant // Worldgen Tasks EvilIslandCorrupt: Adding a putrid floating island EvilIslandCrimson: Adding a grotesque floating island -BetterDungeon: Building a better dungeon +AstralChest: Placing an astral chest BetterJungleTemple: Building a bigger jungle temple JungleTempleAltar: Placing the Lihzahrd altar GiantBeehive: Building a giant beehive diff --git a/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson b/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson index 8b13789179..23edcb0c1f 100644 --- a/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson +++ b/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson @@ -1 +1,143 @@ +SetBonus: { + Adamantite: { + $parentVal: + ''' + Half of your current DR is added to your critical strike chance + Continuously doing damage makes you gradually gain more and more defense, up to a maximum of {0} + When not doing damage, this bonus gradually decays + This added defense can be broken by defense damage + ''' + Melee: 15% increased melee speed and 20% increased movement speed + } + Chlorophyte: + ''' + Summons a powerful leaf crystal to shoot pulses of life every {0} seconds + The pulses do a base damage of {1} to enemies within its range + The pulses also provide a {2} health boost to you and all players on your team + Players healed by pulses cannot be healed by another pulse until {3} seconds have passed + Both the health boost and the damage scale based on your strongest class + ''' + + Cobalt: { + $parentVal: + ''' + {0}% increased max speed and acceleration + You gain a damage and critical strike chance boost relative to your current movement speed, up to {0}% + ''' + Melee: 10% increased melee damage + } + + Copper: Increases all damage by 2 + Eskimo: + ''' + Multiplies all cold-based debuff damage by 1.25 + Cold enemies will deal reduced contact damage to the player + Provides immunity to the Chilled, Frozen, Frostburn and Glacial State debuffs + ''' + Frost: + ''' + Melee and ranged attacks inflict Frostbite + {0}% increased damage which scales based on how far the target is from you + Closer range grants melee damage, while farther range grants ranged damage + ''' + Gladiator: + ''' + +3 defense + +60 maximum stealth + 5% increased rogue damage and 10% increased velocity + ''' + Gold: + ''' + All enemies have a 4% chance to drop 1 gold. All bosses killed drop 3 gold + You gain 1% critical strike chance for every 5 gold in your inventory, capped at 10% + ''' + Iron: + ''' + Increases damage reduction by 6% + +1 HP/s life regen + ''' + Lead: + ''' + Increases damage reduction by 3% + +0.5 HP/s life regen + Grants immunity to knockback + ''' + Meteor: Space Gun costs 50% mana + Mining: Mining ore will sometimes have additional yield + Molten: + ''' + 20% extra true melee damage + Grants immunity to fire blocks and temporary immunity to lava + ''' + MonkTier2: + ''' + 10% increased melee speed, crit, and damage + 15% increased minion damage + ''' + Mythril: + ''' + Enemy hits release mythril flares, which home in on enemies after a short delay + Once a flare is created, there is a {0} frame delay before another one can appear + ''' + Necro: + ''' + Allows you to temporarily survive fatal damage + Grants up to {0} seconds of life before imminent death + ''' + Obsidian: + ''' + Increases whip range by 50% and speed by 35% + Increases minion damage by 15% + Grants immunity to fire blocks and temporary immunity to lava + ''' + Platinum: + ''' + Every 10 defense gives you +0.5 HP/s life regen, 1% increased damage and 1% increased critical strike chance + These effects cap at 40 defense + ''' + Shadow: 15% increased max movement speed and acceleration + Silver: + ''' + +0.5 HP/s life regen + Two seconds after getting hit for 20 or more damage, you heal for 10 + Getting hit again resets the timer, delaying the heal + ''' + Tin: Increases armor penetration by 5 + Tungsten: + ''' + Increases your critical strike chance by 100% of the knockback of your held weapon + This effect caps at Insane knockback, which gives 10% increased critical strike chance + Increases all knockback by 33%, this counts for the above boost + Current bonus: {0}% critical strike chance from {1} knockback + ''' + CrystalAssassin: + ''' + Allows the ability to dash + 10% increased damage and critical strike chance + ''' + SquireTier2: + ''' + Increases your life regeneration + 15% increased minion damage and 10% increased melee critical strike chance + ''' + HuntressTier2: 10% increased minion and ranged damage + ApprenticeTier2: 5% increased minion damage and 15% increased magic critical strike chance + MonkTier3: + ''' + 10% increased melee damage, melee critical strike chance and melee speed + 30% increased minion damage + ''' + SquireTier3: + ''' + Massively increased life regeneration + 10% increased minion damage and melee critical strike chance + ''' + HuntressTier3: 10% increased minion and ranged damage + ApprenticeTier3: 10% increased minion damage and 15% increased magic critical strike chance + SpectreHealing: + ''' + Reduces Magic damage by 20% and converts it to healing force + Magic damage done to enemies heals the player with lowest health + ''' +} diff --git a/Localization/en-US/Mods.CalamityMod.Vanilla.hjson b/Localization/en-US/Mods.CalamityMod.Vanilla.hjson index 449aa03b95..aed63d706f 100644 --- a/Localization/en-US/Mods.CalamityMod.Vanilla.hjson +++ b/Localization/en-US/Mods.CalamityMod.Vanilla.hjson @@ -68,6 +68,16 @@ GuideChat: { Hardmode2: That earthquake wasn't natural, something must have caused it... Beware when exploring, whatever caused it must be a powerful entity, perhaps even otherworldly. } +HerbTooltips: { + Daybloom: "[C/FFEB8A:A cheerful herb which blooms under daylight]" + Moonglow: "[C/8AFFFF:A radiant herb which blossoms under moonlight]" + Waterleaf: "[C/8AFFAF:A tenacious herb that blossoms in the rain]" + Blinkroot: "[C/FFC28A:A fickle herb, whose blooming is unpredictable]" + Shiverthorn: "[C/AADEFA:A frigid herb that blooms slowly and permanently]" + Deathweed: "[C/A98AFF:A foul herb, blossoming under the Full or Blood Moon]" + Fireblossom: "[C/FF8063:A vibrant herb, blossoming in the sunset hours]" +} + MechanicChat: { MoonLordDefeated: What do you mean your traps aren't making the cut? Don't look at me! Eclipse: Um... should my nightlight be on? @@ -117,6 +127,16 @@ PirateChat: { SulphurSea2: Me ship might just sink from the acid alone. } +SeedTooltips: { + Daybloom: "[C/FFEB8A:Must be planted in regular Grass]" + Moonglow: "[C/8AFFFF:Must be planted in Jungle Grass]" + Waterleaf: "[C/8AFFAF:Must be placed in Sand]" + Blinkroot: "[C/FFC28A:Must be sown in Dirt or Mud]" + Shiverthorn: "[C/AADEFA:Must be placed in Snow or Ice]" + Deathweed: "[C/A98AFF:Must be buried in Evil Grass or Evil Stone]" + Fireblossom: "[C/FF8063:Must be buried in Ash]" +} + SkeletonMerchantChat.Normal: What'dya buyin'? SteampunkerChat: { diff --git a/ModSupport/ModCalls.cs b/ModSupport/ModCalls.cs index d9501d93b9..46243a07e7 100644 --- a/ModSupport/ModCalls.cs +++ b/ModSupport/ModCalls.cs @@ -6,14 +6,15 @@ using CalamityMod.Cooldowns; using CalamityMod.Events; using CalamityMod.ExtraJumps; using CalamityMod.Items; +using CalamityMod.NPCs; using CalamityMod.Particles; -using CalamityMod.Particles.Metaballs; using CalamityMod.Systems; using CalamityMod.UI; using CalamityMod.UI.CalamitasEnchants; using CalamityMod.UI.DraedonSummoning; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Localization; using Terraria.ModLoader; @@ -577,13 +578,13 @@ namespace CalamityMod public static float AddMaxStealth(Player p, float add) => p is null ? 0f : (p.Calamity().rogueStealthMax += add); public static bool CanStealthStrike(Player p) => p?.Calamity()?.StealthStrikeAvailable() ?? false; - + public static void SetStealthProjectile(Projectile projectile, bool enabled) { if (projectile != null) projectile.Calamity().stealthStrike = enabled; } - + public static bool GetStealthProjectile(Projectile projectile) => projectile?.Calamity()?.stealthStrike ?? false; #endregion @@ -644,849 +645,6 @@ namespace CalamityMod } #endregion - #region Player Armor Set Bonuses - /// - /// Returns whether the specified player has the set bonus corresponding to the given string. - /// - /// The player whose set bonuses are being questioned. - /// The set bonus to check for. - /// Whether the player currently has the set bonus. - public static bool GetSetBonus(Player p, string setBonus) - { - CalamityPlayer mp = p.Calamity(); - - setBonus = setBonus.ToLower(); - - // LATER -- no summon set bonuses are written well. all use two bools, neither of which actually controls the function - - // Desert Prowler - if (setBonus == "desertprowler" || setBonus == "desert prowler") - return mp.desertProwler; - - // Snow Ruffian - if (setBonus == "snowruffian" || setBonus == "snow ruffian") - return mp.snowRuffianSet; - - // Sulphurous - if (setBonus == "sulfur" || setBonus == "sulphur" || setBonus == "sulfurous" || setBonus == "sulphurous") - return mp.sulfurSet; - - // Victide - if (setBonus == "victide_summon" || setBonus == "victide summon") - return mp.victideSummoner; // the bool set directly by VictideHelmet.UpdateArmorSet - else if (setBonus == "victide" || setBonus.StartsWith("victide_") || setBonus.StartsWith("victide ")) - return mp.victideSet; - - // Aerospec - if (setBonus == "aerospec_summon" || setBonus == "aerospec summon") - return mp.valkyrie; // the bool set directly by AerospecHelmet.UpdateArmorSet - else if (setBonus == "aerospec" || setBonus.StartsWith("aerospec_") || setBonus.StartsWith("aerospec ")) - return mp.aeroSet; - - // Statigel - if (setBonus == "statigel_summon" || setBonus == "statigel summon") - return mp.slimeGod; // the bool set directly by StatigelHood.UpdateArmorSet - if (setBonus == "statigel" || setBonus.StartsWith("statigel_") || setBonus.StartsWith("statigel ")) - return mp.statigelSet; - - // Mollusk - if (setBonus == "mollusk") - return mp.molluskSet; - - // Titan Heart - if (setBonus == "titanheart" || setBonus == "titan heart") - return mp.titanHeartSet; - - // Forbidden Circlet - if (setBonus == "forbidden_circlet" || setBonus == "forbidden circlet") - return mp.forbiddenCirclet; - - // Daedalus - switch (setBonus) - { - default: - break; - case "daedalus": - return mp.daedalusReflect || mp.daedalusShard || mp.daedalusAbsorb || mp.daedalusCrystal || mp.daedalusSplit; - case "daedalus_melee": - case "daedalus melee": - return mp.daedalusReflect; - case "daedalus_ranged": - case "daedalus ranged": - return mp.daedalusShard; - case "daedalus_magic": - case "daedalus magic": - return mp.daedalusAbsorb; - case "daedalus_summon": - case "daedalus summon": - return mp.daedalusCrystal; - case "daedalus_rogue": - case "daedalus rogue": - return mp.daedalusSplit; - } - - // Reaver - switch (setBonus) - { - default: - break; - case "reaver": - return mp.reaverSpeed || mp.reaverExplore || mp.reaverDefense; - case "reaver_speed": - case "reaver speed": - return mp.reaverSpeed; - case "reaver_explore": - case "reaver explore": - case "reaver_exploration": - case "reaver exploration": - return mp.reaverExplore; - case "reaver_defense": - case "reaver defense": - case "reaver_tank": - case "reaver tank": - return mp.reaverDefense; - } - - // Fathom Swarmer - if (setBonus == "fathomswarmer" || setBonus == "fathom swarmer") - return mp.fathomSwarmer; - - // Brimflame - if (setBonus == "brimflame") - return mp.brimflameSet; - - // Umbraphile - if (setBonus == "umbraphile") - return mp.umbraphileSet; - - // Hydrothermic (Ataxia is legacy name) - switch (setBonus) - { - default: - break; - case "ataxia": - case "hydrothermic": - case "hydrothermal": - return mp.ataxiaBlaze; - case "ataxia_melee": - case "ataxia melee": - case "hydrothermic_melee": - case "hydrothermic melee": - case "hydrothermal_melee": - case "hydrothermal melee": - return mp.ataxiaGeyser; - case "ataxia_ranged": - case "ataxia ranged": - case "hydrothermic_ranged": - case "hydrothermic ranged": - case "hydrothermal_ranged": - case "hydrothermal ranged": - return mp.ataxiaBolt; - case "ataxia_magic": - case "ataxia magic": - case "hydrothermic_magic": - case "hydrothermic magic": - case "hydrothermal_magic": - case "hydrothermal magic": - return mp.ataxiaMage; - case "ataxia_summon": - case "ataxia summon": - case "hydrothermic_summon": - case "hydrothermic summon": - case "hydrothermal_summon": - case "hydrothermal summon": - return mp.chaosSpirit; - case "ataxia_rogue": - case "ataxia rogue": - case "hydrothermic_rogue": - case "hydrothermic rogue": - case "hydrothermal_rogue": - case "hydrothermal rogue": - return mp.ataxiaVolley; - } - - // Plague Reaper - if (setBonus == "plaguereaper" || setBonus == "plague reaper") - return mp.plagueReaper; - - // Plaguebringer - if (setBonus == "plaguebringer" || setBonus == "plaguebringerpatron" || setBonus == "plaguebringer patron") - return mp.plaguebringerPatronSet; - - // Astral - if (setBonus == "astral") - return mp.astralStarRain; - - // Empyrean (formerly Xeroc) - if (setBonus == "empyrean" || setBonus == "xeroc") - return mp.xerocSet; - - // Tarragon - switch (setBonus) - { - default: - break; - case "tarragon": - return mp.tarraSet; - case "tarragon_melee": - case "tarragon melee": - return mp.tarraMelee; - case "tarragon_ranged": - case "tarragon ranged": - return mp.tarraRanged; - case "tarragon_magic": - case "tarragon magic": - return mp.tarraMage; - case "tarragon_summon": - case "tarragon summon": - return mp.tarraSummon; - case "tarragon_rogue": - case "tarragon rogue": - return mp.tarraThrowing; - } - - // Prismatic - if (setBonus == "prismatic" || setBonus == "prism") - return mp.prismaticSet; - - // Bloodflare - switch (setBonus) - { - default: - break; - case "bloodflare": - return mp.bloodflareSet; - case "bloodflare_melee": - case "bloodflare melee": - return mp.bloodflareMelee; - case "bloodflare_ranged": - case "bloodflare ranged": - return mp.bloodflareRanged; - case "bloodflare_magic": - case "bloodflare magic": - return mp.bloodflareMage; - case "bloodflare_summon": - case "bloodflare summon": - return mp.bloodflareSummon; - case "bloodflare_rogue": - case "bloodflare rogue": - return mp.bloodflareThrowing; - } - - // Omega Blue - if (setBonus == "omegablue" || setBonus == "omega blue") - return mp.omegaBlueSet; - - // God Slayer - switch (setBonus) - { - default: - break; - case "godslayer": - case "god slayer": - return mp.godSlayer; - case "godslayer_melee": - case "godslayer melee": - case "god slayer melee": - return mp.godSlayerDamage; // melee helm - case "godslayer_ranged": - case "godslayer ranged": - case "god slayer ranged": - return mp.godSlayerRanged; - // God Slayer Mage was removed in the Draedon Update - case "godslayer_magic": - case "godslayer magic": - case "god slayer magic": - return false; // mp.godSlayerMage; - // God Slayer Summon was removed in the Draedon Update - case "godslayer_summon": - case "godslayer summon": - case "god slayer summon": - return false; // mp.godSlayerSummon; - - case "godslayer_rogue": - case "godslayer rogue": - case "god slayer rogue": - return mp.godSlayerThrowing; - } - - // Fearmonger - if (setBonus == "fearmonger") - return mp.fearmongerSet; - - // Silva - switch (setBonus) - { - default: - break; - case "silva": - return mp.silvaSet; - - // Silva Melee was removed in the Draedon Update - case "silva_melee": - case "silva melee": - return false; // mp.silvaMelee; - // Silva Ranged was removed in the Draedon Update - case "silva_ranged": - case "silva ranged": - return false; // mp.silvaRanged; - case "silva_magic": - case "silva magic": - return mp.silvaMage; - case "silva_summon": - case "silva summon": - return mp.silvaSummon; - // Silva Rogue was removed in the Draedon Update - case "silva_rogue": - case "silva rogue": - return false; // mp.silvaThrowing; - } - - // Auric Tesla - if (setBonus == "auric" || setBonus == "aurictesla" || setBonus == "auric tesla") - return mp.auricSet; - - // Demonshade - if (setBonus == "demonshade") - return mp.dsSetBonus; - - return false; - } - - /// - /// Turns the set bonus corresponding to the given string on or off for the specified player. - /// - /// The player whose set bonuses are being toggled. - /// The set bonus to check for. - /// Whether the set bonus should be enabled (true) or disabled (false). - /// Whether any set bonus was adjusted. - public static bool SetSetBonus(Player p, string setBonus, bool enabled) - { - CalamityPlayer mp = p.Calamity(); - setBonus = setBonus.ToLower(); - - // Desert Prowler - if (setBonus == "desertprowler" || setBonus == "desert prowler") - { - mp.desertProwler = enabled; - return true; - } - - // Snow Ruffian - if (setBonus == "snowruffian" || setBonus == "snow ruffian") - { - mp.snowRuffianSet = enabled; - return true; - } - - // Sulphurous - if (setBonus == "sulfur" || setBonus == "sulphur" || setBonus == "sulfurous" || setBonus == "sulphurous") - { - mp.sulfurSet = enabled; - if (enabled) - p.GetJumpState().Enable(); - return true; - } - - // Victide - if (setBonus == "victide_summon" || setBonus == "victide summon") - { - mp.victideSet = enabled; - mp.victideSummoner = enabled; - return true; - } - else if (setBonus == "victide" || setBonus.StartsWith("victide_") || setBonus.StartsWith("victide ")) - { - mp.victideSet = true; - return true; - } - - // Aerospec - if (setBonus == "aerospec_summon" || setBonus == "aerospec summon") - { - mp.aeroSet = enabled; - mp.valkyrie = enabled; // LATER -- remove this when player.valkyrie actually controls aerospec summoner - return true; - } - else if (setBonus == "aerospec" || setBonus.StartsWith("aerospec_") || setBonus.StartsWith("aerospec ")) - { - mp.aeroSet = enabled; - return true; - } - - // Statigel - if (setBonus == "statigel_summon" || setBonus == "statigel summon") - { - mp.statigelSet = enabled; - if (enabled) - p.GetJumpState().Enable(); - mp.slimeGod = enabled; // LATER -- remove this when player.slimeGod actually controls statigel summoner - return true; - } - else if (setBonus == "statigel" || setBonus.StartsWith("statigel_") || setBonus.StartsWith("statigel ")) - { - mp.statigelSet = enabled; - if (enabled) - p.GetJumpState().Enable(); - return true; - } - - // Mollusk - if (setBonus == "mollusk") - { - mp.molluskSet = enabled; - return true; - } - - // Titan Heart - if (setBonus == "titanheart" || setBonus == "titan heart") - { - mp.titanHeartMask = enabled; - mp.titanHeartMantle = enabled; - mp.titanHeartBoots = enabled; - mp.titanHeartSet = enabled; - return true; - } - - // Forbidden Circlet - if (setBonus == "forbidden_circlet" || setBonus == "forbidden circlet") - { - mp.forbiddenCirclet = enabled; - return true; - } - - // Daedalus - switch (setBonus) - { - default: - break; - case "daedalus_melee": - case "daedalus melee": - mp.daedalusReflect = enabled; - return true; - case "daedalus_ranged": - case "daedalus ranged": - mp.daedalusShard = enabled; - return true; - case "daedalus_magic": - case "daedalus magic": - mp.daedalusAbsorb = enabled; - return true; - case "daedalus_summon": - case "daedalus summon": - mp.daedalusCrystal = enabled; // LATER -- remove this when player.daedalusCrystal actually controls daedalus summoner - return true; - case "daedalus_rogue": - case "daedalus rogue": - mp.daedalusSplit = enabled; - return true; - } - - // Reaver - switch (setBonus) - { - default: - break; - case "reaver_speed": - case "reaver speed": - mp.reaverSpeed = enabled; - return true; - case "reaver_explore": - case "reaver explore": - case "reaver_exploration": - case "reaver exploration": - mp.reaverExplore = enabled; - return true; - case "reaver_defense": - case "reaver defense": - case "reaver_tank": - case "reaver tank": - mp.reaverDefense = enabled; - return true; - } - - // Fathom Swarmer - if (setBonus == "fathomswarmer" || setBonus == "fathom swarmer") - { - mp.fathomSwarmer = enabled; - return true; - } - - // Brimflame - if (setBonus == "brimflame") - { - mp.brimflameSet = enabled; - return true; - } - - // Umbraphile - if (setBonus == "umbraphile") - { - mp.umbraphileSet = enabled; - return true; - } - - // Hydrothermic (Ataxia as legacy name) - switch (setBonus) - { - default: - break; - case "ataxia": - case "hydrothermic": - case "hydrothermal": - mp.ataxiaBlaze = enabled; - return true; - case "ataxia_melee": - case "ataxia melee": - case "hydrothermic_melee": - case "hydrothermic melee": - case "hydrothermal_melee": - case "hydrothermal melee": - mp.ataxiaBlaze = enabled; - mp.ataxiaGeyser = enabled; - return true; - case "ataxia_ranged": - case "ataxia ranged": - case "hydrothermic_ranged": - case "hydrothermic ranged": - case "hydrothermal_ranged": - case "hydrothermal ranged": - mp.ataxiaBlaze = enabled; - mp.ataxiaBolt = enabled; - return true; - case "ataxia_magic": - case "ataxia magic": - case "hydrothermic_magic": - case "hydrothermic magic": - case "hydrothermal_magic": - case "hydrothermal magic": - mp.ataxiaBlaze = enabled; - mp.ataxiaMage = enabled; - return true; - case "ataxia_summon": - case "ataxia summon": - case "hydrothermic_summon": - case "hydrothermic summon": - case "hydrothermal_summon": - case "hydrothermal summon": - mp.ataxiaBlaze = enabled; - mp.chaosSpirit = enabled; // LATER -- remove this when player.chaosSpirit actually controls ataxia summoner - return true; - case "ataxia_rogue": - case "ataxia rogue": - case "hydrothermic_rogue": - case "hydrothermic rogue": - case "hydrothermal_rogue": - case "hydrothermal rogue": - mp.ataxiaBlaze = enabled; - mp.ataxiaVolley = enabled; - return true; - } - - // Plague Reaper - if (setBonus == "plaguereaper" || setBonus == "plague reaper") - { - mp.plagueReaper = enabled; - return true; - } - - // Plaguebringer - if (setBonus == "plaguebringer" || setBonus == "plaguebringerpatron" || setBonus == "plaguebringer patron") - { - mp.plaguebringerPatronSet = enabled; - return true; - } - - // Astral - if (setBonus == "astral") - { - mp.astralStarRain = enabled; - return true; - } - - // Xeroc - if (setBonus == "empyrean" || setBonus == "xeroc") - { - mp.xerocSet = enabled; - return true; - } - - // Tarragon - switch (setBonus) - { - default: - break; - case "tarragon": - mp.tarraSet = enabled; - return true; - case "tarragon_melee": - case "tarragon melee": - mp.tarraSet = enabled; - mp.tarraMelee = enabled; - return true; - case "tarragon_ranged": - case "tarragon ranged": - mp.tarraSet = enabled; - mp.tarraRanged = enabled; - return true; - case "tarragon_magic": - case "tarragon magic": - mp.tarraSet = enabled; - mp.tarraMage = enabled; - return true; - case "tarragon_summon": - case "tarragon summon": - mp.tarraSet = enabled; - mp.tarraSummon = enabled; // LATER -- remove this when player.tarraSummon actually controls life aura - return true; - case "tarragon_rogue": - case "tarragon rogue": - mp.tarraSet = enabled; - mp.tarraThrowing = enabled; - return true; - } - - // Prismatic - if (setBonus == "prismatic" || setBonus == "prism") - { - mp.prismaticSet = enabled; - return true; - } - - // Bloodflare - switch (setBonus) - { - default: - break; - case "bloodflare": - mp.bloodflareSet = enabled; - return true; - case "bloodflare_melee": - case "bloodflare melee": - mp.bloodflareSet = enabled; - mp.bloodflareMelee = enabled; - return true; - case "bloodflare_ranged": - case "bloodflare ranged": - mp.bloodflareSet = enabled; - mp.bloodflareRanged = enabled; - return true; - case "bloodflare_magic": - case "bloodflare magic": - mp.bloodflareSet = enabled; - mp.bloodflareMage = enabled; - return true; - case "bloodflare_summon": - case "bloodflare summon": - mp.bloodflareSet = enabled; - mp.bloodflareSummon = enabled; // LATER -- remove this when player.bloodflareSummon actually controls bloodflare orbs - return true; - case "bloodflare_rogue": - case "bloodflare rogue": - mp.bloodflareSet = enabled; - mp.bloodflareThrowing = enabled; - return true; - } - - // Omega Blue - if (setBonus == "omegablue" || setBonus == "omega blue") - { - mp.omegaBlueSet = enabled; - return true; - } - - // God Slayer - switch (setBonus) - { - default: - break; - case "godslayer": - case "god slayer": - mp.godSlayer = enabled; - return true; - case "godslayer_melee": - case "godslayer melee": - case "god slayer melee": - mp.godSlayer = enabled; - mp.godSlayerDamage = enabled; // melee helm - return true; - case "godslayer_ranged": - case "godslayer ranged": - case "god slayer ranged": - mp.godSlayer = enabled; - mp.godSlayerRanged = enabled; - return true; - // God Slayer Mage and Summon were removed in the Draedon Update - /* - case "godslayer_magic": - case "godslayer magic": - case "god slayer magic": - mp.godSlayer = enabled; - mp.godSlayerMage = enabled; - return true; - case "godslayer_summon": - case "godslayer summon": - case "god slayer summon": - mp.godSlayer = enabled; - mp.godSlayerSummon = enabled; - return true; - */ - case "godslayer_rogue": - case "godslayer rogue": - case "god slayer rogue": - mp.godSlayer = enabled; - mp.godSlayerThrowing = enabled; - return true; - } - - // Fearmonger - if (setBonus == "fearmonger") - { - mp.fearmongerSet = enabled; - return true; - } - - // Silva - switch (setBonus) - { - default: - break; - case "silva": - mp.silvaSet = enabled; - return true; - case "silva_magic": - case "silva magic": - mp.silvaSet = enabled; - mp.silvaMage = enabled; - return true; - case "silva_summon": - case "silva summon": - mp.silvaSet = enabled; - mp.silvaSummon = enabled; // LATER -- remove this when player.silvaSummon actually controls silva crystal - return true; - // Silva Melee, Ranged and Rogue were removed in the Draedon Update - /* - case "silva_melee": - case "silva melee": - mp.silvaSet = enabled; - mp.silvaMelee = enabled; - return true; - case "silva_ranged": - case "silva ranged": - mp.silvaSet = enabled; - mp.silvaRanged = enabled; - return true; - case "silva_rogue": - case "silva rogue": - mp.silvaSet = enabled; - mp.silvaThrowing = enabled; - return true; - */ - } - - // Auric Tesla (includes all components) - switch (setBonus) - { - default: - break; - case "auric": - case "aurictesla": - case "auric tesla": - mp.tarraSet = enabled; - mp.bloodflareSet = enabled; - mp.godSlayer = enabled; - mp.silvaSet = enabled; - mp.auricSet = enabled; - return true; - case "auric_melee": - case "auric melee": - case "aurictesla_melee": - case "aurictesla melee": - case "auric tesla melee": - mp.tarraSet = enabled; - mp.tarraMelee = enabled; - mp.bloodflareSet = enabled; - mp.bloodflareMelee = enabled; - mp.godSlayer = enabled; - mp.godSlayerDamage = enabled; - mp.silvaSet = enabled; - // mp.silvaMelee = enabled; - mp.auricSet = enabled; - return true; - case "auric_ranged": - case "auric ranged": - case "aurictesla_ranged": - case "aurictesla ranged": - case "auric tesla ranged": - mp.tarraSet = enabled; - mp.tarraRanged = enabled; - mp.bloodflareSet = enabled; - mp.bloodflareRanged = enabled; - mp.godSlayer = enabled; - mp.godSlayerRanged = enabled; - mp.silvaSet = enabled; - // mp.silvaRanged = enabled; - mp.auricSet = enabled; - return true; - case "auric_magic": - case "auric magic": - case "aurictesla_magic": - case "aurictesla magic": - case "auric tesla magic": - mp.tarraSet = enabled; - mp.tarraMage = enabled; - mp.bloodflareSet = enabled; - mp.bloodflareMage = enabled; - mp.godSlayer = enabled; - // mp.godSlayerMage = enabled; - mp.silvaSet = enabled; - mp.silvaMage = enabled; - mp.auricSet = enabled; - return true; - case "auric_summon": - case "auric summon": - case "aurictesla_summon": - case "aurictesla summon": - case "auric tesla summon": - mp.tarraSet = enabled; - mp.tarraSummon = enabled; - mp.bloodflareSet = enabled; - mp.bloodflareSummon = enabled; - mp.godSlayer = enabled; - // mp.godSlayerSummon = enabled; - mp.silvaSet = enabled; - mp.silvaSummon = enabled; - mp.auricSet = enabled; - return true; - case "auric_rogue": - case "auric rogue": - case "aurictesla_rogue": - case "aurictesla rogue": - case "auric tesla rogue": - mp.tarraSet = enabled; - mp.tarraThrowing = enabled; - mp.bloodflareSet = enabled; - mp.bloodflareThrowing = enabled; - mp.godSlayer = enabled; - mp.godSlayerThrowing = enabled; - mp.silvaSet = enabled; - // mp.silvaThrowing = enabled; - mp.auricSet = enabled; - return true; - } - - // Demonshade - if (setBonus == "demonshade") - { - mp.dsSetBonus = enabled; - mp.rDevil = enabled; // LATER -- remove this when player.rDevil controls demonshade summoned minion - return true; - } - - return false; - } - #endregion - #region Other Player Stats public static int GetLightStrength(Player p) => p?.GetCurrentAbyssLightLevel() ?? 0; @@ -1650,6 +808,8 @@ namespace CalamityMod } #endregion + #region Calamity AI + public static float[] GetCalamityAI(NPC npc) => npc?.Calamity()?.newAI ?? new float[0]; public static void SetCalamityAI(NPC npc, int aiSlot, float value) @@ -1659,11 +819,15 @@ namespace CalamityMod npc.Calamity().newAI[aiSlot] = value; } } + #endregion #region Boss Health Bars public static bool BossHealthBarVisible() => Main.LocalPlayer.Calamity().drawBossHPBar; public static bool SetBossHealthBarVisible(bool visible) => Main.LocalPlayer.Calamity().drawBossHPBar = visible; + + public static bool GetShouldCloseBossHealthBar(NPC npc) => npc?.Calamity()?.ShouldCloseHPBar ?? false; + public static void SetShouldCloseBossHealthBar(NPC npc, bool enabled) => npc.Calamity().ShouldCloseHPBar = enabled; #endregion #region Dodge Disabling @@ -1759,7 +923,7 @@ namespace CalamityMod #endregion #region Summoner Cross Class Nerf Disabling - public static bool SetSummonerNerfDisabledByMinion(int type, bool disableNerf) + public static bool SetSummonerNerfDisabledByMinion(int type, bool disableNerf) { if (disableNerf && !CalamityLists.DisabledSummonerNerfMinions.Contains(type)) { @@ -1792,6 +956,26 @@ namespace CalamityMod public static bool GetSummonerNerfDisabledByItem(int type) => CalamityLists.DisabledSummonerNerfItems.Contains(type); #endregion + #region Debuff Display support + public static void RegisterDebuff(string texturePath, Predicate debuffCheck) + { + if (!CalamityGlobalNPC.moddedDebuffTextureList.Contains((texturePath, debuffCheck))) + { + CalamityGlobalNPC.moddedDebuffTextureList.Add((texturePath, debuffCheck)); + } + } + #endregion + + #region Town NPC Alert support + public static void RegisterTownNPCShop(int id, Predicate getShop, Action setShop) + { + if (!CalamityGlobalNPC.npcAlertList.Contains((id, getShop, setShop))) + { + CalamityGlobalNPC.npcAlertList.Add((id, getShop, setShop)); + } + } + #endregion + #region Call public static object Call(params object[] args) @@ -1913,7 +1097,7 @@ namespace CalamityMod case "AddDifficultyToUI": if (args.Length < 2) return new ArgumentException("ERROR: Not enough arguements provided"); - + if (args[1] is not DifficultyMode mode) return new ArgumentException("ERROR: A class inheriting from 'DifficultyMode' must be provided."); AddCustomDifficulty(mode); @@ -1927,7 +1111,7 @@ namespace CalamityMod case "GetAbyssLightStrength": if (args.Length < 2) return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player)."); - if(!isValidPlayerArg(args[1])) + if (!isValidPlayerArg(args[1])) return new ArgumentException("ERROR: The argument to \"GetLightStrength\" must be a Player or an int."); return GetLightStrength(castPlayer(args[1])); @@ -1968,7 +1152,7 @@ namespace CalamityMod case "GetWearingRogueArmor": if (args.Length < 2) return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player)."); - if(!isValidPlayerArg(args[1])) + if (!isValidPlayerArg(args[1])) return new ArgumentException("ERROR: The argument to \"GetRogueArmor\" must be a Player or an int."); return GetWearingRogueArmor(castPlayer(args[1])); @@ -1996,7 +1180,7 @@ namespace CalamityMod case "GetWearingPostMoonLordSummonerArmor": if (args.Length < 2) return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player)."); - if(!isValidPlayerArg(args[1])) + if (!isValidPlayerArg(args[1])) return new ArgumentException("ERROR: The argument to \"GetPostMoonLordSummonerArmor\" must be a Player or an int."); return GetWearingPostMLSummonerArmor(castPlayer(args[1])); @@ -2504,10 +1688,34 @@ namespace CalamityMod return new ArgumentNullException("ERROR: Must specify a bool."); return SetBossHealthBarVisible(bossBarEnabled); + case "SetShouldCloseBossHealthBar": + { + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify both an NPC and whether or not the NPC's health bar should be closed as a bool."); + if (args.Length < 3) + return new ArgumentNullException("ERROR: Must specify whether or not the NPC's health bar should be closed as a bool."); + if (!(args[2] is float) && !(args[2] is bool)) + return new ArgumentException("ERROR: The second argument to \"SetShouldCloseBossHealthBar\" must be a bool."); + if (!isValidNPCArg(args[1])) + return new ArgumentException("ERROR: The first argument to \"SetShouldCloseBossHealthBar\" must be an NPC."); + + SetShouldCloseBossHealthBar(castNPC(args[1]), (bool)args[2]); + return null; + } + + case "GetShouldCloseBossHealthbar": + { + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify an NPC."); + if (!isValidNPCArg(args[1])) + return new ArgumentException("ERROR: The first argument to \"GetShouldCloseBossHealthBar\" must be an NPC."); + return GetShouldCloseBossHealthBar(castNPC(args[1])); + } + case "CanFirePointBlank": case "CanFirePointBlankShots": if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify an Item object (or int index of an Item in the Main.item array).");; + return new ArgumentNullException("ERROR: Must specify an Item object (or int index of an Item in the Main.item array)."); ; if (!isValidItemArg(args[1])) return new ArgumentException("ERROR: The first argument to \"CanFirePointBlank\" must be an Item or an int."); return CanFirePointBlank(castItem(args[1])); @@ -2715,8 +1923,6 @@ namespace CalamityMod return new ArgumentNullException("ERROR: Must specify a Mod instance to load particles from."); GeneralParticleHandler.LoadModParticleInstances(args[1] as Mod); - FusableParticleManager.ExtraModsToLoadSetsFrom.Add(args[1] as Mod); - FusableParticleManager.LoadParticleRenderSets(true); return null; case "RegisterModCooldowns": @@ -2788,6 +1994,55 @@ namespace CalamityMod return new ArgumentException("ERROR: Must specify a valid item type as an int index of the item."); return AddToVeneratedLocketBanlist(itemType); + case "RegisterDebuff": + case "AddToDebuffDisplay": + case "AddDebuffDisplay": + case "DisplayDebuff": + case "DebuffIcon": + { + if (args.Length < 2 || args[1] is not string texturePath) + return new ArgumentException("ERROR: The first argument to \"RegisterDebuff\" must be the texture path to the debuff sprite as a string"); + if (args.Length != 3 || args[2] is not Predicate debuffCheck) + return new ArgumentException("ERROR: The second argument to \"RegisterDebuff\" Must be a Predicate that checks if an NPC meets the conditions for the debuff."); + RegisterDebuff(texturePath, debuffCheck); + return null; + } + + case "RegisterNPCShop": + case "RegisterShop": + case "RegisterTownNPCShop": + case "AddNPCShop": + case "AddShop": + case "AddTownNPCShop": + { + if (args.Length < 2 || args[1] is not int npc) + return new ArgumentException("ERROR: The first argument to \"RegisterTownNPCShop\" must be the id of the NPC"); + if (args.Length < 3 || args[2] is not Predicate shopCheck) + return new ArgumentException("ERROR: The second argument to \"RegisterTownNPCShop\" Must be a Predicate that checks if the new shop variable bool is true or not."); + if (args.Length != 4 || args[3] is not Action shopSet) + return new ArgumentException("ERROR: The third argument to \"RegisterTownNPCShop\" Must be a Action that is able to get and set the player's shop variable bool."); + RegisterTownNPCShop(npc, shopCheck, shopSet); + return null; + } + + case "SetNewShopVariable": + case "SendNPCShopAlert": + case "SendNPCAlert": + { + if (args.Length < 2 || args[1] is not int[] npcs) + return new ArgumentException("ERROR: The first argument to \"SetNewShopVariable\" must be an integer array of npc ids that should be alerted."); + if (args.Length != 3 || args[2] is not bool alreadySet) + return new ArgumentException("ERROR: The second argument to \"SetNewShopVariable\" Must be a bool that determines if the shop alert should show."); + CalamityGlobalNPC.SetNewShopVariable(npcs, alreadySet); + return null; + } + + case "BossHealthBoost": + case "GetBossHealthBoost": + case "BossHealthMultiplier": + case "GetBossHealthMultiplier": + return CalamityConfig.Instance.BossHealthBoost; + default: return new ArgumentException("ERROR: Invalid method name."); } diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index b629b91164..b9b8987d39 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -1013,10 +1013,10 @@ namespace CalamityMod { { "Terraria KingSlime", new List() { ItemType(), ItemType() } }, { "Terraria EyeofCthulhu", new List() { ItemType(), ItemType() } }, - { "Terraria EaterofWorldsHead", new List() { ItemType(), ItemType(), ItemType() } }, + { "Terraria EaterofWorlds", new List() { ItemType(), ItemType(), ItemType() } }, { "Terraria BrainofCthulhu", new List() { ItemType(), ItemType(), ItemType() } }, { "Terraria QueenBee", new List() { ItemType(), ItemType() } }, - { "Terraria SkeletronHead", new List() { ItemType(), ItemType() } }, + { "Terraria Skeletron", new List() { ItemType(), ItemType() } }, { "Terraria WallofFlesh", new List() { ItemType(), ItemType(), ItemType(), ItemType() } }, { "Terraria QueenSlimeBoss", new List() { ItemType(), ItemType() } }, { "Terraria TheTwins", new List() { ItemType(), ItemType(), ItemType() } }, @@ -1079,7 +1079,7 @@ namespace CalamityMod RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); diff --git a/NPCs/Abyss/BabyCannonballJellyfish.cs b/NPCs/Abyss/BabyCannonballJellyfish.cs index e63b7ff216..005e45e222 100644 --- a/NPCs/Abyss/BabyCannonballJellyfish.cs +++ b/NPCs/Abyss/BabyCannonballJellyfish.cs @@ -134,13 +134,13 @@ namespace CalamityMod.NPCs.Abyss spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/Abyss/BabyCannonballJellyfishGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/Abyss/BabyCannonballJellyfishGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(new Color(67, 218, 166)); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Abyss/BabyCannonballJellyfishGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override bool CheckDead() diff --git a/NPCs/Abyss/Bloatfish.cs b/NPCs/Abyss/Bloatfish.cs index 943294f0dd..44511aa4b1 100644 --- a/NPCs/Abyss/Bloatfish.cs +++ b/NPCs/Abyss/Bloatfish.cs @@ -106,15 +106,15 @@ namespace CalamityMod.NPCs.Abyss NPC.ai[0] = -1f; } } - int num258 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num259 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/Abyss/BobbitWormHead.cs b/NPCs/Abyss/BobbitWormHead.cs index 74d8388ecf..ae8cc1e6d5 100644 --- a/NPCs/Abyss/BobbitWormHead.cs +++ b/NPCs/Abyss/BobbitWormHead.cs @@ -18,7 +18,7 @@ namespace CalamityMod.NPCs.Abyss public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 4; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { //Preferably would have its head animated, but this will do for now CustomTexturePath = "CalamityMod/ExtraTextures/Bestiary/BobbitWorm_Bestiary" @@ -75,16 +75,16 @@ namespace CalamityMod.NPCs.Abyss if (NPC.ai[0] == 0f) { NPC.noTileCollide = true; - float num659 = 14f; - Vector2 vector79 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num660 = Main.npc[(int)NPC.ai[2]].Center.X - vector79.X; - float num661 = Main.npc[(int)NPC.ai[2]].Center.Y - vector79.Y; - float num662 = (float)Math.Sqrt((double)(num660 * num660 + num661 * num661)); - if (num662 < 11f + num659) + float launchSpeed = 14f; + Vector2 bobbitCenter = new Vector2(NPC.Center.X, NPC.Center.Y); + float segmentXDist = Main.npc[(int)NPC.ai[2]].Center.X - bobbitCenter.X; + float segmentYDist = Main.npc[(int)NPC.ai[2]].Center.Y - bobbitCenter.Y; + float segmentDistance = (float)Math.Sqrt((double)(segmentXDist * segmentXDist + segmentYDist * segmentYDist)); + if (segmentDistance < 11f + launchSpeed) { NPC.rotation = 0f; - NPC.velocity.X = num660; - NPC.velocity.Y = num661; + NPC.velocity.X = segmentXDist; + NPC.velocity.Y = segmentYDist; NPC.ai[1] += 1f; if (NPC.ai[1] >= 60f) { @@ -102,9 +102,9 @@ namespace CalamityMod.NPCs.Abyss } else { - num662 = num659 / num662; - NPC.velocity.X = num660 * num662; - NPC.velocity.Y = num661 * num662; + segmentDistance = launchSpeed / segmentDistance; + NPC.velocity.X = segmentXDist * segmentDistance; + NPC.velocity.Y = segmentYDist * segmentDistance; NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) - 1.57f; } } @@ -113,14 +113,14 @@ namespace CalamityMod.NPCs.Abyss NPC.noTileCollide = true; NPC.collideX = false; NPC.collideY = false; - float num663 = 16f; - Vector2 vector80 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num664 = Main.player[NPC.target].Center.X - vector80.X; - float num665 = Main.player[NPC.target].Center.Y - vector80.Y; - float num666 = (float)Math.Sqrt((double)(num664 * num664 + num665 * num665)); - num666 = num663 / num666; - NPC.velocity.X = num664 * num666; - NPC.velocity.Y = num665 * num666; + float returnSpeed = 16f; + Vector2 bobbitCenterReturn = new Vector2(NPC.Center.X, NPC.Center.Y); + float segmentReturnXDist = Main.player[NPC.target].Center.X - bobbitCenterReturn.X; + float segmentReturnYDist = Main.player[NPC.target].Center.Y - bobbitCenterReturn.Y; + float segmentReturnDistance = (float)Math.Sqrt((double)(segmentReturnXDist * segmentReturnXDist + segmentReturnYDist * segmentReturnYDist)); + segmentReturnDistance = returnSpeed / segmentReturnDistance; + NPC.velocity.X = segmentReturnXDist * segmentReturnDistance; + NPC.velocity.Y = segmentReturnYDist * segmentReturnDistance; NPC.ai[0] = 2f; NPC.rotation = (float)Math.Atan2((double)-(double)NPC.velocity.Y, (double)-(double)NPC.velocity.X) - 1.57f; } @@ -148,11 +148,11 @@ namespace CalamityMod.NPCs.Abyss NPC.noTileCollide = false; } } - Vector2 vector81 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num667 = Main.npc[(int)NPC.ai[2]].Center.X - vector81.X; - float num668 = Main.npc[(int)NPC.ai[2]].Center.Y - vector81.Y; - float num669 = (float)Math.Sqrt((double)(num667 * num667 + num668 * num668)); - if (num669 > 700f || NPC.collideX || NPC.collideY) + Vector2 bobbitCenterReturning = new Vector2(NPC.Center.X, NPC.Center.Y); + float segmentReturningXDist = Main.npc[(int)NPC.ai[2]].Center.X - bobbitCenterReturning.X; + float segmentReturningYDist = Main.npc[(int)NPC.ai[2]].Center.Y - bobbitCenterReturning.Y; + float segmentReturningDistance = (float)Math.Sqrt((double)(segmentReturningXDist * segmentReturningXDist + segmentReturningYDist * segmentReturningYDist)); + if (segmentReturningDistance > 700f || NPC.collideX || NPC.collideY) { NPC.noTileCollide = true; NPC.ai[0] = 0f; @@ -162,45 +162,45 @@ namespace CalamityMod.NPCs.Abyss else if (NPC.ai[0] == 3f) { NPC.noTileCollide = true; - float num671 = 16f; - float num672 = 0.25f; - Vector2 vector82 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num673 = Main.player[NPC.target].Center.X - vector82.X; - float num674 = Main.player[NPC.target].Center.Y - vector82.Y; - float num675 = (float)Math.Sqrt((double)(num673 * num673 + num674 * num674)); - num675 = num671 / num675; - num673 *= num675; - num674 *= num675; - if (NPC.velocity.X < num673) + float unusedSpeed = 16f; + float unusedAcceleration = 0.25f; + Vector2 unusedBobbitCenter = new Vector2(NPC.Center.X, NPC.Center.Y); + float unusedTargetXDist = Main.player[NPC.target].Center.X - unusedBobbitCenter.X; + float unusedTargetYDist = Main.player[NPC.target].Center.Y - unusedBobbitCenter.Y; + float unusedTargetDistance = (float)Math.Sqrt((double)(unusedTargetXDist * unusedTargetXDist + unusedTargetYDist * unusedTargetYDist)); + unusedTargetDistance = unusedSpeed / unusedTargetDistance; + unusedTargetXDist *= unusedTargetDistance; + unusedTargetYDist *= unusedTargetDistance; + if (NPC.velocity.X < unusedTargetXDist) { - NPC.velocity.X = NPC.velocity.X + num672; - if (NPC.velocity.X < 0f && num673 > 0f) + NPC.velocity.X = NPC.velocity.X + unusedAcceleration; + if (NPC.velocity.X < 0f && unusedTargetXDist > 0f) { - NPC.velocity.X = NPC.velocity.X + num672 * 2f; + NPC.velocity.X = NPC.velocity.X + unusedAcceleration * 2f; } } - else if (NPC.velocity.X > num673) + else if (NPC.velocity.X > unusedTargetXDist) { - NPC.velocity.X = NPC.velocity.X - num672; - if (NPC.velocity.X > 0f && num673 < 0f) + NPC.velocity.X = NPC.velocity.X - unusedAcceleration; + if (NPC.velocity.X > 0f && unusedTargetXDist < 0f) { - NPC.velocity.X = NPC.velocity.X - num672 * 2f; + NPC.velocity.X = NPC.velocity.X - unusedAcceleration * 2f; } } - if (NPC.velocity.Y < num674) + if (NPC.velocity.Y < unusedTargetYDist) { - NPC.velocity.Y = NPC.velocity.Y + num672; - if (NPC.velocity.Y < 0f && num674 > 0f) + NPC.velocity.Y = NPC.velocity.Y + unusedAcceleration; + if (NPC.velocity.Y < 0f && unusedTargetYDist > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num672 * 2f; + NPC.velocity.Y = NPC.velocity.Y + unusedAcceleration * 2f; } } - else if (NPC.velocity.Y > num674) + else if (NPC.velocity.Y > unusedTargetYDist) { - NPC.velocity.Y = NPC.velocity.Y - num672; - if (NPC.velocity.Y > 0f && num674 < 0f) + NPC.velocity.Y = NPC.velocity.Y - unusedAcceleration; + if (NPC.velocity.Y > 0f && unusedTargetYDist < 0f) { - NPC.velocity.Y = NPC.velocity.Y - num672 * 2f; + NPC.velocity.Y = NPC.velocity.Y - unusedAcceleration * 2f; } } NPC.rotation = (float)Math.Atan2((double)-(double)NPC.velocity.Y, (double)-(double)NPC.velocity.X); diff --git a/NPCs/Abyss/BoxJellyfish.cs b/NPCs/Abyss/BoxJellyfish.cs index 992182fc49..a345647128 100644 --- a/NPCs/Abyss/BoxJellyfish.cs +++ b/NPCs/Abyss/BoxJellyfish.cs @@ -18,7 +18,7 @@ namespace CalamityMod.NPCs.Abyss public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 4; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0); value.Position.Y += 10; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; } @@ -100,31 +100,31 @@ namespace CalamityMod.NPCs.Abyss NPC.ai[0] = 1f; } } - bool flag16 = false; + bool canAttack = false; NPC.TargetClosest(false); if (Main.player[NPC.target].wet && !Main.player[NPC.target].dead && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { - flag16 = true; + canAttack = true; } - if (flag16) + if (canAttack) { NPC.localAI[2] = 1f; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + 1.57f; NPC.velocity *= 0.975f; - float num263 = 0.8f; - if (NPC.velocity.X > -num263 && NPC.velocity.X < num263 && NPC.velocity.Y > -num263 && NPC.velocity.Y < num263) + float lungeThreshold = 0.8f; + if (NPC.velocity.X > -lungeThreshold && NPC.velocity.X < lungeThreshold && NPC.velocity.Y > -lungeThreshold && NPC.velocity.Y < lungeThreshold) { NPC.TargetClosest(true); - float num264 = CalamityWorld.death ? 12f : CalamityWorld.revenge ? 10f : 8f; - Vector2 vector31 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num265 = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2) - vector31.X; - float num266 = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2) - vector31.Y; - float num267 = (float)Math.Sqrt(num265 * num265 + num266 * num266); - num267 = num264 / num267; - num265 *= num267; - num266 *= num267; - NPC.velocity.X = num265; - NPC.velocity.Y = num266; + float lungeSpeed = CalamityWorld.death ? 12f : CalamityWorld.revenge ? 10f : 8f; + Vector2 npcPosition = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2) - npcPosition.X; + float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2) - npcPosition.Y; + float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); + targetDistance = lungeSpeed / targetDistance; + targetX *= targetDistance; + targetY *= targetDistance; + NPC.velocity.X = targetX; + NPC.velocity.Y = targetY; } } else @@ -152,15 +152,15 @@ namespace CalamityMod.NPCs.Abyss NPC.ai[0] = -1f; } } - int num268 = (int)(NPC.position.X + (NPC.width / 2)) / 16; - int num269 = (int)(NPC.position.Y + (NPC.height / 2)) / 16; - if (Main.tile[num268, num269 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num268, num269 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num268, num269 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/Abyss/CannonballJellyfish.cs b/NPCs/Abyss/CannonballJellyfish.cs index 1cefcf6e86..9ac54fa763 100644 --- a/NPCs/Abyss/CannonballJellyfish.cs +++ b/NPCs/Abyss/CannonballJellyfish.cs @@ -120,22 +120,22 @@ namespace CalamityMod.NPCs.Abyss if (boomTimer >= (dyingDuration - 20)) //home for the first 20 frames, not beyond that { - float num543 = player.position.X + (float)(player.width / 2); - float num544 = player.position.Y + (float)(player.height / 2); - float num550 = 30f; - Vector2 vector43 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num551 = num543 - vector43.X; - float num552 = num544 - vector43.Y; - float num553 = (float)Math.Sqrt((double)(num551 * num551 + num552 * num552)); - if (num553 < 100f) + float targetXDirection = player.position.X + (float)(player.width / 2); + float targetYDirection = player.position.Y + (float)(player.height / 2); + float homingSpeed = 30f; + Vector2 npcPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = targetXDirection - npcPosition.X; + float targetYDist = targetYDirection - npcPosition.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + if (targetDistance < 100f) { - num550 = 10f; //5 + homingSpeed = 10f; //5 } - num553 = num550 / num553; - num551 *= num553; - num552 *= num553; - NPC.velocity.X = (NPC.velocity.X * 5f + num551) / 6f; - NPC.velocity.Y = (NPC.velocity.Y * 5f + num552) / 6f; + targetDistance = homingSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + NPC.velocity.X = (NPC.velocity.X * 5f + targetXDist) / 6f; + NPC.velocity.Y = (NPC.velocity.Y * 5f + targetYDist) / 6f; NPC.velocity *= 0.9f; //slow it down a bit to be fair @@ -250,14 +250,14 @@ namespace CalamityMod.NPCs.Abyss } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); var texture = TextureAssets.Npc[NPC.type]; - Vector2 vector11 = new Vector2((float)(texture.Value.Width / 2), (float)(texture.Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(texture.Value.Width / 2), (float)(texture.Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; var glowTexture = ModContent.Request("CalamityMod/NPCs/Abyss/CannonballJellyfishGlow"); vector -= new Vector2((float)glowTexture.Value.Width, (float)(glowTexture.Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(new Color(67, 218, 166)); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Abyss/CannonballJellyfishGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } private void Explode() diff --git a/NPCs/Abyss/ColossalSquid.cs b/NPCs/Abyss/ColossalSquid.cs index 2fce5f13aa..c5677cd416 100644 --- a/NPCs/Abyss/ColossalSquid.cs +++ b/NPCs/Abyss/ColossalSquid.cs @@ -119,49 +119,49 @@ namespace CalamityMod.NPCs.Abyss } else { - Vector2 value29 = Main.player[NPC.target].Center - NPC.Center; - value29.Y -= (float)(Main.player[NPC.target].height / 4); - float num1310 = value29.Length(); - if (num1310 > 800f) + Vector2 targetDirection = Main.player[NPC.target].Center - NPC.Center; + targetDirection.Y -= (float)(Main.player[NPC.target].height / 4); + float targetDistance = targetDirection.Length(); + if (targetDistance > 800f) { NPC.ai[0] = 2f; } else { - Vector2 center26 = NPC.Center; - center26.X = Main.player[NPC.target].Center.X; - Vector2 vector230 = center26 - NPC.Center; - if (vector230.Length() > 8f && Collision.CanHit(NPC.Center, 1, 1, center26, 1, 1)) + Vector2 squidCenter = NPC.Center; + squidCenter.X = Main.player[NPC.target].Center.X; + Vector2 squidDirection = squidCenter - NPC.Center; + if (squidDirection.Length() > 8f && Collision.CanHit(NPC.Center, 1, 1, squidCenter, 1, 1)) { NPC.ai[0] = 3f; - NPC.ai[1] = center26.X; - NPC.ai[2] = center26.Y; - Vector2 center27 = NPC.Center; - center27.Y = Main.player[NPC.target].Center.Y; - if (vector230.Length() > 8f && Collision.CanHit(NPC.Center, 1, 1, center27, 1, 1) && Collision.CanHit(center27, 1, 1, Main.player[NPC.target].position, 1, 1)) + NPC.ai[1] = squidCenter.X; + NPC.ai[2] = squidCenter.Y; + Vector2 squidCenterAgain = NPC.Center; + squidCenterAgain.Y = Main.player[NPC.target].Center.Y; + if (squidDirection.Length() > 8f && Collision.CanHit(NPC.Center, 1, 1, squidCenterAgain, 1, 1) && Collision.CanHit(squidCenterAgain, 1, 1, Main.player[NPC.target].position, 1, 1)) { NPC.ai[0] = 3f; - NPC.ai[1] = center27.X; - NPC.ai[2] = center27.Y; + NPC.ai[1] = squidCenterAgain.X; + NPC.ai[2] = squidCenterAgain.Y; } } else { - center26 = NPC.Center; - center26.Y = Main.player[NPC.target].Center.Y; - if ((center26 - NPC.Center).Length() > 8f && Collision.CanHit(NPC.Center, 1, 1, center26, 1, 1)) + squidCenter = NPC.Center; + squidCenter.Y = Main.player[NPC.target].Center.Y; + if ((squidCenter - NPC.Center).Length() > 8f && Collision.CanHit(NPC.Center, 1, 1, squidCenter, 1, 1)) { NPC.ai[0] = 3f; - NPC.ai[1] = center26.X; - NPC.ai[2] = center26.Y; + NPC.ai[1] = squidCenter.X; + NPC.ai[2] = squidCenter.Y; } } if (NPC.ai[0] == 0f) { NPC.localAI[0] = 0f; - value29.Normalize(); - value29 *= 0.5f; - NPC.velocity += value29; + targetDirection.Normalize(); + targetDirection *= 0.5f; + NPC.velocity += targetDirection; NPC.ai[0] = 4f; NPC.ai[1] = 0f; } @@ -171,20 +171,20 @@ namespace CalamityMod.NPCs.Abyss else if (NPC.ai[0] == 1f) { NPC.rotation += (float)NPC.direction * 0.1f; - Vector2 value30 = Main.player[NPC.target].Top - NPC.Center; - float num1311 = value30.Length(); - float num1312 = 5f; - num1312 += num1311 / 100f; - int num1313 = 50; - value30.Normalize(); - value30 *= num1312; - NPC.velocity = (NPC.velocity * (float)(num1313 - 1) + value30) / (float)num1313; + Vector2 latchPosition = Main.player[NPC.target].Top - NPC.Center; + float latchDistance = latchPosition.Length(); + float latchLockSpeed = 5f; + latchLockSpeed += latchDistance / 100f; + int latchVelocity = 50; + latchPosition.Normalize(); + latchPosition *= latchLockSpeed; + NPC.velocity = (NPC.velocity * (float)(latchVelocity - 1) + latchPosition) / (float)latchVelocity; if (!Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) { NPC.ai[0] = 0f; NPC.ai[1] = 0f; } - if (num1311 < 160f && Main.player[NPC.target].active && !Main.player[NPC.target].dead && !clone) + if (latchDistance < 160f && Main.player[NPC.target].active && !Main.player[NPC.target].dead && !clone) { NPC.Center = Main.player[NPC.target].Top; NPC.velocity = Vector2.Zero; @@ -197,14 +197,14 @@ namespace CalamityMod.NPCs.Abyss { NPC.rotation = NPC.velocity.X * 0.05f; NPC.noTileCollide = true; - Vector2 value31 = Main.player[NPC.target].Center - NPC.Center; - float num1315 = value31.Length(); - float scaleFactor11 = 3f; - int num1316 = 3; - value31.Normalize(); - value31 *= scaleFactor11; - NPC.velocity = (NPC.velocity * (float)(num1316 - 1) + value31) / (float)num1316; - if (num1315 < 600f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + Vector2 lungeDirection = Main.player[NPC.target].Center - NPC.Center; + float lungeDistance = lungeDirection.Length(); + float lungeSpeed = 3f; + int lungeVelocity = 3; + lungeDirection.Normalize(); + lungeDirection *= lungeSpeed; + NPC.velocity = (NPC.velocity * (float)(lungeVelocity - 1) + lungeDirection) / (float)lungeVelocity; + if (lungeDistance < 600f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) { NPC.ai[0] = 0f; } @@ -212,20 +212,20 @@ namespace CalamityMod.NPCs.Abyss else if (NPC.ai[0] == 3f) { NPC.rotation = NPC.velocity.X * 0.05f; - Vector2 value32 = new Vector2(NPC.ai[1], NPC.ai[2]); - Vector2 value33 = value32 - NPC.Center; - float num1317 = value33.Length(); - float num1318 = 2f; - float num1319 = 3f; - value33.Normalize(); - value33 *= num1318; - NPC.velocity = (NPC.velocity * (num1319 - 1f) + value33) / num1319; + Vector2 otherLungePos = new Vector2(NPC.ai[1], NPC.ai[2]); + Vector2 otherLungeDirection = otherLungePos - NPC.Center; + float otherLungeDistance = otherLungeDirection.Length(); + float otherLungeSpeed = 2f; + float otherLungeVelocity = 3f; + otherLungeDirection.Normalize(); + otherLungeDirection *= otherLungeSpeed; + NPC.velocity = (NPC.velocity * (otherLungeVelocity - 1f) + otherLungeDirection) / otherLungeVelocity; if (NPC.collideX || NPC.collideY) { NPC.ai[0] = 4f; NPC.ai[1] = 0f; } - if (num1317 < num1318 || num1317 > 800f || Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + if (otherLungeDistance < otherLungeSpeed || otherLungeDistance > 800f || Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) { NPC.ai[0] = 0f; } @@ -241,20 +241,19 @@ namespace CalamityMod.NPCs.Abyss { NPC.velocity.Y = NPC.velocity.Y * -0.8f; } - Vector2 value34; + Vector2 slowDownDirection; if (NPC.velocity.X == 0f && NPC.velocity.Y == 0f) { - value34 = Main.player[NPC.target].Center - NPC.Center; - value34.Y -= (float)(Main.player[NPC.target].height / 4); - value34.Normalize(); - NPC.velocity = value34 * 0.1f; + slowDownDirection = Main.player[NPC.target].Center - NPC.Center; + slowDownDirection.Y -= (float)(Main.player[NPC.target].height / 4); + slowDownDirection.Normalize(); + NPC.velocity = slowDownDirection * 0.1f; } - float scaleFactor12 = 2f; - float num1320 = 20f; - value34 = NPC.velocity; - value34.Normalize(); - value34 *= scaleFactor12; - NPC.velocity = (NPC.velocity * (num1320 - 1f) + value34) / num1320; + float slowDownVelocity = 20f; + slowDownDirection = NPC.velocity; + slowDownDirection.Normalize(); + slowDownDirection *= 2f; + NPC.velocity = (NPC.velocity * (slowDownVelocity - 1f) + slowDownDirection) / slowDownVelocity; NPC.ai[1] += 1f; if (NPC.ai[1] > 180f) { @@ -269,31 +268,31 @@ namespace CalamityMod.NPCs.Abyss if (NPC.localAI[0] >= 5f && !Collision.SolidCollision(NPC.position - new Vector2(10f, 10f), NPC.width + 20, NPC.height + 20)) { NPC.localAI[0] = 0f; - Vector2 center28 = NPC.Center; - center28.X = Main.player[NPC.target].Center.X; - if (Collision.CanHit(NPC.Center, 1, 1, center28, 1, 1) && Collision.CanHit(NPC.Center, 1, 1, center28, 1, 1) && Collision.CanHit(Main.player[NPC.target].Center, 1, 1, center28, 1, 1)) + Vector2 slowDownCenter = NPC.Center; + slowDownCenter.X = Main.player[NPC.target].Center.X; + if (Collision.CanHit(NPC.Center, 1, 1, slowDownCenter, 1, 1) && Collision.CanHit(NPC.Center, 1, 1, slowDownCenter, 1, 1) && Collision.CanHit(Main.player[NPC.target].Center, 1, 1, slowDownCenter, 1, 1)) { NPC.ai[0] = 3f; - NPC.ai[1] = center28.X; - NPC.ai[2] = center28.Y; + NPC.ai[1] = slowDownCenter.X; + NPC.ai[2] = slowDownCenter.Y; } else { - center28 = NPC.Center; - center28.Y = Main.player[NPC.target].Center.Y; - if (Collision.CanHit(NPC.Center, 1, 1, center28, 1, 1) && Collision.CanHit(Main.player[NPC.target].Center, 1, 1, center28, 1, 1)) + slowDownCenter = NPC.Center; + slowDownCenter.Y = Main.player[NPC.target].Center.Y; + if (Collision.CanHit(NPC.Center, 1, 1, slowDownCenter, 1, 1) && Collision.CanHit(Main.player[NPC.target].Center, 1, 1, slowDownCenter, 1, 1)) { NPC.ai[0] = 3f; - NPC.ai[1] = center28.X; - NPC.ai[2] = center28.Y; + NPC.ai[1] = slowDownCenter.X; + NPC.ai[2] = slowDownCenter.Y; } } } } else if (NPC.ai[0] == 5f) { - Player player7 = Main.player[NPC.target]; - if (!player7.active || player7.dead || clone) + Player latchedTarget = Main.player[NPC.target]; + if (!latchedTarget.active || latchedTarget.dead || clone) { NPC.ai[0] = 0f; NPC.ai[1] = 0f; @@ -301,10 +300,10 @@ namespace CalamityMod.NPCs.Abyss } else { - NPC.Center = ((player7.gravDir == 1f) ? player7.Top : player7.Bottom) + new Vector2((float)(player7.direction * 4), 0f); - NPC.gfxOffY = player7.gfxOffY; + NPC.Center = ((latchedTarget.gravDir == 1f) ? latchedTarget.Top : latchedTarget.Bottom) + new Vector2((float)(latchedTarget.direction * 4), 0f); + NPC.gfxOffY = latchedTarget.gfxOffY; NPC.velocity = Vector2.Zero; - player7.AddBuff(BuffID.Obstructed, 59, true); + latchedTarget.AddBuff(BuffID.Obstructed, 59, true); } } NPC.rotation = NPC.velocity.X * 0.05f; @@ -436,20 +435,19 @@ namespace CalamityMod.NPCs.Abyss } NPC.rotation = NPC.velocity.X * 0.05f; NPC.velocity *= 0.975f; - float num263 = 2.5f; - if (NPC.velocity.X > -num263 && NPC.velocity.X < num263 && NPC.velocity.Y > -num263 && NPC.velocity.Y < num263) + float hitLungeThreshold = 2.5f; + if (NPC.velocity.X > -hitLungeThreshold && NPC.velocity.X < hitLungeThreshold && NPC.velocity.Y > -hitLungeThreshold && NPC.velocity.Y < hitLungeThreshold) { NPC.TargetClosest(true); - float num264 = 20f; - Vector2 vector31 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num265 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - vector31.X; - float num266 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - vector31.Y; - float num267 = (float)Math.Sqrt((double)(num265 * num265 + num266 * num266)); - num267 = num264 / num267; - num265 *= num267; - num266 *= num267; - NPC.velocity.X = num265; - NPC.velocity.Y = num266; + Vector2 hitLungePos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float hitLungeTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - hitLungePos.X; + float hitLungeTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - hitLungePos.Y; + float hitLungeTargetDist = (float)Math.Sqrt((double)(hitLungeTargetX * hitLungeTargetX + hitLungeTargetY * hitLungeTargetY)); + hitLungeTargetDist = 20f / hitLungeTargetDist; + hitLungeTargetX *= hitLungeTargetDist; + hitLungeTargetY *= hitLungeTargetDist; + NPC.velocity.X = hitLungeTargetX; + NPC.velocity.Y = hitLungeTargetY; return; } } @@ -482,15 +480,15 @@ namespace CalamityMod.NPCs.Abyss NPC.ai[0] = -1f; } } - int num268 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num269 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num268, num269 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num268, num269 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num268, num269 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/Abyss/Cuttlefish.cs b/NPCs/Abyss/Cuttlefish.cs index 6827b05362..6afe61c019 100644 --- a/NPCs/Abyss/Cuttlefish.cs +++ b/NPCs/Abyss/Cuttlefish.cs @@ -58,10 +58,10 @@ namespace CalamityMod.NPCs.Abyss public override void AI() { NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; - int num = 150; + int alphaControl = 150; if (NPC.ai[2] == 0f) { - NPC.alpha = num; + NPC.alpha = alphaControl; NPC.TargetClosest(true); if (!Main.player[NPC.target].dead && (Main.player[NPC.target].Center - NPC.Center).Length() < Main.player[NPC.target].Calamity().GetAbyssAggro(160f) && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) @@ -114,15 +114,15 @@ namespace CalamityMod.NPCs.Abyss NPC.ai[0] = -1f; } } - int num268 = (int)(NPC.position.X + (NPC.width / 2)) / 16; - int num269 = (int)(NPC.position.Y + (NPC.height / 2)) / 16; - if (Main.tile[num268, num269 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num268, num269 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num268, num269 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } @@ -141,7 +141,7 @@ namespace CalamityMod.NPCs.Abyss { if (NPC.alpha > 0) { - NPC.alpha -= num / 16; + NPC.alpha -= alphaControl / 16; if (NPC.alpha < 0) { NPC.alpha = 0; @@ -165,13 +165,13 @@ namespace CalamityMod.NPCs.Abyss } if (NPC.wet || NPC.noTileCollide) { - bool flag14 = false; + bool canAttack = false; NPC.TargetClosest(false); if (Main.player[NPC.target].wet && !Main.player[NPC.target].dead) { - flag14 = true; + canAttack = true; } - if (!flag14) + if (!canAttack) { if (!Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) { @@ -200,7 +200,7 @@ namespace CalamityMod.NPCs.Abyss } } } - if (flag14) + if (canAttack) { if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { @@ -279,15 +279,15 @@ namespace CalamityMod.NPCs.Abyss } } } - int num258 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num259 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount > 128) + int npcTileXAgain = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileYAgain = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileXAgain, npcTileYAgain - 1].LiquidAmount > 128) { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[npcTileXAgain, npcTileYAgain + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[npcTileXAgain, npcTileYAgain + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/Abyss/DevilFish.cs b/NPCs/Abyss/DevilFish.cs index e4d7cc01cd..546982c7ab 100644 --- a/NPCs/Abyss/DevilFish.cs +++ b/NPCs/Abyss/DevilFish.cs @@ -28,7 +28,7 @@ namespace CalamityMod.NPCs.Abyss public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 16; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { PortraitPositionXOverride = 5f }; @@ -112,17 +112,17 @@ namespace CalamityMod.NPCs.Abyss if (NPC.wet) { - bool flag14 = brokenMask; + bool canAttack = brokenMask; NPC.TargetClosest(false); if (player.statLife <= player.statLifeMax2 / 4) { - flag14 = true; + canAttack = true; } - if ((!player.wet || player.dead || !Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) && flag14) + if ((!player.wet || player.dead || !Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) && canAttack) { - flag14 = false; + canAttack = false; } - if (!flag14) + if (!canAttack) { if (NPC.collideX) { @@ -147,7 +147,7 @@ namespace CalamityMod.NPCs.Abyss } } } - if (flag14) + if (canAttack) { NPC.TargetClosest(true); NPC.velocity.X = NPC.velocity.X + (float)NPC.direction * (CalamityWorld.death ? 0.5f : CalamityWorld.revenge ? 0.375f : 0.25f) * speedBoost; @@ -194,15 +194,15 @@ namespace CalamityMod.NPCs.Abyss } } } - int num258 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num259 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/Abyss/DevilFishAlt.cs b/NPCs/Abyss/DevilFishAlt.cs index 68a796f6ce..44060ffa94 100644 --- a/NPCs/Abyss/DevilFishAlt.cs +++ b/NPCs/Abyss/DevilFishAlt.cs @@ -23,12 +23,7 @@ namespace CalamityMod.NPCs.Abyss public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 16; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() - { - PortraitPositionXOverride = 5f - }; - value.Position.X += 30f; - NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; + this.HideFromBestiary(); } public override void SetDefaults() @@ -47,7 +42,7 @@ namespace CalamityMod.NPCs.Abyss NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath1; NPC.knockBackResist = 0.85f; - Banner = NPC.type; + Banner = ModContent.NPCType(); BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToSickness = true; @@ -56,14 +51,6 @@ namespace CalamityMod.NPCs.Abyss SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] - { - new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.DevilFishAlt") - }); - } - public override void SendExtraAI(BinaryWriter writer) { writer.Write(brokenMask); @@ -107,17 +94,17 @@ namespace CalamityMod.NPCs.Abyss if (NPC.wet) { - bool flag14 = brokenMask; + bool canAttack = brokenMask; NPC.TargetClosest(false); if (player.statLife <= player.statLifeMax2 / 4) { - flag14 = true; + canAttack = true; } - if ((!player.wet || player.dead || !Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) && flag14) + if ((!player.wet || player.dead || !Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) && canAttack) { - flag14 = false; + canAttack = false; } - if (!flag14) + if (!canAttack) { if (NPC.collideX) { @@ -142,7 +129,7 @@ namespace CalamityMod.NPCs.Abyss } } } - if (flag14) + if (canAttack) { NPC.TargetClosest(true); NPC.velocity.X = NPC.velocity.X + (float)NPC.direction * (CalamityWorld.death ? 0.5f : CalamityWorld.revenge ? 0.375f : 0.25f) * speedBoost; @@ -189,15 +176,15 @@ namespace CalamityMod.NPCs.Abyss } } } - int num258 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num259 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/Abyss/EidolonWyrmBody.cs b/NPCs/Abyss/EidolonWyrmBody.cs index 133c3a2d6b..c1a8c86b08 100644 --- a/NPCs/Abyss/EidolonWyrmBody.cs +++ b/NPCs/Abyss/EidolonWyrmBody.cs @@ -82,39 +82,39 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDirection = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDirection = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDirection = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDirection = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDirection, (double)targetXDirection) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDirection *= targetDistance; + targetYDirection *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDirection; + NPC.position.Y = NPC.position.Y + targetYDirection; - if (num191 < 0f) + if (targetXDirection < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetXDirection > 0f) NPC.spriteDirection = 1; } } @@ -127,13 +127,13 @@ namespace CalamityMod.NPCs.Abyss spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmBodyGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmBodyGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmBodyGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override bool CheckActive() diff --git a/NPCs/Abyss/EidolonWyrmBodyAlt.cs b/NPCs/Abyss/EidolonWyrmBodyAlt.cs index f50ca655ac..2cbfd9e8f6 100644 --- a/NPCs/Abyss/EidolonWyrmBodyAlt.cs +++ b/NPCs/Abyss/EidolonWyrmBodyAlt.cs @@ -82,39 +82,39 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDirection = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDirection = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDirection = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDirection = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDirection, (double)targetXDirection) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDirection *= targetDistance; + targetYDirection *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDirection; + NPC.position.Y = NPC.position.Y + targetYDirection; - if (num191 < 0f) + if (targetXDirection < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetXDirection > 0f) NPC.spriteDirection = 1; } } @@ -127,13 +127,13 @@ namespace CalamityMod.NPCs.Abyss spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmBodyAltGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmBodyAltGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Color.White); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmBodyAltGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override bool CheckActive() diff --git a/NPCs/Abyss/EidolonWyrmHead.cs b/NPCs/Abyss/EidolonWyrmHead.cs index e700283a62..3746bc643e 100644 --- a/NPCs/Abyss/EidolonWyrmHead.cs +++ b/NPCs/Abyss/EidolonWyrmHead.cs @@ -36,7 +36,7 @@ namespace CalamityMod.NPCs.Abyss public override void SetStaticDefaults() { - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { CustomTexturePath = "CalamityMod/ExtraTextures/Bestiary/EidolonWyrm_Bestiary", PortraitPositionXOverride = 40 @@ -145,12 +145,12 @@ namespace CalamityMod.NPCs.Abyss if (!TailSpawned && NPC.ai[0] == 0f) { int Previous = NPC.whoAmI; - for (int num36 = 0; num36 < maxLength; num36++) + for (int segments = 0; segments < maxLength; segments++) { int lol; - if (num36 >= 0 && num36 < minLength) + if (segments >= 0 && segments < minLength) { - if (num36 % 2 == 0) + 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); } @@ -208,167 +208,167 @@ namespace CalamityMod.NPCs.Abyss NPC.active = false; } - float num188 = speed; - float num189 = turnSpeed; - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float currentSpeed = speed; + float currentTurnSpeed = turnSpeed; + Vector2 segmentPosition = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); if (patrolSpot == Vector2.Zero) patrolSpot = Main.player[NPC.target].Center; - float num191 = detectsPlayer ? Main.player[NPC.target].Center.X : patrolSpot.X; - float num192 = detectsPlayer ? Main.player[NPC.target].Center.Y : patrolSpot.Y; + float targetXDirection = detectsPlayer ? Main.player[NPC.target].Center.X : patrolSpot.X; + float targetYDirection = detectsPlayer ? Main.player[NPC.target].Center.Y : patrolSpot.Y; if (!detectsPlayer) { - num192 += 800; - if (Math.Abs(NPC.Center.X - num191) < 400f) //500 + targetYDirection += 800; + if (Math.Abs(NPC.Center.X - targetXDirection) < 400f) //500 { if (NPC.velocity.X > 0f) { - num191 += 500f; + targetXDirection += 500f; } else { - num191 -= 500f; + targetXDirection -= 500f; } } } else { - num188 = 7.5f; - num189 = 0.125f; + currentSpeed = 7.5f; + currentTurnSpeed = 0.125f; if (!Main.player[NPC.target].wet) { - num188 = 15f; - num189 = 0.25f; + currentSpeed = 15f; + currentTurnSpeed = 0.25f; } if (adultWyrmAlive) { if (!Main.player[NPC.target].Calamity().ZoneAbyssLayer4) { - num188 = 22.5f; - num189 = 0.375f; + currentSpeed = 22.5f; + currentTurnSpeed = 0.375f; } } } - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = NPC.velocity.Length(); - if (num50 > 0f) + float maxCurrentSpeed = currentSpeed * 1.3f; + float minCurrentSpeed = currentSpeed * 0.7f; + float speedComparison = NPC.velocity.Length(); + if (speedComparison > 0f) { - if (num50 > num48) + if (speedComparison > maxCurrentSpeed) { NPC.velocity.Normalize(); - NPC.velocity *= num48; + NPC.velocity *= maxCurrentSpeed; } - else if (num50 < num49) + else if (speedComparison < minCurrentSpeed) { NPC.velocity.Normalize(); - NPC.velocity *= num49; + NPC.velocity *= minCurrentSpeed; } } - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - float num196 = System.Math.Abs(num191); - float num197 = System.Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; - if ((NPC.velocity.X > 0f && num191 > 0f) || (NPC.velocity.X < 0f && num191 < 0f) || (NPC.velocity.Y > 0f && num192 > 0f) || (NPC.velocity.Y < 0f && num192 < 0f)) + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + float absolutetargetX = System.Math.Abs(targetXDirection); + float absolutetargetY = System.Math.Abs(targetYDirection); + float timeToReachTarget = currentSpeed / targetDistance; + targetXDirection *= timeToReachTarget; + targetYDirection *= timeToReachTarget; + if ((NPC.velocity.X > 0f && targetXDirection > 0f) || (NPC.velocity.X < 0f && targetXDirection < 0f) || (NPC.velocity.Y > 0f && targetYDirection > 0f) || (NPC.velocity.Y < 0f && targetYDirection < 0f)) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetXDirection) { - NPC.velocity.X = NPC.velocity.X + num189; + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed; } else { - if (NPC.velocity.X > num191) + if (NPC.velocity.X > targetXDirection) { - NPC.velocity.X = NPC.velocity.X - num189; + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed; } } - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y + num189; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed; } else { - if (NPC.velocity.Y > num192) + if (NPC.velocity.Y > targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y - num189; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed; } } - if ((double)System.Math.Abs(num192) < (double)num188 * 0.2 && ((NPC.velocity.X > 0f && num191 < 0f) || (NPC.velocity.X < 0f && num191 > 0f))) + if ((double)System.Math.Abs(targetYDirection) < (double)currentSpeed * 0.2 && ((NPC.velocity.X > 0f && targetXDirection < 0f) || (NPC.velocity.X < 0f && targetXDirection > 0f))) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num189 * 2f; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed * 2f; } else { - NPC.velocity.Y = NPC.velocity.Y - num189 * 2f; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed * 2f; } } - if ((double)System.Math.Abs(num191) < (double)num188 * 0.2 && ((NPC.velocity.Y > 0f && num192 < 0f) || (NPC.velocity.Y < 0f && num192 > 0f))) + if ((double)System.Math.Abs(targetXDirection) < (double)currentSpeed * 0.2 && ((NPC.velocity.Y > 0f && targetYDirection < 0f) || (NPC.velocity.Y < 0f && targetYDirection > 0f))) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num189 * 2f; //changed from 2 + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed * 2f; //changed from 2 } else { - NPC.velocity.X = NPC.velocity.X - num189 * 2f; //changed from 2 + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed * 2f; //changed from 2 } } } else { - if (num196 > num197) + if (absolutetargetX > absolutetargetY) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetXDirection) { - NPC.velocity.X = NPC.velocity.X + num189 * 1.1f; //changed from 1.1 + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed * 1.1f; //changed from 1.1 } - else if (NPC.velocity.X > num191) + else if (NPC.velocity.X > targetXDirection) { - NPC.velocity.X = NPC.velocity.X - num189 * 1.1f; //changed from 1.1 + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed * 1.1f; //changed from 1.1 } - if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)num188 * 0.5) + if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)currentSpeed * 0.5) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num189; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed; } else { - NPC.velocity.Y = NPC.velocity.Y - num189; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed; } } } else { - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y + num189 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed * 1.1f; } - else if (NPC.velocity.Y > num192) + else if (NPC.velocity.Y > targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y - num189 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed * 1.1f; } - if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)num188 * 0.5) + if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)currentSpeed * 0.5) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num189; + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed; } else { - NPC.velocity.X = NPC.velocity.X - num189; + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed; } } } @@ -390,18 +390,18 @@ namespace CalamityMod.NPCs.Abyss Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= 40f; } @@ -423,13 +423,13 @@ namespace CalamityMod.NPCs.Abyss spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmHeadGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmHeadGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Color.White); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmHeadGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override float SpawnChance(NPCSpawnInfo spawnInfo) diff --git a/NPCs/Abyss/EidolonWyrmTail.cs b/NPCs/Abyss/EidolonWyrmTail.cs index e1f8c42a2a..463c697b83 100644 --- a/NPCs/Abyss/EidolonWyrmTail.cs +++ b/NPCs/Abyss/EidolonWyrmTail.cs @@ -82,39 +82,39 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDirection = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDirection = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDirection = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDirection = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDirection, (double)targetXDirection) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDirection *= targetDistance; + targetYDirection *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDirection; + NPC.position.Y = NPC.position.Y + targetYDirection; - if (num191 < 0f) + if (targetXDirection < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetXDirection > 0f) NPC.spriteDirection = 1; } } @@ -127,13 +127,13 @@ namespace CalamityMod.NPCs.Abyss spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmTailGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmTailGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmTailGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override bool CheckActive() diff --git a/NPCs/Abyss/GiantSquid.cs b/NPCs/Abyss/GiantSquid.cs index 5edb35afd8..9806b3eafc 100644 --- a/NPCs/Abyss/GiantSquid.cs +++ b/NPCs/Abyss/GiantSquid.cs @@ -125,20 +125,20 @@ namespace CalamityMod.NPCs.Abyss { NPC.localAI[2] = 1f; NPC.velocity *= 0.975f; - float num263 = 1.6f; - if (NPC.velocity.X > -num263 && NPC.velocity.X < num263 && NPC.velocity.Y > -num263 && NPC.velocity.Y < num263) + float lungeThreshold = 1.6f; + if (NPC.velocity.X > -lungeThreshold && NPC.velocity.X < lungeThreshold && NPC.velocity.Y > -lungeThreshold && NPC.velocity.Y < lungeThreshold) { NPC.TargetClosest(true); - float num264 = CalamityWorld.death ? 24f : CalamityWorld.revenge ? 20f : 16f; - Vector2 vector31 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num265 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - vector31.X; - float num266 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - vector31.Y; - float num267 = (float)Math.Sqrt((double)(num265 * num265 + num266 * num266)); - num267 = num264 / num267; - num265 *= num267; - num266 *= num267; - NPC.velocity.X = num265; - NPC.velocity.Y = num266; + float lungeSpeed = CalamityWorld.death ? 24f : CalamityWorld.revenge ? 20f : 16f; + Vector2 lungeNPCPos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float lungeTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - lungeNPCPos.X; + float lungeTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - lungeNPCPos.Y; + float lungeTargetDist = (float)Math.Sqrt((double)(lungeTargetX * lungeTargetX + lungeTargetY * lungeTargetY)); + lungeTargetDist = lungeSpeed / lungeTargetDist; + lungeTargetX *= lungeTargetDist; + lungeTargetY *= lungeTargetDist; + NPC.velocity.X = lungeTargetX; + NPC.velocity.Y = lungeTargetY; return; } } @@ -166,15 +166,15 @@ namespace CalamityMod.NPCs.Abyss NPC.ai[0] = -1f; } } - int num268 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num269 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num268, num269 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num268, num269 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num268, num269 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/Abyss/GulperEelBody.cs b/NPCs/Abyss/GulperEelBody.cs index 910f9d5539..8fab0776de 100644 --- a/NPCs/Abyss/GulperEelBody.cs +++ b/NPCs/Abyss/GulperEelBody.cs @@ -87,39 +87,39 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDirection = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDirection = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDirection = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDirection = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDirection, (double)targetXDirection) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDirection *= targetDistance; + targetYDirection *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDirection; + NPC.position.Y = NPC.position.Y + targetYDirection; - if (num191 < 0f) + if (targetXDirection < 0f) NPC.spriteDirection = 1; - else if (num191 > 0f) + else if (targetXDirection > 0f) NPC.spriteDirection = -1; } } @@ -132,13 +132,13 @@ namespace CalamityMod.NPCs.Abyss spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelBodyGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelBodyGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Color.White); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelBodyGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override bool CheckActive() diff --git a/NPCs/Abyss/GulperEelBodyAlt.cs b/NPCs/Abyss/GulperEelBodyAlt.cs index faf194b425..292bae06f1 100644 --- a/NPCs/Abyss/GulperEelBodyAlt.cs +++ b/NPCs/Abyss/GulperEelBodyAlt.cs @@ -87,39 +87,39 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDirection = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDirection = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDirection = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDirection = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDirection, (double)targetXDirection) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDirection *= targetDistance; + targetYDirection *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDirection; + NPC.position.Y = NPC.position.Y + targetYDirection; - if (num191 < 0f) + if (targetXDirection < 0f) NPC.spriteDirection = 1; - else if (num191 > 0f) + else if (targetXDirection > 0f) NPC.spriteDirection = -1; } } @@ -132,13 +132,13 @@ namespace CalamityMod.NPCs.Abyss spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelBodyAltGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelBodyAltGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelBodyAltGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override bool CheckActive() diff --git a/NPCs/Abyss/GulperEelHead.cs b/NPCs/Abyss/GulperEelHead.cs index 511e42fc02..98a75fac66 100644 --- a/NPCs/Abyss/GulperEelHead.cs +++ b/NPCs/Abyss/GulperEelHead.cs @@ -27,7 +27,7 @@ namespace CalamityMod.NPCs.Abyss public override void SetStaticDefaults() { - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.75f, CustomTexturePath = "CalamityMod/ExtraTextures/Bestiary/GulperEel_Bestiary", @@ -123,12 +123,12 @@ namespace CalamityMod.NPCs.Abyss if (!TailSpawned && NPC.ai[0] == 0f) { int Previous = NPC.whoAmI; - for (int num36 = 0; num36 < maxLength; num36++) + for (int segments = 0; segments < maxLength; segments++) { int lol; - if (num36 >= 0 && num36 < minLength) + if (segments >= 0 && segments < minLength) { - if (num36 == 0) + 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); } @@ -173,154 +173,154 @@ namespace CalamityMod.NPCs.Abyss NPC.active = false; } - float num188 = speed; - float num189 = turnSpeed; - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + 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); if (patrolSpot == Vector2.Zero) patrolSpot = Main.player[NPC.target].Center; - float num191 = detectsPlayer ? Main.player[NPC.target].Center.X : patrolSpot.X; - float num192 = detectsPlayer ? Main.player[NPC.target].Center.Y : patrolSpot.Y; + float targetXDirection = detectsPlayer ? Main.player[NPC.target].Center.X : patrolSpot.X; + float targetYDirection = detectsPlayer ? Main.player[NPC.target].Center.Y : patrolSpot.Y; if (!detectsPlayer) { - num192 += 500; - if (Math.Abs(NPC.Center.X - num191) < 300f) //500 + targetYDirection += 500; + if (Math.Abs(NPC.Center.X - targetXDirection) < 300f) //500 { if (NPC.velocity.X > 0f) { - num191 += 400f; + targetXDirection += 400f; } else { - num191 -= 400f; + targetXDirection -= 400f; } } } else { - num188 *= 1.5f; - num189 *= 1.5f; + currentSpeed *= 1.5f; + currentTurnSpeed *= 1.5f; } - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = NPC.velocity.Length(); - if (num50 > 0f) + float maxCurrentSpeed = currentSpeed * 1.3f; + float minCurrentSpeed = currentSpeed * 0.7f; + float speedCompare = NPC.velocity.Length(); + if (speedCompare > 0f) { - if (num50 > num48) + if (speedCompare > maxCurrentSpeed) { NPC.velocity.Normalize(); - NPC.velocity *= num48; + NPC.velocity *= maxCurrentSpeed; } - else if (num50 < num49) + else if (speedCompare < minCurrentSpeed) { NPC.velocity.Normalize(); - NPC.velocity *= num49; + NPC.velocity *= minCurrentSpeed; } } - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - float num196 = System.Math.Abs(num191); - float num197 = System.Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; - if ((NPC.velocity.X > 0f && num191 > 0f) || (NPC.velocity.X < 0f && num191 < 0f) || (NPC.velocity.Y > 0f && num192 > 0f) || (NPC.velocity.Y < 0f && num192 < 0f)) + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + float absoluteTargetX = System.Math.Abs(targetXDirection); + float absoluteTargetY = System.Math.Abs(targetYDirection); + float timeToReachTarget = currentSpeed / targetDistance; + targetXDirection *= timeToReachTarget; + targetYDirection *= timeToReachTarget; + if ((NPC.velocity.X > 0f && targetXDirection > 0f) || (NPC.velocity.X < 0f && targetXDirection < 0f) || (NPC.velocity.Y > 0f && targetYDirection > 0f) || (NPC.velocity.Y < 0f && targetYDirection < 0f)) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetXDirection) { - NPC.velocity.X = NPC.velocity.X + num189; + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed; } else { - if (NPC.velocity.X > num191) + if (NPC.velocity.X > targetXDirection) { - NPC.velocity.X = NPC.velocity.X - num189; + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed; } } - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y + num189; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed; } else { - if (NPC.velocity.Y > num192) + if (NPC.velocity.Y > targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y - num189; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed; } } - if ((double)System.Math.Abs(num192) < (double)num188 * 0.2 && ((NPC.velocity.X > 0f && num191 < 0f) || (NPC.velocity.X < 0f && num191 > 0f))) + if ((double)System.Math.Abs(targetYDirection) < (double)currentSpeed * 0.2 && ((NPC.velocity.X > 0f && targetXDirection < 0f) || (NPC.velocity.X < 0f && targetXDirection > 0f))) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num189 * 2f; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed * 2f; } else { - NPC.velocity.Y = NPC.velocity.Y - num189 * 2f; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed * 2f; } } - if ((double)System.Math.Abs(num191) < (double)num188 * 0.2 && ((NPC.velocity.Y > 0f && num192 < 0f) || (NPC.velocity.Y < 0f && num192 > 0f))) + if ((double)System.Math.Abs(targetXDirection) < (double)currentSpeed * 0.2 && ((NPC.velocity.Y > 0f && targetYDirection < 0f) || (NPC.velocity.Y < 0f && targetYDirection > 0f))) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num189 * 2f; //changed from 2 + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed * 2f; //changed from 2 } else { - NPC.velocity.X = NPC.velocity.X - num189 * 2f; //changed from 2 + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed * 2f; //changed from 2 } } } else { - if (num196 > num197) + if (absoluteTargetX > absoluteTargetY) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetXDirection) { - NPC.velocity.X = NPC.velocity.X + num189 * 1.1f; //changed from 1.1 + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed * 1.1f; //changed from 1.1 } - else if (NPC.velocity.X > num191) + else if (NPC.velocity.X > targetXDirection) { - NPC.velocity.X = NPC.velocity.X - num189 * 1.1f; //changed from 1.1 + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed * 1.1f; //changed from 1.1 } - if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)num188 * 0.5) + if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)currentSpeed * 0.5) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num189; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed; } else { - NPC.velocity.Y = NPC.velocity.Y - num189; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed; } } } else { - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y + num189 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed * 1.1f; } - else if (NPC.velocity.Y > num192) + else if (NPC.velocity.Y > targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y - num189 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed * 1.1f; } - if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)num188 * 0.5) + if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)currentSpeed * 0.5) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num189; + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed; } else { - NPC.velocity.X = NPC.velocity.X - num189; + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed; } } } @@ -345,13 +345,13 @@ namespace CalamityMod.NPCs.Abyss spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelHeadGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelHeadGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelHeadGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override float SpawnChance(NPCSpawnInfo spawnInfo) diff --git a/NPCs/Abyss/GulperEelTail.cs b/NPCs/Abyss/GulperEelTail.cs index bab56e99fc..7381e75b4f 100644 --- a/NPCs/Abyss/GulperEelTail.cs +++ b/NPCs/Abyss/GulperEelTail.cs @@ -87,39 +87,39 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDirection = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDirection = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDirection = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDirection = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDirection, (double)targetXDirection) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDirection *= targetDistance; + targetYDirection *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDirection; + NPC.position.Y = NPC.position.Y + targetYDirection; - if (num191 < 0f) + if (targetXDirection < 0f) NPC.spriteDirection = 1; - else if (num191 > 0f) + else if (targetXDirection > 0f) NPC.spriteDirection = -1; } } @@ -132,13 +132,13 @@ namespace CalamityMod.NPCs.Abyss spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelTailGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelTailGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelTailGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override bool CheckActive() diff --git a/NPCs/Abyss/LuminousCorvina.cs b/NPCs/Abyss/LuminousCorvina.cs index d9f0601f21..d0b2b2bc6d 100644 --- a/NPCs/Abyss/LuminousCorvina.cs +++ b/NPCs/Abyss/LuminousCorvina.cs @@ -91,13 +91,13 @@ namespace CalamityMod.NPCs.Abyss NPC.chaseable = hasBeenHit; if (NPC.wet) { - bool flag14 = hasBeenHit; + bool canAttack = hasBeenHit; NPC.TargetClosest(false); if ((Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && ((NPC.Center.X - 15f < Main.player[NPC.target].Center.X && NPC.direction == 1) || (NPC.Center.X + 15f > Main.player[NPC.target].Center.X && NPC.direction == -1))) || (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, - Main.player[NPC.target].width, Main.player[NPC.target].height) && flag14)) + Main.player[NPC.target].width, Main.player[NPC.target].height) && canAttack)) { ++screamTimer; @@ -122,7 +122,7 @@ namespace CalamityMod.NPCs.Abyss return; } } - if ((!Main.player[NPC.target].wet || Main.player[NPC.target].dead) && flag14) + if ((!Main.player[NPC.target].wet || Main.player[NPC.target].dead) && canAttack) { } if (NPC.collideX) @@ -168,15 +168,15 @@ namespace CalamityMod.NPCs.Abyss NPC.ai[0] = -1f; } } - int num258 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num259 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/Abyss/MirageJelly.cs b/NPCs/Abyss/MirageJelly.cs index 62c57bd5e2..8005102f35 100644 --- a/NPCs/Abyss/MirageJelly.cs +++ b/NPCs/Abyss/MirageJelly.cs @@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.Abyss public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 7; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { PortraitPositionYOverride = 20 }; @@ -107,41 +107,41 @@ namespace CalamityMod.NPCs.Abyss { teleporting = false; NPC.TargetClosest(true); - int num1249 = 0; - int num1250; - int num1251; + int teleportTries = 0; + int teleportTileX; + int teleportTileY; while (true) { - num1249++; - num1250 = (int)player.Center.X / 16; - num1251 = (int)player.Center.Y / 16; + teleportTries++; + teleportTileX = (int)player.Center.X / 16; + teleportTileY = (int)player.Center.Y / 16; int min = 6; int max = 9; if (Main.rand.NextBool()) - num1250 += Main.rand.Next(min, max); + teleportTileX += Main.rand.Next(min, max); else - num1250 -= Main.rand.Next(min, max); + teleportTileX -= Main.rand.Next(min, max); min = 11; max = 26; - num1251 += Main.rand.Next(min, max); + teleportTileY += Main.rand.Next(min, max); - if (!WorldGen.SolidTile(num1250, num1251) && Collision.CanHit(new Vector2((float)(num1250 * 16), (float)(num1251 * 16)), 1, 1, player.position, player.width, player.height) && - Main.tile[num1250, num1251].LiquidAmount > 204) + if (!WorldGen.SolidTile(teleportTileX, teleportTileY) && Collision.CanHit(new Vector2((float)(teleportTileX * 16), (float)(teleportTileY * 16)), 1, 1, player.position, player.width, player.height) && + Main.tile[teleportTileX, teleportTileY].LiquidAmount > 204) { break; } - if (num1249 > 100) + if (teleportTries > 100) { goto Block; } } NPC.ai[0] = 1f; - NPC.ai[1] = (float)num1250; - NPC.ai[2] = (float)num1251; + NPC.ai[1] = (float)teleportTileX; + NPC.ai[2] = (float)teleportTileY; NPC.netUpdate = true; Block: ; diff --git a/NPCs/Abyss/MorayEel.cs b/NPCs/Abyss/MorayEel.cs index 9e102e33bc..68155b0c9c 100644 --- a/NPCs/Abyss/MorayEel.cs +++ b/NPCs/Abyss/MorayEel.cs @@ -16,7 +16,7 @@ namespace CalamityMod.NPCs.Abyss public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 6; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.75f, PortraitPositionXOverride = 0f, diff --git a/NPCs/Abyss/OarfishBody.cs b/NPCs/Abyss/OarfishBody.cs index b1a9017a0a..71dad1d575 100644 --- a/NPCs/Abyss/OarfishBody.cs +++ b/NPCs/Abyss/OarfishBody.cs @@ -84,39 +84,39 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDirection = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDirection = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDirection = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDirection = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDirection, (double)targetXDirection) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDirection *= targetDistance; + targetYDirection *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDirection; + NPC.position.Y = NPC.position.Y + targetYDirection; - if (num191 < 0f) + if (targetXDirection < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetXDirection > 0f) NPC.spriteDirection = 1; } } diff --git a/NPCs/Abyss/OarfishHead.cs b/NPCs/Abyss/OarfishHead.cs index 66af36cbd8..2f17785853 100644 --- a/NPCs/Abyss/OarfishHead.cs +++ b/NPCs/Abyss/OarfishHead.cs @@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.Abyss public override void SetStaticDefaults() { - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { CustomTexturePath = "CalamityMod/ExtraTextures/Bestiary/Oarfish_Bestiary", PortraitPositionYOverride = 20 @@ -116,10 +116,10 @@ namespace CalamityMod.NPCs.Abyss if (!TailSpawned && NPC.ai[0] == 0f) { int Previous = NPC.whoAmI; - for (int num36 = 0; num36 < maxLength; num36++) + for (int segments = 0; segments < maxLength; segments++) { int lol; - if (num36 >= 0 && num36 < minLength) + if (segments >= 0 && segments < minLength) { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); } @@ -153,154 +153,154 @@ namespace CalamityMod.NPCs.Abyss if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f) NPC.active = false; - float num188 = speed; - float num189 = turnSpeed; - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + 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); if (patrolSpot == Vector2.Zero) patrolSpot = Main.player[NPC.target].Center; - float num191 = detectsPlayer ? Main.player[NPC.target].Center.X : patrolSpot.X; - float num192 = detectsPlayer ? Main.player[NPC.target].Center.Y : patrolSpot.Y; + float targetXDirection = detectsPlayer ? Main.player[NPC.target].Center.X : patrolSpot.X; + float targetYDirection = detectsPlayer ? Main.player[NPC.target].Center.Y : patrolSpot.Y; if (!detectsPlayer) { - num192 += 300; - if (Math.Abs(NPC.Center.X - num191) < 250f) //500 + targetYDirection += 300; + if (Math.Abs(NPC.Center.X - targetXDirection) < 250f) //500 { if (NPC.velocity.X > 0f) { - num191 += 300f; + targetXDirection += 300f; } else { - num191 -= 300f; + targetXDirection -= 300f; } } } else { - num188 *= 1.5f; - num189 *= 1.5f; + currentSpeed *= 1.5f; + currentTurnSpeed *= 1.5f; } - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = NPC.velocity.Length(); - if (num50 > 0f) + float maxCurrentSpeed = currentSpeed * 1.3f; + float minCurrentSpeed = currentSpeed * 0.7f; + float currentSpeedCheck = NPC.velocity.Length(); + if (currentSpeedCheck > 0f) { - if (num50 > num48) + if (currentSpeedCheck > maxCurrentSpeed) { NPC.velocity.Normalize(); - NPC.velocity *= num48; + NPC.velocity *= maxCurrentSpeed; } - else if (num50 < num49) + else if (currentSpeedCheck < minCurrentSpeed) { NPC.velocity.Normalize(); - NPC.velocity *= num49; + NPC.velocity *= minCurrentSpeed; } } - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - float num196 = System.Math.Abs(num191); - float num197 = System.Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; - if ((NPC.velocity.X > 0f && num191 > 0f) || (NPC.velocity.X < 0f && num191 < 0f) || (NPC.velocity.Y > 0f && num192 > 0f) || (NPC.velocity.Y < 0f && num192 < 0f)) + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + float absoluteTargetX = System.Math.Abs(targetXDirection); + float absoluteTargetY = System.Math.Abs(targetYDirection); + float timeToReachTarget = currentSpeed / targetDistance; + targetXDirection *= timeToReachTarget; + targetYDirection *= timeToReachTarget; + if ((NPC.velocity.X > 0f && targetXDirection > 0f) || (NPC.velocity.X < 0f && targetXDirection < 0f) || (NPC.velocity.Y > 0f && targetYDirection > 0f) || (NPC.velocity.Y < 0f && targetYDirection < 0f)) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetXDirection) { - NPC.velocity.X = NPC.velocity.X + num189; + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed; } else { - if (NPC.velocity.X > num191) + if (NPC.velocity.X > targetXDirection) { - NPC.velocity.X = NPC.velocity.X - num189; + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed; } } - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y + num189; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed; } else { - if (NPC.velocity.Y > num192) + if (NPC.velocity.Y > targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y - num189; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed; } } - if ((double)System.Math.Abs(num192) < (double)num188 * 0.2 && ((NPC.velocity.X > 0f && num191 < 0f) || (NPC.velocity.X < 0f && num191 > 0f))) + if ((double)System.Math.Abs(targetYDirection) < (double)currentSpeed * 0.2 && ((NPC.velocity.X > 0f && targetXDirection < 0f) || (NPC.velocity.X < 0f && targetXDirection > 0f))) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num189 * 2f; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed * 2f; } else { - NPC.velocity.Y = NPC.velocity.Y - num189 * 2f; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed * 2f; } } - if ((double)System.Math.Abs(num191) < (double)num188 * 0.2 && ((NPC.velocity.Y > 0f && num192 < 0f) || (NPC.velocity.Y < 0f && num192 > 0f))) + if ((double)System.Math.Abs(targetXDirection) < (double)currentSpeed * 0.2 && ((NPC.velocity.Y > 0f && targetYDirection < 0f) || (NPC.velocity.Y < 0f && targetYDirection > 0f))) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num189 * 2f; //changed from 2 + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed * 2f; //changed from 2 } else { - NPC.velocity.X = NPC.velocity.X - num189 * 2f; //changed from 2 + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed * 2f; //changed from 2 } } } else { - if (num196 > num197) + if (absoluteTargetX > absoluteTargetY) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetXDirection) { - NPC.velocity.X = NPC.velocity.X + num189 * 1.1f; //changed from 1.1 + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed * 1.1f; //changed from 1.1 } - else if (NPC.velocity.X > num191) + else if (NPC.velocity.X > targetXDirection) { - NPC.velocity.X = NPC.velocity.X - num189 * 1.1f; //changed from 1.1 + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed * 1.1f; //changed from 1.1 } - if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)num188 * 0.5) + if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)currentSpeed * 0.5) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num189; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed; } else { - NPC.velocity.Y = NPC.velocity.Y - num189; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed; } } } else { - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y + num189 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed * 1.1f; } - else if (NPC.velocity.Y > num192) + else if (NPC.velocity.Y > targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y - num189 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed * 1.1f; } - if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)num188 * 0.5) + if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)currentSpeed * 0.5) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num189; + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed; } else { - NPC.velocity.X = NPC.velocity.X - num189; + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed; } } } diff --git a/NPCs/Abyss/OarfishTail.cs b/NPCs/Abyss/OarfishTail.cs index 01db892718..f9bf228a3c 100644 --- a/NPCs/Abyss/OarfishTail.cs +++ b/NPCs/Abyss/OarfishTail.cs @@ -84,39 +84,39 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDirection = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDirection = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDirection = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDirection = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDirection, (double)targetXDirection) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDirection *= targetDistance; + targetYDirection *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDirection; + NPC.position.Y = NPC.position.Y + targetYDirection; - if (num191 < 0f) + if (targetXDirection < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetXDirection > 0f) NPC.spriteDirection = 1; } } diff --git a/NPCs/Abyss/ReaperShark.cs b/NPCs/Abyss/ReaperShark.cs index 9b6100524a..1f7b10c7a0 100644 --- a/NPCs/Abyss/ReaperShark.cs +++ b/NPCs/Abyss/ReaperShark.cs @@ -163,7 +163,7 @@ namespace CalamityMod.NPCs.Abyss } if (NPC.wet || NPC.noTileCollide) { - bool flag14 = hasBeenHit; + bool canAttack = hasBeenHit; NPC.TargetClosest(false); @@ -175,7 +175,7 @@ namespace CalamityMod.NPCs.Abyss hasBeenHit = true; } - if (!flag14) + if (!canAttack) { if (!Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) { @@ -204,7 +204,7 @@ namespace CalamityMod.NPCs.Abyss } } } - if (flag14) + if (canAttack) { if (NPC.ai[3] > 0f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) { @@ -283,15 +283,15 @@ namespace CalamityMod.NPCs.Abyss } } } - int num258 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num259 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } @@ -346,14 +346,11 @@ namespace CalamityMod.NPCs.Abyss NPC.netUpdate = true; } bool expertMode = Main.expertMode; - int num2 = 30; - float num3 = expertMode ? 0.4f : 0.35f; - float scaleFactor = expertMode ? 6f : 5.5f; - int num4 = expertMode ? 28 : 30; - float num5 = expertMode ? 12f : 11f; - int num9 = 90; - int num16 = 75; - Vector2 vector = NPC.Center; + float chargeAcceleration = expertMode ? 0.4f : 0.35f; + float chargeThreshold = expertMode ? 6f : 5.5f; + int phase2Delay = expertMode ? 28 : 30; + float chargeVelocity = expertMode ? 12f : 11f; + Vector2 shorkCenter = NPC.Center; Player player = Main.player[NPC.target]; if (NPC.target < 0 || NPC.target == Main.maxPlayers || player.dead || !player.active) { @@ -361,7 +358,7 @@ namespace CalamityMod.NPCs.Abyss player = Main.player[NPC.target]; NPC.netUpdate = true; } - if (player.dead || Vector2.Distance(player.Center, vector) > 5600f) + if (player.dead || Vector2.Distance(player.Center, shorkCenter) > 5600f) { NPC.velocity.Y = NPC.velocity.Y + 0.4f; if (NPC.timeLeft > 10) @@ -382,53 +379,53 @@ namespace CalamityMod.NPCs.Abyss NPC.netUpdate = true; } } - float num17 = (float)Math.Atan2((double)(player.Center.Y - vector.Y), (double)(player.Center.X - vector.X)); + float getRotatedIdiot = (float)Math.Atan2((double)(player.Center.Y - shorkCenter.Y), (double)(player.Center.X - shorkCenter.X)); if (NPC.spriteDirection == 1) { - num17 += 3.14159274f; + getRotatedIdiot += 3.14159274f; } - if (num17 < 0f) + if (getRotatedIdiot < 0f) { - num17 += 6.28318548f; + getRotatedIdiot += 6.28318548f; } - if (num17 > 6.28318548f) + if (getRotatedIdiot > 6.28318548f) { - num17 -= 6.28318548f; + getRotatedIdiot -= 6.28318548f; } if (NPC.ai[0] == -1f) { - num17 = 0f; + getRotatedIdiot = 0f; } - float num18 = 0.04f; + float rotationSpeed = 0.04f; if (NPC.ai[0] == 1f) { - num18 = 0f; + rotationSpeed = 0f; } - if (NPC.rotation < num17) + if (NPC.rotation < getRotatedIdiot) { - if ((double)(num17 - NPC.rotation) > 3.1415926535897931) + if ((double)(getRotatedIdiot - NPC.rotation) > 3.1415926535897931) { - NPC.rotation -= num18; + NPC.rotation -= rotationSpeed; } else { - NPC.rotation += num18; + NPC.rotation += rotationSpeed; } } - if (NPC.rotation > num17) + if (NPC.rotation > getRotatedIdiot) { - if ((double)(NPC.rotation - num17) > 3.1415926535897931) + if ((double)(NPC.rotation - getRotatedIdiot) > 3.1415926535897931) { - NPC.rotation += num18; + NPC.rotation += rotationSpeed; } else { - NPC.rotation -= num18; + NPC.rotation -= rotationSpeed; } } - if (NPC.rotation > num17 - num18 && NPC.rotation < num17 + num18) + if (NPC.rotation > getRotatedIdiot - rotationSpeed && NPC.rotation < getRotatedIdiot + rotationSpeed) { - NPC.rotation = num17; + NPC.rotation = getRotatedIdiot; } if (NPC.rotation < 0f) { @@ -438,9 +435,9 @@ namespace CalamityMod.NPCs.Abyss { NPC.rotation -= 6.28318548f; } - if (NPC.rotation > num17 - num18 && NPC.rotation < num17 + num18) + if (NPC.rotation > getRotatedIdiot - rotationSpeed && NPC.rotation < getRotatedIdiot + rotationSpeed) { - NPC.rotation = num17; + NPC.rotation = getRotatedIdiot; } if (NPC.ai[0] != -1f) { @@ -466,10 +463,10 @@ namespace CalamityMod.NPCs.Abyss NPC.dontTakeDamage = true; NPC.chaseable = false; NPC.velocity *= 0.98f; - int num19 = Math.Sign(player.Center.X - vector.X); - if (num19 != 0) + int spriteFaceDirection = Math.Sign(player.Center.X - shorkCenter.X); + if (spriteFaceDirection != 0) { - NPC.direction = num19; + NPC.direction = spriteFaceDirection; NPC.spriteDirection = -NPC.direction; } if (NPC.ai[2] > 20f) @@ -489,22 +486,22 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 150; } } - if (NPC.ai[2] == (float)(num9 - 30)) + if (NPC.ai[2] == 60f) { - int num20 = 36; - for (int i = 0; i < num20; i++) + int dustAmt = 36; + for (int i = 0; i < dustAmt; i++) { - Vector2 expr_80F = (Vector2.Normalize(NPC.velocity) * new Vector2((float)NPC.width / 2f, (float)NPC.height) * 0.75f * 0.5f).RotatedBy((double)((float)(i - (num20 / 2 - 1)) * 6.28318548f / (float)num20), default) + NPC.Center; - Vector2 vector2 = expr_80F - NPC.Center; - int num21 = Dust.NewDust(expr_80F + vector2, 0, 0, 172, vector2.X * 2f, vector2.Y * 2f, 100, default, 1.4f); - Main.dust[num21].noGravity = true; - Main.dust[num21].noLight = true; - Main.dust[num21].velocity = Vector2.Normalize(vector2) * 3f; + Vector2 expr_80F = (Vector2.Normalize(NPC.velocity) * new Vector2((float)NPC.width / 2f, (float)NPC.height) * 0.75f * 0.5f).RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + NPC.Center; + Vector2 dustDirection = expr_80F - NPC.Center; + int chargeDust = Dust.NewDust(expr_80F + dustDirection, 0, 0, 172, dustDirection.X * 2f, dustDirection.Y * 2f, 100, default, 1.4f); + Main.dust[chargeDust].noGravity = true; + Main.dust[chargeDust].noLight = true; + Main.dust[chargeDust].velocity = Vector2.Normalize(dustDirection) * 3f; } SoundEngine.PlaySound(EnragedRoarSound, NPC.Center); } NPC.ai[2] += 1f; - if (NPC.ai[2] >= (float)num16) + if (NPC.ai[2] >= 75f) { NPC.ai[0] = 0f; NPC.ai[1] = 0f; @@ -519,49 +516,49 @@ namespace CalamityMod.NPCs.Abyss NPC.chaseable = true; if (NPC.ai[1] == 0f) { - NPC.ai[1] = (float)(300 * Math.Sign((vector - player.Center).X)); + NPC.ai[1] = (float)(300 * Math.Sign((shorkCenter - player.Center).X)); } - Vector2 vector3 = Vector2.Normalize(player.Center + new Vector2(NPC.ai[1], -200f) - vector - NPC.velocity) * scaleFactor; - if (NPC.velocity.X < vector3.X) + Vector2 chargeDirection = Vector2.Normalize(player.Center + new Vector2(NPC.ai[1], -200f) - shorkCenter - NPC.velocity) * chargeThreshold; + if (NPC.velocity.X < chargeDirection.X) { - NPC.velocity.X = NPC.velocity.X + num3; - if (NPC.velocity.X < 0f && vector3.X > 0f) + NPC.velocity.X = NPC.velocity.X + chargeAcceleration; + if (NPC.velocity.X < 0f && chargeDirection.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num3; + NPC.velocity.X = NPC.velocity.X + chargeAcceleration; } } - else if (NPC.velocity.X > vector3.X) + else if (NPC.velocity.X > chargeDirection.X) { - NPC.velocity.X = NPC.velocity.X - num3; - if (NPC.velocity.X > 0f && vector3.X < 0f) + NPC.velocity.X = NPC.velocity.X - chargeAcceleration; + if (NPC.velocity.X > 0f && chargeDirection.X < 0f) { - NPC.velocity.X = NPC.velocity.X - num3; + NPC.velocity.X = NPC.velocity.X - chargeAcceleration; } } - if (NPC.velocity.Y < vector3.Y) + if (NPC.velocity.Y < chargeDirection.Y) { - NPC.velocity.Y = NPC.velocity.Y + num3; - if (NPC.velocity.Y < 0f && vector3.Y > 0f) + NPC.velocity.Y = NPC.velocity.Y + chargeAcceleration; + if (NPC.velocity.Y < 0f && chargeDirection.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num3; + NPC.velocity.Y = NPC.velocity.Y + chargeAcceleration; } } - else if (NPC.velocity.Y > vector3.Y) + else if (NPC.velocity.Y > chargeDirection.Y) { - NPC.velocity.Y = NPC.velocity.Y - num3; - if (NPC.velocity.Y > 0f && vector3.Y < 0f) + NPC.velocity.Y = NPC.velocity.Y - chargeAcceleration; + if (NPC.velocity.Y > 0f && chargeDirection.Y < 0f) { - NPC.velocity.Y = NPC.velocity.Y - num3; + NPC.velocity.Y = NPC.velocity.Y - chargeAcceleration; } } - int num22 = Math.Sign(player.Center.X - vector.X); - if (num22 != 0) + int shorkFacingSign = Math.Sign(player.Center.X - shorkCenter.X); + if (shorkFacingSign != 0) { - if (NPC.ai[2] == 0f && num22 != NPC.direction) + if (NPC.ai[2] == 0f && shorkFacingSign != NPC.direction) { NPC.rotation += 3.14159274f; } - NPC.direction = num22; + NPC.direction = shorkFacingSign; if (NPC.spriteDirection != -NPC.direction) { NPC.rotation += 3.14159274f; @@ -569,16 +566,16 @@ namespace CalamityMod.NPCs.Abyss NPC.spriteDirection = -NPC.direction; } NPC.ai[2] += 1f; - if (NPC.ai[2] >= (float)num2) + if (NPC.ai[2] >= 30f) { NPC.ai[0] = 1f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; - NPC.velocity = Vector2.Normalize(player.Center - vector) * num5; + NPC.velocity = Vector2.Normalize(player.Center - shorkCenter) * chargeVelocity; NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X); - if (num22 != 0) + if (shorkFacingSign != 0) { - NPC.direction = num22; + NPC.direction = shorkFacingSign; if (NPC.spriteDirection == 1) { NPC.rotation += 3.14159274f; @@ -591,19 +588,19 @@ namespace CalamityMod.NPCs.Abyss } else if (NPC.ai[0] == 1f) { - int num24 = 7; - for (int j = 0; j < num24; j++) + int phase2DustAmt = 7; + for (int j = 0; j < phase2DustAmt; j++) { - Vector2 arg_E1C_0 = (Vector2.Normalize(NPC.velocity) * new Vector2((float)(NPC.width + 50) / 2f, (float)NPC.height) * 0.75f).RotatedBy((double)(j - (num24 / 2 - 1)) * 3.1415926535897931 / (double)(float)num24, default) + vector; - Vector2 vector4 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); - int num25 = Dust.NewDust(arg_E1C_0 + vector4, 0, 0, 172, vector4.X * 2f, vector4.Y * 2f, 100, default, 1.4f); - Main.dust[num25].noGravity = true; - Main.dust[num25].noLight = true; - Main.dust[num25].velocity /= 4f; - Main.dust[num25].velocity -= NPC.velocity; + Vector2 arg_E1C_0 = (Vector2.Normalize(NPC.velocity) * new Vector2((float)(NPC.width + 50) / 2f, (float)NPC.height) * 0.75f).RotatedBy((double)(j - (phase2DustAmt / 2 - 1)) * 3.1415926535897931 / (double)(float)phase2DustAmt, default) + shorkCenter; + Vector2 phase2DustRotation = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + int phase2Dust = Dust.NewDust(arg_E1C_0 + phase2DustRotation, 0, 0, 172, phase2DustRotation.X * 2f, phase2DustRotation.Y * 2f, 100, default, 1.4f); + Main.dust[phase2Dust].noGravity = true; + Main.dust[phase2Dust].noLight = true; + Main.dust[phase2Dust].velocity /= 4f; + Main.dust[phase2Dust].velocity -= NPC.velocity; } NPC.ai[2] += 1f; - if (NPC.ai[2] >= (float)num4) + if (NPC.ai[2] >= (float)phase2Delay) { NPC.ai[0] = 0f; NPC.ai[1] = 0f; @@ -613,7 +610,7 @@ namespace CalamityMod.NPCs.Abyss } if (Main.zenithWorld && Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[2] % 5 == 0) { - Vector2 direction = vector - player.Center; + Vector2 direction = shorkCenter - player.Center; direction.Normalize(); Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, direction * 10f, ProjectileID.DemonSickle, NPC.damage / 2, 0f, Main.myPlayer); } @@ -637,7 +634,7 @@ namespace CalamityMod.NPCs.Abyss public override void FindFrame(int frameHeight) { int newFrameHeight = (int)(frameHeight * (Main.zenithWorld ? 1.5f : 1f)); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.3f, PortraitPositionXOverride = 54f, diff --git a/NPCs/Abyss/ToxicMinnow.cs b/NPCs/Abyss/ToxicMinnow.cs index f619c3b9b3..dc6308bd63 100644 --- a/NPCs/Abyss/ToxicMinnow.cs +++ b/NPCs/Abyss/ToxicMinnow.cs @@ -21,7 +21,7 @@ namespace CalamityMod.NPCs.Abyss public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 4; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.8f, }; diff --git a/NPCs/Abyss/Viperfish.cs b/NPCs/Abyss/Viperfish.cs index 435786c671..43e88471c6 100644 --- a/NPCs/Abyss/Viperfish.cs +++ b/NPCs/Abyss/Viperfish.cs @@ -19,7 +19,7 @@ namespace CalamityMod.NPCs.Abyss public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 4; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { PortraitPositionXOverride = 0 }; diff --git a/NPCs/AcidRain/AcidEel.cs b/NPCs/AcidRain/AcidEel.cs index 6a0ee223b7..b49de944d5 100644 --- a/NPCs/AcidRain/AcidEel.cs +++ b/NPCs/AcidRain/AcidEel.cs @@ -29,7 +29,7 @@ namespace CalamityMod.NPCs.AcidRain Main.npcFrameCount[NPC.type] = 6; NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.TrailCacheLength[NPC.type] = 12; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { PortraitPositionXOverride = 0 }; diff --git a/NPCs/AcidRain/Mauler.cs b/NPCs/AcidRain/Mauler.cs index bba47c6721..a835f8ee24 100644 --- a/NPCs/AcidRain/Mauler.cs +++ b/NPCs/AcidRain/Mauler.cs @@ -50,7 +50,7 @@ namespace CalamityMod.NPCs.AcidRain { Main.npcFrameCount[NPC.type] = 8; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.425f, PortraitScale = 0.9f, @@ -500,25 +500,25 @@ namespace CalamityMod.NPCs.AcidRain int boom2 = Projectile.NewProjectile(NPC.GetSource_Death(), valueBoom.X, valueBoom.Y, (float)(-Math.Sin(offsetAngleBoom) * 6f), (float)(-Math.Cos(offsetAngleBoom) * 6f), projectileType, damageBoom, 0f, Main.myPlayer, 0f, 0f); } } - for (int num621 = 0; num621 < 25; num621++) + for (int i = 0; i < 25; i++) { - int num622 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 31, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int deathDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 31, 0f, 0f, 100, default, 2f); + Main.dust[deathDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[deathDust].scale = 0.5f; + Main.dust[deathDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } - Main.dust[num622].noGravity = true; + Main.dust[deathDust].noGravity = true; } - for (int num623 = 0; num623 < 50; num623++) + for (int j = 0; j < 50; j++) { - int num624 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 5, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 5, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - Main.dust[num624].noGravity = true; + int deathDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 5, 0f, 0f, 100, default, 3f); + Main.dust[deathDust2].noGravity = true; + Main.dust[deathDust2].velocity *= 5f; + deathDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 5, 0f, 0f, 100, default, 2f); + Main.dust[deathDust2].velocity *= 2f; + Main.dust[deathDust2].noGravity = true; } NPC.netUpdate = true; } diff --git a/NPCs/AcidRain/NuclearTerror.cs b/NPCs/AcidRain/NuclearTerror.cs index 78194d9e79..0b8165919e 100644 --- a/NPCs/AcidRain/NuclearTerror.cs +++ b/NPCs/AcidRain/NuclearTerror.cs @@ -40,6 +40,7 @@ namespace CalamityMod.NPCs.AcidRain public Player Target => Main.player[NPC.target]; public ref float AttackTime => ref NPC.ai[0]; public ref float TeleportCountdown => ref NPC.ai[1]; + public Vector2 TeleportLocation { get => new Vector2(NPC.ai[2], NPC.ai[3]); @@ -49,8 +50,10 @@ namespace CalamityMod.NPCs.AcidRain NPC.ai[3] = value.Y; } } + public ref float HorizontalCollisionCounterDelay => ref NPC.localAI[0]; public ref float HorizontalCollisionSpamCounter => ref NPC.localAI[1]; + public static readonly SpecialAttackState[] PhaseArray = new SpecialAttackState[] { SpecialAttackState.ShotgunBurstOfBullets, @@ -71,6 +74,7 @@ namespace CalamityMod.NPCs.AcidRain SpecialAttackState.ShotgunBurstOfBullets, SpecialAttackState.ConeStreamOfBullets }; + public const int AttackCycleTime = 520; public const int SpecialAttackTime = 240; public const float TeleportTime = 60f; @@ -87,7 +91,7 @@ namespace CalamityMod.NPCs.AcidRain NPCID.Sets.TrailCacheLength[NPC.type] = 6; NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.4f, Direction = 1 @@ -143,6 +147,7 @@ namespace CalamityMod.NPCs.AcidRain writer.Write(DeathrayTime); writer.WriteVector2(ShootPosition); } + public override void ReceiveExtraAI(BinaryReader reader) { NPC.dontTakeDamage = reader.ReadBoolean(); @@ -175,7 +180,12 @@ namespace CalamityMod.NPCs.AcidRain if (NPC.target < 0 || NPC.target >= 255 || Main.player[NPC.target].dead || !Main.player[NPC.target].active) { NPC.TargetClosest(false); + NPC.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (NPC.netSpam >= 10) + NPC.netSpam = 9; } if (TeleportCountdown > -TeleportCooldown) @@ -224,21 +234,36 @@ namespace CalamityMod.NPCs.AcidRain JumpTimer = 0f; NPC.velocity.Y -= MathHelper.Clamp(Math.Abs(Target.Center.Y - NPC.Center.Y) / 12.5f, 8f, 18f); NPC.velocity.X = NPC.SafeDirectionTo(Target.Center).X * 18f; + NPC.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (NPC.netSpam >= 10) + NPC.netSpam = 9; } else { if (Walking != Math.Abs(NPC.velocity.X) > 4f) { Walking = Math.Abs(NPC.velocity.X) > 4f; + NPC.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (NPC.netSpam >= 10) + NPC.netSpam = 9; } // Force a jump the next frame to overcome any horizontal obstacles if they exist. if (NPC.collideX) { JumpTimer = 50; + NPC.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (NPC.netSpam >= 10) + NPC.netSpam = 9; } // Otherwise walk towards the target if they're not super close. @@ -261,7 +286,13 @@ namespace CalamityMod.NPCs.AcidRain if (wrappedAttackTime == 255f) { ShootPosition = Target.Center; + NPC.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (NPC.netSpam >= 10) + NPC.netSpam = 9; + NPC.spriteDirection = (ShootPosition.X - NPC.Center.X < 0).ToDirectionInt(); } @@ -275,6 +306,7 @@ namespace CalamityMod.NPCs.AcidRain } } } + public void TeleportCheck() { float distanceFromTarget = NPC.Distance(Target.Center); @@ -324,9 +356,15 @@ namespace CalamityMod.NPCs.AcidRain TeleportCountdown = TeleportTime; TeleportLocation = new Vector2(x, y - 6f); HorizontalCollisionSpamCounter = 0f; + NPC.netUpdate = true; + // Prevent netUpdate from being blocked by the spam counter. + if (NPC.netSpam >= 10) + NPC.netSpam = 9; + return; + Continue: continue; } @@ -339,13 +377,20 @@ namespace CalamityMod.NPCs.AcidRain { if (TeleportCountdown > TeleportTime) TeleportCountdown = TeleportTime; + TeleportCountdown--; if (TeleportCountdown >= 0f) { if (TeleportCountdown == 0f && TeleportLocation != Vector2.Zero) { NPC.position = TeleportLocation.ToWorldCoordinates(8f, 0f) - NPC.Size; + NPC.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (NPC.netSpam >= 10) + NPC.netSpam = 9; + NPC.velocity = Vector2.Zero; } else @@ -366,6 +411,7 @@ namespace CalamityMod.NPCs.AcidRain if (NPC.velocity.Y < 18f) NPC.velocity.Y += 0.35f; } + return; } @@ -408,6 +454,7 @@ namespace CalamityMod.NPCs.AcidRain switch (PhaseArray[AttackIndex]) { case SpecialAttackState.DivergingBullets: + NPC.velocity.X *= 0.9f; float shootAdjustedTime = wrappedAttackTime - (AttackCycleTime - SpecialAttackTime); bool shouldShoot = shootAdjustedTime >= 20f; @@ -426,10 +473,14 @@ namespace CalamityMod.NPCs.AcidRain NPC.spriteDirection = (ShootPosition.X - NPC.Center.X < 0).ToDirectionInt(); SoundEngine.PlaySound(SoundID.NPCDeath13, mouthPosition); } + if (wrappedAttackTime >= (AttackCycleTime - SpecialAttackTime + 35f) && AttackTime % 10f == 9f) Projectile.NewProjectile(NPC.GetSource_FromAI(), mouthPosition, directionToTarget * 12f, ModContent.ProjectileType(), 48, 3f); + break; + case SpecialAttackState.ConeStreamOfBullets: + if (wrappedAttackTime >= AttackCycleTime - SpecialAttackTime + 35f && AttackTime % 4f == 3f) { if (Main.netMode != NetmodeID.MultiplayerClient) @@ -438,10 +489,14 @@ namespace CalamityMod.NPCs.AcidRain Projectile.NewProjectile(NPC.GetSource_FromAI(), mouthPosition, directionToTarget.RotatedBy(angle) * 16f, ModContent.ProjectileType(), 48, 4.5f); Projectile.NewProjectile(NPC.GetSource_FromAI(), mouthPosition, directionToTarget.RotatedBy(-angle) * 16f, ModContent.ProjectileType(), 48, 4.5f); } + NPC.spriteDirection = (Target.Center.X - NPC.Center.X < 0).ToDirectionInt(); } + break; + case SpecialAttackState.ShotgunBurstOfBullets: + if (wrappedAttackTime >= AttackCycleTime - SpecialAttackTime + 35f && AttackTime % 20f == 19f) { if (Main.netMode != NetmodeID.MultiplayerClient) @@ -452,8 +507,10 @@ namespace CalamityMod.NPCs.AcidRain Projectile.NewProjectile(NPC.GetSource_FromAI(), mouthPosition, directionToShootPosition.RotatedBy(angle) * 13f, ModContent.ProjectileType(), 48, 4f); } } + NPC.spriteDirection = (ShootPosition.X - NPC.Center.X < 0).ToDirectionInt(); } + break; } } @@ -466,17 +523,17 @@ namespace CalamityMod.NPCs.AcidRain NPC.alpha = 0; if (DeathrayTime < 240f) { - int num5 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 200, default, 1.5f); - Main.dust[num5].noGravity = true; - Main.dust[num5].velocity *= 0.75f; - Main.dust[num5].fadeIn = 1.3f; + int bigFuckOffDeathrayDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 200, default, 1.5f); + Main.dust[bigFuckOffDeathrayDust].noGravity = true; + Main.dust[bigFuckOffDeathrayDust].velocity *= 0.75f; + Main.dust[bigFuckOffDeathrayDust].fadeIn = 1.3f; Vector2 vector = new Vector2((float)Main.rand.Next(-200, 201), (float)Main.rand.Next(-200, 201)); vector.Normalize(); vector *= (float)Main.rand.Next(100, 200) * 0.04f; - Main.dust[num5].velocity = vector; + Main.dust[bigFuckOffDeathrayDust].velocity = vector; vector.Normalize(); vector *= 34f; - Main.dust[num5].position = NPC.Center - vector; + Main.dust[bigFuckOffDeathrayDust].position = NPC.Center - vector; } else if (DeathrayTime == 240f) { @@ -505,6 +562,7 @@ namespace CalamityMod.NPCs.AcidRain NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance); NPC.damage = (int)(NPC.damage * 0.85f); } + public override void FindFrame(int frameHeight) { NPC.frameCounter++; @@ -519,6 +577,7 @@ namespace CalamityMod.NPCs.AcidRain NPC.frame.Y += frameHeight; NPC.frameCounter = 0; } + if (Dying) { SoundEngine.PlaySound(DeathSound, NPC.Center); @@ -533,6 +592,7 @@ namespace CalamityMod.NPCs.AcidRain Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, angle.ToRotationVector2() * Main.rand.NextFloat(4f, 11f), type, 48, 3f); } } + for (int i = 0; i < 60; i++) { Dust dust = Dust.NewDustDirect(NPC.Center, 45, 45, (int)CalamityDusts.SulfurousSeaAcid); @@ -540,14 +600,17 @@ namespace CalamityMod.NPCs.AcidRain dust.noGravity = true; dust.scale = Main.rand.NextFloat(2f, 3f); } + NPC.frame.Y = frameHeight * 8; } + if (NPC.frame.Y >= frameHeight * Main.npcFrameCount[NPC.type] && Main.netMode != NetmodeID.MultiplayerClient) NPC.StrikeInstantKill(); } else if (NPC.frame.Y >= (Walking ? 8 : 4) * frameHeight) NPC.frame.Y = Walking ? 4 * frameHeight : 0; } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { if (NPC.velocity.Length() > 0f) @@ -556,7 +619,9 @@ namespace CalamityMod.NPCs.AcidRain endColor.A = Color.Transparent.A; CalamityGlobalNPC.DrawAfterimage(NPC, spriteBatch, drawColor, endColor, directioning: true, invertedDirection: true); } + CalamityGlobalNPC.DrawGlowmask(NPC, spriteBatch, null, true); + return false; } @@ -569,9 +634,16 @@ namespace CalamityMod.NPCs.AcidRain NPC.life = 1; NPC.dontTakeDamage = true; NPC.velocity = Vector2.Zero; + NPC.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (NPC.netSpam >= 10) + NPC.netSpam = 9; + return false; } + return Dying; } diff --git a/NPCs/AcidRain/NuclearToad.cs b/NPCs/AcidRain/NuclearToad.cs index be79dae332..b26e44e5c5 100644 --- a/NPCs/AcidRain/NuclearToad.cs +++ b/NPCs/AcidRain/NuclearToad.cs @@ -39,7 +39,7 @@ namespace CalamityMod.NPCs.AcidRain public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 5; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0); value.Position.Y += 8; value.PortraitPositionYOverride = 28f; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; diff --git a/NPCs/AcidRain/Orthocera.cs b/NPCs/AcidRain/Orthocera.cs index 48db750c06..8b36b27fd9 100644 --- a/NPCs/AcidRain/Orthocera.cs +++ b/NPCs/AcidRain/Orthocera.cs @@ -3,13 +3,12 @@ using System.IO; using CalamityMod.BiomeManagers; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; +using CalamityMod.Graphics.Metaballs; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Weapons.Summon; -using CalamityMod.Particles.Metaballs; using CalamityMod.Projectiles.Enemy; using CalamityMod.Projectiles.Magic; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent.Bestiary; @@ -76,9 +75,9 @@ namespace CalamityMod.NPCs.AcidRain public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Orthocera") + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Orthocera") }); } @@ -212,7 +211,7 @@ namespace CalamityMod.NPCs.AcidRain if (NPC.Calamity().newAI[0] % 5 == 0 && Main.netMode != NetmodeID.MultiplayerClient) { Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Bottom, Main.rand.NextVector2Circular(4f, 8f), ModContent.ProjectileType(), 0, 0f, Main.myPlayer); - FusableParticleManager.GetParticleSetByType().SpawnParticle(NPC.Bottom + Main.rand.NextVector2Circular(10f, 10f), 135f); + RancorLavaMetaball.SpawnParticle(NPC.Bottom + Main.rand.NextVector2Circular(10f, 10f), 135f); } if (NPC.Calamity().newAI[0] % 30 == 0 && Main.netMode != NetmodeID.MultiplayerClient) { diff --git a/NPCs/AcidRain/Skyfin.cs b/NPCs/AcidRain/Skyfin.cs index 70a210d607..fafbc88638 100644 --- a/NPCs/AcidRain/Skyfin.cs +++ b/NPCs/AcidRain/Skyfin.cs @@ -23,7 +23,7 @@ namespace CalamityMod.NPCs.AcidRain public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 5; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Rotation = MathHelper.Pi }; diff --git a/NPCs/AcidRain/SulphurousSkater.cs b/NPCs/AcidRain/SulphurousSkater.cs index 46c3a49da3..d5502e57d5 100644 --- a/NPCs/AcidRain/SulphurousSkater.cs +++ b/NPCs/AcidRain/SulphurousSkater.cs @@ -200,7 +200,7 @@ namespace CalamityMod.NPCs.AcidRain public override void FindFrame(int frameHeight) { - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { SpriteDirection = 1 }; diff --git a/NPCs/AquaticScourge/AquaticScourgeBody.cs b/NPCs/AquaticScourge/AquaticScourgeBody.cs index e316b31f81..d66f327dce 100644 --- a/NPCs/AquaticScourge/AquaticScourgeBody.cs +++ b/NPCs/AquaticScourge/AquaticScourgeBody.cs @@ -100,11 +100,11 @@ namespace CalamityMod.NPCs.AquaticScourge spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); + Vector2 scaledDraw = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; + drawLocation += scaledDraw * NPC.scale + new Vector2(0f, NPC.gfxOffY); Color color = NPC.GetAlpha(drawColor); if (CalamityWorld.revenge || BossRushEvent.BossRushActive || Main.zenithWorld) @@ -115,7 +115,7 @@ namespace CalamityMod.NPCs.AquaticScourge color = Color.Lerp(color, Color.SandyBrown, MathHelper.Clamp(Main.npc[(int)NPC.ai[2]].localAI[3] / 90f, 0f, 1f)); } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, color, NPC.rotation, scaledDraw, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs b/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs index 878f092770..06f72e58ef 100644 --- a/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs +++ b/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs @@ -99,11 +99,11 @@ namespace CalamityMod.NPCs.AquaticScourge spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); + Vector2 scaledDraw = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; + drawLocation += scaledDraw * NPC.scale + new Vector2(0f, NPC.gfxOffY); Color color = NPC.GetAlpha(drawColor); if (CalamityWorld.revenge || BossRushEvent.BossRushActive || Main.zenithWorld) @@ -114,7 +114,7 @@ namespace CalamityMod.NPCs.AquaticScourge color = Color.Lerp(color, Color.SandyBrown, MathHelper.Clamp(Main.npc[(int)NPC.ai[2]].localAI[3] / 90f, 0f, 1f)); } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, color, NPC.rotation, scaledDraw, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/AquaticScourge/AquaticScourgeHead.cs b/NPCs/AquaticScourge/AquaticScourgeHead.cs index 5a6623acd1..f73c8daa8d 100644 --- a/NPCs/AquaticScourge/AquaticScourgeHead.cs +++ b/NPCs/AquaticScourge/AquaticScourgeHead.cs @@ -37,7 +37,7 @@ namespace CalamityMod.NPCs.AquaticScourge public override void SetStaticDefaults() { NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.6f, PortraitScale = 0.6f, @@ -96,8 +96,10 @@ namespace CalamityMod.NPCs.AquaticScourge public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) { + bestiaryEntry.UIInfoProvider = new CommonEnemyUICollectionInfoProvider(ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[Type], quickUnlock: true); bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + new BossBestiaryInfoElement(), new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.AquaticScourge") }); } @@ -136,11 +138,11 @@ namespace CalamityMod.NPCs.AquaticScourge spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); + Vector2 scaledDraw = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; + drawLocation += scaledDraw * NPC.scale + new Vector2(0f, NPC.gfxOffY); Color color = NPC.GetAlpha(drawColor); if (CalamityWorld.revenge || BossRushEvent.BossRushActive || Main.zenithWorld) @@ -151,7 +153,7 @@ namespace CalamityMod.NPCs.AquaticScourge color = Color.Lerp(color, Color.SandyBrown, MathHelper.Clamp(NPC.localAI[3] / 90f, 0f, 1f)); } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, color, NPC.rotation, scaledDraw, NPC.scale, spriteEffects, 0f); return false; } @@ -160,18 +162,18 @@ namespace CalamityMod.NPCs.AquaticScourge { Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float topLeftHitbox = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float topRightHitbox = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float bottomLeftHitbox = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float bottomRightHitbox = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = topLeftHitbox; + if (topRightHitbox < minDist) + minDist = topRightHitbox; + if (bottomLeftHitbox < minDist) + minDist = bottomLeftHitbox; + if (bottomRightHitbox < minDist) + minDist = bottomRightHitbox; return minDist <= 50f * NPC.scale; } @@ -255,7 +257,7 @@ namespace CalamityMod.NPCs.AquaticScourge npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB troll drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType()); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), hideLootReport: true); // Lore bool firstASKill() => !DownedBossSystem.downedAquaticScourge; diff --git a/NPCs/AquaticScourge/AquaticScourgeTail.cs b/NPCs/AquaticScourge/AquaticScourgeTail.cs index 8f3c854675..51908a45bf 100644 --- a/NPCs/AquaticScourge/AquaticScourgeTail.cs +++ b/NPCs/AquaticScourge/AquaticScourgeTail.cs @@ -99,11 +99,11 @@ namespace CalamityMod.NPCs.AquaticScourge spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); + Vector2 scaledDraw = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; + drawLocation += scaledDraw * NPC.scale + new Vector2(0f, NPC.gfxOffY); Color color = NPC.GetAlpha(drawColor); if (CalamityWorld.revenge || BossRushEvent.BossRushActive || Main.zenithWorld) @@ -114,7 +114,7 @@ namespace CalamityMod.NPCs.AquaticScourge color = Color.Lerp(color, Color.SandyBrown, MathHelper.Clamp(Main.npc[(int)NPC.ai[2]].localAI[3] / 90f, 0f, 1f)); } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, color, NPC.rotation, scaledDraw, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/Astral/AstralProbe.cs b/NPCs/Astral/AstralProbe.cs index baa847bb42..46a657a72e 100644 --- a/NPCs/Astral/AstralProbe.cs +++ b/NPCs/Astral/AstralProbe.cs @@ -65,36 +65,36 @@ namespace CalamityMod.NPCs.Astral { NPC.TargetClosest(true); } - float num = CalamityWorld.death ? 8f : CalamityWorld.revenge ? 6.5f : 5f; - float num2 = CalamityWorld.death ? 0.08f : CalamityWorld.revenge ? 0.065f : 0.05f; - Vector2 vector = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num4 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num5 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num4 = (float)((int)(num4 / 8f) * 8); - num5 = (float)((int)(num5 / 8f) * 8); - vector.X = (float)((int)(vector.X / 8f) * 8); - vector.Y = (float)((int)(vector.Y / 8f) * 8); - num4 -= vector.X; - num5 -= vector.Y; - float num6 = (float)Math.Sqrt((double)(num4 * num4 + num5 * num5)); - float num7 = num6; - bool flag = false; - if (num6 > 600f) + float probeSpeed = CalamityWorld.death ? 8f : CalamityWorld.revenge ? 6.5f : 5f; + float probeAcceleration = CalamityWorld.death ? 0.08f : CalamityWorld.revenge ? 0.065f : 0.05f; + Vector2 probePosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDirection = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDirection = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDirection = (float)((int)(targetXDirection / 8f) * 8); + targetYDirection = (float)((int)(targetYDirection / 8f) * 8); + probePosition.X = (float)((int)(probePosition.X / 8f) * 8); + probePosition.Y = (float)((int)(probePosition.Y / 8f) * 8); + targetXDirection -= probePosition.X; + targetYDirection -= probePosition.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + float accelerateDistance = targetDistance; + bool tooFar = false; + if (targetDistance > 600f) { - flag = true; + tooFar = true; } - if (num6 == 0f) + if (targetDistance == 0f) { - num4 = NPC.velocity.X; - num5 = NPC.velocity.Y; + targetXDirection = NPC.velocity.X; + targetYDirection = NPC.velocity.Y; } else { - num6 = num / num6; - num4 *= num6; - num5 *= num6; + targetDistance = probeSpeed / targetDistance; + targetXDirection *= targetDistance; + targetYDirection *= targetDistance; } - if (num7 > 100f) + if (accelerateDistance > 100f) { NPC.ai[0] += 1f; if (NPC.ai[0] > 0f) @@ -120,24 +120,24 @@ namespace CalamityMod.NPCs.Astral } if (Main.player[NPC.target].dead) { - num4 = (float)NPC.direction * num / 2f; - num5 = -num / 2f; + targetXDirection = (float)NPC.direction * probeSpeed / 2f; + targetYDirection = -probeSpeed / 2f; } - if (NPC.velocity.X < num4) + if (NPC.velocity.X < targetXDirection) { - NPC.velocity.X = NPC.velocity.X + num2; + NPC.velocity.X = NPC.velocity.X + probeAcceleration; } - else if (NPC.velocity.X > num4) + else if (NPC.velocity.X > targetXDirection) { - NPC.velocity.X = NPC.velocity.X - num2; + NPC.velocity.X = NPC.velocity.X - probeAcceleration; } - if (NPC.velocity.Y < num5) + if (NPC.velocity.Y < targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y + num2; + NPC.velocity.Y = NPC.velocity.Y + probeAcceleration; } - else if (NPC.velocity.Y > num5) + else if (NPC.velocity.Y > targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y - num2; + NPC.velocity.Y = NPC.velocity.Y - probeAcceleration; } NPC.localAI[0] += 1f; if (NPC.justHit) @@ -149,37 +149,36 @@ namespace CalamityMod.NPCs.Astral NPC.localAI[0] = 0f; if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { - int num8 = Main.expertMode ? 14 : 18; + int projDamage = Main.expertMode ? 14 : 18; if (DownedBossSystem.downedAstrumAureus) - num8 += 6; + projDamage += 6; - int num9 = ProjectileID.PinkLaser; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector.X, vector.Y, num4, num5, num9, num8, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), probePosition.X, probePosition.Y, targetXDirection, targetYDirection, ProjectileID.PinkLaser, projDamage, 0f, Main.myPlayer, 0f, 0f); } } - int num10 = (int)NPC.position.X + NPC.width / 2; - int num11 = (int)NPC.position.Y + NPC.height / 2; - num10 /= 16; - num11 /= 16; - if (!WorldGen.SolidTile(num10, num11)) + int npcTileX = (int)NPC.position.X + NPC.width / 2; + int npcTileY = (int)NPC.position.Y + NPC.height / 2; + npcTileX /= 16; + npcTileY /= 16; + if (!WorldGen.SolidTile(npcTileX, npcTileY)) { Lighting.AddLight((int)((NPC.position.X + (float)(NPC.width / 2)) / 16f), (int)((NPC.position.Y + (float)(NPC.height / 2)) / 16f), 0.3f, 0f, 0.25f); } - if (num4 > 0f) + if (targetXDirection > 0f) { NPC.spriteDirection = 1; - NPC.rotation = (float)Math.Atan2((double)num5, (double)num4); + NPC.rotation = (float)Math.Atan2((double)targetYDirection, (double)targetXDirection); } - if (num4 < 0f) + if (targetXDirection < 0f) { NPC.spriteDirection = -1; - NPC.rotation = (float)Math.Atan2((double)num5, (double)num4) + 3.14f; + NPC.rotation = (float)Math.Atan2((double)targetYDirection, (double)targetXDirection) + 3.14f; } - float num12 = 0.7f; + float recoilVelocity = 0.7f; if (NPC.collideX) { NPC.netUpdate = true; - NPC.velocity.X = NPC.oldVelocity.X * -num12; + NPC.velocity.X = NPC.oldVelocity.X * -recoilVelocity; if (NPC.direction == -1 && NPC.velocity.X > 0f && NPC.velocity.X < 2f) { NPC.velocity.X = 2f; @@ -192,7 +191,7 @@ namespace CalamityMod.NPCs.Astral if (NPC.collideY) { NPC.netUpdate = true; - NPC.velocity.Y = NPC.oldVelocity.Y * -num12; + NPC.velocity.Y = NPC.oldVelocity.Y * -recoilVelocity; if (NPC.velocity.Y > 0f && (double)NPC.velocity.Y < 1.5) { NPC.velocity.Y = 2f; @@ -202,9 +201,9 @@ namespace CalamityMod.NPCs.Astral NPC.velocity.Y = -2f; } } - if (flag) + if (tooFar) { - if ((NPC.velocity.X > 0f && num4 > 0f) || (NPC.velocity.X < 0f && num4 < 0f)) + if ((NPC.velocity.X > 0f && targetXDirection > 0f) || (NPC.velocity.X < 0f && targetXDirection < 0f)) { if (Math.Abs(NPC.velocity.X) < 12f) { @@ -229,16 +228,16 @@ namespace CalamityMod.NPCs.Astral spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); + Vector2 drawPosition = NPC.Center - screenPos; + drawPosition -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; + drawPosition += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawPosition, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/Astral/AstralProbeGlow").Value; - spriteBatch.Draw(texture2D15, vector43, NPC.frame, Color.White * 0.6f, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawPosition, NPC.frame, Color.White * 0.6f, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/Astral/AstralachneaGround.cs b/NPCs/Astral/AstralachneaGround.cs index cebe618dcc..b6e40c4cdb 100644 --- a/NPCs/Astral/AstralachneaGround.cs +++ b/NPCs/Astral/AstralachneaGround.cs @@ -1,19 +1,15 @@ -using CalamityMod.BiomeManagers; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; -using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using System; using Terraria; -using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; -using ReLogic.Content; -using CalamityMod.Sounds; namespace CalamityMod.NPCs.Astral { @@ -23,13 +19,12 @@ namespace CalamityMod.NPCs.Astral public override void SetStaticDefaults() { - Main.npcFrameCount[NPC.type] = 5; if (!Main.dedServ) glowmask = ModContent.Request("CalamityMod/NPCs/Astral/AstralachneaGroundGlow", AssetRequestMode.ImmediateLoad).Value; - base.SetStaticDefaults(); + this.HideFromBestiary(); } public override void SetDefaults() @@ -46,7 +41,7 @@ namespace CalamityMod.NPCs.Astral NPC.value = Item.buyPrice(0, 0, 20, 0); NPC.timeLeft = NPC.activeTime * 2; AnimationType = NPCID.WallCreeper; - Banner = NPC.type; + Banner = ModContent.NPCType(); BannerItem = ModContent.ItemType(); if (DownedBossSystem.downedAstrumAureus) { @@ -57,15 +52,6 @@ namespace CalamityMod.NPCs.Astral } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - } - - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] - { - new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Astralachnea") - }); } public override void AI() @@ -95,19 +81,6 @@ namespace CalamityMod.NPCs.Astral public override void FindFrame(int frameHeight) { - if (NPC.IsABestiaryIconDummy) - { - NPC.frameCounter += 1; - if (NPC.frameCounter > 6) - { - NPC.frame.Y += frameHeight; - NPC.frameCounter = 0; - } - if (NPC.frame.Y > frameHeight * 5) - { - NPC.frame.Y = 0; - } - } //DO DUST int frame = NPC.frame.Y / frameHeight; Rectangle rect = new Rectangle(62, 4, 14, 6); @@ -181,13 +154,6 @@ namespace CalamityMod.NPCs.Astral target.AddBuff(ModContent.BuffType(), 75, true); } - public static void ModifyAstralachneaLoot(NPCLoot npcLoot) - { - npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 2, 2, 3); - npcLoot.AddIf(() => Main.expertMode, ModContent.ItemType(), 1, 1, 4); - npcLoot.AddIf(() => DownedBossSystem.downedAstrumAureus, ModContent.ItemType(), 7); - } - - public override void ModifyNPCLoot(NPCLoot npcLoot) => ModifyAstralachneaLoot(npcLoot); + public override void ModifyNPCLoot(NPCLoot npcLoot) => AstralachneaWall.ModifyAstralachneaLoot(npcLoot); } } diff --git a/NPCs/Astral/AstralachneaWall.cs b/NPCs/Astral/AstralachneaWall.cs index 1e38e13f3c..b4f2184c55 100644 --- a/NPCs/Astral/AstralachneaWall.cs +++ b/NPCs/Astral/AstralachneaWall.cs @@ -1,17 +1,21 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.BiomeManagers; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Sounds; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using System; using Terraria; +using Terraria.Audio; +using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; -using Terraria.Audio; -using ReLogic.Content; -using CalamityMod.Sounds; namespace CalamityMod.NPCs.Astral { @@ -25,10 +29,8 @@ namespace CalamityMod.NPCs.Astral if (!Main.dedServ) glowmask = ModContent.Request("CalamityMod/NPCs/Astral/AstralachneaWallGlow", AssetRequestMode.ImmediateLoad).Value; - - base.SetStaticDefaults(); - NPCID.Sets.NPCBestiaryDrawModifiers bestiaryData = new NPCID.Sets.NPCBestiaryDrawModifiers() { Hide = true }; - NPCID.Sets.NPCBestiaryDrawOffset.Add(Type, bestiaryData); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Rotation = -MathHelper.PiOver2 }; + NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; } public override void SetDefaults() @@ -46,7 +48,7 @@ namespace CalamityMod.NPCs.Astral NPC.value = Item.buyPrice(0, 0, 20, 0); NPC.timeLeft = NPC.activeTime * 2; AnimationType = NPCID.BlackRecluseWall; - Banner = ModContent.NPCType(); + Banner = NPC.type; BannerItem = ModContent.ItemType(); if (DownedBossSystem.downedAstrumAureus) { @@ -56,6 +58,15 @@ namespace CalamityMod.NPCs.Astral } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] + { + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Astralachnea") + }); } public override void AI() @@ -65,6 +76,13 @@ namespace CalamityMod.NPCs.Astral public override void FindFrame(int frameHeight) { + if (NPC.IsABestiaryIconDummy) + { + NPC.frameCounter += 0.1f; + NPC.frameCounter %= Main.npcFrameCount[NPC.type]; + NPC.frame.Y = (int)NPC.frameCounter * frameHeight; + return; + } //DO DUST int frame = NPC.frame.Y / frameHeight; Rectangle rect = new Rectangle(12, 24, 18, 10); @@ -131,6 +149,13 @@ namespace CalamityMod.NPCs.Astral target.AddBuff(ModContent.BuffType(), 75, true); } - public override void ModifyNPCLoot(NPCLoot npcLoot) => AstralachneaGround.ModifyAstralachneaLoot(npcLoot); + public static void ModifyAstralachneaLoot(NPCLoot npcLoot) + { + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 2, 2, 3); + npcLoot.AddIf(() => Main.expertMode, ModContent.ItemType(), 1, 1, 4); + npcLoot.AddIf(() => DownedBossSystem.downedAstrumAureus, ModContent.ItemType(), 7); + } + + public override void ModifyNPCLoot(NPCLoot npcLoot) => ModifyAstralachneaLoot(npcLoot); } } diff --git a/NPCs/Astral/Atlas.cs b/NPCs/Astral/Atlas.cs index 500fcfa786..10abbd321b 100644 --- a/NPCs/Astral/Atlas.cs +++ b/NPCs/Astral/Atlas.cs @@ -109,7 +109,7 @@ namespace CalamityMod.NPCs.Astral //not much we can do. looks fine in-game so /shrug if (!Main.dedServ) glowmask = ModContent.Request("CalamityMod/NPCs/Astral/AtlasGlow", AssetRequestMode.ImmediateLoad).Value; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { PortraitPositionYOverride = -5 }; diff --git a/NPCs/Astral/FusionFeeder.cs b/NPCs/Astral/FusionFeeder.cs index c53400ba52..0b9e929fa6 100644 --- a/NPCs/Astral/FusionFeeder.cs +++ b/NPCs/Astral/FusionFeeder.cs @@ -36,7 +36,7 @@ namespace CalamityMod.NPCs.Astral { if (!Main.dedServ) glowmask = ModContent.Request("CalamityMod/NPCs/Astral/FusionFeederGlow", AssetRequestMode.ImmediateLoad).Value; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.5f, PortraitPositionXOverride = 0f, diff --git a/NPCs/Astral/Hadarian.cs b/NPCs/Astral/Hadarian.cs index 4377d7b1fb..71f74ba954 100644 --- a/NPCs/Astral/Hadarian.cs +++ b/NPCs/Astral/Hadarian.cs @@ -28,7 +28,7 @@ namespace CalamityMod.NPCs.Astral { if (!Main.dedServ) glowmask = ModContent.Request("CalamityMod/NPCs/Astral/HadarianGlow", AssetRequestMode.ImmediateLoad).Value; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0); value.Position.X += 10f; value.Position.Y += 10f; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; diff --git a/NPCs/Astral/Hiveling.cs b/NPCs/Astral/Hiveling.cs index 02e38debe3..bb284ecf97 100644 --- a/NPCs/Astral/Hiveling.cs +++ b/NPCs/Astral/Hiveling.cs @@ -24,7 +24,7 @@ namespace CalamityMod.NPCs.Astral if (!Main.dedServ) glowmask = ModContent.Request("CalamityMod/NPCs/Astral/HivelingGlow", AssetRequestMode.ImmediateLoad).Value; Main.npcFrameCount[NPC.type] = 4; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0); value.Position.Y -= 8; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; } diff --git a/NPCs/Astral/Mantis.cs b/NPCs/Astral/Mantis.cs index 587c865a2e..0c16b746eb 100644 --- a/NPCs/Astral/Mantis.cs +++ b/NPCs/Astral/Mantis.cs @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.Astral public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 14; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { PortraitPositionYOverride = 0 }; diff --git a/NPCs/Astral/Nova.cs b/NPCs/Astral/Nova.cs index c532f15bc2..4453eb8aea 100644 --- a/NPCs/Astral/Nova.cs +++ b/NPCs/Astral/Nova.cs @@ -37,7 +37,7 @@ namespace CalamityMod.NPCs.Astral if (!Main.dedServ) glowmask = ModContent.Request("CalamityMod/NPCs/Astral/NovaGlow", AssetRequestMode.ImmediateLoad).Value; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.64f, PortraitPositionXOverride = 10f, diff --git a/NPCs/Astral/SightseerCollider.cs b/NPCs/Astral/SightseerCollider.cs index 779dd8c078..b482b4381f 100644 --- a/NPCs/Astral/SightseerCollider.cs +++ b/NPCs/Astral/SightseerCollider.cs @@ -27,7 +27,7 @@ namespace CalamityMod.NPCs.Astral if (!Main.dedServ) glowmask = ModContent.Request("CalamityMod/NPCs/Astral/SightseerColliderGlow", AssetRequestMode.ImmediateLoad).Value; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { PortraitPositionXOverride = 0 }; diff --git a/NPCs/Astral/SightseerSpitter.cs b/NPCs/Astral/SightseerSpitter.cs index ecb7257bb4..97c1bd3230 100644 --- a/NPCs/Astral/SightseerSpitter.cs +++ b/NPCs/Astral/SightseerSpitter.cs @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.Astral Main.npcFrameCount[NPC.type] = 4; if (!Main.dedServ) glowmask = ModContent.Request("CalamityMod/NPCs/Astral/SightseerSpitterGlow", AssetRequestMode.ImmediateLoad).Value; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.7f, Velocity = 2f, diff --git a/NPCs/Astral/StellarCulex.cs b/NPCs/Astral/StellarCulex.cs index 7f4b5b3396..15d82413e3 100644 --- a/NPCs/Astral/StellarCulex.cs +++ b/NPCs/Astral/StellarCulex.cs @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.Astral if (!Main.dedServ) glowmask = ModContent.Request("CalamityMod/NPCs/Astral/StellarCulexGlow", AssetRequestMode.ImmediateLoad).Value; Main.npcFrameCount[NPC.type] = 4; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { PortraitPositionXOverride = 10f }; diff --git a/NPCs/AstrumAureus/AstrumAureus.cs b/NPCs/AstrumAureus/AstrumAureus.cs index 1525c05545..6a7d4a7caa 100644 --- a/NPCs/AstrumAureus/AstrumAureus.cs +++ b/NPCs/AstrumAureus/AstrumAureus.cs @@ -47,7 +47,7 @@ namespace CalamityMod.NPCs.AstrumAureus Main.npcFrameCount[NPC.type] = 6; NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.27f, PortraitScale = 0.45f, @@ -276,67 +276,67 @@ namespace CalamityMod.NPCs.AstrumAureus } int frameCount = Main.npcFrameCount[NPC.type]; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / frameCount / 2); + Vector2 originalDrawSize = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / frameCount / 2); Rectangle frame = NPC.frame; float scale = NPC.scale; float rotation = NPC.rotation; float offsetY = NPC.gfxOffY; - Color color36 = Color.White; + Color slimeColor = Color.White; if (Main.zenithWorld && slimePhaseHP) { - color36 = slimePhase == 0 ? Color.Yellow : Color.Violet; + slimeColor = slimePhase == 0 ? Color.Yellow : Color.Violet; } - float amount9 = 0.5f; - int num153 = 7; + float colorLerpAmt = 0.5f; + int afterimageAmt = 7; if (NPC.ai[0] == 3f || NPC.ai[0] == 4f) - num153 = 10; + afterimageAmt = 10; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(NPCTexture.Width, NPCTexture.Height / frameCount) * scale / 2f; - vector41 += vector11 * scale + new Vector2(0f, 4f + offsetY); - spriteBatch.Draw(NPCTexture, vector41, frame, color38, rotation, vector11, scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, slimeColor, colorLerpAmt); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(NPCTexture.Width, NPCTexture.Height / frameCount) * scale / 2f; + afterimagePos += originalDrawSize * scale + new Vector2(0f, 4f + offsetY); + spriteBatch.Draw(NPCTexture, afterimagePos, frame, afterimageColor, rotation, originalDrawSize, scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(NPCTexture.Width, NPCTexture.Height / frameCount) * scale / 2f; - vector43 += vector11 * scale + new Vector2(0f, 4f + offsetY); - Color toUse = Main.zenithWorld && slimePhaseHP ? color36 : drawColor; - spriteBatch.Draw(NPCTexture, vector43, frame, NPC.GetAlpha(toUse), rotation, vector11, scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(NPCTexture.Width, NPCTexture.Height / frameCount) * scale / 2f; + drawLocation += originalDrawSize * scale + new Vector2(0f, 4f + offsetY); + Color toUse = Main.zenithWorld && slimePhaseHP ? slimeColor : drawColor; + spriteBatch.Draw(NPCTexture, drawLocation, frame, NPC.GetAlpha(toUse), rotation, originalDrawSize, scale, spriteEffects, 0f); if (NPC.ai[0] != 1 || (slimePhaseHP && Main.zenithWorld)) //draw only if not recharging { Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Color.Gold); - Color color40 = Color.Lerp(Color.White, color, 0.5f); + Color attackingColor = Color.Lerp(Color.White, color, 0.5f); if (Main.zenithWorld && slimePhaseHP) { - color40 = slimePhase == 0 ? Color.Violet : Color.Yellow; + attackingColor = slimePhase == 0 ? Color.Violet : Color.Yellow; } if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color40; - color41 = Color.Lerp(color41, color36, amount9); - color41 = NPC.GetAlpha(color41); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector44 -= new Vector2(GlowMaskTexture.Width, GlowMaskTexture.Height / frameCount) * scale / 2f; - vector44 += vector11 * scale + new Vector2(0f, 4f + offsetY); - spriteBatch.Draw(GlowMaskTexture, vector44, frame, color41, rotation, vector11, scale, spriteEffects, 0f); + Color attackingAfterimageColor = attackingColor; + attackingAfterimageColor = Color.Lerp(attackingAfterimageColor, slimeColor, colorLerpAmt); + attackingAfterimageColor = NPC.GetAlpha(attackingAfterimageColor); + attackingAfterimageColor *= (afterimageAmt - j) / 15f; + Vector2 attackAfterimagePos = NPC.oldPos[j] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + attackAfterimagePos -= new Vector2(GlowMaskTexture.Width, GlowMaskTexture.Height / frameCount) * scale / 2f; + attackAfterimagePos += originalDrawSize * scale + new Vector2(0f, 4f + offsetY); + spriteBatch.Draw(GlowMaskTexture, attackAfterimagePos, frame, attackingAfterimageColor, rotation, originalDrawSize, scale, spriteEffects, 0f); } } - spriteBatch.Draw(GlowMaskTexture, vector43, frame, color40, rotation, vector11, scale, spriteEffects, 0f); + spriteBatch.Draw(GlowMaskTexture, drawLocation, frame, attackingColor, rotation, originalDrawSize, scale, spriteEffects, 0f); } return false; @@ -387,8 +387,8 @@ namespace CalamityMod.NPCs.AstrumAureus // GFB Crab Banner and Asteroid Staff drop var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ItemID.CrabBanner, 1, 1, 9999); - GFBOnly.Add(ModContent.ItemType()); + GFBOnly.Add(ItemID.CrabBanner, 1, 1, 9999, true); + GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); } // Lore @@ -440,23 +440,23 @@ namespace CalamityMod.NPCs.AstrumAureus NPC.height = (int)(100 * NPC.scale); NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 50; num621++) + for (int r = 0; r < 50; r++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int aureusDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[aureusDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[aureusDust].scale = 0.5f; + Main.dust[aureusDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 100; num623++) + for (int s = 0; s < 100; s++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, ModContent.DustType(), 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, ModContent.DustType(), 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int aureusDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, ModContent.DustType(), 0f, 0f, 100, default, 3f); + Main.dust[aureusDust2].noGravity = true; + Main.dust[aureusDust2].velocity *= 5f; + aureusDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, ModContent.DustType(), 0f, 0f, 100, default, 2f); + Main.dust[aureusDust2].velocity *= 2f; } } } diff --git a/NPCs/AstrumAureus/AureusSpawn.cs b/NPCs/AstrumAureus/AureusSpawn.cs index 90390664c8..848c2a6de0 100644 --- a/NPCs/AstrumAureus/AureusSpawn.cs +++ b/NPCs/AstrumAureus/AureusSpawn.cs @@ -240,49 +240,48 @@ namespace CalamityMod.NPCs.AstrumAureus NPC.DrawBackglow(Color.Lerp(Color.Cyan, Color.Orange, (float)Math.Sin(Main.GlobalTimeWrappedHourly) / 2f + 0.5f) with { A = 0 }, 2f + 8f * ((float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.TwoPi) + 1f), spriteEffects, NPC.frame, screenPos); Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 10; + Vector2 originalDrawSize = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); + Color whiteColor = Color.White; + int afterimageAmt = 10; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, whiteColor, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + afterimagePos += originalDrawSize * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, originalDrawSize, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + drawLocation += originalDrawSize * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, originalDrawSize, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/AstrumAureus/AureusSpawnGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Orange, 0.5f) * NPC.Opacity; + Color afterimageColorLerp = Color.Lerp(Color.White, Color.Orange, 0.5f) * NPC.Opacity; if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color secondAfterimageColor = afterimageColorLerp; + secondAfterimageColor = Color.Lerp(secondAfterimageColor, whiteColor, 0.5f); + secondAfterimageColor *= (afterimageAmt - j) / 15f; + Vector2 secondAfterimagePos = NPC.oldPos[j] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + secondAfterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + secondAfterimagePos += originalDrawSize * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, secondAfterimagePos, NPC.frame, secondAfterimageColor, NPC.rotation, originalDrawSize, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, afterimageColorLerp, NPC.rotation, originalDrawSize, NPC.scale, spriteEffects, 0f); return false; } @@ -351,26 +350,26 @@ namespace CalamityMod.NPCs.AstrumAureus NPC.position.X = NPC.position.X - NPC.width / 2; NPC.position.Y = NPC.position.Y - NPC.height / 2; - for (int num621 = 0; num621 < 30; num621++) + for (int r = 0; r < 30; r++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, ModContent.DustType(), 0f, 0f, 100, default, 1f); - Main.dust[num622].velocity *= 3f; + int astralDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, ModContent.DustType(), 0f, 0f, 100, default, 1f); + Main.dust[astralDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[astralDust].scale = 0.5f; + Main.dust[astralDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } - Main.dust[num622].noGravity = true; + Main.dust[astralDust].noGravity = true; } - for (int num623 = 0; num623 < 60; num623++) + for (int s = 0; s < 60; s++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 173, 0f, 0f, 100, default, 2f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, ModContent.DustType(), 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; - Main.dust[num624].noGravity = true; + int astralDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 173, 0f, 0f, 100, default, 2f); + Main.dust[astralDust2].noGravity = true; + Main.dust[astralDust2].velocity *= 5f; + astralDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, ModContent.DustType(), 0f, 0f, 100, default, 1f); + Main.dust[astralDust2].velocity *= 2f; + Main.dust[astralDust2].noGravity = true; } } } diff --git a/NPCs/AstrumDeus/AstrumDeusBody.cs b/NPCs/AstrumDeus/AstrumDeusBody.cs index 9904695fef..ba1e2f361f 100644 --- a/NPCs/AstrumDeus/AstrumDeusBody.cs +++ b/NPCs/AstrumDeus/AstrumDeusBody.cs @@ -99,34 +99,34 @@ namespace CalamityMod.NPCs.AstrumDeus bool deathModeEnragePhase = Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] == 3f; bool doubleWormPhase = NPC.Calamity().newAI[0] != 0f && !deathModeEnragePhase; - Texture2D texture = altBodyTextures ? ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyAltSpectral").Value : TextureAssets.Npc[NPC.type].Value; - Texture2D texture2 = ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyGlow2").Value; - Vector2 vector = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); + Texture2D mainWormTex = altBodyTextures ? ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyAltSpectral").Value : TextureAssets.Npc[NPC.type].Value; + Texture2D secondWormTex = ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyGlow2").Value; + Vector2 halfSizeTex = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); - Vector2 vector2 = NPC.Center - screenPos; - vector2 -= new Vector2(texture.Width, texture.Height) * NPC.scale / 2f; - vector2 += vector * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture, vector2, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(mainWormTex.Width, mainWormTex.Height) * NPC.scale / 2f; + drawLocation += halfSizeTex * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(mainWormTex, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); - texture = altBodyTextures ? ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyAltGlow").Value : ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyGlow").Value; + mainWormTex = altBodyTextures ? ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyAltGlow").Value : ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyGlow").Value; Color phaseColor = drawCyan ? Color.Cyan : Color.Orange; if (doubleWormPhase) { - texture = drawCyan ? texture : (altBodyTextures ? ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyAltGlow2").Value : ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyGlow3").Value); - texture2 = drawCyan ? ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyGlow4").Value : texture2; + mainWormTex = drawCyan ? mainWormTex : (altBodyTextures ? ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyAltGlow2").Value : ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyGlow3").Value); + secondWormTex = drawCyan ? ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyGlow4").Value : secondWormTex; } - Color color = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Cyan, 0.5f) * (deathModeEnragePhase ? 1f : NPC.Opacity); - Color color2 = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Orange, 0.5f) * (deathModeEnragePhase ? 1f : NPC.Opacity); + Color mainWormColorLerp = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Cyan, 0.5f) * (deathModeEnragePhase ? 1f : NPC.Opacity); + Color secondWormColorLerp = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Orange, 0.5f) * (deathModeEnragePhase ? 1f : NPC.Opacity); int timesToDraw = deathModeEnragePhase ? 3 : drawCyan ? 1 : 2; for (int i = 0; i < timesToDraw; i++) - spriteBatch.Draw(texture, vector2, NPC.frame, color, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(mainWormTex, drawLocation, NPC.frame, mainWormColorLerp, NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); if (!altBodyTextures) { timesToDraw = deathModeEnragePhase ? 3 : drawCyan ? 2 : 1; for (int i = 0; i < timesToDraw; i++) - spriteBatch.Draw(texture2, vector2, NPC.frame, color2, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(secondWormTex, drawLocation, NPC.frame, secondWormColorLerp, NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); } return false; @@ -152,23 +152,23 @@ namespace CalamityMod.NPCs.AstrumDeus NPC.height = 50; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int purpleDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[purpleDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[purpleDust].scale = 0.5f; + Main.dust[purpleDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, ModContent.DustType(), 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, ModContent.DustType(), 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int astralDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, ModContent.DustType(), 0f, 0f, 100, default, 3f); + Main.dust[astralDust].noGravity = true; + Main.dust[astralDust].velocity *= 5f; + astralDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, ModContent.DustType(), 0f, 0f, 100, default, 2f); + Main.dust[astralDust].velocity *= 2f; } } } diff --git a/NPCs/AstrumDeus/AstrumDeusHead.cs b/NPCs/AstrumDeus/AstrumDeusHead.cs index 09b034c58a..4e0f3ff8a2 100644 --- a/NPCs/AstrumDeus/AstrumDeusHead.cs +++ b/NPCs/AstrumDeus/AstrumDeusHead.cs @@ -44,7 +44,7 @@ namespace CalamityMod.NPCs.AstrumDeus { NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.70f, PortraitScale = 0.75f, @@ -149,32 +149,32 @@ namespace CalamityMod.NPCs.AstrumDeus bool deathModeEnragePhase = NPC.Calamity().newAI[0] == 3f; bool doubleWormPhase = NPC.Calamity().newAI[0] != 0f && !deathModeEnragePhase; - Texture2D texture = TextureAssets.Npc[NPC.type].Value; - Texture2D texture2 = ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusHeadGlow2").Value; - Vector2 vector = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); + Texture2D mainWormTex = TextureAssets.Npc[NPC.type].Value; + Texture2D secondWormTex = ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusHeadGlow2").Value; + Vector2 halfSizeTex = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); - Vector2 vector2 = NPC.Center - screenPos; - vector2 -= new Vector2(texture.Width, texture.Height) * NPC.scale / 2f; - vector2 += vector * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture, vector2, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(mainWormTex.Width, mainWormTex.Height) * NPC.scale / 2f; + drawLocation += halfSizeTex * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(mainWormTex, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); - texture = ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusHeadGlow").Value; + mainWormTex = ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusHeadGlow").Value; Color phaseColor = drawCyan ? Color.Cyan : Color.Orange; if (doubleWormPhase) { - texture = drawCyan ? texture : ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusHeadGlow3").Value; - texture2 = drawCyan ? ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusHeadGlow4").Value : texture2; + mainWormTex = drawCyan ? mainWormTex : ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusHeadGlow3").Value; + secondWormTex = drawCyan ? ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusHeadGlow4").Value : secondWormTex; } - Color color = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Cyan, 0.5f) * (deathModeEnragePhase ? 1f : NPC.Opacity); - Color color2 = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Orange, 0.5f) * (deathModeEnragePhase ? 1f : NPC.Opacity); + Color mainWormColorLerp = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Cyan, 0.5f) * (deathModeEnragePhase ? 1f : NPC.Opacity); + Color secondWormColorLerp = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Orange, 0.5f) * (deathModeEnragePhase ? 1f : NPC.Opacity); int timesToDraw = deathModeEnragePhase ? 3 : drawCyan ? 1 : 2; for (int i = 0; i < timesToDraw; i++) - spriteBatch.Draw(texture, vector2, NPC.frame, color, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(mainWormTex, drawLocation, NPC.frame, mainWormColorLerp, NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); timesToDraw = deathModeEnragePhase ? 3 : drawCyan ? 2 : 1; for (int i = 0; i < timesToDraw; i++) - spriteBatch.Draw(texture2, vector2, NPC.frame, color2, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(secondWormTex, drawLocation, NPC.frame, secondWormColorLerp, NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); return false; } @@ -191,23 +191,23 @@ namespace CalamityMod.NPCs.AstrumDeus NPC.height = 50; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int purpleDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[purpleDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[purpleDust].scale = 0.5f; + Main.dust[purpleDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, ModContent.DustType(), 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, ModContent.DustType(), 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int astralDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, ModContent.DustType(), 0f, 0f, 100, default, 3f); + Main.dust[astralDust].noGravity = true; + Main.dust[astralDust].velocity *= 5f; + astralDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, ModContent.DustType(), 0f, 0f, 100, default, 2f); + Main.dust[astralDust].velocity *= 2f; } } } @@ -314,12 +314,12 @@ namespace CalamityMod.NPCs.AstrumDeus // GFB Worm and Spaghetti drop var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ItemID.Worm, 1, 1, 9999); - GFBOnly.Add(ItemID.CanOfWorms, 1, 1, 9999); - GFBOnly.Add(ItemID.GummyWorm, 1, 1, 9999); - GFBOnly.Add(ItemID.TruffleWorm, 1, 1, 9999); - GFBOnly.Add(ItemID.EnchantedNightcrawler, 1, 1, 9999); - GFBOnly.Add(ItemID.Spaghetti, 1, 1, 9999); + GFBOnly.Add(ItemID.Worm, 1, 1, 9999, true); + GFBOnly.Add(ItemID.CanOfWorms, 1, 1, 9999, true); + GFBOnly.Add(ItemID.GummyWorm, 1, 1, 9999, true); + GFBOnly.Add(ItemID.TruffleWorm, 1, 1, 9999, true); + GFBOnly.Add(ItemID.EnchantedNightcrawler, 1, 1, 9999, true); + GFBOnly.Add(ItemID.Spaghetti, 1, 1, 9999, true); } // Lore diff --git a/NPCs/AstrumDeus/AstrumDeusTail.cs b/NPCs/AstrumDeus/AstrumDeusTail.cs index 5747de46ef..eae753ab00 100644 --- a/NPCs/AstrumDeus/AstrumDeusTail.cs +++ b/NPCs/AstrumDeus/AstrumDeusTail.cs @@ -98,24 +98,24 @@ namespace CalamityMod.NPCs.AstrumDeus bool deathModeEnragePhase = Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] == 3f; bool doubleWormPhase = NPC.Calamity().newAI[0] != 0f && !deathModeEnragePhase; - Texture2D texture = TextureAssets.Npc[NPC.type].Value; - Vector2 vector = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); + Texture2D wormTexture = TextureAssets.Npc[NPC.type].Value; + Vector2 halfSizeTex = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); - Vector2 vector2 = NPC.Center - screenPos; - vector2 -= new Vector2(texture.Width, texture.Height) * NPC.scale / 2f; - vector2 += vector * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture, vector2, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(wormTexture.Width, wormTexture.Height) * NPC.scale / 2f; + drawLocation += halfSizeTex * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(wormTexture, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); - texture = ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusTailGlow").Value; + wormTexture = ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusTailGlow").Value; Color phaseColor = drawCyan ? Color.Cyan : Color.Orange; if (doubleWormPhase) - texture = drawCyan ? ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusTailGlow2").Value : texture; + wormTexture = drawCyan ? ModContent.Request("CalamityMod/NPCs/AstrumDeus/AstrumDeusTailGlow2").Value : wormTexture; - Color color = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Orange, 0.5f) * (deathModeEnragePhase ? 1f : NPC.Opacity); + Color wormColorLerp = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Orange, 0.5f) * (deathModeEnragePhase ? 1f : NPC.Opacity); int timesToDraw = deathModeEnragePhase ? 3 : drawCyan ? 2 : 1; for (int i = 0; i < timesToDraw; i++) - spriteBatch.Draw(texture, vector2, NPC.frame, color, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(wormTexture, drawLocation, NPC.frame, wormColorLerp, NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); return false; } @@ -135,23 +135,23 @@ namespace CalamityMod.NPCs.AstrumDeus NPC.height = 50; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int purpleDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[purpleDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[purpleDust].scale = 0.5f; + Main.dust[purpleDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, ModContent.DustType(), 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, ModContent.DustType(), 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int astralDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, ModContent.DustType(), 0f, 0f, 100, default, 3f); + Main.dust[astralDust].noGravity = true; + Main.dust[astralDust].velocity *= 5f; + astralDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, ModContent.DustType(), 0f, 0f, 100, default, 2f); + Main.dust[astralDust].velocity *= 2f; } } } diff --git a/NPCs/BrimstoneElemental/Brimling.cs b/NPCs/BrimstoneElemental/Brimling.cs index 72d45033b2..bb7d4fa158 100644 --- a/NPCs/BrimstoneElemental/Brimling.cs +++ b/NPCs/BrimstoneElemental/Brimling.cs @@ -182,14 +182,14 @@ namespace CalamityMod.NPCs.BrimstoneElemental Vector2 distanceFromMother = Main.npc[CalamityGlobalNPC.brimstoneElemental].Center - NPC.Center; if (distanceFromMother.Length() > 120f) { - Vector2 value54 = distanceFromMother; - if (value54.Length() > movementVelocity) + Vector2 farFromBrimVelocityMult = distanceFromMother; + if (farFromBrimVelocityMult.Length() > movementVelocity) { - value54.Normalize(); - value54 *= movementVelocity; + farFromBrimVelocityMult.Normalize(); + farFromBrimVelocityMult *= movementVelocity; } int inertia = 20; - NPC.velocity = (NPC.velocity * (inertia - 1) + value54) / inertia; + NPC.velocity = (NPC.velocity * (inertia - 1) + farFromBrimVelocityMult) / inertia; } else NPC.velocity *= 0.96f; @@ -221,13 +221,13 @@ namespace CalamityMod.NPCs.BrimstoneElemental // Teleport to Brim's new location if (NPC.ai[2] != 0f && NPC.ai[3] != 0f) { - for (int num1449 = 0; num1449 < 20; num1449++) + for (int i = 0; i < 20; i++) { - int num1450 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 235, 0f, 0f, 100, Color.Transparent, 1f); - Dust dust = Main.dust[num1450]; + int deepRedDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 235, 0f, 0f, 100, Color.Transparent, 1f); + Dust dust = Main.dust[deepRedDust]; dust.velocity *= 3f; - Main.dust[num1450].noGravity = true; - Main.dust[num1450].scale = 2.5f; + Main.dust[deepRedDust].noGravity = true; + Main.dust[deepRedDust].scale = 2.5f; } NPC.Center = new Vector2(NPC.ai[2] * 16f, NPC.ai[3] * 16f); @@ -238,13 +238,13 @@ namespace CalamityMod.NPCs.BrimstoneElemental SoundEngine.PlaySound(SoundID.Item8, NPC.Center); - for (int num1451 = 0; num1451 < 20; num1451++) + for (int j = 0; j < 20; j++) { - int num1452 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 235, 0f, 0f, 100, Color.Transparent, 1f); - Dust dust = Main.dust[num1452]; + int deepRedDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 235, 0f, 0f, 100, Color.Transparent, 1f); + Dust dust = Main.dust[deepRedDust2]; dust.velocity *= 3f; - Main.dust[num1452].noGravity = true; - Main.dust[num1452].scale = 2.5f; + Main.dust[deepRedDust2].noGravity = true; + Main.dust[deepRedDust2].scale = 2.5f; } } @@ -261,30 +261,29 @@ namespace CalamityMod.NPCs.BrimstoneElemental // Teleport when Brim teleports if (Main.npc[CalamityGlobalNPC.brimstoneElemental].alpha == 255 && Main.netMode != NetmodeID.MultiplayerClient) { - Point point12 = NPC.Center.ToTileCoordinates(); - Point point13 = Main.npc[CalamityGlobalNPC.brimstoneElemental].Center.ToTileCoordinates(); - int num1453 = 6; - int num1454 = 3; - int num1455 = 4; - int num1456 = 1; - int num1457 = 0; - while (num1457 < 100) + Point npcTileCoords = NPC.Center.ToTileCoordinates(); + Point brimmyTileCoords = Main.npc[CalamityGlobalNPC.brimstoneElemental].Center.ToTileCoordinates(); + int babTeleportRadius = 3; + int brimmyTeleportRadius = 4; + int solidTileRadius = 1; + int increment = 0; + while (increment < 100) { - num1457++; - int num1458 = Main.rand.Next(point13.X - num1453, point13.X + num1453 + 1); - int num1459 = Main.rand.Next(point13.Y - num1453, point13.Y + num1453 + 1); - if ((num1459 < point13.Y - num1455 || num1459 > point13.Y + num1455 || num1458 < point13.X - num1455 || num1458 > point13.X + num1455) && (num1459 < point12.Y - num1454 || num1459 > point12.Y + num1454 || num1458 < point12.X - num1454 || num1458 > point12.X + num1454) && !Main.tile[num1458, num1459].HasUnactuatedTile) + increment++; + int randXOffset = Main.rand.Next(brimmyTileCoords.X - 6, brimmyTileCoords.X + 7); + int randYOffset = Main.rand.Next(brimmyTileCoords.Y - 6, brimmyTileCoords.Y + 7); + if ((randYOffset < brimmyTileCoords.Y - brimmyTeleportRadius || randYOffset > brimmyTileCoords.Y + brimmyTeleportRadius || randXOffset < brimmyTileCoords.X - brimmyTeleportRadius || randXOffset > brimmyTileCoords.X + brimmyTeleportRadius) && (randYOffset < npcTileCoords.Y - babTeleportRadius || randYOffset > npcTileCoords.Y + babTeleportRadius || randXOffset < npcTileCoords.X - babTeleportRadius || randXOffset > npcTileCoords.X + babTeleportRadius) && !Main.tile[randXOffset, randYOffset].HasUnactuatedTile) { - bool flag107 = true; - if (flag107 && Main.tile[num1458, num1459].LiquidType == LiquidID.Lava) - flag107 = false; - if (flag107 && Collision.SolidTiles(num1458 - num1456, num1458 + num1456, num1459 - num1456, num1459 + num1456)) - flag107 = false; + bool canTeleport = true; + if (canTeleport && Main.tile[randXOffset, randYOffset].LiquidType == LiquidID.Lava) + canTeleport = false; + if (canTeleport && Collision.SolidTiles(randXOffset - solidTileRadius, randXOffset + solidTileRadius, randYOffset - solidTileRadius, randYOffset + solidTileRadius)) + canTeleport = false; - if (flag107) + if (canTeleport) { - NPC.ai[2] = num1458; - NPC.ai[3] = num1459; + NPC.ai[2] = randXOffset; + NPC.ai[3] = randYOffset; break; } } diff --git a/NPCs/BrimstoneElemental/BrimstoneElemental.cs b/NPCs/BrimstoneElemental/BrimstoneElemental.cs index 31379d2969..bf3c38328e 100644 --- a/NPCs/BrimstoneElemental/BrimstoneElemental.cs +++ b/NPCs/BrimstoneElemental/BrimstoneElemental.cs @@ -47,7 +47,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental { Main.npcFrameCount[NPC.type] = 12; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.5f, PortraitScale = 0.64f @@ -210,7 +210,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental ModContent.ItemType(), }; normalOnly.Add(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, accs)); - normalOnly.Add(ModContent.ItemType(), 10); + normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); // Vanity normalOnly.Add(ModContent.ItemType(), 7); @@ -225,7 +225,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB Heart of the Elements drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType()); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedBrimstoneElemental, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -263,23 +263,23 @@ namespace CalamityMod.NPCs.BrimstoneElemental NPC.height = 150; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int brimDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[brimDust].scale = 0.5f; + Main.dust[brimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 60; num623++) + for (int j = 0; j < 60; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int brimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); + Main.dust[brimDust2].noGravity = true; + Main.dust[brimDust2].velocity *= 5f; + brimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimDust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) { @@ -300,11 +300,11 @@ namespace CalamityMod.NPCs.BrimstoneElemental SpriteEffects spriteEffects = SpriteEffects.None; if (NPC.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture = TextureAssets.Npc[NPC.type].Value; - Vector2 origin = new Vector2((float)(texture.Width / 2), (float)(texture.Height / Main.npcFrameCount[NPC.type] / 2)); + Texture2D npcTexture = TextureAssets.Npc[NPC.type].Value; + Vector2 frameLocation = new Vector2((float)(npcTexture.Width / 2), (float)(npcTexture.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 npcOffset = NPC.Center - screenPos; - npcOffset -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - npcOffset += origin * NPC.scale + new Vector2(0f, NPC.gfxOffY); + npcOffset -= new Vector2((float)npcTexture.Width, (float)(npcTexture.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + npcOffset += frameLocation * NPC.scale + new Vector2(0f, NPC.gfxOffY); // Give brimmy an outline based on current elemental mode if (Main.zenithWorld) @@ -340,11 +340,11 @@ namespace CalamityMod.NPCs.BrimstoneElemental for (float i = 0; i < 1; i += 0.125f) { - spriteBatch.Draw(texture, npcOffset + (i * MathHelper.TwoPi).ToRotationVector2() * outlineThickness, NPC.frame, outlineColor, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(npcTexture, npcOffset + (i * MathHelper.TwoPi).ToRotationVector2() * outlineThickness, NPC.frame, outlineColor, NPC.rotation, frameLocation, NPC.scale, spriteEffects, 0f); } CalamityUtils.ExitShaderRegion(spriteBatch); } - spriteBatch.Draw(texture, npcOffset, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(npcTexture, npcOffset, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, frameLocation, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/Bumblebirb/Bumblefuck.cs b/NPCs/Bumblebirb/Bumblefuck.cs index 8ff7604fa9..5173fb793e 100644 --- a/NPCs/Bumblebirb/Bumblefuck.cs +++ b/NPCs/Bumblebirb/Bumblefuck.cs @@ -1,4 +1,6 @@ -using CalamityMod.Events; +using System; +using System.IO; +using CalamityMod.Events; using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; @@ -7,6 +9,7 @@ using CalamityMod.Items.Mounts; using CalamityMod.Items.Placeables.Furniture.BossRelics; using CalamityMod.Items.Placeables.Furniture.DevPaintings; using CalamityMod.Items.Placeables.Furniture.Trophies; +using CalamityMod.Items.Potions; using CalamityMod.Items.TreasureBags; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; @@ -16,16 +19,13 @@ using CalamityMod.Sounds; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; -using System.IO; using Terraria; +using Terraria.Audio; using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.GameContent.ItemDropRules; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Items.Potions; namespace CalamityMod.NPCs.Bumblebirb { @@ -37,7 +37,7 @@ namespace CalamityMod.NPCs.Bumblebirb Main.npcFrameCount[NPC.type] = 6; NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.5f, PortraitScale = 0.85f, @@ -46,7 +46,7 @@ namespace CalamityMod.NPCs.Bumblebirb value.Position.X += 20f; value.Position.Y += 8f; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; - NPCID.Sets.MPAllowedEnemies[Type] = true; + NPCID.Sets.MPAllowedEnemies[Type] = true; } public override string Texture => "CalamityMod/NPCs/Bumblebirb/Birb"; @@ -85,7 +85,7 @@ namespace CalamityMod.NPCs.Bumblebirb bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Jungle, - new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Bumblefuck") + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Bumblefuck") }); } @@ -142,8 +142,8 @@ namespace CalamityMod.NPCs.Bumblebirb if (phaseSwitchPhase || birbSpawn) { float frameGateValue = birbSpawn ? NPC.ai[1] : phase3 ? calamityGlobalNPC.newAI[1] : calamityGlobalNPC.newAI[0]; - int num116 = 180; - if (frameGateValue < (num116 - 60) || frameGateValue > (num116 - 20)) + int frameTimer = 180; + if (frameGateValue < (frameTimer - 60) || frameGateValue > (frameTimer - 20)) { NPC.frameCounter += 1D; if (NPC.frameCounter > 5D) @@ -159,7 +159,7 @@ namespace CalamityMod.NPCs.Bumblebirb else { NPC.frame.Y = frameHeight * 4; - if (frameGateValue > (num116 - 50) && frameGateValue < (num116 - 25)) + if (frameGateValue > (frameTimer - 50) && frameGateValue < (frameTimer - 25)) { NPC.frame.Y = frameHeight * 5; } @@ -167,8 +167,8 @@ namespace CalamityMod.NPCs.Bumblebirb } else if (NPC.ai[0] == 5f) { - int num115 = 120; - if (NPC.ai[1] < (num115 - 50) || NPC.ai[1] > (num115 - 10)) + int otherFrameTimer = 120; + if (NPC.ai[1] < (otherFrameTimer - 50) || NPC.ai[1] > (otherFrameTimer - 10)) { NPC.frameCounter += 1D; if (NPC.frameCounter > 5D) @@ -184,7 +184,7 @@ namespace CalamityMod.NPCs.Bumblebirb else { NPC.frame.Y = frameHeight * 4; - if (NPC.ai[1] > (num115 - 40) && NPC.ai[1] < (num115 - 15)) + if (NPC.ai[1] > (otherFrameTimer - 40) && NPC.ai[1] < (otherFrameTimer - 15)) { NPC.frame.Y = frameHeight * 5; } @@ -228,13 +228,13 @@ namespace CalamityMod.NPCs.Bumblebirb spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Color color = drawColor; - Color color36 = Color.White; + Color altColor = Color.White; - float amount9 = 0f; - int num150 = 120; - int num151 = 60; + float lerpDrawTransition = 0f; + int newAITracker = 120; + int buffColorDampener = 60; if (phase3 && calamityGlobalNPC.newAI[3] == 1f) { @@ -244,157 +244,155 @@ namespace CalamityMod.NPCs.Bumblebirb { color = CalamityGlobalNPC.buffColor(color, 0.7f, 0.7f, 0.3f, 1f); } - else if (phase2 && calamityGlobalNPC.newAI[0] > (float)num150) + else if (phase2 && calamityGlobalNPC.newAI[0] > (float)newAITracker) { - float num152 = calamityGlobalNPC.newAI[0] - (float)num150; - num152 /= (float)num151; - color = CalamityGlobalNPC.buffColor(color, 1f - 0.3f * num152, 1f - 0.3f * num152, 1f - 0.7f * num152, 1f); + float phase2TranBuff = calamityGlobalNPC.newAI[0] - (float)newAITracker; + phase2TranBuff /= (float)buffColorDampener; + color = CalamityGlobalNPC.buffColor(color, 1f - 0.3f * phase2TranBuff, 1f - 0.3f * phase2TranBuff, 1f - 0.7f * phase2TranBuff, 1f); } - int num153 = 10; - int num154 = 2; + int afterimageAmt = 10; + int afterimageIncrement = 2; if (NPC.ai[0] == 0f || NPC.ai[0] == 3.1f || NPC.ai[0] == 4f || NPC.ai[0] == 4.2f) { - num153 = 4; + afterimageAmt = 4; } if (NPC.ai[0] == 1f || NPC.ai[0] == 3f || NPC.ai[0] == 4.1f) { - num153 = 7; + afterimageAmt = 7; } if (NPC.ai[0] == 2f || NPC.ai[0] == 3.2f || (phase2 && calamityGlobalNPC.newAI[2] == 1f)) { - color36 = Color.Yellow; - amount9 = 0.5f; + altColor = Color.Yellow; + lerpDrawTransition = 0.5f; } else { - color = drawColor; + color = altColor; } if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += num154) + for (int i = 1; i < afterimageAmt; i += afterimageIncrement) { - Color color38 = color; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = color; + afterimageColor = Color.Lerp(afterimageColor, altColor, lerpDrawTransition); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; + Vector2 afterimageDrawPos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + afterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + afterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimageDrawPos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - int num156 = 0; - float num157 = 0f; - float scaleFactor9 = 0f; + int extraAfterimageAmt = 0; + float extraAfterimageDampener = 0f; + float afterimageScaler = 0f; if (NPC.ai[0] == 0f || NPC.ai[0] == 3.1f || NPC.ai[0] == 4f || NPC.ai[0] == 4.2f) { - num156 = 4; + extraAfterimageAmt = 4; } if (NPC.ai[0] == 5f) { - int num158 = 60; - int num159 = 30; - if (NPC.ai[1] > (float)num158) + if (NPC.ai[1] > 60f) { - num156 = 6; - num157 = 1f - (float)Math.Cos((double)((NPC.ai[1] - (float)num158) / (float)num159 * MathHelper.TwoPi)); - num157 /= 3f; - scaleFactor9 = 40f; + extraAfterimageAmt = 6; + extraAfterimageDampener = 1f - (float)Math.Cos((double)((NPC.ai[1] - 60f) / 30f * MathHelper.TwoPi)); + extraAfterimageDampener /= 3f; + afterimageScaler = 40f; } } if (phaseSwitchPhase) { - if (phase3 && calamityGlobalNPC.newAI[1] > (float)num150) + if (phase3 && calamityGlobalNPC.newAI[1] > (float)newAITracker) { - num156 = 6; - num157 = 1f - (float)Math.Cos((double)((calamityGlobalNPC.newAI[1] - (float)num150) / (float)num151 * MathHelper.TwoPi)); - num157 /= 3f; - scaleFactor9 = 60f; + extraAfterimageAmt = 6; + extraAfterimageDampener = 1f - (float)Math.Cos((double)((calamityGlobalNPC.newAI[1] - (float)newAITracker) / (float)buffColorDampener * MathHelper.TwoPi)); + extraAfterimageDampener /= 3f; + afterimageScaler = 60f; } - else if (phase2 && calamityGlobalNPC.newAI[0] > (float)num150) + else if (phase2 && calamityGlobalNPC.newAI[0] > (float)newAITracker) { - num156 = 6; - num157 = 1f - (float)Math.Cos((double)((calamityGlobalNPC.newAI[0] - (float)num150) / (float)num151 * MathHelper.TwoPi)); - num157 /= 3f; - scaleFactor9 = 60f; + extraAfterimageAmt = 6; + extraAfterimageDampener = 1f - (float)Math.Cos((double)((calamityGlobalNPC.newAI[0] - (float)newAITracker) / (float)buffColorDampener * MathHelper.TwoPi)); + extraAfterimageDampener /= 3f; + afterimageScaler = 60f; } } if (CalamityConfig.Instance.Afterimages) { - for (int num160 = 0; num160 < num156; num160++) + for (int j = 0; j < extraAfterimageAmt; j++) { - Color color39 = drawColor; - color39 = Color.Lerp(color39, color36, amount9); - color39 = NPC.GetAlpha(color39); - color39 *= 1f - num157; - Vector2 vector42 = NPC.Center + ((float)num160 / (float)num156 * MathHelper.TwoPi + NPC.rotation).ToRotationVector2() * scaleFactor9 * num157 - screenPos; - vector42 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector42 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector42, NPC.frame, color39, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color extraAfterimageColor = altColor; + extraAfterimageColor = Color.Lerp(extraAfterimageColor, altColor, lerpDrawTransition); + extraAfterimageColor = NPC.GetAlpha(extraAfterimageColor); + extraAfterimageColor *= 1f - extraAfterimageDampener; + Vector2 extraAfterimageDrawPos = NPC.Center + ((float)j / (float)extraAfterimageAmt * MathHelper.TwoPi + NPC.rotation).ToRotationVector2() * afterimageScaler * extraAfterimageDampener - screenPos; + extraAfterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + extraAfterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, extraAfterimageDrawPos, NPC.frame, extraAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Color color2 = drawColor; - color2 = Color.Lerp(color2, color36, amount9); - color2 = NPC.GetAlpha(color2); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, (phase3 && calamityGlobalNPC.newAI[3] == 1f ? color2 : NPC.GetAlpha(drawColor)), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color mainDrawingColor = altColor; + mainDrawingColor = Color.Lerp(mainDrawingColor, altColor, lerpDrawTransition); + mainDrawingColor = NPC.GetAlpha(mainDrawingColor); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, (phase3 && calamityGlobalNPC.newAI[3] == 1f ? mainDrawingColor : NPC.GetAlpha(altColor)), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); if (phase2) { texture2D15 = ModContent.Request("CalamityMod/NPCs/Bumblebirb/BirbGlow").Value; - Color color40 = Color.Lerp(Color.White, Color.Red, 0.5f); - color36 = Color.Red; + Color glowmaskColor = Color.Lerp(Color.White, Color.Red, 0.5f); + altColor = Color.Red; - amount9 = 1f; - num157 = 0.5f; - scaleFactor9 = 10f; - num154 = 1; + lerpDrawTransition = 1f; + extraAfterimageDampener = 0.5f; + afterimageScaler = 10f; + afterimageIncrement = 1; if (phaseSwitchPhase) { - float num161 = (phase3 ? calamityGlobalNPC.newAI[1] : calamityGlobalNPC.newAI[0]) - (float)num150; - num161 /= (float)num151; - color36 *= num161; - color40 *= num161; + float glowmaskDampener = (phase3 ? calamityGlobalNPC.newAI[1] : calamityGlobalNPC.newAI[0]) - (float)newAITracker; + glowmaskDampener /= (float)buffColorDampener; + altColor *= glowmaskDampener; + glowmaskColor *= glowmaskDampener; } if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163 += num154) + for (int k = 1; k < afterimageAmt; k += afterimageIncrement) { - Color color41 = color40; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color glowmaskAfterimageColor = glowmaskColor; + glowmaskAfterimageColor = Color.Lerp(glowmaskAfterimageColor, altColor, lerpDrawTransition); + glowmaskAfterimageColor *= (float)(afterimageAmt - k) / 15f; + Vector2 glowmaskAfterimageDrawPos = NPC.oldPos[k] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + glowmaskAfterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + glowmaskAfterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, glowmaskAfterimageDrawPos, NPC.frame, glowmaskAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } - for (int num164 = 1; num164 < num156; num164++) + for (int l = 1; l < extraAfterimageAmt; l++) { - Color color42 = color40; - color42 = Color.Lerp(color42, color36, amount9); - color42 = NPC.GetAlpha(color42); - color42 *= 1f - num157; - Vector2 vector45 = NPC.Center + ((float)num164 / (float)num156 * MathHelper.TwoPi + NPC.rotation).ToRotationVector2() * scaleFactor9 * num157 - screenPos; - vector45 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector45 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector45, NPC.frame, color42, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color extraGlowmaskAfterimageColor = glowmaskColor; + extraGlowmaskAfterimageColor = Color.Lerp(extraGlowmaskAfterimageColor, altColor, lerpDrawTransition); + extraGlowmaskAfterimageColor = NPC.GetAlpha(extraGlowmaskAfterimageColor); + extraGlowmaskAfterimageColor *= 1f - extraAfterimageDampener; + Vector2 extraGlowmaskAfterimageDrawPos = NPC.Center + ((float)l / (float)extraAfterimageAmt * MathHelper.TwoPi + NPC.rotation).ToRotationVector2() * afterimageScaler * extraAfterimageDampener - screenPos; + extraGlowmaskAfterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + extraGlowmaskAfterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, extraGlowmaskAfterimageDrawPos, NPC.frame, extraGlowmaskAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color40, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } return false; @@ -446,7 +444,7 @@ namespace CalamityMod.NPCs.Bumblebirb npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB Omega Healing Potion drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), 1, 50, 100); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), 1, 50, 100, true); // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedDragonfolly, ModContent.ItemType(), desc: DropHelper.FirstKillText); diff --git a/NPCs/Bumblebirb/Bumblefuck2.cs b/NPCs/Bumblebirb/Bumblefuck2.cs index ab2e47b4b0..9312bb3f08 100644 --- a/NPCs/Bumblebirb/Bumblefuck2.cs +++ b/NPCs/Bumblebirb/Bumblefuck2.cs @@ -99,30 +99,28 @@ namespace CalamityMod.NPCs.Bumblebirb spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); - Color color36 = Color.Gold; - float amount9 = 0.5f; - int num153 = NPC.ai[0] == 2.1f ? 7 : 0; + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); + int afterimageAmt = NPC.ai[0] == 2.1f ? 7 : 0; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.Gold, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; + Vector2 afterimageDrawPos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimageDrawPos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + afterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimageDrawPos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/CalClone/CalamitasClone.cs b/NPCs/CalClone/CalamitasClone.cs index e580a62dbf..1af5ce551a 100644 --- a/NPCs/CalClone/CalamitasClone.cs +++ b/NPCs/CalClone/CalamitasClone.cs @@ -37,7 +37,7 @@ namespace CalamityMod.NPCs.CalClone Main.npcFrameCount[NPC.type] = 6; NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.65f, PortraitScale = 0.65f @@ -138,14 +138,14 @@ namespace CalamityMod.NPCs.CalClone { for (int i = 1; i < afterimageAmt; i += 2) { - Color color1 = drawColor; - color1 = Color.Lerp(color1, white, colorLerpAmt); - color1 = NPC.GetAlpha(color1); - color1 *= (float)(afterimageAmt - i) / 15f; + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, white, colorLerpAmt); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; Vector2 offset = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; offset -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; offset += origin * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture, offset, NPC.frame, color1, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, offset, NPC.frame, afterimageColor, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); } } @@ -165,13 +165,13 @@ namespace CalamityMod.NPCs.CalClone { for (int i = 1; i < afterimageAmt; i++) { - Color color2 = color; - color2 = Color.Lerp(color2, white, colorLerpAmt); - color2 *= (float)(afterimageAmt - i) / 15f; + Color extraAfterimageColor = color; + extraAfterimageColor = Color.Lerp(extraAfterimageColor, white, colorLerpAmt); + extraAfterimageColor *= (float)(afterimageAmt - i) / 15f; Vector2 offset = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; offset -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; offset += origin * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture, offset, NPC.frame, color2, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, offset, NPC.frame, extraAfterimageColor, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); } } @@ -221,7 +221,7 @@ namespace CalamityMod.NPCs.CalClone npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB Ashes of Annihilation drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), 1, 6, 9); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), 1, 6, 9, true); // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedCalamitasClone, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -275,23 +275,23 @@ namespace CalamityMod.NPCs.CalClone NPC.height = 100; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int brimDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[brimDust].scale = 0.5f; + Main.dust[brimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int brimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); + Main.dust[brimDust2].noGravity = true; + Main.dust[brimDust2].velocity *= 5f; + brimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimDust2].velocity *= 2f; } } } diff --git a/NPCs/CalClone/Cataclysm.cs b/NPCs/CalClone/Cataclysm.cs index a51f821322..1f2c153cea 100644 --- a/NPCs/CalClone/Cataclysm.cs +++ b/NPCs/CalClone/Cataclysm.cs @@ -23,7 +23,7 @@ namespace CalamityMod.NPCs.CalClone Main.npcFrameCount[NPC.type] = 6; NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { PortraitScale = 0.8f, Scale = 0.5f, @@ -106,49 +106,47 @@ namespace CalamityMod.NPCs.CalClone spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 7; + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + int afterimageAmt = 7; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; + Vector2 afterimageDrawPos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + afterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + afterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimageDrawPos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/CalClone/CataclysmGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + Color pinkLerp = Color.Lerp(Color.White, Color.Red, 0.5f); if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color extraAfterimageColor = pinkLerp; + extraAfterimageColor = Color.Lerp(extraAfterimageColor, Color.White, 0.5f); + extraAfterimageColor *= (float)(afterimageAmt - j) / 15f; + Vector2 extraAfterimageDrawPos = NPC.oldPos[j] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + extraAfterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + extraAfterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, extraAfterimageDrawPos, NPC.frame, extraAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, pinkLerp, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -190,23 +188,23 @@ namespace CalamityMod.NPCs.CalClone NPC.height = 100; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int brimDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[brimDust].scale = 0.5f; + Main.dust[brimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int brimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); + Main.dust[brimDust2].noGravity = true; + Main.dust[brimDust2].velocity *= 5f; + brimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimDust2].velocity *= 2f; } } } diff --git a/NPCs/CalClone/Catastrophe.cs b/NPCs/CalClone/Catastrophe.cs index 20bae367ad..eac8c67b49 100644 --- a/NPCs/CalClone/Catastrophe.cs +++ b/NPCs/CalClone/Catastrophe.cs @@ -23,7 +23,7 @@ namespace CalamityMod.NPCs.CalClone Main.npcFrameCount[NPC.type] = 6; NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { PortraitScale = 0.8f, Scale = 0.5f @@ -106,49 +106,47 @@ namespace CalamityMod.NPCs.CalClone spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 7; + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + int afterimageAmt = 7; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; + Vector2 afterimageDrawPos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + afterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + afterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimageDrawPos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/CalClone/CatastropheGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + Color pinkLerp = Color.Lerp(Color.White, Color.Red, 0.5f); if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color extraAfterimageColor = pinkLerp; + extraAfterimageColor = Color.Lerp(extraAfterimageColor, Color.White, 0.5f); + extraAfterimageColor *= (float)(afterimageAmt - j) / 15f; + Vector2 extraAfterimageDrawPos = NPC.oldPos[j] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + extraAfterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + extraAfterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, extraAfterimageDrawPos, NPC.frame, extraAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, pinkLerp, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -190,23 +188,23 @@ namespace CalamityMod.NPCs.CalClone NPC.height = 100; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int brimDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[brimDust].scale = 0.5f; + Main.dust[brimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int brimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); + Main.dust[brimDust2].noGravity = true; + Main.dust[brimDust2].velocity *= 5f; + brimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimDust2].velocity *= 2f; } } } diff --git a/NPCs/CalamityAI.cs b/NPCs/CalamityAI.cs index d058a3a086..0bada01b73 100644 --- a/NPCs/CalamityAI.cs +++ b/NPCs/CalamityAI.cs @@ -1,4 +1,5 @@ -using CalamityMod.Buffs.DamageOverTime; +using System; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer; using CalamityMod.Dusts; @@ -12,9 +13,8 @@ using CalamityMod.NPCs.Bumblebirb; using CalamityMod.NPCs.CalClone; using CalamityMod.NPCs.CeaselessVoid; using CalamityMod.NPCs.Crags; -using CalamityMod.NPCs.Leviathan; -using CalamityMod.NPCs.OldDuke; using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.NPCs.OldDuke; using CalamityMod.NPCs.SulphurousSea; using CalamityMod.NPCs.SunkenSea; using CalamityMod.Projectiles.Boss; @@ -22,12 +22,10 @@ using CalamityMod.Projectiles.Enemy; using CalamityMod.Sounds; using CalamityMod.World; using Microsoft.Xna.Framework; -using System; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; -using static CalamityMod.NPCs.ExoMechs.Ares.AresBody; namespace CalamityMod.NPCs { @@ -44,8 +42,8 @@ namespace CalamityMod.NPCs bool getFuckedAI = Main.zenithWorld; - if (head) - CalamityGlobalNPC.aquaticScourge = npc.whoAmI; + if (head) + CalamityGlobalNPC.aquaticScourge = npc.whoAmI; // Adjust hostility and stats bool nonHostile = calamityGlobalNPC.newAI[0] == 0f; @@ -150,7 +148,7 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { float mistVelocity = death ? 10f : 8f; - Vector2 projectileVelocity = Vector2.Normalize(npc.Center + npc.velocity * 10f - npc.Center); + Vector2 projectileVelocity = (npc.Center + npc.velocity * 10f - npc.Center).SafeNormalize(Vector2.UnitY); int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + projectileVelocity * 5f, projectileVelocity * mistVelocity, type, damage, 0f, Main.myPlayer); @@ -174,7 +172,7 @@ namespace CalamityMod.NPCs for (int k = 0; k < totalProjectiles; k++) { Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + Vector2.Normalize(vector255) * 5f, vector255, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + vector255.SafeNormalize(Vector2.UnitY) * 5f, vector255, type, damage, 0f, Main.myPlayer); } } } @@ -182,7 +180,7 @@ namespace CalamityMod.NPCs // Velocity boost if (calamityGlobalNPC.newAI[3] == spiralGateValue) { - npc.velocity.Normalize(); + npc.velocity = npc.velocity.SafeNormalize(Vector2.UnitY); npc.velocity *= 24f; } @@ -238,12 +236,12 @@ namespace CalamityMod.NPCs { int maxLength = getFuckedAI ? 24 : death ? 80 : revenge ? 40 : expertMode ? 35 : 30; int Previous = npc.whoAmI; - for (int num36 = 0; num36 < maxLength; num36++) + for (int segments = 0; segments < maxLength; segments++) { int lol; - if (num36 >= 0 && num36 < maxLength - 1) + if (segments >= 0 && segments < maxLength - 1) { - if (num36 % 2 == 0) + 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); @@ -285,14 +283,14 @@ namespace CalamityMod.NPCs for (int i = 0; i < totalProjectiles; i++) { Vector2 velocity = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - velocity.Normalize(); + velocity = velocity.SafeNormalize(Vector2.UnitY); velocity *= Main.rand.Next(phase3 ? 300 : 100, 401) * 0.01f; float maximumVelocityMult = death ? 0.75f : 0.5f; if (expertMode) velocity *= 1f + (maximumVelocityMult * (0.5f - lifeRatio)); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + Vector2.Normalize(velocity) * 5f, velocity, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + velocity.SafeNormalize(Vector2.UnitY) * 5f, velocity, type, damage, 0f, Main.myPlayer); } } } @@ -321,7 +319,7 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { float toothVelocity = death ? 9f : 8f; - Vector2 projectileVelocity = Vector2.Normalize(player.Center - npc.Center); + Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY); int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); float accelerate = phase4 ? 1f : 0f; @@ -408,85 +406,85 @@ namespace CalamityMod.NPCs } // Velocity and movement - float num188 = 5f; - float num189 = 0.08f; - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float scourgeMaxSpeed = 5f; + float scourgeAcceleration = 0.08f; + Vector2 scourgePosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); Vector2 predictionVector = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? Main.player[npc.target].velocity * 20f : Vector2.Zero; - float num191 = player.position.X + (player.width / 2) + predictionVector.X; - float num192 = player.position.Y + (player.height / 2) + predictionVector.Y; + float scourgeTargetX = player.position.X + (player.width / 2) + predictionVector.X; + float scourgeTargetY = player.position.Y + (player.height / 2) + predictionVector.Y; if (head && !doSpiral) { if (calamityGlobalNPC.newAI[0] != 1f) { - num192 += 400; + scourgeTargetY += 400; if (Math.Abs(npc.Center.X - player.Center.X) < 500f) { if (npc.velocity.X > 0f) - num191 = player.Center.X + 600f; + scourgeTargetX = player.Center.X + 600f; else - num191 = player.Center.X - 600f; + scourgeTargetX = player.Center.X - 600f; } } if (calamityGlobalNPC.newAI[0] == 1f) { - num188 = revenge ? 14.4f : 12f; - num189 = revenge ? 0.18f : 0.15f; + scourgeMaxSpeed = revenge ? 14.4f : 12f; + scourgeAcceleration = revenge ? 0.18f : 0.15f; if (expertMode) { - num188 += 2.4f * (1f - lifeRatio); - num189 += 0.03f * (1f - lifeRatio); + scourgeMaxSpeed += 2.4f * (1f - lifeRatio); + scourgeAcceleration += 0.03f * (1f - lifeRatio); } - num188 += 3f * enrageScale; - num189 += 0.06f * enrageScale; + scourgeMaxSpeed += 3f * enrageScale; + scourgeAcceleration += 0.06f * enrageScale; if (death || getFuckedAI) { - num188 += 5f; - num189 -= getFuckedAI ? 0f : 0.03f; - num188 += Vector2.Distance(player.Center, npc.Center) * 0.001f; - num189 += Vector2.Distance(player.Center, npc.Center) * 0.000045f; + scourgeMaxSpeed += 5f; + scourgeAcceleration -= getFuckedAI ? 0f : 0.03f; + scourgeMaxSpeed += Vector2.Distance(player.Center, npc.Center) * 0.001f; + scourgeAcceleration += Vector2.Distance(player.Center, npc.Center) * 0.000045f; } // Increase acceleration after spiral attack if (npc.localAI[3] > 0f) { float accelerationMultiplier = MathHelper.Lerp(1f, 2f, npc.localAI[3] / colorFadeTimeAfterSpiral); - num189 *= accelerationMultiplier; + scourgeAcceleration *= accelerationMultiplier; } if (Main.getGoodWorld) { - num188 *= 1.15f; - num189 *= 1.15f; + scourgeMaxSpeed *= 1.15f; + scourgeAcceleration *= 1.15f; } } - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = npc.velocity.Length(); - if (num50 > 0f) + float scourgeHigherSpeed = scourgeMaxSpeed * 1.3f; + float scourgeLowerSpeed = scourgeMaxSpeed * 0.7f; + float scourgeSpeed = npc.velocity.Length(); + if (scourgeSpeed > 0f) { - if (num50 > num48) + if (scourgeSpeed > scourgeHigherSpeed) { - npc.velocity.Normalize(); - npc.velocity *= num48; + npc.velocity = npc.velocity.SafeNormalize(Vector2.UnitY); + npc.velocity *= scourgeHigherSpeed; } - else if (num50 < num49) + else if (scourgeSpeed < scourgeLowerSpeed) { - npc.velocity.Normalize(); - npc.velocity *= num49; + npc.velocity = npc.velocity.SafeNormalize(Vector2.UnitY); + npc.velocity *= scourgeLowerSpeed; } } } - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); + scourgeTargetX = (int)(scourgeTargetX / 16f) * 16; + scourgeTargetY = (int)(scourgeTargetY / 16f) * 16; + scourgePosition.X = (int)(scourgePosition.X / 16f) * 16; + scourgePosition.Y = (int)(scourgePosition.Y / 16f) * 16; + scourgeTargetX -= scourgePosition.X; + scourgeTargetY -= scourgePosition.Y; + float scourgeTargetDist = (float)Math.Sqrt(scourgeTargetX * scourgeTargetX + scourgeTargetY * scourgeTargetY); if (!head) { @@ -494,27 +492,27 @@ namespace CalamityMod.NPCs { try { - vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; + scourgePosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + scourgeTargetX = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - scourgePosition.X; + scourgeTargetY = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - scourgePosition.Y; } catch { } - npc.rotation = (float)Math.Atan2(num192, num191) + MathHelper.PiOver2; - num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = npc.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; + npc.rotation = (float)Math.Atan2(scourgeTargetY, scourgeTargetX) + MathHelper.PiOver2; + scourgeTargetDist = (float)Math.Sqrt(scourgeTargetX * scourgeTargetX + scourgeTargetY * scourgeTargetY); + int scourgeWidth = npc.width; + scourgeTargetDist = (scourgeTargetDist - scourgeWidth) / scourgeTargetDist; + scourgeTargetX *= scourgeTargetDist; + scourgeTargetY *= scourgeTargetDist; npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; - if (num191 < 0f) + npc.position.X = npc.position.X + scourgeTargetX; + npc.position.Y = npc.position.Y + scourgeTargetY; + if (scourgeTargetX < 0f) { npc.spriteDirection = -1; } - else if (num191 > 0f) + else if (scourgeTargetX > 0f) { npc.spriteDirection = 1; } @@ -522,77 +520,77 @@ namespace CalamityMod.NPCs } else if (!doSpiral) { - float num196 = Math.Abs(num191); - float num197 = Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; + float scourgeAbsoluteTargetX = Math.Abs(scourgeTargetX); + float scourgeAbsoluteTargetY = Math.Abs(scourgeTargetY); + float scourgeTimeToReachTarget = scourgeMaxSpeed / scourgeTargetDist; + scourgeTargetX *= scourgeTimeToReachTarget; + scourgeTargetY *= scourgeTimeToReachTarget; - if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) + if ((npc.velocity.X > 0f && scourgeTargetX > 0f) || (npc.velocity.X < 0f && scourgeTargetX < 0f) || (npc.velocity.Y > 0f && scourgeTargetY > 0f) || (npc.velocity.Y < 0f && scourgeTargetY < 0f)) { - if (npc.velocity.X < num191) + if (npc.velocity.X < scourgeTargetX) { - npc.velocity.X += num189; + npc.velocity.X += scourgeAcceleration; } else { - if (npc.velocity.X > num191) - npc.velocity.X -= num189; + if (npc.velocity.X > scourgeTargetX) + npc.velocity.X -= scourgeAcceleration; } - if (npc.velocity.Y < num192) + if (npc.velocity.Y < scourgeTargetY) { - npc.velocity.Y += num189; + npc.velocity.Y += scourgeAcceleration; } else { - if (npc.velocity.Y > num192) - npc.velocity.Y -= num189; + if (npc.velocity.Y > scourgeTargetY) + npc.velocity.Y -= scourgeAcceleration; } - if (Math.Abs(num192) < num188 * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) + if (Math.Abs(scourgeTargetY) < scourgeMaxSpeed * 0.2 && ((npc.velocity.X > 0f && scourgeTargetX < 0f) || (npc.velocity.X < 0f && scourgeTargetX > 0f))) { if (npc.velocity.Y > 0f) - npc.velocity.Y += num189 * 2f; + npc.velocity.Y += scourgeAcceleration * 2f; else - npc.velocity.Y -= num189 * 2f; + npc.velocity.Y -= scourgeAcceleration * 2f; } - if (Math.Abs(num191) < num188 * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) + if (Math.Abs(scourgeTargetX) < scourgeMaxSpeed * 0.2 && ((npc.velocity.Y > 0f && scourgeTargetY < 0f) || (npc.velocity.Y < 0f && scourgeTargetY > 0f))) { if (npc.velocity.X > 0f) - npc.velocity.X += num189 * 2f; + npc.velocity.X += scourgeAcceleration * 2f; else - npc.velocity.X -= num189 * 2f; + npc.velocity.X -= scourgeAcceleration * 2f; } } else { - if (num196 > num197) + if (scourgeAbsoluteTargetX > scourgeAbsoluteTargetY) { - if (npc.velocity.X < num191) - npc.velocity.X += num189 * 1.1f; - else if (npc.velocity.X > num191) - npc.velocity.X -= num189 * 1.1f; + if (npc.velocity.X < scourgeTargetX) + npc.velocity.X += scourgeAcceleration * 1.1f; + else if (npc.velocity.X > scourgeTargetX) + npc.velocity.X -= scourgeAcceleration * 1.1f; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < scourgeMaxSpeed * 0.5) { if (npc.velocity.Y > 0f) - npc.velocity.Y += num189; + npc.velocity.Y += scourgeAcceleration; else - npc.velocity.Y -= num189; + npc.velocity.Y -= scourgeAcceleration; } } else { - if (npc.velocity.Y < num192) - npc.velocity.Y += num189 * 1.1f; - else if (npc.velocity.Y > num192) - npc.velocity.Y -= num189 * 1.1f; + if (npc.velocity.Y < scourgeTargetY) + npc.velocity.Y += scourgeAcceleration * 1.1f; + else if (npc.velocity.Y > scourgeTargetY) + npc.velocity.Y -= scourgeAcceleration * 1.1f; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < scourgeMaxSpeed * 0.5) { if (npc.velocity.X > 0f) - npc.velocity.X += num189; + npc.velocity.X += scourgeAcceleration; else - npc.velocity.X -= num189; + npc.velocity.X -= scourgeAcceleration; } } } @@ -709,7 +707,7 @@ namespace CalamityMod.NPCs int size = (npc.ai[0] == 2f) ? 50 : 35; if (npc.ai[0] != 1f) { - for (int num1011 = 0; num1011 < 2; num1011++) + for (int i = 0; i < 2; i++) { if (Main.rand.Next(3) < dustAmt) { @@ -986,11 +984,11 @@ namespace CalamityMod.NPCs type = ModContent.ProjectileType(); SoundEngine.PlaySound(SoundID.Item30, player.Center); } - Vector2 projectileVelocity = Vector2.Normalize(player.Center - npc.Center) * velocity; + Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity; if (Main.netMode != NetmodeID.MultiplayerClient) { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + Vector2.Normalize(projectileVelocity) * 5f, projectileVelocity, type, damage, 0f, Main.myPlayer, player.position.X, player.position.Y); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 5f, projectileVelocity, type, damage, 0f, Main.myPlayer, player.position.X, player.position.Y); Main.projectile[proj].timeLeft = 240; if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) Main.projectile[proj].extraUpdates += 1; @@ -1006,7 +1004,7 @@ namespace CalamityMod.NPCs type = ModContent.ProjectileType(); SoundEngine.PlaySound(SoundID.Item21, player.Center); } - projectileVelocity = Vector2.Normalize(player.Center - npc.Center) * velocity; + projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity; int numProj = death ? 8 : 4; int spread = death ? 90 : 45; if (Main.getGoodWorld) @@ -1021,7 +1019,7 @@ namespace CalamityMod.NPCs for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - int proj2 = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + Vector2.Normalize(perturbedSpeed) * 5f, perturbedSpeed, type, damage, 0f, Main.myPlayer, 1f, 0f); + int proj2 = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 5f, perturbedSpeed, type, damage, 0f, Main.myPlayer, 1f, 0f); if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) Main.projectile[proj2].extraUpdates += 1; } @@ -1065,10 +1063,10 @@ namespace CalamityMod.NPCs float radialOffset = 0.2f; float diameter = 80f; - projectileVelocity = Vector2.Normalize(projectileVelocity) * projectileSpeed; + projectileVelocity = projectileVelocity.SafeNormalize(Vector2.UnitY) * projectileSpeed; Vector2 velocity = projectileVelocity; - velocity.Normalize(); + velocity = velocity.SafeNormalize(Vector2.UnitY); velocity *= diameter; int totalProjectiles = 6; @@ -1109,7 +1107,7 @@ namespace CalamityMod.NPCs for (int k = 0; k < totalProjectiles; k++) { Vector2 vector255 = spinningPoint.RotatedBy(radians2 * k); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + Vector2.Normalize(vector255) * 5f, vector255, type, damage, 0f, Main.myPlayer, 1f, 0f); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + vector255.SafeNormalize(Vector2.UnitY) * 5f, vector255, type, damage, 0f, Main.myPlayer, 1f, 0f); if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) Main.projectile[proj].extraUpdates += 1; } @@ -1120,7 +1118,7 @@ namespace CalamityMod.NPCs for (int k = 0; k < totalProjectiles; k++) { Vector2 vector255 = spinningPoint.RotatedBy(radians2 * k); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + Vector2.Normalize(vector255) * 5f, vector255 * 0.75f, type, damage, 0f, Main.myPlayer, 1f, 0f); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + vector255.SafeNormalize(Vector2.UnitY) * 5f, vector255 * 0.75f, type, damage, 0f, Main.myPlayer, 1f, 0f); if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) Main.projectile[proj].extraUpdates += 1; } @@ -1160,13 +1158,13 @@ namespace CalamityMod.NPCs Vector2 aimAt = player.Center + player.velocity * 20f; float aimResponsiveness = bossRush ? 0.05f : (npc.ai[2] == 1f || death) ? 0.1f : 0.25f; - Vector2 aimVector = Vector2.Normalize(aimAt - source); + Vector2 aimVector = (aimAt - source).SafeNormalize(Vector2.UnitY); if (aimVector.HasNaNs()) aimVector = -Vector2.UnitY; - aimVector = Vector2.Normalize(Vector2.Lerp(aimVector, Vector2.Normalize(npc.velocity), aimResponsiveness)); + aimVector = (Vector2.Lerp(aimVector, npc.velocity.SafeNormalize(Vector2.UnitY), aimResponsiveness)).SafeNormalize(Vector2.UnitY); aimVector *= 6f; - Vector2 laserVelocity = Vector2.Normalize(aimVector); + Vector2 laserVelocity = aimVector.SafeNormalize(Vector2.UnitY); if (laserVelocity.HasNaNs()) laserVelocity = -Vector2.UnitY; @@ -1205,7 +1203,7 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { Vector2 laserVelocity2 = new Vector2(npc.localAI[0], npc.localAI[1]); - laserVelocity2.Normalize(); + laserVelocity2 = laserVelocity2.SafeNormalize(Vector2.UnitY); int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); @@ -1350,8 +1348,8 @@ namespace CalamityMod.NPCs // Bullet hells at 70% and 10%, brothers at 40% if (npc.life > 0) { - int num660 = (int)(npc.lifeMax * 0.3); - if ((npc.life + num660) < calamityGlobalNPC.newAI[0]) + int calClonePhaseThreshold = (int)(npc.lifeMax * 0.3); + if ((npc.life + calClonePhaseThreshold) < calamityGlobalNPC.newAI[0]) { calamityGlobalNPC.newAI[0] = npc.life; if (calamityGlobalNPC.newAI[0] <= npc.lifeMax * 0.1) @@ -2028,38 +2026,38 @@ namespace CalamityMod.NPCs enrageScale += 2f; } - float num840 = npc.position.X + (npc.width / 2) - player.position.X - (player.width / 2); - float num841 = npc.position.Y + npc.height - 59f - player.position.Y - (player.height / 2); - float num842 = (float)Math.Atan2(num841, num840) + MathHelper.PiOver2; - if (num842 < 0f) - num842 += MathHelper.TwoPi; - else if (num842 > MathHelper.TwoPi) - num842 -= MathHelper.TwoPi; + float calCloneBroPlayerXDist = npc.position.X + (npc.width / 2) - player.position.X - (player.width / 2); + float calCloneBroPlayerYDist = npc.position.Y + npc.height - 59f - player.position.Y - (player.height / 2); + float calCloneBroRotation = (float)Math.Atan2(calCloneBroPlayerYDist, calCloneBroPlayerXDist) + MathHelper.PiOver2; + if (calCloneBroRotation < 0f) + calCloneBroRotation += MathHelper.TwoPi; + else if (calCloneBroRotation > MathHelper.TwoPi) + calCloneBroRotation -= MathHelper.TwoPi; - float num843 = 0.15f; - if (npc.rotation < num842) + float calCloneBroRotationSpeed = 0.15f; + if (npc.rotation < calCloneBroRotation) { - if ((num842 - npc.rotation) > MathHelper.Pi) - npc.rotation -= num843; + if ((calCloneBroRotation - npc.rotation) > MathHelper.Pi) + npc.rotation -= calCloneBroRotationSpeed; else - npc.rotation += num843; + npc.rotation += calCloneBroRotationSpeed; } - else if (npc.rotation > num842) + else if (npc.rotation > calCloneBroRotation) { - if ((npc.rotation - num842) > MathHelper.Pi) - npc.rotation += num843; + if ((npc.rotation - calCloneBroRotation) > MathHelper.Pi) + npc.rotation += calCloneBroRotationSpeed; else - npc.rotation -= num843; + npc.rotation -= calCloneBroRotationSpeed; } - if (npc.rotation > num842 - num843 && npc.rotation < num842 + num843) - npc.rotation = num842; + if (npc.rotation > calCloneBroRotation - calCloneBroRotationSpeed && npc.rotation < calCloneBroRotation + calCloneBroRotationSpeed) + npc.rotation = calCloneBroRotation; if (npc.rotation < 0f) npc.rotation += MathHelper.TwoPi; else if (npc.rotation > MathHelper.TwoPi) npc.rotation -= MathHelper.TwoPi; - if (npc.rotation > num842 - num843 && npc.rotation < num842 + num843) - npc.rotation = num842; + if (npc.rotation > calCloneBroRotation - calCloneBroRotationSpeed && npc.rotation < calCloneBroRotation + calCloneBroRotationSpeed) + npc.rotation = calCloneBroRotation; if (!player.active || player.dead) { @@ -2090,69 +2088,69 @@ namespace CalamityMod.NPCs if (npc.ai[1] == 0f) { - float num861 = 5f; - float num862 = 0.1f; - num861 += 2f * enrageScale; - num862 += 0.06f * enrageScale; + float calCloneBroProjAttackMaxSpeed = 5f; + float calCloneBroProjAttackAccel = 0.1f; + calCloneBroProjAttackMaxSpeed += 2f * enrageScale; + calCloneBroProjAttackAccel += 0.06f * enrageScale; if (Main.getGoodWorld) { - num861 *= 1.15f; - num862 *= 1.15f; + calCloneBroProjAttackMaxSpeed *= 1.15f; + calCloneBroProjAttackAccel *= 1.15f; } - int num863 = 1; + int calCloneBroProjAttackDirection = 1; if (npc.position.X + (npc.width / 2) < player.position.X + player.width) - num863 = -1; + calCloneBroProjAttackDirection = -1; - Vector2 vector86 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num864 = player.position.X + (player.width / 2) + (num863 * 180) - vector86.X; - float num865 = player.position.Y + (player.height / 2) - vector86.Y; - float num866 = (float)Math.Sqrt(num864 * num864 + num865 * num865); + Vector2 calCloneBroProjLocation = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float calCloneBroProjTargetX = player.position.X + (player.width / 2) + (calCloneBroProjAttackDirection * 180) - calCloneBroProjLocation.X; + float calCloneBroProjTargetY = player.position.Y + (player.height / 2) - calCloneBroProjLocation.Y; + float calCloneBroProjTargetDist = (float)Math.Sqrt(calCloneBroProjTargetX * calCloneBroProjTargetX + calCloneBroProjTargetY * calCloneBroProjTargetY); if (expertMode) { - if (num866 > 300f) - num861 += 0.5f; - if (num866 > 400f) - num861 += 0.5f; - if (num866 > 500f) - num861 += 0.55f; - if (num866 > 600f) - num861 += 0.55f; - if (num866 > 700f) - num861 += 0.6f; - if (num866 > 800f) - num861 += 0.6f; + if (calCloneBroProjTargetDist > 300f) + calCloneBroProjAttackMaxSpeed += 0.5f; + if (calCloneBroProjTargetDist > 400f) + calCloneBroProjAttackMaxSpeed += 0.5f; + if (calCloneBroProjTargetDist > 500f) + calCloneBroProjAttackMaxSpeed += 0.55f; + if (calCloneBroProjTargetDist > 600f) + calCloneBroProjAttackMaxSpeed += 0.55f; + if (calCloneBroProjTargetDist > 700f) + calCloneBroProjAttackMaxSpeed += 0.6f; + if (calCloneBroProjTargetDist > 800f) + calCloneBroProjAttackMaxSpeed += 0.6f; } - num866 = num861 / num866; - num864 *= num866; - num865 *= num866; + calCloneBroProjTargetDist = calCloneBroProjAttackMaxSpeed / calCloneBroProjTargetDist; + calCloneBroProjTargetX *= calCloneBroProjTargetDist; + calCloneBroProjTargetY *= calCloneBroProjTargetDist; - if (npc.velocity.X < num864) + if (npc.velocity.X < calCloneBroProjTargetX) { - npc.velocity.X += num862; - if (npc.velocity.X < 0f && num864 > 0f) - npc.velocity.X += num862; + npc.velocity.X += calCloneBroProjAttackAccel; + if (npc.velocity.X < 0f && calCloneBroProjTargetX > 0f) + npc.velocity.X += calCloneBroProjAttackAccel; } - else if (npc.velocity.X > num864) + else if (npc.velocity.X > calCloneBroProjTargetX) { - npc.velocity.X -= num862; - if (npc.velocity.X > 0f && num864 < 0f) - npc.velocity.X -= num862; + npc.velocity.X -= calCloneBroProjAttackAccel; + if (npc.velocity.X > 0f && calCloneBroProjTargetX < 0f) + npc.velocity.X -= calCloneBroProjAttackAccel; } - if (npc.velocity.Y < num865) + if (npc.velocity.Y < calCloneBroProjTargetY) { - npc.velocity.Y += num862; - if (npc.velocity.Y < 0f && num865 > 0f) - npc.velocity.Y += num862; + npc.velocity.Y += calCloneBroProjAttackAccel; + if (npc.velocity.Y < 0f && calCloneBroProjTargetY > 0f) + npc.velocity.Y += calCloneBroProjAttackAccel; } - else if (npc.velocity.Y > num865) + else if (npc.velocity.Y > calCloneBroProjTargetY) { - npc.velocity.Y -= num862; - if (npc.velocity.Y > 0f && num865 < 0f) - npc.velocity.Y -= num862; + npc.velocity.Y -= calCloneBroProjAttackAccel; + if (npc.velocity.Y > 0f && calCloneBroProjTargetY < 0f) + npc.velocity.Y -= calCloneBroProjAttackAccel; } npc.ai[2] += 1f; @@ -2177,29 +2175,29 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[1] += 1f; + npc.localAI[1] += 3f; if (revenge) - npc.localAI[1] += 0.5f; + npc.localAI[1] += 1f; if (npc.localAI[1] > 12f) { npc.localAI[1] = 0f; - float num867 = NPC.AnyNPCs(ModContent.NPCType()) ? 4f : 6f; - num867 += enrageScale; + float calCloneBroProjSpeed = NPC.AnyNPCs(ModContent.NPCType()) ? 4f : 6f; + calCloneBroProjSpeed += enrageScale; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - vector86 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num864 = player.position.X + (player.width / 2) - vector86.X; - num865 = player.position.Y + (player.height / 2) - vector86.Y; - num866 = (float)Math.Sqrt(num864 * num864 + num865 * num865); - num866 = num867 / num866; - num864 *= num866; - num865 *= num866; - num865 += npc.velocity.Y * 0.5f; - num864 += npc.velocity.X * 0.5f; - vector86.X -= num864; - vector86.Y -= num865; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector86.X, vector86.Y, num864, num865, type, damage, 0f, Main.myPlayer, 0f, 0f); + calCloneBroProjLocation = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + calCloneBroProjTargetX = player.position.X + (player.width / 2) - calCloneBroProjLocation.X; + calCloneBroProjTargetY = player.position.Y + (player.height / 2) - calCloneBroProjLocation.Y; + calCloneBroProjTargetDist = (float)Math.Sqrt(calCloneBroProjTargetX * calCloneBroProjTargetX + calCloneBroProjTargetY * calCloneBroProjTargetY); + calCloneBroProjTargetDist = calCloneBroProjSpeed / calCloneBroProjTargetDist; + calCloneBroProjTargetX *= calCloneBroProjTargetDist; + calCloneBroProjTargetY *= calCloneBroProjTargetDist; + calCloneBroProjTargetY += npc.velocity.Y * 0.5f; + calCloneBroProjTargetX += npc.velocity.X * 0.5f; + calCloneBroProjLocation.X -= calCloneBroProjTargetX; + calCloneBroProjLocation.Y -= calCloneBroProjTargetY; + Projectile.NewProjectile(npc.GetSource_FromAI(), calCloneBroProjLocation.X, calCloneBroProjLocation.Y, calCloneBroProjTargetX, calCloneBroProjTargetY, type, damage, 0f, Main.myPlayer, 0f, 0f); } } } @@ -2209,24 +2207,24 @@ namespace CalamityMod.NPCs if (npc.ai[1] == 1f) { SoundEngine.PlaySound(SoundID.Roar, npc.Center); - npc.rotation = num842; + npc.rotation = calCloneBroRotation; - float num870 = 14f + (death ? 4f * (1f - lifeRatio) : 0f); - num870 += 3f * enrageScale; + float calCloneBroChargeSpeed = 14f + (death ? 4f * (1f - lifeRatio) : 0f); + calCloneBroChargeSpeed += 3f * enrageScale; if (expertMode) - num870 += 2f; + calCloneBroChargeSpeed += 2f; if (revenge) - num870 += 2f; + calCloneBroChargeSpeed += 2f; if (Main.getGoodWorld) - num870 *= 1.25f; + calCloneBroChargeSpeed *= 1.25f; - Vector2 vector87 = npc.Center; - float num871 = player.Center.X - vector87.X; - float num872 = player.Center.Y - vector87.Y; - float num873 = (float)Math.Sqrt(num871 * num871 + num872 * num872); - num873 = num870 / num873; - npc.velocity.X = num871 * num873; - npc.velocity.Y = num872 * num873; + Vector2 calCloneBroChargeCenter = npc.Center; + float calCloneBroChargeTargetXDist = player.Center.X - calCloneBroChargeCenter.X; + float calCloneBroChargeTargetYDist = player.Center.Y - calCloneBroChargeCenter.Y; + float calCloneBroChargeTargetDistance = (float)Math.Sqrt(calCloneBroChargeTargetXDist * calCloneBroChargeTargetXDist + calCloneBroChargeTargetYDist * calCloneBroChargeTargetYDist); + calCloneBroChargeTargetDistance = calCloneBroChargeSpeed / calCloneBroChargeTargetDistance; + npc.velocity.X = calCloneBroChargeTargetXDist * calCloneBroChargeTargetDistance; + npc.velocity.Y = calCloneBroChargeTargetYDist * calCloneBroChargeTargetDistance; npc.ai[1] = 2f; if (Main.zenithWorld) @@ -2279,7 +2277,7 @@ namespace CalamityMod.NPCs npc.ai[3] += 1f; npc.ai[2] = 0f; npc.target = 255; - npc.rotation = num842; + npc.rotation = calCloneBroRotation; npc.TargetClosest(); if (npc.ai[3] >= 3f) { @@ -2335,38 +2333,38 @@ namespace CalamityMod.NPCs enrageScale += 2f; } - float num840 = npc.position.X + (npc.width / 2) - player.position.X - (player.width / 2); - float num841 = npc.position.Y + npc.height - 59f - player.position.Y - (player.height / 2); - float num842 = (float)Math.Atan2(num841, num840) + MathHelper.PiOver2; - if (num842 < 0f) - num842 += MathHelper.TwoPi; - else if (num842 > MathHelper.TwoPi) - num842 -= MathHelper.TwoPi; + float calCloneBroPlayerXDist = npc.position.X + (npc.width / 2) - player.position.X - (player.width / 2); + float calCloneBroPlayerYDist = npc.position.Y + npc.height - 59f - player.position.Y - (player.height / 2); + float calCloneBroRotation = (float)Math.Atan2(calCloneBroPlayerYDist, calCloneBroPlayerXDist) + MathHelper.PiOver2; + if (calCloneBroRotation < 0f) + calCloneBroRotation += MathHelper.TwoPi; + else if (calCloneBroRotation > MathHelper.TwoPi) + calCloneBroRotation -= MathHelper.TwoPi; - float num843 = 0.15f; - if (npc.rotation < num842) + float calCloneBroRotationSpeed = 0.15f; + if (npc.rotation < calCloneBroRotation) { - if ((num842 - npc.rotation) > MathHelper.Pi) - npc.rotation -= num843; + if ((calCloneBroRotation - npc.rotation) > MathHelper.Pi) + npc.rotation -= calCloneBroRotationSpeed; else - npc.rotation += num843; + npc.rotation += calCloneBroRotationSpeed; } - else if (npc.rotation > num842) + else if (npc.rotation > calCloneBroRotation) { - if ((npc.rotation - num842) > MathHelper.Pi) - npc.rotation += num843; + if ((npc.rotation - calCloneBroRotation) > MathHelper.Pi) + npc.rotation += calCloneBroRotationSpeed; else - npc.rotation -= num843; + npc.rotation -= calCloneBroRotationSpeed; } - if (npc.rotation > num842 - num843 && npc.rotation < num842 + num843) - npc.rotation = num842; + if (npc.rotation > calCloneBroRotation - calCloneBroRotationSpeed && npc.rotation < calCloneBroRotation + calCloneBroRotationSpeed) + npc.rotation = calCloneBroRotation; if (npc.rotation < 0f) npc.rotation += MathHelper.TwoPi; else if (npc.rotation > MathHelper.TwoPi) npc.rotation -= MathHelper.TwoPi; - if (npc.rotation > num842 - num843 && npc.rotation < num842 + num843) - npc.rotation = num842; + if (npc.rotation > calCloneBroRotation - calCloneBroRotationSpeed && npc.rotation < calCloneBroRotation + calCloneBroRotationSpeed) + npc.rotation = calCloneBroRotation; if (!player.active || player.dead) { @@ -2397,69 +2395,69 @@ namespace CalamityMod.NPCs if (npc.ai[1] == 0f) { - float num861 = 4.5f; - float num862 = 0.2f; - num861 += 2f * enrageScale; - num862 += 0.1f * enrageScale; + float calCloneBroProjAttackMaxSpeed = 4.5f; + float calCloneBroProjAttackAccel = 0.2f; + calCloneBroProjAttackMaxSpeed += 2f * enrageScale; + calCloneBroProjAttackAccel += 0.1f * enrageScale; if (Main.getGoodWorld) { - num861 *= 1.15f; - num862 *= 1.15f; + calCloneBroProjAttackMaxSpeed *= 1.15f; + calCloneBroProjAttackAccel *= 1.15f; } - int num863 = 1; + int calCloneBroProjAttackDirection = 1; if (npc.Center.X < player.Center.X) - num863 = -1; + calCloneBroProjAttackDirection = -1; - Vector2 vector86 = npc.Center; - float num864 = player.Center.X + (num863 * 180) - vector86.X; - float num865 = player.Center.Y - vector86.Y; - float num866 = (float)Math.Sqrt(num864 * num864 + num865 * num865); + Vector2 calCloneBroProjLocation = npc.Center; + float calCloneBroProjTargetX = player.Center.X + (calCloneBroProjAttackDirection * 180) - calCloneBroProjLocation.X; + float calCloneBroProjTargetY = player.Center.Y - calCloneBroProjLocation.Y; + float calCloneBroProjTargetDist = (float)Math.Sqrt(calCloneBroProjTargetX * calCloneBroProjTargetX + calCloneBroProjTargetY * calCloneBroProjTargetY); if (expertMode) { - if (num866 > 300f) - num861 += 0.5f; - if (num866 > 400f) - num861 += 0.5f; - if (num866 > 500f) - num861 += 0.55f; - if (num866 > 600f) - num861 += 0.55f; - if (num866 > 700f) - num861 += 0.6f; - if (num866 > 800f) - num861 += 0.6f; + if (calCloneBroProjTargetDist > 300f) + calCloneBroProjAttackMaxSpeed += 0.5f; + if (calCloneBroProjTargetDist > 400f) + calCloneBroProjAttackMaxSpeed += 0.5f; + if (calCloneBroProjTargetDist > 500f) + calCloneBroProjAttackMaxSpeed += 0.55f; + if (calCloneBroProjTargetDist > 600f) + calCloneBroProjAttackMaxSpeed += 0.55f; + if (calCloneBroProjTargetDist > 700f) + calCloneBroProjAttackMaxSpeed += 0.6f; + if (calCloneBroProjTargetDist > 800f) + calCloneBroProjAttackMaxSpeed += 0.6f; } - num866 = num861 / num866; - num864 *= num866; - num865 *= num866; + calCloneBroProjTargetDist = calCloneBroProjAttackMaxSpeed / calCloneBroProjTargetDist; + calCloneBroProjTargetX *= calCloneBroProjTargetDist; + calCloneBroProjTargetY *= calCloneBroProjTargetDist; - if (npc.velocity.X < num864) + if (npc.velocity.X < calCloneBroProjTargetX) { - npc.velocity.X += num862; - if (npc.velocity.X < 0f && num864 > 0f) - npc.velocity.X += num862; + npc.velocity.X += calCloneBroProjAttackAccel; + if (npc.velocity.X < 0f && calCloneBroProjTargetX > 0f) + npc.velocity.X += calCloneBroProjAttackAccel; } - else if (npc.velocity.X > num864) + else if (npc.velocity.X > calCloneBroProjTargetX) { - npc.velocity.X -= num862; - if (npc.velocity.X > 0f && num864 < 0f) - npc.velocity.X -= num862; + npc.velocity.X -= calCloneBroProjAttackAccel; + if (npc.velocity.X > 0f && calCloneBroProjTargetX < 0f) + npc.velocity.X -= calCloneBroProjAttackAccel; } - if (npc.velocity.Y < num865) + if (npc.velocity.Y < calCloneBroProjTargetY) { - npc.velocity.Y += num862; - if (npc.velocity.Y < 0f && num865 > 0f) - npc.velocity.Y += num862; + npc.velocity.Y += calCloneBroProjAttackAccel; + if (npc.velocity.Y < 0f && calCloneBroProjTargetY > 0f) + npc.velocity.Y += calCloneBroProjAttackAccel; } - else if (npc.velocity.Y > num865) + else if (npc.velocity.Y > calCloneBroProjTargetY) { - npc.velocity.Y -= num862; - if (npc.velocity.Y > 0f && num865 < 0f) - npc.velocity.Y -= num862; + npc.velocity.Y -= calCloneBroProjAttackAccel; + if (npc.velocity.Y > 0f && calCloneBroProjTargetY < 0f) + npc.velocity.Y -= calCloneBroProjAttackAccel; } npc.ai[2] += 1f; @@ -2491,22 +2489,22 @@ namespace CalamityMod.NPCs if (npc.localAI[1] > 50f) { npc.localAI[1] = 0f; - float num867 = death ? 14f : 12f; - num867 += 3f * enrageScale; + float calCloneBroProjSpeed = death ? 14f : 12f; + calCloneBroProjSpeed += 3f * enrageScale; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - vector86 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num864 = player.position.X + (player.width / 2) - vector86.X; - num865 = player.position.Y + (player.height / 2) - vector86.Y; - num866 = (float)Math.Sqrt(num864 * num864 + num865 * num865); - num866 = num867 / num866; - num864 *= num866; - num865 *= num866; - num865 += npc.velocity.Y * 0.5f; - num864 += npc.velocity.X * 0.5f; - vector86.X -= num864; - vector86.Y -= num865; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector86.X, vector86.Y, num864, num865, type, damage, 0f, Main.myPlayer, 0f, 0f); + calCloneBroProjLocation = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + calCloneBroProjTargetX = player.position.X + (player.width / 2) - calCloneBroProjLocation.X; + calCloneBroProjTargetY = player.position.Y + (player.height / 2) - calCloneBroProjLocation.Y; + calCloneBroProjTargetDist = (float)Math.Sqrt(calCloneBroProjTargetX * calCloneBroProjTargetX + calCloneBroProjTargetY * calCloneBroProjTargetY); + calCloneBroProjTargetDist = calCloneBroProjSpeed / calCloneBroProjTargetDist; + calCloneBroProjTargetX *= calCloneBroProjTargetDist; + calCloneBroProjTargetY *= calCloneBroProjTargetDist; + calCloneBroProjTargetY += npc.velocity.Y * 0.5f; + calCloneBroProjTargetX += npc.velocity.X * 0.5f; + calCloneBroProjLocation.X -= calCloneBroProjTargetX; + calCloneBroProjLocation.Y -= calCloneBroProjTargetY; + Projectile.NewProjectile(npc.GetSource_FromAI(), calCloneBroProjLocation.X, calCloneBroProjLocation.Y, calCloneBroProjTargetX, calCloneBroProjTargetY, type, damage, 0f, Main.myPlayer, 0f, 0f); } } } @@ -2516,24 +2514,24 @@ namespace CalamityMod.NPCs if (npc.ai[1] == 1f) { SoundEngine.PlaySound(SoundID.Roar, npc.Center); - npc.rotation = num842; + npc.rotation = calCloneBroRotation; - float num870 = (NPC.AnyNPCs(ModContent.NPCType()) ? 12f : 16f) + (death ? 4f * (1f - lifeRatio) : 0f); - num870 += 4f * enrageScale; + float calCloneBroChargeSpeed = (NPC.AnyNPCs(ModContent.NPCType()) ? 12f : 16f) + (death ? 4f * (1f - lifeRatio) : 0f); + calCloneBroChargeSpeed += 4f * enrageScale; if (expertMode) - num870 += 2f; + calCloneBroChargeSpeed += 2f; if (revenge) - num870 += 2f; + calCloneBroChargeSpeed += 2f; if (Main.getGoodWorld) - num870 *= 1.25f; + calCloneBroChargeSpeed *= 1.25f; - Vector2 vector87 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num871 = player.position.X + (player.width / 2) - vector87.X; - float num872 = player.position.Y + (player.height / 2) - vector87.Y; - float num873 = (float)Math.Sqrt(num871 * num871 + num872 * num872); - num873 = num870 / num873; - npc.velocity.X = num871 * num873; - npc.velocity.Y = num872 * num873; + Vector2 calCloneBroChargeCenter = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float calCloneBroChargeTargetXDist = player.position.X + (player.width / 2) - calCloneBroChargeCenter.X; + float calCloneBroChargeTargetYDist = player.position.Y + (player.height / 2) - calCloneBroChargeCenter.Y; + float calCloneBroChargeTargetDistance = (float)Math.Sqrt(calCloneBroChargeTargetXDist * calCloneBroChargeTargetXDist + calCloneBroChargeTargetYDist * calCloneBroChargeTargetYDist); + calCloneBroChargeTargetDistance = calCloneBroChargeSpeed / calCloneBroChargeTargetDistance; + npc.velocity.X = calCloneBroChargeTargetXDist * calCloneBroChargeTargetDistance; + npc.velocity.Y = calCloneBroChargeTargetYDist * calCloneBroChargeTargetDistance; npc.ai[1] = 2f; if (Main.zenithWorld) @@ -2586,7 +2584,7 @@ namespace CalamityMod.NPCs npc.ai[3] += 1f; npc.ai[2] = 0f; npc.TargetClosest(); - npc.rotation = num842; + npc.rotation = calCloneBroRotation; if (npc.ai[3] >= 4f) { npc.ai[1] = 0f; @@ -2755,18 +2753,18 @@ namespace CalamityMod.NPCs { int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - float num1070 = 7f; - float num1071 = player.Center.X - npc.Center.X; - float num1072 = player.Center.Y - npc.Center.Y; - float num1073 = (float)Math.Sqrt(num1071 * num1071 + num1072 * num1072); - num1073 = num1070 / num1073; - num1071 *= num1073; - num1072 *= num1073; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, num1071, num1072, type, damage, 0f, Main.myPlayer); + float aureusLaserSpeed = 7f; + float aureusLaserTargetX = player.Center.X - npc.Center.X; + float aureusLaserTargetY = player.Center.Y - npc.Center.Y; + float aureusLaserTargetDist = (float)Math.Sqrt(aureusLaserTargetX * aureusLaserTargetX + aureusLaserTargetY * aureusLaserTargetY); + aureusLaserTargetDist = aureusLaserSpeed / aureusLaserTargetDist; + aureusLaserTargetX *= aureusLaserTargetDist; + aureusLaserTargetY *= aureusLaserTargetDist; + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, aureusLaserTargetX, aureusLaserTargetY, type, damage, 0f, Main.myPlayer); for (int i = 0; i < 4; i++) { Vector2 offset = new Vector2(Main.rand.Next(-6, 7), Main.rand.Next(-6, 7)); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, num1071 + offset.X, num1072 + offset.Y, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, aureusLaserTargetX + offset.X, aureusLaserTargetY + offset.Y, type, damage, 0f, Main.myPlayer); } } astrumAureus.slimePhase = 1; @@ -2973,19 +2971,19 @@ namespace CalamityMod.NPCs npc.noTileCollide = true; // Walk through tiles if colliding with tiles and player is out of reach - int num854 = 80; - int num855 = 20; - Vector2 position2 = new Vector2(npc.Center.X - (num854 / 2), npc.position.Y + npc.height - num855); + int aureusHitboxWidth = 80; + int aureusHitboxHeight = 20; + Vector2 aureusHitboxTileCollideSize = new Vector2(npc.Center.X - (aureusHitboxWidth / 2), npc.position.Y + npc.height - aureusHitboxHeight); - bool flag52 = false; + bool nearPlayerWalkingThroughTiles = false; if (npc.position.X < player.position.X && npc.position.X + npc.width > player.position.X + player.width && npc.position.Y + npc.height < player.position.Y + player.height - 16f) - flag52 = true; + nearPlayerWalkingThroughTiles = true; - if (flag52) + if (nearPlayerWalkingThroughTiles) { npc.velocity.Y += 0.5f; } - else if (Collision.SolidCollision(position2, num854, num855)) + else if (Collision.SolidCollision(aureusHitboxTileCollideSize, aureusHitboxWidth, aureusHitboxHeight)) { if (npc.velocity.Y > 0f) npc.velocity.Y = 0f; @@ -3153,12 +3151,12 @@ namespace CalamityMod.NPCs calamityGlobalNPC.newAI[3] = 0f; // Spawn dust for visual effect - for (int num622 = (int)npc.position.X - 20; num622 < (int)npc.position.X + npc.width + 40; num622 += 20) + for (int i = (int)npc.position.X - 20; i < (int)npc.position.X + npc.width + 40; i += 20) { - for (int num623 = 0; num623 < 4; num623++) + for (int j = 0; j < 4; j++) { - int num624 = Dust.NewDust(new Vector2(npc.position.X - 20f, npc.position.Y + npc.height), npc.width + 20, 4, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); - Main.dust[num624].velocity *= 0.2f; + int stompDust = Dust.NewDust(new Vector2(npc.position.X - 20f, npc.position.Y + npc.height), npc.width + 20, 4, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); + Main.dust[stompDust].velocity *= 0.2f; } } @@ -3342,24 +3340,23 @@ namespace CalamityMod.NPCs Vector2 vectorAimedAheadOfTarget = Main.player[npc.target].Center + new Vector2((float)Math.Round(Main.player[npc.target].velocity.X), 0f).SafeNormalize(Vector2.Zero) * 1000f; Point point4 = vectorAimedAheadOfTarget.ToTileCoordinates(); - int num235 = 5; - int num238 = 0; - while (num238 < 100) + int teleportTries = 0; + while (teleportTries < 100) { - num238++; - int num239 = Main.rand.Next(point4.X - num235, point4.X + num235 + 1); - int num240 = Main.rand.Next(point4.Y - num235, point4.Y); + teleportTries++; + int teleportTileX = Main.rand.Next(point4.X - 5, point4.X + 6); + int teleportTileY = Main.rand.Next(point4.Y - 5, point4.Y); - if (!Main.tile[num239, num240].HasUnactuatedTile) + if (!Main.tile[teleportTileX, teleportTileY].HasUnactuatedTile) { - npc.ai[1] = num239 * 16 + 8; - npc.ai[3] = num240 * 16 + 16; + npc.ai[1] = teleportTileX * 16 + 8; + npc.ai[3] = teleportTileY * 16 + 16; break; } } // Default teleport if the above conditions aren't met in 100 iterations - if (num238 >= 100) + if (teleportTries >= 100) { Vector2 bottom = Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].Bottom; npc.ai[1] = bottom.X; @@ -3412,11 +3409,11 @@ namespace CalamityMod.NPCs } // Emit dust to make the teleport pretty - for (int num245 = 0; num245 < 10; num245++) + for (int i = 0; i < 10; i++) { - int num244 = Dust.NewDust(npc.position, npc.width, npc.height, ModContent.DustType(), npc.velocity.X, npc.velocity.Y, 255, default, 2f); - Main.dust[num244].noGravity = true; - Main.dust[num244].velocity *= 0.5f; + int teleportDust = Dust.NewDust(npc.position, npc.width, npc.height, ModContent.DustType(), npc.velocity.X, npc.velocity.Y, 255, default, 2f); + Main.dust[teleportDust].noGravity = true; + Main.dust[teleportDust].velocity *= 0.5f; } CustomGravity(); @@ -3432,21 +3429,21 @@ namespace CalamityMod.NPCs npc.alpha -= 10; if (npc.alpha <= 0) { - // Spawn slimes + // Spawn Aureus Spawns bool spawnFlag = expertMode; if (NPC.CountNPCS(ModContent.NPCType()) >= 2) spawnFlag = false; if (spawnFlag && Main.netMode != NetmodeID.MultiplayerClient) { - int slime = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)(npc.Center.Y - 25f * npc.scale), ModContent.NPCType()); - Main.npc[slime].velocity.Y = -10f; - Main.npc[slime].netUpdate = true; + int aureusSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)(npc.Center.Y - 25f * npc.scale), ModContent.NPCType()); + Main.npc[aureusSpawn].velocity.Y = -10f; + Main.npc[aureusSpawn].netUpdate = true; if (revenge) { - slime = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)(npc.Center.Y - 25f * npc.scale), ModContent.NPCType()); - Main.npc[slime].velocity.Y = -15f; - Main.npc[slime].netUpdate = true; + aureusSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)(npc.Center.Y - 25f * npc.scale), ModContent.NPCType()); + Main.npc[aureusSpawn].velocity.Y = -15f; + Main.npc[aureusSpawn].netUpdate = true; } if (death) @@ -3481,11 +3478,11 @@ namespace CalamityMod.NPCs } // Emit dust to make the teleport pretty - for (int num245 = 0; num245 < 10; num245++) + for (int i = 0; i < 10; i++) { - int num244 = Dust.NewDust(npc.position, npc.width, npc.height, ModContent.DustType(), npc.velocity.X, npc.velocity.Y, 255, default, 2f); - Main.dust[num244].noGravity = true; - Main.dust[num244].velocity *= 0.5f; + int teleportDust = Dust.NewDust(npc.position, npc.width, npc.height, ModContent.DustType(), npc.velocity.X, npc.velocity.Y, 255, default, 2f); + Main.dust[teleportDust].noGravity = true; + Main.dust[teleportDust].velocity *= 0.5f; } CustomGravity(); @@ -3850,15 +3847,15 @@ namespace CalamityMod.NPCs int Previous = npc.whoAmI; int bodyType = ModContent.NPCType(); int tailType = ModContent.NPCType(); - for (int num36 = 0; num36 < maxLength; num36++) + for (int segments = 0; segments < maxLength; segments++) { int lol; - if (num36 >= 0 && num36 < maxLength - 1) + if (segments >= 0 && segments < maxLength - 1) lol = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), bodyType, npc.whoAmI); else lol = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), tailType, npc.whoAmI); - if (num36 % 2 == 0) + if (segments % 2 == 0) Main.npc[lol].localAI[3] = 1f; Main.npc[lol].realLife = npc.whoAmI; @@ -3887,27 +3884,27 @@ namespace CalamityMod.NPCs if (head) { - int num12 = (int)(npc.position.X / 16f) - 1; - int num13 = (int)((npc.position.X + npc.width) / 16f) + 2; - int num14 = (int)(npc.position.Y / 16f) - 1; - int num15 = (int)((npc.position.Y + npc.height) / 16f) + 2; + int headTilePositionX = (int)(npc.position.X / 16f) - 1; + int headTileWidthPosX = (int)((npc.position.X + npc.width) / 16f) + 2; + int headTilePositionY = (int)(npc.position.Y / 16f) - 1; + int headTileWidthPosY = (int)((npc.position.Y + npc.height) / 16f) + 2; - if (num12 < 0) - num12 = 0; - if (num13 > Main.maxTilesX) - num13 = Main.maxTilesX; - if (num14 < 0) - num14 = 0; - if (num15 > Main.maxTilesY) - num15 = Main.maxTilesY; + if (headTilePositionX < 0) + headTilePositionX = 0; + if (headTileWidthPosX > Main.maxTilesX) + headTileWidthPosX = Main.maxTilesX; + if (headTilePositionY < 0) + headTilePositionY = 0; + if (headTileWidthPosY > Main.maxTilesY) + headTileWidthPosY = Main.maxTilesY; // Fly or not - bool flag2 = flyAtTarget; - if (!flag2) + bool shouldFly = flyAtTarget; + if (!shouldFly) { - for (int k = num12; k < num13; k++) + for (int k = headTilePositionX; k < headTileWidthPosX; k++) { - for (int l = num14; l < num15; l++) + for (int l = headTilePositionY; l < headTileWidthPosY; l++) { if (Main.tile[k, l] != null && ((Main.tile[k, l].HasUnactuatedTile && (Main.tileSolid[Main.tile[k, l].TileType] || (Main.tileSolidTop[Main.tile[k, l].TileType] && Main.tile[k, l].TileFrameY == 0))) || Main.tile[k, l].LiquidAmount > 64)) { @@ -3916,7 +3913,7 @@ namespace CalamityMod.NPCs vector2.Y = l * 16f; if (npc.position.X + npc.width > vector2.X && npc.position.X < vector2.X + 16f && npc.position.Y + npc.height > vector2.Y && npc.position.Y < vector2.Y + 16f) { - flag2 = true; + shouldFly = true; break; } } @@ -3925,15 +3922,15 @@ namespace CalamityMod.NPCs } // Start flying if target is not within a certain distance - if (!flag2) + if (!shouldFly) { npc.localAI[1] = 1f; Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - int num16 = 200; + int noFlyZone = 200; int heightReduction = death ? 130 : (int)(130f * (1f - lifeRatio)); int height = 400 - heightReduction; - bool flag3 = true; + bool outsideNoFlyZone = true; if (npc.position.Y > player.position.Y) { @@ -3941,16 +3938,16 @@ namespace CalamityMod.NPCs { if (Main.player[m].active) { - Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - num16, (int)Main.player[m].position.Y - num16, num16 * 2, height); + Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - noFlyZone, (int)Main.player[m].position.Y - noFlyZone, noFlyZone * 2, height); if (rectangle.Intersects(rectangle2)) { - flag3 = false; + outsideNoFlyZone = false; break; } } } - if (flag3) - flag2 = true; + if (outsideNoFlyZone) + shouldFly = true; } } else @@ -3960,7 +3957,7 @@ namespace CalamityMod.NPCs float fallSpeed = deathModeEnragePhase_Head ? 19f : death ? 17.5f : 16f; if (player.dead) { - flag2 = false; + shouldFly = false; float velocity = 2f; npc.velocity.Y -= velocity; if ((double)npc.position.Y < Main.topWorld + 16f) @@ -3974,17 +3971,17 @@ namespace CalamityMod.NPCs int tailType = ModContent.NPCType(); if ((double)npc.position.Y < Main.topWorld + 16f) { - for (int num957 = 0; num957 < Main.maxNPCs; num957++) + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num957].type == headType || Main.npc[num957].type == bodyType || Main.npc[num957].type == tailType) + if (Main.npc[i].type == headType || Main.npc[i].type == bodyType || Main.npc[i].type == tailType) { - Main.npc[num957].active = false; + Main.npc[i].active = false; - Main.npc[num957].netUpdate = true; + Main.npc[i].netUpdate = true; // Prevent netUpdate from being blocked by the spam counter. - if (Main.npc[num957].netSpam >= 10) - Main.npc[num957].netSpam = 9; + if (Main.npc[i].netSpam >= 10) + Main.npc[i].netSpam = 9; } } } @@ -4025,17 +4022,17 @@ namespace CalamityMod.NPCs turnSpeed *= 1.15f; } - Vector2 vector3 = npc.Center; - float num20 = player.position.X + (player.width / 2); - float num21 = player.position.Y + (player.height / 2); - num20 = (int)(num20 / 16f) * 16; - num21 = (int)(num21 / 16f) * 16; - vector3.X = (int)(vector3.X / 16f) * 16; - vector3.Y = (int)(vector3.Y / 16f) * 16; - num20 -= vector3.X; - num21 -= vector3.Y; + Vector2 deusCenter = npc.Center; + float deusTargetX = player.position.X + (player.width / 2); + float deusTargetY = player.position.Y + (player.height / 2); + deusTargetX = (int)(deusTargetX / 16f) * 16; + deusTargetY = (int)(deusTargetY / 16f) * 16; + deusCenter.X = (int)(deusCenter.X / 16f) * 16; + deusCenter.Y = (int)(deusCenter.Y / 16f) * 16; + deusTargetX -= deusCenter.X; + deusTargetY -= deusCenter.Y; - if (!flag2) + if (!shouldFly) { npc.velocity.Y += 0.15f; if (npc.velocity.Y > fallSpeed) @@ -4050,9 +4047,9 @@ namespace CalamityMod.NPCs } else if (npc.velocity.Y == fallSpeed) { - if (npc.velocity.X < num20) + if (npc.velocity.X < deusTargetX) npc.velocity.X += speed; - else if (npc.velocity.X > num20) + else if (npc.velocity.X > deusTargetX) npc.velocity.X -= speed; } else if (npc.velocity.Y > 4f) @@ -4065,19 +4062,19 @@ namespace CalamityMod.NPCs } else { - float num22 = (float)Math.Sqrt(num20 * num20 + num21 * num21); - float num25 = Math.Abs(num20); - float num26 = Math.Abs(num21); - float num27 = fallSpeed / num22; - num20 *= num27; - num21 *= num27; + float deusTargetDist = (float)Math.Sqrt(deusTargetX * deusTargetX + deusTargetY * deusTargetY); + float deusAbsoluteTargetX = Math.Abs(deusTargetX); + float deusAbsoluteTargetY = Math.Abs(deusTargetY); + float deusTimeToReachTarget = fallSpeed / deusTargetDist; + deusTargetX *= deusTimeToReachTarget; + deusTargetY *= deusTimeToReachTarget; - bool flag6 = false; + bool speedUpWhileFlying = false; if (flyAtTarget) { - if (((npc.velocity.X > 0f && num20 < 0f) || (npc.velocity.X < 0f && num20 > 0f) || (npc.velocity.Y > 0f && num21 < 0f) || (npc.velocity.Y < 0f && num21 > 0f)) && Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) > speed / 2f && num22 < 400f) + if (((npc.velocity.X > 0f && deusTargetX < 0f) || (npc.velocity.X < 0f && deusTargetX > 0f) || (npc.velocity.Y > 0f && deusTargetY < 0f) || (npc.velocity.Y < 0f && deusTargetY > 0f)) && Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) > speed / 2f && deusTargetDist < 400f) { - flag6 = true; + speedUpWhileFlying = true; if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < fallSpeed) npc.velocity *= 1.1f; @@ -4085,7 +4082,7 @@ namespace CalamityMod.NPCs if (npc.position.Y > player.position.Y) { - flag6 = true; + speedUpWhileFlying = true; if (Math.Abs(npc.velocity.X) < fallSpeed / 2f) { @@ -4099,42 +4096,42 @@ namespace CalamityMod.NPCs } } - if (!flag6) + if (!speedUpWhileFlying) { if (!flyAtTarget) { - if (((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f)) && ((npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f))) + if (((npc.velocity.X > 0f && deusTargetX > 0f) || (npc.velocity.X < 0f && deusTargetX < 0f)) && ((npc.velocity.Y > 0f && deusTargetY > 0f) || (npc.velocity.Y < 0f && deusTargetY < 0f))) { - if (npc.velocity.X < num20) + if (npc.velocity.X < deusTargetX) npc.velocity.X += turnSpeed; - else if (npc.velocity.X > num20) + else if (npc.velocity.X > deusTargetX) npc.velocity.X -= turnSpeed; - if (npc.velocity.Y < num21) + if (npc.velocity.Y < deusTargetY) npc.velocity.Y += turnSpeed; - else if (npc.velocity.Y > num21) + else if (npc.velocity.Y > deusTargetY) npc.velocity.Y -= turnSpeed; } } - if ((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f) || (npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f)) + if ((npc.velocity.X > 0f && deusTargetX > 0f) || (npc.velocity.X < 0f && deusTargetX < 0f) || (npc.velocity.Y > 0f && deusTargetY > 0f) || (npc.velocity.Y < 0f && deusTargetY < 0f)) { - if (npc.velocity.X < num20) + if (npc.velocity.X < deusTargetX) npc.velocity.X += speed; - else if (npc.velocity.X > num20) + else if (npc.velocity.X > deusTargetX) npc.velocity.X -= speed; - if (npc.velocity.Y < num21) + if (npc.velocity.Y < deusTargetY) npc.velocity.Y += speed; - else if (npc.velocity.Y > num21) + else if (npc.velocity.Y > deusTargetY) npc.velocity.Y -= speed; - if (Math.Abs(num21) < fallSpeed * 0.2 && ((npc.velocity.X > 0f && num20 < 0f) || (npc.velocity.X < 0f && num20 > 0f))) + if (Math.Abs(deusTargetY) < fallSpeed * 0.2 && ((npc.velocity.X > 0f && deusTargetX < 0f) || (npc.velocity.X < 0f && deusTargetX > 0f))) { if (npc.velocity.Y > 0f) npc.velocity.Y += speed * 2f; else npc.velocity.Y -= speed * 2f; } - if (Math.Abs(num20) < fallSpeed * 0.2 && ((npc.velocity.Y > 0f && num21 < 0f) || (npc.velocity.Y < 0f && num21 > 0f))) + if (Math.Abs(deusTargetX) < fallSpeed * 0.2 && ((npc.velocity.Y > 0f && deusTargetY < 0f) || (npc.velocity.Y < 0f && deusTargetY > 0f))) { if (npc.velocity.X > 0f) npc.velocity.X += speed * 2f; @@ -4142,11 +4139,11 @@ namespace CalamityMod.NPCs npc.velocity.X -= speed * 2f; } } - else if (num25 > num26) + else if (deusAbsoluteTargetX > deusAbsoluteTargetY) { - if (npc.velocity.X < num20) + if (npc.velocity.X < deusTargetX) npc.velocity.X += speed * 1.1f; - else if (npc.velocity.X > num20) + else if (npc.velocity.X > deusTargetX) npc.velocity.X -= speed * 1.1f; if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.5) @@ -4159,9 +4156,9 @@ namespace CalamityMod.NPCs } else { - if (npc.velocity.Y < num21) + if (npc.velocity.Y < deusTargetY) npc.velocity.Y += speed * 1.1f; - else if (npc.velocity.Y > num21) + else if (npc.velocity.Y > deusTargetY) npc.velocity.Y -= speed * 1.1f; if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.5) @@ -4175,7 +4172,7 @@ namespace CalamityMod.NPCs } } - if (flag2) + if (shouldFly) { if (npc.localAI[0] != 1f) { @@ -4241,10 +4238,10 @@ namespace CalamityMod.NPCs Vector2 velocity = Vector2.Zero; if (movingMines) { - Vector2 vector15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - vector15.Normalize(); - vector15 *= Main.rand.Next(90, 121) * 0.01f; - velocity = vector15; + Vector2 randomMineMovement = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + randomMineMovement.Normalize(); + randomMineMovement *= Main.rand.Next(90, 121) * 0.01f; + velocity = randomMineMovement; } int type = ModContent.ProjectileType(); @@ -4260,18 +4257,18 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { - float num941 = (death ? 16f : revenge ? 14f : 13f) + enrageScale * 4f; - Vector2 vector104 = npc.Center; - float num942 = player.position.X + player.width * 0.5f - vector104.X; - float num943 = player.position.Y + player.height * 0.5f - vector104.Y; - float num944 = (float)Math.Sqrt(num942 * num942 + num943 * num943); - num944 = num941 / num944; - num942 *= num944; - num943 *= num944; - vector104.X += num942 * 5f; - vector104.Y += num943 * 5f; - Vector2 shootDirection = new Vector2(num942, num943).SafeNormalize(Vector2.UnitY); - Vector2 laserVelocity = shootDirection * num941; + float deusLaserSpeed = (death ? 16f : revenge ? 14f : 13f) + enrageScale * 4f; + Vector2 deusLaserCenter = npc.Center; + float deusLaserTargetX = player.position.X + player.width * 0.5f - deusLaserCenter.X; + float deusLaserTargetY = player.position.Y + player.height * 0.5f - deusLaserCenter.Y; + float deusLaserTargetDist = (float)Math.Sqrt(deusLaserTargetX * deusLaserTargetX + deusLaserTargetY * deusLaserTargetY); + deusLaserTargetDist = deusLaserSpeed / deusLaserTargetDist; + deusLaserTargetX *= deusLaserTargetDist; + deusLaserTargetY *= deusLaserTargetDist; + deusLaserCenter.X += deusLaserTargetX * 5f; + deusLaserCenter.Y += deusLaserTargetY * 5f; + Vector2 shootDirection = new Vector2(deusLaserTargetX, deusLaserTargetY).SafeNormalize(Vector2.UnitY); + Vector2 laserVelocity = shootDirection * deusLaserSpeed; int type = shootGodRays ? ModContent.ProjectileType() : ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); if (shootGodRays) @@ -4282,7 +4279,7 @@ namespace CalamityMod.NPCs for (int i = -1; i <= 1; i += 2) { - Vector2 laserStartPos = vector104 + i * perp + Main.rand.NextVector2CircularEdge(6f, 6f); + Vector2 laserStartPos = deusLaserCenter + i * perp + Main.rand.NextVector2CircularEdge(6f, 6f); Projectile godRay = Projectile.NewProjectileDirect(npc.GetSource_FromAI(), laserStartPos, laserVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); // Tell this Phased God Ray exactly which way it should be waving. @@ -4290,7 +4287,7 @@ namespace CalamityMod.NPCs } } else - Projectile.NewProjectile(npc.GetSource_FromAI(), vector104, laserVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); + Projectile.NewProjectile(npc.GetSource_FromAI(), deusLaserCenter, laserVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); } } } @@ -4302,10 +4299,10 @@ namespace CalamityMod.NPCs Vector2 velocity = Vector2.Zero; if (movingMines) { - Vector2 vector15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - vector15.Normalize(); - vector15 *= Main.rand.Next(30, 121) * 0.01f; - velocity = vector15; + Vector2 randomMineMovement = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + randomMineMovement.Normalize(); + randomMineMovement *= Main.rand.Next(30, 121) * 0.01f; + velocity = randomMineMovement; } int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); @@ -4316,41 +4313,41 @@ namespace CalamityMod.NPCs } // Follow the head - Vector2 vector18 = npc.Center; - float num191 = player.position.X + (player.width / 2); - float num192 = player.position.Y + (player.height / 2); - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; + Vector2 segmentCenter = npc.Center; + float segmentTargetX = player.position.X + (player.width / 2); + float segmentTargetY = player.position.Y + (player.height / 2); + segmentTargetX = (int)(segmentTargetX / 16f) * 16; + segmentTargetY = (int)(segmentTargetY / 16f) * 16; + segmentCenter.X = (int)(segmentCenter.X / 16f) * 16; + segmentCenter.Y = (int)(segmentCenter.Y / 16f) * 16; + segmentTargetX -= segmentCenter.X; + segmentTargetY -= segmentCenter.Y; if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) { try { - vector18 = npc.Center; - num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; + segmentCenter = npc.Center; + segmentTargetX = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - segmentCenter.X; + segmentTargetY = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - segmentCenter.Y; } catch { } - npc.rotation = (float)Math.Atan2(num192, num191) + MathHelper.PiOver2; - float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = npc.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; + npc.rotation = (float)Math.Atan2(segmentTargetY, segmentTargetX) + MathHelper.PiOver2; + float segmentTargetDist = (float)Math.Sqrt(segmentTargetX * segmentTargetX + segmentTargetY * segmentTargetY); + int segmentWidth = npc.width; + segmentTargetDist = (segmentTargetDist - segmentWidth) / segmentTargetDist; + segmentTargetX *= segmentTargetDist; + segmentTargetY *= segmentTargetDist; npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; + npc.position.X = npc.position.X + segmentTargetX; + npc.position.Y = npc.position.Y + segmentTargetY; - if (num191 < 0f) + if (segmentTargetX < 0f) npc.spriteDirection = -1; - else if (num191 > 0f) + else if (segmentTargetX > 0f) npc.spriteDirection = 1; } } @@ -5006,7 +5003,12 @@ namespace CalamityMod.NPCs npc.ai[0] = 0f; npc.ai[1] = 0f; npc.ai[2] = 0f; + npc.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (npc.netSpam >= 10) + npc.netSpam = 9; } return; @@ -5079,7 +5081,12 @@ namespace CalamityMod.NPCs npc.ai[1] = 0f; npc.ai[2] = 0f; npc.SyncExtraAI(); + npc.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (npc.netSpam >= 10) + npc.netSpam = 9; } } else @@ -5120,16 +5127,21 @@ namespace CalamityMod.NPCs npc.ai[1] = 0f; npc.ai[2] = 0f; npc.SyncExtraAI(); + npc.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (npc.netSpam >= 10) + npc.netSpam = 9; } } - Vector2 value52 = player.Center - npc.Center; - float scaleFactor16 = 4f + value52.Length() / 100f; - float num1308 = 25f; - value52.Normalize(); - value52 *= scaleFactor16; - npc.velocity = (npc.velocity * (num1308 - 1f) + value52) / num1308; + Vector2 follyTargetDirection = player.Center - npc.Center; + float follyTargetDistance = 4f + follyTargetDirection.Length() / 100f; + float follyVelocityMult = 25f; + follyTargetDirection.Normalize(); + follyTargetDirection *= follyTargetDistance; + npc.velocity = (npc.velocity * (follyVelocityMult - 1f) + follyTargetDirection) / follyVelocityMult; return; } @@ -5157,22 +5169,22 @@ namespace CalamityMod.NPCs npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt * 1.25f) / 10f; // Fly to target if target is too far away, otherwise get close to target and then slow down - Vector2 value51 = player.Center - npc.Center; - value51.Y -= 200f; - if (value51.Length() > 2800f) + Vector2 follyFlyTargetDirection = player.Center - npc.Center; + follyFlyTargetDirection.Y -= 200f; + if (follyFlyTargetDirection.Length() > 2800f) { npc.TargetClosest(); npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; } - else if (value51.Length() > 240f) + else if (follyFlyTargetDirection.Length() > 240f) { - float scaleFactor15 = 12f + (enrageScale - 1f) * 6f; - float num1306 = 30f; - value51.Normalize(); - value51 *= scaleFactor15; - npc.velocity = (npc.velocity * (num1306 - 1f) + value51) / num1306; + float follyFlySpeed = 12f + (enrageScale - 1f) * 6f; + float follyFlyVelocityMult = 30f; + follyFlyTargetDirection.Normalize(); + follyFlyTargetDirection *= follyFlySpeed; + npc.velocity = (npc.velocity * (follyFlyVelocityMult - 1f) + follyFlyTargetDirection) / follyFlyVelocityMult; } else if (npc.velocity.Length() > 2f) npc.velocity *= 0.95f; @@ -5211,15 +5223,15 @@ namespace CalamityMod.NPCs } else { - int num1307 = phase2 ? Main.rand.Next(2) + 1 : Main.rand.Next(3); + int follyAttackPicker = phase2 ? Main.rand.Next(2) + 1 : Main.rand.Next(3); if (phase3) - num1307 = 1; + follyAttackPicker = 1; float featherVelocity = 2f + (enrageScale - 1f); int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - if (num1307 == 0 && npc.localAI[3] == 0f) + if (follyAttackPicker == 0 && npc.localAI[3] == 0f) { npc.TargetClosest(); npc.ai[0] = 2f; @@ -5235,7 +5247,7 @@ namespace CalamityMod.NPCs // Birb will do at least 1 different attack before entering this phase again npc.localAI[3] = 1f; } - else if (num1307 == 1) + else if (follyAttackPicker == 1) { npc.TargetClosest(); npc.ai[0] = 3f; @@ -5372,6 +5384,11 @@ namespace CalamityMod.NPCs } npc.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (npc.netSpam >= 10) + npc.netSpam = 9; + npc.SyncExtraAI(); } } @@ -5387,23 +5404,29 @@ namespace CalamityMod.NPCs npc.spriteDirection = npc.direction; npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt) / 10f; - Vector2 value52 = player.Center - npc.Center; - if (value52.Length() < 800f) + Vector2 follyTargetDirection = player.Center - npc.Center; + if (follyTargetDirection.Length() < 800f) { npc.TargetClosest(); npc.ai[0] = 0f; npc.ai[1] = 0f; npc.ai[2] = 0f; + npc.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (npc.netSpam >= 10) + npc.netSpam = 9; + npc.SyncExtraAI(); } float velocity = 14f + (enrageScale - 1f) * 4f; - float scaleFactor16 = velocity + value52.Length() / 100f; - float num1308 = 25f; - value52.Normalize(); - value52 *= scaleFactor16; - npc.velocity = (npc.velocity * (num1308 - 1f) + value52) / num1308; + float follyTargetDistance = velocity + follyTargetDirection.Length() / 100f; + float follyVelocityMult = 25f; + follyTargetDirection.Normalize(); + follyTargetDirection *= follyTargetDistance; + npc.velocity = (npc.velocity * (follyVelocityMult - 1f) + follyTargetDirection) / follyVelocityMult; } // Fly towards target quickly @@ -5415,7 +5438,13 @@ namespace CalamityMod.NPCs npc.ai[0] = 0f; npc.ai[1] = 0f; npc.ai[2] = 0f; + npc.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (npc.netSpam >= 10) + npc.netSpam = 9; + npc.SyncExtraAI(); } @@ -5427,21 +5456,21 @@ namespace CalamityMod.NPCs npc.spriteDirection = npc.direction; npc.rotation = (npc.rotation * rotationMult * 0.5f + npc.velocity.X * rotationAmt * 1.25f) / 5f; - Vector2 value53 = player.Center - npc.Center; - value53.Y -= 20f; + Vector2 follyQuickFlyTargetDirection = player.Center - npc.Center; + follyQuickFlyTargetDirection.Y -= 20f; npc.ai[2] += 0.0222222228f; if (expertMode) npc.ai[2] += 0.0166666675f; float velocity = 8f + (enrageScale - 1f) * 2f; - float scaleFactor17 = velocity + npc.ai[2] + value53.Length() / 120f; + float follyQuickFlySpeed = velocity + npc.ai[2] + follyQuickFlyTargetDirection.Length() / 120f; if (CalamityWorld.LegendaryMode && revenge) - scaleFactor17 *= 2f; + follyQuickFlySpeed *= 2f; - float num1309 = 20f; - value53.Normalize(); - value53 *= scaleFactor17; - npc.velocity = (npc.velocity * (num1309 - 1f) + value53) / num1309; + float follyQuickFlyVelMult = 20f; + follyQuickFlyTargetDirection.Normalize(); + follyQuickFlyTargetDirection *= follyQuickFlySpeed; + npc.velocity = (npc.velocity * (follyQuickFlyVelMult - 1f) + follyQuickFlyTargetDirection) / follyQuickFlyVelMult; npc.ai[1] += 1f; if (npc.ai[1] >= ((CalamityWorld.LegendaryMode && revenge) ? 90f : 180f)) @@ -5450,7 +5479,13 @@ namespace CalamityMod.NPCs npc.ai[0] = 0f; npc.ai[1] = 0f; npc.ai[2] = 0f; + npc.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (npc.netSpam >= 10) + npc.netSpam = 9; + npc.SyncExtraAI(); } } @@ -5466,29 +5501,35 @@ namespace CalamityMod.NPCs npc.spriteDirection = npc.direction; npc.rotation = (npc.rotation * rotationMult * 0.5f + npc.velocity.X * rotationAmt * 0.85f) / 5f; - Vector2 value54 = player.Center - npc.Center; - value54.Y -= 12f; + Vector2 follyLineUpTargetDirection = player.Center - npc.Center; + follyLineUpTargetDirection.Y -= 12f; if (npc.Center.X > player.Center.X) - value54.X += chargeDistance; + follyLineUpTargetDirection.X += chargeDistance; else - value54.X -= chargeDistance; + follyLineUpTargetDirection.X -= chargeDistance; float verticalDistanceGateValue = (phase3 ? 100f : 20f) + (enrageScale - 1f) * 20f; if (Math.Abs(npc.Center.X - player.Center.X) > chargeDistance - 50f && Math.Abs(npc.Center.Y - player.Center.Y) < verticalDistanceGateValue) { npc.ai[0] = 3.1f; npc.ai[1] = 0f; + npc.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (npc.netSpam >= 10) + npc.netSpam = 9; + npc.SyncExtraAI(); } npc.ai[1] += 0.0333333351f; float velocity = 16f + (enrageScale - 1f) * 4f; - float scaleFactor18 = velocity + npc.ai[1]; - float num1310 = 4f; - value54.Normalize(); - value54 *= scaleFactor18; - npc.velocity = (npc.velocity * (num1310 - 1f) + value54) / num1310; + float follyLineUpSpeed = velocity + npc.ai[1]; + float follyLineUpVelMult = 4f; + follyLineUpTargetDirection.Normalize(); + follyLineUpTargetDirection *= follyLineUpSpeed; + npc.velocity = (npc.velocity * (follyLineUpVelMult - 1f) + follyLineUpTargetDirection) / follyLineUpVelMult; } // Prepare to charge @@ -5496,13 +5537,13 @@ namespace CalamityMod.NPCs { npc.rotation = (npc.rotation * rotationMult * 0.5f + npc.velocity.X * rotationAmt * 0.85f) / 5f; - Vector2 vector206 = player.Center - npc.Center; - vector206.Y -= 12f; - float scaleFactor19 = 28f + (enrageScale - 1f) * 4f; - float num1311 = 8f; - vector206.Normalize(); - vector206 *= scaleFactor19; - npc.velocity = (npc.velocity * (num1311 - 1f) + vector206) / num1311; + Vector2 follyChargePrepareTargetDirection = player.Center - npc.Center; + follyChargePrepareTargetDirection.Y -= 12f; + float follyChargePrepareSpeed = 28f + (enrageScale - 1f) * 4f; + float follyChargePrepareVelMult = 8f; + follyChargePrepareTargetDirection.Normalize(); + follyChargePrepareTargetDirection *= follyChargePrepareSpeed; + npc.velocity = (npc.velocity * (follyChargePrepareVelMult - 1f) + follyChargePrepareTargetDirection) / follyChargePrepareVelMult; if (npc.velocity.X < 0f) npc.direction = -1; @@ -5514,7 +5555,7 @@ namespace CalamityMod.NPCs npc.ai[1] += 1f; if (npc.ai[1] > 10f) { - npc.velocity = vector206; + npc.velocity = follyChargePrepareTargetDirection; if (npc.velocity.X < 0f) npc.direction = -1; @@ -5523,7 +5564,13 @@ namespace CalamityMod.NPCs npc.ai[0] = 3.2f; npc.ai[1] = npc.direction; + npc.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (npc.netSpam >= 10) + npc.netSpam = 9; + npc.SyncExtraAI(); } } @@ -5543,7 +5590,12 @@ namespace CalamityMod.NPCs npc.ai[0] = 0f; npc.ai[1] = 0f; npc.ai[2] = 0f; + npc.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (npc.netSpam >= 10) + npc.netSpam = 9; } else if (Math.Abs(npc.Center.X - player.Center.X) > chargeDistance + 200f) { @@ -5551,7 +5603,12 @@ namespace CalamityMod.NPCs npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; + npc.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (npc.netSpam >= 10) + npc.netSpam = 9; } } @@ -5578,7 +5635,12 @@ namespace CalamityMod.NPCs if (npc.Distance(player.Center) < 600f || npc.ai[2] >= 180f) { npc.ai[1] = 1f; + npc.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (npc.netSpam >= 10) + npc.netSpam = 9; } } else @@ -5628,11 +5690,15 @@ namespace CalamityMod.NPCs bool spawnFlag = NPC.CountNPCS(ModContent.NPCType()) < maxBirbs && (npc.ai[1] == 140f || (revenge && npc.ai[1] == 155f) || npc.ai[1] == 170f || gfbSpawnFlag); if (spawnFlag) { - Vector2 vector7 = npc.Center + (MathHelper.TwoPi * Main.rand.NextFloat()).ToRotationVector2() * new Vector2(2f, 1f) * 50f * (0.6f + Main.rand.NextFloat() * 0.4f); - if (Vector2.Distance(vector7, player.Center) > 150f) - NPC.NewNPC(npc.GetSource_FromAI(), (int)vector7.X, (int)vector7.Y, ModContent.NPCType(), npc.whoAmI); + Vector2 follySpawnCenter = npc.Center + (MathHelper.TwoPi * Main.rand.NextFloat()).ToRotationVector2() * new Vector2(2f, 1f) * 50f * (0.6f + Main.rand.NextFloat() * 0.4f); + if (Vector2.Distance(follySpawnCenter, player.Center) > 150f) + NPC.NewNPC(npc.GetSource_FromAI(), (int)follySpawnCenter.X, (int)follySpawnCenter.Y, ModContent.NPCType(), npc.whoAmI); npc.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (npc.netSpam >= 10) + npc.netSpam = 9; } } @@ -5645,7 +5711,12 @@ namespace CalamityMod.NPCs npc.ai[1] = 0f; npc.ai[2] = 0f; npc.TargetClosest(); + npc.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (npc.netSpam >= 10) + npc.netSpam = 9; } } @@ -5664,12 +5735,18 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector7 = npc.rotation.ToRotationVector2() * (Vector2.UnitX * npc.direction) * (npc.width + 20) / 2f + npc.Center; + Vector2 follySpawnCenter = npc.rotation.ToRotationVector2() * (Vector2.UnitX * npc.direction) * (npc.width + 20) / 2f + npc.Center; float ai0 = (phase3 ? 2f : 0f) + (enrageScale - 1f); if (ai0 > 3f) ai0 = 3f; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector7.X, vector7.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, ai0, npc.target + 1); + + Projectile.NewProjectile(npc.GetSource_FromAI(), follySpawnCenter.X, follySpawnCenter.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, ai0, npc.target + 1); + npc.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (npc.netSpam >= 10) + npc.netSpam = 9; } if (Main.zenithWorld) @@ -5697,7 +5774,12 @@ namespace CalamityMod.NPCs { npc.ai[0] = 0f; npc.ai[1] = 0f; + npc.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (npc.netSpam >= 10) + npc.netSpam = 9; } } } @@ -5712,9 +5794,7 @@ namespace CalamityMod.NPCs if (Vector2.Distance(player.Center, npc.Center) > 5600f) { if (npc.timeLeft > 5) - { npc.timeLeft = 5; - } } npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt * 1.25f) / 10f; @@ -5725,14 +5805,14 @@ namespace CalamityMod.NPCs { if (i != npc.whoAmI && Main.npc[i].active && Main.npc[i].type == npc.type) { - Vector2 value42 = Main.npc[i].Center - npc.Center; - if (value42.Length() < (npc.width + npc.height)) + Vector2 otherSwarmerDirection = Main.npc[i].Center - npc.Center; + if (otherSwarmerDirection.Length() < (npc.width + npc.height)) { - value42.Normalize(); - value42 *= -0.1f; - npc.velocity += value42; + otherSwarmerDirection.Normalize(); + otherSwarmerDirection *= -0.1f; + npc.velocity += otherSwarmerDirection; NPC nPC6 = Main.npc[i]; - nPC6.velocity -= value42; + nPC6.velocity -= otherSwarmerDirection; } } } @@ -5741,25 +5821,21 @@ namespace CalamityMod.NPCs if (npc.target < 0 || Main.player[npc.target].dead || !Main.player[npc.target].active) { npc.TargetClosest(true); - Vector2 vector240 = Main.player[npc.target].Center - npc.Center; - if (Main.player[npc.target].dead || vector240.Length() > (bossMinion ? 5600f : 2800f)) - { + Vector2 swarmerTargetDist = Main.player[npc.target].Center - npc.Center; + if (Main.player[npc.target].dead || swarmerTargetDist.Length() > (bossMinion ? 5600f : 2800f)) npc.ai[0] = -1f; - } } else { - Vector2 vector241 = Main.player[npc.target].Center - npc.Center; - if (npc.ai[0] > 1f && vector241.Length() > 3600f) - { + Vector2 swarmerCatchUpTargetDist = Main.player[npc.target].Center - npc.Center; + if (npc.ai[0] > 1f && swarmerCatchUpTargetDist.Length() > 3600f) npc.ai[0] = 1f; - } } if (npc.ai[0] == -1f) { - Vector2 value43 = new Vector2(0f, -8f); - npc.velocity = (npc.velocity * 21f + value43) / 10f; + Vector2 swarmerDespawnVelMult = new Vector2(0f, -8f); + npc.velocity = (npc.velocity * 21f + swarmerDespawnVelMult) / 10f; return; } @@ -5767,32 +5843,29 @@ namespace CalamityMod.NPCs { npc.TargetClosest(true); npc.spriteDirection = npc.direction; - Vector2 value44 = Main.player[npc.target].Center - npc.Center; - if (value44.Length() > 2800f) + + Vector2 swarmerIdleTargetDist = Main.player[npc.target].Center - npc.Center; + if (swarmerIdleTargetDist.Length() > 2800f) { npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; } - else if (value44.Length() > 400f) + else if (swarmerIdleTargetDist.Length() > 400f) { - float scaleFactor20 = (bossMinion ? 9f : 7f) + value44.Length() / 100f + npc.ai[1] / 15f; - float num1377 = 30f; - value44.Normalize(); - value44 *= scaleFactor20; - npc.velocity = (npc.velocity * (num1377 - 1f) + value44) / num1377; + float swarmerIdleSpeed = (bossMinion ? 9f : 7f) + swarmerIdleTargetDist.Length() / 100f + npc.ai[1] / 15f; + swarmerIdleTargetDist.Normalize(); + swarmerIdleTargetDist *= swarmerIdleSpeed; + npc.velocity = (npc.velocity * 29F + swarmerIdleTargetDist) / 30F; if (Main.getGoodWorld && !Main.zenithWorld) npc.velocity *= 1.15f; } else if (npc.velocity.Length() > 2f) - { npc.velocity *= 0.95f; - } else if (npc.velocity.Length() < 1f) - { npc.velocity *= 1.05f; - } + npc.ai[1] += 1f; if (npc.ai[1] >= (bossMinion ? 90f : 105f)) { @@ -5805,89 +5878,79 @@ namespace CalamityMod.NPCs if (npc.ai[0] == 1f) { if (npc.target < 0 || !Main.player[npc.target].active || Main.player[npc.target].dead) - { npc.TargetClosest(true); - } + if (npc.velocity.X < 0f) - { npc.direction = -1; - } else if (npc.velocity.X > 0f) - { npc.direction = 1; - } + npc.spriteDirection = npc.direction; npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt) / 10f; - Vector2 value45 = Main.player[npc.target].Center - npc.Center; - if (value45.Length() < 800f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) + + Vector2 swarmerChargeTargetDist = Main.player[npc.target].Center - npc.Center; + if (swarmerChargeTargetDist.Length() < 800f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) { npc.ai[0] = 0f; npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; } + npc.ai[2] += 0.0166666675f; - float scaleFactor21 = (bossMinion ? 12f : 9f) + npc.ai[2] + value45.Length() / 150f; - float num1378 = 25f; - value45.Normalize(); - value45 *= scaleFactor21; - npc.velocity = (npc.velocity * (num1378 - 1f) + value45) / num1378; + float swarmerChargeSpeed = (bossMinion ? 12f : 9f) + npc.ai[2] + swarmerChargeTargetDist.Length() / 150f; + float swarmerChargeVelMult = 25f; + swarmerChargeTargetDist.Normalize(); + swarmerChargeTargetDist *= swarmerChargeSpeed; + npc.velocity = (npc.velocity * (swarmerChargeVelMult - 1f) + swarmerChargeTargetDist) / swarmerChargeVelMult; if (Main.getGoodWorld && !Main.zenithWorld) npc.velocity *= 1.15f; npc.netSpam = 5; if (Main.netMode == NetmodeID.Server) - { NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI, 0f, 0f, 0f, 0, 0, 0); - } + return; } if (npc.ai[0] == 2f) { if (npc.velocity.X < 0f) - { npc.direction = -1; - } else if (npc.velocity.X > 0f) - { npc.direction = 1; - } + npc.spriteDirection = npc.direction; npc.rotation = (npc.rotation * rotationMult * 0.75f + npc.velocity.X * rotationAmt * 1.25f) / 8f; - Vector2 vector242 = Main.player[npc.target].Center - npc.Center; - vector242.Y -= 8f; - float scaleFactor22 = bossMinion ? 18f : 14f; - float num1379 = 8f; - vector242.Normalize(); - vector242 *= scaleFactor22; - npc.velocity = (npc.velocity * (num1379 - 1f) + vector242) / num1379; + + Vector2 swarmerDecelerateTargetDist = Main.player[npc.target].Center - npc.Center; + swarmerDecelerateTargetDist.Y -= 8f; + float swarmerDecelerateSpeed = bossMinion ? 18f : 14f; + float swarmerDecelerateVelMult = 8f; + swarmerDecelerateTargetDist.Normalize(); + swarmerDecelerateTargetDist *= swarmerDecelerateSpeed; + npc.velocity = (npc.velocity * (swarmerDecelerateVelMult - 1f) + swarmerDecelerateTargetDist) / swarmerDecelerateVelMult; if (Main.getGoodWorld && !Main.zenithWorld) npc.velocity *= 1.15f; if (npc.velocity.X < 0f) - { npc.direction = -1; - } else - { npc.direction = 1; - } + npc.spriteDirection = npc.direction; + npc.ai[1] += 1f; if (npc.ai[1] > 10f) { - npc.velocity = vector242; + npc.velocity = swarmerDecelerateTargetDist; if (Main.getGoodWorld && !Main.zenithWorld) npc.velocity *= 1.15f; if (npc.velocity.X < 0f) - { npc.direction = -1; - } else - { npc.direction = 1; - } + npc.ai[0] = 2.1f; npc.ai[1] = 0f; } @@ -5895,18 +5958,16 @@ namespace CalamityMod.NPCs else if (npc.ai[0] == 2.1f) { if (npc.velocity.X < 0f) - { npc.direction = -1; - } else if (npc.velocity.X > 0f) - { npc.direction = 1; - } + npc.spriteDirection = npc.direction; + npc.velocity *= 1.01f; + npc.ai[1] += 1f; - int num1380 = 30; - if (npc.ai[1] > num1380) + if (npc.ai[1] > 30) { if (!Collision.SolidCollision(npc.position, npc.width, npc.height)) { @@ -5915,7 +5976,8 @@ namespace CalamityMod.NPCs npc.ai[2] = 0f; return; } - if (npc.ai[1] > (num1380 * 2)) + + if (npc.ai[1] > 60) { npc.ai[0] = 1f; npc.ai[1] = 0f; @@ -6057,16 +6119,15 @@ namespace CalamityMod.NPCs float goreVelocityX = death ? 8f : revenge ? 7.5f : expertMode ? 7f : 6f; float goreVelocityY = death ? 10.5f : revenge ? 10f : expertMode ? 9.5f : 8f; float sharkronVelocity = bossRush ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; - int num9 = 120; - int num10 = 180; - int num12 = 30; + int attackTimer = 120; + int phaseTransitionTimer = 180; + int teleportPauseTimer = 30; int toothBallSpinPhaseDivisor = bossRush ? 27 : death ? 32 : 45; - int num13 = maxToothBallBelches * toothBallSpinPhaseDivisor; - float spinTime = num13 / 2f; + int toothBallSpinTimer = maxToothBallBelches * toothBallSpinPhaseDivisor; + float spinTime = toothBallSpinTimer / 2f; float toothBallSpinToothBallVelocity = bossRush ? 14f : death ? 9.5f : 9f; - float scaleFactor4 = Main.zenithWorld ? 44f : 22f; - float num15 = MathHelper.TwoPi / spinTime; - int num16 = 75; + float spinAttackSpeed = Main.zenithWorld ? 44f : 22f; + float spinSpeed = MathHelper.TwoPi / spinTime; Player player = Main.player[npc.target]; @@ -6257,28 +6318,28 @@ namespace CalamityMod.NPCs } } - float num17 = (float)Math.Atan2(rotationVector.Y, rotationVector.X); + float dukeRotationSpeed = (float)Math.Atan2(rotationVector.Y, rotationVector.X); if (npc.spriteDirection == 1) - num17 += pie; - if (num17 < 0f) - num17 += MathHelper.TwoPi; - if (num17 > MathHelper.TwoPi) - num17 -= MathHelper.TwoPi; + dukeRotationSpeed += pie; + if (dukeRotationSpeed < 0f) + dukeRotationSpeed += MathHelper.TwoPi; + if (dukeRotationSpeed > MathHelper.TwoPi) + dukeRotationSpeed -= MathHelper.TwoPi; if (npc.ai[0] == -1f || npc.ai[0] == 3f || npc.ai[0] == 4f) - num17 = 0f; + dukeRotationSpeed = 0f; if (npc.ai[0] == 8f || npc.ai[0] == 13f) - num17 = pie * 0.1666666667f * npc.spriteDirection; + dukeRotationSpeed = pie * 0.1666666667f * npc.spriteDirection; - if (npc.rotation < num17) + if (npc.rotation < dukeRotationSpeed) { - if (num17 - npc.rotation > pie) + if (dukeRotationSpeed - npc.rotation > pie) npc.rotation -= rateOfRotation; else npc.rotation += rateOfRotation; } - if (npc.rotation > num17) + if (npc.rotation > dukeRotationSpeed) { - if (npc.rotation - num17 > pie) + if (npc.rotation - dukeRotationSpeed > pie) npc.rotation += rateOfRotation; else npc.rotation -= rateOfRotation; @@ -6286,14 +6347,14 @@ namespace CalamityMod.NPCs if ((npc.ai[0] != 8f && npc.ai[0] != 13f) || npc.spriteDirection == 1) { - if (npc.rotation > num17 - rateOfRotation && npc.rotation < num17 + rateOfRotation) - npc.rotation = num17; + if (npc.rotation > dukeRotationSpeed - rateOfRotation && npc.rotation < dukeRotationSpeed + rateOfRotation) + npc.rotation = dukeRotationSpeed; if (npc.rotation < 0f) npc.rotation += MathHelper.TwoPi; if (npc.rotation > MathHelper.TwoPi) npc.rotation -= MathHelper.TwoPi; - if (npc.rotation > num17 - rateOfRotation && npc.rotation < num17 + rateOfRotation) - npc.rotation = num17; + if (npc.rotation > dukeRotationSpeed - rateOfRotation && npc.rotation < dukeRotationSpeed + rateOfRotation) + npc.rotation = dukeRotationSpeed; } // Alpha adjustments @@ -6318,10 +6379,10 @@ namespace CalamityMod.NPCs npc.velocity *= 0.98f; // Direction - int num19 = Math.Sign(player.Center.X - npc.Center.X); - if (num19 != 0) + int dukeFaceDirection = Math.Sign(player.Center.X - npc.Center.X); + if (dukeFaceDirection != 0) { - npc.direction = num19; + npc.direction = dukeFaceDirection; npc.spriteDirection = -npc.direction; } @@ -6341,24 +6402,24 @@ namespace CalamityMod.NPCs } // Spawn dust and play sound - if (npc.ai[2] == num9 - 30) + if (npc.ai[2] == attackTimer - 30) { - int num20 = 36; - for (int i = 0; i < num20; i++) + int dustAmt = 36; + for (int i = 0; i < dustAmt; i++) { - Vector2 dust = (Vector2.Normalize(npc.velocity) * new Vector2(npc.width / 2f, npc.height) * 0.75f * 0.5f).RotatedBy((i - (num20 / 2 - 1)) * MathHelper.TwoPi / num20) + npc.Center; + Vector2 dust = (Vector2.Normalize(npc.velocity) * new Vector2(npc.width / 2f, npc.height) * 0.75f * 0.5f).RotatedBy((i - (dustAmt / 2 - 1)) * MathHelper.TwoPi / dustAmt) + npc.Center; Vector2 vector2 = dust - npc.Center; - int num21 = Dust.NewDust(dust + vector2, 0, 0, (int)CalamityDusts.SulfurousSeaAcid, vector2.X * 2f, vector2.Y * 2f, 100, default, 1.4f); - Main.dust[num21].noGravity = true; - Main.dust[num21].noLight = true; - Main.dust[num21].velocity = Vector2.Normalize(vector2) * 3f; + int toxicDust = Dust.NewDust(dust + vector2, 0, 0, (int)CalamityDusts.SulfurousSeaAcid, vector2.X * 2f, vector2.Y * 2f, 100, default, 1.4f); + Main.dust[toxicDust].noGravity = true; + Main.dust[toxicDust].noLight = true; + Main.dust[toxicDust].velocity = Vector2.Normalize(vector2) * 3f; } modNPC.RoarSoundSlot = SoundEngine.PlaySound(OldDuke.OldDuke.RoarSound, npc.Center); } npc.ai[2] += 1f; - if (npc.ai[2] >= num16) + if (npc.ai[2] >= 75) { npc.ai[0] = 0f; npc.ai[1] = 0f; @@ -6374,17 +6435,17 @@ namespace CalamityMod.NPCs if (npc.ai[1] == 0f) npc.ai[1] = 500 * Math.Sign((npc.Center - player.Center).X); - Vector2 vector3 = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -300f) - npc.Center - npc.velocity) * idlePhaseVelocity; - npc.SimpleFlyMovement(vector3, idlePhaseAcceleration); + Vector2 phase1IdleSpeed = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -300f) - npc.Center - npc.velocity) * idlePhaseVelocity; + npc.SimpleFlyMovement(phase1IdleSpeed, idlePhaseAcceleration); // Rotation and direction - int num22 = Math.Sign(player.Center.X - npc.Center.X); - if (num22 != 0) + int dukeLookAt = Math.Sign(player.Center.X - npc.Center.X); + if (dukeLookAt != 0) { - if (npc.ai[2] == 0f && num22 != npc.direction) + if (npc.ai[2] == 0f && dukeLookAt != npc.direction) npc.rotation += pie; - npc.direction = num22; + npc.direction = dukeLookAt; if (npc.spriteDirection != -npc.direction) npc.rotation += pie; @@ -6398,7 +6459,7 @@ namespace CalamityMod.NPCs npc.ai[2] += 1f; if (npc.ai[2] >= idlePhaseTimer || (phase2 && !phase2AI)) { - int num23 = 0; + int oldDukeAttackPicker = 0; switch ((int)npc.ai[3]) { case 0: @@ -6407,23 +6468,23 @@ namespace CalamityMod.NPCs case 3: case 4: case 5: - num23 = 1; + oldDukeAttackPicker = 1; break; case 6: npc.ai[3] = 1f; - num23 = 2; + oldDukeAttackPicker = 2; break; case 7: npc.ai[3] = 0f; - num23 = 3; + oldDukeAttackPicker = 3; break; } if (phase2) - num23 = 4; + oldDukeAttackPicker = 4; // Set velocity for charge - if (num23 == 1) + if (oldDukeAttackPicker == 1) { npc.ai[0] = 1f; npc.ai[1] = 0f; @@ -6435,9 +6496,9 @@ namespace CalamityMod.NPCs npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); // Direction - if (num22 != 0) + if (dukeLookAt != 0) { - npc.direction = num22; + npc.direction = dukeLookAt; if (npc.spriteDirection == 1) npc.rotation += pie; @@ -6447,7 +6508,7 @@ namespace CalamityMod.NPCs } // Tooth Balls - else if (num23 == 2) + else if (oldDukeAttackPicker == 2) { npc.ai[0] = 2f; npc.ai[1] = 0f; @@ -6455,7 +6516,7 @@ namespace CalamityMod.NPCs } // Call sharks from the sides of the screen - else if (num23 == 3) + else if (oldDukeAttackPicker == 3) { npc.ai[0] = 3f; npc.ai[1] = 0f; @@ -6463,7 +6524,7 @@ namespace CalamityMod.NPCs } // Go to phase 2 - else if (num23 == 4) + else if (oldDukeAttackPicker == 4) { npc.ai[0] = 4f; npc.ai[1] = 0f; @@ -6518,16 +6579,16 @@ namespace CalamityMod.NPCs } // Spawn dust - int num24 = 7; - for (int j = 0; j < num24; j++) + int chargeDustAmt = 7; + for (int j = 0; j < chargeDustAmt; j++) { - Vector2 arg_E1C_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((j - (num24 / 2 - 1)) * pie / num24) + npc.Center; + Vector2 arg_E1C_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((j - (chargeDustAmt / 2 - 1)) * pie / chargeDustAmt) + npc.Center; Vector2 vector4 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num25 = Dust.NewDust(arg_E1C_0 + vector4, 0, 0, (int)CalamityDusts.SulfurousSeaAcid, vector4.X * 2f, vector4.Y * 2f, 100, default, 1.4f); - Main.dust[num25].noGravity = true; - Main.dust[num25].noLight = true; - Main.dust[num25].velocity /= 4f; - Main.dust[num25].velocity -= npc.velocity; + int chargeDust = Dust.NewDust(arg_E1C_0 + vector4, 0, 0, (int)CalamityDusts.SulfurousSeaAcid, vector4.X * 2f, vector4.Y * 2f, 100, default, 1.4f); + Main.dust[chargeDust].noGravity = true; + Main.dust[chargeDust].noLight = true; + Main.dust[chargeDust].velocity /= 4f; + Main.dust[chargeDust].velocity -= npc.velocity; } npc.ai[2] += 1f; @@ -6550,8 +6611,8 @@ namespace CalamityMod.NPCs if (npc.ai[1] == 0f) npc.ai[1] = 500 * Math.Sign((npc.Center - player.Center).X); - Vector2 vector5 = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -300f) - npc.Center - npc.velocity) * toothBallBelchPhaseVelocity; - npc.SimpleFlyMovement(vector5, toothBallBelchPhaseAcceleration); + Vector2 toothBallBelchPhaseSpeed = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -300f) - npc.Center - npc.velocity) * toothBallBelchPhaseVelocity; + npc.SimpleFlyMovement(toothBallBelchPhaseSpeed, toothBallBelchPhaseAcceleration); // Play sounds and spawn Tooth Balls if (npc.ai[2] == 0f) @@ -6562,9 +6623,9 @@ namespace CalamityMod.NPCs if (npc.ai[2] != 0f) SoundEngine.PlaySound(OldDuke.OldDuke.VomitSound, npc.Center); - Vector2 vector6 = Vector2.Normalize(player.Center - npc.Center) * (npc.width + 20) / 2f + npc.Center; + Vector2 toothBallDirection = Vector2.Normalize(player.Center - npc.Center) * (npc.width + 20) / 2f + npc.Center; Vector2 toothBallVelocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * toothBallFinalVelocity; - Vector2 toothBallSpawnPos = new Vector2(vector6.X, vector6.Y + 45f); + Vector2 toothBallSpawnPos = new Vector2(toothBallDirection.X, toothBallDirection.Y + 45f); if (Main.netMode != NetmodeID.MultiplayerClient) { int toothBall = NPC.NewNPC(npc.GetSource_FromAI(), (int)toothBallSpawnPos.X, (int)toothBallSpawnPos.Y, ModContent.NPCType(), 0, toothBallVelocity.X, toothBallVelocity.Y); @@ -6605,10 +6666,10 @@ namespace CalamityMod.NPCs } // Direction - int num26 = Math.Sign(player.Center.X - npc.Center.X); - if (num26 != 0) + int toothBallLookAt = Math.Sign(player.Center.X - npc.Center.X); + if (toothBallLookAt != 0) { - npc.direction = num26; + npc.direction = toothBallLookAt; if (npc.spriteDirection != -npc.direction) npc.rotation += pie; npc.spriteDirection = -npc.direction; @@ -6634,10 +6695,10 @@ namespace CalamityMod.NPCs npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); // Play sound and spawn sharks - if (npc.ai[2] == num9 - 30) + if (npc.ai[2] == attackTimer - 30) SoundEngine.PlaySound(OldDuke.OldDuke.VomitSound, npc.Center); - if (npc.ai[2] >= num9 - 90) + if (npc.ai[2] >= attackTimer - 90) { if (npc.ai[2] % 18f == 0f) { @@ -6658,7 +6719,7 @@ namespace CalamityMod.NPCs } npc.ai[2] += 1f; - if (npc.ai[2] >= num9) + if (npc.ai[2] >= attackTimer) { calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; calamityGlobalNPC.newAI[2] = 0f; @@ -6678,10 +6739,10 @@ namespace CalamityMod.NPCs npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); // Sound - if (npc.ai[2] == num10 - 60) + if (npc.ai[2] == phaseTransitionTimer - 60) modNPC.RoarSoundSlot = SoundEngine.PlaySound(OldDuke.OldDuke.RoarSound, npc.Center); - if (npc.ai[2] >= num10 - 60) + if (npc.ai[2] >= phaseTransitionTimer - 60) { if (npc.ai[2] % 18f == 0f) { @@ -6702,7 +6763,7 @@ namespace CalamityMod.NPCs } npc.ai[2] += 1f; - if (npc.ai[2] >= num10) + if (npc.ai[2] >= phaseTransitionTimer) { calamityGlobalNPC.newAI[0] = 0f; calamityGlobalNPC.newAI[1] = 0f; @@ -6723,17 +6784,17 @@ namespace CalamityMod.NPCs if (npc.ai[1] == 0f) npc.ai[1] = 500 * Math.Sign((npc.Center - player.Center).X); - Vector2 vector8 = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -300f) - npc.Center - npc.velocity) * idlePhaseVelocity; - npc.SimpleFlyMovement(vector8, idlePhaseAcceleration); + Vector2 dukePhase2IdleSpeed = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -300f) - npc.Center - npc.velocity) * idlePhaseVelocity; + npc.SimpleFlyMovement(dukePhase2IdleSpeed, idlePhaseAcceleration); // Direction and rotation - int num27 = Math.Sign(player.Center.X - npc.Center.X); - if (num27 != 0) + int phase2FaceDirection = Math.Sign(player.Center.X - npc.Center.X); + if (phase2FaceDirection != 0) { - if (npc.ai[2] == 0f && num27 != npc.direction) + if (npc.ai[2] == 0f && phase2FaceDirection != npc.direction) npc.rotation += pie; - npc.direction = num27; + npc.direction = phase2FaceDirection; if (npc.spriteDirection != -npc.direction) npc.rotation += pie; @@ -6747,30 +6808,30 @@ namespace CalamityMod.NPCs npc.ai[2] += 1f; if (npc.ai[2] >= idlePhaseTimer || (phase3 && !phase3AI)) { - int num28 = 0; + int phase2AttackPicker = 0; switch ((int)npc.ai[3]) { case 0: case 1: case 2: case 3: - num28 = 1; + phase2AttackPicker = 1; break; case 4: npc.ai[3] = 1f; - num28 = 2; + phase2AttackPicker = 2; break; case 5: npc.ai[3] = 0f; - num28 = 3; + phase2AttackPicker = 3; break; } if (phase3) - num28 = 4; + phase2AttackPicker = 4; // Set velocity for charge - if (num28 == 1) + if (phase2AttackPicker == 1) { npc.ai[0] = 6f; npc.ai[1] = 0f; @@ -6782,9 +6843,9 @@ namespace CalamityMod.NPCs npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); // Direction - if (num27 != 0) + if (phase2FaceDirection != 0) { - npc.direction = num27; + npc.direction = phase2FaceDirection; if (npc.spriteDirection == 1) npc.rotation += pie; @@ -6794,16 +6855,16 @@ namespace CalamityMod.NPCs } // Set velocity for spin - else if (num28 == 2) + else if (phase2AttackPicker == 2) { // Velocity and rotation - npc.velocity = Vector2.Normalize(player.Center - npc.Center) * scaleFactor4; + npc.velocity = Vector2.Normalize(player.Center - npc.Center) * spinAttackSpeed; npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); // Direction - if (num27 != 0) + if (phase2FaceDirection != 0) { - npc.direction = num27; + npc.direction = phase2FaceDirection; if (npc.spriteDirection == 1) npc.rotation += pie; @@ -6816,7 +6877,7 @@ namespace CalamityMod.NPCs npc.ai[2] = 0f; } - else if (num28 == 3) + else if (phase2AttackPicker == 3) { npc.ai[0] = 8f; npc.ai[1] = 0f; @@ -6824,7 +6885,7 @@ namespace CalamityMod.NPCs } // Go to next phase - else if (num28 == 4) + else if (phase2AttackPicker == 4) { npc.ai[0] = 9f; npc.ai[1] = 0f; @@ -6879,16 +6940,16 @@ namespace CalamityMod.NPCs } // Spawn dust - int num29 = 7; - for (int k = 0; k < num29; k++) + int phase2ChargeDustAmt = 7; + for (int k = 0; k < phase2ChargeDustAmt; k++) { - Vector2 arg_1A97_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((k - (num29 / 2 - 1)) * pie / num29) + npc.Center; + Vector2 arg_1A97_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((k - (phase2ChargeDustAmt / 2 - 1)) * pie / phase2ChargeDustAmt) + npc.Center; Vector2 vector9 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num30 = Dust.NewDust(arg_1A97_0 + vector9, 0, 0, (int)CalamityDusts.SulfurousSeaAcid, vector9.X * 2f, vector9.Y * 2f, 100, default, 1.4f); - Main.dust[num30].noGravity = true; - Main.dust[num30].noLight = true; - Main.dust[num30].velocity /= 4f; - Main.dust[num30].velocity -= npc.velocity; + int phase2ChargeDust = Dust.NewDust(arg_1A97_0 + vector9, 0, 0, (int)CalamityDusts.SulfurousSeaAcid, vector9.X * 2f, vector9.Y * 2f, 100, default, 1.4f); + Main.dust[phase2ChargeDust].noGravity = true; + Main.dust[phase2ChargeDust].noLight = true; + Main.dust[phase2ChargeDust].velocity /= 4f; + Main.dust[phase2ChargeDust].velocity -= npc.velocity; } npc.ai[2] += 1f; @@ -6924,9 +6985,9 @@ namespace CalamityMod.NPCs if (npc.ai[2] != 0f) SoundEngine.PlaySound(OldDuke.OldDuke.VomitSound, npc.Center); - Vector2 vector10 = Vector2.Normalize(npc.velocity) * (npc.width + 20) / 2f + npc.Center; + Vector2 phase2ToothBallDirection = Vector2.Normalize(npc.velocity) * (npc.width + 20) / 2f + npc.Center; Vector2 toothBallVelocity = Vector2.Normalize(npc.velocity).RotatedBy(MathHelper.PiOver2 * npc.direction) * toothBallSpinToothBallVelocity; - Vector2 toothBallSpawnPos = new Vector2(vector10.X, vector10.Y + 45f); + Vector2 toothBallSpawnPos = new Vector2(phase2ToothBallDirection.X, phase2ToothBallDirection.Y + 45f); if (Main.netMode != NetmodeID.MultiplayerClient) { int toothBall = NPC.NewNPC(npc.GetSource_FromAI(), (int)toothBallSpawnPos.X, (int)toothBallSpawnPos.Y, ModContent.NPCType(), 0, toothBallVelocity.X, toothBallVelocity.Y); @@ -6969,11 +7030,11 @@ namespace CalamityMod.NPCs } // Velocity and rotation - npc.velocity = npc.velocity.RotatedBy(-(double)num15 * (float)npc.direction); - npc.rotation -= num15 * npc.direction; + npc.velocity = npc.velocity.RotatedBy(-(double)spinSpeed * (float)npc.direction); + npc.rotation -= spinSpeed * npc.direction; npc.ai[2] += 1f; - if (npc.ai[2] >= num13) + if (npc.ai[2] >= toothBallSpinTimer) { calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; npc.ai[0] = 5f; @@ -6992,13 +7053,13 @@ namespace CalamityMod.NPCs npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); // Play sound - if (npc.ai[2] == num9 - 30) + if (npc.ai[2] == attackTimer - 30) { SoundEngine.PlaySound(OldDuke.OldDuke.VomitSound, npc.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector7 = npc.rotation.ToRotationVector2() * (Vector2.UnitX * npc.direction) * (npc.width + 20) / 2f + npc.Center; + Vector2 phase2GoreDirection = npc.rotation.ToRotationVector2() * (Vector2.UnitX * npc.direction) * (npc.width + 20) / 2f + npc.Center; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); int totalGore = Main.getGoodWorld ? 40 : 20; @@ -7013,12 +7074,12 @@ namespace CalamityMod.NPCs velocityY *= Main.rand.NextFloat() + 0.5f; } - Projectile.NewProjectile(npc.GetSource_FromAI(), vector7.X, vector7.Y, velocityX, -velocityY, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), phase2GoreDirection.X, phase2GoreDirection.Y, velocityX, -velocityY, type, damage, 0f, Main.myPlayer, 0f, 0f); } } } - if (npc.ai[2] >= num9 - 90) + if (npc.ai[2] >= attackTimer - 90) { if (npc.ai[2] % 18f == 0f) { @@ -7034,7 +7095,7 @@ namespace CalamityMod.NPCs } npc.ai[2] += 1f; - if (npc.ai[2] >= num9) + if (npc.ai[2] >= attackTimer) { calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; calamityGlobalNPC.newAI[2] = 0f; @@ -7054,10 +7115,10 @@ namespace CalamityMod.NPCs npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); // Sound - if (npc.ai[2] == num10 - 60) + if (npc.ai[2] == phaseTransitionTimer - 60) modNPC.RoarSoundSlot = SoundEngine.PlaySound(OldDuke.OldDuke.RoarSound, npc.Center); - if (npc.ai[2] >= num10 - 60) + if (npc.ai[2] >= phaseTransitionTimer - 60) { if (npc.ai[2] % 18f == 0f) { @@ -7078,7 +7139,7 @@ namespace CalamityMod.NPCs } npc.ai[2] += 1f; - if (npc.ai[2] >= num10) + if (npc.ai[2] >= phaseTransitionTimer) { calamityGlobalNPC.newAI[0] = 0f; calamityGlobalNPC.newAI[1] = 0f; @@ -7108,17 +7169,17 @@ namespace CalamityMod.NPCs npc.SimpleFlyMovement(desiredVelocity, idlePhaseAcceleration); // Rotation and direction - int num32 = Math.Sign(player.Center.X - npc.Center.X); - if (num32 != 0) + int phase3FaceDirection = Math.Sign(player.Center.X - npc.Center.X); + if (phase3FaceDirection != 0) { - if (npc.ai[2] == 0f && num32 != npc.direction) + if (npc.ai[2] == 0f && phase3FaceDirection != npc.direction) { npc.rotation += pie; for (int l = 0; l < npc.oldPos.Length; l++) npc.oldPos[l] = Vector2.Zero; } - npc.direction = num32; + npc.direction = phase3FaceDirection; if (npc.spriteDirection != -npc.direction) npc.rotation += pie; @@ -7129,10 +7190,13 @@ namespace CalamityMod.NPCs // Phase switch if (calamityGlobalNPC.newAI[1] != 1f) { + // Avoid cheap bullshit + npc.damage = 0; + npc.ai[2] += 1f; if (npc.ai[2] >= idlePhaseTimer) { - int num33 = 0; + int phase3AttackPicker = 0; switch ((int)npc.ai[3]) { case 0: @@ -7141,24 +7205,24 @@ namespace CalamityMod.NPCs case 5: case 6: case 7: - num33 = 1; + phase3AttackPicker = 1; break; case 1: case 8: - num33 = 2; + phase3AttackPicker = 2; break; case 4: npc.ai[3] = 1f; - num33 = 3; + phase3AttackPicker = 3; break; case 9: npc.ai[3] = 6f; - num33 = 4; + phase3AttackPicker = 4; break; } // Set velocity for charge - if (num33 == 1) + if (phase3AttackPicker == 1) { npc.ai[0] = 11f; npc.ai[1] = 0f; @@ -7170,9 +7234,9 @@ namespace CalamityMod.NPCs npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); // Direction - if (num32 != 0) + if (phase3FaceDirection != 0) { - npc.direction = num32; + npc.direction = phase3FaceDirection; if (npc.spriteDirection == 1) npc.rotation += pie; @@ -7182,14 +7246,14 @@ namespace CalamityMod.NPCs } // Pause - else if (num33 == 2) + else if (phase3AttackPicker == 2) { npc.ai[0] = 12f; npc.ai[1] = 0f; npc.ai[2] = 0f; } - else if (num33 == 3) + else if (phase3AttackPicker == 3) { npc.ai[0] = 13f; npc.ai[1] = 0f; @@ -7197,16 +7261,16 @@ namespace CalamityMod.NPCs } // Set velocity for spin - else if (num33 == 4) + else if (phase3AttackPicker == 4) { // Velocity and rotation - npc.velocity = Vector2.Normalize(player.Center - npc.Center) * scaleFactor4; + npc.velocity = Vector2.Normalize(player.Center - npc.Center) * spinAttackSpeed; npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); // Direction - if (num32 != 0) + if (phase3FaceDirection != 0) { - npc.direction = num32; + npc.direction = phase3FaceDirection; if (npc.spriteDirection == 1) npc.rotation += pie; @@ -7267,16 +7331,16 @@ namespace CalamityMod.NPCs } // Spawn dust - int num34 = 7; - for (int m = 0; m < num34; m++) + int phase3ChargeDustAmt = 7; + for (int m = 0; m < phase3ChargeDustAmt; m++) { - Vector2 arg_2444_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((m - (num34 / 2 - 1)) * pie / num34) + npc.Center; + Vector2 arg_2444_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((m - (phase3ChargeDustAmt / 2 - 1)) * pie / phase3ChargeDustAmt) + npc.Center; Vector2 vector11 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num35 = Dust.NewDust(arg_2444_0 + vector11, 0, 0, (int)CalamityDusts.SulfurousSeaAcid, vector11.X * 2f, vector11.Y * 2f, 100, default, 1.4f); - Main.dust[num35].noGravity = true; - Main.dust[num35].noLight = true; - Main.dust[num35].velocity /= 4f; - Main.dust[num35].velocity -= npc.velocity; + int phase3ChargeDust = Dust.NewDust(arg_2444_0 + vector11, 0, 0, (int)CalamityDusts.SulfurousSeaAcid, vector11.X * 2f, vector11.Y * 2f, 100, default, 1.4f); + Main.dust[phase3ChargeDust].noGravity = true; + Main.dust[phase3ChargeDust].noLight = true; + Main.dust[phase3ChargeDust].velocity /= 4f; + Main.dust[phase3ChargeDust].velocity -= npc.velocity; } npc.ai[2] += 1f; @@ -7299,7 +7363,7 @@ namespace CalamityMod.NPCs npc.damage = 0; // Alpha - if (npc.alpha < 255 && npc.ai[2] >= num12 - 15f) + if (npc.alpha < 255 && npc.ai[2] >= teleportPauseTimer - 15f) { npc.alpha += 17; if (npc.alpha > 255) @@ -7311,10 +7375,10 @@ namespace CalamityMod.NPCs npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); // Play sound - if (npc.ai[2] == num12 / 2) + if (npc.ai[2] == teleportPauseTimer / 2) modNPC.RoarSoundSlot = SoundEngine.PlaySound(OldDuke.OldDuke.RoarSound, npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == num12 / 2) + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == teleportPauseTimer / 2) { // Teleport location if (npc.ai[1] == 0f) @@ -7323,17 +7387,17 @@ namespace CalamityMod.NPCs // Rotation and direction Vector2 center = player.Center + new Vector2(npc.ai[1], -300f); Vector2 npcCenter = npc.Center = center; - int num36 = Math.Sign(player.Center.X - npcCenter.X); - if (num36 != 0) + int phase3TeleportFaceDirection = Math.Sign(player.Center.X - npcCenter.X); + if (phase3TeleportFaceDirection != 0) { - if (npc.ai[2] == 0f && num36 != npc.direction) + if (npc.ai[2] == 0f && phase3TeleportFaceDirection != npc.direction) { npc.rotation += pie; for (int n = 0; n < npc.oldPos.Length; n++) npc.oldPos[n] = Vector2.Zero; } - npc.direction = num36; + npc.direction = phase3TeleportFaceDirection; if (npc.spriteDirection != -npc.direction) npc.rotation += pie; @@ -7343,7 +7407,7 @@ namespace CalamityMod.NPCs } npc.ai[2] += 1f; - if (npc.ai[2] >= num12) + if (npc.ai[2] >= teleportPauseTimer) { npc.ai[0] = 10f; npc.ai[1] = 0f; @@ -7365,13 +7429,13 @@ namespace CalamityMod.NPCs npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); // Play sound - if (npc.ai[2] == num9 - 30) + if (npc.ai[2] == attackTimer - 30) { SoundEngine.PlaySound(OldDuke.OldDuke.VomitSound, npc.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector7 = npc.rotation.ToRotationVector2() * (Vector2.UnitX * npc.direction) * (npc.width + 20) / 2f + npc.Center; + Vector2 phase3GoreDirection = npc.rotation.ToRotationVector2() * (Vector2.UnitX * npc.direction) * (npc.width + 20) / 2f + npc.Center; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); int totalGore = Main.getGoodWorld ? 40 : 20; @@ -7386,12 +7450,12 @@ namespace CalamityMod.NPCs velocityY *= Main.rand.NextFloat() + 0.5f; } - Projectile.NewProjectile(npc.GetSource_FromAI(), vector7.X, vector7.Y, velocityX, -velocityY, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), phase3GoreDirection.X, phase3GoreDirection.Y, velocityX, -velocityY, type, damage, 0f, Main.myPlayer, 0f, 0f); } } } - if (npc.ai[2] >= num9 - 90) + if (npc.ai[2] >= attackTimer - 90) { if (npc.ai[2] % 18f == 0f) { @@ -7413,7 +7477,7 @@ namespace CalamityMod.NPCs } npc.ai[2] += 1f; - if (npc.ai[2] >= num9) + if (npc.ai[2] >= attackTimer) { calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; calamityGlobalNPC.newAI[2] = 0f; @@ -7445,9 +7509,9 @@ namespace CalamityMod.NPCs if (npc.ai[2] != 0f) SoundEngine.PlaySound(OldDuke.OldDuke.VomitSound, npc.Center); - Vector2 vector10 = Vector2.Normalize(npc.velocity) * (npc.width + 20) / 2f + npc.Center; + Vector2 phase3ToothBallDirection = Vector2.Normalize(npc.velocity) * (npc.width + 20) / 2f + npc.Center; Vector2 toothBallVelocity = Vector2.Normalize(npc.velocity).RotatedBy(MathHelper.PiOver2 * npc.direction) * toothBallSpinToothBallVelocity; - Vector2 toothBallSpawnPos = new Vector2(vector10.X, vector10.Y + 45f); + Vector2 toothBallSpawnPos = new Vector2(phase3ToothBallDirection.X, phase3ToothBallDirection.Y + 45f); if (Main.netMode != NetmodeID.MultiplayerClient) { int toothBall = NPC.NewNPC(npc.GetSource_FromAI(), (int)toothBallSpawnPos.X, (int)toothBallSpawnPos.Y, ModContent.NPCType(), 0, toothBallVelocity.X, toothBallVelocity.Y); @@ -7490,11 +7554,11 @@ namespace CalamityMod.NPCs } // Velocity and rotation - npc.velocity = npc.velocity.RotatedBy(-(double)num15 * npc.direction); - npc.rotation -= num15 * npc.direction; + npc.velocity = npc.velocity.RotatedBy(-(double)spinSpeed * npc.direction); + npc.rotation -= spinSpeed * npc.direction; npc.ai[2] += 1f; - if (npc.ai[2] >= num13) + if (npc.ai[2] >= toothBallSpinTimer) { calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; npc.ai[0] = 10f; @@ -7515,26 +7579,25 @@ namespace CalamityMod.NPCs #region Gem Crawler AI public static void GemCrawlerAI(NPC npc, Mod mod, float speedDetect, float speedAdditive) { - int num19 = 30; - int num20 = 10; - bool flag19 = false; - bool flag20 = false; - bool flag30 = false; + int turnAroundDelay = 30; + bool unusedFlag = false; + bool isRunning = false; + bool shouldTurnAround = false; if (npc.velocity.Y == 0f && ((npc.velocity.X > 0f && npc.direction > 0) || (npc.velocity.X < 0f && npc.direction < 0))) { - flag20 = true; + isRunning = true; npc.ai[3] += 1f; } - if ((npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)num19) | flag20) + if ((npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)turnAroundDelay) | isRunning) { npc.ai[3] += 1f; - flag30 = true; + shouldTurnAround = true; } else if (npc.ai[3] > 0f) { npc.ai[3] -= 1f; } - if (npc.ai[3] > (float)(num19 * num20)) + if (npc.ai[3] > (float)(turnAroundDelay * 10)) { npc.ai[3] = 0f; } @@ -7542,7 +7605,7 @@ namespace CalamityMod.NPCs { npc.ai[3] = 0f; } - if (npc.ai[3] == (float)num19) + if (npc.ai[3] == (float)turnAroundDelay) { npc.netUpdate = true; } @@ -7550,11 +7613,11 @@ namespace CalamityMod.NPCs float xDist = Main.player[npc.target].Center.X - npcPos.X; float yDist = Main.player[npc.target].Center.Y - npcPos.Y; float targetDist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); - if (targetDist < 200f && !flag30) + if (targetDist < 200f && !shouldTurnAround) { npc.ai[3] = 0f; } - if (npc.ai[3] < (float)num19) + if (npc.ai[3] < (float)turnAroundDelay) { npc.TargetClosest(true); } @@ -7583,50 +7646,50 @@ namespace CalamityMod.NPCs npc.direction = 1; } } - float num6 = speedDetect; //5 - float num70 = speedAdditive; //0.05 - if (!flag19 && (npc.velocity.Y == 0f || npc.wet || (npc.velocity.X <= 0f && npc.direction > 0) || (npc.velocity.X >= 0f && npc.direction < 0))) + float maxVelocity = speedDetect; //5 + float acceleration = speedAdditive; //0.05 + if (!unusedFlag && (npc.velocity.Y == 0f || npc.wet || (npc.velocity.X <= 0f && npc.direction > 0) || (npc.velocity.X >= 0f && npc.direction < 0))) { - if (npc.velocity.X < -num6 || npc.velocity.X > num6) + if (npc.velocity.X < -maxVelocity || npc.velocity.X > maxVelocity) { if (npc.velocity.Y == 0f) { npc.velocity *= 0.8f; } } - else if (npc.velocity.X < num6 && npc.direction == -1) + else if (npc.velocity.X < maxVelocity && npc.direction == -1) { - npc.velocity.X = npc.velocity.X + num70; - if (npc.velocity.X > num6) + npc.velocity.X = npc.velocity.X + acceleration; + if (npc.velocity.X > maxVelocity) { - npc.velocity.X = num6; + npc.velocity.X = maxVelocity; } } - else if (npc.velocity.X > -num6 && npc.direction == 1) + else if (npc.velocity.X > -maxVelocity && npc.direction == 1) { - npc.velocity.X = npc.velocity.X - num70; - if (npc.velocity.X < -num6) + npc.velocity.X = npc.velocity.X - acceleration; + if (npc.velocity.X < -maxVelocity) { - npc.velocity.X = -num6; + npc.velocity.X = -maxVelocity; } } } if (npc.velocity.Y >= 0f) { - int num9 = 0; + int faceDirection = 0; if (npc.velocity.X < 0f) { - num9 = -1; + faceDirection = -1; } if (npc.velocity.X > 0f) { - num9 = 1; + faceDirection = 1; } Vector2 position = npc.position; position.X += npc.velocity.X; - int x = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * num9)) / 16f); + int x = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * faceDirection)) / 16f); int y = (int)((position.Y + (float)npc.height - 1f) / 16f); - if ((float)(x * 16) < position.X + (float)npc.width && (float)(x * 16 + 16) > position.X && ((Main.tile[x, y].HasUnactuatedTile && !Main.tile[x, y].TopSlope && !Main.tile[x, y - 1].TopSlope && Main.tileSolid[(int)Main.tile[x, y].TileType] && !Main.tileSolidTop[(int)Main.tile[x, y].TileType]) || (Main.tile[x, y - 1].IsHalfBlock && Main.tile[x, y - 1].HasUnactuatedTile)) && (!Main.tile[x, y - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 1].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 1].TileType] || (Main.tile[x, y - 1].IsHalfBlock && (!Main.tile[x, y - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 4].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 4].TileType]))) && (!Main.tile[x, y - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 2].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 2].TileType]) && (!Main.tile[x, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 3].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 3].TileType]) && (!Main.tile[x - num9, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x - num9, y - 3].TileType])) + if ((float)(x * 16) < position.X + (float)npc.width && (float)(x * 16 + 16) > position.X && ((Main.tile[x, y].HasUnactuatedTile && !Main.tile[x, y].TopSlope && !Main.tile[x, y - 1].TopSlope && Main.tileSolid[(int)Main.tile[x, y].TileType] && !Main.tileSolidTop[(int)Main.tile[x, y].TileType]) || (Main.tile[x, y - 1].IsHalfBlock && Main.tile[x, y - 1].HasUnactuatedTile)) && (!Main.tile[x, y - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 1].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 1].TileType] || (Main.tile[x, y - 1].IsHalfBlock && (!Main.tile[x, y - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 4].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 4].TileType]))) && (!Main.tile[x, y - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 2].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 2].TileType]) && (!Main.tile[x, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 3].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 3].TileType]) && (!Main.tile[x - faceDirection, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x - faceDirection, y - 3].TileType])) { float npcBottom = (float)(y * 16); if (Main.tile[x, y].IsHalfBlock) @@ -7639,12 +7702,12 @@ namespace CalamityMod.NPCs } if (npcBottom < position.Y + (float)npc.height) { - float num13 = position.Y + (float)npc.height - npcBottom; - if (num13 <= 16.1f) + float percentageTileRisen = position.Y + (float)npc.height - npcBottom; + if (percentageTileRisen <= 16.1f) { npc.gfxOffY += npc.position.Y + (float)npc.height - npcBottom; npc.position.Y = npcBottom - (float)npc.height; - if (num13 < 9f) + if (percentageTileRisen < 9f) { npc.stepSpeed = 1f; } @@ -7707,18 +7770,18 @@ namespace CalamityMod.NPCs { bool DogPhase1 = npc.type == ModContent.NPCType() && npc.life > npc.lifeMax * (CalamityWorld.death ? 0.9 : CalamityWorld.revenge ? 0.7 : 0.5); bool DogPhase2 = npc.type == ModContent.NPCType() && npc.life <= npc.lifeMax * (CalamityWorld.death ? 0.9 : CalamityWorld.revenge ? 0.7 : 0.5); - int num = 30; - bool flag2 = false; - bool flag3 = false; + int turnAroundDelay = 30; + bool isRunning = false; + bool shouldTurnAround = false; if (npc.velocity.Y == 0f && ((npc.velocity.X > 0f && npc.direction < 0) || (npc.velocity.X < 0f && npc.direction > 0))) { - flag2 = true; + isRunning = true; npc.ai[3] += 1f; } - int num2 = DogPhase1 ? 10 : 4; + int turnAroundDelayMult = DogPhase1 ? 10 : 4; if (!DogPhase1) { - bool flag4 = npc.velocity.Y == 0f; + bool noYVelocity = npc.velocity.Y == 0f; for (int i = 0; i < Main.maxNPCs; i++) { if (i != npc.whoAmI && Main.npc[i].active && Main.npc[i].type == npc.type && Math.Abs(npc.position.X - Main.npc[i].position.X) + Math.Abs(npc.position.Y - Main.npc[i].position.Y) < (float)npc.width) @@ -7741,21 +7804,21 @@ namespace CalamityMod.NPCs } } } - if (flag4) + if (noYVelocity) { npc.velocity.Y = 0f; } } - if (npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)num || flag2) + if (npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)turnAroundDelay || isRunning) { npc.ai[3] += 1f; - flag3 = true; + shouldTurnAround = true; } else if (npc.ai[3] > 0f) { npc.ai[3] -= 1f; } - if (npc.ai[3] > (float)(num * num2)) + if (npc.ai[3] > (float)(turnAroundDelay * turnAroundDelayMult)) { npc.ai[3] = 0f; } @@ -7763,7 +7826,7 @@ namespace CalamityMod.NPCs { npc.ai[3] = 0f; } - if (npc.ai[3] == (float)num) + if (npc.ai[3] == (float)turnAroundDelay) { npc.netUpdate = true; } @@ -7771,7 +7834,7 @@ namespace CalamityMod.NPCs float xDist = Main.player[npc.target].Center.X - npcPos.X; float yDist = Main.player[npc.target].Center.Y - npcPos.Y; float targetDist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); - if (targetDist < 200f && !flag3) + if (targetDist < 200f && !shouldTurnAround) { npc.ai[3] = 0f; } @@ -7814,7 +7877,7 @@ namespace CalamityMod.NPCs } } } - if (npc.ai[3] < (float)num) + if (npc.ai[3] < (float)turnAroundDelay) { npc.TargetClosest(true); } @@ -7850,51 +7913,51 @@ namespace CalamityMod.NPCs { npc.velocity.X *= 0.92f; } - float num9 = MathHelper.Lerp(0.6f, 1f, Math.Abs(Main.windSpeedCurrent)) * (float)Math.Sign(Main.windSpeedCurrent); + float sandstormPush = MathHelper.Lerp(0.6f, 1f, Math.Abs(Main.windSpeedCurrent)) * (float)Math.Sign(Main.windSpeedCurrent); if (!Main.player[npc.target].ZoneSandstorm) { - num9 = 0f; + sandstormPush = 0f; } - float num7 = speedDetect; - float num8 = speedAdditive; - if (npc.velocity.X < -num7 || npc.velocity.X > num7) + float maxVelocity = speedDetect; + float acceleration = speedAdditive; + if (npc.velocity.X < -maxVelocity || npc.velocity.X > maxVelocity) { if (npc.velocity.Y == 0f) { npc.velocity *= 0.8f; } } - else if (npc.velocity.X < num7 && npc.direction == 1) + else if (npc.velocity.X < maxVelocity && npc.direction == 1) { - npc.velocity.X += num8; - if (npc.velocity.X > num7) + npc.velocity.X += acceleration; + if (npc.velocity.X > maxVelocity) { - npc.velocity.X = num7; + npc.velocity.X = maxVelocity; } } - else if (npc.velocity.X > -num7 && npc.direction == -1) + else if (npc.velocity.X > -maxVelocity && npc.direction == -1) { - npc.velocity.X -= num8; - if (npc.velocity.X < -num7) + npc.velocity.X -= acceleration; + if (npc.velocity.X < -maxVelocity) { - npc.velocity.X = -num7; + npc.velocity.X = -maxVelocity; } } } if (npc.velocity.Y >= 0f) { - int num10 = 0; + int faceDirection = 0; if (npc.velocity.X < 0f) { - num10 = -1; + faceDirection = -1; } if (npc.velocity.X > 0f) { - num10 = 1; + faceDirection = 1; } Vector2 position = npc.position; position.X += npc.velocity.X; - int x = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * num10)) / 16f); + int x = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * faceDirection)) / 16f); int y = (int)((position.Y + (float)npc.height - 1f) / 16f); // 21JAN2023: Ozzatron -- this is probably the single most unmaintainable if statement I've ever seen @@ -7903,7 +7966,7 @@ namespace CalamityMod.NPCs Tile t_xy1 = CalamityUtils.ParanoidTileRetrieval(x, y - 1); Tile t_xy2 = CalamityUtils.ParanoidTileRetrieval(x, y - 2); Tile t_xy3 = CalamityUtils.ParanoidTileRetrieval(x, y - 3); - Tile t_xOffY3 = CalamityUtils.ParanoidTileRetrieval(x - num10, y - 3); // 3 down, offset 1 in the direction of the NPC's movement + Tile t_xOffY3 = CalamityUtils.ParanoidTileRetrieval(x - faceDirection, y - 3); // 3 down, offset 1 in the direction of the NPC's movement Tile t_xy4 = CalamityUtils.ParanoidTileRetrieval(x, y - 4); bool positionCheck = (float)(x * 16) < position.X + (float)npc.width && (float)(x * 16 + 16) > position.X; bool tileSolidityCheck1 = t_xy.HasUnactuatedTile && !t_xy.TopSlope && !t_xy1.TopSlope && Main.tileSolid[t_xy.TileType] && !Main.tileSolidTop[t_xy.TileType]; @@ -7915,23 +7978,23 @@ namespace CalamityMod.NPCs bool threeDownOffsetIsNonSolid = !t_xOffY3.HasUnactuatedTile || !Main.tileSolid[t_xOffY3.TileType]; if (positionCheck && (tileSolidityCheck1 || oneBelowIsSolidHalf) && canFallThrough && twoDownIsNonSolid && threeDownIsNonSolid && threeDownOffsetIsNonSolid) { - float num13 = (float)(y * 16); + float tilePixelPosition = (float)(y * 16); if (Main.tile[x, y].IsHalfBlock) { - num13 += 8f; + tilePixelPosition += 8f; } if (Main.tile[x, y - 1].IsHalfBlock) { - num13 -= 8f; + tilePixelPosition -= 8f; } - if (num13 < position.Y + (float)npc.height) + if (tilePixelPosition < position.Y + (float)npc.height) { - float num14 = position.Y + (float)npc.height - num13; - if ((double)num14 <= 16.1) + float percentageTileRisen = position.Y + (float)npc.height - tilePixelPosition; + if ((double)percentageTileRisen <= 16.1) { - npc.gfxOffY += npc.position.Y + (float)npc.height - num13; - npc.position.Y = num13 - (float)npc.height; - if (num14 < 9f) + npc.gfxOffY += npc.position.Y + (float)npc.height - tilePixelPosition; + npc.position.Y = tilePixelPosition - (float)npc.height; + if (percentageTileRisen < 9f) { npc.stepSpeed = 1f; } @@ -7945,16 +8008,15 @@ namespace CalamityMod.NPCs } if (npc.velocity.Y == 0f) { - int num15 = (int)((npc.position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 2) * npc.direction) + npc.velocity.X * 5f) / 16f); - int num16 = (int)((npc.position.Y + (float)npc.height - 15f) / 16f); - int num17 = npc.spriteDirection; - num17 *= -1; - if ((npc.velocity.X < 0f && num17 == -1) || (npc.velocity.X > 0f && num17 == 1)) + int npcTileX = (int)((npc.position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 2) * npc.direction) + npc.velocity.X * 5f) / 16f); + int npcTileY = (int)((npc.position.Y + (float)npc.height - 15f) / 16f); + int spriteDirection = npc.spriteDirection; + spriteDirection *= -1; + if ((npc.velocity.X < 0f && spriteDirection == -1) || (npc.velocity.X > 0f && spriteDirection == 1)) { - float num18 = 3f; - if (Main.tile[num15, num16 - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num15, num16 - 2].TileType]) + if (Main.tile[npcTileX, npcTileY - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 2].TileType]) { - if (Main.tile[num15, num16 - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num15, num16 - 3].TileType]) + if (Main.tile[npcTileX, npcTileY - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 3].TileType]) { npc.velocity.Y = bouncy1; npc.netUpdate = true; @@ -7965,17 +8027,17 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } } - else if (Main.tile[num15, num16 - 1].HasUnactuatedTile && !Main.tile[num15, num16 - 1].TopSlope && Main.tileSolid[(int)Main.tile[num15, num16 - 1].TileType]) + else if (Main.tile[npcTileX, npcTileY - 1].HasUnactuatedTile && !Main.tile[npcTileX, npcTileY - 1].TopSlope && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 1].TileType]) { npc.velocity.Y = bouncy3; npc.netUpdate = true; } - else if (npc.position.Y + (float)npc.height - (float)(num16 * 16) > 20f && Main.tile[num15, num16].HasUnactuatedTile && !Main.tile[num15, num16].TopSlope && Main.tileSolid[(int)Main.tile[num15, num16].TileType]) + else if (npc.position.Y + (float)npc.height - (float)(npcTileY * 16) > 20f && Main.tile[npcTileX, npcTileY].HasUnactuatedTile && !Main.tile[npcTileX, npcTileY].TopSlope && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY].TileType]) { npc.velocity.Y = bouncy4; npc.netUpdate = true; } - else if ((npc.directionY < 0 || Math.Abs(npc.velocity.X) > num18) && (!Main.tile[num15, num16 + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num15, num16 + 1].TileType]) && (!Main.tile[num15, num16 + 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num15, num16 + 2].TileType]) && (!Main.tile[num15 + npc.direction, num16 + 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num15 + npc.direction, num16 + 3].TileType])) + else if ((npc.directionY < 0 || Math.Abs(npc.velocity.X) > 3f) && (!Main.tile[npcTileX, npcTileY + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX, npcTileY + 1].TileType]) && (!Main.tile[npcTileX, npcTileY + 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX, npcTileY + 2].TileType]) && (!Main.tile[npcTileX + npc.direction, npcTileY + 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX + npc.direction, npcTileY + 3].TileType])) { npc.velocity.Y = bouncy5; npc.netUpdate = true; @@ -7991,11 +8053,11 @@ namespace CalamityMod.NPCs #endregion #region Swimming AI - // Passiveness: - // 0 = Catfish, Flounder, Frogfish, Viperfish, Moray Eel, Laserfish - // 1 = Blinded Angler - // 2 = Prism-Back, Toxic Minnow - // 3 = Sea Minnow + // Passiveness: + // 0 = Catfish, Flounder, Frogfish, Viperfish, Moray Eel, Laserfish + // 1 = Blinded Angler + // 2 = Prism-Back, Toxic Minnow + // 3 = Sea Minnow public static void PassiveSwimmingAI(NPC npc, Mod mod, int passiveness, float detectRange, float xSpeed, float ySpeed, float speedLimitX, float speedLimitY, float rotation, bool spriteFacesLeft = true) { if (spriteFacesLeft) @@ -8008,7 +8070,7 @@ namespace CalamityMod.NPCs { npc.TargetClosest(true); } - Player target = Main.player[npc.target]; + Player target = Main.player[npc.target]; if (npc.justHit && passiveness != 3) { npc.chaseable = true; @@ -8017,8 +8079,8 @@ namespace CalamityMod.NPCs { bool hasWetTarget = npc.chaseable; npc.TargetClosest(false); - target = Main.player[npc.target]; - // Player detection behavior + target = Main.player[npc.target]; + // Player detection behavior if (passiveness != 2) { if (npc.type == ModContent.NPCType()) @@ -8056,14 +8118,14 @@ namespace CalamityMod.NPCs hasWetTarget = false; } - // Swim back and forth + // Swim back and forth if (!hasWetTarget || passiveness == 2) { if (passiveness == 0) - { + { npc.TargetClosest(true); - target = Main.player[npc.target]; - } + target = Main.player[npc.target]; + } if (npc.collideX) { npc.velocity.X = npc.velocity.X * -1f; @@ -8091,14 +8153,14 @@ namespace CalamityMod.NPCs if (hasWetTarget && passiveness != 2) { npc.TargetClosest(true); - target = Main.player[npc.target]; - // Swim away from the player + target = Main.player[npc.target]; + // Swim away from the player if (passiveness == 3) { npc.velocity.X = npc.velocity.X - (float)npc.direction * xSpeed; npc.velocity.Y = npc.velocity.Y - (float)npc.directionY * ySpeed; } - // Swim toward the player + // Swim toward the player else { npc.velocity.X = npc.velocity.X + (float)npc.direction * (CalamityWorld.death ? 2f * xSpeed : CalamityWorld.revenge ? 1.5f * xSpeed : xSpeed); @@ -8136,7 +8198,7 @@ namespace CalamityMod.NPCs } } - // Flounder shoot Sulphuric Mist at the player + // Flounder shoot Sulphuric Mist at the player if (npc.type == ModContent.NPCType()) { if ((target.Center - npc.Center).Length() < 350f) @@ -8162,7 +8224,7 @@ namespace CalamityMod.NPCs } } - // Sea Minnows face away from the player + // Sea Minnows face away from the player if (npc.type == ModContent.NPCType()) { npc.direction *= -1; @@ -8170,7 +8232,7 @@ namespace CalamityMod.NPCs } else { - // No target behavior + // No target behavior npc.velocity.X += (float)npc.direction * 0.1f; if (npc.velocity.X < -2.5f || npc.velocity.X > 2.5f) { @@ -8193,15 +8255,15 @@ namespace CalamityMod.NPCs } } } - int num258 = (int)(npc.position.X + (float)(npc.width / 2)) / 16; - int num259 = (int)(npc.position.Y + (float)(npc.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount > 128) + int npcTileX = (int)(npc.position.X + (float)(npc.width / 2)) / 16; + int npcTileY = (int)(npc.position.Y + (float)(npc.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { npc.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { npc.ai[0] = -1f; } @@ -8213,7 +8275,7 @@ namespace CalamityMod.NPCs } else { - // Out of water behavior + // Out of water behavior if (npc.velocity.Y == 0f) { npc.velocity.X = npc.velocity.X * 0.94f; diff --git a/NPCs/CalamityGlobalAI.cs b/NPCs/CalamityGlobalAI.cs index 48a955524b..6ca9db0a96 100644 --- a/NPCs/CalamityGlobalAI.cs +++ b/NPCs/CalamityGlobalAI.cs @@ -103,7 +103,7 @@ namespace CalamityMod.NPCs Vector2 headPosition = npc.Top + new Vector2((float)(npc.spriteDirection * 6), 6f); float rotationVectorMult = MathHelper.Lerp(20f, 30f, (time * 3f + 50f) / 182f); Main.rand.NextFloat(); - for (float num17 = 0f; num17 < 2f; num17 += 1f) + for (float i = 0f; i < 2f; i += 1f) { Vector2 rotationVector = Vector2.UnitY.RotatedByRandom(Math.PI * 2.0) * (Main.rand.NextFloat() * 0.5f + 0.5f); Dust dust = Dust.NewDustDirect(headPosition, 0, 0, 228, 0f, 0f, 0, default, 1f); @@ -584,12 +584,12 @@ namespace CalamityMod.NPCs npc.TargetClosest(true); float velocityMultiplier = 10f; float turnValue = 40f; - Vector2 value3 = Main.player[npc.target].Center - npc.Center; - float playerDistance = value3.Length(); + Vector2 targetDirection = Main.player[npc.target].Center - npc.Center; + float playerDistance = targetDirection.Length(); velocityMultiplier += playerDistance / 200f; - value3.Normalize(); - value3 *= velocityMultiplier; - npc.velocity = (npc.velocity * (turnValue - 1f) + value3) / turnValue; + targetDirection.Normalize(); + targetDirection *= velocityMultiplier; + npc.velocity = (npc.velocity * (turnValue - 1f) + targetDirection) / turnValue; if (playerDistance < 500f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) { // Go back to normal AI @@ -1038,10 +1038,10 @@ namespace CalamityMod.NPCs SoundEngine.PlaySound(SoundID.Item8, npc.position); float distX = npc.oldPos[2].X + (float)npc.width * 0.5f - npc.Center.X; float distY = npc.oldPos[2].Y + (float)npc.height * 0.5f - npc.Center.Y; - float num38 = (float)Math.Sqrt((distX * distX + distY * distY)); - num38 = 2f / num38; - distX *= num38; - distY *= num38; + float distance = (float)Math.Sqrt((distX * distX + distY * distY)); + distance = 2f / distance; + distX *= distance; + distY *= distance; for (int m = 0; m < 20; m++) { int dustIdx = Dust.NewDust(npc.position, npc.width, npc.height, 71, distX, distY, 200, default, 2f); @@ -1083,12 +1083,7 @@ namespace CalamityMod.NPCs ableToAlterAI3 = true; } - // This variable means so many fucking things for different NPCs - // Such as npc spawn timer, projectile timer, ect - // From what I can gather, the ai2 value's max for spawning things also varies - // As a result, I'll just leave this as flag7. If anyone has - // Ideas for a better variable name, please change it - bool flag7 = npc.ai[2] <= 0f; + bool npcTimer = npc.ai[2] <= 0f; if (npcType <= NPCID.RayGunner) { if (npcType <= NPCID.PirateCaptain) @@ -1126,7 +1121,7 @@ namespace CalamityMod.NPCs //& and && (same with | and ||) with booleans, // I'd greatly appreciate it PrepareToShoot: - if (!ableToAlterAI3 & flag7) + if (!ableToAlterAI3 & npcTimer) { if (npc.velocity.Y == 0f && ((npc.velocity.X > 0f && npc.direction < 0) || (npc.velocity.X < 0f && npc.direction > 0))) { @@ -2509,17 +2504,17 @@ namespace CalamityMod.NPCs { bool npcAllowedToShoot = npcType == NPCID.BrainScrambler || npcType == NPCID.RayGunner || npcType == NPCID.MartianWalker; bool isAlienQueen = npcType == NPCID.VortexHornetQueen; - bool flag18 = true; - int num136 = -1; - int num137 = -1; + bool canShootAtTarget = true; + int stardustGateValue = -1; + int stardustGateValueAdd = -1; if (npcType == NPCID.StardustSoldier) { npcAllowedToShoot = true; - num136 = 90; - num137 = 90; + stardustGateValue = 90; + stardustGateValueAdd = 90; if (npc.ai[1] <= 150f) { - flag18 = false; + canShootAtTarget = false; } } if (npc.confused) @@ -2623,85 +2618,85 @@ namespace CalamityMod.NPCs } } attackTimeMax = (int)(attackTimeMax * 0.75); - int num139 = attackTimeMax / 2; + int modifiedAttackTime = attackTimeMax / 2; if (npcType == NPCID.NebulaSoldier) { - num139 = attackTimeMax - 1; + modifiedAttackTime = attackTimeMax - 1; } if (npcType == NPCID.VortexHornetQueen) { - num139 = attackTimeMax - 1; + modifiedAttackTime = attackTimeMax - 1; } if (npc.ai[2] > 0f) { - if (flag18) + if (canShootAtTarget) { npc.TargetClosest(true); } - if (npc.ai[1] == (float)num139) + if (npc.ai[1] == (float)modifiedAttackTime) { if (npcType == NPCID.PirateCaptain) { npc.localAI[2] += 1f; } - float num140 = CalamityWorld.death ? 6f : 11f; + float projSpeed = CalamityWorld.death ? 6f : 11f; if (npcType == NPCID.GoblinArcher) { - num140 = CalamityWorld.death ? 5f : 9f; + projSpeed = CalamityWorld.death ? 5f : 9f; } if (npcType == NPCID.IcyMerman) { - num140 = CalamityWorld.death ? 4f : 7f; + projSpeed = CalamityWorld.death ? 4f : 7f; } if (npcType == NPCID.Paladin) { - num140 = CalamityWorld.death ? 5f : 9f; + projSpeed = CalamityWorld.death ? 5f : 9f; } if (npcType == NPCID.SkeletonCommando) { - num140 = CalamityWorld.death ? 2.5f : 4f; + projSpeed = CalamityWorld.death ? 2.5f : 4f; } if (npcType == NPCID.PirateDeadeye) { - num140 = CalamityWorld.death ? 8f : 14f; + projSpeed = CalamityWorld.death ? 8f : 14f; } if (npcType == NPCID.PirateCrossbower) { - num140 = CalamityWorld.death ? 9f : 16f; + projSpeed = CalamityWorld.death ? 9f : 16f; } if (npcType == NPCID.RayGunner) { - num140 = CalamityWorld.death ? 4f : 7f; + projSpeed = CalamityWorld.death ? 4f : 7f; } if (npcType == NPCID.MartianWalker) { - num140 = CalamityWorld.death ? 5f : 8f; + projSpeed = CalamityWorld.death ? 5f : 8f; } if (npcType == NPCID.StardustSpiderBig) { - num140 = 4f; + projSpeed = 4f; } if (npcType >= 449 && npcType <= 452) { - num140 = CalamityWorld.death ? 4f : 7f; + projSpeed = CalamityWorld.death ? 4f : 7f; } if (npcType == NPCID.GreekSkeleton) { - num140 = CalamityWorld.death ? 5f : 8f; + projSpeed = CalamityWorld.death ? 5f : 8f; } if (npcType == NPCID.DrManFly) { - num140 = CalamityWorld.death ? 4.5f : 7.5f; + projSpeed = CalamityWorld.death ? 4.5f : 7.5f; } if (npcType == NPCID.StardustSoldier) { - num140 = 1f; + projSpeed = 1f; } if (npcType >= 498 && npcType <= 506) { - num140 = CalamityWorld.death ? 4f : 7f; + projSpeed = CalamityWorld.death ? 4f : 7f; } - num140 *= 1.25f; + projSpeed *= 1.25f; Vector2 spawnPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); if (npcType == NPCID.GreekSkeleton) { @@ -2732,43 +2727,43 @@ namespace CalamityMod.NPCs spawnPosition += new Vector2((float)(npc.spriteDirection * 2), -12f); } float distX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - spawnPosition.X; - float num142 = Math.Abs(distX) * 0.1f; + float projOffset = Math.Abs(distX) * 0.1f; if (npcType == NPCID.SkeletonSniper || npcType == NPCID.TacticalSkeleton) { - num142 = 0f; + projOffset = 0f; } if (npcType == NPCID.PirateCrossbower) { - num142 = Math.Abs(distX) * 0.08f; + projOffset = Math.Abs(distX) * 0.08f; } if (npcType == NPCID.PirateDeadeye || (npcType == NPCID.PirateCaptain && !priateCaptainBoost)) { - num142 = 0f; + projOffset = 0f; } if (npcType == NPCID.BrainScrambler || npcType == NPCID.RayGunner || npcType == NPCID.MartianWalker) { - num142 = 0f; + projOffset = 0f; } if (npcType >= 449 && npcType <= 452) { - num142 = Math.Abs(distX) * (float)Main.rand.Next(10, 50) * 0.01f; + projOffset = Math.Abs(distX) * (float)Main.rand.Next(10, 50) * 0.01f; } if (npcType == NPCID.DrManFly) { - num142 = Math.Abs(distX) * (float)Main.rand.Next(10, 50) * 0.01f; + projOffset = Math.Abs(distX) * (float)Main.rand.Next(10, 50) * 0.01f; } if (npcType == NPCID.GreekSkeleton) { - num142 = Math.Abs(distX) * (float)Main.rand.Next(-10, 11) * 0.0035f; + projOffset = Math.Abs(distX) * (float)Main.rand.Next(-10, 11) * 0.0035f; } if (npcType >= 498 && npcType <= 506) { - num142 = Math.Abs(distX) * (float)Main.rand.Next(1, 11) * 0.0025f; + projOffset = Math.Abs(distX) * (float)Main.rand.Next(1, 11) * 0.0025f; } - float distY = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - spawnPosition.Y - num142; + float distY = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - spawnPosition.Y - projOffset; float magnitude = (float)Math.Sqrt((distX * distX + distY * distY)); npc.netUpdate = true; - magnitude = num140 / magnitude; + magnitude = projSpeed / magnitude; distX *= magnitude; distY *= magnitude; int damage = 35; @@ -2980,7 +2975,7 @@ namespace CalamityMod.NPCs npc.ai[2] = 0f; npc.ai[1] = 0f; } - else if (!npcAllowedToShoot || (num136 != -1 && npc.ai[1] >= (float)num136 && npc.ai[1] < (float)(num136 + num137) && (!isAlienQueen || npc.velocity.Y == 0f))) + else if (!npcAllowedToShoot || (stardustGateValue != -1 && npc.ai[1] >= (float)stardustGateValue && npc.ai[1] < (float)(stardustGateValue + stardustGateValueAdd) && (!isAlienQueen || npc.velocity.Y == 0f))) { npc.velocity.X *= 0.9f; npc.spriteDirection = npc.direction; @@ -3004,10 +2999,10 @@ namespace CalamityMod.NPCs } if (canAttack) { - Vector2 vector23 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float distX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector23.X; + Vector2 projSpawnPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float distX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - projSpawnPosition.X; float distXAbsolute = Math.Abs(distX) * 0.1f; - float distY = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector23.Y - distXAbsolute; + float distY = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - projSpawnPosition.Y - distXAbsolute; distX += (float)Main.rand.Next(-40, 41); distY += (float)Main.rand.Next(-40, 41); float playerDistance = (float)Math.Sqrt(distX * distX + distY * distY); @@ -3076,7 +3071,7 @@ namespace CalamityMod.NPCs } } - if (npc.ai[2] <= 0f || (npcAllowedToShoot && (num136 == -1 || npc.ai[1] < (float)num136 || npc.ai[1] >= (float)(num136 + num137)))) + if (npc.ai[2] <= 0f || (npcAllowedToShoot && (stardustGateValue == -1 || npc.ai[1] < (float)stardustGateValue || npc.ai[1] >= (float)(stardustGateValue + stardustGateValueAdd)))) { float maxVelocity = 1f; float acceleration = 0.07f; @@ -3175,12 +3170,12 @@ namespace CalamityMod.NPCs Vector2 spawnPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f - (float)(npc.direction * 24), npc.position.Y + 4f); int velocityX = 3 * npc.direction; int velocityY = -5; - int num160 = Projectile.NewProjectile(npc.GetSource_FromAI(), spawnPosition.X, spawnPosition.Y, velocityX, velocityY, ProjectileID.HappyBomb, 0, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[num160].timeLeft = 300; + int clownBomb = Projectile.NewProjectile(npc.GetSource_FromAI(), spawnPosition.X, spawnPosition.Y, velocityX, velocityY, ProjectileID.HappyBomb, 0, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[clownBomb].timeLeft = 300; if (CalamityWorld.death) { - Main.projectile[num160].extraUpdates += 1; - Main.projectile[num160].timeLeft = 600; + Main.projectile[clownBomb].extraUpdates += 1; + Main.projectile[clownBomb].timeLeft = 600; } npc.ai[2] = 0f; } @@ -3336,26 +3331,26 @@ namespace CalamityMod.NPCs { if (Main.tile[x, y - 1].TileType == TileID.ClosedDoor) { - bool flag24 = WorldGen.OpenDoor(x, y - 1, npc.direction); - if (!flag24) + bool canOpenDoor = WorldGen.OpenDoor(x, y - 1, npc.direction); + if (!canOpenDoor) { npc.ai[3] = (float)aiGateValue; npc.netUpdate = true; } - if (Main.netMode == NetmodeID.Server & flag24) + if (Main.netMode == NetmodeID.Server & canOpenDoor) { NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 0, (float)x, (float)(y - 1), (float)npc.direction, 0, 0, 0); } } if (Main.tile[x, y - 1].TileType == TileID.TallGateClosed) { - bool flag25 = WorldGen.ShiftTallGate(x, y - 1, false); - if (!flag25) + bool canOpenTallGate = WorldGen.ShiftTallGate(x, y - 1, false); + if (!canOpenTallGate) { npc.ai[3] = (float)aiGateValue; npc.netUpdate = true; } - if (Main.netMode == NetmodeID.Server & flag25) + if (Main.netMode == NetmodeID.Server & canOpenTallGate) { NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 4, (float)x, (float)(y - 1), 0f, 0, 0, 0); } @@ -3473,25 +3468,25 @@ namespace CalamityMod.NPCs { tryCount++; int randX = Main.rand.Next(tileCoordsX - maxDistanceX, tileCoordsX + maxDistanceX); - for (int num181 = Main.rand.Next(tileCoordsY - maxDistanceX, tileCoordsY + maxDistanceX); num181 < tileCoordsY + maxDistanceX; num181++) + for (int t = Main.rand.Next(tileCoordsY - maxDistanceX, tileCoordsY + maxDistanceX); t < tileCoordsY + maxDistanceX; t++) { - if ((num181 < tileCoordsY - 4 || num181 > tileCoordsY + 4 || randX < tileCoordsX - 4 || randX > tileCoordsX + 4) && (num181 < tileCoordsY2 - 1 || num181 > tileCoordsY2 + 1 || randX < tileCoordsX2 - 1 || randX > tileCoordsX2 + 1) && Main.tile[randX, num181].HasUnactuatedTile) + if ((t < tileCoordsY - 4 || t > tileCoordsY + 4 || randX < tileCoordsX - 4 || randX > tileCoordsX + 4) && (t < tileCoordsY2 - 1 || t > tileCoordsY2 + 1 || randX < tileCoordsX2 - 1 || randX > tileCoordsX2 + 1) && Main.tile[randX, t].HasUnactuatedTile) { bool foundGoodTeleport = true; // I don't understand why the hell this exists if it's only for Chaos Elementals, but I suppose I'll // Leave it here - if (npcType == NPCID.DarkCaster && Main.tile[randX, num181 - 1].WallType == WallID.None) + if (npcType == NPCID.DarkCaster && Main.tile[randX, t - 1].WallType == WallID.None) { foundGoodTeleport = false; } - else if (Main.tile[randX, num181 - 1].LiquidType == LiquidID.Lava) + else if (Main.tile[randX, t - 1].LiquidType == LiquidID.Lava) { foundGoodTeleport = false; } - if (foundGoodTeleport && Main.tileSolid[(int)Main.tile[randX, num181].TileType] && !Collision.SolidTiles(randX - 1, randX + 1, num181 - 4, num181 - 1)) + if (foundGoodTeleport && Main.tileSolid[(int)Main.tile[randX, t].TileType] && !Collision.SolidTiles(randX - 1, randX + 1, t - 4, t - 1)) { npc.position.X = (float)(randX * 16 - npc.width / 2); - npc.position.Y = (float)(num181 * 16 - npc.height); + npc.position.Y = (float)(t * 16 - npc.height); npc.netUpdate = true; npc.ai[3] = -30f; } @@ -3540,11 +3535,11 @@ namespace CalamityMod.NPCs { for (int j = 0; j < 2; j++) { - Dust dust2 = Dust.NewDustDirect(npc.position, npc.width, npc.height, 5); - dust2.velocity *= 1f; - dust2.scale = 1f + Main.rand.NextFloat() * 0.5f; - dust2.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f; - dust2.velocity += npc.velocity * 0.3f; + Dust eyeFishDust = Dust.NewDustDirect(npc.position, npc.width, npc.height, 5); + eyeFishDust.velocity *= 1f; + eyeFishDust.scale = 1f + Main.rand.NextFloat() * 0.5f; + eyeFishDust.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f; + eyeFishDust.velocity += npc.velocity * 0.3f; } } @@ -3556,35 +3551,35 @@ namespace CalamityMod.NPCs if (targetData.Type == NPCTargetType.Player) targetDead = Main.player[npc.target].dead; - float num = 6f; - float num2 = 0.05f; + float maxVelocity = 6f; + float acceleration = 0.05f; if (npc.type == NPCID.EaterofSouls || npc.type == NPCID.Crimera) { - num = 4f; - num2 = 0.035f; + maxVelocity = 4f; + acceleration = 0.035f; } else if (npc.type == NPCID.Corruptor) { - num = 4.2f; - num2 = 0.022f; + maxVelocity = 4.2f; + acceleration = 0.022f; } else if (npc.type == NPCID.BloodSquid) { - num = 6f; - num2 = 0.1f; + maxVelocity = 6f; + acceleration = 0.1f; } else if (npc.type == NPCID.Hornet || (npc.type >= NPCID.HornetFatty && npc.type <= NPCID.HornetStingy)) { - num = 3.5f; - num2 = 0.021f; + maxVelocity = 3.5f; + acceleration = 0.021f; if (npc.type == NPCID.HornetFatty) { - num = 3f; - num2 = 0.017f; + maxVelocity = 3f; + acceleration = 0.017f; } - num *= 1f - npc.scale; - num2 *= 1f - npc.scale; + maxVelocity *= 1f - npc.scale; + acceleration *= 1f - npc.scale; if ((double)(npc.position.Y / 16f) < Main.worldSurface) { if (Main.player[npc.target].position.Y - npc.position.Y > 300f && npc.velocity.Y < 0f) @@ -3596,36 +3591,36 @@ namespace CalamityMod.NPCs } else if (npc.type == NPCID.MossHornet) { - num = 4f; - num2 = 0.017f; + maxVelocity = 4f; + acceleration = 0.017f; } else if (npc.type == NPCID.Parrot) { if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { - num = 6f; - num2 = 0.1f; + maxVelocity = 6f; + acceleration = 0.1f; } else { - num2 = 0.01f; - num = 2f; + acceleration = 0.01f; + maxVelocity = 2f; } } else if (npc.type == NPCID.Moth) { - num = 7f; - num2 = 0.06f; + maxVelocity = 7f; + acceleration = 0.06f; } else if (npc.type == NPCID.MeteorHead) { - num = 2f; - num2 = 0.05f; + maxVelocity = 2f; + acceleration = 0.05f; } else if (npc.type == NPCID.ServantofCthulhu) { - num = 5f; - num2 = 0.03f; + maxVelocity = 5f; + acceleration = 0.03f; } else if (npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall) { @@ -3635,10 +3630,10 @@ namespace CalamityMod.NPCs float originalFlyAwayVelocity = 6f; float flyAwayDistance = originalFlyAwayTime * originalFlyAwayVelocity; float flyAwayVelocity = flyAwayDistance / flyAwayTime; - float num3 = (npc.ai[1] - flyAwayTime) / flyAwayTime; - if (num3 > 1f) + float flyAwayAccel = (npc.ai[1] - flyAwayTime) / flyAwayTime; + if (flyAwayAccel > 1f) { - num3 = 1f; + flyAwayAccel = 1f; } else { @@ -3655,47 +3650,47 @@ namespace CalamityMod.NPCs npc.velocity.Y = -flyAwayVelocity; } - num = 5f; - num2 = 0.1f; - num2 *= num3; + maxVelocity = 5f; + acceleration = 0.1f; + acceleration *= flyAwayAccel; } - num *= 1.25f; - num2 *= 1.25f; + maxVelocity *= 1.25f; + acceleration *= 1.25f; if (CalamityWorld.death) { - num *= 1.25f; - num2 *= 1.25f; + maxVelocity *= 1.25f; + acceleration *= 1.25f; } Vector2 vector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num4 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num5 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); - num4 = (float)((int)(num4 / 8f) * 8); - num5 = (float)((int)(num5 / 8f) * 8); + float targetXDist = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); + float targetYDist = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); + targetXDist = (float)((int)(targetXDist / 8f) * 8); + targetYDist = (float)((int)(targetYDist / 8f) * 8); vector.X = (float)((int)(vector.X / 8f) * 8); vector.Y = (float)((int)(vector.Y / 8f) * 8); - num4 -= vector.X; - num5 -= vector.Y; - float num6 = (float)Math.Sqrt((double)(num4 * num4 + num5 * num5)); - float num7 = num6; + targetXDist -= vector.X; + targetYDist -= vector.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + float targetDistCheck = targetDistance; bool flag = false; - if (num6 > 600f) + if (targetDistance > 600f) { flag = true; } - if (num6 == 0f) + if (targetDistance == 0f) { - num4 = npc.velocity.X; - num5 = npc.velocity.Y; + targetXDist = npc.velocity.X; + targetYDist = npc.velocity.Y; } else { - num6 = num / num6; - num4 *= num6; - num5 *= num6; + targetDistance = maxVelocity / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; } if (npc.type == NPCID.Hornet || npc.type == NPCID.MossHornet || (npc.type >= NPCID.HornetFatty && npc.type <= NPCID.HornetStingy) || npc.type == NPCID.EaterofSouls || npc.type == NPCID.Corruptor || npc.type == NPCID.Probe || npc.type == NPCID.Crimera || npc.type == NPCID.Moth || npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall || npc.type == NPCID.BloodSquid) { - if (num7 > 100f || npc.type == NPCID.Corruptor || npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall || npc.type == NPCID.BloodSquid || npc.type == NPCID.Hornet || npc.type == NPCID.MossHornet || (npc.type >= NPCID.HornetFatty && npc.type <= NPCID.HornetStingy)) + if (targetDistCheck > 100f || npc.type == NPCID.Corruptor || npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall || npc.type == NPCID.BloodSquid || npc.type == NPCID.Hornet || npc.type == NPCID.MossHornet || (npc.type >= NPCID.HornetFatty && npc.type <= NPCID.HornetStingy)) { npc.ai[0] += 1f; if (npc.ai[0] > 0f) @@ -3719,60 +3714,60 @@ namespace CalamityMod.NPCs npc.ai[0] = -200f; } } - if (num7 < 150f && (npc.type == NPCID.EaterofSouls || npc.type == NPCID.Corruptor || npc.type == NPCID.Crimera || npc.type == NPCID.BloodSquid)) + if (targetDistCheck < 150f && (npc.type == NPCID.EaterofSouls || npc.type == NPCID.Corruptor || npc.type == NPCID.Crimera || npc.type == NPCID.BloodSquid)) { - npc.velocity.X = npc.velocity.X + num4 * 0.009f; - npc.velocity.Y = npc.velocity.Y + num5 * 0.009f; + npc.velocity.X = npc.velocity.X + targetXDist * 0.009f; + npc.velocity.Y = npc.velocity.Y + targetYDist * 0.009f; } } if (targetDead) { - num4 = (float)npc.direction * num / 2f; - num5 = -num / 2f; + targetXDist = (float)npc.direction * maxVelocity / 2f; + targetYDist = -maxVelocity / 2f; } - if (npc.velocity.X < num4) + if (npc.velocity.X < targetXDist) { - npc.velocity.X = npc.velocity.X + num2; - if (npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.Corruptor && npc.type != NPCID.Probe && npc.type != NPCID.BloodSquid && npc.velocity.X < 0f && num4 > 0f) + npc.velocity.X = npc.velocity.X + acceleration; + if (npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.Corruptor && npc.type != NPCID.Probe && npc.type != NPCID.BloodSquid && npc.velocity.X < 0f && targetXDist > 0f) { - npc.velocity.X = npc.velocity.X + num2; + npc.velocity.X = npc.velocity.X + acceleration; } } - else if (npc.velocity.X > num4) + else if (npc.velocity.X > targetXDist) { - npc.velocity.X = npc.velocity.X - num2; - if (npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.Corruptor && npc.type != NPCID.Probe && npc.type != NPCID.BloodSquid && npc.velocity.X > 0f && num4 < 0f) + npc.velocity.X = npc.velocity.X - acceleration; + if (npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.Corruptor && npc.type != NPCID.Probe && npc.type != NPCID.BloodSquid && npc.velocity.X > 0f && targetXDist < 0f) { - npc.velocity.X = npc.velocity.X - num2; + npc.velocity.X = npc.velocity.X - acceleration; } } - if (npc.velocity.Y < num5) + if (npc.velocity.Y < targetYDist) { - npc.velocity.Y = npc.velocity.Y + num2; - if (npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.Corruptor && npc.type != NPCID.Probe && npc.type != NPCID.BloodSquid && npc.velocity.Y < 0f && num5 > 0f) + npc.velocity.Y = npc.velocity.Y + acceleration; + if (npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.Corruptor && npc.type != NPCID.Probe && npc.type != NPCID.BloodSquid && npc.velocity.Y < 0f && targetYDist > 0f) { - npc.velocity.Y = npc.velocity.Y + num2; + npc.velocity.Y = npc.velocity.Y + acceleration; } } - else if (npc.velocity.Y > num5) + else if (npc.velocity.Y > targetYDist) { - npc.velocity.Y = npc.velocity.Y - num2; - if (npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.Corruptor && npc.type != NPCID.Probe && npc.type != NPCID.BloodSquid && npc.velocity.Y > 0f && num5 < 0f) + npc.velocity.Y = npc.velocity.Y - acceleration; + if (npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.Corruptor && npc.type != NPCID.Probe && npc.type != NPCID.BloodSquid && npc.velocity.Y > 0f && targetYDist < 0f) { - npc.velocity.Y = npc.velocity.Y - num2; + npc.velocity.Y = npc.velocity.Y - acceleration; } } if (npc.type == NPCID.MeteorHead) { - if (num4 > 0f) + if (targetXDist > 0f) { npc.spriteDirection = 1; - npc.rotation = (float)Math.Atan2((double)num5, (double)num4); + npc.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist); } - else if (num4 < 0f) + else if (targetXDist < 0f) { npc.spriteDirection = -1; - npc.rotation = (float)Math.Atan2((double)num5, (double)num4) + MathHelper.Pi; + npc.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist) + MathHelper.Pi; } } else if (npc.type == NPCID.Probe) @@ -3786,33 +3781,33 @@ namespace CalamityMod.NPCs npc.localAI[0] = 0f; if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { - int num8 = 22; - int num9 = 84; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector.X, vector.Y, num4, num5, num9, num8, 0f, Main.myPlayer, 0f, 0f); + int projDamage = 22; + int projType = 84; + Projectile.NewProjectile(npc.GetSource_FromAI(), vector.X, vector.Y, targetXDist, targetYDist, projType, projDamage, 0f, Main.myPlayer, 0f, 0f); } } - int arg_A81_0 = (int)npc.position.X + npc.width / 2; - int num10 = (int)npc.position.Y + npc.height / 2; - int arg_A8B_0 = arg_A81_0 / 16; - num10 /= 16; - if (!WorldGen.SolidTile(arg_A8B_0, num10)) + int npcXPos = (int)npc.position.X + npc.width / 2; + int npcTileY = (int)npc.position.Y + npc.height / 2; + int npcTileX = npcXPos / 16; + npcTileY /= 16; + if (!WorldGen.SolidTile(npcTileX, npcTileY)) { Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.3f, 0.1f, 0.05f); } - if (num4 > 0f) + if (targetXDist > 0f) { npc.spriteDirection = 1; - npc.rotation = (float)Math.Atan2((double)num5, (double)num4); + npc.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist); } - if (num4 < 0f) + if (targetXDist < 0f) { npc.spriteDirection = -1; - npc.rotation = (float)Math.Atan2((double)num5, (double)num4) + MathHelper.Pi; + npc.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist) + MathHelper.Pi; } } else if (npc.type == NPCID.EaterofSouls || npc.type == NPCID.Corruptor || npc.type == NPCID.Crimera || npc.type == NPCID.BloodSquid) { - npc.rotation = (float)Math.Atan2((double)num5, (double)num4) - MathHelper.PiOver2; + npc.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist) - MathHelper.PiOver2; } else if (npc.type == NPCID.Moth || npc.type == NPCID.Hornet || npc.type == NPCID.MossHornet || (npc.type >= NPCID.HornetFatty && npc.type <= NPCID.HornetStingy)) { @@ -3832,15 +3827,15 @@ namespace CalamityMod.NPCs } if (npc.type == NPCID.Hornet || npc.type == NPCID.MossHornet || (npc.type >= NPCID.HornetFatty && npc.type <= NPCID.HornetStingy) || npc.type == NPCID.EaterofSouls || npc.type == NPCID.MeteorHead || npc.type == NPCID.Corruptor || npc.type == NPCID.Probe || npc.type == NPCID.Crimera || npc.type == NPCID.Moth || npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall || npc.type == NPCID.BloodSquid) { - float num11 = 0.7f; + float reboundSpeed = 0.7f; if (npc.type == NPCID.EaterofSouls || npc.type == NPCID.Crimera) { - num11 = 0.4f; + reboundSpeed = 0.4f; } if (npc.collideX) { npc.netUpdate = true; - npc.velocity.X = npc.oldVelocity.X * -num11; + npc.velocity.X = npc.oldVelocity.X * -reboundSpeed; if (npc.direction == -1 && npc.velocity.X > 0f && npc.velocity.X < 2f) { npc.velocity.X = 2f; @@ -3853,7 +3848,7 @@ namespace CalamityMod.NPCs if (npc.collideY) { npc.netUpdate = true; - npc.velocity.Y = npc.oldVelocity.Y * -num11; + npc.velocity.Y = npc.oldVelocity.Y * -reboundSpeed; if (npc.velocity.Y > 0f && (double)npc.velocity.Y < 1.5) { npc.velocity.Y = 2f; @@ -3865,34 +3860,34 @@ namespace CalamityMod.NPCs } if (npc.type == NPCID.BloodSquid) { - int num13 = Dust.NewDust(npc.position, npc.width, npc.height, 5, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100); - Main.dust[num13].velocity *= 0.5f; + int bloodDust = Dust.NewDust(npc.position, npc.width, npc.height, 5, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100); + Main.dust[bloodDust].velocity *= 0.5f; } else if (npc.type == NPCID.MeteorHead) { - int num12 = Dust.NewDust(new Vector2(npc.position.X - npc.velocity.X, npc.position.Y - npc.velocity.Y), npc.width, npc.height, 6, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 2f); - Dust dust = Main.dust[num12]; + int meteorDust = Dust.NewDust(new Vector2(npc.position.X - npc.velocity.X, npc.position.Y - npc.velocity.Y), npc.width, npc.height, 6, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 2f); + Dust dust = Main.dust[meteorDust]; dust.noGravity = true; dust.velocity.X *= 0.3f; dust.velocity.Y *= 0.3f; } else if (npc.type != NPCID.Probe && npc.type != NPCID.Moth && npc.type != NPCID.Parrot && npc.type != NPCID.Bee && npc.type != NPCID.BeeSmall && Main.rand.NextBool(20)) { - int num13 = 18; + int dustType = 18; if (npc.type == NPCID.Crimera) { - num13 = 5; + dustType = 5; } - int num14 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + (float)npc.height * 0.25f), npc.width, (int)((float)npc.height * 0.5f), num13, npc.velocity.X, 2f, 75, npc.color, npc.scale); - Dust dust = Main.dust[num14]; + int idleDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + (float)npc.height * 0.25f), npc.width, (int)((float)npc.height * 0.5f), dustType, npc.velocity.X, 2f, 75, npc.color, npc.scale); + Dust dust = Main.dust[idleDust]; dust.velocity.X *= 0.5f; dust.velocity.Y *= 0.1f; } } else if (npc.type != NPCID.Parrot && Main.rand.NextBool(40)) { - int num15 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + (float)npc.height * 0.25f), npc.width, (int)((float)npc.height * 0.5f), 5, npc.velocity.X, 2f, 0, default(Color), 1f); - Dust dust = Main.dust[num15]; + int otherIdleDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + (float)npc.height * 0.25f), npc.width, (int)((float)npc.height * 0.5f), 5, npc.velocity.X, 2f, 0, default(Color), 1f); + Dust dust = Main.dust[otherIdleDust]; dust.velocity.X *= 0.5f; dust.velocity.Y *= 0.1f; } @@ -3949,24 +3944,24 @@ namespace CalamityMod.NPCs { if (targetData.Type != 0 && Collision.CanHit(npc, targetData)) { - float num17 = (CalamityWorld.death || Main.hardMode) ? 5f : 8f; - Vector2 vector2 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height / 2); - float num18 = targetData.Center.X - vector2.X; - float num19 = targetData.Center.Y - vector2.Y; - if ((num18 < 0f && npc.velocity.X < 0f) || (num18 > 0f && npc.velocity.X > 0f)) + float projSpeed = (CalamityWorld.death || Main.hardMode) ? 5f : 8f; + Vector2 projSpawnPosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height / 2); + float projTargetXDist = targetData.Center.X - projSpawnPosition.X; + float projTargetYDist = targetData.Center.Y - projSpawnPosition.Y; + if ((projTargetXDist < 0f && npc.velocity.X < 0f) || (projTargetXDist > 0f && npc.velocity.X > 0f)) { - float num20 = (float)Math.Sqrt(num18 * num18 + num19 * num19); - num20 = num17 / num20; - num18 *= num20; - num19 *= num20; - int num21 = (int)(10f * npc.scale); + float projTargetDistance = (float)Math.Sqrt(projTargetXDist * projTargetXDist + projTargetYDist * projTargetYDist); + projTargetDistance = projSpeed / projTargetDistance; + projTargetXDist *= projTargetDistance; + projTargetYDist *= projTargetDistance; + int projDamage = (int)(10f * npc.scale); if (npc.type == NPCID.MossHornet) - num21 = (int)(30f * npc.scale); + projDamage = (int)(30f * npc.scale); - int num22 = ProjectileID.Stinger; - int num23 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector2.X, vector2.Y, num18, num19, num22, num21, 0f, Main.myPlayer); - Main.projectile[num23].timeLeft = (CalamityWorld.death || Main.hardMode) ? 600 : 300; - Main.projectile[num23].extraUpdates += (CalamityWorld.death || Main.hardMode) ? 1 : 0; + int stingerType = ProjectileID.Stinger; + int stingerSpawn = Projectile.NewProjectile(npc.GetSource_FromAI(), projSpawnPosition.X, projSpawnPosition.Y, projTargetXDist, projTargetYDist, stingerType, projDamage, 0f, Main.myPlayer); + Main.projectile[stingerSpawn].timeLeft = (CalamityWorld.death || Main.hardMode) ? 600 : 300; + Main.projectile[stingerSpawn].extraUpdates += (CalamityWorld.death || Main.hardMode) ? 1 : 0; npc.ai[1] = 301f; npc.netUpdate = true; } @@ -3981,7 +3976,7 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.Probe & flag) { - if ((npc.velocity.X > 0f && num4 > 0f) || (npc.velocity.X < 0f && num4 < 0f)) + if ((npc.velocity.X > 0f && targetXDist > 0f) || (npc.velocity.X < 0f && targetXDist < 0f)) { if (Math.Abs(npc.velocity.X) < 12f) npc.velocity.X = npc.velocity.X * 1.05f; @@ -4037,12 +4032,12 @@ namespace CalamityMod.NPCs { if ((npc.Center - targetData.Center).Length() < 400f) { - Vector2 vector3 = npc.DirectionTo(new Vector2(targetData.Center.X, targetData.Position.Y)); - npc.velocity = -vector3 * 5f; + Vector2 bloodShotPosition = npc.DirectionTo(new Vector2(targetData.Center.X, targetData.Position.Y)); + npc.velocity = -bloodShotPosition * 5f; npc.netUpdate = true; npc.localAI[0] = 0f; - vector3 = npc.DirectionTo(new Vector2(targetData.Center.X, targetData.Position.Y)); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, vector3 * (CalamityWorld.death ? 6f : 10f), ProjectileID.BloodShot, 50, 1f, Main.myPlayer); + bloodShotPosition = npc.DirectionTo(new Vector2(targetData.Center.X, targetData.Position.Y)); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, bloodShotPosition * (CalamityWorld.death ? 6f : 10f), ProjectileID.BloodShot, 50, 1f, Main.myPlayer); if (CalamityWorld.death) { Main.projectile[proj].extraUpdates += 1; @@ -4060,7 +4055,7 @@ namespace CalamityMod.NPCs if ((Main.dayTime && npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.MeteorHead && npc.type != NPCID.Bee && npc.type != NPCID.BeeSmall && npc.type != NPCID.Corruptor && npc.type != NPCID.Moth && npc.type != NPCID.Parrot && npc.type != NPCID.BloodSquid) || Main.player[npc.target].dead) { - npc.velocity.Y = npc.velocity.Y - num2 * 2f; + npc.velocity.Y = npc.velocity.Y - acceleration * 2f; if (npc.timeLeft > 10) npc.timeLeft = 10; } @@ -4079,14 +4074,14 @@ namespace CalamityMod.NPCs { npc.localAI[1] = 1f; SoundEngine.PlaySound(SoundID.NPCDeath13, npc.position); - int num = 1; + int dustVelocity = 1; if (npc.velocity.X < 0f) { - num = -1; + dustVelocity = -1; } for (int i = 0; i < 20; i++) { - Dust.NewDust(new Vector2(npc.position.X - 20f, npc.position.Y - 20f), npc.width + 40, npc.height + 40, 5, (float)(num * 8), -1f, 0, default(Color), 1f); + Dust.NewDust(new Vector2(npc.position.X - 20f, npc.position.Y - 20f), npc.width + 40, npc.height + 40, 5, (float)(dustVelocity * 8), -1f, 0, default(Color), 1f); } } @@ -4120,8 +4115,8 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } - bool flag = npc.type == NPCID.GiantWormHead || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.DiggerHead || npc.type == NPCID.LeechHead || npc.type == NPCID.DuneSplicerHead || (!Main.player[npc.target].ZoneUndergroundDesert && npc.type == NPCID.TombCrawlerHead); - float num4 = npc.type == NPCID.TombCrawlerHead ? 0.1f : 0.2f; + bool wormHead = npc.type == NPCID.GiantWormHead || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.DiggerHead || npc.type == NPCID.LeechHead || npc.type == NPCID.DuneSplicerHead || (!Main.player[npc.target].ZoneUndergroundDesert && npc.type == NPCID.TombCrawlerHead); + float acceleration = npc.type == NPCID.TombCrawlerHead ? 0.1f : 0.2f; bool isSplittingNPC = (npc.type >= NPCID.DiggerHead && npc.type <= NPCID.DiggerTail) || (npc.type >= NPCID.SeekerHead && npc.type <= NPCID.SeekerTail) || (npc.type >= NPCID.DuneSplicerHead && npc.type <= NPCID.DuneSplicerTail); @@ -4143,20 +4138,20 @@ namespace CalamityMod.NPCs npc.realLife = (int)npc.ai[3]; } - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || (flag && (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0)) + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || (wormHead && (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0)) { npc.TargetClosest(true); } - if (Main.player[npc.target].dead || (flag && (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0)) + if (Main.player[npc.target].dead || (wormHead && (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0)) { if (npc.timeLeft > 300) { npc.timeLeft = 300; } - if (flag) + if (wormHead) { - npc.velocity.Y = npc.velocity.Y + num4; + npc.velocity.Y = npc.velocity.Y + acceleration; } } @@ -4173,33 +4168,33 @@ namespace CalamityMod.NPCs int maxParts = CalamityWorld.death ? 30 : 21; npc.ai[3] = (float)npc.whoAmI; npc.realLife = npc.whoAmI; - int num6 = npc.whoAmI; + int currentNPC = npc.whoAmI; for (int k = 0; k < maxParts; k++) { - int num7 = NPCID.WyvernBody; + int wyvernSegmentType = NPCID.WyvernBody; if (k == 1 || k == 12) { - num7 = NPCID.WyvernLegs; + wyvernSegmentType = NPCID.WyvernLegs; } else if (k == maxParts - 3) { - num7 = NPCID.WyvernBody2; + wyvernSegmentType = NPCID.WyvernBody2; } else if (k == maxParts - 2) { - num7 = NPCID.WyvernBody3; + wyvernSegmentType = NPCID.WyvernBody3; } else if (k == maxParts - 1) { - num7 = NPCID.WyvernTail; + wyvernSegmentType = NPCID.WyvernTail; } - int num8 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), num7, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num8].ai[3] = (float)npc.whoAmI; - Main.npc[num8].realLife = npc.whoAmI; - Main.npc[num8].ai[1] = (float)num6; - Main.npc[num6].ai[0] = (float)num8; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num8, 0f, 0f, 0f, 0, 0, 0); - num6 = num8; + int wyvernSegment = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), wyvernSegmentType, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[wyvernSegment].ai[3] = (float)npc.whoAmI; + Main.npc[wyvernSegment].realLife = npc.whoAmI; + Main.npc[wyvernSegment].ai[1] = (float)currentNPC; + Main.npc[currentNPC].ai[0] = (float)wyvernSegment; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, wyvernSegment, 0f, 0f, 0f, 0, 0, 0); + currentNPC = wyvernSegment; } } @@ -4207,22 +4202,22 @@ namespace CalamityMod.NPCs { npc.ai[3] = (float)npc.whoAmI; npc.realLife = npc.whoAmI; - int num12 = npc.whoAmI; - int num13 = Main.rand.Next(11, CalamityWorld.death ? 25 : 15); - for (int m = 0; m < num13; m++) + int currentTombCrawler = npc.whoAmI; + int tombCrawlerSegments = Main.rand.Next(11, CalamityWorld.death ? 25 : 15); + for (int m = 0; m < tombCrawlerSegments; m++) { - int num14 = NPCID.TombCrawlerBody; - if (m == num13 - 1) + int tombCrawlerSegmentType = NPCID.TombCrawlerBody; + if (m == tombCrawlerSegments - 1) { - num14 = NPCID.TombCrawlerTail; + tombCrawlerSegmentType = NPCID.TombCrawlerTail; } - int num15 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), num14, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num15].ai[3] = (float)npc.whoAmI; - Main.npc[num15].realLife = npc.whoAmI; - Main.npc[num15].ai[1] = (float)num12; - Main.npc[num12].ai[0] = (float)num15; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num15, 0f, 0f, 0f, 0, 0, 0); - num12 = num15; + int tombCrawlerSegment = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), tombCrawlerSegmentType, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[tombCrawlerSegment].ai[3] = (float)npc.whoAmI; + Main.npc[tombCrawlerSegment].realLife = npc.whoAmI; + Main.npc[tombCrawlerSegment].ai[1] = (float)currentTombCrawler; + Main.npc[currentTombCrawler].ai[0] = (float)tombCrawlerSegment; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, tombCrawlerSegment, 0f, 0f, 0f, 0, 0, 0); + currentTombCrawler = tombCrawlerSegment; } } @@ -4230,22 +4225,22 @@ namespace CalamityMod.NPCs { npc.ai[3] = (float)npc.whoAmI; npc.realLife = npc.whoAmI; - int num20 = npc.whoAmI; - int num21 = CalamityWorld.death ? 70 : 50; - for (int num22 = 0; num22 < num21; num22++) + int projTargetDistance = npc.whoAmI; + int crawltipedeSegments = CalamityWorld.death ? 70 : 50; + for (int n = 0; n < crawltipedeSegments; n++) { - int num23 = NPCID.SolarCrawltipedeBody; - if (num22 == num21 - 1) + int crawltipedeSegmentType = NPCID.SolarCrawltipedeBody; + if (n == crawltipedeSegments - 1) { - num23 = NPCID.SolarCrawltipedeTail; + crawltipedeSegmentType = NPCID.SolarCrawltipedeTail; } - int num24 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), num23, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num24].ai[3] = (float)npc.whoAmI; - Main.npc[num24].realLife = npc.whoAmI; - Main.npc[num24].ai[1] = (float)num20; - Main.npc[num20].ai[0] = (float)num24; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num24, 0f, 0f, 0f, 0, 0, 0); - num20 = num24; + int crawltipedeSegment = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), crawltipedeSegmentType, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[crawltipedeSegment].ai[3] = (float)npc.whoAmI; + Main.npc[crawltipedeSegment].realLife = npc.whoAmI; + Main.npc[crawltipedeSegment].ai[1] = (float)projTargetDistance; + Main.npc[projTargetDistance].ai[0] = (float)crawltipedeSegment; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, crawltipedeSegment, 0f, 0f, 0f, 0, 0, 0); + projTargetDistance = crawltipedeSegment; } } @@ -4253,23 +4248,23 @@ namespace CalamityMod.NPCs { npc.ai[3] = npc.whoAmI; npc.realLife = npc.whoAmI; - int num22 = 0; - int num23 = npc.whoAmI; - int num24 = CalamityWorld.death ? 44 : 34; - for (int num25 = 0; num25 < num24; num25++) + int bloodEelSegment = 0; + int currentBloodEel = npc.whoAmI; + int bloodEelSegments = CalamityWorld.death ? 44 : 34; + for (int p = 0; p < bloodEelSegments; p++) { - int num26 = NPCID.BloodEelBody; - if (num25 == num24 - 1) - num26 = NPCID.BloodEelTail; + int bloodEelSegmentType = NPCID.BloodEelBody; + if (p == bloodEelSegments - 1) + bloodEelSegmentType = NPCID.BloodEelTail; - num22 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), num26, npc.whoAmI); - Main.npc[num22].ai[3] = npc.whoAmI; - Main.npc[num22].realLife = npc.whoAmI; - Main.npc[num22].ai[1] = num23; - Main.npc[num22].CopyInteractions(npc); - Main.npc[num23].ai[0] = num22; - NetMessage.SendData(23, -1, -1, null, num22); - num23 = num22; + bloodEelSegment = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), bloodEelSegmentType, npc.whoAmI); + Main.npc[bloodEelSegment].ai[3] = npc.whoAmI; + Main.npc[bloodEelSegment].realLife = npc.whoAmI; + Main.npc[bloodEelSegment].ai[1] = currentBloodEel; + Main.npc[bloodEelSegment].CopyInteractions(npc); + Main.npc[currentBloodEel].ai[0] = bloodEelSegment; + NetMessage.SendData(23, -1, -1, null, bloodEelSegment); + currentBloodEel = bloodEelSegment; } } else if ((isSplittingNPCHead || isSplittingNPCBody || npc.type == NPCID.GiantWormHead || npc.type == NPCID.GiantWormBody || npc.type == NPCID.DevourerHead || npc.type == NPCID.DevourerBody || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.BoneSerpentBody || npc.type == NPCID.LeechHead || npc.type == NPCID.LeechBody) && npc.ai[0] == 0f) @@ -4381,11 +4376,11 @@ namespace CalamityMod.NPCs { npc.type = npc.type - 1; int whoAmI = npc.whoAmI; - float num25 = (float)npc.life / (float)npc.lifeMax; - float num26 = npc.ai[0]; + float currentHealthAmt = (float)npc.life / (float)npc.lifeMax; + float newSegment = npc.ai[0]; npc.SetDefaultsKeepPlayerInteraction(npc.type); - npc.life = (int)((float)npc.lifeMax * num25); - npc.ai[0] = num26; + npc.life = (int)((float)npc.lifeMax * currentHealthAmt); + npc.ai[0] = newSegment; npc.TargetClosest(true); npc.netUpdate = true; npc.whoAmI = whoAmI; @@ -4393,11 +4388,11 @@ namespace CalamityMod.NPCs if (isSplittingNPCBody && (!Main.npc[(int)npc.ai[0]].active || Main.npc[(int)npc.ai[0]].aiStyle != npc.aiStyle)) { int whoAmI2 = npc.whoAmI; - float num27 = (float)npc.life / (float)npc.lifeMax; - float num28 = npc.ai[1]; + float currentHealthAmt2 = (float)npc.life / (float)npc.lifeMax; + float newSegment = npc.ai[1]; npc.SetDefaultsKeepPlayerInteraction(npc.type); - npc.life = (int)((float)npc.lifeMax * num27); - npc.ai[1] = num28; + npc.life = (int)((float)npc.lifeMax * currentHealthAmt2); + npc.ai[1] = newSegment; npc.TargetClosest(true); npc.netUpdate = true; npc.whoAmI = whoAmI2; @@ -4410,61 +4405,61 @@ namespace CalamityMod.NPCs } } - int num29 = (int)(npc.position.X / 16f) - 1; - int num30 = (int)((npc.position.X + (float)npc.width) / 16f) + 2; - int num31 = (int)(npc.position.Y / 16f) - 1; - int num32 = (int)((npc.position.Y + (float)npc.height) / 16f) + 2; - if (num29 < 0) + int tilePositionX = (int)(npc.position.X / 16f) - 1; + int tileWidthPosX = (int)((npc.position.X + (float)npc.width) / 16f) + 2; + int tilePositionY = (int)(npc.position.Y / 16f) - 1; + int tileWidthPosY = (int)((npc.position.Y + (float)npc.height) / 16f) + 2; + if (tilePositionX < 0) { - num29 = 0; + tilePositionX = 0; } - if (num30 > Main.maxTilesX) + if (tileWidthPosX > Main.maxTilesX) { - num30 = Main.maxTilesX; + tileWidthPosX = Main.maxTilesX; } - if (num31 < 0) + if (tilePositionY < 0) { - num31 = 0; + tilePositionY = 0; } - if (num32 > Main.maxTilesY) + if (tileWidthPosY > Main.maxTilesY) { - num32 = Main.maxTilesY; + tileWidthPosY = Main.maxTilesY; } - bool flag2 = false; + bool flying = false; if (npc.type >= NPCID.WyvernHead && npc.type <= NPCID.WyvernTail) { - flag2 = true; + flying = true; } if (npc.type == NPCID.StardustWormHead && npc.ai[1] == -1f) { - flag2 = true; + flying = true; } if (npc.type >= NPCID.SolarCrawltipedeHead && npc.type <= NPCID.SolarCrawltipedeTail) { - flag2 = true; + flying = true; } if (npc.type >= NPCID.BloodEelHead && npc.type <= NPCID.BloodEelTail) { - flag2 = true; + flying = true; } - if (!flag2) + if (!flying) { - for (int num33 = num29; num33 < num30; num33++) + for (int x = tilePositionX; x < tileWidthPosX; x++) { - for (int num34 = num31; num34 < num32; num34++) + for (int y = tilePositionY; y < tileWidthPosY; y++) { - if (Main.tile[num33, num34] != null && ((Main.tile[num33, num34].HasUnactuatedTile && (Main.tileSolid[(int)Main.tile[num33, num34].TileType] || (Main.tileSolidTop[(int)Main.tile[num33, num34].TileType] && Main.tile[num33, num34].TileFrameY == 0))) || Main.tile[num33, num34].LiquidAmount > 64)) + if (Main.tile[x, y] != null && ((Main.tile[x, y].HasUnactuatedTile && (Main.tileSolid[(int)Main.tile[x, y].TileType] || (Main.tileSolidTop[(int)Main.tile[x, y].TileType] && Main.tile[x, y].TileFrameY == 0))) || Main.tile[x, y].LiquidAmount > 64)) { - Vector2 vector; - vector.X = (float)(num33 * 16); - vector.Y = (float)(num34 * 16); - if (npc.position.X + (float)npc.width > vector.X && npc.position.X < vector.X + 16f && npc.position.Y + (float)npc.height > vector.Y && npc.position.Y < vector.Y + 16f) + Vector2 flyingPos; + flyingPos.X = (float)(x * 16); + flyingPos.Y = (float)(y * 16); + if (npc.position.X + (float)npc.width > flyingPos.X && npc.position.X < flyingPos.X + 16f && npc.position.Y + (float)npc.height > flyingPos.Y && npc.position.Y < flyingPos.Y + 16f) { - flag2 = true; - if (Main.rand.NextBool(100) && npc.type != NPCID.LeechHead && Main.tile[num33, num34].HasUnactuatedTile) + flying = true; + if (Main.rand.NextBool(100) && npc.type != NPCID.LeechHead && Main.tile[x, y].HasUnactuatedTile) { - WorldGen.KillTile(num33, num34, true, true, false); + WorldGen.KillTile(x, y, true, true, false); } } } @@ -4472,26 +4467,26 @@ namespace CalamityMod.NPCs } } - if (!flag2 && (isSplittingNPCHead || npc.type == NPCID.GiantWormHead || npc.type == NPCID.DevourerHead || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.LeechHead || npc.type == NPCID.TombCrawlerHead)) + if (!flying && (isSplittingNPCHead || npc.type == NPCID.GiantWormHead || npc.type == NPCID.DevourerHead || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.LeechHead || npc.type == NPCID.TombCrawlerHead)) { Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - int num35 = 1000; - bool flag3 = true; - for (int num36 = 0; num36 < Main.maxPlayers; num36++) + int noFlyZone = 1000; + bool outsideNoFlyZone = true; + for (int f = 0; f < Main.maxPlayers; f++) { - if (Main.player[num36].active) + if (Main.player[f].active) { - Rectangle rectangle2 = new Rectangle((int)Main.player[num36].position.X - num35, (int)Main.player[num36].position.Y - num35, num35 * 2, num35 * 2); + Rectangle rectangle2 = new Rectangle((int)Main.player[f].position.X - noFlyZone, (int)Main.player[f].position.Y - noFlyZone, noFlyZone * 2, noFlyZone * 2); if (rectangle.Intersects(rectangle2)) { - flag3 = false; + outsideNoFlyZone = false; break; } } } - if (flag3) + if (outsideNoFlyZone) { - flag2 = true; + flying = true; } } @@ -4534,242 +4529,242 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.SolarCrawltipedeHead) { - Vector2 value = npc.Center + (npc.rotation - MathHelper.PiOver2).ToRotationVector2() * 8f; - Vector2 value2 = npc.rotation.ToRotationVector2() * 16f; - Dust expr_1AAB = Main.dust[Dust.NewDust(value + value2, 0, 0, 6, npc.velocity.X, npc.velocity.Y, 100, Color.Transparent, 1f + Main.rand.NextFloat() * 3f)]; - expr_1AAB.noGravity = true; - expr_1AAB.noLight = true; - expr_1AAB.position -= new Vector2(4f); - expr_1AAB.fadeIn = 1f; - expr_1AAB.velocity = Vector2.Zero; - Dust expr_1B33 = Main.dust[Dust.NewDust(value - value2, 0, 0, 6, npc.velocity.X, npc.velocity.Y, 100, Color.Transparent, 1f + Main.rand.NextFloat() * 3f)]; - expr_1B33.noGravity = true; - expr_1B33.noLight = true; - expr_1B33.position -= new Vector2(4f); - expr_1B33.fadeIn = 1f; - expr_1B33.velocity = Vector2.Zero; + Vector2 crawltipedeDustPos = npc.Center + (npc.rotation - MathHelper.PiOver2).ToRotationVector2() * 8f; + Vector2 crawltipedeDustRotation = npc.rotation.ToRotationVector2() * 16f; + Dust crawltipedeDust = Main.dust[Dust.NewDust(crawltipedeDustPos + crawltipedeDustRotation, 0, 0, 6, npc.velocity.X, npc.velocity.Y, 100, Color.Transparent, 1f + Main.rand.NextFloat() * 3f)]; + crawltipedeDust.noGravity = true; + crawltipedeDust.noLight = true; + crawltipedeDust.position -= new Vector2(4f); + crawltipedeDust.fadeIn = 1f; + crawltipedeDust.velocity = Vector2.Zero; + Dust crawltipedeDust2 = Main.dust[Dust.NewDust(crawltipedeDustPos - crawltipedeDustRotation, 0, 0, 6, npc.velocity.X, npc.velocity.Y, 100, Color.Transparent, 1f + Main.rand.NextFloat() * 3f)]; + crawltipedeDust2.noGravity = true; + crawltipedeDust2.noLight = true; + crawltipedeDust2.position -= new Vector2(4f); + crawltipedeDust2.fadeIn = 1f; + crawltipedeDust2.velocity = Vector2.Zero; } - float num37 = 10f; - float num38 = 0.09f; + float wormSpeed = 10f; + float wormAccel = 0.09f; if (npc.type == NPCID.DiggerHead) { - num37 = 6.5f; - num38 = 0.05f; + wormSpeed = 6.5f; + wormAccel = 0.05f; } if (npc.type == NPCID.GiantWormHead) { - num37 = 7.5f; - num38 = 0.06f; + wormSpeed = 7.5f; + wormAccel = 0.06f; } if (npc.type == NPCID.TombCrawlerHead) { - num37 = 8f; - num38 = 0.13f; + wormSpeed = 8f; + wormAccel = 0.13f; } if (npc.type == NPCID.DuneSplicerHead) { if (!Main.player[npc.target].dead && Main.player[npc.target].ZoneSandstorm) { - num37 = 16f; - num38 = 0.35f; + wormSpeed = 16f; + wormAccel = 0.35f; } else { - num38 = 0.25f; + wormAccel = 0.25f; } } if (npc.type == NPCID.WyvernHead) { - num37 = 11f; - num38 = 0.3f; + wormSpeed = 11f; + wormAccel = 0.3f; } if (npc.type == NPCID.StardustWormHead) { - num37 = 9f; - num38 = 0.25f; + wormSpeed = 9f; + wormAccel = 0.25f; } if (npc.type == NPCID.LeechHead && Main.wofNPCIndex >= 0) { float lifeRatio = (float)Main.npc[Main.wofNPCIndex].life / (float)Main.npc[Main.wofNPCIndex].lifeMax; if (lifeRatio < 0.75f) { - num37 += 1f; - num38 += 0.1f; + wormSpeed += 1f; + wormAccel += 0.1f; } if (lifeRatio < 0.5f) { - num37 += 1f; - num38 += 0.1f; + wormSpeed += 1f; + wormAccel += 0.1f; } if (lifeRatio < 0.25f) { - num37 += 2f; - num38 += 0.1f; + wormSpeed += 2f; + wormAccel += 0.1f; } } if (npc.type == NPCID.BloodEelHead) { - num37 = 18f; - num38 = 0.6f; + wormSpeed = 18f; + wormAccel = 0.6f; } if (CalamityWorld.death) { - num37 *= 1.25f; - num38 *= 1.25f; + wormSpeed *= 1.25f; + wormAccel *= 1.25f; } - Vector2 vector2 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num39 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num40 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); + Vector2 segmentPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float wormTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); + float wormTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); if (npc.type == NPCID.SolarCrawltipedeHead) { - num37 = 12f; - num38 = 0.32f; - int num41 = -1; - int num42 = (int)(Main.player[npc.target].Center.X / 16f); - int num43 = (int)(Main.player[npc.target].Center.Y / 16f); - for (int num44 = num42 - 2; num44 <= num42 + 2; num44++) + wormSpeed = 12f; + wormAccel = 0.32f; + int crawltipedeTargetY = -1; + int targetTileX = (int)(Main.player[npc.target].Center.X / 16f); + int targetTileY = (int)(Main.player[npc.target].Center.Y / 16f); + for (int i = targetTileX - 2; i <= targetTileX + 2; i++) { - for (int num45 = num43; num45 <= num43 + 15; num45++) + for (int j = targetTileY; j <= targetTileY + 15; j++) { - if (WorldGen.SolidTile2(num44, num45)) + if (WorldGen.SolidTile2(i, j)) { - num41 = num45; + crawltipedeTargetY = j; break; } } - if (num41 > 0) + if (crawltipedeTargetY > 0) { break; } } - if (num41 > 0) + if (crawltipedeTargetY > 0) { - num41 *= 16; - float num46 = (float)(num41 - 800); - if (Main.player[npc.target].position.Y > num46) + crawltipedeTargetY *= 16; + float crawltipedeYTarget = (float)(crawltipedeTargetY - 800); + if (Main.player[npc.target].position.Y > crawltipedeYTarget) { - num40 = num46; + wormTargetY = crawltipedeYTarget; if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 500f) { if (npc.velocity.X > 0f) { - num39 = Main.player[npc.target].Center.X + 600f; + wormTargetX = Main.player[npc.target].Center.X + 600f; } else { - num39 = Main.player[npc.target].Center.X - 600f; + wormTargetX = Main.player[npc.target].Center.X - 600f; } } } } else { - num37 = 28f; - num38 = 0.8f; + wormSpeed = 28f; + wormAccel = 0.8f; } - float num47 = num37 * 1.3f; - float num48 = num37 * 0.7f; - float num49 = npc.velocity.Length(); - if (num49 > 0f) + float maxWormSpeed = wormSpeed * 1.3f; + float minWormSpeed = wormSpeed * 0.7f; + float velocityCheck = npc.velocity.Length(); + if (velocityCheck > 0f) { - if (num49 > num47) + if (velocityCheck > maxWormSpeed) { npc.velocity.Normalize(); - npc.velocity *= num47; + npc.velocity *= maxWormSpeed; } - else if (num49 < num48) + else if (velocityCheck < minWormSpeed) { npc.velocity.Normalize(); - npc.velocity *= num48; + npc.velocity *= minWormSpeed; } } - if (num41 > 0) + if (crawltipedeTargetY > 0) { - for (int num50 = 0; num50 < Main.maxNPCs; num50++) + for (int k = 0; k < Main.maxNPCs; k++) { - if (Main.npc[num50].active && Main.npc[num50].type == npc.type && num50 != npc.whoAmI) + if (Main.npc[k].active && Main.npc[k].type == npc.type && k != npc.whoAmI) { - Vector2 vector3 = Main.npc[num50].Center - npc.Center; - if (vector3.Length() < 400f) + Vector2 targetDirection = Main.npc[k].Center - npc.Center; + if (targetDirection.Length() < 400f) { - vector3.Normalize(); - vector3 *= 1000f; - num39 -= vector3.X; - num40 -= vector3.Y; + targetDirection.Normalize(); + targetDirection *= 1000f; + wormTargetX -= targetDirection.X; + wormTargetY -= targetDirection.Y; } } } } else { - for (int num51 = 0; num51 < Main.maxNPCs; num51++) + for (int l = 0; l < Main.maxNPCs; l++) { - if (Main.npc[num51].active && Main.npc[num51].type == npc.type && num51 != npc.whoAmI) + if (Main.npc[l].active && Main.npc[l].type == npc.type && l != npc.whoAmI) { - Vector2 vector4 = Main.npc[num51].Center - npc.Center; - if (vector4.Length() < 60f) + Vector2 idleDirection = Main.npc[l].Center - npc.Center; + if (idleDirection.Length() < 60f) { - vector4.Normalize(); - vector4 *= 200f; - num39 -= vector4.X; - num40 -= vector4.Y; + idleDirection.Normalize(); + idleDirection *= 200f; + wormTargetX -= idleDirection.X; + wormTargetY -= idleDirection.Y; } } } } } - num39 = (float)((int)(num39 / 16f) * 16); - num40 = (float)((int)(num40 / 16f) * 16); - vector2.X = (float)((int)(vector2.X / 16f) * 16); - vector2.Y = (float)((int)(vector2.Y / 16f) * 16); - num39 -= vector2.X; - num40 -= vector2.Y; - float num52 = (float)Math.Sqrt((double)(num39 * num39 + num40 * num40)); + wormTargetX = (float)((int)(wormTargetX / 16f) * 16); + wormTargetY = (float)((int)(wormTargetY / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + wormTargetX -= segmentPosition.X; + wormTargetY -= segmentPosition.Y; + float wormTargetDist = (float)Math.Sqrt((double)(wormTargetX * wormTargetX + wormTargetY * wormTargetY)); if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) { try { - vector2 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num39 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector2.X; - num40 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector2.Y; + segmentPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + wormTargetX = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - segmentPosition.X; + wormTargetY = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - segmentPosition.Y; } catch { } - npc.rotation = (float)Math.Atan2((double)num40, (double)num39) + MathHelper.PiOver2; - num52 = (float)Math.Sqrt((double)(num39 * num39 + num40 * num40)); - int num53 = npc.width; + npc.rotation = (float)Math.Atan2((double)wormTargetY, (double)wormTargetX) + MathHelper.PiOver2; + wormTargetDist = (float)Math.Sqrt((double)(wormTargetX * wormTargetX + wormTargetY * wormTargetY)); + int segmentWidth = npc.width; if (npc.type >= NPCID.WyvernHead && npc.type <= NPCID.WyvernTail) { - num53 = 42; + segmentWidth = 42; } if (npc.type >= NPCID.SolarCrawltipedeHead && npc.type <= NPCID.SolarCrawltipedeTail) { - num53 += 6; + segmentWidth += 6; } if (npc.type >= NPCID.BloodEelHead && npc.type <= NPCID.BloodEelTail) { - num53 = 24; + segmentWidth = 24; } - num52 = (num52 - (float)num53) / num52; - num39 *= num52; - num40 *= num52; + wormTargetDist = (wormTargetDist - (float)segmentWidth) / wormTargetDist; + wormTargetX *= wormTargetDist; + wormTargetY *= wormTargetDist; npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num39; - npc.position.Y = npc.position.Y + num40; + npc.position.X = npc.position.X + wormTargetX; + npc.position.Y = npc.position.Y + wormTargetY; if ((npc.type >= NPCID.WyvernHead && npc.type <= NPCID.WyvernTail) || (npc.type >= NPCID.BloodEelHead && npc.type <= NPCID.BloodEelTail)) { - if (num39 < 0f) + if (wormTargetX < 0f) { npc.spriteDirection = 1; } - else if (num39 > 0f) + else if (wormTargetX > 0f) { npc.spriteDirection = -1; } @@ -4777,45 +4772,45 @@ namespace CalamityMod.NPCs } else { - if (!flag2) + if (!flying) { npc.TargetClosest(true); npc.velocity.Y = npc.velocity.Y + 0.11f; - if (npc.velocity.Y > num37) + if (npc.velocity.Y > wormSpeed) { - npc.velocity.Y = num37; + npc.velocity.Y = wormSpeed; } - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num37 * 0.4) + if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)wormSpeed * 0.4) { if (npc.velocity.X < 0f) { - npc.velocity.X = npc.velocity.X - num38 * 1.1f; + npc.velocity.X = npc.velocity.X - wormAccel * 1.1f; } else { - npc.velocity.X = npc.velocity.X + num38 * 1.1f; + npc.velocity.X = npc.velocity.X + wormAccel * 1.1f; } } - else if (npc.velocity.Y == num37) + else if (npc.velocity.Y == wormSpeed) { - if (npc.velocity.X < num39) + if (npc.velocity.X < wormTargetX) { - npc.velocity.X = npc.velocity.X + num38; + npc.velocity.X = npc.velocity.X + wormAccel; } - else if (npc.velocity.X > num39) + else if (npc.velocity.X > wormTargetX) { - npc.velocity.X = npc.velocity.X - num38; + npc.velocity.X = npc.velocity.X - wormAccel; } } else if (npc.velocity.Y > 4f) { if (npc.velocity.X < 0f) { - npc.velocity.X = npc.velocity.X + num38 * 0.9f; + npc.velocity.X = npc.velocity.X + wormAccel * 0.9f; } else { - npc.velocity.X = npc.velocity.X - num38 * 0.9f; + npc.velocity.X = npc.velocity.X - wormAccel * 0.9f; } } } @@ -4823,184 +4818,183 @@ namespace CalamityMod.NPCs { if (npc.type != NPCID.WyvernHead && npc.type != NPCID.LeechHead && npc.type != NPCID.SolarCrawltipedeHead && npc.type != NPCID.BloodEelHead && npc.soundDelay == 0) { - float num54 = num52 / 40f; - if (num54 < 10f) + float soundDelay = wormTargetDist / 40f; + if (soundDelay < 10f) { - num54 = 10f; + soundDelay = 10f; } - if (num54 > 20f) + if (soundDelay > 20f) { - num54 = 20f; + soundDelay = 20f; } - npc.soundDelay = (int)num54; + npc.soundDelay = (int)soundDelay; SoundEngine.PlaySound(SoundID.WormDig, npc.position); } - num52 = (float)Math.Sqrt((double)(num39 * num39 + num40 * num40)); - float num55 = Math.Abs(num39); - float num56 = Math.Abs(num40); - float num57 = num37 / num52; - num39 *= num57; - num40 *= num57; + wormTargetDist = (float)Math.Sqrt((double)(wormTargetX * wormTargetX + wormTargetY * wormTargetY)); + float absoluteTargetX = Math.Abs(wormTargetX); + float absoluteTargetY = Math.Abs(wormTargetY); + float timeToReachTarget = wormSpeed / wormTargetDist; + wormTargetX *= timeToReachTarget; + wormTargetY *= timeToReachTarget; - bool flag4 = false; + bool wormShouldFlee = false; if (npc.type == NPCID.DevourerHead && ((!Main.player[npc.target].ZoneCorrupt && !Main.player[npc.target].ZoneCrimson) || Main.player[npc.target].dead)) { - flag4 = true; + wormShouldFlee = true; } if ((npc.type == NPCID.TombCrawlerHead && (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0 && !Main.player[npc.target].ZoneSandstorm && !Main.player[npc.target].ZoneUndergroundDesert) || Main.player[npc.target].dead) { - flag4 = true; + wormShouldFlee = true; } if ((npc.type == NPCID.DuneSplicerHead && (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0 && !Main.player[npc.target].ZoneSandstorm && !Main.player[npc.target].ZoneUndergroundDesert) || Main.player[npc.target].dead) { - flag4 = true; + wormShouldFlee = true; } - if (flag4) + if (wormShouldFlee) { - bool flag5 = true; - for (int num58 = 0; num58 < Main.maxPlayers; num58++) + bool definitelyFlee = true; + for (int p = 0; p < Main.maxPlayers; p++) { - if (Main.player[num58].active && !Main.player[num58].dead && Main.player[num58].ZoneCorrupt) + if (Main.player[p].active && !Main.player[p].dead && Main.player[p].ZoneCorrupt) { - flag5 = false; + definitelyFlee = false; } } - if (flag5) + if (definitelyFlee) { if (Main.netMode != NetmodeID.MultiplayerClient && (double)(npc.position.Y / 16f) > (Main.rockLayer + (double)Main.maxTilesY) / 2.0) { npc.active = false; - int num59 = (int)npc.ai[0]; - while (num59 > 0 && num59 < Main.maxNPCs && Main.npc[num59].active && Main.npc[num59].aiStyle == npc.aiStyle) + int q = (int)npc.ai[0]; + while (q > 0 && q < Main.maxNPCs && Main.npc[q].active && Main.npc[q].aiStyle == npc.aiStyle) { - int arg_2853_0 = (int)Main.npc[num59].ai[0]; - Main.npc[num59].active = false; + int differentSegment = (int)Main.npc[q].ai[0]; + Main.npc[q].active = false; npc.life = 0; if (Main.netMode == NetmodeID.Server) { - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num59, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, q, 0f, 0f, 0f, 0, 0, 0); } - num59 = arg_2853_0; + q = differentSegment; } if (Main.netMode == NetmodeID.Server) { NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI, 0f, 0f, 0f, 0, 0, 0); } } - num39 = 0f; - num40 = num37; + wormTargetX = 0f; + wormTargetY = wormSpeed; } } - bool flag6 = false; + bool shouldSwoopDown = false; if (npc.type == NPCID.WyvernHead) { - if (((npc.velocity.X > 0f && num39 < 0f) || (npc.velocity.X < 0f && num39 > 0f) || (npc.velocity.Y > 0f && num40 < 0f) || (npc.velocity.Y < 0f && num40 > 0f)) && Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) > num38 / 2f && num52 < 300f) + if (((npc.velocity.X > 0f && wormTargetX < 0f) || (npc.velocity.X < 0f && wormTargetX > 0f) || (npc.velocity.Y > 0f && wormTargetY < 0f) || (npc.velocity.Y < 0f && wormTargetY > 0f)) && Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) > wormAccel / 2f && wormTargetDist < 300f) { - flag6 = true; + shouldSwoopDown = true; - if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < num37) + if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < wormSpeed) npc.velocity *= 1.1f; } if (npc.position.Y > Main.player[npc.target].position.Y || (double)(Main.player[npc.target].position.Y / 16f) > Main.worldSurface || Main.player[npc.target].dead) { - flag6 = true; + shouldSwoopDown = true; - if (Math.Abs(npc.velocity.X) < num37 / 2f) + if (Math.Abs(npc.velocity.X) < wormSpeed / 2f) { if (npc.velocity.X == 0f) npc.velocity.X = npc.velocity.X - npc.direction; npc.velocity.X = npc.velocity.X * 1.1f; } - else if (npc.velocity.Y > -num37) - npc.velocity.Y = npc.velocity.Y - num38; + else if (npc.velocity.Y > -wormSpeed) + npc.velocity.Y = npc.velocity.Y - wormAccel; } } if (npc.type == NPCID.BloodEelHead) { - float num69 = 120f; - if (((npc.velocity.X > 0f && num39 < 0f) || (npc.velocity.X < 0f && num39 > 0f) || (npc.velocity.Y > 0f && num40 < 0f) || (npc.velocity.Y < 0f && num40 > 0f)) && Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) > num38 / 2f && num52 < num69) + if (((npc.velocity.X > 0f && wormTargetX < 0f) || (npc.velocity.X < 0f && wormTargetX > 0f) || (npc.velocity.Y > 0f && wormTargetY < 0f) || (npc.velocity.Y < 0f && wormTargetY > 0f)) && Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) > wormAccel / 2f && wormTargetDist < 120f) { - flag6 = true; - if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < num37) + shouldSwoopDown = true; + if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < wormSpeed) npc.velocity *= 1.1f; } if (npc.position.Y > Main.player[npc.target].position.Y || Main.player[npc.target].dead) { - flag6 = true; - if (Math.Abs(npc.velocity.X) < num37 / 2f) + shouldSwoopDown = true; + if (Math.Abs(npc.velocity.X) < wormSpeed / 2f) { if (npc.velocity.X == 0f) npc.velocity.X -= npc.direction; npc.velocity.X *= 1.1f; } - else if (npc.velocity.Y > 0f - num37) - npc.velocity.Y -= num38; + else if (npc.velocity.Y > 0f - wormSpeed) + npc.velocity.Y -= wormAccel; } } - if (!flag6) + if (!shouldSwoopDown) { - if ((npc.velocity.X > 0f && num39 > 0f) || (npc.velocity.X < 0f && num39 < 0f) || (npc.velocity.Y > 0f && num40 > 0f) || (npc.velocity.Y < 0f && num40 < 0f)) + if ((npc.velocity.X > 0f && wormTargetX > 0f) || (npc.velocity.X < 0f && wormTargetX < 0f) || (npc.velocity.Y > 0f && wormTargetY > 0f) || (npc.velocity.Y < 0f && wormTargetY < 0f)) { - if (npc.velocity.X < num39) - npc.velocity.X = npc.velocity.X + num38; - else if (npc.velocity.X > num39) - npc.velocity.X = npc.velocity.X - num38; + if (npc.velocity.X < wormTargetX) + npc.velocity.X = npc.velocity.X + wormAccel; + else if (npc.velocity.X > wormTargetX) + npc.velocity.X = npc.velocity.X - wormAccel; - if (npc.velocity.Y < num40) - npc.velocity.Y = npc.velocity.Y + num38; - else if (npc.velocity.Y > num40) - npc.velocity.Y = npc.velocity.Y - num38; + if (npc.velocity.Y < wormTargetY) + npc.velocity.Y = npc.velocity.Y + wormAccel; + else if (npc.velocity.Y > wormTargetY) + npc.velocity.Y = npc.velocity.Y - wormAccel; - if ((double)Math.Abs(num40) < (double)num37 * 0.2 && ((npc.velocity.X > 0f && num39 < 0f) || (npc.velocity.X < 0f && num39 > 0f))) + if ((double)Math.Abs(wormTargetY) < (double)wormSpeed * 0.2 && ((npc.velocity.X > 0f && wormTargetX < 0f) || (npc.velocity.X < 0f && wormTargetX > 0f))) { if (npc.velocity.Y > 0f) - npc.velocity.Y = npc.velocity.Y + num38 * 2f; + npc.velocity.Y = npc.velocity.Y + wormAccel * 2f; else - npc.velocity.Y = npc.velocity.Y - num38 * 2f; + npc.velocity.Y = npc.velocity.Y - wormAccel * 2f; } - if ((double)Math.Abs(num39) < (double)num37 * 0.2 && ((npc.velocity.Y > 0f && num40 < 0f) || (npc.velocity.Y < 0f && num40 > 0f))) + if ((double)Math.Abs(wormTargetX) < (double)wormSpeed * 0.2 && ((npc.velocity.Y > 0f && wormTargetY < 0f) || (npc.velocity.Y < 0f && wormTargetY > 0f))) { if (npc.velocity.X > 0f) - npc.velocity.X = npc.velocity.X + num38 * 2f; + npc.velocity.X = npc.velocity.X + wormAccel * 2f; else - npc.velocity.X = npc.velocity.X - num38 * 2f; + npc.velocity.X = npc.velocity.X - wormAccel * 2f; } } - else if (num55 > num56) + else if (absoluteTargetX > absoluteTargetY) { - if (npc.velocity.X < num39) - npc.velocity.X = npc.velocity.X + num38 * 1.1f; - else if (npc.velocity.X > num39) - npc.velocity.X = npc.velocity.X - num38 * 1.1f; + if (npc.velocity.X < wormTargetX) + npc.velocity.X = npc.velocity.X + wormAccel * 1.1f; + else if (npc.velocity.X > wormTargetX) + npc.velocity.X = npc.velocity.X - wormAccel * 1.1f; - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num37 * 0.5) + if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)wormSpeed * 0.5) { if (npc.velocity.Y > 0f) - npc.velocity.Y = npc.velocity.Y + num38; + npc.velocity.Y = npc.velocity.Y + wormAccel; else - npc.velocity.Y = npc.velocity.Y - num38; + npc.velocity.Y = npc.velocity.Y - wormAccel; } } else { - if (npc.velocity.Y < num40) - npc.velocity.Y = npc.velocity.Y + num38 * 1.1f; - else if (npc.velocity.Y > num40) - npc.velocity.Y = npc.velocity.Y - num38 * 1.1f; + if (npc.velocity.Y < wormTargetY) + npc.velocity.Y = npc.velocity.Y + wormAccel * 1.1f; + else if (npc.velocity.Y > wormTargetY) + npc.velocity.Y = npc.velocity.Y - wormAccel * 1.1f; - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num37 * 0.5) + if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)wormSpeed * 0.5) { if (npc.velocity.X > 0f) - npc.velocity.X = npc.velocity.X + num38; + npc.velocity.X = npc.velocity.X + wormAccel; else - npc.velocity.X = npc.velocity.X - num38; + npc.velocity.X = npc.velocity.X - wormAccel; } } } @@ -5009,7 +5003,7 @@ namespace CalamityMod.NPCs npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + MathHelper.PiOver2; if (npc.type == NPCID.DevourerHead || npc.type == NPCID.GiantWormHead || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.DiggerHead || npc.type == NPCID.SeekerHead || npc.type == NPCID.LeechHead || npc.type == NPCID.DuneSplicerHead || npc.type == NPCID.TombCrawlerHead) { - if (flag2) + if (flying) { if (npc.localAI[0] != 1f) npc.netUpdate = true; @@ -5065,69 +5059,69 @@ namespace CalamityMod.NPCs npc.alpha = 255; } SoundEngine.PlaySound(SoundID.Item8, npc.position); - int num; - for (int num68 = 0; num68 < 50; num68 = num + 1) + int dustIncrement; + for (int i = 0; i < 50; i = dustIncrement + 1) { if (npc.type == NPCID.GoblinSorcerer || npc.type == NPCID.Tim) { - int num69 = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 100, default(Color), (float)Main.rand.Next(1, 3)); - Dust dust = Main.dust[num69]; + int goblinDust = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 100, default(Color), (float)Main.rand.Next(1, 3)); + Dust dust = Main.dust[goblinDust]; dust.velocity *= 3f; - if (Main.dust[num69].scale > 1f) + if (Main.dust[goblinDust].scale > 1f) { - Main.dust[num69].noGravity = true; + Main.dust[goblinDust].noGravity = true; } } else if (npc.type == NPCID.DarkCaster) { - int num70 = Dust.NewDust(npc.position, npc.width, npc.height, 172, 0f, 0f, 100, default(Color), 1.5f); - Dust dust = Main.dust[num70]; + int darkCasterDust = Dust.NewDust(npc.position, npc.width, npc.height, 172, 0f, 0f, 100, default(Color), 1.5f); + Dust dust = Main.dust[darkCasterDust]; dust.velocity *= 3f; - Main.dust[num70].noGravity = true; + Main.dust[darkCasterDust].noGravity = true; } else if (npc.type == NPCID.Necromancer || npc.type == NPCID.NecromancerArmored) { - int num71 = Dust.NewDust(npc.position, npc.width, npc.height, 173, 0f, 0f, 0, default(Color), 1f); - Dust dust = Main.dust[num71]; + int necromancerDust = Dust.NewDust(npc.position, npc.width, npc.height, 173, 0f, 0f, 0, default(Color), 1f); + Dust dust = Main.dust[necromancerDust]; dust.velocity *= 2f; - Main.dust[num71].scale = 1.4f; + Main.dust[necromancerDust].scale = 1.4f; } else if (npc.type == NPCID.DiabolistRed || npc.type == NPCID.DiabolistWhite) { - int num72 = Dust.NewDust(npc.position, npc.width, npc.height, 174, 0f, 0f, 100, default(Color), 1.5f); - Dust dust = Main.dust[num72]; + int diabolistDust = Dust.NewDust(npc.position, npc.width, npc.height, 174, 0f, 0f, 100, default(Color), 1.5f); + Dust dust = Main.dust[diabolistDust]; dust.velocity *= 3f; - Main.dust[num72].noGravity = true; + Main.dust[diabolistDust].noGravity = true; } else if (npc.type == NPCID.RaggedCaster || npc.type == NPCID.RaggedCasterOpenCoat) { - int num73 = Dust.NewDust(npc.position, npc.width, npc.height, 175, 0f, 0f, 100, default(Color), 1.5f); - Dust dust = Main.dust[num73]; + int raggedCasterDust = Dust.NewDust(npc.position, npc.width, npc.height, 175, 0f, 0f, 100, default(Color), 1.5f); + Dust dust = Main.dust[raggedCasterDust]; dust.velocity *= 3f; - Main.dust[num73].noGravity = true; + Main.dust[raggedCasterDust].noGravity = true; } else if (npc.type == NPCID.RuneWizard) { - int num74 = Dust.NewDust(npc.position, npc.width, npc.height, 106, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[num74]; + int runeWizardDust = Dust.NewDust(npc.position, npc.width, npc.height, 106, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[runeWizardDust]; dust.velocity *= 3f; - Main.dust[num74].noGravity = true; + Main.dust[runeWizardDust].noGravity = true; } else if (npc.type == NPCID.DesertDjinn) { - int num75 = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[num75]; + int desertSpiritDust = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[desertSpiritDust]; dust.velocity *= 3f; - Main.dust[num75].noGravity = true; + Main.dust[desertSpiritDust].noGravity = true; } else { - int num76 = Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[num76]; + int fireImpDust = Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[fireImpDust]; dust.velocity *= 3f; - Main.dust[num76].noGravity = true; + Main.dust[fireImpDust].noGravity = true; } - num = num68; + dustIncrement = i; } npc.position.X = npc.ai[2] * 16f - (float)(npc.width / 2) + 8f; npc.position.Y = npc.ai[3] * 16f - (float)npc.height; @@ -5136,68 +5130,68 @@ namespace CalamityMod.NPCs npc.ai[2] = 0f; npc.ai[3] = 0f; SoundEngine.PlaySound(SoundID.Item8, npc.position); - for (int num77 = 0; num77 < 50; num77 = num + 1) + for (int j = 0; j < 50; j = dustIncrement + 1) { if (npc.type == NPCID.GoblinSorcerer || npc.type == NPCID.Tim) { - int num78 = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 100, default(Color), (float)Main.rand.Next(1, 3)); - Dust dust = Main.dust[num78]; + int goblinCastDust = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 100, default(Color), (float)Main.rand.Next(1, 3)); + Dust dust = Main.dust[goblinCastDust]; dust.velocity *= 3f; - if (Main.dust[num78].scale > 1f) + if (Main.dust[goblinCastDust].scale > 1f) { - Main.dust[num78].noGravity = true; + Main.dust[goblinCastDust].noGravity = true; } } else if (npc.type == NPCID.DarkCaster) { - int num79 = Dust.NewDust(npc.position, npc.width, npc.height, 172, 0f, 0f, 100, default(Color), 1.5f); - Dust dust = Main.dust[num79]; + int darkCasterCastDust = Dust.NewDust(npc.position, npc.width, npc.height, 172, 0f, 0f, 100, default(Color), 1.5f); + Dust dust = Main.dust[darkCasterCastDust]; dust.velocity *= 3f; - Main.dust[num79].noGravity = true; + Main.dust[darkCasterCastDust].noGravity = true; } else if (npc.type == NPCID.RuneWizard) { - int num80 = Dust.NewDust(npc.position, npc.width, npc.height, 106, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[num80]; + int runeWizardCastDust = Dust.NewDust(npc.position, npc.width, npc.height, 106, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[runeWizardCastDust]; dust.velocity *= 3f; - Main.dust[num80].noGravity = true; + Main.dust[runeWizardCastDust].noGravity = true; } else if (npc.type == NPCID.Necromancer || npc.type == NPCID.NecromancerArmored) { - int num81 = Dust.NewDust(npc.position, npc.width, npc.height, 173, 0f, 0f, 0, default(Color), 1f); - Dust dust = Main.dust[num81]; + int necromancerCastDust = Dust.NewDust(npc.position, npc.width, npc.height, 173, 0f, 0f, 0, default(Color), 1f); + Dust dust = Main.dust[necromancerCastDust]; dust.velocity *= 2f; - Main.dust[num81].scale = 1.4f; + Main.dust[necromancerCastDust].scale = 1.4f; } else if (npc.type == NPCID.DiabolistRed || npc.type == NPCID.DiabolistWhite) { - int num82 = Dust.NewDust(npc.position, npc.width, npc.height, 174, 0f, 0f, 100, default(Color), 1.5f); - Dust dust = Main.dust[num82]; + int diabolistCastDust = Dust.NewDust(npc.position, npc.width, npc.height, 174, 0f, 0f, 100, default(Color), 1.5f); + Dust dust = Main.dust[diabolistCastDust]; dust.velocity *= 3f; - Main.dust[num82].noGravity = true; + Main.dust[diabolistCastDust].noGravity = true; } else if (npc.type == NPCID.RaggedCaster || npc.type == NPCID.RaggedCasterOpenCoat) { - int num83 = Dust.NewDust(npc.position, npc.width, npc.height, 175, 0f, 0f, 100, default(Color), 1.5f); - Dust dust = Main.dust[num83]; + int raggedCasterCastDust = Dust.NewDust(npc.position, npc.width, npc.height, 175, 0f, 0f, 100, default(Color), 1.5f); + Dust dust = Main.dust[raggedCasterCastDust]; dust.velocity *= 3f; - Main.dust[num83].noGravity = true; + Main.dust[raggedCasterCastDust].noGravity = true; } else if (npc.type == NPCID.DesertDjinn) { - int num84 = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[num84]; + int desertSpiritCastDust = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[desertSpiritCastDust]; dust.velocity *= 3f; - Main.dust[num84].noGravity = true; + Main.dust[desertSpiritCastDust].noGravity = true; } else { - int num85 = Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[num85]; + int fireImpCastDust = Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[fireImpCastDust]; dust.velocity *= 3f; - Main.dust[num85].noGravity = true; + Main.dust[fireImpCastDust].noGravity = true; } - num = num77; + dustIncrement = j; } } @@ -5262,47 +5256,47 @@ namespace CalamityMod.NPCs if (npc.ai[0] >= 650f && Main.netMode != NetmodeID.MultiplayerClient) { npc.ai[0] = 2f; - int num86 = (int)Main.player[npc.target].position.X / 16; - int num87 = (int)Main.player[npc.target].position.Y / 16; - int num88 = (int)npc.position.X / 16; - int num89 = (int)npc.position.Y / 16; - int num90 = 20; - int num91 = 0; - bool flag4 = false; + int targetTileX = (int)Main.player[npc.target].position.X / 16; + int targetTileY = (int)Main.player[npc.target].position.Y / 16; + int npcTileX = (int)npc.position.X / 16; + int npcTileY = (int)npc.position.Y / 16; + int randTeleportOffset = 20; + int teleportTries = 0; + bool canTeleport = false; if (Math.Abs(npc.position.X - Main.player[npc.target].position.X) + Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 2000f) { - num91 = 100; - flag4 = true; + teleportTries = 100; + canTeleport = true; } - while (!flag4 && num91 < 100) + while (!canTeleport && teleportTries < 100) { - num91++; - int num92 = Main.rand.Next(num86 - num90, num86 + num90); - int num93 = Main.rand.Next(num87 - num90, num87 + num90); - int num; - for (int num94 = num93; num94 < num87 + num90; num94 = num + 1) + teleportTries++; + int teleportTileX = Main.rand.Next(targetTileX - randTeleportOffset, targetTileX + randTeleportOffset); + int teleportTileY = Main.rand.Next(targetTileY - randTeleportOffset, targetTileY + randTeleportOffset); + int dustIncrement; + for (int k = teleportTileY; k < targetTileY + randTeleportOffset; k = dustIncrement + 1) { - if ((num94 < num87 - 4 || num94 > num87 + 4 || num92 < num86 - 4 || num92 > num86 + 4) && (num94 < num89 - 1 || num94 > num89 + 1 || num92 < num88 - 1 || num92 > num88 + 1) && Main.tile[num92, num94].HasUnactuatedTile) + if ((k < targetTileY - 4 || k > targetTileY + 4 || teleportTileX < targetTileX - 4 || teleportTileX > targetTileX + 4) && (k < npcTileY - 1 || k > npcTileY + 1 || teleportTileX < npcTileX - 1 || teleportTileX > npcTileX + 1) && Main.tile[teleportTileX, k].HasUnactuatedTile) { - bool flag5 = true; - if ((npc.type == NPCID.DarkCaster || (npc.type >= NPCID.RaggedCaster && npc.type <= NPCID.DiabolistWhite)) && !Main.wallDungeon[(int)Main.tile[num92, num94 - 1].WallType]) + bool validTeleportSpot = true; + if ((npc.type == NPCID.DarkCaster || (npc.type >= NPCID.RaggedCaster && npc.type <= NPCID.DiabolistWhite)) && !Main.wallDungeon[(int)Main.tile[teleportTileX, k - 1].WallType]) { - flag5 = false; + validTeleportSpot = false; } - else if (Main.tile[num92, num94 - 1].LiquidType == LiquidID.Lava) + else if (Main.tile[teleportTileX, k - 1].LiquidType == LiquidID.Lava) { - flag5 = false; + validTeleportSpot = false; } - if (flag5 && Main.tileSolid[(int)Main.tile[num92, num94].TileType] && !Collision.SolidTiles(num92 - 1, num92 + 1, num94 - 4, num94 - 1)) + if (validTeleportSpot && Main.tileSolid[(int)Main.tile[teleportTileX, k].TileType] && !Collision.SolidTiles(teleportTileX - 1, teleportTileX + 1, k - 4, k - 1)) { npc.ai[1] = 20f; - npc.ai[2] = (float)num92; - npc.ai[3] = (float)num94; - flag4 = true; + npc.ai[2] = (float)teleportTileX; + npc.ai[3] = (float)k; + canTeleport = true; break; } } - num = num94; + dustIncrement = k; } } npc.netUpdate = true; @@ -5317,42 +5311,42 @@ namespace CalamityMod.NPCs SoundEngine.PlaySound(SoundID.Item8, npc.position); if (Main.netMode != NetmodeID.MultiplayerClient) { - Point point = npc.Center.ToTileCoordinates(); - Point point2 = Main.player[npc.target].Center.ToTileCoordinates(); - Vector2 vector12 = Main.player[npc.target].Center - npc.Center; - int num95 = 6; - int num96 = 6; - int num97 = 0; - int num98 = 2; - int num99 = 0; - bool flag6 = false; - if (vector12.Length() > 2000f) + Point spiritCenter = npc.Center.ToTileCoordinates(); + Point targetCenter = Main.player[npc.target].Center.ToTileCoordinates(); + Vector2 targetDirection = Main.player[npc.target].Center - npc.Center; + int randProjRadius = 6; + int spiritSpawnRadius = 6; + int targetSpawnRadius = 0; + int solidTileCheckRadius = 2; + int projSpawnTries = 0; + bool targetTooFar = false; + if (targetDirection.Length() > 2000f) { - flag6 = true; + targetTooFar = true; } - while (!flag6) + while (!targetTooFar) { - if (num99 >= 50) + if (projSpawnTries >= 50) { break; } - num99++; - int num100 = Main.rand.Next(point2.X - num95, point2.X + num95 + 1); - int num101 = Main.rand.Next(point2.Y - num95, point2.Y + num95 + 1); - if ((num101 < point2.Y - num97 || num101 > point2.Y + num97 || num100 < point2.X - num97 || num100 > point2.X + num97) && (num101 < point.Y - num96 || num101 > point.Y + num96 || num100 < point.X - num96 || num100 > point.X + num96) && !Main.tile[num100, num101].HasUnactuatedTile) + projSpawnTries++; + int spiritProjSpawnX = Main.rand.Next(targetCenter.X - randProjRadius, targetCenter.X + randProjRadius + 1); + int spiritProjSpawnY = Main.rand.Next(targetCenter.Y - randProjRadius, targetCenter.Y + randProjRadius + 1); + if ((spiritProjSpawnY < targetCenter.Y - targetSpawnRadius || spiritProjSpawnY > targetCenter.Y + targetSpawnRadius || spiritProjSpawnX < targetCenter.X - targetSpawnRadius || spiritProjSpawnX > targetCenter.X + targetSpawnRadius) && (spiritProjSpawnY < spiritCenter.Y - spiritSpawnRadius || spiritProjSpawnY > spiritCenter.Y + spiritSpawnRadius || spiritProjSpawnX < spiritCenter.X - spiritSpawnRadius || spiritProjSpawnX > spiritCenter.X + spiritSpawnRadius) && !Main.tile[spiritProjSpawnX, spiritProjSpawnY].HasUnactuatedTile) { - bool flag7 = true; - if (flag7 && Main.tile[num100, num101].LiquidType == LiquidID.Lava) + bool canSpawnProj = true; + if (canSpawnProj && Main.tile[spiritProjSpawnX, spiritProjSpawnY].LiquidType == LiquidID.Lava) { - flag7 = false; + canSpawnProj = false; } - if (flag7 && Collision.SolidTiles(num100 - num98, num100 + num98, num101 - num98, num101 + num98)) + if (canSpawnProj && Collision.SolidTiles(spiritProjSpawnX - solidTileCheckRadius, spiritProjSpawnX + solidTileCheckRadius, spiritProjSpawnY - solidTileCheckRadius, spiritProjSpawnY + solidTileCheckRadius)) { - flag7 = false; + canSpawnProj = false; } - if (flag7) + if (canSpawnProj) { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), (float)(num100 * 16 + 8), (float)(num101 * 16 + 8), 0f, 0f, ProjectileID.DesertDjinnCurse, 0, 1f, Main.myPlayer, (float)npc.target, 0f); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), (float)(spiritProjSpawnX * 16 + 8), (float)(spiritProjSpawnY * 16 + 8), 0f, 0f, ProjectileID.DesertDjinnCurse, 0, 1f, Main.myPlayer, (float)npc.target, 0f); if (CalamityWorld.death) Main.projectile[proj].extraUpdates += 1; break; @@ -5368,22 +5362,22 @@ namespace CalamityMod.NPCs { if (Main.netMode != NetmodeID.MultiplayerClient) { - float num102 = CalamityWorld.death ? 8f : 6f; + float dungeonCasterProjSpeed = CalamityWorld.death ? 8f : 6f; if (npc.type == NPCID.DiabolistRed || npc.type == NPCID.DiabolistWhite) { - num102 = CalamityWorld.death ? 10f : 8f; + dungeonCasterProjSpeed = CalamityWorld.death ? 10f : 8f; } if (npc.type == NPCID.RaggedCaster || npc.type == NPCID.RaggedCasterOpenCoat) { - num102 = CalamityWorld.death ? 5f : 4f; + dungeonCasterProjSpeed = CalamityWorld.death ? 5f : 4f; } - Vector2 vector13 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y); - float num103 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector13.X; - float num104 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector13.Y; - float num105 = (float)Math.Sqrt((double)(num103 * num103 + num104 * num104)); - num105 = num102 / num105; - num103 *= num105; - num104 *= num105; + Vector2 dungeonCasterPos = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y); + float dungeonCasterTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - dungeonCasterPos.X; + float dungeonCasterTargetY = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - dungeonCasterPos.Y; + float dungeonCasterTargetDist = (float)Math.Sqrt((double)(dungeonCasterTargetX * dungeonCasterTargetX + dungeonCasterTargetY * dungeonCasterTargetY)); + dungeonCasterTargetDist = dungeonCasterProjSpeed / dungeonCasterTargetDist; + dungeonCasterTargetX *= dungeonCasterTargetDist; + dungeonCasterTargetY *= dungeonCasterTargetDist; int damage = 16; int projType = ProjectileID.ShadowBeamHostile; if (npc.type == NPCID.DiabolistRed || npc.type == NPCID.DiabolistWhite) @@ -5396,13 +5390,13 @@ namespace CalamityMod.NPCs projType = ProjectileID.LostSoulHostile; damage = 32; } - int num108 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector13.X, vector13.Y, num103, num104, projType, damage, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[num108].timeLeft = 300; + int dungeonCasterProj = Projectile.NewProjectile(npc.GetSource_FromAI(), dungeonCasterPos.X, dungeonCasterPos.Y, dungeonCasterTargetX, dungeonCasterTargetY, projType, damage, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[dungeonCasterProj].timeLeft = 300; if (projType == ProjectileID.InfernoHostileBolt) { - Main.projectile[num108].ai[0] = Main.player[npc.target].Center.X; - Main.projectile[num108].ai[1] = Main.player[npc.target].Center.Y; - Main.projectile[num108].netUpdate = true; + Main.projectile[dungeonCasterProj].ai[0] = Main.player[npc.target].Center.X; + Main.projectile[dungeonCasterProj].ai[1] = Main.player[npc.target].Center.Y; + Main.projectile[dungeonCasterProj].netUpdate = true; } npc.localAI[0] = 0f; } @@ -5425,18 +5419,16 @@ namespace CalamityMod.NPCs } else if (npc.type == NPCID.RuneWizard) { - float num109 = CalamityWorld.death ? 12f : 10f; + float runeWizardProjSpeed = CalamityWorld.death ? 12f : 10f; Vector2 vector14 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num110 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector14.X; - float num111 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector14.Y; - float num112 = (float)Math.Sqrt((double)(num110 * num110 + num111 * num111)); - num112 = num109 / num112; - num110 *= num112; - num111 *= num112; - int num113 = 40; - int num114 = ProjectileID.RuneBlast; - int num115 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector14.X, vector14.Y, num110, num111, num114, num113, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[num115].timeLeft = 300; + float runeWizardTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector14.X; + float runeWizardTargetY = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector14.Y; + float runeWizardTargetDist = (float)Math.Sqrt((double)(runeWizardTargetX * runeWizardTargetX + runeWizardTargetY * runeWizardTargetY)); + runeWizardTargetDist = runeWizardProjSpeed / runeWizardTargetDist; + runeWizardTargetX *= runeWizardTargetDist; + runeWizardTargetY *= runeWizardTargetDist; + int runeWizardProj = Projectile.NewProjectile(npc.GetSource_FromAI(), vector14.X, vector14.Y, runeWizardTargetX, runeWizardTargetY, ProjectileID.RuneBlast, 40, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[runeWizardProj].timeLeft = 300; npc.localAI[0] = 0f; } else @@ -5451,8 +5443,8 @@ namespace CalamityMod.NPCs { if (Main.rand.NextBool(5)) { - int num116 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 27, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 1.5f); - Dust dust = Main.dust[num116]; + int shadowflameSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 27, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 1.5f); + Dust dust = Main.dust[shadowflameSpawnDust]; dust.noGravity = true; dust.velocity.X *= 0.5f; dust.velocity.Y = -2f; @@ -5462,8 +5454,8 @@ namespace CalamityMod.NPCs { if (Main.rand.Next(3) != 0) { - int num117 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 172, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 0.9f); - Dust dust = Main.dust[num117]; + int waterSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 172, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 0.9f); + Dust dust = Main.dust[waterSpawnDust]; dust.noGravity = true; dust.velocity.X *= 0.3f; dust.velocity.Y *= 0.2f; @@ -5474,24 +5466,24 @@ namespace CalamityMod.NPCs { if (npc.type == NPCID.RuneWizard) { - int num118 = 1; + int runeWizardDustAmt = 1; if (npc.alpha == 255) { - num118 = 2; + runeWizardDustAmt = 2; } - int num; - for (int num119 = 0; num119 < num118; num119 = num + 1) + int dustIncrement; + for (int r = 0; r < runeWizardDustAmt; r = dustIncrement + 1) { if (Main.rand.Next(255) > 255 - npc.alpha) { - int num120 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 106, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 1.2f); - Dust dust = Main.dust[num120]; + int runeSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 106, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 1.2f); + Dust dust = Main.dust[runeSpawnDust]; dust.noGravity = true; dust.velocity.X *= (0.1f + (float)Main.rand.Next(30) * 0.01f); dust.velocity.Y *= (0.1f + (float)Main.rand.Next(30) * 0.01f); dust.scale *= 1f + (float)Main.rand.Next(6) * 0.1f; } - num = num119; + dustIncrement = r; } return false; } @@ -5499,8 +5491,8 @@ namespace CalamityMod.NPCs { if (Main.rand.NextBool()) { - int num121 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 173, 0f, 0f, 0, default(Color), 1f); - Dust dust = Main.dust[num121]; + int necroSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 173, 0f, 0f, 0, default(Color), 1f); + Dust dust = Main.dust[necroSpawnDust]; dust.velocity.X *= 0.5f; dust.velocity.Y *= 0.5f; } @@ -5509,8 +5501,8 @@ namespace CalamityMod.NPCs { if (Main.rand.NextBool()) { - int num122 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 174, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 1f); - Dust dust = Main.dust[num122]; + int flameSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 174, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 1f); + Dust dust = Main.dust[flameSpawnDust]; dust.noGravity = true; dust.velocity *= 0.4f; dust.velocity.Y -= 0.7f; @@ -5521,8 +5513,8 @@ namespace CalamityMod.NPCs { if (Main.rand.NextBool()) { - int num123 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 175, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 0.1f); - Dust dust = Main.dust[num123]; + int ghostSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 175, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 0.1f); + Dust dust = Main.dust[ghostSpawnDust]; dust.noGravity = true; dust.velocity *= 0.5f; dust.fadeIn = 1.2f; @@ -5537,8 +5529,8 @@ namespace CalamityMod.NPCs } if (Main.rand.NextBool()) { - int num124 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 6, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 2f); - Dust dust = Main.dust[num124]; + int desertSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 6, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 2f); + Dust dust = Main.dust[desertSpawnDust]; dust.noGravity = true; dust.velocity.X *= 1f; dust.velocity.Y *= 1f; @@ -5758,16 +5750,16 @@ namespace CalamityMod.NPCs { if (npc.type == NPCID.Hellbat || npc.type == NPCID.Lavabat) { - int num203 = Dust.NewDust(npc.position, npc.width, npc.height, 6, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 2f); - Main.dust[num203].noGravity = true; + int lavaDust = Dust.NewDust(npc.position, npc.width, npc.height, 6, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 2f); + Main.dust[lavaDust].noGravity = true; } if (npc.type == NPCID.IceBat && Main.rand.NextBool(10)) { - int num204 = Dust.NewDust(npc.position, npc.width, npc.height, 67, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 1.5f); - Main.dust[num204].noGravity = true; - Dust dust = Main.dust[num204]; + int iceDust = Dust.NewDust(npc.position, npc.width, npc.height, 67, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 1.5f); + Main.dust[iceDust].noGravity = true; + Dust dust = Main.dust[iceDust]; dust.velocity *= 0.2f; - Main.dust[num204].noLight = true; + Main.dust[iceDust].noLight = true; } npc.noGravity = true; // Collision on the X axis. @@ -6680,51 +6672,51 @@ namespace CalamityMod.NPCs } else { - float num282 = (CalamityWorld.death ? 12f : 9f) * npc.ai[3]; - float num283 = (CalamityWorld.death ? 0.4f : 0.3f) * npc.ai[3]; - float num284 = num282 / num283 / 2f; - if (npc.ai[0] >= 1f && npc.ai[0] < (float)((int)num284)) + float maxSpinSpeed = (CalamityWorld.death ? 12f : 9f) * npc.ai[3]; + float spinAcceleration = (CalamityWorld.death ? 0.4f : 0.3f) * npc.ai[3]; + float timeToReachMaxSpeed = maxSpinSpeed / spinAcceleration / 2f; + if (npc.ai[0] >= 1f && npc.ai[0] < (float)((int)timeToReachMaxSpeed)) { - npc.velocity.Y = (float)npc.directionY * num282; + npc.velocity.Y = (float)npc.directionY * maxSpinSpeed; npc.ai[0] += 1f; return false; } - if (npc.ai[0] >= (float)((int)num284)) + if (npc.ai[0] >= (float)((int)timeToReachMaxSpeed)) { npc.velocity.Y = 0f; npc.directionY *= -1; - npc.velocity.X = num282 * (float)npc.direction; + npc.velocity.X = maxSpinSpeed * (float)npc.direction; npc.ai[0] = -1f; return false; } if (npc.directionY > 0) { - if (npc.velocity.Y >= num282) + if (npc.velocity.Y >= maxSpinSpeed) { npc.directionY *= -1; - npc.velocity.Y = num282; + npc.velocity.Y = maxSpinSpeed; } } - else if (npc.directionY < 0 && npc.velocity.Y <= -num282) + else if (npc.directionY < 0 && npc.velocity.Y <= -maxSpinSpeed) { npc.directionY *= -1; - npc.velocity.Y = -num282; + npc.velocity.Y = -maxSpinSpeed; } if (npc.direction > 0) { - if (npc.velocity.X >= num282) + if (npc.velocity.X >= maxSpinSpeed) { npc.direction *= -1; - npc.velocity.X = num282; + npc.velocity.X = maxSpinSpeed; } } - else if (npc.direction < 0 && npc.velocity.X <= -num282) + else if (npc.direction < 0 && npc.velocity.X <= -maxSpinSpeed) { npc.direction *= -1; - npc.velocity.X = -num282; + npc.velocity.X = -maxSpinSpeed; } - npc.velocity.X = npc.velocity.X + num283 * (float)npc.direction; - npc.velocity.Y = npc.velocity.Y + num283 * (float)npc.directionY; + npc.velocity.X = npc.velocity.X + spinAcceleration * (float)npc.direction; + npc.velocity.Y = npc.velocity.Y + spinAcceleration * (float)npc.directionY; } return false; } @@ -6739,7 +6731,7 @@ namespace CalamityMod.NPCs npc.directionY = 1; npc.ai[0] = 1f; } - int num285 = CalamityWorld.death ? 9 : 6; + int wheelVelocity = CalamityWorld.death ? 9 : 6; if (npc.ai[1] == 0f) { npc.rotation += (float)(npc.direction * npc.directionY) * 0.13f; @@ -6778,19 +6770,19 @@ namespace CalamityMod.NPCs npc.ai[1] = 0f; } } - npc.velocity.X = (float)(num285 * npc.direction); - npc.velocity.Y = (float)(num285 * npc.directionY); - float num286 = (float)(270 - (int)Main.mouseTextColor) / 400f; - Lighting.AddLight((int)(npc.position.X + (float)(npc.width / 2)) / 16, (int)(npc.position.Y + (float)(npc.height / 2)) / 16, 0.9f, 0.3f + num286, 0.2f); + npc.velocity.X = (float)(wheelVelocity * npc.direction); + npc.velocity.Y = (float)(wheelVelocity * npc.directionY); + float lighting = (float)(270 - (int)Main.mouseTextColor) / 400f; + Lighting.AddLight((int)(npc.position.X + (float)(npc.width / 2)) / 16, (int)(npc.position.Y + (float)(npc.height / 2)) / 16, 0.9f, 0.3f + lighting, 0.2f); if (Main.netMode != NetmodeID.MultiplayerClient) { npc.localAI[0] += 1f; if (npc.localAI[0] >= (CalamityWorld.death ? 90f : 120f)) { npc.localAI[0] = 0f; - for (int num1501 = 0; num1501 < 4; num1501++) + for (int i = 0; i < 4; i++) { - Vector2 vector255 = new Vector2(0f, -5f).RotatedBy((double)(MathHelper.PiOver2 * (float)num1501)); + Vector2 vector255 = new Vector2(0f, -5f).RotatedBy((double)(MathHelper.PiOver2 * (float)i)); int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, vector255.X, vector255.Y, ProjectileID.FlamesTrap, 20, 0f, Main.myPlayer, 0f, 0f); Main.projectile[proj].tileCollide = false; Main.projectile[proj].friendly = false; @@ -6805,39 +6797,39 @@ namespace CalamityMod.NPCs #region Hovering AI public static bool BuffedHoveringAI(NPC npc, Mod mod) { - bool flag19 = false; - bool flag20 = npc.type == NPCID.Poltergeist && !Main.pumpkinMoon; + bool hoverDownDistCheck = false; + bool runAway = npc.type == NPCID.Poltergeist && !Main.pumpkinMoon; if (npc.type == NPCID.Reaper && !Main.eclipse) { - flag20 = true; + runAway = true; } if (npc.type == NPCID.Drippler && Main.dayTime) { - flag20 = true; + runAway = true; } - if (!flag20) + if (!runAway) { if (npc.ai[2] >= 0f) { - int num287 = 16; - bool flag21 = false; - bool flag22 = false; - if (npc.position.X > npc.ai[0] - (float)num287 && npc.position.X < npc.ai[0] + (float)num287) + int hoverDistance = 16; + bool changeDirectionX = false; + bool changeDirectionY = false; + if (npc.position.X > npc.ai[0] - (float)hoverDistance && npc.position.X < npc.ai[0] + (float)hoverDistance) { - flag21 = true; + changeDirectionX = true; } else if ((npc.velocity.X < 0f && npc.direction > 0) || (npc.velocity.X > 0f && npc.direction < 0)) { - flag21 = true; + changeDirectionX = true; } - num287 += 24; - if (npc.position.Y > npc.ai[1] - (float)num287 && npc.position.Y < npc.ai[1] + (float)num287) + hoverDistance += 24; + if (npc.position.Y > npc.ai[1] - (float)hoverDistance && npc.position.Y < npc.ai[1] + (float)hoverDistance) { - flag22 = true; + changeDirectionY = true; } - if (flag21 & flag22) + if (changeDirectionX & changeDirectionY) { npc.ai[2] += 1f; if (npc.ai[2] >= 40f) @@ -6882,23 +6874,23 @@ namespace CalamityMod.NPCs } } - int num288 = (int)((npc.position.X + (float)(npc.width / 2)) / 16f) + npc.direction * 2; - int num289 = (int)((npc.position.Y + (float)npc.height) / 16f); - bool flag23 = true; - bool flag24 = false; - int num290 = 6; + int npcTileX = (int)((npc.position.X + (float)(npc.width / 2)) / 16f) + npc.direction * 2; + int npcTileY = (int)((npc.position.Y + (float)npc.height) / 16f); + bool hoverDownwards = true; + bool canOpenDoor = false; + int tileCheckLoopAmt = 6; if (npc.type == NPCID.Gastropod) { - float num291 = 6f; - Vector2 vector33 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num292 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector33.X; - float num293 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector33.Y; - float num294 = (float)Math.Sqrt((double)(num292 * num292 + num293 * num293)); + float gastropodProjSpeed = 6f; + Vector2 gastropodPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float gastropodTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - gastropodPosition.X; + float gastropodTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - gastropodPosition.Y; + float gastropodTargetDist = (float)Math.Sqrt((double)(gastropodTargetX * gastropodTargetX + gastropodTargetY * gastropodTargetY)); - num294 = num291 / num294; - num292 *= num294; - num293 *= num294; + gastropodTargetDist = gastropodProjSpeed / gastropodTargetDist; + gastropodTargetX *= gastropodTargetDist; + gastropodTargetY *= gastropodTargetDist; if (npc.justHit) { @@ -6910,10 +6902,10 @@ namespace CalamityMod.NPCs { int damage = 25; int projType = ProjectileID.PinkLaser; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector33.X, vector33.Y, num292, num293, projType, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), gastropodPosition.X, gastropodPosition.Y, gastropodTargetX, gastropodTargetY, projType, damage, 0f, Main.myPlayer, 0f, 0f); } - num290 = 12; + tileCheckLoopAmt = 12; if (npc.ai[3] > 0f) { @@ -6937,12 +6929,12 @@ namespace CalamityMod.NPCs } else if (npc.type == NPCID.Pixie) { - num290 = 8; + tileCheckLoopAmt = 8; if (Main.rand.NextBool(6)) { - int num298 = Dust.NewDust(npc.position, npc.width, npc.height, 55, 0f, 0f, 200, npc.color, 1f); - Dust dust = Main.dust[num298]; + int pixieDust = Dust.NewDust(npc.position, npc.width, npc.height, 55, 0f, 0f, 200, npc.color, 1f); + Dust dust = Main.dust[pixieDust]; dust.velocity *= 0.3f; } @@ -6959,23 +6951,23 @@ namespace CalamityMod.NPCs if (Main.rand.NextBool(3)) { - int num299 = Dust.NewDust(npc.position, npc.width, npc.height, 92, 0f, 0f, 200, default(Color), 1f); - Dust dust = Main.dust[num299]; + int iceEleDust = Dust.NewDust(npc.position, npc.width, npc.height, 92, 0f, 0f, 200, default(Color), 1f); + Dust dust = Main.dust[iceEleDust]; dust.velocity *= 0.3f; - Main.dust[num299].noGravity = true; + Main.dust[iceEleDust].noGravity = true; } - float num300 = 6f; - Vector2 vector34 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num301 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector34.X; - float num302 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector34.Y; - float num303 = (float)Math.Sqrt((double)(num301 * num301 + num302 * num302)); + float iceElementalProjSpeed = 6f; + Vector2 iceElementalPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float iceElementalTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - iceElementalPosition.X; + float iceElementalTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - iceElementalPosition.Y; + float iceElementalTargetDist = (float)Math.Sqrt((double)(iceElementalTargetX * iceElementalTargetX + iceElementalTargetY * iceElementalTargetY)); - num303 = num300 / num303; - num301 *= num303; - num302 *= num303; + iceElementalTargetDist = iceElementalProjSpeed / iceElementalTargetDist; + iceElementalTargetX *= iceElementalTargetDist; + iceElementalTargetY *= iceElementalTargetDist; - if (num301 > 0f) + if (iceElementalTargetX > 0f) { npc.direction = 1; } @@ -6988,11 +6980,11 @@ namespace CalamityMod.NPCs if (npc.direction < 0) { - npc.rotation = (float)Math.Atan2((double)(-(double)num302), (double)(-(double)num301)); + npc.rotation = (float)Math.Atan2((double)(-(double)iceElementalTargetY), (double)(-(double)iceElementalTargetX)); } else { - npc.rotation = (float)Math.Atan2((double)num302, (double)num301); + npc.rotation = (float)Math.Atan2((double)iceElementalTargetY, (double)iceElementalTargetX); } if (npc.justHit) @@ -7005,10 +6997,10 @@ namespace CalamityMod.NPCs { int dmg = 45; int projType = ProjectileID.FrostBlastHostile; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector34.X, vector34.Y, num301, num302, projType, dmg, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), iceElementalPosition.X, iceElementalPosition.Y, iceElementalTargetX, iceElementalTargetY, projType, dmg, 0f, Main.myPlayer, 0f, 0f); } - num290 = 15; + tileCheckLoopAmt = 15; if (npc.ai[3] > 0f) { @@ -7036,11 +7028,11 @@ namespace CalamityMod.NPCs if (Main.player[npc.target].Center.Y < npc.Center.Y) { - num290 = 18; + tileCheckLoopAmt = 18; } else { - num290 = 9; + tileCheckLoopAmt = 9; } if (npc.justHit) @@ -7054,18 +7046,18 @@ namespace CalamityMod.NPCs npc.ai[3] = 0f; if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].head)) { - float num307 = 10f; - Vector2 vector35 = new Vector2(npc.position.X + (float)npc.width * 0.5f - 4f, npc.position.Y + (float)npc.height * 0.7f); - float num308 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector35.X; - float num309 = Math.Abs(num308) * 0.1f; - float num310 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector35.Y - num309; - float num311 = (float)Math.Sqrt((double)(num308 * num308 + num310 * num310)); - num311 = num307 / num311; - num308 *= num311; - num310 *= num311; + float ichorStickerProjSpeed = 10f; + Vector2 ichorStickerPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f - 4f, npc.position.Y + (float)npc.height * 0.7f); + float ichorStickerTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - ichorStickerPosition.X; + float ichorStickerAbsTargetX = Math.Abs(ichorStickerTargetX) * 0.1f; + float ichorStickerTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - ichorStickerPosition.Y - ichorStickerAbsTargetX; + float ichorStickerTargetDist = (float)Math.Sqrt((double)(ichorStickerTargetX * ichorStickerTargetX + ichorStickerTargetY * ichorStickerTargetY)); + ichorStickerTargetDist = ichorStickerProjSpeed / ichorStickerTargetDist; + ichorStickerTargetX *= ichorStickerTargetDist; + ichorStickerTargetY *= ichorStickerTargetDist; int dmg = 40; int projType = ProjectileID.GoldenShowerHostile; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector35.X, vector35.Y, num308, num310, projType, dmg, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), ichorStickerPosition.X, ichorStickerPosition.Y, ichorStickerTargetX, ichorStickerTargetY, projType, dmg, 0f, Main.myPlayer, 0f, 0f); } } } @@ -7073,70 +7065,70 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.Drippler) { - num290 = 8; + tileCheckLoopAmt = 8; if (npc.target >= 0) { - float num315 = (Main.player[npc.target].Center - npc.Center).Length(); - num315 /= 70f; - if (num315 > 8f) + float dripperTargetDist = (Main.player[npc.target].Center - npc.Center).Length(); + dripperTargetDist /= 70f; + if (dripperTargetDist > 8f) { - num315 = 8f; + dripperTargetDist = 8f; } - num290 += (int)num315; + tileCheckLoopAmt += (int)dripperTargetDist; } } - for (int num316 = num289; num316 < num289 + num290; num316++) + for (int y = npcTileY; y < npcTileY + tileCheckLoopAmt; y++) { - if ((Main.tile[num288, num316].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num288, num316].TileType]) || Main.tile[num288, num316].LiquidAmount > 0) + if ((Main.tile[npcTileX, y].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, y].TileType]) || Main.tile[npcTileX, y].LiquidAmount > 0) { - if (num316 <= num289 + 1) + if (y <= npcTileY + 1) { - flag24 = true; + canOpenDoor = true; } - flag23 = false; + hoverDownwards = false; break; } } if (Main.player[npc.target].npcTypeNoAggro[npc.type]) { - bool flag25 = false; - for (int num317 = num289; num317 < num289 + num290 - 2; num317++) + bool canOpenTallGate = false; + for (int yInc = npcTileY; yInc < npcTileY + tileCheckLoopAmt - 2; yInc++) { - if ((Main.tile[num288, num317].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num288, num317].TileType]) || Main.tile[num288, num317].LiquidAmount > 0) + if ((Main.tile[npcTileX, yInc].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, yInc].TileType]) || Main.tile[npcTileX, yInc].LiquidAmount > 0) { - flag25 = true; + canOpenTallGate = true; break; } } - npc.directionY = (!flag25).ToDirectionInt(); + npc.directionY = (!canOpenTallGate).ToDirectionInt(); } if (npc.type == NPCID.IceElemental || npc.type == NPCID.IchorSticker) { - for (int num318 = num289 - 3; num318 < num289; num318++) + for (int iceIchorY = npcTileY - 3; iceIchorY < npcTileY; iceIchorY++) { - if ((Main.tile[num288, num318].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num288, num318].TileType]) || Main.tile[num288, num318].LiquidAmount > 0) + if ((Main.tile[npcTileX, iceIchorY].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, iceIchorY].TileType]) || Main.tile[npcTileX, iceIchorY].LiquidAmount > 0) { - flag24 = false; - flag19 = true; + canOpenDoor = false; + hoverDownDistCheck = true; break; } } } - if (flag19) + if (hoverDownDistCheck) { - flag23 = true; + hoverDownwards = true; if (npc.type == NPCID.IchorSticker) { npc.velocity.Y = npc.velocity.Y + 3f; } } - if (flag23) + if (hoverDownwards) { if (npc.type == NPCID.Pixie || npc.type == NPCID.IceElemental) { @@ -7167,14 +7159,14 @@ namespace CalamityMod.NPCs { if (npc.type == NPCID.Pixie || npc.type == NPCID.IceElemental) { - if ((npc.directionY < 0 && npc.velocity.Y > 0f) | flag24) + if ((npc.directionY < 0 && npc.velocity.Y > 0f) | canOpenDoor) { npc.velocity.Y = npc.velocity.Y - 0.3f; } } else if (npc.type == NPCID.Drippler) { - if ((npc.directionY < 0 && npc.velocity.Y > 0f) | flag24) + if ((npc.directionY < 0 && npc.velocity.Y > 0f) | canOpenDoor) { npc.velocity.Y = npc.velocity.Y - 0.1f; } @@ -7228,29 +7220,29 @@ namespace CalamityMod.NPCs } } - float num319 = 4f; + float maxHoverVel = 4f; if (npc.type == NPCID.Pixie) { - num319 = 5f; + maxHoverVel = 5f; } if (npc.type == NPCID.Reaper) { - num319 = 6f; + maxHoverVel = 6f; } if (npc.type == NPCID.Drippler) { - num319 = 2.5f; + maxHoverVel = 2.5f; } if (CalamityWorld.death) { - num319 *= 1.25f; + maxHoverVel *= 1.25f; } if (npc.type == NPCID.Poltergeist) { npc.alpha = 0; - num319 = 6f; - if (!flag20) + maxHoverVel = 6f; + if (!runAway) { npc.TargetClosest(true); } @@ -7268,10 +7260,10 @@ namespace CalamityMod.NPCs } } - if (npc.direction == -1 && npc.velocity.X > -num319) + if (npc.direction == -1 && npc.velocity.X > -maxHoverVel) { npc.velocity.X = npc.velocity.X - 0.15f; - if (npc.velocity.X > num319) + if (npc.velocity.X > maxHoverVel) { npc.velocity.X = npc.velocity.X - 0.15f; } @@ -7279,15 +7271,15 @@ namespace CalamityMod.NPCs { npc.velocity.X = npc.velocity.X + 0.1f; } - if (npc.velocity.X < -num319) + if (npc.velocity.X < -maxHoverVel) { - npc.velocity.X = -num319; + npc.velocity.X = -maxHoverVel; } } - else if (npc.direction == 1 && npc.velocity.X < num319) + else if (npc.direction == 1 && npc.velocity.X < maxHoverVel) { npc.velocity.X = npc.velocity.X + 0.15f; - if (npc.velocity.X < -num319) + if (npc.velocity.X < -maxHoverVel) { npc.velocity.X = npc.velocity.X + 0.15f; } @@ -7295,29 +7287,29 @@ namespace CalamityMod.NPCs { npc.velocity.X = npc.velocity.X - 0.1f; } - if (npc.velocity.X > num319) + if (npc.velocity.X > maxHoverVel) { - npc.velocity.X = num319; + npc.velocity.X = maxHoverVel; } } if (npc.type == NPCID.Drippler) { - num319 = 1.5f; + maxHoverVel = 1.5f; } else { - num319 = 2.5f; + maxHoverVel = 2.5f; } if (CalamityWorld.death) { - num319 *= 1.25f; + maxHoverVel *= 1.25f; } - if (npc.directionY == -1 && npc.velocity.Y > -num319) + if (npc.directionY == -1 && npc.velocity.Y > -maxHoverVel) { npc.velocity.Y = npc.velocity.Y - 0.06f; - if (npc.velocity.Y > num319) + if (npc.velocity.Y > maxHoverVel) { npc.velocity.Y = npc.velocity.Y - 0.1f; } @@ -7325,15 +7317,15 @@ namespace CalamityMod.NPCs { npc.velocity.Y = npc.velocity.Y + 0.05f; } - if (npc.velocity.Y < -num319) + if (npc.velocity.Y < -maxHoverVel) { - npc.velocity.Y = -num319; + npc.velocity.Y = -maxHoverVel; } } - else if (npc.directionY == 1 && npc.velocity.Y < num319) + else if (npc.directionY == 1 && npc.velocity.Y < maxHoverVel) { npc.velocity.Y = npc.velocity.Y + 0.06f; - if (npc.velocity.Y < -num319) + if (npc.velocity.Y < -maxHoverVel) { npc.velocity.Y = npc.velocity.Y + 0.1f; } @@ -7341,9 +7333,9 @@ namespace CalamityMod.NPCs { npc.velocity.Y = npc.velocity.Y - 0.05f; } - if (npc.velocity.Y > num319) + if (npc.velocity.Y > maxHoverVel) { - npc.velocity.Y = num319; + npc.velocity.Y = maxHoverVel; } } @@ -7549,23 +7541,23 @@ namespace CalamityMod.NPCs #region Unicorn AI public static bool BuffedUnicornAI(NPC npc, Mod mod) { - int num = 30; - int num2 = 8; + int turnAroundDelay = 30; + int turnAroundDelayMult = 8; bool flag = false; - bool flag2 = false; - bool flag3 = false; + bool isRunning = false; + bool shouldTurnAround = false; if (npc.velocity.Y == 0f && ((npc.velocity.X > 0f && npc.direction < 0) || (npc.velocity.X < 0f && npc.direction > 0))) { - flag2 = true; + isRunning = true; npc.ai[3] += 1f; } if (npc.type == NPCID.Tumbleweed) { - num2 = 3; - bool flag4 = npc.velocity.Y == 0f; + turnAroundDelayMult = 3; + bool noYVelocity = npc.velocity.Y == 0f; for (int i = 0; i < Main.maxNPCs; i++) { if (i != npc.whoAmI && Main.npc[i].active && Main.npc[i].type == npc.type && Math.Abs(npc.position.X - Main.npc[i].position.X) + Math.Abs(npc.position.Y - Main.npc[i].position.Y) < (float)npc.width) @@ -7588,23 +7580,23 @@ namespace CalamityMod.NPCs } } } - if (flag4) + if (noYVelocity) { npc.velocity.Y = 0f; } } - if ((npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)num) | flag2) + if ((npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)turnAroundDelay) | isRunning) { npc.ai[3] += 1f; - flag3 = true; + shouldTurnAround = true; } else if (npc.ai[3] > 0f) { npc.ai[3] -= 1f; } - if (npc.ai[3] > (float)(num * num2)) + if (npc.ai[3] > (float)(turnAroundDelay * turnAroundDelayMult)) { npc.ai[3] = 0f; } @@ -7614,17 +7606,17 @@ namespace CalamityMod.NPCs npc.ai[3] = 0f; } - if (npc.ai[3] == (float)num) + if (npc.ai[3] == (float)turnAroundDelay) { npc.netUpdate = true; } - Vector2 vector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float arg_31B_0 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector.X; - float num3 = Main.player[npc.target].position.Y - vector.Y; - float num4 = (float)Math.Sqrt((double)(arg_31B_0 * arg_31B_0 + num3 * num3)); + Vector2 npcPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float targetXDist = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - npcPosition.X; + float targetYDist = Main.player[npc.target].position.Y - npcPosition.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); - if (num4 < 200f && !flag3) + if (targetDistance < 200f && !shouldTurnAround) { npc.ai[3] = 0f; } @@ -7632,20 +7624,20 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.StardustSpiderSmall) { npc.ai[1] += 1f; - bool flag5 = npc.ai[1] >= (CalamityWorld.death ? 60f : 120f); - if (!flag5 && npc.velocity.Y == 0f) + bool spawnTwinkle = npc.ai[1] >= (CalamityWorld.death ? 60f : 120f); + if (!spawnTwinkle && npc.velocity.Y == 0f) { for (int j = 0; j < Main.maxPlayers; j++) { if (Main.player[j].active && !Main.player[j].dead && Main.player[j].Distance(npc.Center) < 800f && Main.player[j].Center.Y < npc.Center.Y && Math.Abs(Main.player[j].Center.X - npc.Center.X) < 20f) { - flag5 = true; + spawnTwinkle = true; break; } } } - if (flag5 && Main.netMode != NetmodeID.MultiplayerClient) + if (spawnTwinkle && Main.netMode != NetmodeID.MultiplayerClient) { for (int k = 0; k < 3; k++) { @@ -7664,27 +7656,27 @@ namespace CalamityMod.NPCs npc.velocity.X = npc.velocity.X * 0.7f; if (npc.ai[1] < 30f) { - Vector2 vector2 = npc.Center + Vector2.UnitX * (float)npc.spriteDirection * -20f; - Dust arg_5A4_0 = Main.dust[Dust.NewDust(vector2, 0, 0, 242, 0f, 0f, 0, default(Color), 1f)]; - Vector2 vector3 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - arg_5A4_0.position = vector2 + vector3 * 20f; - arg_5A4_0.velocity = -vector3 * 2f; - arg_5A4_0.scale = 0.5f + vector3.X * (float)(-(float)npc.spriteDirection); - arg_5A4_0.fadeIn = 1f; - arg_5A4_0.noGravity = true; + Vector2 nebulaBeastDustRotation = npc.Center + Vector2.UnitX * (float)npc.spriteDirection * -20f; + Dust nebulaBeastDust = Main.dust[Dust.NewDust(nebulaBeastDustRotation, 0, 0, 242, 0f, 0f, 0, default(Color), 1f)]; + Vector2 nebulaBeastDustVelocity = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + nebulaBeastDust.position = nebulaBeastDustRotation + nebulaBeastDustVelocity * 20f; + nebulaBeastDust.velocity = -nebulaBeastDustVelocity * 2f; + nebulaBeastDust.scale = 0.5f + nebulaBeastDustVelocity.X * (float)(-(float)npc.spriteDirection); + nebulaBeastDust.fadeIn = 1f; + nebulaBeastDust.noGravity = true; } else if (npc.ai[1] == 30f) { for (int l = 0; l < 20; l++) { - Vector2 vector4 = npc.Center + Vector2.UnitX * (float)npc.spriteDirection * -20f; - Dust arg_68B_0 = Main.dust[Dust.NewDust(vector4, 0, 0, 242, 0f, 0f, 0, default(Color), 1f)]; - Vector2 vector5 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - arg_68B_0.position = vector4 + vector5 * 4f; - arg_68B_0.velocity = vector5 * 4f + Vector2.UnitX * Main.rand.NextFloat() * (float)npc.spriteDirection * -5f; - arg_68B_0.scale = 0.5f + vector5.X * (float)(-(float)npc.spriteDirection); - arg_68B_0.fadeIn = 1f; - arg_68B_0.noGravity = true; + Vector2 nebulaBeastDustRotation2 = npc.Center + Vector2.UnitX * (float)npc.spriteDirection * -20f; + Dust nebulaBeastDust2 = Main.dust[Dust.NewDust(nebulaBeastDustRotation2, 0, 0, 242, 0f, 0f, 0, default(Color), 1f)]; + Vector2 nebulaBeastDustVelocity2 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + nebulaBeastDust2.position = nebulaBeastDustRotation2 + nebulaBeastDustVelocity2 * 4f; + nebulaBeastDust2.velocity = nebulaBeastDustVelocity2 * 4f + Vector2.UnitX * Main.rand.NextFloat() * (float)npc.spriteDirection * -5f; + nebulaBeastDust2.scale = 0.5f + nebulaBeastDustVelocity2.X * (float)(-(float)npc.spriteDirection); + nebulaBeastDust2.fadeIn = 1f; + nebulaBeastDust2.noGravity = true; } } @@ -7695,8 +7687,8 @@ namespace CalamityMod.NPCs if (npc.ai[1] == 30f && Main.netMode != NetmodeID.MultiplayerClient) { - int num5 = Main.expertMode ? 35 : 50; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + (float)(npc.spriteDirection * -20), npc.Center.Y, (float)(npc.spriteDirection * -7), 0f, ProjectileID.NebulaSphere, num5, 0f, Main.myPlayer, (float)npc.target, 0f); + int nebulaBeastProjDamage = Main.expertMode ? 35 : 50; + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + (float)(npc.spriteDirection * -20), npc.Center.Y, (float)(npc.spriteDirection * -7), 0f, ProjectileID.NebulaSphere, nebulaBeastProjDamage, 0f, Main.myPlayer, (float)npc.target, 0f); } if (npc.ai[1] >= 60f) @@ -7708,14 +7700,14 @@ namespace CalamityMod.NPCs else { npc.ai[1] += 1f; - if (npc.ai[1] >= 180f && num4 < 500f && npc.velocity.Y == 0f) + if (npc.ai[1] >= 180f && targetDistance < 500f && npc.velocity.Y == 0f) { flag = true; npc.ai[1] = 0f; npc.ai[2] = 1f; npc.netUpdate = true; } - else if (npc.velocity.Y == 0f && num4 < 100f && Math.Abs(npc.velocity.X) > 3f && ((npc.Center.X < Main.player[npc.target].Center.X && npc.velocity.X > 0f) || (npc.Center.X > Main.player[npc.target].Center.X && npc.velocity.X < 0f))) + else if (npc.velocity.Y == 0f && targetDistance < 100f && Math.Abs(npc.velocity.X) > 3f && ((npc.Center.X < Main.player[npc.target].Center.X && npc.velocity.X > 0f) || (npc.Center.X > Main.player[npc.target].Center.X && npc.velocity.X < 0f))) { npc.velocity.Y = npc.velocity.Y - 6f; } @@ -7723,7 +7715,7 @@ namespace CalamityMod.NPCs } else if (npc.type == NPCID.Wolf || npc.type == NPCID.Hellhound || npc.type == ModContent.NPCType()) { - if (npc.velocity.Y == 0f && num4 < 100f && Math.Abs(npc.velocity.X) > 3f && ((npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) && npc.velocity.X > 0f) || (npc.position.X + (float)(npc.width / 2) > Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) && npc.velocity.X < 0f))) + if (npc.velocity.Y == 0f && targetDistance < 100f && Math.Abs(npc.velocity.X) > 3f && ((npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) && npc.velocity.X > 0f) || (npc.position.X + (float)(npc.width / 2) > Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) && npc.velocity.X < 0f))) { npc.velocity.Y -= 6f; } @@ -7734,7 +7726,7 @@ namespace CalamityMod.NPCs SoundEngine.PlaySound(SoundID.NPCHit11, npc.Center); } - if (npc.ai[3] < (float)num) + if (npc.ai[3] < (float)turnAroundDelay) { if ((npc.type == NPCID.Hellhound || npc.type == NPCID.HeadlessHorseman) && !Main.pumpkinMoon) { @@ -7774,12 +7766,12 @@ namespace CalamityMod.NPCs } } - float num6 = 9f; - float num7 = 0.1f; + float maxVelocity = 9f; + float acceleration = 0.1f; if (CalamityWorld.death) { - num6 *= 1.25f; - num7 *= 1.25f; + maxVelocity *= 1.25f; + acceleration *= 1.25f; } if (!flag && (npc.velocity.Y == 0f || npc.wet || (npc.velocity.X <= 0f && npc.direction < 0) || (npc.velocity.X >= 0f && npc.direction > 0))) @@ -7824,27 +7816,27 @@ namespace CalamityMod.NPCs { npc.velocity.X *= 0.9f; } - if (npc.velocity.X < -num6 || npc.velocity.X > num6) + if (npc.velocity.X < -maxVelocity || npc.velocity.X > maxVelocity) { if (npc.velocity.Y == 0f) { npc.velocity *= 0.8f; } } - else if (npc.velocity.X < num6 && npc.direction == 1) + else if (npc.velocity.X < maxVelocity && npc.direction == 1) { npc.velocity.X += 0.1f; - if (npc.velocity.X > num6) + if (npc.velocity.X > maxVelocity) { - npc.velocity.X = num6; + npc.velocity.X = maxVelocity; } } - else if (npc.velocity.X > -num6 && npc.direction == -1) + else if (npc.velocity.X > -maxVelocity && npc.direction == -1) { npc.velocity.X -= 0.1f; - if (npc.velocity.X < -num6) + if (npc.velocity.X < -maxVelocity) { - npc.velocity.X = -num6; + npc.velocity.X = -maxVelocity; } } } @@ -7854,7 +7846,7 @@ namespace CalamityMod.NPCs { npc.velocity.X *= 0.8f; } - num7 = 0.2f; + acceleration = 0.2f; } else if (npc.type == NPCID.NebulaBeast) { @@ -7862,8 +7854,8 @@ namespace CalamityMod.NPCs { npc.velocity.X *= 0.8f; } - num6 = 12f; - num7 = 0.2f; + maxVelocity = 12f; + acceleration = 0.2f; } else if (npc.type == NPCID.Tumbleweed) { @@ -7871,80 +7863,80 @@ namespace CalamityMod.NPCs { npc.velocity.X *= 0.9f; } - float num8 = MathHelper.Lerp(0.6f, 1f, Math.Abs(Main.windSpeedCurrent)) * (float)Math.Sign(Main.windSpeedCurrent); + float sandstormPush = MathHelper.Lerp(0.6f, 1f, Math.Abs(Main.windSpeedCurrent)) * (float)Math.Sign(Main.windSpeedCurrent); if (!Main.player[npc.target].ZoneSandstorm) { - num8 = 0f; + sandstormPush = 0f; } - num6 = 6f + num8 * (float)npc.direction * 4f; - num7 = 0.2f; + maxVelocity = 6f + sandstormPush * (float)npc.direction * 4f; + acceleration = 0.2f; } if (CalamityWorld.death) { - num6 *= 1.25f; - num7 *= 1.25f; + maxVelocity *= 1.25f; + acceleration *= 1.25f; } - if (npc.velocity.X < -num6 || npc.velocity.X > num6) + if (npc.velocity.X < -maxVelocity || npc.velocity.X > maxVelocity) { if (npc.velocity.Y == 0f) { npc.velocity *= 0.8f; } } - else if (npc.velocity.X < num6 && npc.direction == 1) + else if (npc.velocity.X < maxVelocity && npc.direction == 1) { - npc.velocity.X = npc.velocity.X + num7; - if (npc.velocity.X > num6) + npc.velocity.X = npc.velocity.X + acceleration; + if (npc.velocity.X > maxVelocity) { - npc.velocity.X = num6; + npc.velocity.X = maxVelocity; } } - else if (npc.velocity.X > -num6 && npc.direction == -1) + else if (npc.velocity.X > -maxVelocity && npc.direction == -1) { - npc.velocity.X = npc.velocity.X - num7; - if (npc.velocity.X < -num6) + npc.velocity.X = npc.velocity.X - acceleration; + if (npc.velocity.X < -maxVelocity) { - npc.velocity.X = -num6; + npc.velocity.X = -maxVelocity; } } } if (npc.velocity.Y >= 0f) { - int num9 = 0; + int faceDirection = 0; if (npc.velocity.X < 0f) { - num9 = -1; + faceDirection = -1; } if (npc.velocity.X > 0f) { - num9 = 1; + faceDirection = 1; } Vector2 position = npc.position; position.X += npc.velocity.X; - int num10 = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * num9)) / 16f); - int num11 = (int)((position.Y + (float)npc.height - 1f) / 16f); + int x = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * faceDirection)) / 16f); + int y = (int)((position.Y + (float)npc.height - 1f) / 16f); - if ((float)(num10 * 16) < position.X + (float)npc.width && (float)(num10 * 16 + 16) > position.X && ((Main.tile[num10, num11].HasUnactuatedTile && !Main.tile[num10, num11].TopSlope && !Main.tile[num10, num11 - 1].TopSlope && Main.tileSolid[(int)Main.tile[num10, num11].TileType] && !Main.tileSolidTop[(int)Main.tile[num10, num11].TileType]) || (Main.tile[num10, num11 - 1].IsHalfBlock && Main.tile[num10, num11 - 1].HasUnactuatedTile)) && (!Main.tile[num10, num11 - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num10, num11 - 1].TileType] || Main.tileSolidTop[(int)Main.tile[num10, num11 - 1].TileType] || (Main.tile[num10, num11 - 1].IsHalfBlock && (!Main.tile[num10, num11 - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num10, num11 - 4].TileType] || Main.tileSolidTop[(int)Main.tile[num10, num11 - 4].TileType]))) && (!Main.tile[num10, num11 - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num10, num11 - 2].TileType] || Main.tileSolidTop[(int)Main.tile[num10, num11 - 2].TileType]) && (!Main.tile[num10, num11 - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num10, num11 - 3].TileType] || Main.tileSolidTop[(int)Main.tile[num10, num11 - 3].TileType]) && (!Main.tile[num10 - num9, num11 - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num10 - num9, num11 - 3].TileType])) + if ((float)(x * 16) < position.X + (float)npc.width && (float)(x * 16 + 16) > position.X && ((Main.tile[x, y].HasUnactuatedTile && !Main.tile[x, y].TopSlope && !Main.tile[x, y - 1].TopSlope && Main.tileSolid[(int)Main.tile[x, y].TileType] && !Main.tileSolidTop[(int)Main.tile[x, y].TileType]) || (Main.tile[x, y - 1].IsHalfBlock && Main.tile[x, y - 1].HasUnactuatedTile)) && (!Main.tile[x, y - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 1].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 1].TileType] || (Main.tile[x, y - 1].IsHalfBlock && (!Main.tile[x, y - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 4].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 4].TileType]))) && (!Main.tile[x, y - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 2].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 2].TileType]) && (!Main.tile[x, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 3].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 3].TileType]) && (!Main.tile[x - faceDirection, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x - faceDirection, y - 3].TileType])) { - float num12 = (float)(num11 * 16); - if (Main.tile[num10, num11].IsHalfBlock) + float tilePixelPosition = (float)(y * 16); + if (Main.tile[x, y].IsHalfBlock) { - num12 += 8f; + tilePixelPosition += 8f; } - if (Main.tile[num10, num11 - 1].IsHalfBlock) + if (Main.tile[x, y - 1].IsHalfBlock) { - num12 -= 8f; + tilePixelPosition -= 8f; } - if (num12 < position.Y + (float)npc.height) + if (tilePixelPosition < position.Y + (float)npc.height) { - float num13 = position.Y + (float)npc.height - num12; - if ((double)num13 <= 16.1) + float percentageTileRisen = position.Y + (float)npc.height - tilePixelPosition; + if ((double)percentageTileRisen <= 16.1) { - npc.gfxOffY += npc.position.Y + (float)npc.height - num12; - npc.position.Y = num12 - (float)npc.height; - if (num13 < 9f) + npc.gfxOffY += npc.position.Y + (float)npc.height - tilePixelPosition; + npc.position.Y = tilePixelPosition - (float)npc.height; + if (percentageTileRisen < 9f) { npc.stepSpeed = 1f; } @@ -7959,23 +7951,22 @@ namespace CalamityMod.NPCs if (npc.velocity.Y == 0f) { - int num14 = (int)((npc.position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 2) * npc.direction) + npc.velocity.X * 5f) / 16f); - int num15 = (int)((npc.position.Y + (float)npc.height - 15f) / 16f); + int npcTileX = (int)((npc.position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 2) * npc.direction) + npc.velocity.X * 5f) / 16f); + int npcTileY = (int)((npc.position.Y + (float)npc.height - 15f) / 16f); - int num16 = npc.spriteDirection; + int spriteDirection = npc.spriteDirection; if (npc.type == NPCID.NebulaBeast || npc.type == NPCID.StardustSpiderSmall || npc.type == NPCID.Tumbleweed) { - num16 *= -1; + spriteDirection *= -1; } - if ((npc.velocity.X < 0f && num16 == -1) || (npc.velocity.X > 0f && num16 == 1)) + if ((npc.velocity.X < 0f && spriteDirection == -1) || (npc.velocity.X > 0f && spriteDirection == 1)) { - bool flag6 = npc.type == NPCID.StardustSpiderSmall || npc.type == NPCID.NebulaBeast; - float num17 = 3f; + bool pillarEnemy = npc.type == NPCID.StardustSpiderSmall || npc.type == NPCID.NebulaBeast; - if (Main.tile[num14, num15 - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num14, num15 - 2].TileType]) + if (Main.tile[npcTileX, npcTileY - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 2].TileType]) { - if (Main.tile[num14, num15 - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num14, num15 - 3].TileType]) + if (Main.tile[npcTileX, npcTileY - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 3].TileType]) { npc.velocity.Y = -10.5f; npc.netUpdate = true; @@ -7986,17 +7977,17 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } } - else if (Main.tile[num14, num15 - 1].HasUnactuatedTile && !Main.tile[num14, num15 - 1].TopSlope && Main.tileSolid[(int)Main.tile[num14, num15 - 1].TileType]) + else if (Main.tile[npcTileX, npcTileY - 1].HasUnactuatedTile && !Main.tile[npcTileX, npcTileY - 1].TopSlope && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 1].TileType]) { npc.velocity.Y = -9f; npc.netUpdate = true; } - else if (npc.position.Y + (float)npc.height - (float)(num15 * 16) > 20f && Main.tile[num14, num15].HasUnactuatedTile && !Main.tile[num14, num15].TopSlope && Main.tileSolid[(int)Main.tile[num14, num15].TileType]) + else if (npc.position.Y + (float)npc.height - (float)(npcTileY * 16) > 20f && Main.tile[npcTileX, npcTileY].HasUnactuatedTile && !Main.tile[npcTileX, npcTileY].TopSlope && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY].TileType]) { npc.velocity.Y = -7f; npc.netUpdate = true; } - else if ((npc.directionY < 0 || Math.Abs(npc.velocity.X) > num17) && (!flag6 || !Main.tile[num14, num15 + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num14, num15 + 1].TileType]) && (!Main.tile[num14, num15 + 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num14, num15 + 2].TileType]) && (!Main.tile[num14 + npc.direction, num15 + 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num14 + npc.direction, num15 + 3].TileType])) + else if ((npc.directionY < 0 || Math.Abs(npc.velocity.X) > 3f) && (!pillarEnemy || !Main.tile[npcTileX, npcTileY + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX, npcTileY + 1].TileType]) && (!Main.tile[npcTileX, npcTileY + 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX, npcTileY + 2].TileType]) && (!Main.tile[npcTileX + npc.direction, npcTileY + 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX + npc.direction, npcTileY + 3].TileType])) { npc.velocity.Y = -10f; npc.netUpdate = true; @@ -8004,18 +7995,18 @@ namespace CalamityMod.NPCs } } - if (npc.type == NPCID.NebulaBeast && Math.Abs(npc.velocity.X) >= num6 * 0.95f) + if (npc.type == NPCID.NebulaBeast && Math.Abs(npc.velocity.X) >= maxVelocity * 0.95f) { Rectangle hitbox = npc.Hitbox; for (int m = 0; m < 2; m++) { if (Main.rand.NextBool(3)) { - Dust expr_1B5F = Main.dust[Dust.NewDust(hitbox.TopLeft(), hitbox.Width, hitbox.Height, 242, 0f, 0f, 0, default(Color), 1f)]; - expr_1B5F.velocity = Vector2.Zero; - expr_1B5F.noGravity = true; - expr_1B5F.fadeIn = 1f; - expr_1B5F.scale = 0.5f + Main.rand.NextFloat(); + Dust nebulaBeastIdleDust = Main.dust[Dust.NewDust(hitbox.TopLeft(), hitbox.Width, hitbox.Height, 242, 0f, 0f, 0, default(Color), 1f)]; + nebulaBeastIdleDust.velocity = Vector2.Zero; + nebulaBeastIdleDust.noGravity = true; + nebulaBeastIdleDust.fadeIn = 1f; + nebulaBeastIdleDust.scale = 0.5f + Main.rand.NextFloat(); } } } @@ -8038,43 +8029,41 @@ namespace CalamityMod.NPCs npc.TargetClosest(true); } - bool flag31 = true; - - int num532 = 0; + int turtleFaceDirection = 0; if (npc.velocity.X < 0f) { - num532 = -1; + turtleFaceDirection = -1; } if (npc.velocity.X > 0f) { - num532 = 1; + turtleFaceDirection = 1; } Vector2 position = npc.position; position.X += npc.velocity.X; - int num533 = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * num532)) / 16f); - int num534 = (int)((position.Y + (float)npc.height - 1f) / 16f); + int turtleTileX = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * turtleFaceDirection)) / 16f); + int turtleTileY = (int)((position.Y + (float)npc.height - 1f) / 16f); - if ((float)(num533 * 16) < position.X + (float)npc.width && (float)(num533 * 16 + 16) > position.X && ((Main.tile[num533, num534].HasUnactuatedTile && !Main.tile[num533, num534].TopSlope && !Main.tile[num533, num534 - 1].TopSlope && ((Main.tileSolid[(int)Main.tile[num533, num534].TileType] && !Main.tileSolidTop[(int)Main.tile[num533, num534].TileType]) || (flag31 && Main.tileSolidTop[(int)Main.tile[num533, num534].TileType] && (!Main.tileSolid[(int)Main.tile[num533, num534 - 1].TileType] || !Main.tile[num533, num534 - 1].HasUnactuatedTile) && Main.tile[num533, num534].TileType != 16 && Main.tile[num533, num534].TileType != 18 && Main.tile[num533, num534].TileType != 134))) || (Main.tile[num533, num534 - 1].IsHalfBlock && Main.tile[num533, num534 - 1].HasUnactuatedTile)) && (!Main.tile[num533, num534 - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num533, num534 - 1].TileType] || Main.tileSolidTop[(int)Main.tile[num533, num534 - 1].TileType] || (Main.tile[num533, num534 - 1].IsHalfBlock && (!Main.tile[num533, num534 - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num533, num534 - 4].TileType] || Main.tileSolidTop[(int)Main.tile[num533, num534 - 4].TileType]))) && (!Main.tile[num533, num534 - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num533, num534 - 2].TileType] || Main.tileSolidTop[(int)Main.tile[num533, num534 - 2].TileType]) && (!Main.tile[num533, num534 - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num533, num534 - 3].TileType] || Main.tileSolidTop[(int)Main.tile[num533, num534 - 3].TileType]) && (!Main.tile[num533 - num532, num534 - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num533 - num532, num534 - 3].TileType] || Main.tileSolidTop[(int)Main.tile[num533 - num532, num534 - 3].TileType])) + if ((float)(turtleTileX * 16) < position.X + (float)npc.width && (float)(turtleTileX * 16 + 16) > position.X && ((Main.tile[turtleTileX, turtleTileY].HasUnactuatedTile && !Main.tile[turtleTileX, turtleTileY].TopSlope && !Main.tile[turtleTileX, turtleTileY - 1].TopSlope && ((Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY].TileType] && !Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY].TileType]) || (Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY].TileType] && (!Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY - 1].TileType] || !Main.tile[turtleTileX, turtleTileY - 1].HasUnactuatedTile) && Main.tile[turtleTileX, turtleTileY].TileType != 16 && Main.tile[turtleTileX, turtleTileY].TileType != 18 && Main.tile[turtleTileX, turtleTileY].TileType != 134))) || (Main.tile[turtleTileX, turtleTileY - 1].IsHalfBlock && Main.tile[turtleTileX, turtleTileY - 1].HasUnactuatedTile)) && (!Main.tile[turtleTileX, turtleTileY - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY - 1].TileType] || Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY - 1].TileType] || (Main.tile[turtleTileX, turtleTileY - 1].IsHalfBlock && (!Main.tile[turtleTileX, turtleTileY - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY - 4].TileType] || Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY - 4].TileType]))) && (!Main.tile[turtleTileX, turtleTileY - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY - 2].TileType] || Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY - 2].TileType]) && (!Main.tile[turtleTileX, turtleTileY - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY - 3].TileType] || Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY - 3].TileType]) && (!Main.tile[turtleTileX - turtleFaceDirection, turtleTileY - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[turtleTileX - turtleFaceDirection, turtleTileY - 3].TileType] || Main.tileSolidTop[(int)Main.tile[turtleTileX - turtleFaceDirection, turtleTileY - 3].TileType])) { - float num535 = (float)(num534 * 16); - if (Main.tile[num533, num534].IsHalfBlock) + float tilePixelPosition = (float)(turtleTileY * 16); + if (Main.tile[turtleTileX, turtleTileY].IsHalfBlock) { - num535 += 8f; + tilePixelPosition += 8f; } - if (Main.tile[num533, num534 - 1].IsHalfBlock) + if (Main.tile[turtleTileX, turtleTileY - 1].IsHalfBlock) { - num535 -= 8f; + tilePixelPosition -= 8f; } - if (num535 < position.Y + (float)npc.height) + if (tilePixelPosition < position.Y + (float)npc.height) { - float num536 = position.Y + (float)npc.height - num535; - if ((double)num536 <= 16.1) + float percentageTileRisen = position.Y + (float)npc.height - tilePixelPosition; + if ((double)percentageTileRisen <= 16.1) { - npc.gfxOffY += npc.position.Y + (float)npc.height - num535; - npc.position.Y = num535 - (float)npc.height; - if (num536 < 9f) + npc.gfxOffY += npc.position.Y + (float)npc.height - tilePixelPosition; + npc.position.Y = tilePixelPosition - (float)npc.height; + if (percentageTileRisen < 9f) { npc.stepSpeed = 0.75f; } @@ -8088,9 +8077,9 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.IceTortoise && Main.rand.NextBool(10)) { - int num537 = Dust.NewDust(npc.position, npc.width, npc.height, 67, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 1.5f); - Main.dust[num537].noGravity = true; - Dust dust = Main.dust[num537]; + int iceTortoiseDust = Dust.NewDust(npc.position, npc.width, npc.height, 67, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 1.5f); + Main.dust[iceTortoiseDust].noGravity = true; + Dust dust = Main.dust[iceTortoiseDust]; dust.velocity *= 0.2f; } @@ -8107,30 +8096,30 @@ namespace CalamityMod.NPCs npc.spriteDirection = npc.direction; - Vector2 vector66 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num538 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector66.X; - float num539 = Main.player[npc.target].position.Y - vector66.Y; - float num540 = (float)Math.Sqrt((double)(num538 * num538 + num539 * num539)); + Vector2 tortoisePosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float tortoiseTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - tortoisePosition.X; + float tortoiseTargetY = Main.player[npc.target].position.Y - tortoisePosition.Y; + float tortoiseTargetDist = (float)Math.Sqrt((double)(tortoiseTargetX * tortoiseTargetX + tortoiseTargetY * tortoiseTargetY)); - bool flag32 = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); + bool canHitPlayer = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); if (npc.type == NPCID.GiantShelly || npc.type == NPCID.GiantShelly2) { - if (num540 > 200f & flag32) + if (tortoiseTargetDist > 200f & canHitPlayer) { npc.ai[1] += 3f; } - if (num540 > 600f && (flag32 || npc.position.Y + (float)npc.height > Main.player[npc.target].position.Y - 200f)) + if (tortoiseTargetDist > 600f && (canHitPlayer || npc.position.Y + (float)npc.height > Main.player[npc.target].position.Y - 200f)) { npc.ai[1] += 6f; } } else { - if (num540 > 200f & flag32) + if (tortoiseTargetDist > 200f & canHitPlayer) { npc.ai[1] += 6f; } - if (num540 > 600f && (flag32 || npc.position.Y + (float)npc.height > Main.player[npc.target].position.Y - 200f)) + if (tortoiseTargetDist > 600f && (canHitPlayer || npc.position.Y + (float)npc.height > Main.player[npc.target].position.Y - 200f)) { npc.ai[1] += 15f; } @@ -8167,34 +8156,34 @@ namespace CalamityMod.NPCs if (npc.velocity.Y == 0f && Main.player[npc.target].position.Y < npc.position.Y + (float)npc.height) { - int num541; - int num542; + int tortoiseLeftTileX; + int tortoiseRightTileX; if (npc.direction > 0) { - num541 = (int)(((double)npc.position.X + (double)npc.width * 0.5) / 16.0); - num542 = num541 + 3; + tortoiseLeftTileX = (int)(((double)npc.position.X + (double)npc.width * 0.5) / 16.0); + tortoiseRightTileX = tortoiseLeftTileX + 3; } else { - num542 = (int)(((double)npc.position.X + (double)npc.width * 0.5) / 16.0); - num541 = num542 - 3; + tortoiseRightTileX = (int)(((double)npc.position.X + (double)npc.width * 0.5) / 16.0); + tortoiseLeftTileX = tortoiseRightTileX - 3; } - int num543 = (int)((npc.position.Y + (float)npc.height + 2f) / 16f) - 1; - int num544 = num543 + 4; - bool flag33 = false; - for (int num545 = num541; num545 <= num542; num545++) + int tortoiseBotTileY = (int)((npc.position.Y + (float)npc.height + 2f) / 16f) - 1; + int tortoiseTopTileY = tortoiseBotTileY + 4; + bool onSolidTile = false; + for (int x = tortoiseLeftTileX; x <= tortoiseRightTileX; x++) { - for (int num546 = num543; num546 <= num544; num546++) + for (int y = tortoiseBotTileY; y <= tortoiseTopTileY; y++) { - if (Main.tile[num545, num546] != null && Main.tile[num545, num546].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num545, num546].TileType]) + if (Main.tile[x, y] != null && Main.tile[x, y].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[x, y].TileType]) { - flag33 = true; + onSolidTile = true; } } } - if (!flag33) + if (!onSolidTile) { npc.direction *= -1; npc.velocity.X = 0.1f * (float)npc.direction; @@ -8203,57 +8192,57 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.GiantShelly || npc.type == NPCID.GiantShelly2) { - float num547 = 1f; - if (npc.velocity.X < -num547 || npc.velocity.X > num547) + float giantShellyMaxVel = 1f; + if (npc.velocity.X < -giantShellyMaxVel || npc.velocity.X > giantShellyMaxVel) { if (npc.velocity.Y == 0f) { npc.velocity *= 0.8f; } } - else if (npc.velocity.X < num547 && npc.direction == 1) + else if (npc.velocity.X < giantShellyMaxVel && npc.direction == 1) { npc.velocity.X = npc.velocity.X + 0.1f; - if (npc.velocity.X > num547) + if (npc.velocity.X > giantShellyMaxVel) { - npc.velocity.X = num547; + npc.velocity.X = giantShellyMaxVel; } } - else if (npc.velocity.X > -num547 && npc.direction == -1) + else if (npc.velocity.X > -giantShellyMaxVel && npc.direction == -1) { npc.velocity.X = npc.velocity.X - 0.1f; - if (npc.velocity.X < -num547) + if (npc.velocity.X < -giantShellyMaxVel) { - npc.velocity.X = -num547; + npc.velocity.X = -giantShellyMaxVel; } } } else { - float num548 = 2f; - if (num540 < 400f) + float tortoiseMaxVel = 2f; + if (tortoiseTargetDist < 400f) { - if (npc.velocity.X < -num548 || npc.velocity.X > num548) + if (npc.velocity.X < -tortoiseMaxVel || npc.velocity.X > tortoiseMaxVel) { if (npc.velocity.Y == 0f) { npc.velocity *= 0.8f; } } - else if (npc.velocity.X < num548 && npc.direction == 1) + else if (npc.velocity.X < tortoiseMaxVel && npc.direction == 1) { npc.velocity.X = npc.velocity.X + 0.1f; - if (npc.velocity.X > num548) + if (npc.velocity.X > tortoiseMaxVel) { - npc.velocity.X = num548; + npc.velocity.X = tortoiseMaxVel; } } - else if (npc.velocity.X > -num548 && npc.direction == -1) + else if (npc.velocity.X > -tortoiseMaxVel && npc.direction == -1) { npc.velocity.X = npc.velocity.X - 0.1f; - if (npc.velocity.X < -num548) + if (npc.velocity.X < -tortoiseMaxVel) { - npc.velocity.X = -num548; + npc.velocity.X = -tortoiseMaxVel; } } } @@ -8316,9 +8305,9 @@ namespace CalamityMod.NPCs { if (npc.type == NPCID.IceTortoise && Main.rand.Next(3) < 2) { - int num549 = Dust.NewDust(npc.position, npc.width, npc.height, 67, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 1.5f); - Main.dust[num549].noGravity = true; - Dust dust = Main.dust[num549]; + int iceTortoiseSpinDust = Dust.NewDust(npc.position, npc.width, npc.height, 67, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 1.5f); + Main.dust[iceTortoiseSpinDust].noGravity = true; + Dust dust = Main.dust[iceTortoiseSpinDust]; dust.velocity *= 0.2f; } @@ -8343,39 +8332,39 @@ namespace CalamityMod.NPCs npc.rotation += npc.ai[2] * (float)npc.direction; npc.ai[1] += 1f; - bool flag34 = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); - float num550 = 15f; - if (!flag34) + bool spinAttackCanHit = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); + float spinAttackSpeed = 15f; + if (!spinAttackCanHit) { - num550 = 6f; + spinAttackSpeed = 6f; } if (npc.type == NPCID.GiantShelly || npc.type == NPCID.GiantShelly2) { - num550 *= 0.75f; + spinAttackSpeed *= 0.75f; } - Vector2 vector67 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num551 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector67.X; - float num552 = Math.Abs(num551) * 0.2f; + Vector2 spinAttackPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float spinAttackTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - spinAttackPosition.X; + float absoluteSpinTargetX = Math.Abs(spinAttackTargetX) * 0.2f; if (npc.directionY > 0) { - num552 = 0f; + absoluteSpinTargetX = 0f; } - float num553 = Main.player[npc.target].position.Y - vector67.Y - num552; - float num554 = (float)Math.Sqrt((double)(num551 * num551 + num553 * num553)); + float spinAttackTargetY = Main.player[npc.target].position.Y - spinAttackPosition.Y - absoluteSpinTargetX; + float spinAttackTargetDist = (float)Math.Sqrt((double)(spinAttackTargetX * spinAttackTargetX + spinAttackTargetY * spinAttackTargetY)); npc.netUpdate = true; - num554 = num550 / num554; - num551 *= num554; - num553 *= num554; + spinAttackTargetDist = spinAttackSpeed / spinAttackTargetDist; + spinAttackTargetX *= spinAttackTargetDist; + spinAttackTargetY *= spinAttackTargetDist; - if (!flag34) + if (!spinAttackCanHit) { - num553 = -10f; + spinAttackTargetY = -10f; } - npc.velocity.X = num551; - npc.velocity.Y = num553; + npc.velocity.X = spinAttackTargetX; + npc.velocity.Y = spinAttackTargetY; npc.ai[3] = npc.velocity.X; } else @@ -8452,8 +8441,8 @@ namespace CalamityMod.NPCs if (Main.rand.Next(3) < 2) { - int num555 = Dust.NewDust(npc.Center - new Vector2(30f), 60, 60, 6, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 1.5f); - Dust dust = Main.dust[num555]; + int spinAttackDust = Dust.NewDust(npc.Center - new Vector2(30f), 60, 60, 6, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 1.5f); + Dust dust = Main.dust[spinAttackDust]; dust.noGravity = true; dust.velocity *= 0.2f; dust.fadeIn = 1f; @@ -8465,23 +8454,23 @@ namespace CalamityMod.NPCs if (npc.ai[3] == 1f) { Vector2 vector68 = npc.Center - new Vector2(50f); - for (int num556 = 0; num556 < 32; num556++) + for (int i = 0; i < 32; i++) { - int num557 = Dust.NewDust(vector68, 100, 100, 6, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[num557]; + int spinEndDust = Dust.NewDust(vector68, 100, 100, 6, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[spinEndDust]; dust.noGravity = true; dust.velocity *= 3f; - num557 = Dust.NewDust(vector68, 100, 100, 6, 0f, 0f, 100, default(Color), 1.5f); + spinEndDust = Dust.NewDust(vector68, 100, 100, 6, 0f, 0f, 100, default(Color), 1.5f); dust.velocity *= 2f; dust.noGravity = true; } if (Main.netMode != NetmodeID.Server) { - for (int num558 = 0; num558 < 4; num558++) + for (int j = 0; j < 4; j++) { - int num559 = Gore.NewGore(npc.GetSource_FromAI(), vector68 + new Vector2((float)(50 * Main.rand.Next(100)) / 100f, (float)(50 * Main.rand.Next(100)) / 100f) - Vector2.One * 10f, default(Vector2), Main.rand.Next(61, 64), 1f); - Gore gore = Main.gore[num559]; + int spinEndGore = Gore.NewGore(npc.GetSource_FromAI(), vector68 + new Vector2((float)(50 * Main.rand.Next(100)) / 100f, (float)(50 * Main.rand.Next(100)) / 100f) - Vector2.One * 10f, default(Vector2), Main.rand.Next(61, 64), 1f); + Gore gore = Main.gore[spinEndGore]; gore.velocity *= 0.3f; gore.velocity.X += (float)Main.rand.Next(-10, 11) * 0.05f; gore.velocity.Y += (float)Main.rand.Next(-10, 11) * 0.05f; @@ -8489,10 +8478,10 @@ namespace CalamityMod.NPCs } } - for (int num560 = 0; num560 < 5; num560++) + for (int k = 0; k < 5; k++) { - int num561 = Dust.NewDust(npc.position, npc.width, npc.height, 31, 0f, 0f, 100, default(Color), 1.5f); - Main.dust[num561].velocity *= Main.rand.NextFloat(); + int moreSpinEndDust = Dust.NewDust(npc.position, npc.width, npc.height, 31, 0f, 0f, 100, default(Color), 1.5f); + Main.dust[moreSpinEndDust].velocity *= Main.rand.NextFloat(); } npc.ai[3] += 1f; @@ -8507,35 +8496,35 @@ namespace CalamityMod.NPCs npc.netUpdate = true; npc.TargetClosest(true); - bool flag35 = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); - float num562 = 24f; - if (!flag35) + bool spinAboveCanHit = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); + float spinAboveSpeed = 24f; + if (!spinAboveCanHit) { - num562 = 10f; + spinAboveSpeed = 10f; } Vector2 vector69 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num563 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector69.X; - float num564 = Math.Abs(num563) * 0.2f; + float spinAboveTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector69.X; + float absoluteSpinAboveTargetX = Math.Abs(spinAboveTargetX) * 0.2f; if (npc.directionY > 0) { - num564 = 0f; + absoluteSpinAboveTargetX = 0f; } - float num565 = Main.player[npc.target].position.Y - vector69.Y - num564; - float num566 = (float)Math.Sqrt((double)(num563 * num563 + num565 * num565)); + float spinAboveTargetY = Main.player[npc.target].position.Y - vector69.Y - absoluteSpinAboveTargetX; + float spinAboveTargetDist = (float)Math.Sqrt((double)(spinAboveTargetX * spinAboveTargetX + spinAboveTargetY * spinAboveTargetY)); npc.netUpdate = true; - num566 = num562 / num566; - num563 *= num566; - num565 *= num566; + spinAboveTargetDist = spinAboveSpeed / spinAboveTargetDist; + spinAboveTargetX *= spinAboveTargetDist; + spinAboveTargetY *= spinAboveTargetDist; - if (!flag35) + if (!spinAboveCanHit) { - num565 = -12f; + spinAboveTargetY = -12f; } - npc.velocity.X = num563; - npc.velocity.Y = num565; + npc.velocity.X = spinAboveTargetX; + npc.velocity.Y = spinAboveTargetY; } else { @@ -8924,27 +8913,27 @@ namespace CalamityMod.NPCs npc.ai[0] += 10f; } - Vector2 vector72 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num585 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector72.X; - float num586 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector72.Y; - float num587 = (float)Math.Sqrt((double)(num585 * num585 + num586 * num586)); - float num588 = 400f / num587; + Vector2 herplingPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float herplingTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - herplingPosition.X; + float herplingTargetY = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - herplingPosition.Y; + float herplingTargetDist = (float)Math.Sqrt((double)(herplingTargetX * herplingTargetX + herplingTargetY * herplingTargetY)); + float herplingJumpHeight = 400f / herplingTargetDist; if (npc.type == NPCID.Derpling) { - num588 *= 5f; + herplingJumpHeight *= 5f; } else { - num588 *= 10f; + herplingJumpHeight *= 10f; } - if (num588 > 30f) + if (herplingJumpHeight > 30f) { - num588 = 30f; + herplingJumpHeight = 30f; } - npc.ai[0] += (float)((int)num588); + npc.ai[0] += (float)((int)herplingJumpHeight); if (npc.ai[0] >= 0f) { @@ -8961,7 +8950,7 @@ namespace CalamityMod.NPCs { npc.velocity.Y = -14f; npc.velocity.X = npc.velocity.X + 3f * (float)npc.direction; - if (num587 < 350f && num587 > 200f) + if (herplingTargetDist < 350f && herplingTargetDist > 200f) { npc.velocity.X = npc.velocity.X + (float)npc.direction; } @@ -8973,7 +8962,7 @@ namespace CalamityMod.NPCs { npc.velocity.Y = -10f; npc.velocity.X = npc.velocity.X + (float)(5 * npc.direction); - if (num587 < 350f && num587 > 200f) + if (herplingTargetDist < 350f && herplingTargetDist > 200f) { npc.velocity.X = npc.velocity.X + (float)npc.direction; } @@ -8985,7 +8974,7 @@ namespace CalamityMod.NPCs { npc.velocity.Y = -9f; npc.velocity.X = npc.velocity.X + (float)(2 * npc.direction); - if (num587 < 350f && num587 > 200f) + if (herplingTargetDist < 350f && herplingTargetDist > 200f) { npc.velocity.X = npc.velocity.X + (float)npc.direction; } @@ -8997,7 +8986,7 @@ namespace CalamityMod.NPCs { npc.velocity.Y = -5f; npc.velocity.X = npc.velocity.X + (float)(4 * npc.direction); - if (num587 < 350f && num587 > 200f) + if (herplingTargetDist < 350f && herplingTargetDist > 200f) { npc.velocity.X = npc.velocity.X + (float)npc.direction; } @@ -9019,10 +9008,10 @@ namespace CalamityMod.NPCs { if (npc.type == NPCID.Derpling) { - bool flag37 = false; + bool derplingDropOnTarget = false; if (npc.position.Y + (float)npc.height < Main.player[npc.target].position.Y && npc.position.X + (float)npc.width > Main.player[npc.target].position.X && npc.position.X < Main.player[npc.target].position.X + (float)Main.player[npc.target].width) { - flag37 = true; + derplingDropOnTarget = true; npc.velocity.X = npc.velocity.X * 0.9f; if (npc.velocity.Y < 0f) { @@ -9031,7 +9020,7 @@ namespace CalamityMod.NPCs } } - if (!flag37 && ((npc.direction == 1 && npc.velocity.X < 4f) || (npc.direction == -1 && npc.velocity.X > -4f))) + if (!derplingDropOnTarget && ((npc.direction == 1 && npc.velocity.X < 4f) || (npc.direction == -1 && npc.velocity.X > -4f))) { if ((npc.direction == -1 && (double)npc.velocity.X < 0.1) || (npc.direction == 1 && (double)npc.velocity.X > -0.1)) { @@ -9091,14 +9080,14 @@ namespace CalamityMod.NPCs { npc.velocity.Y = -6f; npc.netUpdate = true; - for (int num662 = 0; num662 < 15; num662++) + for (int i = 0; i < 15; i++) { - Dust dust2 = Dust.NewDustDirect(npc.position, npc.width, npc.height, 5); - Dust dust = dust2; + Dust eyeFishDust = Dust.NewDustDirect(npc.position, npc.width, npc.height, 5); + Dust dust = eyeFishDust; dust.velocity *= 0.5f; - dust2.scale = 1f + Main.rand.NextFloat() * 0.5f; - dust2.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f; - dust = dust2; + eyeFishDust.scale = 1f + Main.rand.NextFloat() * 0.5f; + eyeFishDust.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f; + dust = eyeFishDust; dust.velocity += npc.velocity * 0.5f; } } @@ -9109,33 +9098,33 @@ namespace CalamityMod.NPCs if (npc.alpha != 0) { - for (int num663 = 0; num663 < 2; num663++) + for (int j = 0; j < 2; j++) { - Dust dust3 = Dust.NewDustDirect(npc.position, npc.width, npc.height, 5); - Dust dust = dust3; + Dust eyeFishDust2 = Dust.NewDustDirect(npc.position, npc.width, npc.height, 5); + Dust dust = eyeFishDust2; dust.velocity *= 1f; - dust3.scale = 1f + Main.rand.NextFloat() * 0.5f; - dust3.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f; - dust = dust3; + eyeFishDust2.scale = 1f + Main.rand.NextFloat() * 0.5f; + eyeFishDust2.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f; + dust = eyeFishDust2; dust.velocity += npc.velocity * 0.3f; } } if (Main.rand.NextBool(3)) { - Dust dust4 = Dust.NewDustDirect(npc.position, npc.width, npc.height, 5); - Dust dust = dust4; + Dust eyeFishIdleDust = Dust.NewDustDirect(npc.position, npc.width, npc.height, 5); + Dust dust = eyeFishIdleDust; dust.velocity *= 0f; - dust4.alpha = 120; - dust4.scale = 0.7f + Main.rand.NextFloat() * 0.5f; - dust = dust4; + eyeFishIdleDust.alpha = 120; + eyeFishIdleDust.scale = 0.7f + Main.rand.NextFloat() * 0.5f; + dust = eyeFishIdleDust; dust.velocity += npc.velocity * 0.3f; } npc.position -= npc.netOffset; } - int num631 = npc.target; - int direction2 = npc.direction; + int fishTarget = npc.target; + int fishDirection = npc.direction; if (npc.target == Main.maxPlayers || (Main.player[npc.target].wet && npc.type != NPCID.EyeballFlyingFish) || Main.player[npc.target].dead || Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) { npc.ai[0] = 90f; @@ -9146,34 +9135,34 @@ namespace CalamityMod.NPCs npc.ai[0] -= 1f; npc.TargetClosest(true); } - if (npc.netUpdate && num631 == npc.target && direction2 == npc.direction) + if (npc.netUpdate && fishTarget == npc.target && fishDirection == npc.direction) { npc.netUpdate = false; } - float num632 = 0.05f; - float num633 = 0.01f; - float num634 = 6f; - float num635 = 3f; - float num636 = 30f; - float num637 = 100f; - float num638 = Math.Abs(npc.position.X + (float)(npc.width / 2) - (Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2))); - float num639 = Main.player[npc.target].position.Y - (float)(npc.height / 2); + float acceleration = 0.05f; + float verticalAcceleration = 0.01f; + float maxVelocity = 6f; + float maxYSpeed = 3f; + float turnAroundXDist = 30f; + float turnAroundYDist = 100f; + float targetXDist = Math.Abs(npc.position.X + (float)(npc.width / 2) - (Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2))); + float targetYDist = Main.player[npc.target].position.Y - (float)(npc.height / 2); if (npc.type == NPCID.FlyingAntlion || npc.type == NPCID.GiantFlyingAntlion) { - num632 = 0.09f; - num633 = 0.03f; - num634 = 9f; - num635 = 6f; - num636 = 40f; - num637 = 150f; - num639 = Main.player[npc.target].Center.Y - (float)(npc.height / 2); + acceleration = 0.09f; + verticalAcceleration = 0.03f; + maxVelocity = 9f; + maxYSpeed = 6f; + turnAroundXDist = 40f; + turnAroundYDist = 150f; + targetYDist = Main.player[npc.target].Center.Y - (float)(npc.height / 2); npc.rotation = npc.velocity.X * 0.1f; - int num; - for (int num640 = 0; num640 < Main.maxNPCs; num640 = num + 1) + int playerInc; + for (int p = 0; p < Main.maxNPCs; p = playerInc + 1) { - if (num640 != npc.whoAmI && Main.npc[num640].active && Main.npc[num640].type == npc.type && Math.Abs(npc.position.X - Main.npc[num640].position.X) + Math.Abs(npc.position.Y - Main.npc[num640].position.Y) < (float)npc.width) + if (p != npc.whoAmI && Main.npc[p].active && Main.npc[p].type == npc.type && Math.Abs(npc.position.X - Main.npc[p].position.X) + Math.Abs(npc.position.Y - Main.npc[p].position.Y) < (float)npc.width) { - if (npc.position.X < Main.npc[num640].position.X) + if (npc.position.X < Main.npc[p].position.X) { npc.velocity.X = npc.velocity.X - 0.05f; } @@ -9181,7 +9170,7 @@ namespace CalamityMod.NPCs { npc.velocity.X = npc.velocity.X + 0.05f; } - if (npc.position.Y < Main.npc[num640].position.Y) + if (npc.position.Y < Main.npc[p].position.Y) { npc.velocity.Y = npc.velocity.Y - 0.05f; } @@ -9190,34 +9179,34 @@ namespace CalamityMod.NPCs npc.velocity.Y = npc.velocity.Y + 0.05f; } } - num = num640; + playerInc = p; } } else if (npc.type == NPCID.EyeballFlyingFish) { - num632 = 0.16f; - num633 = 0.12f; - num634 = 9f; - num635 = 5f; - num636 = 0f; - num637 = 250f; - num639 = Main.player[npc.target].position.Y; + acceleration = 0.16f; + verticalAcceleration = 0.12f; + maxVelocity = 9f; + maxYSpeed = 5f; + turnAroundXDist = 0f; + turnAroundYDist = 250f; + targetYDist = Main.player[npc.target].position.Y; if (Main.dayTime) { - num639 = 0f; + targetYDist = 0f; npc.direction *= -1; } } if (CalamityWorld.death) { - num634 *= 1.25f; - num632 *= 1.25f; + maxVelocity *= 1.25f; + acceleration *= 1.25f; } if (npc.ai[0] <= 0f) { - num634 *= 0.8f; - num632 *= 0.7f; - num639 = npc.Center.Y + (float)(npc.directionY * 1000); + maxVelocity *= 0.8f; + acceleration *= 0.7f; + targetYDist = npc.Center.Y + (float)(npc.directionY * 1000); if (npc.velocity.X < 0f) { npc.direction = -1; @@ -9227,68 +9216,68 @@ namespace CalamityMod.NPCs npc.direction = 1; } } - if (num638 > num636) + if (targetXDist > turnAroundXDist) { - if (npc.direction == -1 && npc.velocity.X > -num634) + if (npc.direction == -1 && npc.velocity.X > -maxVelocity) { - npc.velocity.X = npc.velocity.X - num632; - if (npc.velocity.X > num634) + npc.velocity.X = npc.velocity.X - acceleration; + if (npc.velocity.X > maxVelocity) { - npc.velocity.X = npc.velocity.X - num632; + npc.velocity.X = npc.velocity.X - acceleration; } else if (npc.velocity.X > 0f) { - npc.velocity.X = npc.velocity.X - num632 / 2f; + npc.velocity.X = npc.velocity.X - acceleration / 2f; } - if (npc.velocity.X < -num634) + if (npc.velocity.X < -maxVelocity) { - npc.velocity.X = -num634; + npc.velocity.X = -maxVelocity; } } - else if (npc.direction == 1 && npc.velocity.X < num634) + else if (npc.direction == 1 && npc.velocity.X < maxVelocity) { - npc.velocity.X = npc.velocity.X + num632; - if (npc.velocity.X < -num634) + npc.velocity.X = npc.velocity.X + acceleration; + if (npc.velocity.X < -maxVelocity) { - npc.velocity.X = npc.velocity.X + num632; + npc.velocity.X = npc.velocity.X + acceleration; } else if (npc.velocity.X < 0f) { - npc.velocity.X = npc.velocity.X + num632 / 2f; + npc.velocity.X = npc.velocity.X + acceleration / 2f; } - if (npc.velocity.X > num634) + if (npc.velocity.X > maxVelocity) { - npc.velocity.X = num634; + npc.velocity.X = maxVelocity; } } } - if (num638 > num637) + if (targetXDist > turnAroundYDist) { - num639 -= num637 / 2f; + targetYDist -= turnAroundYDist / 2f; } - if (npc.position.Y < num639) + if (npc.position.Y < targetYDist) { - npc.velocity.Y = npc.velocity.Y + num633; + npc.velocity.Y = npc.velocity.Y + verticalAcceleration; if (npc.velocity.Y < 0f) { - npc.velocity.Y = npc.velocity.Y + num633; + npc.velocity.Y = npc.velocity.Y + verticalAcceleration; } } else { - npc.velocity.Y = npc.velocity.Y - num633; + npc.velocity.Y = npc.velocity.Y - verticalAcceleration; if (npc.velocity.Y > 0f) { - npc.velocity.Y = npc.velocity.Y - num633; + npc.velocity.Y = npc.velocity.Y - verticalAcceleration; } } - if (npc.velocity.Y < -num635) + if (npc.velocity.Y < -maxYSpeed) { - npc.velocity.Y = -num635; + npc.velocity.Y = -maxYSpeed; } - if (npc.velocity.Y > num635) + if (npc.velocity.Y > maxYSpeed) { - npc.velocity.Y = num635; + npc.velocity.Y = maxYSpeed; } if (npc.wet && npc.type != NPCID.EyeballFlyingFish) { @@ -9654,7 +9643,7 @@ namespace CalamityMod.NPCs { int dustSpawnChance = (npc.ai[0] == 2f) ? 2 : 1; int dustSpawnAreaSize = (npc.ai[0] == 2f) ? 30 : 20; - for (int num1055 = 0; num1055 < 2; num1055++) + for (int i = 0; i < 2; i++) { if (Main.rand.Next(3) < dustSpawnChance) { @@ -10079,62 +10068,62 @@ namespace CalamityMod.NPCs npc.ai[0] = 1f; return false; } - Vector2 value46 = Main.player[npc.target].Center - npc.Center; - value46.Y -= (float)(Main.player[npc.target].height / 4); - float attackTimeMax1 = value46.Length(); + Vector2 targetDirection = Main.player[npc.target].Center - npc.Center; + targetDirection.Y -= (float)(Main.player[npc.target].height / 4); + float attackTimeMax1 = targetDirection.Length(); if (attackTimeMax1 > (CalamityWorld.death ? 400f : 800f)) { npc.ai[0] = 2f; return false; } - Vector2 center30 = npc.Center; - center30.X = Main.player[npc.target].Center.X; - Vector2 vector243 = center30 - npc.Center; - if (vector243.Length() > 8f && Collision.CanHit(npc.Center, 1, 1, center30, 1, 1)) + Vector2 elementalCenter = npc.Center; + elementalCenter.X = Main.player[npc.target].Center.X; + Vector2 targetDistance = elementalCenter - npc.Center; + if (targetDistance.Length() > 8f && Collision.CanHit(npc.Center, 1, 1, elementalCenter, 1, 1)) { npc.ai[0] = 3f; - npc.ai[1] = center30.X; - npc.ai[2] = center30.Y; - Vector2 center31 = npc.Center; - center31.Y = Main.player[npc.target].Center.Y; - if (vector243.Length() > 8f && Collision.CanHit(npc.Center, 1, 1, center31, 1, 1) && Collision.CanHit(center31, 1, 1, Main.player[npc.target].position, 1, 1)) + npc.ai[1] = elementalCenter.X; + npc.ai[2] = elementalCenter.Y; + Vector2 elementalCenter2 = npc.Center; + elementalCenter2.Y = Main.player[npc.target].Center.Y; + if (targetDistance.Length() > 8f && Collision.CanHit(npc.Center, 1, 1, elementalCenter2, 1, 1) && Collision.CanHit(elementalCenter2, 1, 1, Main.player[npc.target].position, 1, 1)) { npc.ai[0] = 3f; - npc.ai[1] = center31.X; - npc.ai[2] = center31.Y; + npc.ai[1] = elementalCenter2.X; + npc.ai[2] = elementalCenter2.Y; } } else { - center30 = npc.Center; - center30.Y = Main.player[npc.target].Center.Y; - if ((center30 - npc.Center).Length() > 8f && Collision.CanHit(npc.Center, 1, 1, center30, 1, 1)) + elementalCenter = npc.Center; + elementalCenter.Y = Main.player[npc.target].Center.Y; + if ((elementalCenter - npc.Center).Length() > 8f && Collision.CanHit(npc.Center, 1, 1, elementalCenter, 1, 1)) { npc.ai[0] = 3f; - npc.ai[1] = center30.X; - npc.ai[2] = center30.Y; + npc.ai[1] = elementalCenter.X; + npc.ai[2] = elementalCenter.Y; } } if (npc.ai[0] == 0f) { npc.localAI[0] = 0f; - value46.Normalize(); - value46 *= 0.5f; - npc.velocity += value46; + targetDirection.Normalize(); + targetDirection *= 0.5f; + npc.velocity += targetDirection; npc.ai[0] = 4f; npc.ai[1] = 0f; } } else if (npc.ai[0] == 1f) { - Vector2 value47 = Main.player[npc.target].Center - npc.Center; - float attackTimeMax2 = value47.Length(); + Vector2 targetDirectionAgain = Main.player[npc.target].Center - npc.Center; + float attackTimeMax2 = targetDirectionAgain.Length(); float attackTimeMax3 = 2f; attackTimeMax3 += attackTimeMax2 / (CalamityWorld.death ? 160f : 180f); int attackTimeMax4 = 50; - value47.Normalize(); - value47 *= attackTimeMax3; - npc.velocity = (npc.velocity * (float)(attackTimeMax4 - 1) + value47) / (float)attackTimeMax4; + targetDirectionAgain.Normalize(); + targetDirectionAgain *= attackTimeMax3; + npc.velocity = (npc.velocity * (float)(attackTimeMax4 - 1) + targetDirectionAgain) / (float)attackTimeMax4; if (!Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) { npc.ai[0] = 0f; @@ -10144,13 +10133,13 @@ namespace CalamityMod.NPCs else if (npc.ai[0] == 2f) { npc.noTileCollide = true; - Vector2 value48 = Main.player[npc.target].Center - npc.Center; - float attackTimeMax5 = value48.Length(); + Vector2 targetDirection3 = Main.player[npc.target].Center - npc.Center; + float attackTimeMax5 = targetDirection3.Length(); float scaleFactor23 = CalamityWorld.death ? 3f : 2.5f; int attackTimeMax6 = 4; - value48.Normalize(); - value48 *= scaleFactor23; - npc.velocity = (npc.velocity * (float)(attackTimeMax6 - 1) + value48) / (float)attackTimeMax6; + targetDirection3.Normalize(); + targetDirection3 *= scaleFactor23; + npc.velocity = (npc.velocity * (float)(attackTimeMax6 - 1) + targetDirection3) / (float)attackTimeMax6; if (attackTimeMax5 < 600f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) { npc.ai[0] = 0f; @@ -10158,14 +10147,14 @@ namespace CalamityMod.NPCs } else if (npc.ai[0] == 3f) { - Vector2 value49 = new Vector2(npc.ai[1], npc.ai[2]); - Vector2 value50 = value49 - npc.Center; - float attackTimeMax7 = value50.Length(); + Vector2 elementalCenter3 = new Vector2(npc.ai[1], npc.ai[2]); + Vector2 elementalDirection = elementalCenter3 - npc.Center; + float attackTimeMax7 = elementalDirection.Length(); float attackTimeMax8 = 2f; float attackTimeMax9 = 3f; - value50.Normalize(); - value50 *= attackTimeMax8; - npc.velocity = (npc.velocity * (attackTimeMax9 - 1f) + value50) / attackTimeMax9; + elementalDirection.Normalize(); + elementalDirection *= attackTimeMax8; + npc.velocity = (npc.velocity * (attackTimeMax9 - 1f) + elementalDirection) / attackTimeMax9; if (npc.collideX || npc.collideY) { npc.ai[0] = 4f; @@ -10186,20 +10175,19 @@ namespace CalamityMod.NPCs { npc.velocity.Y = npc.velocity.Y * -0.8f; } - Vector2 value51; + Vector2 stationaryTargetDist; if (npc.velocity.X == 0f && npc.velocity.Y == 0f) { - value51 = Main.player[npc.target].Center - npc.Center; - value51.Y -= (float)(Main.player[npc.target].height / 4); - value51.Normalize(); - npc.velocity = value51 * 0.1f; + stationaryTargetDist = Main.player[npc.target].Center - npc.Center; + stationaryTargetDist.Y -= (float)(Main.player[npc.target].height / 4); + stationaryTargetDist.Normalize(); + npc.velocity = stationaryTargetDist * 0.1f; } float scaleFactor24 = CalamityWorld.death ? 2.5f : 2f; - float num1390 = 20f; - value51 = npc.velocity; - value51.Normalize(); - value51 *= scaleFactor24; - npc.velocity = (npc.velocity * (num1390 - 1f) + value51) / num1390; + stationaryTargetDist = npc.velocity; + stationaryTargetDist.Normalize(); + stationaryTargetDist *= scaleFactor24; + npc.velocity = (npc.velocity * 19f + stationaryTargetDist) / 20f; npc.ai[1] += 1f; if (npc.ai[1] > 180f) { @@ -10214,22 +10202,22 @@ namespace CalamityMod.NPCs if (npc.localAI[0] >= 5f && !Collision.SolidCollision(npc.position - new Vector2(10f, 10f), npc.width + 20, npc.height + 20)) { npc.localAI[0] = 0f; - Vector2 center32 = npc.Center; - center32.X = Main.player[npc.target].Center.X; - if (Collision.CanHit(npc.Center, 1, 1, center32, 1, 1) && Collision.CanHit(npc.Center, 1, 1, center32, 1, 1) && Collision.CanHit(Main.player[npc.target].Center, 1, 1, center32, 1, 1)) + Vector2 elementalCenter4 = npc.Center; + elementalCenter4.X = Main.player[npc.target].Center.X; + if (Collision.CanHit(npc.Center, 1, 1, elementalCenter4, 1, 1) && Collision.CanHit(npc.Center, 1, 1, elementalCenter4, 1, 1) && Collision.CanHit(Main.player[npc.target].Center, 1, 1, elementalCenter4, 1, 1)) { npc.ai[0] = 3f; - npc.ai[1] = center32.X; - npc.ai[2] = center32.Y; + npc.ai[1] = elementalCenter4.X; + npc.ai[2] = elementalCenter4.Y; return false; } - center32 = npc.Center; - center32.Y = Main.player[npc.target].Center.Y; - if (Collision.CanHit(npc.Center, 1, 1, center32, 1, 1) && Collision.CanHit(Main.player[npc.target].Center, 1, 1, center32, 1, 1)) + elementalCenter4 = npc.Center; + elementalCenter4.Y = Main.player[npc.target].Center.Y; + if (Collision.CanHit(npc.Center, 1, 1, elementalCenter4, 1, 1) && Collision.CanHit(Main.player[npc.target].Center, 1, 1, elementalCenter4, 1, 1)) { npc.ai[0] = 3f; - npc.ai[1] = center32.X; - npc.ai[2] = center32.Y; + npc.ai[1] = elementalCenter4.X; + npc.ai[2] = elementalCenter4.Y; } } } @@ -10250,50 +10238,50 @@ namespace CalamityMod.NPCs } else { - Vector2 vector204 = Main.player[npc.target].Center - npc.Center; - vector204.Y -= Main.player[npc.target].height / 4; - float num1324 = vector204.Length(); - if (num1324 > 800f) + Vector2 cellTargetDirection = Main.player[npc.target].Center - npc.Center; + cellTargetDirection.Y -= Main.player[npc.target].height / 4; + float cellTargetDist = cellTargetDirection.Length(); + if (cellTargetDist > 800f) { npc.ai[0] = 2f; } else { - Vector2 center31 = npc.Center; - center31.X = Main.player[npc.target].Center.X; - Vector2 vector205 = center31 - npc.Center; - if (vector205.Length() > 8f && Collision.CanHit(npc.Center, 1, 1, center31, 1, 1)) + Vector2 cellCenter = npc.Center; + cellCenter.X = Main.player[npc.target].Center.X; + Vector2 cellFaceDirection = cellCenter - npc.Center; + if (cellFaceDirection.Length() > 8f && Collision.CanHit(npc.Center, 1, 1, cellCenter, 1, 1)) { npc.ai[0] = 3f; - npc.ai[1] = center31.X; - npc.ai[2] = center31.Y; - Vector2 center32 = npc.Center; - center32.Y = Main.player[npc.target].Center.Y; - if (vector205.Length() > 8f && Collision.CanHit(npc.Center, 1, 1, center32, 1, 1) && Collision.CanHit(center32, 1, 1, Main.player[npc.target].position, 1, 1)) + npc.ai[1] = cellCenter.X; + npc.ai[2] = cellCenter.Y; + Vector2 cellCenter2 = npc.Center; + cellCenter2.Y = Main.player[npc.target].Center.Y; + if (cellFaceDirection.Length() > 8f && Collision.CanHit(npc.Center, 1, 1, cellCenter2, 1, 1) && Collision.CanHit(cellCenter2, 1, 1, Main.player[npc.target].position, 1, 1)) { npc.ai[0] = 3f; - npc.ai[1] = center32.X; - npc.ai[2] = center32.Y; + npc.ai[1] = cellCenter2.X; + npc.ai[2] = cellCenter2.Y; } } else { - center31 = npc.Center; - center31.Y = Main.player[npc.target].Center.Y; - if ((center31 - npc.Center).Length() > 8f && Collision.CanHit(npc.Center, 1, 1, center31, 1, 1)) + cellCenter = npc.Center; + cellCenter.Y = Main.player[npc.target].Center.Y; + if ((cellCenter - npc.Center).Length() > 8f && Collision.CanHit(npc.Center, 1, 1, cellCenter, 1, 1)) { npc.ai[0] = 3f; - npc.ai[1] = center31.X; - npc.ai[2] = center31.Y; + npc.ai[1] = cellCenter.X; + npc.ai[2] = cellCenter.Y; } } if (npc.ai[0] == 0f) { npc.localAI[0] = 0f; - vector204.Normalize(); - vector204 *= 0.5f; - npc.velocity += vector204; + cellTargetDirection.Normalize(); + cellTargetDirection *= 0.5f; + npc.velocity += cellTargetDirection; npc.ai[0] = 4f; npc.ai[1] = 0f; } @@ -10303,37 +10291,37 @@ namespace CalamityMod.NPCs else if (npc.ai[0] == 1f) { npc.rotation += npc.direction * 0.3f; - Vector2 value35 = Main.player[npc.target].Center - npc.Center; + Vector2 attacktargetDirection = Main.player[npc.target].Center - npc.Center; if (npc.type == NPCID.NebulaHeadcrab) - value35 = Main.player[npc.target].Top - npc.Center; + attacktargetDirection = Main.player[npc.target].Top - npc.Center; - float num1325 = value35.Length(); - float num1326 = CalamityWorld.death ? 9f : 7.5f; - num1326 += num1325 / 100f; - int num1327 = CalamityWorld.death ? 40 : 45; - value35.Normalize(); - value35 *= num1326; - npc.velocity = (npc.velocity * (num1327 - 1) + value35) / num1327; + float attackTargetDist = attacktargetDirection.Length(); + float attackVelocity = CalamityWorld.death ? 9f : 7.5f; + attackVelocity += attackTargetDist / 100f; + int attackVelocityMult = CalamityWorld.death ? 40 : 45; + attacktargetDirection.Normalize(); + attacktargetDirection *= attackVelocity; + npc.velocity = (npc.velocity * (attackVelocityMult - 1) + attacktargetDirection) / attackVelocityMult; if (!Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) { npc.ai[0] = 0f; npc.ai[1] = 0f; } - if (npc.type == NPCID.NebulaHeadcrab && num1325 < 40f && Main.player[npc.target].active && !Main.player[npc.target].dead) + if (npc.type == NPCID.NebulaHeadcrab && attackTargetDist < 40f && Main.player[npc.target].active && !Main.player[npc.target].dead) { - bool flag84 = true; - for (int num1328 = 0; num1328 < Main.maxNPCs; num1328++) + bool headcrabAttach = true; + for (int p = 0; p < Main.maxNPCs; p++) { - NPC nPC7 = Main.npc[num1328]; + NPC nPC7 = Main.npc[p]; if (nPC7.active && nPC7.type == npc.type && nPC7.ai[0] == 5f && nPC7.target == npc.target) { - flag84 = false; + headcrabAttach = false; break; } } - if (flag84) + if (headcrabAttach) { npc.Center = Main.player[npc.target].Top; npc.velocity = Vector2.Zero; @@ -10347,34 +10335,34 @@ namespace CalamityMod.NPCs { npc.rotation = npc.velocity.X * 0.1f; npc.noTileCollide = true; - Vector2 value36 = Main.player[npc.target].Center - npc.Center; - float num1329 = value36.Length(); - float num1330 = CalamityWorld.death ? 6f : 4.5f; - int num1331 = 2; - value36.Normalize(); - value36 *= num1330; - npc.velocity = (npc.velocity * (num1331 - 1) + value36) / num1331; - if (num1329 < 600f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) + Vector2 idleTargetDirection = Main.player[npc.target].Center - npc.Center; + float idleTargetDist = idleTargetDirection.Length(); + float idleVelocity = CalamityWorld.death ? 6f : 4.5f; + int idleVelocityMult = 2; + idleTargetDirection.Normalize(); + idleTargetDirection *= idleVelocity; + npc.velocity = (npc.velocity * (idleVelocityMult - 1) + idleTargetDirection) / idleVelocityMult; + if (idleTargetDist < 600f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) npc.ai[0] = 0f; } else if (npc.ai[0] == 3f) { npc.rotation = npc.velocity.X * 0.1f; - Vector2 value37 = new Vector2(npc.ai[1], npc.ai[2]); - Vector2 value38 = value37 - npc.Center; - float num1332 = value38.Length(); - float num1333 = CalamityWorld.death ? 4f : 3f; - float num1334 = 2f; - value38.Normalize(); - value38 *= num1333; - npc.velocity = (npc.velocity * (num1334 - 1f) + value38) / num1334; + Vector2 blockedCellCenter = new Vector2(npc.ai[1], npc.ai[2]); + Vector2 blockedCellDirection = blockedCellCenter - npc.Center; + float blockedTargetDist = blockedCellDirection.Length(); + float blockedVelocity = CalamityWorld.death ? 4f : 3f; + float blockedVelocityMult = 2f; + blockedCellDirection.Normalize(); + blockedCellDirection *= blockedVelocity; + npc.velocity = (npc.velocity * (blockedVelocityMult - 1f) + blockedCellDirection) / blockedVelocityMult; if (npc.collideX || npc.collideY) { npc.ai[0] = 4f; npc.ai[1] = 0f; } - if (num1332 < num1333 || num1332 > 800f || Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) + if (blockedTargetDist < blockedVelocity || blockedTargetDist > 800f || Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) npc.ai[0] = 0f; } else if (npc.ai[0] == 4f) @@ -10386,21 +10374,21 @@ namespace CalamityMod.NPCs if (npc.collideY) npc.velocity.Y *= -0.8f; - Vector2 value39; + Vector2 smolCellDirection; if (npc.velocity.X == 0f && npc.velocity.Y == 0f) { - value39 = Main.player[npc.target].Center - npc.Center; - value39.Y -= Main.player[npc.target].height / 4; - value39.Normalize(); - npc.velocity = value39 * 0.1f; + smolCellDirection = Main.player[npc.target].Center - npc.Center; + smolCellDirection.Y -= Main.player[npc.target].height / 4; + smolCellDirection.Normalize(); + npc.velocity = smolCellDirection * 0.1f; } - float num1335 = CalamityWorld.death ? 4f : 3f; - float num1336 = CalamityWorld.death ? 16f : 18f; - value39 = npc.velocity; - value39.Normalize(); - value39 *= num1335; - npc.velocity = (npc.velocity * (num1336 - 1f) + value39) / num1336; + float smolCellVelocity = CalamityWorld.death ? 4f : 3f; + float smolCellVelocityMult = CalamityWorld.death ? 16f : 18f; + smolCellDirection = npc.velocity; + smolCellDirection.Normalize(); + smolCellDirection *= smolCellVelocity; + npc.velocity = (npc.velocity * (smolCellVelocityMult - 1f) + smolCellDirection) / smolCellVelocityMult; npc.ai[1] += 1f; if (npc.ai[1] > 180f) { @@ -10415,23 +10403,23 @@ namespace CalamityMod.NPCs if (npc.localAI[0] >= 5f && !Collision.SolidCollision(npc.position - new Vector2(10f, 10f), npc.width + 20, npc.height + 20)) { npc.localAI[0] = 0f; - Vector2 center33 = npc.Center; - center33.X = Main.player[npc.target].Center.X; - if (Collision.CanHit(npc.Center, 1, 1, center33, 1, 1) && Collision.CanHit(npc.Center, 1, 1, center33, 1, 1) && Collision.CanHit(Main.player[npc.target].Center, 1, 1, center33, 1, 1)) + Vector2 cellCentered = npc.Center; + cellCentered.X = Main.player[npc.target].Center.X; + if (Collision.CanHit(npc.Center, 1, 1, cellCentered, 1, 1) && Collision.CanHit(npc.Center, 1, 1, cellCentered, 1, 1) && Collision.CanHit(Main.player[npc.target].Center, 1, 1, cellCentered, 1, 1)) { npc.ai[0] = 3f; - npc.ai[1] = center33.X; - npc.ai[2] = center33.Y; + npc.ai[1] = cellCentered.X; + npc.ai[2] = cellCentered.Y; } else { - center33 = npc.Center; - center33.Y = Main.player[npc.target].Center.Y; - if (Collision.CanHit(npc.Center, 1, 1, center33, 1, 1) && Collision.CanHit(Main.player[npc.target].Center, 1, 1, center33, 1, 1)) + cellCentered = npc.Center; + cellCentered.Y = Main.player[npc.target].Center.Y; + if (Collision.CanHit(npc.Center, 1, 1, cellCentered, 1, 1) && Collision.CanHit(Main.player[npc.target].Center, 1, 1, cellCentered, 1, 1)) { npc.ai[0] = 3f; - npc.ai[1] = center33.X; - npc.ai[2] = center33.Y; + npc.ai[1] = cellCentered.X; + npc.ai[2] = cellCentered.Y; } } } @@ -10458,16 +10446,16 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.StardustCellBig) { npc.rotation = 0f; - for (int num1337 = 0; num1337 < Main.maxNPCs; num1337++) + for (int r = 0; r < Main.maxNPCs; r++) { - if (num1337 != npc.whoAmI && Main.npc[num1337].active && Main.npc[num1337].type == npc.type && Math.Abs(npc.position.X - Main.npc[num1337].position.X) + Math.Abs(npc.position.Y - Main.npc[num1337].position.Y) < npc.width) + if (r != npc.whoAmI && Main.npc[r].active && Main.npc[r].type == npc.type && Math.Abs(npc.position.X - Main.npc[r].position.X) + Math.Abs(npc.position.Y - Main.npc[r].position.Y) < npc.width) { - if (npc.position.X < Main.npc[num1337].position.X) + if (npc.position.X < Main.npc[r].position.X) npc.velocity.X -= 0.05f; else npc.velocity.X += 0.05f; - if (npc.position.Y < Main.npc[num1337].position.Y) + if (npc.position.Y < Main.npc[r].position.Y) npc.velocity.Y -= 0.05f; else npc.velocity.Y += 0.05f; @@ -10481,16 +10469,16 @@ namespace CalamityMod.NPCs npc.hide = npc.ai[0] == 5f; npc.rotation = npc.velocity.X * 0.1f; - for (int num1338 = 0; num1338 < Main.maxNPCs; num1338++) + for (int s = 0; s < Main.maxNPCs; s++) { - if (num1338 != npc.whoAmI && Main.npc[num1338].active && Main.npc[num1338].type == npc.type && Math.Abs(npc.position.X - Main.npc[num1338].position.X) + Math.Abs(npc.position.Y - Main.npc[num1338].position.Y) < npc.width) + if (s != npc.whoAmI && Main.npc[s].active && Main.npc[s].type == npc.type && Math.Abs(npc.position.X - Main.npc[s].position.X) + Math.Abs(npc.position.Y - Main.npc[s].position.Y) < npc.width) { - if (npc.position.X < Main.npc[num1338].position.X) + if (npc.position.X < Main.npc[s].position.X) npc.velocity.X -= 0.05f; else npc.velocity.X += 0.05f; - if (npc.position.Y < Main.npc[num1338].position.Y) + if (npc.position.Y < Main.npc[s].position.Y) npc.velocity.Y -= 0.05f; else npc.velocity.Y += 0.05f; @@ -10516,34 +10504,33 @@ namespace CalamityMod.NPCs npc.noTileCollide = true; npc.knockBackResist = 0f; - for (int num1339 = 0; num1339 < Main.maxNPCs; num1339++) + for (int i = 0; i < Main.maxNPCs; i++) { - if (num1339 == npc.whoAmI || !Main.npc[num1339].active || Main.npc[num1339].type != npc.type) + if (i == npc.whoAmI || !Main.npc[i].active || Main.npc[i].type != npc.type) continue; - Vector2 vector206 = Main.npc[num1339].Center - npc.Center; - if (!(vector206.Length() < 50f)) + Vector2 targetDirection = Main.npc[i].Center - npc.Center; + if (!(targetDirection.Length() < 50f)) continue; - vector206.Normalize(); - if (vector206.X == 0f && vector206.Y == 0f) + targetDirection.Normalize(); + if (targetDirection.X == 0f && targetDirection.Y == 0f) { - if (num1339 > npc.whoAmI) - vector206.X = 1f; + if (i > npc.whoAmI) + targetDirection.X = 1f; else - vector206.X = -1f; + targetDirection.X = -1f; } - vector206 *= 0.4f; - npc.velocity -= vector206; - NPC nPC = Main.npc[num1339]; - nPC.velocity += vector206; + targetDirection *= 0.4f; + npc.velocity -= targetDirection; + NPC nPC = Main.npc[i]; + nPC.velocity += targetDirection; } if (npc.type == NPCID.ShadowFlameApparition) { - float num1340 = 120f; - if (npc.localAI[0] < num1340) + if (npc.localAI[0] < 120f) { if (npc.localAI[0] == 0f) { @@ -10555,23 +10542,23 @@ namespace CalamityMod.NPCs npc.velocity.X -= 2f; npc.position += npc.netOffset; - for (int num1341 = 0; num1341 < 20; num1341++) + for (int j = 0; j < 20; j++) { - Vector2 center34 = npc.Center; - center34.Y -= 18f; - Vector2 vector207 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - vector207.Normalize(); - vector207 *= Main.rand.Next(0, 100) * 0.1f; - center34 += vector207; - vector207.Normalize(); - vector207 *= Main.rand.Next(50, 90) * 0.2f; - int num1342 = Dust.NewDust(center34, 1, 1, 27); - Main.dust[num1342].velocity = -vector207 * 0.3f; - Main.dust[num1342].alpha = 100; + Vector2 apparitionCenter = npc.Center; + apparitionCenter.Y -= 18f; + Vector2 apparitionRandVelocity = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + apparitionRandVelocity.Normalize(); + apparitionRandVelocity *= Main.rand.Next(0, 100) * 0.1f; + apparitionCenter += apparitionRandVelocity; + apparitionRandVelocity.Normalize(); + apparitionRandVelocity *= Main.rand.Next(50, 90) * 0.2f; + int shadowflameDust = Dust.NewDust(apparitionCenter, 1, 1, 27); + Main.dust[shadowflameDust].velocity = -apparitionRandVelocity * 0.3f; + Main.dust[shadowflameDust].alpha = 100; if (Main.rand.NextBool()) { - Main.dust[num1342].noGravity = true; - Dust dust = Main.dust[num1342]; + Main.dust[shadowflameDust].noGravity = true; + Dust dust = Main.dust[shadowflameDust]; dust.scale += 0.3f; } } @@ -10580,20 +10567,20 @@ namespace CalamityMod.NPCs } npc.localAI[0] += 1f; - float num1343 = 1f - npc.localAI[0] / num1340; - float num1344 = num1343 * 20f; - for (int num1345 = 0; num1345 < num1344; num1345++) + float localAIDustControl = 1f - npc.localAI[0] / 120f; + float dustAmt = localAIDustControl * 20f; + for (int k = 0; k < dustAmt; k++) { if (Main.rand.NextBool(5)) { npc.position += npc.netOffset; - int num1346 = Dust.NewDust(npc.position, npc.width, npc.height, 27); - Main.dust[num1346].alpha = 100; - Dust dust = Main.dust[num1346]; + int idleShadowflameDust = Dust.NewDust(npc.position, npc.width, npc.height, 27); + Main.dust[idleShadowflameDust].alpha = 100; + Dust dust = Main.dust[idleShadowflameDust]; dust.velocity *= 0.3f; - dust = Main.dust[num1346]; + dust = Main.dust[idleShadowflameDust]; dust.velocity += npc.velocity * 0.75f; - Main.dust[num1346].noGravity = true; + Main.dust[idleShadowflameDust].noGravity = true; npc.position -= npc.netOffset; } } @@ -10602,8 +10589,7 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.AncientCultistSquidhead) { - float num1347 = 120f; - if (npc.localAI[0] < num1347) + if (npc.localAI[0] < 120f) { if (npc.localAI[0] == 0f) { @@ -10616,13 +10602,13 @@ namespace CalamityMod.NPCs } npc.localAI[0] += 1f; - int num1348 = 10; - for (int num1349 = 0; num1349 < 2; num1349++) + int dustPosition = 10; + for (int l = 0; l < 2; l++) { npc.position += npc.netOffset; - int num1350 = Dust.NewDust(npc.position - new Vector2(num1348), npc.width + num1348 * 2, npc.height + num1348 * 2, 228, 0f, 0f, 100, default(Color), 2f); - Main.dust[num1350].noGravity = true; - Main.dust[num1350].noLight = true; + int visionDust = Dust.NewDust(npc.position - new Vector2(dustPosition), npc.width + dustPosition * 2, npc.height + dustPosition * 2, 228, 0f, 0f, 100, default(Color), 2f); + Main.dust[visionDust].noGravity = true; + Main.dust[visionDust].noLight = true; npc.position -= npc.netOffset; } } @@ -10637,44 +10623,44 @@ namespace CalamityMod.NPCs else if (npc.ai[0] == 1f) { npc.TargetClosest(); - float num1351 = 0.5f; - float num1352 = 10f; - float num1353 = 4f; - float num1354 = 550f; - float num1355 = 3f; + float xVelocityMult1 = 0.5f; + float maxXVelocity1 = 10f; + float maxYVelocity1 = 4f; + float turnAroundDist1 = 550f; + float yVelocityMult1 = 3f; if (npc.type == NPCID.AncientCultistSquidhead) { - num1351 = 0.8f; - num1352 = 16f; - num1354 = 440f; - num1353 = 6f; + xVelocityMult1 = 0.8f; + maxXVelocity1 = 16f; + turnAroundDist1 = 440f; + maxYVelocity1 = 6f; } if (CalamityWorld.death) { - num1351 *= 1.25f; - num1352 *= 1.25f; - num1354 *= 0.9f; - num1355 -= 1f; + xVelocityMult1 *= 1.25f; + maxXVelocity1 *= 1.25f; + turnAroundDist1 *= 0.9f; + yVelocityMult1 -= 1f; } - npc.velocity.X += npc.ai[1] * num1351; - if (npc.velocity.X > num1352) - npc.velocity.X = num1352; + npc.velocity.X += npc.ai[1] * xVelocityMult1; + if (npc.velocity.X > maxXVelocity1) + npc.velocity.X = maxXVelocity1; - if (npc.velocity.X < 0f - num1352) - npc.velocity.X = 0f - num1352; + if (npc.velocity.X < 0f - maxXVelocity1) + npc.velocity.X = 0f - maxXVelocity1; - float num1356 = Main.player[npc.target].Center.Y - npc.Center.Y; - if (Math.Abs(num1356) > num1353) - num1355 = CalamityWorld.death ? 10f : 12f; + float targetYDist1 = Main.player[npc.target].Center.Y - npc.Center.Y; + if (Math.Abs(targetYDist1) > maxYVelocity1) + yVelocityMult1 = CalamityWorld.death ? 10f : 12f; - if (num1356 > num1353) - num1356 = num1353; - else if (num1356 < 0f - num1353) - num1356 = 0f - num1353; + if (targetYDist1 > maxYVelocity1) + targetYDist1 = maxYVelocity1; + else if (targetYDist1 < 0f - maxYVelocity1) + targetYDist1 = 0f - maxYVelocity1; - npc.velocity.Y = (npc.velocity.Y * (num1355 - 1f) + num1356) / num1355; - if ((npc.ai[1] > 0f && Main.player[npc.target].Center.X - npc.Center.X < 0f - num1354) || (npc.ai[1] < 0f && Main.player[npc.target].Center.X - npc.Center.X > num1354)) + npc.velocity.Y = (npc.velocity.Y * (yVelocityMult1 - 1f) + targetYDist1) / yVelocityMult1; + if ((npc.ai[1] > 0f && Main.player[npc.target].Center.X - npc.Center.X < 0f - turnAroundDist1) || (npc.ai[1] < 0f && Main.player[npc.target].Center.X - npc.Center.X > turnAroundDist1)) { npc.ai[0] = 2f; npc.ai[1] = 0f; @@ -10686,25 +10672,25 @@ namespace CalamityMod.NPCs } else if (npc.ai[0] == 2f) { - float num1357 = 0.6f; - float num1358 = 0.93f; - float num1359 = 7f; + float decelYVelocityMult = 0.6f; + float deceleration = 0.93f; + float decelerationDist = 7f; if (npc.type == NPCID.AncientCultistSquidhead) { - num1357 = 0.45f; - num1359 = 10f; - num1358 = 0.87f; + decelYVelocityMult = 0.45f; + decelerationDist = 10f; + deceleration = 0.87f; } if (CalamityWorld.death) { - num1357 *= 1.25f; - num1358 *= 0.9f; - num1359 *= 1.25f; + decelYVelocityMult *= 1.25f; + deceleration *= 0.9f; + decelerationDist *= 1.25f; } - npc.velocity.Y += npc.ai[1] * num1357; - if (npc.velocity.Length() > num1359) - npc.velocity *= num1358; + npc.velocity.Y += npc.ai[1] * decelYVelocityMult; + if (npc.velocity.Length() > decelerationDist) + npc.velocity *= deceleration; if (npc.velocity.X > -1f && npc.velocity.X < 1f) { @@ -10715,33 +10701,33 @@ namespace CalamityMod.NPCs } else if (npc.ai[0] == 3f) { - float num1360 = 0.6f; - float num1361 = 0.3f; - float num1362 = 7f; - float num1363 = 0.93f; + float xVelocityMult3 = 0.6f; + float yAlignSpeed = 0.3f; + float decelerationDist3 = 7f; + float deceleration3 = 0.93f; if (npc.type == NPCID.AncientCultistSquidhead) { - num1360 = 0.8f; - num1361 = 0.45f; - num1362 = 9f; - num1363 = 0.87f; + xVelocityMult3 = 0.8f; + yAlignSpeed = 0.45f; + decelerationDist3 = 9f; + deceleration3 = 0.87f; } if (CalamityWorld.death) { - num1360 *= 1.25f; - num1361 *= 1.25f; - num1362 *= 1.25f; - num1363 *= 0.9f; + xVelocityMult3 *= 1.25f; + yAlignSpeed *= 1.25f; + decelerationDist3 *= 1.25f; + deceleration3 *= 0.9f; } - npc.velocity.X += npc.ai[1] * num1360; + npc.velocity.X += npc.ai[1] * xVelocityMult3; if (npc.Center.Y > Main.player[npc.target].Center.Y) - npc.velocity.Y -= num1361; + npc.velocity.Y -= yAlignSpeed; else - npc.velocity.Y += num1361; + npc.velocity.Y += yAlignSpeed; - if (npc.velocity.Length() > num1362) - npc.velocity *= num1363; + if (npc.velocity.Length() > decelerationDist3) + npc.velocity *= deceleration3; if (npc.velocity.Y > -1f && npc.velocity.Y < 1f) { @@ -10753,12 +10739,12 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.AncientCultistSquidhead) { - int num1364 = 10; + int squidDustVelocity = 10; npc.position += npc.netOffset; - int num1366 = Dust.NewDust(npc.position - new Vector2(num1364), npc.width + num1364 * 2, npc.height + num1364 * 2, 228, 0f, 0f, 100, default(Color), 2f); - Main.dust[num1366].noGravity = true; - Main.dust[num1366].noLight = true; + int squidDust = Dust.NewDust(npc.position - new Vector2(squidDustVelocity), npc.width + squidDustVelocity * 2, npc.height + squidDustVelocity * 2, 228, 0f, 0f, 100, default(Color), 2f); + Main.dust[squidDust].noGravity = true; + Main.dust[squidDust].noLight = true; npc.position -= npc.netOffset; } @@ -10791,8 +10777,8 @@ namespace CalamityMod.NPCs if (npc.ai[0] == 0f) { npc.TargetClosest(); - Vector2 vector208 = Main.player[npc.target].Center - npc.Center; - if (Main.netMode != NetmodeID.MultiplayerClient && (npc.velocity.X != 0f || npc.velocity.Y > 100f || npc.justHit || vector208.Length() < 80f)) + Vector2 mimicTargetDirection = Main.player[npc.target].Center - npc.Center; + if (Main.netMode != NetmodeID.MultiplayerClient && (npc.velocity.X != 0f || npc.velocity.Y > 100f || npc.justHit || mimicTargetDirection.Length() < 80f)) { npc.ai[0] = 1f; npc.ai[1] = 0f; @@ -10811,8 +10797,8 @@ namespace CalamityMod.NPCs } else if (npc.ai[0] == 2f) { - Vector2 vector209 = Main.player[npc.target].Center - npc.Center; - if (Main.netMode != NetmodeID.MultiplayerClient && vector209.Length() > 600f) + Vector2 mimicTargetDirection2 = Main.player[npc.target].Center - npc.Center; + if (Main.netMode != NetmodeID.MultiplayerClient && mimicTargetDirection2.Length() > 600f) { npc.ai[0] = 5f; npc.ai[1] = 0f; @@ -10826,25 +10812,25 @@ namespace CalamityMod.NPCs npc.TargetClosest(); npc.velocity.X *= 0.85f; npc.ai[1] += 1f; - float num1367 = 10f + (CalamityWorld.death ? 10f : 20f) * (npc.life / (float)npc.lifeMax); - float num1368 = 5f + (CalamityWorld.death ? 7f : 5f) * (1f - npc.life / (float)npc.lifeMax); - float num1369 = CalamityWorld.death ? 7f : 5f; + float jumpDelay = 10f + (CalamityWorld.death ? 10f : 20f) * (npc.life / (float)npc.lifeMax); + float jumpXVelocity = 5f + (CalamityWorld.death ? 7f : 5f) * (1f - npc.life / (float)npc.lifeMax); + float jumpYVelocity = CalamityWorld.death ? 7f : 5f; if (!Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - num1369 += 2f; + jumpYVelocity += 2f; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] > num1367) + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] > jumpDelay) { npc.ai[3] += 1f; if (npc.ai[3] >= 3f) { npc.ai[3] = 0f; - num1369 *= 2f; - num1368 /= 2f; + jumpYVelocity *= 2f; + jumpXVelocity /= 2f; } npc.ai[1] = 0f; - npc.velocity.Y -= num1369; - npc.velocity.X = num1368 * npc.direction; + npc.velocity.Y -= jumpYVelocity; + npc.velocity.X = jumpXVelocity * npc.direction; npc.netUpdate = true; } } @@ -10919,22 +10905,22 @@ namespace CalamityMod.NPCs npc.spriteDirection = npc.direction; npc.TargetClosest(); - Vector2 center35 = Main.player[npc.target].Center; - center35.Y -= 350f; - Vector2 value40 = center35 - npc.Center; + Vector2 mimicTargetCenter = Main.player[npc.target].Center; + mimicTargetCenter.Y -= 350f; + Vector2 mimicTargetDirection = mimicTargetCenter - npc.Center; if (npc.ai[2] == 1f) { npc.ai[1] += 1f; - value40 = Main.player[npc.target].Center - npc.Center; - value40.Normalize(); - value40 *= CalamityWorld.death ? 12f : 10f; - npc.velocity = (npc.velocity * 4f + value40) / 5f; + mimicTargetDirection = Main.player[npc.target].Center - npc.Center; + mimicTargetDirection.Normalize(); + mimicTargetDirection *= CalamityWorld.death ? 12f : 10f; + npc.velocity = (npc.velocity * 4f + mimicTargetDirection) / 5f; if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] > 6f) { npc.ai[1] = 0f; npc.ai[0] = 4.1f; npc.ai[2] = 0f; - npc.velocity = value40; + npc.velocity = mimicTargetDirection; npc.netUpdate = true; } } @@ -10949,9 +10935,9 @@ namespace CalamityMod.NPCs } else { - value40.Normalize(); - value40 *= CalamityWorld.death ? 16f : 14f; - npc.velocity = (npc.velocity * 5f + value40) / 6f; + mimicTargetDirection.Normalize(); + mimicTargetDirection *= CalamityWorld.death ? 16f : 14f; + npc.velocity = (npc.velocity * 5f + mimicTargetDirection) / 6f; } } else if (npc.ai[0] == 4.1f) @@ -10996,9 +10982,9 @@ namespace CalamityMod.NPCs npc.noTileCollide = true; npc.noGravity = true; npc.knockBackResist = 0f; - Vector2 value41 = Main.player[npc.target].Center - npc.Center; - value41.Y -= 4f; - if (Main.netMode != NetmodeID.MultiplayerClient && value41.Length() < 200f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) + Vector2 chaseTargetDirection = Main.player[npc.target].Center - npc.Center; + chaseTargetDirection.Y -= 4f; + if (Main.netMode != NetmodeID.MultiplayerClient && chaseTargetDirection.Length() < 200f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) { npc.ai[0] = 2f; npc.ai[1] = 0f; @@ -11007,13 +10993,13 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } - if (value41.Length() > 10f) + if (chaseTargetDirection.Length() > 10f) { - value41.Normalize(); - value41 *= CalamityWorld.death ? 15f : 12.5f; + chaseTargetDirection.Normalize(); + chaseTargetDirection *= CalamityWorld.death ? 15f : 12.5f; } - npc.velocity = (npc.velocity * 4f + value41) / 5f; + npc.velocity = (npc.velocity * 4f + chaseTargetDirection) / 5f; } else if (npc.ai[0] == 6f) { @@ -11106,21 +11092,21 @@ namespace CalamityMod.NPCs { int itemID = ItemID.Sets.ItemsForStuffCannon[Main.rand.Next(ItemID.Sets.ItemsForStuffCannon.Length)]; int item = Item.NewItem(npc.GetSource_Loot(), (int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, itemID, 1, noBroadcast: false, -1, noGrabDelay: true); - float num2 = Main.rand.Next(10, 26); + float randomSpeed = Main.rand.Next(10, 26); Vector2 vector = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); Vector2 vector2 = Main.player[npc.target].Center - new Vector2(0f, 120f); - float num3 = vector2.X - vector.X; - float num4 = vector2.Y - vector.Y; - num3 += Main.rand.Next(-50, 51) * 0.1f; - num4 += Main.rand.Next(-50, 51) * 0.1f; - float num5 = (float)Math.Sqrt(num3 * num3 + num4 * num4); - num5 = num2 / num5; - num3 *= num5; - num4 *= num5; - num3 += Main.rand.Next(-50, 51) * 0.1f; - num4 += Main.rand.Next(-50, 51) * 0.1f; - Main.item[item].velocity.X = num3; - Main.item[item].velocity.Y = num4; + float targetXDist = vector2.X - vector.X; + float targetYDist = vector2.Y - vector.Y; + targetXDist += Main.rand.Next(-50, 51) * 0.1f; + targetYDist += Main.rand.Next(-50, 51) * 0.1f; + float targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); + targetDistance = randomSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + targetXDist += Main.rand.Next(-50, 51) * 0.1f; + targetYDist += Main.rand.Next(-50, 51) * 0.1f; + Main.item[item].velocity.X = targetXDist; + Main.item[item].velocity.Y = targetYDist; Main.item[item].noGrabDelay = 100; if (Main.netMode != NetmodeID.SinglePlayer) NetMessage.SendData(MessageID.SyncItem, -1, -1, null, item); @@ -11135,15 +11121,15 @@ namespace CalamityMod.NPCs #region Small Star Cell AI public static bool BuffedSmallStarCellAI(NPC npc, Mod mod) { - float num1470 = CalamityWorld.death ? 100f : 200f; + float turnBigDelay = CalamityWorld.death ? 100f : 200f; if (npc.velocity.Length() > 4f) npc.velocity *= 0.95f; npc.velocity *= 0.99f; npc.ai[0]++; - float num1471 = MathHelper.Clamp(npc.ai[0] / num1470, 0f, 1f); - npc.scale = 1f + 0.3f * num1471; - if (npc.ai[0] >= num1470) + float cellScale = MathHelper.Clamp(npc.ai[0] / turnBigDelay, 0f, 1f); + npc.scale = 1f + 0.3f * cellScale; + if (npc.ai[0] >= turnBigDelay) { if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -11158,28 +11144,26 @@ namespace CalamityMod.NPCs if (!(npc.ai[0] > 20f)) return false; - Vector2 center39 = npc.Center; - int num1472 = (int)(npc.ai[0] / (num1470 / 2f)); - for (int num1473 = 0; num1473 < num1472 + 1; num1473++) + Vector2 cellCenter = npc.Center; + int dustAmt = (int)(npc.ai[0] / (turnBigDelay / 2f)); + for (int i = 0; i < dustAmt + 1; i++) { if (Main.rand.NextBool()) { - int num1474 = 226; - float num1475 = 0.4f; - if (num1473 % 2 == 1) + float dustScale = 0.4f; + if (i % 2 == 1) { - num1474 = 226; - num1475 = 0.65f; + dustScale = 0.65f; } - Vector2 vector222 = center39 + ((float)Main.rand.NextDouble() * ((float)Math.PI * 2f)).ToRotationVector2() * (12f - num1472 * 2); - int num1476 = Dust.NewDust(vector222 - Vector2.One * 12f, 24, 24, num1474, npc.velocity.X / 2f, npc.velocity.Y / 2f); - Dust dust = Main.dust[num1476]; + Vector2 dustRotation = cellCenter + ((float)Main.rand.NextDouble() * ((float)Math.PI * 2f)).ToRotationVector2() * (12f - dustAmt * 2); + int cellDust = Dust.NewDust(dustRotation - Vector2.One * 12f, 24, 24, 226, npc.velocity.X / 2f, npc.velocity.Y / 2f); + Dust dust = Main.dust[cellDust]; dust.position -= new Vector2(2f); - Main.dust[num1476].velocity = Vector2.Normalize(center39 - vector222) * 1.5f * (10f - num1472 * 2f) / 10f; - Main.dust[num1476].noGravity = true; - Main.dust[num1476].scale = num1475; - Main.dust[num1476].customData = npc; + Main.dust[cellDust].velocity = Vector2.Normalize(cellCenter - dustRotation) * 1.5f * (10f - dustAmt * 2f) / 10f; + Main.dust[cellDust].noGravity = true; + Main.dust[cellDust].scale = dustScale; + Main.dust[cellDust].customData = npc; } } @@ -11190,29 +11174,29 @@ namespace CalamityMod.NPCs #region Flow Invader AI public static bool BuffedFlowInvaderAI(NPC npc, Mod mod) { - float num1477 = CalamityWorld.death ? 8f : 6.5f; + float velocityMult = CalamityWorld.death ? 8f : 6.5f; float moveSpeed = CalamityWorld.death ? 0.25f : 0.2f; npc.TargetClosest(); Vector2 desiredVelocity3 = Main.player[npc.target].Center - npc.Center + new Vector2(0f, -300f); - float num1478 = desiredVelocity3.Length(); - if (num1478 < 20f) + float velocityCheck = desiredVelocity3.Length(); + if (velocityCheck < 20f) { desiredVelocity3 = npc.velocity; } - else if (num1478 < 40f) + else if (velocityCheck < 40f) { desiredVelocity3.Normalize(); - desiredVelocity3 *= num1477 * 0.35f; + desiredVelocity3 *= velocityMult * 0.35f; } - else if (num1478 < 80f) + else if (velocityCheck < 80f) { desiredVelocity3.Normalize(); - desiredVelocity3 *= num1477 * 0.65f; + desiredVelocity3 *= velocityMult * 0.65f; } else { desiredVelocity3.Normalize(); - desiredVelocity3 *= num1477; + desiredVelocity3 *= velocityMult; } npc.SimpleFlyMovement(desiredVelocity3, moveSpeed); @@ -11223,11 +11207,11 @@ namespace CalamityMod.NPCs npc.ai[0] = 0f; if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector223 = Vector2.Zero; - while (Math.Abs(vector223.X) < 1.5f) - vector223 = Vector2.UnitY.RotatedByRandom(MathHelper.PiOver2) * new Vector2(5f, 3f); + Vector2 projDirection = Vector2.Zero; + while (Math.Abs(projDirection.X) < 1.5f) + projDirection = Vector2.UnitY.RotatedByRandom(MathHelper.PiOver2) * new Vector2(5f, 3f); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, vector223, ProjectileID.StardustJellyfishSmall, 60, 0f, Main.myPlayer, 0f, npc.whoAmI); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, projDirection, ProjectileID.StardustJellyfishSmall, 60, 0f, Main.myPlayer, 0f, npc.whoAmI); Main.projectile[proj].extraUpdates += 1; } diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 840d88d493..9a9262749c 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -11,6 +11,7 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Buffs.Summon.Whips; using CalamityMod.CalPlayer; using CalamityMod.Events; +using CalamityMod.Graphics.Drawers; using CalamityMod.Items.Accessories; using CalamityMod.Items.Tools; using CalamityMod.Items.Weapons.Melee; @@ -158,7 +159,7 @@ namespace CalamityMod.NPCs private const double DesertEnemyStatMultiplier = 0.75; // Used to increase coin drops in Normal Mode - private const double NPCValueMultiplier_NormalCalamity = 2.5; + private const double NPCValueMultiplier_NormalCalamity = 1.5; // Used to decrease coin drops in Expert Mode private const double NPCValueMultiplier_ExpertVanilla = 2.5; @@ -215,6 +216,7 @@ namespace CalamityMod.NPCs public int pearlAura = 0; public int bBlood = 0; public int brainRot = 0; + public int elementalMix = 0; public int marked = 0; public int absorberAffliction = 0; public int irradiated = 0; @@ -424,6 +426,7 @@ namespace CalamityMod.NPCs myClone.pearlAura = pearlAura; myClone.bBlood = bBlood; myClone.brainRot = brainRot; + myClone.elementalMix = elementalMix; myClone.marked = marked; myClone.absorberAffliction = absorberAffliction; myClone.irradiated = irradiated; @@ -857,19 +860,25 @@ namespace CalamityMod.NPCs } // Daybroken + // 18OCT2023: Ozzatron: im not gonna sugarcoat it + // vanilla debuff damage from Daybreak impales scales linearly up to 8 for 800 DPS + // instead of allowing this entire 800 DPS to be multiplied by heat weakness + heat DoT bonuses, + // each Daybreak spear beyond the first is only affected 25% as much by weaknesses or resistances. + // This also stops Daybreak's DPS from being utterly shafted by heat resistance. + // As no other weapon can stack Daybroken, this has no effect on other weapons (they count as "1 Daybreak spear") if (npc.daybreak) { - int projAmt = 0; + int numImpaledSpears = 0; for (int k = 0; k < Main.maxProjectiles; k++) { if (Main.projectile[k].active && Main.projectile[k].type == ProjectileID.Daybreak && Main.projectile[k].ai[0] == 1f && Main.projectile[k].ai[1] == npc.whoAmI) - projAmt++; + numImpaledSpears++; } - if (projAmt == 0) - projAmt = 1; + // If there are no Daybreak impaled spears, Daybroken has 1x potency (it was applied some other way) + float daybrokenMultiplier = numImpaledSpears <= 1 ? 1f : (1f + 0.25f * (numImpaledSpears - 1)); - int baseDaybreakDoTValue = (int)(projAmt * 2 * 100 * vanillaHeatDamageMult); + int baseDaybreakDoTValue = (int)(daybrokenMultiplier * 2 * 100 * vanillaHeatDamageMult); npc.lifeRegen -= baseDaybreakDoTValue; if (damage < baseDaybreakDoTValue / 4) damage = baseDaybreakDoTValue / 4; @@ -995,7 +1004,7 @@ namespace CalamityMod.NPCs // Sage Poison if (sagePoisonTime > 0) { - // npc.Calamity().sagePoisonDamage = 20 * (float)(Math.Pow(totalSageSpirits, 0.73D) + Math.Pow(totalSageSpirits, 1.1D)) * 0.5f + // npc.Calamity().sagePoisonDamage = 50 * (float)(Math.Pow(totalSageSpirits, 0.73D) + Math.Pow(totalSageSpirits, 1.1D)) * 0.5f // See SageNeedle.cs for details int baseSagePoisonDoTValue = (int)(npc.Calamity().sagePoisonDamage * sicknessDamageMult); ApplyDPSDebuff(baseSagePoisonDoTValue, baseSagePoisonDoTValue / 5, ref npc.lifeRegen, ref damage); @@ -1063,6 +1072,8 @@ namespace CalamityMod.NPCs ApplyDPSDebuff(50, 10, ref npc.lifeRegen, ref damage); if (brainRot > 0) ApplyDPSDebuff(50, 10, ref npc.lifeRegen, ref damage); + if (elementalMix > 0) + ApplyDPSDebuff(400, 80, ref npc.lifeRegen, ref damage); if (miracleBlight > 0) ApplyDPSDebuff(2500, 500, ref npc.lifeRegen, ref damage); @@ -1375,6 +1386,11 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.WallofFlesh) npc.npcSlots = 20f; } + else if (npc.type == NPCID.Deerclops) + { + npc.lifeMax = (int)(npc.lifeMax * 1.2); + npc.npcSlots = 16f; + } else if (npc.type == NPCID.SkeletronHead) { if (CalamityWorld.death) @@ -2456,10 +2472,10 @@ namespace CalamityMod.NPCs private void EditGlobalCoinDrops(NPC npc) { // Old Rev coin drop math: Normal = 10 Gold, Expert = 25 Gold, Rev = 37 Gold 50 Silver. - // New Rev coin drop math: Normal = 25 Gold, Expert AND Rev = 37 Gold 50 Silver. + // New Rev coin drop math: Normal = 15 Gold, Expert AND Rev = 22 Gold 50 Silver. // Rebalance coin drops so that Normal Mode enemies and bosses drop an adequate amount of coins. - // Increase Normal Mode coin drops by 2.5x. + // Increase Normal Mode coin drops by 1.5x. npc.value = (int)(npc.value * NPCValueMultiplier_NormalCalamity); // Change the Expert Mode coin drop multiplier. @@ -2939,6 +2955,9 @@ namespace CalamityMod.NPCs case NPCID.SkeletronHead: return SkeletronAI.BuffedSkeletronAI(npc, Mod); + case NPCID.Deerclops: + return DeerclopsAI.BuffedDeerclopsAI(npc, Mod); + case NPCID.WallofFlesh: return WallOfFleshAI.BuffedWallofFleshAI(npc, Mod); case NPCID.WallofFleshEye: @@ -3752,15 +3771,15 @@ namespace CalamityMod.NPCs else if (Vector2.Distance(npc.Center, targetData.Center) > 80f) { Rectangle r = Utils.CenteredRectangle(targetData.Center, new Vector2(targetData.Width + 60, targetData.Height / 2)); - Vector2 vector3 = r.ClosestPointInRect(npc.Center); - Vector2 value = npc.DirectionTo(vector3) * ((targetData.Velocity.Length() * 0.5f) + 2f); - float num8 = npc.Distance(vector3); - if (num8 > 225f) - value *= 2f; - else if (num8 > 120f) - value *= 1.5f; + Vector2 closestTargetPoint = r.ClosestPointInRect(npc.Center); + Vector2 targetPointDir = npc.DirectionTo(closestTargetPoint) * ((targetData.Velocity.Length() * 0.5f) + 2f); + float targetPointDist = npc.Distance(closestTargetPoint); + if (targetPointDist > 225f) + targetPointDir *= 2f; + else if (targetPointDist > 120f) + targetPointDir *= 1.5f; - npc.velocity = Vector2.Lerp(npc.velocity, value, 0.07f); + npc.velocity = Vector2.Lerp(npc.velocity, targetPointDir, 0.07f); } for (int k = 0; k < Main.maxNPCs; k++) @@ -3777,25 +3796,25 @@ namespace CalamityMod.NPCs npc.direction = (npc.velocity.X >= 0f) ? 1 : (-1); npc.spriteDirection = -npc.direction; - Color value3 = Color.HotPink; - Color value4 = Color.LightPink; - int num17 = 4; + Color dustLerpColor1 = Color.HotPink; + Color dustLerpColor2 = Color.LightPink; + int dustPosition = 4; if (npc.type == NPCID.FairyCritterGreen) { - value3 = Color.LimeGreen; - value4 = Color.LightSeaGreen; + dustLerpColor1 = Color.LimeGreen; + dustLerpColor2 = Color.LightSeaGreen; } if (npc.type == NPCID.FairyCritterBlue) { - value3 = Color.RoyalBlue; - value4 = Color.LightBlue; + dustLerpColor1 = Color.RoyalBlue; + dustLerpColor2 = Color.LightBlue; } if ((int)Main.timeForVisualEffects % 2 == 0) { npc.position += npc.netOffset; - Dust dust = Dust.NewDustDirect(npc.Center - new Vector2(num17) * 0.5f, num17 + 4, num17 + 4, 278, 0f, 0f, 200, Color.Lerp(value3, value4, Main.rand.NextFloat()), 0.65f); + Dust dust = Dust.NewDustDirect(npc.Center - new Vector2(dustPosition) * 0.5f, dustPosition + 4, dustPosition + 4, 278, 0f, 0f, 200, Color.Lerp(dustLerpColor1, dustLerpColor2, Main.rand.NextFloat()), 0.65f); dust.velocity *= 0f; dust.velocity += npc.velocity * 0.3f; dust.noGravity = true; @@ -3803,7 +3822,7 @@ namespace CalamityMod.NPCs npc.position -= npc.netOffset; } - Lighting.AddLight(npc.Center, value3.ToVector3() * 0.7f); + Lighting.AddLight(npc.Center, dustLerpColor1.ToVector3() * 0.7f); if (Main.netMode != NetmodeID.Server) { Player localPlayer = Main.LocalPlayer; @@ -4170,6 +4189,8 @@ namespace CalamityMod.NPCs bBlood--; if (brainRot > 0) brainRot--; + if (elementalMix > 0) + elementalMix--; if (vulnerabilityHex > 0) vulnerabilityHex--; if (marked > 0) @@ -5214,6 +5235,15 @@ namespace CalamityMod.NPCs #region On Spawn public override void OnSpawn(NPC npc, IEntitySource source) { + if (npc.type == NPCID.Deerclops) + { + DeerclopsAI.hasTargetBeenInRange = false; + DeerclopsAI.borderDelay = 7f * 60f; + DeerclopsAI.borderScalar = 0f; + DeerclopsAI.innerBorder = DeerclopsAI.maxDRIncreaseDistance * 5f; + DeerclopsAI.outerBorder = DeerclopsAI.maxDRIncreaseDistance * 5f; + } + if (npc.type != NPCID.VoodooDemon) return; @@ -5278,6 +5308,9 @@ namespace CalamityMod.NPCs if (dragonFire > 0) Dragonfire.DrawEffects(npc, ref drawColor); + if (elementalMix > 0) + ElementalMix.DrawEffects(npc, ref drawColor); + // Eutrophication and Temporal Sadness share the same visual effects if (eutrophication > 0 || tSad > 0) Eutrophication.DrawEffects(npc, ref drawColor); @@ -5419,156 +5452,130 @@ namespace CalamityMod.NPCs return null; } + public static List<(string, Predicate)> moddedDebuffTextureList = new List<(string, Predicate)> + { + // All Calamity DoTs in alphabetical order + ("CalamityMod/Buffs/DamageOverTime/AstralInfectionDebuff", NPC => NPC.Calamity().astralInfection > 0), + ("CalamityMod/Buffs/DamageOverTime/BanishingFire", NPC => NPC.Calamity().banishingFire > 0), + ("CalamityMod/Buffs/DamageOverTime/BrainRot", NPC => NPC.Calamity().brainRot > 0), + ("CalamityMod/Buffs/DamageOverTime/BrimstoneFlames", NPC => NPC.Calamity().bFlames > 0), + ("CalamityMod/Buffs/DamageOverTime/BurningBlood", NPC => NPC.Calamity().bBlood > 0), + ("CalamityMod/Buffs/DamageOverTime/CrushDepth", NPC => NPC.Calamity().cDepth > 0), + ("CalamityMod/Buffs/DamageOverTime/Dragonfire", NPC => NPC.Calamity().dragonFire > 0), + ("CalamityMod/Buffs/DamageOverTime/ElementalMix", NPC => NPC.Calamity().elementalMix > 0), + ("CalamityMod/Buffs/DamageOverTime/GodSlayerInferno", NPC => NPC.Calamity().gsInferno > 0), + ("CalamityMod/Buffs/DamageOverTime/HolyFlames", NPC => NPC.Calamity().hFlames > 0), + ("CalamityMod/Buffs/DamageOverTime/MiracleBlight", NPC => NPC.Calamity().miracleBlight > 0), + ("CalamityMod/Buffs/DamageOverTime/Nightwither", NPC => NPC.Calamity().nightwither > 0), + ("CalamityMod/Buffs/DamageOverTime/Plague", NPC => NPC.Calamity().pFlames > 0), + ("CalamityMod/Buffs/DamageOverTime/RancorBurn", NPC => NPC.Calamity().RancorBurnTime > 0), + ("CalamityMod/Buffs/DamageOverTime/RiptideDebuff", NPC => NPC.Calamity().rTide > 0), + ("CalamityMod/Buffs/DamageOverTime/SagePoison", NPC => NPC.Calamity().sagePoisonTime > 0), + ("CalamityMod/Buffs/DamageOverTime/ShellfishClaps", NPC => NPC.Calamity().shellfishVore > 0), + ("CalamityMod/Buffs/DamageOverTime/Shred", NPC => NPC.Calamity().somaShredStacks > 0), + ("CalamityMod/Buffs/DamageOverTime/SnapClamDebuff", NPC => NPC.Calamity().clamDebuff > 0), + ("CalamityMod/Buffs/DamageOverTime/SulphuricPoisoning", NPC => NPC.Calamity().sulphurPoison > 0), + ("CalamityMod/Buffs/DamageOverTime/Vaporfied", NPC => NPC.Calamity().vaporfied > 0), + ("CalamityMod/Buffs/DamageOverTime/VulnerabilityHex", NPC => NPC.Calamity().vulnerabilityHex > 0), + + // All other important Calamity debuffs, in alphabetical order + ("CalamityMod/Buffs/StatDebuffs/AbsorberAffliction", NPC => NPC.Calamity().absorberAffliction > 0), + ("CalamityMod/Buffs/StatDebuffs/ArmorCrunch", NPC => NPC.Calamity().aCrunch > 0), + ("CalamityMod/Buffs/StatDebuffs/Crumbling", NPC => NPC.Calamity().crumble > 0), + ("CalamityMod/Buffs/StatDebuffs/Eutrophication", NPC => NPC.Calamity().eutrophication > 0), + ("CalamityMod/Buffs/StatDebuffs/GalvanicCorrosion", NPC => NPC.Calamity().tesla > 0), + ("CalamityMod/Buffs/StatDebuffs/GlacialState", NPC => NPC.Calamity().gState > 0), + ("CalamityMod/Buffs/StatDebuffs/Irradiated", NPC => NPC.Calamity().irradiated > 0), + ("CalamityMod/Buffs/StatDebuffs/KamiFlu", NPC => NPC.Calamity().kamiFlu > 0), + ("CalamityMod/Buffs/StatDebuffs/MarkedforDeath", NPC => NPC.Calamity().marked > 0), + ("CalamityMod/Buffs/StatDebuffs/PearlAura", NPC => NPC.Calamity().pearlAura > 0), + ("CalamityMod/Buffs/StatDebuffs/ProfanedWeakness", NPC => NPC.Calamity().relicOfResilienceWeakness > 0), + ("CalamityMod/Buffs/StatDebuffs/TemporalSadness", NPC => NPC.Calamity().tSad > 0), + ("CalamityMod/Buffs/StatDebuffs/TimeDistortion", NPC => NPC.Calamity().timeSlow > 0), + ("CalamityMod/Buffs/StatDebuffs/WhisperingDeath", NPC => NPC.Calamity().wDeath > 0), + ("CalamityMod/Buffs/StatDebuffs/WitherDebuff", NPC => NPC.Calamity().wither > 0), + }; + public override bool PreDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { if (npc.type != NPCID.BrainofCthulhu && (npc.type != NPCID.DukeFishron || npc.ai[0] <= 9f) && npc.active) { if (CalamityConfig.Instance.DebuffDisplay && (npc.boss || BossHealthBarManager.MinibossHPBarList.Contains(npc.type) || BossHealthBarManager.OneToMany.ContainsKey(npc.type) || CalamityLists.needsDebuffIconDisplayList.Contains(npc.type))) { - IList buffTextureList = new List(); + List currentDebuffs = new List() { }; - // Damage over time debuffs - if (astralInfection > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/AstralInfectionDebuff").Value); - if (banishingFire > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/BanishingFire").Value); - if (bFlames > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/BrimstoneFlames").Value); - if (bBlood > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/BurningBlood").Value); - if (brainRot > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/BrainRot").Value); - if (cDepth > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/CrushDepth").Value); - if (rTide > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/RiptideDebuff").Value); - if (dragonFire > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/Dragonfire").Value); - if (miracleBlight > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/MiracleBlight").Value); - if (gsInferno > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/GodSlayerInferno").Value); - if (hFlames > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/HolyFlames").Value); - if (nightwither > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/Nightwither").Value); - if (pFlames > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/Plague").Value); - if (sagePoisonTime > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/SagePoison").Value); - if (shellfishVore > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/ShellfishClaps").Value); - if (somaShredStacks > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/Shred").Value); - if (clamDebuff > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/SnapClamDebuff").Value); - if (sulphurPoison > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/SulphuricPoisoning").Value); - if (vaporfied > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/Vaporfied").Value); - if (vulnerabilityHex > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/VulnerabilityHex").Value); - - // Stat debuffs - if (aCrunch > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/StatDebuffs/ArmorCrunch").Value); - if (crumble > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/StatDebuffs/Crumbling").Value); - if (eutrophication > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/StatDebuffs/Eutrophication").Value); - if (gState > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/StatDebuffs/GlacialState").Value); - if (irradiated > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/StatDebuffs/Irradiated").Value); - if (kamiFlu > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/StatDebuffs/KamiFlu").Value); - if (marked > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/StatDebuffs/MarkedforDeath").Value); - if (absorberAffliction > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/StatDebuffs/AbsorberAffliction").Value); - if (pearlAura > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/StatDebuffs/PearlAura").Value); - if (relicOfResilienceWeakness > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/StatDebuffs/ProfanedWeakness").Value); - if (tSad > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/StatDebuffs/TemporalSadness").Value); - if (tesla > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/StatDebuffs/GalvanicCorrosion").Value); - if (timeSlow > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/StatDebuffs/TimeDistortion").Value); - if (wDeath > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/StatDebuffs/WhisperingDeath").Value); - if (wither > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/StatDebuffs/WitherDebuff").Value); - - // Visual debuff - if (RancorBurnTime > 0) - buffTextureList.Add(Request("CalamityMod/Buffs/DamageOverTime/RancorBurn").Value); + for (int b = 0; b < moddedDebuffTextureList.Count(); b++) + { + if (moddedDebuffTextureList[b].Item2.Invoke(npc)) + { + currentDebuffs.Add(Request(moddedDebuffTextureList[b].Item1).Value); + } + } // Vanilla damage over time debuffs if (electrified > 0) - buffTextureList.Add(TextureAssets.Buff[BuffID.Electrified].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.Electrified].Value); if (npc.onFire) - buffTextureList.Add(TextureAssets.Buff[BuffID.OnFire].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.OnFire].Value); if (npc.poisoned) - buffTextureList.Add(TextureAssets.Buff[BuffID.Poisoned].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.Poisoned].Value); if (npc.onFire2) - buffTextureList.Add(TextureAssets.Buff[BuffID.CursedInferno].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.CursedInferno].Value); if (npc.onFrostBurn) - buffTextureList.Add(TextureAssets.Buff[BuffID.Frostburn].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.Frostburn].Value); if (npc.venom) - buffTextureList.Add(TextureAssets.Buff[BuffID.Venom].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.Venom].Value); if (npc.shadowFlame) - buffTextureList.Add(TextureAssets.Buff[BuffID.ShadowFlame].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.ShadowFlame].Value); if (npc.oiled) - buffTextureList.Add(TextureAssets.Buff[BuffID.Oiled].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.Oiled].Value); if (npc.javelined) - buffTextureList.Add(TextureAssets.Buff[BuffID.BoneJavelin].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.BoneJavelin].Value); if (npc.daybreak) - buffTextureList.Add(TextureAssets.Buff[BuffID.Daybreak].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.Daybreak].Value); if (npc.celled) - buffTextureList.Add(TextureAssets.Buff[BuffID.StardustMinionBleed].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.StardustMinionBleed].Value); if (npc.dryadBane) - buffTextureList.Add(TextureAssets.Buff[BuffID.DryadsWardDebuff].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.DryadsWardDebuff].Value); if (npc.dryadWard) - buffTextureList.Add(TextureAssets.Buff[BuffID.DryadsWard].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.DryadsWard].Value); if (npc.soulDrain && npc.realLife == -1) - buffTextureList.Add(TextureAssets.Buff[BuffID.SoulDrain].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.SoulDrain].Value); if (npc.onFire3) // Hellfire - buffTextureList.Add(TextureAssets.Buff[BuffID.OnFire3].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.OnFire3].Value); if (npc.onFrostBurn2) // Frostbite - buffTextureList.Add(TextureAssets.Buff[BuffID.Frostburn2].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.Frostburn2].Value); if (npc.tentacleSpiked) - buffTextureList.Add(TextureAssets.Buff[BuffID.TentacleSpike].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.TentacleSpike].Value); // Vanilla stat debuffs if (npc.confused) - buffTextureList.Add(TextureAssets.Buff[BuffID.Confused].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.Confused].Value); if (npc.ichor) - buffTextureList.Add(TextureAssets.Buff[BuffID.Ichor].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.Ichor].Value); if (slowed > 0) - buffTextureList.Add(TextureAssets.Buff[BuffID.Slow].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.Slow].Value); if (webbed > 0) - buffTextureList.Add(TextureAssets.Buff[BuffID.Webbed].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.Webbed].Value); if (npc.midas) - buffTextureList.Add(TextureAssets.Buff[BuffID.Midas].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.Midas].Value); if (npc.loveStruck) - buffTextureList.Add(TextureAssets.Buff[BuffID.Lovestruck].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.Lovestruck].Value); if (npc.stinky) - buffTextureList.Add(TextureAssets.Buff[BuffID.Stinky].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.Stinky].Value); if (npc.betsysCurse) - buffTextureList.Add(TextureAssets.Buff[BuffID.BetsysCurse].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.BetsysCurse].Value); if (npc.dripping) - buffTextureList.Add(TextureAssets.Buff[BuffID.Wet].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.Wet].Value); if (npc.drippingSlime) - buffTextureList.Add(TextureAssets.Buff[BuffID.Slimed].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.Slimed].Value); if (npc.drippingSparkleSlime) - buffTextureList.Add(TextureAssets.Buff[BuffID.GelBalloonBuff].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.GelBalloonBuff].Value); if (npc.markedByScytheWhip) // Dark Harvest whip, the only Whip debuff that has an NPC bool - buffTextureList.Add(TextureAssets.Buff[BuffID.ScytheWhipEnemyDebuff].Value); + currentDebuffs.Add(TextureAssets.Buff[BuffID.ScytheWhipEnemyDebuff].Value); // Total amount of elements in the buff list - int buffTextureListLength = buffTextureList.Count; + int buffTextureListLength = currentDebuffs.Count(); // Total length of a single row in the buff display int totalLength = buffTextureListLength * 14; @@ -5587,7 +5594,7 @@ namespace CalamityMod.NPCs float drawPosY = npcHeight + npc.gfxOffY + 16f; // Iterate through the buff texture list - for (int i = 0; i < buffTextureList.Count; i++) + for (int i = 0; i < currentDebuffs.Count; i++) { // Reset the X position of the display every 5th and non-zero iteration, otherwise decrease the X draw position by 16 units if (i != 0) @@ -5602,7 +5609,7 @@ namespace CalamityMod.NPCs float additionalYOffset = 14f * (float)Math.Floor(i * 0.2); // Draw the display - var tex = buffTextureList.ElementAt(i); + var tex = currentDebuffs[i]; spriteBatch.Draw(tex, npc.Center - screenPos - new Vector2(drawPosX, drawPosY + additionalYOffset), null, Color.White, 0f, default, 0.5f, SpriteEffects.None, 0f); // TODO -- Show number of Shred stacks (how?) @@ -5641,38 +5648,37 @@ namespace CalamityMod.NPCs spriteEffects = SpriteEffects.FlipHorizontally; } - float num66 = 0f; - Vector2 vector11 = new Vector2(TextureAssets.Npc[npc.type].Value.Width / 2, TextureAssets.Npc[npc.type].Value.Height / Main.npcFrameCount[npc.type] / 2); - Color color9 = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0); - Color alpha15 = npc.GetAlpha(color9); - float num212 = 0.99f; - alpha15.R = (byte)(alpha15.R * num212); - alpha15.G = (byte)(alpha15.G * num212); - alpha15.B = (byte)(alpha15.B * num212); - alpha15.A = (byte)(alpha15.A * num212); - float xOffset = screenPos.X + npc.width / 2 - TextureAssets.Npc[npc.type].Value.Width * npc.scale / 2f + vector11.X * npc.scale; - float yOffset = screenPos.Y + npc.height - TextureAssets.Npc[npc.type].Value.Height * npc.scale / Main.npcFrameCount[npc.type] + 4f + vector11.Y * npc.scale + num66 + npc.gfxOffY; - for (int num213 = 0; num213 < 4; num213++) + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[npc.type].Value.Width / 2, TextureAssets.Npc[npc.type].Value.Height / Main.npcFrameCount[npc.type] / 2); + Color rainbow = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0); + Color alphaColor = npc.GetAlpha(rainbow); + float RGBMult = 0.99f; + alphaColor.R = (byte)(alphaColor.R * RGBMult); + alphaColor.G = (byte)(alphaColor.G * RGBMult); + alphaColor.B = (byte)(alphaColor.B * RGBMult); + alphaColor.A = (byte)(alphaColor.A * RGBMult); + float xOffset = screenPos.X + npc.width / 2 - TextureAssets.Npc[npc.type].Value.Width * npc.scale / 2f + halfSizeTexture.X * npc.scale; + float yOffset = screenPos.Y + npc.height - TextureAssets.Npc[npc.type].Value.Height * npc.scale / Main.npcFrameCount[npc.type] + 4f + halfSizeTexture.Y * npc.scale + npc.gfxOffY; + for (int i = 0; i < 4; i++) { Vector2 position9 = npc.position; float num214 = Math.Abs(npc.Center.X - Main.LocalPlayer.Center.X); float num215 = Math.Abs(npc.Center.Y - Main.LocalPlayer.Center.Y); - if (num213 == 0 || num213 == 2) + if (i == 0 || i == 2) position9.X = Main.LocalPlayer.Center.X + num214; else position9.X = Main.LocalPlayer.Center.X - num214; position9.X -= npc.width / 2; - if (num213 == 0 || num213 == 1) + if (i == 0 || i == 1) position9.Y = Main.LocalPlayer.Center.Y + num215; else position9.Y = Main.LocalPlayer.Center.Y - num215; position9.Y -= npc.height / 2; - Main.spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position9.X - xOffset, position9.Y - yOffset), new Microsoft.Xna.Framework.Rectangle?(npc.frame), alpha15, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Main.spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position9.X - xOffset, position9.Y - yOffset), new Microsoft.Xna.Framework.Rectangle?(npc.frame), alphaColor, npc.rotation, halfSizeTexture, npc.scale, spriteEffects, 0f); } } else @@ -5694,23 +5700,9 @@ namespace CalamityMod.NPCs else VulnerabilityHexFireDrawer = null; - if (npc.Calamity().miracleBlight > 0) - { - // this is horrible but I can't figure out a better way to do it - Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix); - - MiscShaderData msd = GameShaders.Misc["CalamityMod:MiracleBlight"]; - msd.SetShaderTexture(Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons"), 1); - msd.UseOpacity(0.7f); - DrawData dd = new() - { - texture = TextureAssets.Npc[npc.type].Value, - position = npc.position - Main.screenPosition, - sourceRect = npc.frame, - }; - msd.Apply(dd); - } + // Only draw the NPC if told to by the miracle blight drawer. + if (MiracleBlightDrawer.ValidToDraw(npc)) + return MiracleBlightDrawer.ActuallyDoPreDraw; } // Draw a pillar of light and fade the background as an animation when skipping things in the DD2 event. diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 911947e694..50451023f8 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -103,11 +103,11 @@ namespace CalamityMod.NPCs #region Sky / Space // Harpy - // Coco's Feather (bird dev item) @ 5% + // Coco's Feather (bird dev item) @ 0.1% // Sky Glaze @ 3.33% IF Eye of Cthulhu dead // Essence of Sunlight @ 50% IF Hardmode and not statue spawned case NPCID.Harpy: - npcLoot.Add(ModContent.ItemType(), 20); + npcLoot.Add(ModContent.ItemType(), 1000); postEoC.Add(ModContent.ItemType(), 30); hardmode.AddIf(() => !npc.SpawnedFromStatue, ModContent.ItemType(), 2); break; @@ -846,6 +846,16 @@ namespace CalamityMod.NPCs hardmode.Add(ModContent.ItemType()); break; + // Merchant + // 20-30 Gel, 30-50 Rope & 10-15 Bombs @ 100% IF named "Morshu" + case NPCID.Merchant: + LeadingConditionRule morshuLCR = new LeadingConditionRule(DropHelper.If((info) => info.npc.GivenName == "Morshu", false)); + morshuLCR.Add(ItemID.Gel, 1, 20, 30, true); // lamp oil? + morshuLCR.Add(ItemID.Rope, 1, 30, 50, true); // rope? + morshuLCR.Add(ItemID.Bomb, 1, 10, 15, true); // bombs? you want it? + npcLoot.Add(morshuLCR); // it's yours, my friend + break; + // Angler // Golden Fishing Rod @ 100% IF fed to a Trasher // OTHERWISE, @@ -885,7 +895,7 @@ namespace CalamityMod.NPCs rev.Add(ItemID.KingSlimePetItem, 4); // GFB Aureus Cell drop - GFB.Add(ModContent.ItemType(), 1, 45, 55); + GFB.Add(ModContent.ItemType(), 1, 45, 55, true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedSlimeKing, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -905,7 +915,7 @@ namespace CalamityMod.NPCs rev.Add(ItemID.EyeOfCthulhuPetItem, 4); // GFB Optic Staff drop - GFB.Add(ItemID.OpticStaff); + GFB.Add(ItemID.OpticStaff, hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedBoss1, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -928,7 +938,7 @@ namespace CalamityMod.NPCs rev.AddIf((info) => info.npc.boss, ItemID.EaterOfWorldsPetItem, 4); // GFB Light Disc drop - GFB.Add(ItemID.LightDisc); + GFB.AddIf((info) => info.npc.boss, ItemID.LightDisc, hideLootReport: true); // Corruption World OR Drunk World: Corruption Lore LeadingConditionRule eowCorruptionLore = new(DropHelper.If((info) => info.npc.boss && (!WorldGen.crimson || WorldGen.drunkWorldGen) && !NPC.downedBoss2, desc: DropHelper.FirstKillText)); @@ -955,7 +965,7 @@ namespace CalamityMod.NPCs rev.Add(ItemID.BrainOfCthulhuPetItem, 4); // GFB Occult Skull Crown drop - GFB.Add(ModContent.ItemType()); + GFB.Add(ModContent.ItemType(), hideLootReport: true); // Corruption World OR Drunk World: Corruption Lore LeadingConditionRule bocCorruptionLore = new(DropHelper.If(() => (!WorldGen.crimson || WorldGen.drunkWorldGen) && !NPC.downedBoss2, desc: DropHelper.FirstKillText)); @@ -1033,8 +1043,8 @@ namespace CalamityMod.NPCs rev.Add(ItemID.QueenBeePetItem, 4); // GFB Lavaproof Bug Net and Alchemical Flask drop - GFB.Add(ItemID.FireproofBugNet); - GFB.Add(ModContent.ItemType()); + GFB.Add(ItemID.FireproofBugNet, hideLootReport: true); + GFB.Add(ModContent.ItemType(), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedQueenBee, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1064,7 +1074,7 @@ namespace CalamityMod.NPCs rev.Add(ItemID.SkeletronPetItem, 4); // GFB Flamethrower drop - GFB.Add(ItemID.Flamethrower); + GFB.Add(ItemID.Flamethrower, hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedBoss3, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1150,8 +1160,8 @@ namespace CalamityMod.NPCs rev.Add(ItemID.WallOfFleshGoatMountItem, 4); // GFB Eye of Magnus and Flesh Wall drops - GFB.Add(ModContent.ItemType()); - GFB.Add(ItemID.FleshBlockWall); + GFB.Add(ModContent.ItemType(), hideLootReport: true); + GFB.Add(ItemID.FleshBlockWall, hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !Main.hardMode, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1174,7 +1184,7 @@ namespace CalamityMod.NPCs rev.Add(ItemID.QueenSlimePetItem, 4); // GFB Bottomless Shimmer Bucket drop - GFB.Add(ItemID.BottomlessShimmerBucket); + GFB.Add(ItemID.BottomlessShimmerBucket, hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedQueenSlime, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1199,7 +1209,7 @@ namespace CalamityMod.NPCs rev.Add(ItemID.DestroyerPetItem, 4); // GFB Bloodworm drop - GFB.Add(ModContent.ItemType()); + GFB.Add(ModContent.ItemType(), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedMechBoss1, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1241,7 +1251,7 @@ namespace CalamityMod.NPCs rev.AddIf((info) => IsLastTwinStanding(info), ItemID.TwinsPetItem, 4); // GFB The Eye of Cthulhu drop - GFB.AddIf((info) => IsLastTwinStanding(info), ItemID.TheEyeOfCthulhu); + GFB.AddIf((info) => IsLastTwinStanding(info), ItemID.TheEyeOfCthulhu, hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer((info) => !NPC.downedMechBoss2 && IsLastTwinStanding(info), ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1266,7 +1276,7 @@ namespace CalamityMod.NPCs rev.Add(ItemID.SkeletronPrimePetItem, 4); // GFB Bone Wings drop - GFB.Add(ItemID.BoneWings); + GFB.Add(ItemID.BoneWings, hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedMechBoss3, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1330,7 +1340,7 @@ namespace CalamityMod.NPCs rev.Add(ItemID.PlanteraPetItem, 4); // GFB Life Fruit drop - GFB.Add(ItemID.LifeFruit, 1, 1, 9999); + GFB.Add(ItemID.LifeFruit, 1, 1, 9999, true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedPlantBoss, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1388,12 +1398,12 @@ namespace CalamityMod.NPCs rev.Add(ItemID.GolemPetItem, 4); // GFB Vision Potion drop - GFB.Add(ItemID.NightOwlPotion, 1, 1, 9999); - GFB.Add(ItemID.ShinePotion, 1, 1, 9999); - GFB.Add(ItemID.HunterPotion, 1, 1, 9999); - GFB.Add(ItemID.TrapsightPotion, 1, 1, 9999); - GFB.Add(ItemID.SpelunkerPotion, 1, 1, 9999); - GFB.Add(ModContent.ItemType(), 1, 1, 9999); + GFB.Add(ItemID.NightOwlPotion, 1, 1, 9999, true); + GFB.Add(ItemID.ShinePotion, 1, 1, 9999, true); + GFB.Add(ItemID.HunterPotion, 1, 1, 9999, true); + GFB.Add(ItemID.TrapsightPotion, 1, 1, 9999, true); + GFB.Add(ItemID.SpelunkerPotion, 1, 1, 9999, true); + GFB.Add(ModContent.ItemType(), 1, 1, 9999, true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedGolemBoss, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1472,28 +1482,28 @@ namespace CalamityMod.NPCs rev.Add(ItemID.DukeFishronPetItem, 4); // GFB Old Die and Fish drop - GFB.Add(ModContent.ItemType()); - GFB.Add(ItemID.Fish); - GFB.Add(ItemID.FishBowl); - GFB.Add(ItemID.FishCostumeFinskirt); - GFB.Add(ItemID.FishCostumeMask); - GFB.Add(ItemID.FishCostumeShirt); - GFB.Add(ItemID.FishermansGuide); - GFB.Add(ItemID.FisherofSouls); - GFB.Add(ItemID.FishFinder); - GFB.Add(ItemID.FishHook); - GFB.Add(ItemID.FishingBobber); - GFB.Add(ItemID.FishingPotion, 1, 1, 9999); - GFB.Add(ItemID.FishingSeaweed, 1, 1, 9999); - GFB.Add(ItemID.FishMinecart); - GFB.Add(ItemID.Fishotron); - GFB.Add(ItemID.Fishron); - GFB.Add(ItemID.FishStatue, 1, 1, 9999); - GFB.Add(ModContent.ItemType()); - GFB.Add(ModContent.ItemType(), 1, 1, 9999); - GFB.Add(ModContent.ItemType(), 1, 1, 9999); - GFB.Add(ModContent.ItemType(), 1, 1, 9999); - GFB.Add(ModContent.ItemType(), 1, 1, 9999); + GFB.Add(ModContent.ItemType(), hideLootReport: true); + GFB.Add(ItemID.Fish, hideLootReport: true); + GFB.Add(ItemID.FishBowl, hideLootReport: true); + GFB.Add(ItemID.FishCostumeFinskirt, hideLootReport: true); + GFB.Add(ItemID.FishCostumeMask, hideLootReport: true); + GFB.Add(ItemID.FishCostumeShirt, hideLootReport: true); + GFB.Add(ItemID.FishermansGuide, hideLootReport: true); + GFB.Add(ItemID.FisherofSouls, hideLootReport: true); + GFB.Add(ItemID.FishFinder, hideLootReport: true); + GFB.Add(ItemID.FishHook, hideLootReport: true); + GFB.Add(ItemID.FishingBobber, hideLootReport: true); + GFB.Add(ItemID.FishingPotion, 1, 1, 9999, true); + GFB.Add(ItemID.FishingSeaweed, 1, 1, 9999, true); + GFB.Add(ItemID.FishMinecart, hideLootReport: true); + GFB.Add(ItemID.Fishotron, hideLootReport: true); + GFB.Add(ItemID.Fishron, hideLootReport: true); + GFB.Add(ItemID.FishStatue, 1, 1, 9999, true); + GFB.Add(ModContent.ItemType(), hideLootReport: true); + GFB.Add(ModContent.ItemType(), 1, 1, 9999, true); + GFB.Add(ModContent.ItemType(), 1, 1, 9999, true); + GFB.Add(ModContent.ItemType(), 1, 1, 9999, true); + GFB.Add(ModContent.ItemType(), 1, 1, 9999, true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedFishron, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1545,8 +1555,8 @@ namespace CalamityMod.NPCs rev.Add(ItemID.FairyQueenPetItem, 4); // GFB Fabsol's Vodka and Terraformer drop - GFB.Add(ModContent.ItemType(), 1, 1, 9999); - GFB.Add(ItemID.Clentaminator2); + GFB.Add(ModContent.ItemType(), 1, 1, 9999, true); + GFB.Add(ItemID.Clentaminator2, hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedEmpressOfLight, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1561,7 +1571,7 @@ namespace CalamityMod.NPCs npcLoot.Add(ModContent.ItemType(), ThankYouPainting.DropInt); // GFB Luminite Brick drop - GFB.Add(ItemID.LunarBrick, 1, 1, 9999); + GFB.Add(ItemID.LunarBrick, 1, 1, 9999, true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedAncientCultist, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1611,7 +1621,7 @@ namespace CalamityMod.NPCs rev.Add(ItemID.MoonLordPetItem, 4); // GFB Calamari's Lament drop - GFB.Add(ModContent.ItemType()); + GFB.Add(ModContent.ItemType(), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedMoonlord, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1773,12 +1783,10 @@ namespace CalamityMod.NPCs // First kill: Notify of Abyss chests being unlocked. if (!NPC.downedBoss3) { - if (Main.netMode != NetmodeID.MultiplayerClient) //Only the server should do this to prevent already unlocked chests from attempting to be unlocked + if (Main.netMode != NetmodeID.MultiplayerClient) { - World.Abyss.AbleToUnlockChests = true; World.Abyss.UnlockAllAbyssChests(); } - string keysk = "Mods.CalamityMod.Status.Progression.SkeletronAbyssChestNotification"; CalamityUtils.DisplayLocalizedText(keysk, new Color(76, 181, 76)); } diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index 9d8bdfe390..4d81dd69a6 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -18,6 +18,7 @@ using CalamityMod.NPCs.TownNPCs; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System; using System.Collections.Generic; using Terraria; using Terraria.GameContent; @@ -58,7 +59,6 @@ namespace CalamityMod.NPCs public static int TaxesToCollectLimit => (int)(Item.buyPrice(0, 50, 0, 0) * TaxYieldFactor); - // TODO -- Update all Discord tags here to new Discord usernames. #region Town NPC Patreon Name Sets private static readonly string[] AnglerNames = { @@ -69,17 +69,18 @@ namespace CalamityMod.NPCs { "Drifter", "Finchi", - "Heniek", // <@!363404700445442050> (Kazurgundu#3791) + "Heniek", // <@!363404700445442050> (kazurgundu) "Fire", // <@!354362326947856384> (fire#0692) - "Barney Calhoun", // <@!634462901431697410> (Potato Power#6578) + "Barney Calhoun", // <@!634462901431697410> (potatostego) "XiaoEn0426", // <@!440448864772816896> (XiaoEn0426#9157) "Jeffred", // <@!295362230038560768> (Knight Solaire#0873) - "The Cooler Arthur", // <@!568263512523014154> (better artilery#0001) - "Markie", // <@!291141964039061504> (Markie#6969) + "The Cooler Arthur", // <@!568263512523014154> (gokuartillery) + "Markie", // <@!291141964039061504> (markie_) }; private static readonly string[] ClothierNames = { "Joeseph Jostar", + "Storm Havik", // <@!1013452363178197072> (fishnotduck) }; private static readonly string[] CyborgNames = { @@ -87,13 +88,13 @@ namespace CalamityMod.NPCs }; private static readonly string[] DemolitionistNames = { - "Tavish DeGroot", // <@!442447226992721930> (Magicoal#2655) + "Tavish DeGroot", // <@!442447226992721930> (magicoal) }; private static readonly string[] DryadNames = { "Rythmi", "Izuna", - "Jasmine", // <@!430532867479699456> (phantasmagoria#6777) + "Jasmine", // <@!430532867479699456> (phantasmagoria.) "Cybil", // <@!486507232666845185> (Captain Doofus#????) "Ruth", // <@!1001307586068492388> (Briny_Coffee#4393) }; @@ -102,13 +103,14 @@ namespace CalamityMod.NPCs { "Verth", "Gormer", // <@!287651204924833795> (Picasso's Bean#2819 -- RIP) - "TingFlarg", // <@!185605031716847616> (Smug#7160) + "TingFlarg", // <@!185605031716847616> (smugggo) "Driser", // <@!121996994406252544> (Driser#8630) - "Eddie Spaghetti", // <@!466397267407011841> (Eddie Spaghetti#0002) - "G'tok", // <@!335192200956608535> (gtoktas#7589) + "Eddie Spaghetti", // <@!466397267407011841> (nathansfriend) + "G'tok", // <@!335192200956608535> (gtoktas) "Katto", // <@!175972165504466944> (Katto#2858) - "Him", // <@!931019614958256139> (@himtheguy1) + "Him", // <@!931019614958256139> (himtheguy1) "Tooshiboots", // <@!333532730593771522> (ulmod) + "Neesh", // <@!175803493464932352> (xjetty) }; private static readonly string[] GolferNames = null; private static readonly string[] GuideNames = @@ -119,36 +121,37 @@ namespace CalamityMod.NPCs "Necroplasmic", "Devin", "Woffle", // <@!185980979427540992> (Chipbeam#2268) - "Cameron", // <@!340401981711712258> (CammyWammy#8634) - "Wilbur", // <@!295171926324805634> (ChaosChaos#5979) - "Good Game Design", // <@!564267767042277385> (Dominic Karma#7777) + "Cameron", // <@!340401981711712258> (cammywammy.) + "Wilbur", // <@!295171926324805634> (all_imperfect_chaos) + "Good Game Design", // <@!564267767042277385> (dominickarma) "Danmaku", // <@!756259562268524555> (Danmaku#2659) "Grylken", // <@!299970404435361802> (Grylken#1569) - "Outlaw", // <@!918311619480657922> (TheChosenOutlaw#8746) + "Outlaw", // <@!918311619480657922> (thechosenoutlaw) "Alfred Rend", // <@!606301806481375255> (Deadsqurp300#0907) "Leeman", // <@!281999243168841728> (Tweee#5831) "Mihai", // <@!373941893467209730> (cmihaii.) + "Aka Retribution", // <@!302318734633205761> (azurr_nihilo) }; private static readonly string[] MechanicNames = { "Lilly", - "Daawn", // <@!206162323541458944> (Daawnily#3859) + "Daawn", // <@!206162323541458944> (daawnily) "Robin", // <@!654737510030639112> (Altzeus#8687) - "Curly", // <@!673092101780668416> (Curly~Brace#4830) + "Curly", // <@!673092101780668416> (curly4830) }; private static readonly string[] MerchantNames = { - "Morshu", // <@!194931581826236416> (Uberransy#6969) + "Morshu", // <@!194931581826236416> (uberransy) }; private static readonly string[] NurseNames = { "Farsni", - "Fanny", // <@!799749125720637460> (zombiewolf511#4581) - "Mausi", // <@!194156349347594241> (Sadouken | Daniel#3996) + "Fanny", // <@!799749125720637460> (zombiewolf511) + "Mausi", // <@!194156349347594241> (sadouken) }; private static readonly string[] PainterNames = { - "Picasso", // <@!353316526306361347> (SCONICBOOM#2164 -- for the late Picasso's Bean#2819) + "Picasso", // <@!353316526306361347> (sconicboom -- for the late Picasso's Bean#2819) }; private static readonly string[] PartyGirlNames = { @@ -157,21 +160,28 @@ namespace CalamityMod.NPCs private static readonly string[] PirateNames = { "Tyler Van Hook", - "Cap'n Deek", // "Alex N" on Patreon - "Captain Billy Bones", // <@!699589229507772416> (DjackV#2882) + "Cap'n Deek", // "Alex N" on Patreon (No discord account) + "Captain Billy Bones", // <@!699589229507772416> (djackv) "Captain J. Crackers", // <@!233232602994049024> (Qyuuno#3031) }; private static readonly string[] PrincessNames = { - "Catalyst", // <@!156672312425316352> (xAqult#1122) - "Nyapano", // <@!120976656826368003> (Emi - Nyapano She/Her#4040) - "Jade", // <@!187395834625785869> (VeryMasterNinja#7728) - "Nyavi Aceso", // <@!270260920888852480> (Navigator#8739) + "Catalyst", // <@!156672312425316352> (xaqult) + "Nyapano", // <@!120976656826368003> (nyapano) + "Jade", // <@!187395834625785869> (verymasterninja) + "Nyavi Aceso", // <@!270260920888852480> (navigator.) + "everquartz", // <@!451343554451865611> (everquartz) + "Gwynevere", // <@!142752927348424704> (nuclearchaosazathoth) + }; + private static readonly string[] SantaClausNames = + { + "Jank", // <@!339950757472239616> (jankle_) }; private static readonly string[] SkeletonMerchantNames = { - "Sans Undertale", // <@!145379091648872450> (Shayy#5257) - "Papyrus Undertale", // <@!262663471189983242> (Nycro#0001) + "Sans Undertale", // <@!145379091648872450> (shayy) + "Papyrus Undertale", // <@!262663471189983242> (nycro) + "Mr. Bones", // <@!359215912856977408> (jaybones.) }; private static readonly string[] SteampunkerNames = { @@ -180,15 +190,15 @@ namespace CalamityMod.NPCs }; private static readonly string[] StylistNames = { - "Amber", // <@!114677116473180169> (Mishiro Usui#1295) - "Faith", // <@!509050283871961123> (Toasty#1007) - "Xsiana", // <@!625780237489143839> (xiana.#0015) + "Amber", // <@!114677116473180169> (mishirousui) + "Faith", // <@!509050283871961123> (toasty1007) + "Xsiana", // <@!625780237489143839> (lokistic) }; private static readonly string[] TavernkeepNames = { - "Tim Lockwood", // <@!605839945483026434> (Deimelo#0001) - "Sir Samuel Winchester Jenkins Kester II", // <@!107659695749070848> (Ryaegos#1661) - "Brutus", // <@!591889650692521984> (Brutus#4337) + "Tim Lockwood", // <@!605839945483026434> (pomvoid) + "Sir Samuel Winchester Jenkins Kester II", // <@!107659695749070848> (ryaegos) + "Brutus", // <@!591889650692521984> (.brutus._) "Sloth", // <@!486265327387279391> (BossyPunch#4983) }; private static readonly string[] TaxCollectorNames = @@ -198,7 +208,8 @@ namespace CalamityMod.NPCs private static readonly string[] TravelingMerchantNames = { "Stan Pines", - "Slap Battles", // <@!923504188615450654> (Conquestor#9009) + "Slap Battles", // <@!923504188615450654> (gravityglider.) + "Matt Walsh", // <@!522970788203069442> (phallguy) }; private static readonly string[] TruffleNames = { @@ -208,26 +219,26 @@ namespace CalamityMod.NPCs { "Sok'ar", "Toxin", // <@!348174404984766465> (Toxin#9598), - "Mixcoatl", // <@!284775927294984203> (SharZz#7777) - "Khatunz", // <@!303022375191183360> (jackshiz#7839) - "Amnesia Wapers", // <@!326821498323075073> (Retarded Advice from a Retard#6969) + "Mixcoatl", // <@!284775927294984203> (.sharzz) + "Khatunz", // <@!303022375191183360> (jackshiz) + "Amnesia Wapers", // <@!326821498323075073> (retardedadvicefromaretard) }; private static readonly string[] WizardNames = { - "Mage One-Trick", // <@!340996105460514816> (pixlgray) - going of off memory on this one + "Mage One-Trick", // <@!340996105460514816> (pixlgray) "Inorim, son of Ivukey", "Jensen", - "Merasmus", // <@!288066987819663360> (Spider pee pee#3328) + "Merasmus", // <@!288066987819663360> (spiderprovidence) "Habolo", // <@!163028025494077441> (ChristmasGoat#7810) - "Ortho", // <@!264984390910738432> (Worcuus#5225) - "Chris Tallballs", // <@!770211589076418571> (Bewearium#1111) - "Syethas", // <@!325413275066171393> (CosmicStarIight#4430) + "Ortho", // <@!264984390910738432> (worcuus) + "Chris Tallballs", // <@!770211589076418571> (bewearium) + "Syethas", // <@!325413275066171393> (cosmicstariight) "Nextdoor Psycho", // <@!173261518572486656> (⋈-NextdoorPsycho-⋈#0001) }; private static readonly string[] ZoologistNames = { "Kiriku", // <@!395312478160027668> (rulosss#6814) - "Lacuna", // <@!790746689211203604> (Lacuna#8629) + "Lacuna", // <@!790746689211203604> (_lacuna_) "Mae Borowski", //<@!219158690433990656> (justakkolite) }; @@ -243,19 +254,19 @@ namespace CalamityMod.NPCs private const int TownDogHuskyVanillaNames = 16; private static readonly string[] TownDogNames = { - "Ozymandias", // <@!146333264871686145> (Ozzatron#0001) + "Ozymandias", // <@!146333264871686145> (ozzatron) }; private static readonly string[] TownDogLabradorNames = { - "Riley", // <@!260875558592708619> (potion pal#9979) + "Riley", // <@!260875558592708619> (potionpal) }; private static readonly string[] TownDogPitBullNames = { - "Splinter", // <@!320320801213775873> (Kaimonick#1738) + "Splinter", // <@!320320801213775873> (kaimonick) }; private static readonly string[] TownDogBeagleNames = { - "Kendra", // <@!237247188005158912> (LordMetarex#6407) + "Kendra", // <@!237247188005158912> (lordmetarex) }; private static readonly string[] TownDogCorgiNames = null; private static readonly string[] TownDogDalmatianNames = null; @@ -272,21 +283,21 @@ namespace CalamityMod.NPCs private const int TownCatWhiteVanillaNames = 15; private static readonly string[] TownCatNames = { - "Smoogle", // <@!709968379334623274> (smoogle#5672) + "Smoogle", // <@!709968379334623274> (smooglin) "The Meowurer of Gods", // <@!385949114271268864> (GP#7876) - "Katsafaros", // <@!190595401328492544> (NavyGuy#2650) + "Katsafaros", // <@!190595401328492544> (gr_mm) "Lucerne", // <@!271954788676141066> (lord_lucerne) "Milo", // <@!401849201597874179> (maskedmilo) - "Octo", // <@!796112889353994281> (OctolingGrimm#8888) + "Octo", // <@!796112889353994281> (octolinggrimm) }; private static readonly string[] TownCatSiameseNames = null; private static readonly string[] TownCatBlackNames = { - "Bear", // <@!183424826407518208> (Lilac Vrt Olligoci#5585) + "Bear", // <@!183424826407518208> (lilac_vrt_olligoci) }; private static readonly string[] TownCatOrangeTabbyNames = { - "Felix" // <@!183424826407518208> (Lilac Vrt Olligoci#5585) + "Felix" // <@!183424826407518208> (lilac_vrt_olligoci) }; private static readonly string[] TownCatRussianBlueNames = null; private static readonly string[] TownCatSilverNames = null; @@ -333,13 +344,13 @@ namespace CalamityMod.NPCs // PatreonNames can be null, so can global names, it short circuits in the next step if so int combinedLength = (patreonNames?.Length ?? 0) + (globalNames?.Length ?? 0); int index = Main.rand.Next(numVanillaNames + combinedLength); - + // If the roll isn't low enough, then a "vanilla name" was picked, meaning we change nothing. if (index >= combinedLength) return currentName; - - + + // Change the name to be a randomly selected Patreon name if the roll is low enough. if (index >= globalNames.Length) return patreonNames[index - globalNames.Length]; @@ -502,6 +513,9 @@ namespace CalamityMod.NPCs case NPCID.Princess: AddNewNames(nameList, PrincessNames); break; + case NPCID.SantaClaus: + AddNewNames(nameList, SantaClausNames); + break; case NPCID.SkeletonMerchant: AddNewNames(nameList, SkeletonMerchantNames); break; @@ -620,120 +634,47 @@ namespace CalamityMod.NPCs #endregion #region NPC New Shop Alert + + public static List<(int, Predicate, Action)> npcAlertList = new List<(int, Predicate, Action)>() + { + (NPCID.Merchant, (Player player) => player.Calamity().newMerchantInventory, (Player player, bool enabled) =>{ player.Calamity().newMerchantInventory = enabled; }), + (NPCID.Painter, (Player player) => player.Calamity().newPainterInventory,(Player player, bool enabled) =>{ player.Calamity().newPainterInventory = enabled; }), + (NPCID.Golfer, (Player player) => player.Calamity().newGolferInventory, (Player player, bool enabled) =>{ player.Calamity().newGolferInventory = enabled; }), + (NPCID.BestiaryGirl, (Player player) => player.Calamity().newZoologistInventory,(Player player, bool enabled) =>{ player.Calamity().newZoologistInventory = enabled; }), + (NPCID.DyeTrader, (Player player) => player.Calamity().newDyeTraderInventory, (Player player, bool enabled) =>{ player.Calamity().newDyeTraderInventory = enabled; }), + (NPCID.PartyGirl, (Player player) => player.Calamity().newPartyGirlInventory,(Player player, bool enabled) =>{ player.Calamity().newPartyGirlInventory = enabled; }), + (NPCID.Stylist, (Player player) => player.Calamity().newStylistInventory, (Player player, bool enabled) =>{ player.Calamity().newStylistInventory = enabled; }), + (NPCID.Demolitionist, (Player player) => player.Calamity().newDemolitionistInventory, (Player player, bool enabled) =>{ player.Calamity().newDemolitionistInventory = enabled; }), + (NPCID.Dryad, (Player player) => player.Calamity().newDryadInventory, (Player player, bool enabled) =>{ player.Calamity().newDryadInventory = enabled; }), + (NPCID.DD2Bartender, (Player player) => player.Calamity().newTavernkeepInventory, (Player player, bool enabled) =>{ player.Calamity().newTavernkeepInventory = enabled; }), + (NPCID.ArmsDealer, (Player player) => player.Calamity().newArmsDealerInventory, (Player player, bool enabled) =>{ player.Calamity().newArmsDealerInventory = enabled; }), + (NPCID.GoblinTinkerer, (Player player) => player.Calamity().newGoblinTinkererInventory,(Player player, bool enabled) =>{ player.Calamity().newGoblinTinkererInventory = enabled; }), + (NPCID.WitchDoctor, (Player player) => player.Calamity().newWitchDoctorInventory, (Player player, bool enabled) =>{ player.Calamity().newWitchDoctorInventory = enabled; }), + (NPCID.Clothier, (Player player) => player.Calamity().newClothierInventory, (Player player, bool enabled) =>{ player.Calamity().newClothierInventory = enabled; }), + (NPCID.Mechanic, (Player player) => player.Calamity().newMechanicInventory, (Player player, bool enabled) =>{ player.Calamity().newMechanicInventory = enabled; }), + (NPCID.Pirate, (Player player) => player.Calamity().newPirateInventory, (Player player, bool enabled) =>{ player.Calamity().newPirateInventory = enabled; }), + (NPCID.Truffle, (Player player) => player.Calamity().newTruffleInventory,(Player player, bool enabled) =>{ player.Calamity().newTruffleInventory = enabled; }), + (NPCID.Wizard, (Player player) => player.Calamity().newWizardInventory, (Player player, bool enabled) =>{ player.Calamity().newWizardInventory = enabled; }), + (NPCID.Steampunker, (Player player) => player.Calamity().newSteampunkerInventory, (Player player, bool enabled) =>{ player.Calamity().newSteampunkerInventory = enabled; }), + (NPCID.Cyborg,(Player player) => player.Calamity().newCyborgInventory, (Player player, bool enabled) =>{ player.Calamity().newCyborgInventory = enabled; }), + (NPCID.Princess, (Player player) => player.Calamity().newPrincessInventory,(Player player, bool enabled) =>{ player.Calamity().newPrincessInventory = enabled; }), + (NPCID.SkeletonMerchant, (Player player) => player.Calamity().newSkeletonMerchantInventory, (Player player, bool enabled) =>{ player.Calamity().newSkeletonMerchantInventory = enabled; }), + (NPCType(), (Player player) => player.Calamity().newAmidiasInventory,(Player player, bool enabled) =>{ player.Calamity().newAmidiasInventory = enabled; }), + (NPCType(), (Player player) => player.Calamity().newBanditInventory,(Player player, bool enabled) =>{ player.Calamity().newBanditInventory = enabled; }), + (NPCType(), (Player player) => player.Calamity().newCirrusInventory,(Player player, bool enabled) =>{ player.Calamity().newCirrusInventory = enabled; }), + (NPCType(), (Player player) => player.Calamity().newPermafrostInventory,(Player player, bool enabled) =>{ player.Calamity().newPermafrostInventory = enabled; }), + (NPCType(), (Player player) => player.Calamity().newCalamitasInventory,(Player player, bool enabled) =>{ player.Calamity().newCalamitasInventory = enabled; }) // lol + }; + public void TownNPCAlertSystem(NPC npc, Mod mod, SpriteBatch spriteBatch) { if (CalamityConfig.Instance.ShopNewAlert && npc.townNPC) { - if (npc.type == NPCType() && Main.LocalPlayer.Calamity().newPermafrostInventory) + for (int i = 0; i < npcAlertList.Count; i++) { - DrawNewInventoryAlert(npc); - } - else if (npc.type == NPCType() && Main.LocalPlayer.Calamity().newCirrusInventory) - { - DrawNewInventoryAlert(npc); - } - else if (npc.type == NPCType() && Main.LocalPlayer.Calamity().newAmidiasInventory) - { - DrawNewInventoryAlert(npc); - } - else if (npc.type == NPCType() && Main.LocalPlayer.Calamity().newBanditInventory) - { - DrawNewInventoryAlert(npc); - } - else - { - switch (npc.type) + if (npc.type == npcAlertList[i].Item1 && npcAlertList[i].Item2(Main.LocalPlayer)) { - case NPCID.Merchant: - if (Main.LocalPlayer.Calamity().newMerchantInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Painter: - if (Main.LocalPlayer.Calamity().newPainterInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Golfer: - if (Main.LocalPlayer.Calamity().newGolferInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.BestiaryGirl: - if (Main.LocalPlayer.Calamity().newZoologistInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.DyeTrader: - if (Main.LocalPlayer.Calamity().newDyeTraderInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.PartyGirl: - if (Main.LocalPlayer.Calamity().newPartyGirlInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Stylist: - if (Main.LocalPlayer.Calamity().newStylistInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Demolitionist: - if (Main.LocalPlayer.Calamity().newDemolitionistInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Dryad: - if (Main.LocalPlayer.Calamity().newDryadInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.DD2Bartender: - if (Main.LocalPlayer.Calamity().newTavernkeepInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.ArmsDealer: - if (Main.LocalPlayer.Calamity().newArmsDealerInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.GoblinTinkerer: - if (Main.LocalPlayer.Calamity().newGoblinTinkererInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.WitchDoctor: - if (Main.LocalPlayer.Calamity().newWitchDoctorInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Clothier: - if (Main.LocalPlayer.Calamity().newClothierInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Mechanic: - if (Main.LocalPlayer.Calamity().newMechanicInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Pirate: - if (Main.LocalPlayer.Calamity().newPirateInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Truffle: - if (Main.LocalPlayer.Calamity().newTruffleInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Wizard: - if (Main.LocalPlayer.Calamity().newWizardInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Steampunker: - if (Main.LocalPlayer.Calamity().newSteampunkerInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Cyborg: - if (Main.LocalPlayer.Calamity().newCyborgInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Princess: - if (Main.LocalPlayer.Calamity().newPrincessInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.SkeletonMerchant: - if (Main.LocalPlayer.Calamity().newSkeletonMerchantInventory) - DrawNewInventoryAlert(npc); - break; - default: - break; + DrawNewInventoryAlert(npc); } } @@ -769,176 +710,27 @@ namespace CalamityMod.NPCs public override void OnChatButtonClicked(NPC npc, bool firstButton) { - if (npc.townNPC) + for (int i = 0; i < npcAlertList.Count; i++) { - switch (npc.type) + if (npc.type == npcAlertList[i].Item1) { - case NPCID.Merchant: - Main.LocalPlayer.Calamity().newMerchantInventory = false; - break; - case NPCID.Painter: - Main.LocalPlayer.Calamity().newPainterInventory = false; - break; - case NPCID.Golfer: - Main.LocalPlayer.Calamity().newGolferInventory = false; - break; - case NPCID.BestiaryGirl: - Main.LocalPlayer.Calamity().newZoologistInventory = false; - break; - case NPCID.DyeTrader: - Main.LocalPlayer.Calamity().newDyeTraderInventory = false; - break; - case NPCID.PartyGirl: - Main.LocalPlayer.Calamity().newPartyGirlInventory = false; - break; - case NPCID.Stylist: - Main.LocalPlayer.Calamity().newStylistInventory = false; - break; - case NPCID.Demolitionist: - Main.LocalPlayer.Calamity().newDemolitionistInventory = false; - break; - case NPCID.Dryad: - Main.LocalPlayer.Calamity().newDryadInventory = false; - break; - case NPCID.DD2Bartender: - Main.LocalPlayer.Calamity().newTavernkeepInventory = false; - break; - case NPCID.ArmsDealer: - Main.LocalPlayer.Calamity().newArmsDealerInventory = false; - break; - case NPCID.GoblinTinkerer: - Main.LocalPlayer.Calamity().newGoblinTinkererInventory = false; - break; - case NPCID.WitchDoctor: - Main.LocalPlayer.Calamity().newWitchDoctorInventory = false; - break; - case NPCID.Clothier: - Main.LocalPlayer.Calamity().newClothierInventory = false; - break; - case NPCID.Mechanic: - Main.LocalPlayer.Calamity().newMechanicInventory = false; - break; - case NPCID.Pirate: - Main.LocalPlayer.Calamity().newPirateInventory = false; - break; - case NPCID.Truffle: - Main.LocalPlayer.Calamity().newTruffleInventory = false; - break; - case NPCID.Wizard: - Main.LocalPlayer.Calamity().newWizardInventory = false; - break; - case NPCID.Steampunker: - Main.LocalPlayer.Calamity().newSteampunkerInventory = false; - break; - case NPCID.Cyborg: - Main.LocalPlayer.Calamity().newCyborgInventory = false; - break; - case NPCID.Princess: - Main.LocalPlayer.Calamity().newPrincessInventory = false; - break; - case NPCID.SkeletonMerchant: - Main.LocalPlayer.Calamity().newSkeletonMerchantInventory = false; - break; - default: - break; + npcAlertList[i].Item3(Main.LocalPlayer, false); } } } public static void SetNewShopVariable(int[] types, bool alreadySet) { + string npcname = ContentSamples.NpcsByNetId[types[0]].FullName; if (!alreadySet) { for (int i = 0; i < types.Length; i++) { - if (types[i] == NPCType()) + for (int n = 0; n < npcAlertList.Count; n++) { - Main.LocalPlayer.Calamity().newPermafrostInventory = true; - } - else if (types[i] == NPCType()) - { - Main.LocalPlayer.Calamity().newCirrusInventory = true; - } - else if (types[i] == NPCType()) - { - Main.LocalPlayer.Calamity().newAmidiasInventory = true; - } - else if (types[i] == NPCType()) - { - Main.LocalPlayer.Calamity().newBanditInventory = true; - } - else - { - switch (types[i]) + if (types[i] == npcAlertList[n].Item1) { - case NPCID.Merchant: - Main.LocalPlayer.Calamity().newMerchantInventory = true; - break; - case NPCID.Painter: - Main.LocalPlayer.Calamity().newPainterInventory = true; - break; - case NPCID.Golfer: - Main.LocalPlayer.Calamity().newGolferInventory = true; - break; - case NPCID.BestiaryGirl: - Main.LocalPlayer.Calamity().newZoologistInventory = true; - break; - case NPCID.DyeTrader: - Main.LocalPlayer.Calamity().newDyeTraderInventory = true; - break; - case NPCID.PartyGirl: - Main.LocalPlayer.Calamity().newPartyGirlInventory = true; - break; - case NPCID.Stylist: - Main.LocalPlayer.Calamity().newStylistInventory = true; - break; - case NPCID.Demolitionist: - Main.LocalPlayer.Calamity().newDemolitionistInventory = true; - break; - case NPCID.Dryad: - Main.LocalPlayer.Calamity().newDryadInventory = true; - break; - case NPCID.DD2Bartender: - Main.LocalPlayer.Calamity().newTavernkeepInventory = true; - break; - case NPCID.ArmsDealer: - Main.LocalPlayer.Calamity().newArmsDealerInventory = true; - break; - case NPCID.GoblinTinkerer: - Main.LocalPlayer.Calamity().newGoblinTinkererInventory = true; - break; - case NPCID.WitchDoctor: - Main.LocalPlayer.Calamity().newWitchDoctorInventory = true; - break; - case NPCID.Clothier: - Main.LocalPlayer.Calamity().newClothierInventory = true; - break; - case NPCID.Mechanic: - Main.LocalPlayer.Calamity().newMechanicInventory = true; - break; - case NPCID.Pirate: - Main.LocalPlayer.Calamity().newPirateInventory = true; - break; - case NPCID.Truffle: - Main.LocalPlayer.Calamity().newTruffleInventory = true; - break; - case NPCID.Wizard: - Main.LocalPlayer.Calamity().newWizardInventory = true; - break; - case NPCID.Steampunker: - Main.LocalPlayer.Calamity().newSteampunkerInventory = true; - break; - case NPCID.Cyborg: - Main.LocalPlayer.Calamity().newCyborgInventory = true; - break; - case NPCID.Princess: - Main.LocalPlayer.Calamity().newPrincessInventory = true; - break; - case NPCID.SkeletonMerchant: - Main.LocalPlayer.Calamity().newSkeletonMerchantInventory = true; - break; - default: - break; + npcAlertList[n].Item3(Main.LocalPlayer, true); } } } @@ -1343,7 +1135,9 @@ namespace CalamityMod.NPCs shop.AddWithCustomValue(ItemID.JungleRose, Item.buyPrice(gold: 2)) .AddWithCustomValue(ItemID.NaturesGift, Item.buyPrice(gold: 10)) .Add(ItemType()) - .AddWithCustomValue(ItemID.Grapes, Item.buyPrice(gold: 2, silver: 50), Condition.HappyEnough, Condition.DownedSkeletron); + .AddWithCustomValue(ItemID.Grapes, Item.buyPrice(gold: 2, silver: 50), Condition.HappyEnough, Condition.DownedSkeletron) + .Add(ItemID.CorruptSeeds, Condition.CrimsonWorld, Condition.InGraveyard) + .Add(ItemID.CrimsonSeeds, Condition.CorruptWorld, Condition.InGraveyard); } if (type == NPCID.GoblinTinkerer) diff --git a/NPCs/CalamityPolarityNPC.cs b/NPCs/CalamityPolarityNPC.cs index f3454b8521..6eff97e753 100644 --- a/NPCs/CalamityPolarityNPC.cs +++ b/NPCs/CalamityPolarityNPC.cs @@ -43,7 +43,7 @@ namespace CalamityMod.NPCs public void applyPolarity(float update, NPC npc) { //Round the polarity to avoid ending up with a polarity that's got decimals which will cause it to forever alternate between positive and negative. - CurPolarity = (float)Math.Round(update); + CurPolarity = (float)Math.Round(update); Color pulseColor = AdamantiteParticleAccelerator.LightColors[update < 0 ? 1 : 0]; pulses.Add(new AuraPulseRing(pulseColor, new Vector2(Math.Max(npc.width / 156f * 1.1f, 0.25f) , 0.3f), new Vector2(Math.Max(npc.width / 156f * 1.5f, 0.4f), 0.01f), 40, npc)); } @@ -95,6 +95,10 @@ namespace CalamityMod.NPCs public override void PostDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { + // I don't know who would be using this while also inflicting miracle blight, but in that rare case, do not draw these. + if (npc.Calamity().miracleBlight > 0) + return; + Main.spriteBatch.End(); Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); diff --git a/NPCs/CalamityVanillaMinibossesAI.cs b/NPCs/CalamityVanillaMinibossesAI.cs index 6decfe9f1c..9c8bb57cb4 100644 --- a/NPCs/CalamityVanillaMinibossesAI.cs +++ b/NPCs/CalamityVanillaMinibossesAI.cs @@ -468,22 +468,22 @@ namespace CalamityMod.NPCs } else if (npc.ai[3] == 0f && npc.localAI[2] % 30f == 0f && npc.localAI[2] > 30f) { - float num856 = 10f; - Vector2 vector109 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f + 30f); - if (!WorldGen.SolidTile((int)vector109.X / 16, (int)vector109.Y / 16)) + float greekFireSpeed = 10f; + Vector2 greekFireSpawnPos = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f + 30f); + if (!WorldGen.SolidTile((int)greekFireSpawnPos.X / 16, (int)greekFireSpawnPos.Y / 16)) { - float num857 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector109.X; - float num858 = Main.player[npc.target].position.Y - vector109.Y; - num857 += (float)Main.rand.Next(-50, 51); - num858 += (float)Main.rand.Next(50, 201); - num858 *= 0.2f; - float num859 = (float)Math.Sqrt((double)(num857 * num857 + num858 * num858)); - num859 = num856 / num859; - num857 *= num859; - num858 *= num859; - num857 *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f; - num858 *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector109.X, vector109.Y, num857, num858, ProjectileID.GreekFire1 + Main.rand.Next(3), 60, 0f, Main.myPlayer, 0f, 0f); + float greekFireTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - greekFireSpawnPos.X; + float greekFireTargetY = Main.player[npc.target].position.Y - greekFireSpawnPos.Y; + greekFireTargetX += (float)Main.rand.Next(-50, 51); + greekFireTargetY += (float)Main.rand.Next(50, 201); + greekFireTargetY *= 0.2f; + float greekFireTargetDist = (float)Math.Sqrt((double)(greekFireTargetX * greekFireTargetX + greekFireTargetY * greekFireTargetY)); + greekFireTargetDist = greekFireSpeed / greekFireTargetDist; + greekFireTargetX *= greekFireTargetDist; + greekFireTargetY *= greekFireTargetDist; + greekFireTargetX *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f; + greekFireTargetY *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f; + Projectile.NewProjectile(npc.GetSource_FromAI(), greekFireSpawnPos.X, greekFireSpawnPos.Y, greekFireTargetX, greekFireTargetY, ProjectileID.GreekFire1 + Main.rand.Next(3), 60, 0f, Main.myPlayer, 0f, 0f); } } } @@ -493,18 +493,18 @@ namespace CalamityMod.NPCs npc.TargetClosest(true); npc.ai[0] = 1f; - int num861 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PumpkingBlade, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num861].ai[0] = -1f; - Main.npc[num861].ai[1] = (float)npc.whoAmI; - Main.npc[num861].target = npc.target; - Main.npc[num861].netUpdate = true; + int pumpkingBlades = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PumpkingBlade, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[pumpkingBlades].ai[0] = -1f; + Main.npc[pumpkingBlades].ai[1] = (float)npc.whoAmI; + Main.npc[pumpkingBlades].target = npc.target; + Main.npc[pumpkingBlades].netUpdate = true; - num861 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PumpkingBlade, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num861].ai[0] = 1f; - Main.npc[num861].ai[1] = (float)npc.whoAmI; - Main.npc[num861].ai[3] = 150f; - Main.npc[num861].target = npc.target; - Main.npc[num861].netUpdate = true; + pumpkingBlades = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PumpkingBlade, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[pumpkingBlades].ai[0] = 1f; + Main.npc[pumpkingBlades].ai[1] = (float)npc.whoAmI; + Main.npc[pumpkingBlades].ai[3] = 150f; + Main.npc[pumpkingBlades].target = npc.target; + Main.npc[pumpkingBlades].netUpdate = true; } if (Main.player[npc.target].dead || Math.Abs(npc.position.X - Main.player[npc.target].position.X) > 2000f || Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 2000f) @@ -539,27 +539,27 @@ namespace CalamityMod.NPCs } } - Vector2 vector110 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num862 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector110.X; - float num863 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - 200f - vector110.Y; - float num864 = (float)Math.Sqrt((double)(num862 * num862 + num863 * num863)); - float num865 = 8f; + Vector2 aggressivePosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float aggressiveTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - aggressivePosition.X; + float aggressiveTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - 200f - aggressivePosition.Y; + float aggressiveTargetDist = (float)Math.Sqrt((double)(aggressiveTargetX * aggressiveTargetX + aggressiveTargetY * aggressiveTargetY)); + float aggressiveSpeed = 8f; if (npc.ai[3] == 1f) { - if (num864 > 900f) - num865 = 14f; - else if (num864 > 600f) - num865 = 12f; - else if (num864 > 300f) - num865 = 10f; + if (aggressiveTargetDist > 900f) + aggressiveSpeed = 14f; + else if (aggressiveTargetDist > 600f) + aggressiveSpeed = 12f; + else if (aggressiveTargetDist > 300f) + aggressiveSpeed = 10f; } - if (num864 > 50f) + if (aggressiveTargetDist > 50f) { - num864 = num865 / num864; - npc.velocity.X = (npc.velocity.X * 14f + num862 * num864) / 15f; - npc.velocity.Y = (npc.velocity.Y * 14f + num863 * num864) / 15f; + aggressiveTargetDist = aggressiveSpeed / aggressiveTargetDist; + npc.velocity.X = (npc.velocity.X * 14f + aggressiveTargetX * aggressiveTargetDist) / 15f; + npc.velocity.Y = (npc.velocity.Y * 14f + aggressiveTargetY * aggressiveTargetDist) / 15f; } } else if (npc.ai[1] == 1f) @@ -571,14 +571,14 @@ namespace CalamityMod.NPCs npc.ai[1] = 0f; } - Vector2 vector111 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num866 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector111.X; - float num867 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector111.Y; - float num868 = (float)Math.Sqrt((double)(num866 * num866 + num867 * num867)); - num868 = 20f / num868; + Vector2 scytheAttackPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float scytheAttackTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - scytheAttackPosition.X; + float scytheAttackTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - scytheAttackPosition.Y; + float scytheAttackTargetDist = (float)Math.Sqrt((double)(scytheAttackTargetX * scytheAttackTargetX + scytheAttackTargetY * scytheAttackTargetY)); + scytheAttackTargetDist = 20f / scytheAttackTargetDist; - npc.velocity.X = (npc.velocity.X * 49f + num866 * num868) / 50f; - npc.velocity.Y = (npc.velocity.Y * 49f + num867 * num868) / 50f; + npc.velocity.X = (npc.velocity.X * 49f + scytheAttackTargetX * scytheAttackTargetDist) / 50f; + npc.velocity.Y = (npc.velocity.Y * 49f + scytheAttackTargetY * scytheAttackTargetDist) / 50f; } else if (npc.ai[1] == 2f) { @@ -620,17 +620,17 @@ namespace CalamityMod.NPCs { npc.localAI[1] = 0f; - float num869 = 0.01f; - Vector2 vector112 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f + 30f); - float num870 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector112.X; - float num871 = Main.player[npc.target].position.Y - vector112.Y; - float num872 = (float)Math.Sqrt((double)(num870 * num870 + num871 * num871)); + float scytheProjSpeed = 0.01f; + Vector2 scytheProjSpawn = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f + 30f); + float scytheProjTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - scytheProjSpawn.X; + float scytheProjTargetY = Main.player[npc.target].position.Y - scytheProjSpawn.Y; + float scytheProjTargetDist = (float)Math.Sqrt((double)(scytheProjTargetX * scytheProjTargetX + scytheProjTargetY * scytheProjTargetY)); - num872 = num869 / num872; - num870 *= num872; - num871 *= num872; + scytheProjTargetDist = scytheProjSpeed / scytheProjTargetDist; + scytheProjTargetX *= scytheProjTargetDist; + scytheProjTargetY *= scytheProjTargetDist; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, num870, num871, ProjectileID.FlamingScythe, 70, 0f, Main.myPlayer, npc.rotation, (float)npc.spriteDirection); + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, scytheProjTargetX, scytheProjTargetY, ProjectileID.FlamingScythe, 70, 0f, Main.myPlayer, npc.rotation, (float)npc.spriteDirection); } } @@ -654,53 +654,53 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } - Vector2 vector113 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num874 = (Main.player[npc.target].Center.X + Main.npc[(int)npc.ai[1]].Center.X) / 2f; - float num875 = (Main.player[npc.target].Center.Y + Main.npc[(int)npc.ai[1]].Center.Y) / 2f; - num874 += -170f * npc.ai[0] - vector113.X; - num875 += 90f - vector113.Y; + Vector2 scytheSwipePosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float scytheSwipeTargetX = (Main.player[npc.target].Center.X + Main.npc[(int)npc.ai[1]].Center.X) / 2f; + float scytheSwipeTargetY = (Main.player[npc.target].Center.Y + Main.npc[(int)npc.ai[1]].Center.Y) / 2f; + scytheSwipeTargetX += -170f * npc.ai[0] - scytheSwipePosition.X; + scytheSwipeTargetY += 90f - scytheSwipePosition.Y; - float num876 = Math.Abs(Main.player[npc.target].Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(Main.player[npc.target].Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); - if (num876 > 700f) + float scytheSwipeReelbackDist = Math.Abs(Main.player[npc.target].Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(Main.player[npc.target].Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); + if (scytheSwipeReelbackDist > 700f) { - num874 = Main.npc[(int)npc.ai[1]].Center.X - 170f * npc.ai[0] - vector113.X; - num875 = Main.npc[(int)npc.ai[1]].Center.Y + 90f - vector113.Y; + scytheSwipeTargetX = Main.npc[(int)npc.ai[1]].Center.X - 170f * npc.ai[0] - scytheSwipePosition.X; + scytheSwipeTargetY = Main.npc[(int)npc.ai[1]].Center.Y + 90f - scytheSwipePosition.Y; } - float num877 = (float)Math.Sqrt((double)(num874 * num874 + num875 * num875)); - float num878 = 8f; - if (num877 > 1000f) - num878 = 23f; - else if (num877 > 800f) - num878 = 20f; - else if (num877 > 600f) - num878 = 17f; - else if (num877 > 400f) - num878 = 14f; - else if (num877 > 200f) - num878 = 11f; + float scytheSwipeTargetDist = (float)Math.Sqrt((double)(scytheSwipeTargetX * scytheSwipeTargetX + scytheSwipeTargetY * scytheSwipeTargetY)); + float scytheSwipeSpeed = 8f; + if (scytheSwipeTargetDist > 1000f) + scytheSwipeSpeed = 23f; + else if (scytheSwipeTargetDist > 800f) + scytheSwipeSpeed = 20f; + else if (scytheSwipeTargetDist > 600f) + scytheSwipeSpeed = 17f; + else if (scytheSwipeTargetDist > 400f) + scytheSwipeSpeed = 14f; + else if (scytheSwipeTargetDist > 200f) + scytheSwipeSpeed = 11f; if (npc.ai[0] < 0f && npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X) - num874 -= 4f; + scytheSwipeTargetX -= 4f; if (npc.ai[0] > 0f && npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X) - num874 += 4f; + scytheSwipeTargetX += 4f; - num877 = num878 / num877; - npc.velocity.X = (npc.velocity.X * 14f + num874 * num877) / 15f; - npc.velocity.Y = (npc.velocity.Y * 14f + num875 * num877) / 15f; - num877 = (float)Math.Sqrt((double)(num874 * num874 + num875 * num875)); + scytheSwipeTargetDist = scytheSwipeSpeed / scytheSwipeTargetDist; + npc.velocity.X = (npc.velocity.X * 14f + scytheSwipeTargetX * scytheSwipeTargetDist) / 15f; + npc.velocity.Y = (npc.velocity.Y * 14f + scytheSwipeTargetY * scytheSwipeTargetDist) / 15f; + scytheSwipeTargetDist = (float)Math.Sqrt((double)(scytheSwipeTargetX * scytheSwipeTargetX + scytheSwipeTargetY * scytheSwipeTargetY)); - if (num877 > 20f) - npc.rotation = (float)Math.Atan2((double)num875, (double)num874) + MathHelper.PiOver2; + if (scytheSwipeTargetDist > 20f) + npc.rotation = (float)Math.Atan2((double)scytheSwipeTargetY, (double)scytheSwipeTargetX) + MathHelper.PiOver2; } else if (npc.ai[2] == 1f) { - Vector2 vector114 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num879 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector114.X; - float num880 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector114.Y; - float num881 = (float)Math.Sqrt((double)(num879 * num879 + num880 * num880)); + Vector2 scytheReturnPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float scytheReturnTargetX = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - scytheReturnPosition.X; + float scytheReturnTargetY = Main.npc[(int)npc.ai[1]].position.Y + 230f - scytheReturnPosition.Y; + float scytheReturnTargetDist = (float)Math.Sqrt((double)(scytheReturnTargetX * scytheReturnTargetX + scytheReturnTargetY * scytheReturnTargetY)); - npc.rotation = (float)Math.Atan2((double)num880, (double)num879) + MathHelper.PiOver2; + npc.rotation = (float)Math.Atan2((double)scytheReturnTargetY, (double)scytheReturnTargetX) + MathHelper.PiOver2; npc.velocity.X *= 0.95f; npc.velocity.Y -= 0.3f; @@ -712,32 +712,32 @@ namespace CalamityMod.NPCs npc.TargetClosest(true); npc.ai[2] = 2f; - vector114 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num879 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector114.X; - num880 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector114.Y; - num881 = (float)Math.Sqrt((double)(num879 * num879 + num880 * num880)); - num881 = 24f / num881; + scytheReturnPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + scytheReturnTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - scytheReturnPosition.X; + scytheReturnTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - scytheReturnPosition.Y; + scytheReturnTargetDist = (float)Math.Sqrt((double)(scytheReturnTargetX * scytheReturnTargetX + scytheReturnTargetY * scytheReturnTargetY)); + scytheReturnTargetDist = 24f / scytheReturnTargetDist; - npc.velocity.X = num879 * num881; - npc.velocity.Y = num880 * num881; + npc.velocity.X = scytheReturnTargetX * scytheReturnTargetDist; + npc.velocity.Y = scytheReturnTargetY * scytheReturnTargetDist; npc.netUpdate = true; } } else if (npc.ai[2] == 2f) { - float num882 = Math.Abs(npc.Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(npc.Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); + float scytheReturnDestination = Math.Abs(npc.Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(npc.Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); - if (npc.position.Y > Main.player[npc.target].position.Y || npc.velocity.Y < 0f || num882 > 800f) + if (npc.position.Y > Main.player[npc.target].position.Y || npc.velocity.Y < 0f || scytheReturnDestination > 800f) npc.ai[2] = 3f; } else if (npc.ai[2] == 4f) { - Vector2 vector115 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num883 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector115.X; - float num884 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector115.Y; - float num885 = (float)Math.Sqrt((double)(num883 * num883 + num884 * num884)); + Vector2 scytheLesserSwipePos = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float scytheLesserSwipeTargetX = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - scytheLesserSwipePos.X; + float scytheLesserSwipeTargetY = Main.npc[(int)npc.ai[1]].position.Y + 230f - scytheLesserSwipePos.Y; + float scytheLesserSwipeTargetDist = (float)Math.Sqrt((double)(scytheLesserSwipeTargetX * scytheLesserSwipeTargetX + scytheLesserSwipeTargetY * scytheLesserSwipeTargetY)); - npc.rotation = (float)Math.Atan2((double)num884, (double)num883) + MathHelper.PiOver2; + npc.rotation = (float)Math.Atan2((double)scytheLesserSwipeTargetY, (double)scytheLesserSwipeTargetX) + MathHelper.PiOver2; npc.velocity.Y *= 0.95f; npc.velocity.X += 0.3f * -npc.ai[0]; @@ -751,22 +751,22 @@ namespace CalamityMod.NPCs npc.TargetClosest(true); npc.ai[2] = 5f; - vector115 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num883 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector115.X; - num884 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector115.Y; - num885 = (float)Math.Sqrt((double)(num883 * num883 + num884 * num884)); - num885 = 17f / num885; + scytheLesserSwipePos = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + scytheLesserSwipeTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - scytheLesserSwipePos.X; + scytheLesserSwipeTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - scytheLesserSwipePos.Y; + scytheLesserSwipeTargetDist = (float)Math.Sqrt((double)(scytheLesserSwipeTargetX * scytheLesserSwipeTargetX + scytheLesserSwipeTargetY * scytheLesserSwipeTargetY)); + scytheLesserSwipeTargetDist = 17f / scytheLesserSwipeTargetDist; - npc.velocity.X = num883 * num885; - npc.velocity.Y = num884 * num885; + npc.velocity.X = scytheLesserSwipeTargetX * scytheLesserSwipeTargetDist; + npc.velocity.Y = scytheLesserSwipeTargetY * scytheLesserSwipeTargetDist; npc.netUpdate = true; } } else if (npc.ai[2] == 5f) { - float num886 = Math.Abs(npc.Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(npc.Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); + float scytheLesserSwipeReturnDest = Math.Abs(npc.Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(npc.Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); - if ((npc.velocity.X > 0f && npc.position.X + (float)(npc.width / 2) > Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) || (npc.velocity.X < 0f && npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) || num886 > 800f) + if ((npc.velocity.X > 0f && npc.position.X + (float)(npc.width / 2) > Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) || (npc.velocity.X < 0f && npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) || scytheLesserSwipeReturnDest > 800f) npc.ai[2] = 0f; } @@ -800,42 +800,41 @@ namespace CalamityMod.NPCs } npc.TargetClosest(true); - int num887 = 800; - float num888 = Math.Abs(npc.Center.X - Main.player[npc.target].Center.X); + float iceQueenTargetDist = Math.Abs(npc.Center.X - Main.player[npc.target].Center.X); - if (npc.Center.X < Main.player[npc.target].Center.X && npc.ai[2] < 0f && num888 > (float)num887) + if (npc.Center.X < Main.player[npc.target].Center.X && npc.ai[2] < 0f && iceQueenTargetDist > 800f) npc.ai[2] = 0f; - if (npc.Center.X > Main.player[npc.target].Center.X && npc.ai[2] > 0f && num888 > (float)num887) + if (npc.Center.X > Main.player[npc.target].Center.X && npc.ai[2] > 0f && iceQueenTargetDist > 800f) npc.ai[2] = 0f; - float num889 = 0.6f; - float num890 = 10f; + float iceQueenAcceleration = 0.6f; + float iceQueenMaxVelocity = 10f; if ((double)npc.life < (double)npc.lifeMax * 0.75) { - num889 = 0.7f; - num890 = 12f; + iceQueenAcceleration = 0.7f; + iceQueenMaxVelocity = 12f; } if ((double)npc.life < (double)npc.lifeMax * 0.5) { - num889 = 0.8f; - num890 = 14f; + iceQueenAcceleration = 0.8f; + iceQueenMaxVelocity = 14f; } if ((double)npc.life < (double)npc.lifeMax * 0.25) { - num889 = 0.95f; - num890 = 16f; + iceQueenAcceleration = 0.95f; + iceQueenMaxVelocity = 16f; } - npc.velocity.X += npc.ai[2] * num889; - if (npc.velocity.X > num890) - npc.velocity.X = num890; - if (npc.velocity.X < -num890) - npc.velocity.X = -num890; + npc.velocity.X += npc.ai[2] * iceQueenAcceleration; + if (npc.velocity.X > iceQueenMaxVelocity) + npc.velocity.X = iceQueenMaxVelocity; + if (npc.velocity.X < -iceQueenMaxVelocity) + npc.velocity.X = -iceQueenMaxVelocity; - float num891 = Main.player[npc.target].position.Y - (npc.position.Y + (float)npc.height); - if (num891 < 150f) + float iceQueenHoverHeight = Main.player[npc.target].position.Y - (npc.position.Y + (float)npc.height); + if (iceQueenHoverHeight < 150f) npc.velocity.Y -= 0.2f; - if (num891 > 200f) + if (iceQueenHoverHeight > 200f) npc.velocity.Y += 0.2f; if (npc.velocity.Y > 9f) npc.velocity.Y = 9f; @@ -844,42 +843,42 @@ namespace CalamityMod.NPCs npc.rotation = npc.velocity.X * 0.05f; - if ((num888 < 500f || npc.ai[3] < 0f) && npc.position.Y < Main.player[npc.target].position.Y) + if ((iceQueenTargetDist < 500f || npc.ai[3] < 0f) && npc.position.Y < Main.player[npc.target].position.Y) { npc.ai[3] += 1f; - int num892 = 8; + int frostWaveFireDelay = 8; if ((double)npc.life < (double)npc.lifeMax * 0.75) - num892 = 7; + frostWaveFireDelay = 7; if ((double)npc.life < (double)npc.lifeMax * 0.5) - num892 = 6; + frostWaveFireDelay = 6; if ((double)npc.life < (double)npc.lifeMax * 0.25) - num892 = 5; + frostWaveFireDelay = 5; - num892++; - if (npc.ai[3] > (float)num892) - npc.ai[3] = (float)-(float)num892; + frostWaveFireDelay++; + if (npc.ai[3] > (float)frostWaveFireDelay) + npc.ai[3] = (float)-(float)frostWaveFireDelay; if (npc.ai[3] == 0f && Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector116 = new Vector2(npc.Center.X, npc.Center.Y); - vector116.X += npc.velocity.X * 7f; - float num893 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector116.X; - float num894 = Main.player[npc.target].Center.Y - vector116.Y; - float num895 = (float)Math.Sqrt((double)(num893 * num893 + num894 * num894)); + Vector2 frostWavePosition = new Vector2(npc.Center.X, npc.Center.Y); + frostWavePosition.X += npc.velocity.X * 7f; + float frostWaveTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - frostWavePosition.X; + float frostWaveTargetY = Main.player[npc.target].Center.Y - frostWavePosition.Y; + float frostWaveTargetDist = (float)Math.Sqrt((double)(frostWaveTargetX * frostWaveTargetX + frostWaveTargetY * frostWaveTargetY)); - float num896 = 8f; + float frostWaveSpeed = 8f; if ((double)npc.life < (double)npc.lifeMax * 0.75) - num896 = 9f; + frostWaveSpeed = 9f; if ((double)npc.life < (double)npc.lifeMax * 0.5) - num896 = 10f; + frostWaveSpeed = 10f; if ((double)npc.life < (double)npc.lifeMax * 0.25) - num896 = 11f; + frostWaveSpeed = 11f; - num895 = num896 / num895; - num893 *= num895; - num894 *= num895; + frostWaveTargetDist = frostWaveSpeed / frostWaveTargetDist; + frostWaveTargetX *= frostWaveTargetDist; + frostWaveTargetY *= frostWaveTargetDist; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector116.X, vector116.Y, num893, num894, ProjectileID.FrostWave, 50, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), frostWavePosition.X, frostWavePosition.Y, frostWaveTargetX, frostWaveTargetY, ProjectileID.FrostWave, 50, 0f, Main.myPlayer, 0f, 0f); } } else if (npc.ai[3] < 0f) @@ -889,7 +888,7 @@ namespace CalamityMod.NPCs { npc.ai[1] += (float)Main.rand.Next(1, 4); - if (npc.ai[1] > 600f && num888 < 600f) + if (npc.ai[1] > 600f && iceQueenTargetDist < 600f) npc.ai[0] = -1f; } } @@ -897,45 +896,45 @@ namespace CalamityMod.NPCs { npc.TargetClosest(true); - float num898 = 0.2f; - float num899 = 10f; + float icicleAttackAcceleration = 0.2f; + float icicleAttackMaxVelocity = 10f; if ((double)npc.life < (double)npc.lifeMax * 0.75) { - num898 = 0.24f; - num899 = 12f; + icicleAttackAcceleration = 0.24f; + icicleAttackMaxVelocity = 12f; } if ((double)npc.life < (double)npc.lifeMax * 0.5) { - num898 = 0.28f; - num899 = 14f; + icicleAttackAcceleration = 0.28f; + icicleAttackMaxVelocity = 14f; } if ((double)npc.life < (double)npc.lifeMax * 0.25) { - num898 = 0.32f; - num899 = 16f; + icicleAttackAcceleration = 0.32f; + icicleAttackMaxVelocity = 16f; } - num898 -= 0.05f; - num899 -= 1f; + icicleAttackAcceleration -= 0.05f; + icicleAttackMaxVelocity -= 1f; if (npc.Center.X < Main.player[npc.target].Center.X) { - npc.velocity.X += num898; + npc.velocity.X += icicleAttackAcceleration; if (npc.velocity.X < 0f) npc.velocity.X *= 0.98f; } if (npc.Center.X > Main.player[npc.target].Center.X) { - npc.velocity.X -= num898; + npc.velocity.X -= icicleAttackAcceleration; if (npc.velocity.X > 0f) npc.velocity.X *= 0.98f; } - if (npc.velocity.X > num899 || npc.velocity.X < -num899) + if (npc.velocity.X > icicleAttackMaxVelocity || npc.velocity.X < -icicleAttackMaxVelocity) npc.velocity.X *= 0.95f; - float num900 = Main.player[npc.target].position.Y - (npc.position.Y + (float)npc.height); - if (num900 < 180f) + float icicleAttackHoverHeight = Main.player[npc.target].position.Y - (npc.position.Y + (float)npc.height); + if (icicleAttackHoverHeight < 180f) npc.velocity.Y -= 0.1f; - if (num900 > 200f) + if (icicleAttackHoverHeight > 200f) npc.velocity.Y += 0.1f; if (npc.velocity.Y > 7f) @@ -948,33 +947,33 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { npc.ai[3] += 1f; - int num901 = 10; + int icicleFireDelay = 10; if ((double)npc.life < (double)npc.lifeMax * 0.75) - num901 = 8; + icicleFireDelay = 8; if ((double)npc.life < (double)npc.lifeMax * 0.5) - num901 = 6; + icicleFireDelay = 6; if ((double)npc.life < (double)npc.lifeMax * 0.25) - num901 = 4; + icicleFireDelay = 4; if ((double)npc.life < (double)npc.lifeMax * 0.1) - num901 = 2; + icicleFireDelay = 2; - num901 += 3; - if (npc.ai[3] >= (float)num901) + icicleFireDelay += 3; + if (npc.ai[3] >= (float)icicleFireDelay) { npc.ai[3] = 0f; - Vector2 vector117 = new Vector2(npc.Center.X, npc.position.Y + (float)npc.height - 14f); - int i2 = (int)(vector117.X / 16f); - int j2 = (int)(vector117.Y / 16f); + Vector2 icicleSpawnPos = new Vector2(npc.Center.X, npc.position.Y + (float)npc.height - 14f); + int i2 = (int)(icicleSpawnPos.X / 16f); + int j2 = (int)(icicleSpawnPos.Y / 16f); if (!WorldGen.SolidTile(i2, j2)) { - float num902 = npc.velocity.Y; + float icicleFallSpeed = npc.velocity.Y; - if (num902 < 0f) - num902 = 0f; + if (icicleFallSpeed < 0f) + icicleFallSpeed = 0f; - num902 += 3f; + icicleFallSpeed += 3f; float speedX2 = npc.velocity.X * 0.25f; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector117.X, vector117.Y, speedX2, num902, ProjectileID.FrostShard, 44, 0f, Main.myPlayer, (float)Main.rand.Next(5), 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), icicleSpawnPos.X, icicleSpawnPos.Y, speedX2, icicleFallSpeed, ProjectileID.FrostShard, 44, 0f, Main.myPlayer, (float)Main.rand.Next(5), 0f); } } } @@ -991,35 +990,35 @@ namespace CalamityMod.NPCs { npc.TargetClosest(true); - Vector2 vector118 = new Vector2(npc.Center.X, npc.Center.Y - 20f); - float num904 = (float)Main.rand.Next(-1000, 1001); - float num905 = (float)Main.rand.Next(-1000, 1001); - float num906 = (float)Math.Sqrt((double)(num904 * num904 + num905 * num905)); - float num907 = 20f; + Vector2 iceRainPosition = new Vector2(npc.Center.X, npc.Center.Y - 20f); + float iceRainXVel = (float)Main.rand.Next(-1000, 1001); + float iceRainYVel = (float)Main.rand.Next(-1000, 1001); + float iceRainVelocity = (float)Math.Sqrt((double)(iceRainXVel * iceRainXVel + iceRainYVel * iceRainYVel)); + float iceRainSpeed = 20f; npc.velocity *= 0.95f; - num906 = num907 / num906; - num904 *= num906; - num905 *= num906; + iceRainVelocity = iceRainSpeed / iceRainVelocity; + iceRainXVel *= iceRainVelocity; + iceRainYVel *= iceRainVelocity; npc.rotation += 0.2f; - vector118.X += num904 * 4f; - vector118.Y += num905 * 4f; + iceRainPosition.X += iceRainXVel * 4f; + iceRainPosition.Y += iceRainYVel * 4f; npc.ai[3] += 1f; - int num908 = 7; + int iceRainFireDelay = 7; if ((double)npc.life < (double)npc.lifeMax * 0.75) - num908--; + iceRainFireDelay--; if ((double)npc.life < (double)npc.lifeMax * 0.5) - num908 -= 2; + iceRainFireDelay -= 2; if ((double)npc.life < (double)npc.lifeMax * 0.25) - num908 -= 3; + iceRainFireDelay -= 3; if ((double)npc.life < (double)npc.lifeMax * 0.1) - num908 -= 4; + iceRainFireDelay -= 4; - if (npc.ai[3] > (float)num908) + if (npc.ai[3] > (float)iceRainFireDelay) { npc.ai[3] = 0f; - int num909 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector118.X, vector118.Y, num904, num905, ProjectileID.FrostShard, 40, 0f, Main.myPlayer, 0f, 0f); + int iceRainAttack = Projectile.NewProjectile(npc.GetSource_FromAI(), iceRainPosition.X, iceRainPosition.Y, iceRainXVel, iceRainYVel, ProjectileID.FrostShard, 40, 0f, Main.myPlayer, 0f, 0f); } if (Main.netMode != NetmodeID.MultiplayerClient) @@ -1032,13 +1031,13 @@ namespace CalamityMod.NPCs } if (npc.ai[0] == -1f) { - int num910 = Main.rand.Next(3); + int attackPicker = Main.rand.Next(3); npc.TargetClosest(true); if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) > 1000f) - num910 = 0; + attackPicker = 0; - npc.ai[0] = (float)num910; + npc.ai[0] = (float)attackPicker; npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; diff --git a/NPCs/CeaselessVoid/CeaselessVoid.cs b/NPCs/CeaselessVoid/CeaselessVoid.cs index c3b96a69db..7ec4467489 100644 --- a/NPCs/CeaselessVoid/CeaselessVoid.cs +++ b/NPCs/CeaselessVoid/CeaselessVoid.cs @@ -39,7 +39,7 @@ namespace CalamityMod.NPCs.CeaselessVoid Main.npcFrameCount[NPC.type] = 6; NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.55f, }; @@ -122,18 +122,18 @@ namespace CalamityMod.NPCs.CeaselessVoid { Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= 50f; } @@ -145,49 +145,47 @@ namespace CalamityMod.NPCs.CeaselessVoid spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 7; + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + int afterimageAmt = 7; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; + Vector2 afterimageDrawPos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + afterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + afterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimageDrawPos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/CeaselessVoid/CeaselessVoidGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + Color cyanLerp = Color.Lerp(Color.White, Color.Cyan, 0.5f); if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color extraAfterimageColor = cyanLerp; + extraAfterimageColor = Color.Lerp(extraAfterimageColor, Color.White, 0.5f); + extraAfterimageColor *= (float)(afterimageAmt - j) / 15f; + Vector2 extraAfterimageDrawPos = NPC.oldPos[j] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + extraAfterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + extraAfterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, extraAfterimageDrawPos, NPC.frame, extraAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, cyanLerp, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -238,8 +236,8 @@ namespace CalamityMod.NPCs.CeaselessVoid // GFB Eclipse Mirror and Nucleogenesis drop var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ModContent.ItemType()); - GFBOnly.Add(ModContent.ItemType()); + GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); + GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); } // Lore @@ -283,25 +281,25 @@ namespace CalamityMod.NPCs.CeaselessVoid NPC.height = 100; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - Main.dust[num622].noGravity = true; + int purpleDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[purpleDust].velocity *= 3f; + Main.dust[purpleDust].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[purpleDust].scale = 0.5f; + Main.dust[purpleDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 2f; + int purpleDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[purpleDust2].noGravity = true; + Main.dust[purpleDust2].velocity *= 5f; + purpleDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[purpleDust2].noGravity = true; + Main.dust[purpleDust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) diff --git a/NPCs/CeaselessVoid/DarkEnergy.cs b/NPCs/CeaselessVoid/DarkEnergy.cs index 754d971bd2..a254faf2f8 100644 --- a/NPCs/CeaselessVoid/DarkEnergy.cs +++ b/NPCs/CeaselessVoid/DarkEnergy.cs @@ -282,18 +282,18 @@ namespace CalamityMod.NPCs.CeaselessVoid { Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= 35f * NPC.scale; } diff --git a/NPCs/Crabulon/Crabulon.cs b/NPCs/Crabulon/Crabulon.cs index 300faa9feb..b54d7a4d5b 100644 --- a/NPCs/Crabulon/Crabulon.cs +++ b/NPCs/Crabulon/Crabulon.cs @@ -39,7 +39,7 @@ namespace CalamityMod.NPCs.Crabulon { Main.npcFrameCount[NPC.type] = 6; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.32f, PortraitScale = 0.55f, @@ -190,18 +190,18 @@ namespace CalamityMod.NPCs.Crabulon if (NPC.ai[0] < 2f) { - Vector2 vector34 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - int num352 = 1; + Vector2 mushBombDirection = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + int mushBombAmt = 1; NPC.localAI[3] += 2f; if (phase2) { NPC.localAI[3] += 1f; - num352 += 2; + mushBombAmt += 2; } if (phase3) { NPC.localAI[3] += 2f; - num352 += 3; + mushBombAmt += 3; } if (NPC.ai[3] == 0f) { @@ -215,30 +215,30 @@ namespace CalamityMod.NPCs.Crabulon { NPC.localAI[3] = 0f; NPC.ai[3] += 1f; - if (NPC.ai[3] >= num352) + if (NPC.ai[3] >= mushBombAmt) NPC.ai[3] = 0f; - float num353 = 10f; + float mushBombSpeed = 10f; int type = ModContent.ProjectileType(); SoundEngine.PlaySound(SoundID.Item42, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { if (phase2) - num353 += 1f; + mushBombSpeed += 1f; if (phase3) - num353 += 1f; + mushBombSpeed += 1f; - vector34 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num349 = player.position.X + player.width * 0.5f - vector34.X; - float num350 = player.position.Y + player.height * 0.5f - vector34.Y; - float num351 = (float)Math.Sqrt(num349 * num349 + num350 * num350); - num351 = num353 / num351; - num349 *= num351; - num350 *= num351; - vector34.X += num349; - vector34.Y += num350; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector34.X, vector34.Y, num349, num350 - 5f, type, NPC.GetProjectileDamage(type), 0f, Main.myPlayer, 0f, player.Center.Y); + mushBombDirection = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float playerXDist = player.position.X + player.width * 0.5f - mushBombDirection.X; + float playerYDist = player.position.Y + player.height * 0.5f - mushBombDirection.Y; + float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); + playerDistance = mushBombSpeed / playerDistance; + playerXDist *= playerDistance; + playerYDist *= playerDistance; + mushBombDirection.X += playerXDist; + mushBombDirection.Y += playerYDist; + Projectile.NewProjectile(NPC.GetSource_FromAI(), mushBombDirection.X, mushBombDirection.Y, playerXDist, playerYDist - 5f, type, NPC.GetProjectileDamage(type), 0f, Main.myPlayer, 0f, player.Center.Y); } } } @@ -278,11 +278,11 @@ namespace CalamityMod.NPCs.Crabulon walkingVelocity *= 2f; walkingVelocity += 2.5f * enrageScale; - bool flag51 = false; + bool shouldWalkSlower = false; if (Math.Abs(NPC.Center.X - player.Center.X) < 50f) - flag51 = true; + shouldWalkSlower = true; - if (flag51) + if (shouldWalkSlower) { NPC.velocity.X *= 0.9f; if (NPC.velocity.X > -0.1 && NPC.velocity.X < 0.1) @@ -308,17 +308,14 @@ namespace CalamityMod.NPCs.Crabulon { NPC.noGravity = true; NPC.noTileCollide = true; - - int num854 = 80; - int num855 = 20; - Vector2 position2 = new Vector2(NPC.Center.X - (num854 / 2), NPC.position.Y + NPC.height - num855); + Vector2 collisionCheckPosition = new Vector2(NPC.Center.X - 40, NPC.position.Y + NPC.height - 20); bool fallDownOnTopOfTarget = NPC.position.X < player.position.X && NPC.position.X + NPC.width > player.position.X + player.width && NPC.position.Y + NPC.height < player.position.Y + player.height - 16f; if (fallDownOnTopOfTarget) { NPC.velocity.Y += 0.5f; } - else if (Collision.SolidCollision(position2, num854, num855)) + else if (Collision.SolidCollision(collisionCheckPosition, 80, 20)) { if (NPC.velocity.Y > 0f) NPC.velocity.Y = 0f; @@ -529,16 +526,16 @@ namespace CalamityMod.NPCs.Crabulon NPC.netUpdate = true; } - for (int num622 = (int)NPC.position.X - 20; num622 < (int)NPC.position.X + NPC.width + 40; num622 += 20) + for (int j = (int)NPC.position.X - 20; j < (int)NPC.position.X + NPC.width + 40; j += 20) { - for (int num623 = 0; num623 < 4; num623++) + for (int k = 0; k < 4; k++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X - 20f, NPC.position.Y + NPC.height), NPC.width + 20, 4, 56, 0f, 0f, 100, default, 1.5f); - Main.dust[num624].velocity *= 0.2f; + int stompDust = Dust.NewDust(new Vector2(NPC.position.X - 20f, NPC.position.Y + NPC.height), NPC.width + 20, 4, 56, 0f, 0f, 100, default, 1.5f); + Main.dust[stompDust].velocity *= 0.2f; } if (Main.zenithWorld) { - int x = num622 / 16; + int x = j / 16; int y = (int)(NPC.position.Y + NPC.height) / 16; Tile groundTile = CalamityUtils.ParanoidTileRetrieval(x, y); Tile walkTile = CalamityUtils.ParanoidTileRetrieval(x, y - 1); @@ -588,27 +585,27 @@ namespace CalamityMod.NPCs.Crabulon else if (NPC.direction > 0) NPC.velocity.X += velocityX; - float num626 = 2.5f; - num626 += enrageScale; + float topXSpeed = 2.5f; + topXSpeed += enrageScale; if (revenge) { - num626 += 1f; + topXSpeed += 1f; } if (phase2) { - num626 += 1f; + topXSpeed += 1f; } if (phase3) { - num626 += 1f; + topXSpeed += 1f; } - if (NPC.velocity.X < -num626) + if (NPC.velocity.X < -topXSpeed) { - NPC.velocity.X = -num626; + NPC.velocity.X = -topXSpeed; } - if (NPC.velocity.X > num626) + if (NPC.velocity.X > topXSpeed) { - NPC.velocity.X = num626; + NPC.velocity.X = topXSpeed; } } } @@ -622,23 +619,23 @@ namespace CalamityMod.NPCs.Crabulon { if (Main.netMode != NetmodeID.MultiplayerClient) { - int num660 = (int)(NPC.lifeMax * ((CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.01 : Main.getGoodWorld ? 0.025 : 0.05)); - if ((NPC.life + num660) < NPC.localAI[0]) + int crabShroomSpawnFreq = (int)(NPC.lifeMax * ((CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.01 : Main.getGoodWorld ? 0.025 : 0.05)); + if ((NPC.life + crabShroomSpawnFreq) < NPC.localAI[0]) { NPC.localAI[0] = NPC.life; - int num661 = death ? 3 : expertMode ? Main.rand.Next(2, 4) : 2; - for (int num662 = 0; num662 < num661; num662++) + int crabShroomAmt = death ? 3 : expertMode ? Main.rand.Next(2, 4) : 2; + for (int mush = 0; mush < crabShroomAmt; mush++) { int x = (int)(NPC.position.X + Main.rand.Next(NPC.width - 32)); int y = (int)(NPC.position.Y + Main.rand.Next(NPC.height - 32)); - int num663 = ModContent.NPCType(); - int num664 = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, num663); - Main.npc[num664].SetDefaults(num663); - Main.npc[num664].velocity.X = Main.rand.Next(-50, 51) * (Main.getGoodWorld ? 0.2f : 0.1f); - Main.npc[num664].velocity.Y = Main.rand.Next(-50, -31) * (Main.getGoodWorld ? 0.2f : 0.1f); - if (Main.netMode == NetmodeID.Server && num664 < Main.maxNPCs) + int npcType = ModContent.NPCType(); + int crabShroom = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, npcType); + Main.npc[crabShroom].SetDefaults(npcType); + Main.npc[crabShroom].velocity.X = Main.rand.Next(-50, 51) * (Main.getGoodWorld ? 0.2f : 0.1f); + Main.npc[crabShroom].velocity.Y = Main.rand.Next(-50, -31) * (Main.getGoodWorld ? 0.2f : 0.1f); + if (Main.netMode == NetmodeID.Server && crabShroom < Main.maxNPCs) { - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, crabShroom, 0f, 0f, 0f, 0, 0, 0); } } } @@ -853,7 +850,7 @@ namespace CalamityMod.NPCs.Crabulon npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB Odd Mushroom drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), 1, 1, 9999); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), 1, 1, 9999, true); // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedCrabulon, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -894,23 +891,23 @@ namespace CalamityMod.NPCs.Crabulon NPC.height = (int)(100 * NPC.scale); NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 56, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int j = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 56, 0f, 0f, 100, default, 2f); + Main.dust[j].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[j].scale = 0.5f; + Main.dust[j].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int k = 0; k < 70; k++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 56, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 56, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int stompDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 56, 0f, 0f, 100, default, 3f); + Main.dust[stompDust].noGravity = true; + Main.dust[stompDust].velocity *= 5f; + stompDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 56, 0f, 0f, 100, default, 2f); + Main.dust[stompDust].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) { diff --git a/NPCs/Crags/CalamityEye.cs b/NPCs/Crags/CalamityEye.cs index 5648c90d26..ce525958e2 100644 --- a/NPCs/Crags/CalamityEye.cs +++ b/NPCs/Crags/CalamityEye.cs @@ -15,7 +15,7 @@ namespace CalamityMod.NPCs.Crags public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 4; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0); value.Position.Y -= 10f; value.PortraitPositionYOverride = -36f; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; diff --git a/NPCs/Crags/HeatSpirit.cs b/NPCs/Crags/HeatSpirit.cs index e6906b90f5..931fe5835d 100644 --- a/NPCs/Crags/HeatSpirit.cs +++ b/NPCs/Crags/HeatSpirit.cs @@ -16,7 +16,7 @@ namespace CalamityMod.NPCs.Crags public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 4; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { SpriteDirection = -1, PortraitPositionYOverride = -32f diff --git a/NPCs/Crags/Scryllar.cs b/NPCs/Crags/Scryllar.cs index f6e89324ce..01b59b4993 100644 --- a/NPCs/Crags/Scryllar.cs +++ b/NPCs/Crags/Scryllar.cs @@ -16,7 +16,7 @@ namespace CalamityMod.NPCs.Crags { public override void SetStaticDefaults() { - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { PortraitPositionYOverride = 10f }; @@ -67,35 +67,35 @@ namespace CalamityMod.NPCs.Crags { NPC.rotation = NPC.velocity.X * 0.04f; NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; - bool flag19 = false; + bool hoverDownDistCheck = false; if (NPC.justHit) { NPC.ai[2] = 0f; } if (NPC.ai[2] >= 0f) { - int num282 = 16; - bool flag21 = false; - bool flag22 = false; - if (NPC.position.X > NPC.ai[0] - (float)num282 && NPC.position.X < NPC.ai[0] + (float)num282) + int hoverDistance = 16; + bool changeDirectionX = false; + bool changeDirectionY = false; + if (NPC.position.X > NPC.ai[0] - (float)hoverDistance && NPC.position.X < NPC.ai[0] + (float)hoverDistance) { - flag21 = true; + changeDirectionX = true; } else if ((NPC.velocity.X < 0f && NPC.direction > 0) || (NPC.velocity.X > 0f && NPC.direction < 0)) { - flag21 = true; + changeDirectionX = true; } - num282 += 24; - if (NPC.position.Y > NPC.ai[1] - (float)num282 && NPC.position.Y < NPC.ai[1] + (float)num282) + hoverDistance += 24; + if (NPC.position.Y > NPC.ai[1] - (float)hoverDistance && NPC.position.Y < NPC.ai[1] + (float)hoverDistance) { - flag22 = true; + changeDirectionY = true; } - if (flag21 && flag22) + if (changeDirectionX && changeDirectionY) { NPC.ai[2] += 1f; - if (NPC.ai[2] >= 30f && num282 == 16) + if (NPC.ai[2] >= 30f && hoverDistance == 16) { - flag19 = true; + hoverDownDistCheck = true; } if (NPC.ai[2] >= 60f) { @@ -118,36 +118,36 @@ namespace CalamityMod.NPCs.Crags NPC.TargetClosest(true); NPC.ai[2] += 2f; } - int num283 = (int)((NPC.position.X + (float)(NPC.width / 2)) / 16f) + NPC.direction * 2; - int num284 = (int)((NPC.position.Y + (float)NPC.height) / 16f); - bool flag23 = true; - int num285 = 3; - for (int num308 = num284; num308 < num284 + num285; num308++) + int npcTileX = (int)((NPC.position.X + (float)(NPC.width / 2)) / 16f) + NPC.direction * 2; + int npcTileY = (int)((NPC.position.Y + (float)NPC.height) / 16f); + bool hoverDownwards = true; + int tileCheckLoopAmt = 3; + for (int loopInc1 = npcTileY; loopInc1 < npcTileY + tileCheckLoopAmt; loopInc1++) { - if ((Main.tile[num283, num308].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num283, num308].TileType]) || Main.tile[num283, num308].LiquidAmount > 0) + if ((Main.tile[npcTileX, loopInc1].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, loopInc1].TileType]) || Main.tile[npcTileX, loopInc1].LiquidAmount > 0) { - flag23 = false; + hoverDownwards = false; break; } } if (Main.player[NPC.target].npcTypeNoAggro[NPC.type]) { - bool flag25 = false; - for (int num309 = num284; num309 < num284 + num285 - 2; num309++) + bool inTileNoAggro = false; + for (int loopInc2 = npcTileY; loopInc2 < npcTileY + tileCheckLoopAmt - 2; loopInc2++) { - if ((Main.tile[num283, num309].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num283, num309].TileType]) || Main.tile[num283, num309].LiquidAmount > 0) + if ((Main.tile[npcTileX, loopInc2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, loopInc2].TileType]) || Main.tile[npcTileX, loopInc2].LiquidAmount > 0) { - flag25 = true; + inTileNoAggro = true; break; } } - NPC.directionY = (!flag25).ToDirectionInt(); + NPC.directionY = (!inTileNoAggro).ToDirectionInt(); } - if (flag19) + if (hoverDownDistCheck) { - flag23 = true; + hoverDownwards = true; } - if (flag23) + if (hoverDownwards) { NPC.velocity.Y = NPC.velocity.Y + 0.1f; if (NPC.velocity.Y > 3f) @@ -190,11 +190,11 @@ namespace CalamityMod.NPCs.Crags NPC.velocity.Y = -1f; } } - float num311 = 4f; - if (NPC.direction == -1 && NPC.velocity.X > -num311) + float maxXVelocity = 4f; + if (NPC.direction == -1 && NPC.velocity.X > -maxXVelocity) { NPC.velocity.X = NPC.velocity.X - 0.1f; - if (NPC.velocity.X > num311) + if (NPC.velocity.X > maxXVelocity) { NPC.velocity.X = NPC.velocity.X - 0.1f; } @@ -202,15 +202,15 @@ namespace CalamityMod.NPCs.Crags { NPC.velocity.X = NPC.velocity.X + 0.05f; } - if (NPC.velocity.X < -num311) + if (NPC.velocity.X < -maxXVelocity) { - NPC.velocity.X = -num311; + NPC.velocity.X = -maxXVelocity; } } - else if (NPC.direction == 1 && NPC.velocity.X < num311) + else if (NPC.direction == 1 && NPC.velocity.X < maxXVelocity) { NPC.velocity.X = NPC.velocity.X + 0.1f; - if (NPC.velocity.X < -num311) + if (NPC.velocity.X < -maxXVelocity) { NPC.velocity.X = NPC.velocity.X + 0.1f; } @@ -218,16 +218,16 @@ namespace CalamityMod.NPCs.Crags { NPC.velocity.X = NPC.velocity.X - 0.05f; } - if (NPC.velocity.X > num311) + if (NPC.velocity.X > maxXVelocity) { - NPC.velocity.X = num311; + NPC.velocity.X = maxXVelocity; } } - num311 = 1.5f; - if (NPC.directionY == -1 && NPC.velocity.Y > -num311) + maxXVelocity = 1.5f; + if (NPC.directionY == -1 && NPC.velocity.Y > -maxXVelocity) { NPC.velocity.Y = NPC.velocity.Y - 0.04f; - if (NPC.velocity.Y > num311) + if (NPC.velocity.Y > maxXVelocity) { NPC.velocity.Y = NPC.velocity.Y - 0.05f; } @@ -235,15 +235,15 @@ namespace CalamityMod.NPCs.Crags { NPC.velocity.Y = NPC.velocity.Y + 0.03f; } - if (NPC.velocity.Y < -num311) + if (NPC.velocity.Y < -maxXVelocity) { - NPC.velocity.Y = -num311; + NPC.velocity.Y = -maxXVelocity; } } - else if (NPC.directionY == 1 && NPC.velocity.Y < num311) + else if (NPC.directionY == 1 && NPC.velocity.Y < maxXVelocity) { NPC.velocity.Y = NPC.velocity.Y + 0.04f; - if (NPC.velocity.Y < -num311) + if (NPC.velocity.Y < -maxXVelocity) { NPC.velocity.Y = NPC.velocity.Y + 0.05f; } @@ -251,9 +251,9 @@ namespace CalamityMod.NPCs.Crags { NPC.velocity.Y = NPC.velocity.Y - 0.03f; } - if (NPC.velocity.Y > num311) + if (NPC.velocity.Y > maxXVelocity) { - NPC.velocity.Y = num311; + NPC.velocity.Y = maxXVelocity; } } } diff --git a/NPCs/Crags/ScryllarRage.cs b/NPCs/Crags/ScryllarRage.cs index 5657aa505d..25025b69e0 100644 --- a/NPCs/Crags/ScryllarRage.cs +++ b/NPCs/Crags/ScryllarRage.cs @@ -49,35 +49,35 @@ namespace CalamityMod.NPCs.Crags { NPC.rotation = NPC.velocity.X * 0.04f; NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; - bool flag19 = false; + bool hoverDownDistCheck = false; if (NPC.justHit) { NPC.ai[2] = 0f; } if (NPC.ai[2] >= 0f) { - int num282 = 16; - bool flag21 = false; - bool flag22 = false; - if (NPC.position.X > NPC.ai[0] - (float)num282 && NPC.position.X < NPC.ai[0] + (float)num282) + int hoverDistance = 16; + bool changeDirectionX = false; + bool changeDirectionY = false; + if (NPC.position.X > NPC.ai[0] - (float)hoverDistance && NPC.position.X < NPC.ai[0] + (float)hoverDistance) { - flag21 = true; + changeDirectionX = true; } else if ((NPC.velocity.X < 0f && NPC.direction > 0) || (NPC.velocity.X > 0f && NPC.direction < 0)) { - flag21 = true; + changeDirectionX = true; } - num282 += 24; - if (NPC.position.Y > NPC.ai[1] - (float)num282 && NPC.position.Y < NPC.ai[1] + (float)num282) + hoverDistance += 24; + if (NPC.position.Y > NPC.ai[1] - (float)hoverDistance && NPC.position.Y < NPC.ai[1] + (float)hoverDistance) { - flag22 = true; + changeDirectionY = true; } - if (flag21 && flag22) + if (changeDirectionX && changeDirectionY) { NPC.ai[2] += 1f; - if (NPC.ai[2] >= 30f && num282 == 16) + if (NPC.ai[2] >= 30f && hoverDistance == 16) { - flag19 = true; + hoverDownDistCheck = true; } if (NPC.ai[2] >= 60f) { @@ -100,36 +100,36 @@ namespace CalamityMod.NPCs.Crags NPC.TargetClosest(true); NPC.ai[2] += 2f; } - int num283 = (int)((NPC.position.X + (float)(NPC.width / 2)) / 16f) + NPC.direction * 2; - int num284 = (int)((NPC.position.Y + (float)NPC.height) / 16f); - bool flag23 = true; - int num285 = 3; - for (int num308 = num284; num308 < num284 + num285; num308++) + int npcTileX = (int)((NPC.position.X + (float)(NPC.width / 2)) / 16f) + NPC.direction * 2; + int npcTileY = (int)((NPC.position.Y + (float)NPC.height) / 16f); + bool hoverDownwards = true; + int tileCheckLoopAmt = 3; + for (int loopInc1 = npcTileY; loopInc1 < npcTileY + tileCheckLoopAmt; loopInc1++) { - if ((Main.tile[num283, num308].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num283, num308].TileType]) || Main.tile[num283, num308].LiquidAmount > 0) + if ((Main.tile[npcTileX, loopInc1].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, loopInc1].TileType]) || Main.tile[npcTileX, loopInc1].LiquidAmount > 0) { - flag23 = false; + hoverDownwards = false; break; } } if (Main.player[NPC.target].npcTypeNoAggro[NPC.type]) { - bool flag25 = false; - for (int num309 = num284; num309 < num284 + num285 - 2; num309++) + bool inTileNoAggro = false; + for (int loopInc2 = npcTileY; loopInc2 < npcTileY + tileCheckLoopAmt - 2; loopInc2++) { - if ((Main.tile[num283, num309].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num283, num309].TileType]) || Main.tile[num283, num309].LiquidAmount > 0) + if ((Main.tile[npcTileX, loopInc2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, loopInc2].TileType]) || Main.tile[npcTileX, loopInc2].LiquidAmount > 0) { - flag25 = true; + inTileNoAggro = true; break; } } - NPC.directionY = (!flag25).ToDirectionInt(); + NPC.directionY = (!inTileNoAggro).ToDirectionInt(); } - if (flag19) + if (hoverDownDistCheck) { - flag23 = true; + hoverDownwards = true; } - if (flag23) + if (hoverDownwards) { NPC.velocity.Y = NPC.velocity.Y + 0.1f; if (NPC.velocity.Y > 3f) @@ -172,11 +172,11 @@ namespace CalamityMod.NPCs.Crags NPC.velocity.Y = -1f; } } - float num311 = 7f; - if (NPC.direction == -1 && NPC.velocity.X > -num311) + float maxXVelocity = 7f; + if (NPC.direction == -1 && NPC.velocity.X > -maxXVelocity) { NPC.velocity.X = NPC.velocity.X - 0.1f; - if (NPC.velocity.X > num311) + if (NPC.velocity.X > maxXVelocity) { NPC.velocity.X = NPC.velocity.X - 0.1f; } @@ -184,15 +184,15 @@ namespace CalamityMod.NPCs.Crags { NPC.velocity.X = NPC.velocity.X + 0.05f; } - if (NPC.velocity.X < -num311) + if (NPC.velocity.X < -maxXVelocity) { - NPC.velocity.X = -num311; + NPC.velocity.X = -maxXVelocity; } } - else if (NPC.direction == 1 && NPC.velocity.X < num311) + else if (NPC.direction == 1 && NPC.velocity.X < maxXVelocity) { NPC.velocity.X = NPC.velocity.X + 0.1f; - if (NPC.velocity.X < -num311) + if (NPC.velocity.X < -maxXVelocity) { NPC.velocity.X = NPC.velocity.X + 0.1f; } @@ -200,16 +200,16 @@ namespace CalamityMod.NPCs.Crags { NPC.velocity.X = NPC.velocity.X - 0.05f; } - if (NPC.velocity.X > num311) + if (NPC.velocity.X > maxXVelocity) { - NPC.velocity.X = num311; + NPC.velocity.X = maxXVelocity; } } - num311 = 1.5f; - if (NPC.directionY == -1 && NPC.velocity.Y > -num311) + maxXVelocity = 1.5f; + if (NPC.directionY == -1 && NPC.velocity.Y > -maxXVelocity) { NPC.velocity.Y = NPC.velocity.Y - 0.04f; - if (NPC.velocity.Y > num311) + if (NPC.velocity.Y > maxXVelocity) { NPC.velocity.Y = NPC.velocity.Y - 0.05f; } @@ -217,15 +217,15 @@ namespace CalamityMod.NPCs.Crags { NPC.velocity.Y = NPC.velocity.Y + 0.03f; } - if (NPC.velocity.Y < -num311) + if (NPC.velocity.Y < -maxXVelocity) { - NPC.velocity.Y = -num311; + NPC.velocity.Y = -maxXVelocity; } } - else if (NPC.directionY == 1 && NPC.velocity.Y < num311) + else if (NPC.directionY == 1 && NPC.velocity.Y < maxXVelocity) { NPC.velocity.Y = NPC.velocity.Y + 0.04f; - if (NPC.velocity.Y < -num311) + if (NPC.velocity.Y < -maxXVelocity) { NPC.velocity.Y = NPC.velocity.Y + 0.05f; } @@ -233,9 +233,9 @@ namespace CalamityMod.NPCs.Crags { NPC.velocity.Y = NPC.velocity.Y - 0.03f; } - if (NPC.velocity.Y > num311) + if (NPC.velocity.Y > maxXVelocity) { - NPC.velocity.Y = num311; + NPC.velocity.Y = maxXVelocity; } } } diff --git a/NPCs/Crags/SoulSlurper.cs b/NPCs/Crags/SoulSlurper.cs index 72d8388085..4647877849 100644 --- a/NPCs/Crags/SoulSlurper.cs +++ b/NPCs/Crags/SoulSlurper.cs @@ -75,36 +75,36 @@ namespace CalamityMod.NPCs.Crags { NPC.TargetClosest(true); } - float num = 5f; - float num2 = 0.07f; - Vector2 source = NPC.Center; - float num4 = target.Center.X; - float num5 = target.Center.Y; - num4 = (float)((int)(num4 / 8f) * 8); - num5 = (float)((int)(num5 / 8f) * 8); - source.X = (float)((int)(source.X / 8f) * 8); - source.Y = (float)((int)(source.Y / 8f) * 8); - num4 -= source.X; - num5 -= source.Y; - float num6 = (float)Math.Sqrt((double)(num4 * num4 + num5 * num5)); - float num7 = num6; - bool flag = false; - if (num6 > 600f) + float npcSpeed = 5f; + float npcAcceleration = 0.07f; + Vector2 npcCenter = NPC.Center; + float targetX = target.Center.X; + float targetY = target.Center.Y; + targetX = (float)((int)(targetX / 8f) * 8); + targetY = (float)((int)(targetY / 8f) * 8); + npcCenter.X = (float)((int)(npcCenter.X / 8f) * 8); + npcCenter.Y = (float)((int)(npcCenter.Y / 8f) * 8); + targetX -= npcCenter.X; + targetY -= npcCenter.Y; + float targetDistance = (float)Math.Sqrt((double)(targetX * targetX + targetY * targetY)); + float accelerateDistance = targetDistance; + bool tooFar = false; + if (targetDistance > 600f) { - flag = true; + tooFar = true; } - if (num6 == 0f) + if (targetDistance == 0f) { - num4 = NPC.velocity.X; - num5 = NPC.velocity.Y; + targetX = NPC.velocity.X; + targetY = NPC.velocity.Y; } else { - num6 = num / num6; - num4 *= num6; - num5 *= num6; + targetDistance = npcSpeed / targetDistance; + targetX *= targetDistance; + targetY *= targetDistance; } - if (num7 > 100f) + if (accelerateDistance > 100f) { NPC.ai[0] += 1f; if (NPC.ai[0] > 0f) @@ -130,24 +130,24 @@ namespace CalamityMod.NPCs.Crags } if (target.dead) { - num4 = (float)NPC.direction * num / 2f; - num5 = -num / 2f; + targetX = (float)NPC.direction * npcSpeed / 2f; + targetY = -npcSpeed / 2f; } - if (NPC.velocity.X < num4) + if (NPC.velocity.X < targetX) { - NPC.velocity.X += num2; + NPC.velocity.X += npcAcceleration; } - else if (NPC.velocity.X > num4) + else if (NPC.velocity.X > targetX) { - NPC.velocity.X -= num2; + NPC.velocity.X -= npcAcceleration; } - if (NPC.velocity.Y < num5) + if (NPC.velocity.Y < targetY) { - NPC.velocity.Y += num2; + NPC.velocity.Y += npcAcceleration; } - else if (NPC.velocity.Y > num5) + else if (NPC.velocity.Y > targetY) { - NPC.velocity.Y -= num2; + NPC.velocity.Y -= npcAcceleration; } NPC.localAI[0] += 1f; if (NPC.justHit) @@ -165,32 +165,32 @@ namespace CalamityMod.NPCs.Crags dmg = 22; } int projType = ModContent.ProjectileType(); - Projectile.NewProjectile(NPC.GetSource_FromAI(), source.X, source.Y, num4, num5, projType, dmg + (provy ? 30 : 0), 0f, Main.myPlayer, 1f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), npcCenter.X, npcCenter.Y, targetX, targetY, projType, dmg + (provy ? 30 : 0), 0f, Main.myPlayer, 1f, 0f); } } - int num10 = (int)NPC.Center.X; - int num11 = (int)NPC.Center.Y; - num10 /= 16; - num11 /= 16; - if (!WorldGen.SolidTile(num10, num11)) + int npcTileX = (int)NPC.Center.X; + int npcTileY = (int)NPC.Center.Y; + npcTileX /= 16; + npcTileY /= 16; + if (!WorldGen.SolidTile(npcTileX, npcTileY)) { Lighting.AddLight((int)NPC.Center.X / 16, (int)NPC.Center.Y / 16, 0.75f, 0f, 0f); } - if (num4 > 0f) + if (targetX > 0f) { NPC.spriteDirection = 1; - NPC.rotation = (float)Math.Atan2((double)num5, (double)num4); + NPC.rotation = (float)Math.Atan2((double)targetY, (double)targetX); } - if (num4 < 0f) + if (targetX < 0f) { NPC.spriteDirection = -1; - NPC.rotation = (float)Math.Atan2((double)num5, (double)num4) + MathHelper.Pi; + NPC.rotation = (float)Math.Atan2((double)targetY, (double)targetX) + MathHelper.Pi; } - float num12 = 0.7f; + float recoilSpeed = 0.7f; if (NPC.collideX) { NPC.netUpdate = true; - NPC.velocity.X = NPC.oldVelocity.X * -num12; + NPC.velocity.X = NPC.oldVelocity.X * -recoilSpeed; if (NPC.direction == -1 && NPC.velocity.X > 0f && NPC.velocity.X < 2f) { NPC.velocity.X = 2f; @@ -203,7 +203,7 @@ namespace CalamityMod.NPCs.Crags if (NPC.collideY) { NPC.netUpdate = true; - NPC.velocity.Y = NPC.oldVelocity.Y * -num12; + NPC.velocity.Y = NPC.oldVelocity.Y * -recoilSpeed; if (NPC.velocity.Y > 0f && NPC.velocity.Y < 1.5f) { NPC.velocity.Y = 2f; @@ -213,9 +213,9 @@ namespace CalamityMod.NPCs.Crags NPC.velocity.Y = -2f; } } - if (flag) + if (tooFar) { - if ((NPC.velocity.X > 0f && num4 > 0f) || (NPC.velocity.X < 0f && num4 < 0f)) + if ((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f)) { if (Math.Abs(NPC.velocity.X) < 12f) { @@ -240,49 +240,47 @@ namespace CalamityMod.NPCs.Crags spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(texture.Width / 2), (float)(texture.Height / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Vector2 halfSizeTexture = new Vector2((float)(texture.Width / 2), (float)(texture.Height / 2)); + int afterimageAmt = 5; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector41 -= new Vector2((float)texture.Width, (float)(texture.Height)) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2((float)texture.Width, (float)(texture.Height)) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture.Width, (float)(texture.Height)) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture.Width, (float)(texture.Height)) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture = ModContent.Request("CalamityMod/NPCs/Crags/SoulSlurperGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + Color redGlow = Color.Lerp(Color.White, Color.Red, 0.5f); if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector44 -= new Vector2((float)texture.Width, (float)(texture.Height)) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f); + Color glowmaskAfterimageColor = redGlow; + glowmaskAfterimageColor = Color.Lerp(glowmaskAfterimageColor, Color.White, 0.5f); + glowmaskAfterimageColor *= (float)(afterimageAmt - j) / 15f; + Vector2 glowmaskAfterimagePos = NPC.oldPos[j] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + glowmaskAfterimagePos -= new Vector2((float)texture.Width, (float)(texture.Height)) * NPC.scale / 2f; + glowmaskAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture, glowmaskAfterimagePos, NPC.frame, glowmaskAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f); } } - spriteBatch.Draw(texture, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f); + spriteBatch.Draw(texture, drawLocation, NPC.frame, redGlow, NPC.rotation, halfSizeTexture, NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f); return false; } @@ -325,23 +323,23 @@ namespace CalamityMod.NPCs.Crags NPC.height = 50; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int brimDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[brimDust].scale = 0.5f; + Main.dust[brimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int brimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); + Main.dust[brimDust2].noGravity = true; + Main.dust[brimDust2].velocity *= 5f; + brimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimDust2].velocity *= 2f; } } } diff --git a/NPCs/Cryogen/Cryogen.cs b/NPCs/Cryogen/Cryogen.cs index 55f40e6d24..057201c028 100644 --- a/NPCs/Cryogen/Cryogen.cs +++ b/NPCs/Cryogen/Cryogen.cs @@ -230,16 +230,16 @@ namespace CalamityMod.NPCs.Cryogen if (NPC.ai[2] == 0f && NPC.localAI[1] == 0f && Main.netMode != NetmodeID.MultiplayerClient && (NPC.ai[0] < 3f || bossRush || (death && NPC.ai[0] > 3f))) //spawn shield for phase 0 1 2, not 3 4 5 { SoundEngine.PlaySound(ShieldRegenSound, NPC.Center); - int num6 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType(), NPC.whoAmI); - NPC.ai[2] = num6 + 1; + int shieldSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType(), NPC.whoAmI); + NPC.ai[2] = shieldSpawn + 1; NPC.localAI[1] = -1f; NPC.netUpdate = true; - Main.npc[num6].ai[0] = NPC.whoAmI; - Main.npc[num6].netUpdate = true; + Main.npc[shieldSpawn].ai[0] = NPC.whoAmI; + Main.npc[shieldSpawn].netUpdate = true; } - int num7 = (int)NPC.ai[2] - 1; - if (num7 != -1 && Main.npc[num7].active && Main.npc[num7].type == ModContent.NPCType()) + int shieldTracker = (int)NPC.ai[2] - 1; + if (shieldTracker != -1 && Main.npc[shieldTracker].active && Main.npc[shieldTracker].type == ModContent.NPCType()) { NPC.dontTakeDamage = true; } @@ -292,21 +292,20 @@ namespace CalamityMod.NPCs.Cryogen int spawnType = Main.zenithWorld ? NPCID.RedDevil : NPCID.IceGolem; if (!NPC.AnyNPCs(spawnType)) { - int num167 = 1000; - for (int num168 = 0; num168 < num167; num168++) + for (int i = 0; i < 1000; i++) { - int num169 = (int)(NPC.Center.X / 16f) + Main.rand.Next(-50, 51); - int num170; - for (num170 = (int)(NPC.Center.Y / 16f) + Main.rand.Next(-50, 51); num170 < Main.maxTilesY - 10 && !WorldGen.SolidTile(num169, num170); num170++) + int enemySpawnX = (int)(NPC.Center.X / 16f) + Main.rand.Next(-50, 51); + int enemySpawnY; + for (enemySpawnY = (int)(NPC.Center.Y / 16f) + Main.rand.Next(-50, 51); enemySpawnY < Main.maxTilesY - 10 && !WorldGen.SolidTile(enemySpawnX, enemySpawnY); enemySpawnY++) { } - num170--; - if (!WorldGen.SolidTile(num169, num170)) + enemySpawnY--; + if (!WorldGen.SolidTile(enemySpawnX, enemySpawnY)) { - int num171 = NPC.NewNPC(NPC.GetSource_FromAI(), num169 * 16 + 8, num170 * 16, spawnType); - if (Main.netMode == NetmodeID.Server && num171 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num171); + int legendEnemySpawn = NPC.NewNPC(NPC.GetSource_FromAI(), enemySpawnX * 16 + 8, enemySpawnY * 16, spawnType); + if (Main.netMode == NetmodeID.Server && legendEnemySpawn < Main.maxNPCs) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, legendEnemySpawn); break; } @@ -352,8 +351,8 @@ namespace CalamityMod.NPCs.Cryogen Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); for (int k = 0; k < totalProjectiles; k++) { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(vector255) * 30f, vector255, type, damage, 0f, Main.myPlayer); + Vector2 projSpreadRotation = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, damage, 0f, Main.myPlayer); } } } @@ -382,31 +381,31 @@ namespace CalamityMod.NPCs.Cryogen Vector2 spinningPoint = new Vector2(0f, -velocity); for (int k = 0; k < totalProjectiles; k++) { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(vector255) * 30f, vector255, type, damage, 0f, Main.myPlayer); + Vector2 projSpreadRotation = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, damage, 0f, Main.myPlayer); } } } } - Vector2 vector142 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num1243 = player.Center.X - vector142.X; - float num1244 = player.Center.Y - vector142.Y; - float num1245 = (float)Math.Sqrt(num1243 * num1243 + num1244 * num1244); + Vector2 cryogenCenter = new Vector2(NPC.Center.X, NPC.Center.Y); + float playerXDist = player.Center.X - cryogenCenter.X; + float playerYDist = player.Center.Y - cryogenCenter.Y; + float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); - float num1246 = revenge ? 5f : 4f; - num1246 += 4f * enrageScale; + float cryogenSpeed = revenge ? 5f : 4f; + cryogenSpeed += 4f * enrageScale; - num1245 = num1246 / num1245; - num1243 *= num1245; - num1244 *= num1245; + playerDistance = cryogenSpeed / playerDistance; + playerXDist *= playerDistance; + playerYDist *= playerDistance; float inertia = 50f; if (Main.getGoodWorld) inertia *= 0.5f; - NPC.velocity.X = (NPC.velocity.X * inertia + num1243) / (inertia + 1f); - NPC.velocity.Y = (NPC.velocity.Y * inertia + num1244) / (inertia + 1f); + NPC.velocity.X = (NPC.velocity.X * inertia + playerXDist) / (inertia + 1f); + NPC.velocity.Y = (NPC.velocity.Y * inertia + playerYDist) / (inertia + 1f); if (phase2) { @@ -443,8 +442,8 @@ namespace CalamityMod.NPCs.Cryogen Vector2 spinningPoint = new Vector2(0f, -velocity2); for (int k = 0; k < totalProjectiles; k++) { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(vector255) * 30f, vector255, type, damage, 0f, Main.myPlayer); + Vector2 projSpreadRotation = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, damage, 0f, Main.myPlayer); } } } @@ -527,8 +526,8 @@ namespace CalamityMod.NPCs.Cryogen Vector2 spinningPoint = i == 0 ? new Vector2(0f, -newVelocity) : new Vector2(-velocityX, -newVelocity); for (int k = 0; k < totalProjectilesShot; k++) { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(vector255) * 30f, vector255, type, damage, 0f, Main.myPlayer, 0f, velocity); + Vector2 projSpreadRotation = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, damage, 0f, Main.myPlayer, 0f, velocity); } } } @@ -619,31 +618,31 @@ namespace CalamityMod.NPCs.Cryogen Vector2 spinningPoint = new Vector2(0f, -velocity); for (int k = 0; k < totalProjectiles; k++) { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(vector255) * 30f, vector255, type, damage, 0f, Main.myPlayer); + Vector2 projSpreadRotation = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, damage, 0f, Main.myPlayer); } } } } - Vector2 vector142 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num1243 = player.Center.X - vector142.X; - float num1244 = player.Center.Y - vector142.Y; - float num1245 = (float)Math.Sqrt(num1243 * num1243 + num1244 * num1244); + Vector2 cryogenCenter = new Vector2(NPC.Center.X, NPC.Center.Y); + float playerXDist = player.Center.X - cryogenCenter.X; + float playerYDist = player.Center.Y - cryogenCenter.Y; + float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); - float num1246 = revenge ? 7f : 6f; - num1246 += 4f * enrageScale; + float cryogenSpeed = revenge ? 7f : 6f; + cryogenSpeed += 4f * enrageScale; - num1245 = num1246 / num1245; - num1243 *= num1245; - num1244 *= num1245; + playerDistance = cryogenSpeed / playerDistance; + playerXDist *= playerDistance; + playerYDist *= playerDistance; float inertia = 50f; if (Main.getGoodWorld) inertia *= 0.5f; - NPC.velocity.X = (NPC.velocity.X * inertia + num1243) / (inertia + 1f); - NPC.velocity.Y = (NPC.velocity.Y * inertia + num1244) / (inertia + 1f); + NPC.velocity.X = (NPC.velocity.X * inertia + playerXDist) / (inertia + 1f); + NPC.velocity.Y = (NPC.velocity.Y * inertia + playerYDist) / (inertia + 1f); } else if (NPC.ai[1] < chargeGateValue) { @@ -675,8 +674,8 @@ namespace CalamityMod.NPCs.Cryogen Vector2 spinningPoint = i == 1 ? new Vector2(0f, -newVelocity) : new Vector2(-velocityX, -newVelocity); for (int k = 0; k < totalProjectilesShot; k++) { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(vector255) * 30f, vector255, type, damage, 0f, Main.myPlayer, 0f, velocity); + Vector2 projSpreadRotation = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, damage, 0f, Main.myPlayer, 0f, velocity); } } } @@ -769,31 +768,31 @@ namespace CalamityMod.NPCs.Cryogen Vector2 spinningPoint = new Vector2(0f, -velocity); for (int k = 0; k < totalProjectiles; k++) { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(vector255) * 30f, vector255, type, damage, 0f, Main.myPlayer); + Vector2 projSpreadRotation = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, damage, 0f, Main.myPlayer); } } } } - Vector2 vector142 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num1243 = player.Center.X - vector142.X; - float num1244 = player.Center.Y - vector142.Y; - float num1245 = (float)Math.Sqrt(num1243 * num1243 + num1244 * num1244); + Vector2 cryogenCenter = new Vector2(NPC.Center.X, NPC.Center.Y); + float playerXDist = player.Center.X - cryogenCenter.X; + float playerYDist = player.Center.Y - cryogenCenter.Y; + float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); float speed = revenge ? 5.5f : 5f; speed += 3f * enrageScale; - num1245 = speed / num1245; - num1243 *= num1245; - num1244 *= num1245; + playerDistance = speed / playerDistance; + playerXDist *= playerDistance; + playerYDist *= playerDistance; float inertia = 50f; if (Main.getGoodWorld) inertia *= 0.5f; - NPC.velocity.X = (NPC.velocity.X * inertia + num1243) / (inertia + 1f); - NPC.velocity.Y = (NPC.velocity.Y * inertia + num1244) / (inertia + 1f); + NPC.velocity.X = (NPC.velocity.X * inertia + playerXDist) / (inertia + 1f); + NPC.velocity.Y = (NPC.velocity.Y * inertia + playerYDist) / (inertia + 1f); if (NPC.ai[1] == 0f) { @@ -804,37 +803,37 @@ namespace CalamityMod.NPCs.Cryogen { NPC.TargetClosest(); NPC.localAI[2] = 0f; - int num1249 = 0; - int num1250; - int num1251; + int attackTimer = 0; + int playerTileX; + int playerTileY; while (true) { - num1249++; - num1250 = (int)player.Center.X / 16; - num1251 = (int)player.Center.Y / 16; + attackTimer++; + playerTileX = (int)player.Center.X / 16; + playerTileY = (int)player.Center.Y / 16; int min = 16; int max = 20; if (Main.rand.NextBool()) - num1250 += Main.rand.Next(min, max); + playerTileX += Main.rand.Next(min, max); else - num1250 -= Main.rand.Next(min, max); + playerTileX -= Main.rand.Next(min, max); if (Main.rand.NextBool()) - num1251 += Main.rand.Next(min, max); + playerTileY += Main.rand.Next(min, max); else - num1251 -= Main.rand.Next(min, max); + playerTileY -= Main.rand.Next(min, max); - if (!WorldGen.SolidTile(num1250, num1251) && Collision.CanHit(new Vector2(num1250 * 16, num1251 * 16), 1, 1, player.position, player.width, player.height)) + if (!WorldGen.SolidTile(playerTileX, playerTileY) && Collision.CanHit(new Vector2(playerTileX * 16, playerTileY * 16), 1, 1, player.position, player.width, player.height)) break; - if (num1249 > 100) + if (attackTimer > 100) goto Block; } NPC.ai[1] = 1f; - teleportLocationX = num1250; - calamityGlobalNPC.newAI[2] = num1251; + teleportLocationX = playerTileX; + calamityGlobalNPC.newAI[2] = playerTileY; NPC.netUpdate = true; Block: ; @@ -861,8 +860,8 @@ namespace CalamityMod.NPCs.Cryogen for (int n = 0; n < 15; n++) { - int num39 = Dust.NewDust(NPC.position, NPC.width, NPC.height, dustType, 0f, 0f, 100, default, 3f); - Main.dust[num39].noGravity = true; + int iceDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, dustType, 0f, 0f, 100, default, 3f); + Main.dust[iceDust].noGravity = true; } if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) @@ -890,8 +889,8 @@ namespace CalamityMod.NPCs.Cryogen Vector2 spinningPoint = i == 0 ? new Vector2(0f, -newVelocity) : new Vector2(-velocityX, -newVelocity); for (int k = 0; k < totalProjectiles; k++) { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(vector255) * 30f, vector255, type, damage, 0f, Main.myPlayer, 0f, velocity); + Vector2 projSpreadRotation = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, damage, 0f, Main.myPlayer, 0f, velocity); } } } @@ -976,8 +975,8 @@ namespace CalamityMod.NPCs.Cryogen Vector2 spinningPoint = i == 0 ? new Vector2(0f, -newVelocity) : new Vector2(-velocityX, -newVelocity); for (int k = 0; k < totalProjectiles; k++) { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(vector255) * 30f, vector255, type, damage, 0f, Main.myPlayer, ai, 1f); + Vector2 projSpreadRotation = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, damage, 0f, Main.myPlayer, ai, 1f); } } } @@ -1012,29 +1011,29 @@ namespace CalamityMod.NPCs.Cryogen return; } - float num1372 = 18f + enrageScale * 2f; + float chargeVelMult = 18f + enrageScale * 2f; - Vector2 vector167 = new Vector2(NPC.Center.X + (NPC.direction * 20), NPC.Center.Y + 6f); - float num1373 = player.position.X + player.width * 0.5f - vector167.X; - float num1374 = player.Center.Y - vector167.Y; - float num1375 = (float)Math.Sqrt(num1373 * num1373 + num1374 * num1374); - float num1376 = num1372 / num1375; - num1373 *= num1376; - num1374 *= num1376; + Vector2 chargeDirection = new Vector2(NPC.Center.X + (NPC.direction * 20), NPC.Center.Y + 6f); + float playerchargeXDist = player.position.X + player.width * 0.5f - chargeDirection.X; + float playerchargeYDist = player.Center.Y - chargeDirection.Y; + float playerDistance = (float)Math.Sqrt(playerchargeXDist * playerchargeXDist + playerchargeYDist * playerchargeYDist); + float chargeSpeed = chargeVelMult / playerDistance; + playerchargeXDist *= chargeSpeed; + playerchargeYDist *= chargeSpeed; calamityGlobalNPC.newAI[2] -= 1f; float chargeStartDistance = 300f; float chargeCooldown = 30f; - if (num1375 < chargeStartDistance || calamityGlobalNPC.newAI[2] > 0f) + if (playerDistance < chargeStartDistance || calamityGlobalNPC.newAI[2] > 0f) { - if (num1375 < chargeStartDistance) + if (playerDistance < chargeStartDistance) calamityGlobalNPC.newAI[2] = chargeCooldown; - if (NPC.velocity.Length() < num1372) + if (NPC.velocity.Length() < chargeVelMult) { NPC.velocity.Normalize(); - NPC.velocity *= num1372; + NPC.velocity *= chargeVelMult; } NPC.rotation += NPC.direction * 0.5f; @@ -1046,17 +1045,17 @@ namespace CalamityMod.NPCs.Cryogen if (Main.getGoodWorld) inertia *= 0.5f; - NPC.velocity.X = (NPC.velocity.X * inertia + num1373) / (inertia + 1f); - NPC.velocity.Y = (NPC.velocity.Y * inertia + num1374) / (inertia + 1f); - if (num1375 < chargeStartDistance + 200f) + NPC.velocity.X = (NPC.velocity.X * inertia + playerchargeXDist) / (inertia + 1f); + NPC.velocity.Y = (NPC.velocity.Y * inertia + playerchargeYDist) / (inertia + 1f); + if (playerDistance < chargeStartDistance + 200f) { - NPC.velocity.X = (NPC.velocity.X * 9f + num1373) / 10f; - NPC.velocity.Y = (NPC.velocity.Y * 9f + num1374) / 10f; + NPC.velocity.X = (NPC.velocity.X * 9f + playerchargeXDist) / 10f; + NPC.velocity.Y = (NPC.velocity.Y * 9f + playerchargeYDist) / 10f; } - if (num1375 < chargeStartDistance + 100f) + if (playerDistance < chargeStartDistance + 100f) { - NPC.velocity.X = (NPC.velocity.X * 4f + num1373) / 5f; - NPC.velocity.Y = (NPC.velocity.Y * 4f + num1374) / 5f; + NPC.velocity.X = (NPC.velocity.X * 4f + playerchargeXDist) / 5f; + NPC.velocity.Y = (NPC.velocity.Y * 4f + playerchargeYDist) / 5f; } NPC.rotation = NPC.velocity.X * 0.15f; @@ -1081,8 +1080,8 @@ namespace CalamityMod.NPCs.Cryogen Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity2) : new Vector2(velocityX, -velocity2); for (int k = 0; k < totalProjectiles; k++) { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(vector255) * 30f, vector255, type, damage, 0f, Main.myPlayer); + Vector2 projSpreadRotation = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, damage, 0f, Main.myPlayer); } } @@ -1250,23 +1249,23 @@ namespace CalamityMod.NPCs.Cryogen } if (NPC.life <= 0) { - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, dusttype, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int icyDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, dusttype, 0f, 0f, 100, default, 2f); + Main.dust[icyDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[icyDust].scale = 0.5f; + Main.dust[icyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, dusttype, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, dusttype, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int icyDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, dusttype, 0f, 0f, 100, default, 3f); + Main.dust[icyDust2].noGravity = true; + Main.dust[icyDust2].velocity *= 5f; + icyDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, dusttype, 0f, 0f, 100, default, 2f); + Main.dust[icyDust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server && !Main.zenithWorld) { @@ -1326,7 +1325,7 @@ namespace CalamityMod.NPCs.Cryogen npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB Bloodflare Core drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType()); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedCryogen, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1361,18 +1360,18 @@ namespace CalamityMod.NPCs.Cryogen { Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= 40f * NPC.scale; } diff --git a/NPCs/Cryogen/CryogenShield.cs b/NPCs/Cryogen/CryogenShield.cs index 246b7cc930..4c07fcb1a8 100644 --- a/NPCs/Cryogen/CryogenShield.cs +++ b/NPCs/Cryogen/CryogenShield.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -71,14 +70,14 @@ namespace CalamityMod.NPCs.Cryogen if (NPC.type == ModContent.NPCType()) { - int num989 = (int)NPC.ai[0]; - if (Main.npc[num989].active && Main.npc[num989].type == ModContent.NPCType()) + int mainCryogen = (int)NPC.ai[0]; + if (Main.npc[mainCryogen].active && Main.npc[mainCryogen].type == ModContent.NPCType()) { NPC.velocity = Vector2.Zero; - NPC.position = Main.npc[num989].Center; - NPC.ai[1] = Main.npc[num989].velocity.X; - NPC.ai[2] = Main.npc[num989].velocity.Y; - NPC.ai[3] = Main.npc[num989].target; + NPC.position = Main.npc[mainCryogen].Center; + NPC.ai[1] = Main.npc[mainCryogen].velocity.X; + NPC.ai[2] = Main.npc[mainCryogen].velocity.Y; + NPC.ai[3] = Main.npc[mainCryogen].target; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); return; @@ -95,18 +94,18 @@ namespace CalamityMod.NPCs.Cryogen { Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= (100f * NPC.scale) && NPC.Opacity == 1f; } @@ -156,6 +155,9 @@ namespace CalamityMod.NPCs.Cryogen } } + // Don't count towards NPC limit and don't despawn offscreen. + public override bool CheckActive() => false; + public override void HitEffect(NPC.HitInfo hit) { int dusttype = Main.zenithWorld ? 235 : 67; @@ -165,24 +167,24 @@ namespace CalamityMod.NPCs.Cryogen } if (NPC.life <= 0) { - for (int num621 = 0; num621 < 25; num621++) + for (int i = 0; i < 25; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, dusttype, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int icyDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, dusttype, 0f, 0f, 100, default, 2f); + Main.dust[icyDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[icyDust].scale = 0.5f; + Main.dust[icyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 50; num623++) + for (int j = 0; j < 50; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, dusttype, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, dusttype, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int icyDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, dusttype, 0f, 0f, 100, default, 3f); + Main.dust[icyDust2].noGravity = true; + Main.dust[icyDust2].velocity *= 5f; + icyDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, dusttype, 0f, 0f, 100, default, 2f); + Main.dust[icyDust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server && !Main.zenithWorld) @@ -192,11 +194,11 @@ namespace CalamityMod.NPCs.Cryogen Vector2 spinningPoint = new Vector2(0f, -1f); for (int k = 0; k < totalGores; k++) { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Vector2 goreRotation = spinningPoint.RotatedBy(radians * k); for (int x = 1; x <= 4; x++) { float randomSpread = Main.rand.Next(-200, 201) / 100f; - Gore.NewGore(NPC.GetSource_Death(), NPC.Center + Vector2.Normalize(vector255) * 80f, vector255 * new Vector2(NPC.ai[1], NPC.ai[2]) * randomSpread, Mod.Find("CryoShieldGore" + x).Type, NPC.scale); + Gore.NewGore(NPC.GetSource_Death(), NPC.Center + Vector2.Normalize(goreRotation) * 80f, goreRotation * new Vector2(NPC.ai[1], NPC.ai[2]) * randomSpread, Mod.Find("CryoShieldGore" + x).Type, NPC.scale); } } } diff --git a/NPCs/DesertScourge/DesertNuisanceBody.cs b/NPCs/DesertScourge/DesertNuisanceBody.cs index 800bf83d00..0b2b291868 100644 --- a/NPCs/DesertScourge/DesertNuisanceBody.cs +++ b/NPCs/DesertScourge/DesertNuisanceBody.cs @@ -93,40 +93,39 @@ namespace CalamityMod.NPCs.DesertScourge if (Main.player[NPC.target].dead) NPC.TargetClosest(false); - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentTilePos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float playerXPos = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float playerYPos = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + playerXPos = (float)((int)(playerXPos / 16f) * 16); + playerYPos = (float)((int)(playerYPos / 16f) * 16); + segmentTilePos.X = (float)((int)(segmentTilePos.X / 16f) * 16); + segmentTilePos.Y = (float)((int)(segmentTilePos.Y / 16f) * 16); + playerXPos -= segmentTilePos.X; + playerYPos -= segmentTilePos.Y; + float playerDistance = (float)System.Math.Sqrt((double)(playerXPos * playerXPos + playerYPos * playerYPos)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentTilePos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + playerXPos = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentTilePos.X; + playerYPos = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentTilePos.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)playerYPos, (double)playerXPos) + 1.57f; + playerDistance = (float)System.Math.Sqrt((double)(playerXPos * playerXPos + playerYPos * playerYPos)); + playerDistance = (playerDistance - (float)(NPC.width)) / playerDistance; + playerXPos *= playerDistance; + playerYPos *= playerDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + playerXPos; + NPC.position.Y = NPC.position.Y + playerYPos; - if (num191 < 0f) + if (playerXPos < 0f) NPC.spriteDirection = 1; - else if (num191 > 0f) + else if (playerXPos > 0f) NPC.spriteDirection = -1; } } diff --git a/NPCs/DesertScourge/DesertNuisanceHead.cs b/NPCs/DesertScourge/DesertNuisanceHead.cs index cc9369b1d0..9c0732dded 100644 --- a/NPCs/DesertScourge/DesertNuisanceHead.cs +++ b/NPCs/DesertScourge/DesertNuisanceHead.cs @@ -22,7 +22,7 @@ namespace CalamityMod.NPCs.DesertScourge public override void SetStaticDefaults() { NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.8f, PortraitScale = 0.8f, @@ -100,51 +100,50 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[2] = (float)NPC.whoAmI; NPC.realLife = NPC.whoAmI; int num2 = NPC.whoAmI; - int num3 = maxLength; - for (int j = 0; j <= num3; j++) + for (int j = 0; j <= maxLength; j++) { - int num4 = ModContent.NPCType(); - if (j == num3) + int segmentType = ModContent.NPCType(); + if (j == maxLength) { - num4 = ModContent.NPCType(); + segmentType = ModContent.NPCType(); } - int num5 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (float)(NPC.width / 2)), (int)(NPC.position.Y + (float)NPC.height), num4, NPC.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num5].ai[2] = (float)NPC.whoAmI; - Main.npc[num5].realLife = NPC.whoAmI; - Main.npc[num5].ai[1] = (float)num2; - Main.npc[num2].ai[0] = (float)num5; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num5, 0f, 0f, 0f, 0, 0, 0); - num2 = num5; + int segmentSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (float)(NPC.width / 2)), (int)(NPC.position.Y + (float)NPC.height), segmentType, NPC.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[segmentSpawn].ai[2] = (float)NPC.whoAmI; + Main.npc[segmentSpawn].realLife = NPC.whoAmI; + Main.npc[segmentSpawn].ai[1] = (float)num2; + Main.npc[num2].ai[0] = (float)segmentSpawn; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, segmentSpawn, 0f, 0f, 0f, 0, 0, 0); + num2 = segmentSpawn; } TailSpawned = true; } } - int num12 = (int)(NPC.position.X / 16f) - 1; - int num13 = (int)((NPC.position.X + (float)NPC.width) / 16f) + 2; - int num14 = (int)(NPC.position.Y / 16f) - 1; - int num15 = (int)((NPC.position.Y + (float)NPC.height) / 16f) + 2; - if (num12 < 0) + int tilePositionX = (int)(NPC.position.X / 16f) - 1; + int tileWidthPosX = (int)((NPC.position.X + (float)NPC.width) / 16f) + 2; + int tilePositionY = (int)(NPC.position.Y / 16f) - 1; + int tileWidthPosY = (int)((NPC.position.Y + (float)NPC.height) / 16f) + 2; + if (tilePositionX < 0) { - num12 = 0; + tilePositionX = 0; } - if (num13 > Main.maxTilesX) + if (tileWidthPosX > Main.maxTilesX) { - num13 = Main.maxTilesX; + tileWidthPosX = Main.maxTilesX; } - if (num14 < 0) + if (tilePositionY < 0) { - num14 = 0; + tilePositionY = 0; } - if (num15 > Main.maxTilesY) + if (tileWidthPosY > Main.maxTilesY) { - num15 = Main.maxTilesY; + tileWidthPosY = Main.maxTilesY; } - bool flag2 = false; - if (!flag2) + bool shouldFly = false; + if (!shouldFly) { - for (int k = num12; k < num13; k++) + for (int k = tilePositionX; k < tileWidthPosX; k++) { - for (int l = num14; l < num15; l++) + for (int l = tilePositionY; l < tileWidthPosY; l++) { if (Main.tile[k, l] != null && ((Main.tile[k, l].HasUnactuatedTile && (Main.tileSolid[(int)Main.tile[k, l].TileType] || (Main.tileSolidTop[(int)Main.tile[k, l].TileType] && Main.tile[k, l].TileFrameY == 0))) || Main.tile[k, l].LiquidAmount > 64)) { @@ -153,36 +152,36 @@ namespace CalamityMod.NPCs.DesertScourge vector2.Y = (float)(l * 16); if (NPC.position.X + (float)NPC.width > vector2.X && NPC.position.X < vector2.X + 16f && NPC.position.Y + (float)NPC.height > vector2.Y && NPC.position.Y < vector2.Y + 16f) { - flag2 = true; + shouldFly = true; break; } } } } } - if (!flag2) + if (!shouldFly) { NPC.localAI[1] = 1f; Rectangle rectangle = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); - int num16 = 1000; - bool flag3 = true; + int directChaseDistance = 1000; + bool shouldDirectlyChase = true; if (NPC.position.Y > Main.player[NPC.target].position.Y) { for (int m = 0; m < 255; m++) { if (Main.player[m].active) { - Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - num16, (int)Main.player[m].position.Y - num16, num16 * 2, num16 * 2); + Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - directChaseDistance, (int)Main.player[m].position.Y - directChaseDistance, directChaseDistance * 2, directChaseDistance * 2); if (rectangle.Intersects(rectangle2)) { - flag3 = false; + shouldDirectlyChase = false; break; } } } - if (flag3) + if (shouldDirectlyChase) { - flag2 = true; + shouldFly = true; } } } @@ -190,15 +189,15 @@ namespace CalamityMod.NPCs.DesertScourge { NPC.localAI[1] = 0f; } - float num17 = 16f; + float maxChaseSpeed = 16f; if (Main.player[NPC.target].dead) { - flag2 = false; + shouldFly = false; NPC.velocity.Y = NPC.velocity.Y + 1f; if ((double)NPC.position.Y > Main.worldSurface * 16.0) { NPC.velocity.Y = NPC.velocity.Y + 1f; - num17 = 32f; + maxChaseSpeed = 32f; } if ((double)NPC.position.Y > Main.rockLayer * 16.0) { @@ -212,62 +211,62 @@ namespace CalamityMod.NPCs.DesertScourge } } } - float num18 = speed; - float num19 = turnSpeed; + float speedCopy = speed; + float turnSpeedCopy = turnSpeed; if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) { - num18 *= 1.5f; - num19 *= 1.5f; + speedCopy *= 1.5f; + turnSpeedCopy *= 1.5f; } - Vector2 vector3 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num20 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num21 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num20 = (float)((int)(num20 / 16f) * 16); - num21 = (float)((int)(num21 / 16f) * 16); - vector3.X = (float)((int)(vector3.X / 16f) * 16); - vector3.Y = (float)((int)(vector3.Y / 16f) * 16); - num20 -= vector3.X; - num21 -= vector3.Y; - float num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); - if (!flag2) + Vector2 npcCenter = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float playerX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targettingPosition = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + playerX = (float)((int)(playerX / 16f) * 16); + targettingPosition = (float)((int)(targettingPosition / 16f) * 16); + npcCenter.X = (float)((int)(npcCenter.X / 16f) * 16); + npcCenter.Y = (float)((int)(npcCenter.Y / 16f) * 16); + playerX -= npcCenter.X; + targettingPosition -= npcCenter.Y; + float targetDistance = (float)Math.Sqrt((double)(playerX * playerX + targettingPosition * targettingPosition)); + if (!shouldFly) { NPC.TargetClosest(); NPC.velocity.Y = NPC.velocity.Y + 0.15f; - if (NPC.velocity.Y > num17) + if (NPC.velocity.Y > maxChaseSpeed) { - NPC.velocity.Y = num17; + NPC.velocity.Y = maxChaseSpeed; } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)num17 * 0.4) + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)maxChaseSpeed * 0.4) { if (NPC.velocity.X < 0f) { - NPC.velocity.X = NPC.velocity.X - num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X - speedCopy * 1.1f; } else { - NPC.velocity.X = NPC.velocity.X + num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X + speedCopy * 1.1f; } } - else if (NPC.velocity.Y == num17) + else if (NPC.velocity.Y == maxChaseSpeed) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < playerX) { - NPC.velocity.X = NPC.velocity.X + num18; + NPC.velocity.X = NPC.velocity.X + speedCopy; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > playerX) { - NPC.velocity.X = NPC.velocity.X - num18; + NPC.velocity.X = NPC.velocity.X - speedCopy; } } else if (NPC.velocity.Y > 4f) { if (NPC.velocity.X < 0f) { - NPC.velocity.X = NPC.velocity.X + num18 * 0.9f; + NPC.velocity.X = NPC.velocity.X + speedCopy * 0.9f; } else { - NPC.velocity.X = NPC.velocity.X - num18 * 0.9f; + NPC.velocity.X = NPC.velocity.X - speedCopy * 0.9f; } } } @@ -275,131 +274,131 @@ namespace CalamityMod.NPCs.DesertScourge { if (NPC.soundDelay == 0) { - float num24 = num22 / 40f; - if (num24 < 10f) + float soundDelay = targetDistance / 40f; + if (soundDelay < 10f) { - num24 = 10f; + soundDelay = 10f; } - if (num24 > 20f) + if (soundDelay > 20f) { - num24 = 20f; + soundDelay = 20f; } - NPC.soundDelay = (int)num24; + NPC.soundDelay = (int)soundDelay; SoundEngine.PlaySound(SoundID.WormDig, NPC.Center); } - num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); - float num25 = Math.Abs(num20); - float num26 = Math.Abs(num21); - float num27 = num17 / num22; - num20 *= num27; - num21 *= num27; - if (((NPC.velocity.X > 0f && num20 > 0f) || (NPC.velocity.X < 0f && num20 < 0f)) && ((NPC.velocity.Y > 0f && num21 > 0f) || (NPC.velocity.Y < 0f && num21 < 0f))) + targetDistance = (float)Math.Sqrt((double)(playerX * playerX + targettingPosition * targettingPosition)); + float absolutePlayerX = Math.Abs(playerX); + float absoluteTargetPos = Math.Abs(targettingPosition); + float timeToReachTarget = maxChaseSpeed / targetDistance; + playerX *= timeToReachTarget; + targettingPosition *= timeToReachTarget; + if (((NPC.velocity.X > 0f && playerX > 0f) || (NPC.velocity.X < 0f && playerX < 0f)) && ((NPC.velocity.Y > 0f && targettingPosition > 0f) || (NPC.velocity.Y < 0f && targettingPosition < 0f))) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < playerX) { - NPC.velocity.X = NPC.velocity.X + num19; + NPC.velocity.X = NPC.velocity.X + turnSpeedCopy; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > playerX) { - NPC.velocity.X = NPC.velocity.X - num19; + NPC.velocity.X = NPC.velocity.X - turnSpeedCopy; } - if (NPC.velocity.Y < num21) + if (NPC.velocity.Y < targettingPosition) { - NPC.velocity.Y = NPC.velocity.Y + num19; + NPC.velocity.Y = NPC.velocity.Y + turnSpeedCopy; } - else if (NPC.velocity.Y > num21) + else if (NPC.velocity.Y > targettingPosition) { - NPC.velocity.Y = NPC.velocity.Y - num19; + NPC.velocity.Y = NPC.velocity.Y - turnSpeedCopy; } } - if ((NPC.velocity.X > 0f && num20 > 0f) || (NPC.velocity.X < 0f && num20 < 0f) || (NPC.velocity.Y > 0f && num21 > 0f) || (NPC.velocity.Y < 0f && num21 < 0f)) + if ((NPC.velocity.X > 0f && playerX > 0f) || (NPC.velocity.X < 0f && playerX < 0f) || (NPC.velocity.Y > 0f && targettingPosition > 0f) || (NPC.velocity.Y < 0f && targettingPosition < 0f)) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < playerX) { - NPC.velocity.X = NPC.velocity.X + num18; + NPC.velocity.X = NPC.velocity.X + speedCopy; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > playerX) { - NPC.velocity.X = NPC.velocity.X - num18; + NPC.velocity.X = NPC.velocity.X - speedCopy; } - if (NPC.velocity.Y < num21) + if (NPC.velocity.Y < targettingPosition) { - NPC.velocity.Y = NPC.velocity.Y + num18; + NPC.velocity.Y = NPC.velocity.Y + speedCopy; } - else if (NPC.velocity.Y > num21) + else if (NPC.velocity.Y > targettingPosition) { - NPC.velocity.Y = NPC.velocity.Y - num18; + NPC.velocity.Y = NPC.velocity.Y - speedCopy; } - if ((double)Math.Abs(num21) < (double)num17 * 0.2 && ((NPC.velocity.X > 0f && num20 < 0f) || (NPC.velocity.X < 0f && num20 > 0f))) + if ((double)Math.Abs(targettingPosition) < (double)maxChaseSpeed * 0.2 && ((NPC.velocity.X > 0f && playerX < 0f) || (NPC.velocity.X < 0f && playerX > 0f))) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num18 * 2f; + NPC.velocity.Y = NPC.velocity.Y + speedCopy * 2f; } else { - NPC.velocity.Y = NPC.velocity.Y - num18 * 2f; + NPC.velocity.Y = NPC.velocity.Y - speedCopy * 2f; } } - if ((double)Math.Abs(num20) < (double)num17 * 0.2 && ((NPC.velocity.Y > 0f && num21 < 0f) || (NPC.velocity.Y < 0f && num21 > 0f))) + if ((double)Math.Abs(playerX) < (double)maxChaseSpeed * 0.2 && ((NPC.velocity.Y > 0f && targettingPosition < 0f) || (NPC.velocity.Y < 0f && targettingPosition > 0f))) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num18 * 2f; + NPC.velocity.X = NPC.velocity.X + speedCopy * 2f; } else { - NPC.velocity.X = NPC.velocity.X - num18 * 2f; + NPC.velocity.X = NPC.velocity.X - speedCopy * 2f; } } } - else if (num25 > num26) + else if (absolutePlayerX > absoluteTargetPos) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < playerX) { - NPC.velocity.X = NPC.velocity.X + num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X + speedCopy * 1.1f; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > playerX) { - NPC.velocity.X = NPC.velocity.X - num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X - speedCopy * 1.1f; } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)num17 * 0.5) + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)maxChaseSpeed * 0.5) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num18; + NPC.velocity.Y = NPC.velocity.Y + speedCopy; } else { - NPC.velocity.Y = NPC.velocity.Y - num18; + NPC.velocity.Y = NPC.velocity.Y - speedCopy; } } } else { - if (NPC.velocity.Y < num21) + if (NPC.velocity.Y < targettingPosition) { - NPC.velocity.Y = NPC.velocity.Y + num18 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y + speedCopy * 1.1f; } - else if (NPC.velocity.Y > num21) + else if (NPC.velocity.Y > targettingPosition) { - NPC.velocity.Y = NPC.velocity.Y - num18 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y - speedCopy * 1.1f; } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)num17 * 0.5) + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)maxChaseSpeed * 0.5) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num18; + NPC.velocity.X = NPC.velocity.X + speedCopy; } else { - NPC.velocity.X = NPC.velocity.X - num18; + NPC.velocity.X = NPC.velocity.X - speedCopy; } } } } NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) + 1.57f; - if (flag2) + if (shouldFly) { if (NPC.localAI[0] != 1f) { diff --git a/NPCs/DesertScourge/DesertNuisanceTail.cs b/NPCs/DesertScourge/DesertNuisanceTail.cs index 26bba2e479..4d71065aab 100644 --- a/NPCs/DesertScourge/DesertNuisanceTail.cs +++ b/NPCs/DesertScourge/DesertNuisanceTail.cs @@ -93,40 +93,39 @@ namespace CalamityMod.NPCs.DesertScourge if (Main.player[NPC.target].dead) NPC.TargetClosest(false); - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentTilePos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float playerXPos = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float playerYPos = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + playerXPos = (float)((int)(playerXPos / 16f) * 16); + playerYPos = (float)((int)(playerYPos / 16f) * 16); + segmentTilePos.X = (float)((int)(segmentTilePos.X / 16f) * 16); + segmentTilePos.Y = (float)((int)(segmentTilePos.Y / 16f) * 16); + playerXPos -= segmentTilePos.X; + playerYPos -= segmentTilePos.Y; + float playerDistance = (float)System.Math.Sqrt((double)(playerXPos * playerXPos + playerYPos * playerYPos)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentTilePos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + playerXPos = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentTilePos.X; + playerYPos = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentTilePos.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)playerYPos, (double)playerXPos) + 1.57f; + playerDistance = (float)System.Math.Sqrt((double)(playerXPos * playerXPos + playerYPos * playerYPos)); + playerDistance = (playerDistance - (float)(NPC.width)) / playerDistance; + playerXPos *= playerDistance; + playerYPos *= playerDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + playerXPos; + NPC.position.Y = NPC.position.Y + playerYPos; - if (num191 < 0f) + if (playerXPos < 0f) NPC.spriteDirection = 1; - else if (num191 > 0f) + else if (playerXPos > 0f) NPC.spriteDirection = -1; } } diff --git a/NPCs/DesertScourge/DesertScourgeBody.cs b/NPCs/DesertScourge/DesertScourgeBody.cs index 2b44b423b2..3154b76c7e 100644 --- a/NPCs/DesertScourge/DesertScourgeBody.cs +++ b/NPCs/DesertScourge/DesertScourgeBody.cs @@ -109,40 +109,39 @@ namespace CalamityMod.NPCs.DesertScourge if (Main.player[NPC.target].dead) NPC.TargetClosest(false); - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentTilePos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float playerXPos = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float playerYPos = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + playerXPos = (float)((int)(playerXPos / 16f) * 16); + playerYPos = (float)((int)(playerYPos / 16f) * 16); + segmentTilePos.X = (float)((int)(segmentTilePos.X / 16f) * 16); + segmentTilePos.Y = (float)((int)(segmentTilePos.Y / 16f) * 16); + playerXPos -= segmentTilePos.X; + playerYPos -= segmentTilePos.Y; + float playerDistance = (float)System.Math.Sqrt((double)(playerXPos * playerXPos + playerYPos * playerYPos)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentTilePos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + playerXPos = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentTilePos.X; + playerYPos = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentTilePos.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)playerYPos, (double)playerXPos) + 1.57f; + playerDistance = (float)System.Math.Sqrt((double)(playerXPos * playerXPos + playerYPos * playerYPos)); + playerDistance = (playerDistance - (float)(NPC.width)) / playerDistance; + playerXPos *= playerDistance; + playerYPos *= playerDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + playerXPos; + NPC.position.Y = NPC.position.Y + playerYPos; - if (num191 < 0f) + if (playerXPos < 0f) NPC.spriteDirection = 1; - else if (num191 > 0f) + else if (playerXPos > 0f) NPC.spriteDirection = -1; } } diff --git a/NPCs/DesertScourge/DesertScourgeHead.cs b/NPCs/DesertScourge/DesertScourgeHead.cs index f1714c5b72..4b558ac7d8 100644 --- a/NPCs/DesertScourge/DesertScourgeHead.cs +++ b/NPCs/DesertScourge/DesertScourgeHead.cs @@ -42,7 +42,7 @@ namespace CalamityMod.NPCs.DesertScourge public override void SetStaticDefaults() { NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.75f, PortraitScale = 0.6f, @@ -232,10 +232,10 @@ namespace CalamityMod.NPCs.DesertScourge if (Main.getGoodWorld) minLength *= 3; - for (int num36 = 0; num36 < minLength + 1; num36++) + for (int i = 0; i < minLength + 1; i++) { int lol; - if (num36 >= 0 && num36 < minLength) + if (i >= 0 && i < minLength) { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); } @@ -300,32 +300,32 @@ namespace CalamityMod.NPCs.DesertScourge } } - int num12 = (int)(NPC.position.X / 16f) - 1; - int num13 = (int)((NPC.position.X + (float)NPC.width) / 16f) + 2; - int num14 = (int)(NPC.position.Y / 16f) - 1; - int num15 = (int)((NPC.position.Y + (float)NPC.height) / 16f) + 2; - if (num12 < 0) + int tilePositionX = (int)(NPC.position.X / 16f) - 1; + int tileWidthPosX = (int)((NPC.position.X + (float)NPC.width) / 16f) + 2; + int tilePositionY = (int)(NPC.position.Y / 16f) - 1; + int tileWidthPosY = (int)((NPC.position.Y + (float)NPC.height) / 16f) + 2; + if (tilePositionX < 0) { - num12 = 0; + tilePositionX = 0; } - if (num13 > Main.maxTilesX) + if (tileWidthPosX > Main.maxTilesX) { - num13 = Main.maxTilesX; + tileWidthPosX = Main.maxTilesX; } - if (num14 < 0) + if (tilePositionY < 0) { - num14 = 0; + tilePositionY = 0; } - if (num15 > Main.maxTilesY) + if (tileWidthPosY > Main.maxTilesY) { - num15 = Main.maxTilesY; + tileWidthPosY = Main.maxTilesY; } - bool flag2 = lungeUpward; - if (!flag2) + bool shouldFly = lungeUpward; + if (!shouldFly) { - for (int k = num12; k < num13; k++) + for (int k = tilePositionX; k < tileWidthPosX; k++) { - for (int l = num14; l < num15; l++) + for (int l = tilePositionY; l < tileWidthPosY; l++) { if (Main.tile[k, l] != null && ((Main.tile[k, l].HasUnactuatedTile && (Main.tileSolid[(int)Main.tile[k, l].TileType] || (Main.tileSolidTop[(int)Main.tile[k, l].TileType] && Main.tile[k, l].TileFrameY == 0))) || Main.tile[k, l].LiquidAmount > 64)) { @@ -334,43 +334,43 @@ namespace CalamityMod.NPCs.DesertScourge vector2.Y = (float)(l * 16); if (NPC.position.X + (float)NPC.width > vector2.X && NPC.position.X < vector2.X + 16f && NPC.position.Y + (float)NPC.height > vector2.Y && NPC.position.Y < vector2.Y + 16f) { - flag2 = true; + shouldFly = true; break; } } } } } - if (!flag2) + if (!shouldFly) { NPC.localAI[1] = 1f; Rectangle rectangle = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); - int num954 = 1000; + int directChaseDistance = 1000; if (enrageScale > 0f) - num954 = 100; + directChaseDistance = 100; - bool flag3 = true; + bool shouldDirectlyChase = true; if (NPC.position.Y > player.position.Y) { - int rectWidth = num954 * 2; - int rectHeight = num954 * 2; + int rectWidth = directChaseDistance * 2; + int rectHeight = directChaseDistance * 2; for (int m = 0; m < 255; m++) { if (Main.player[m].active) { - int rectX = (int)Main.player[m].position.X - num954; - int rectY = (int)Main.player[m].position.Y - num954; - Rectangle rectangle13 = new Rectangle(rectX, rectY, rectWidth, rectHeight); - if (rectangle.Intersects(rectangle13)) + int rectX = (int)Main.player[m].position.X - directChaseDistance; + int rectY = (int)Main.player[m].position.Y - directChaseDistance; + Rectangle directChaseRect = new Rectangle(rectX, rectY, rectWidth, rectHeight); + if (rectangle.Intersects(directChaseRect)) { - flag3 = false; + shouldDirectlyChase = false; break; } } } - if (flag3) + if (shouldDirectlyChase) { - flag2 = true; + shouldFly = true; } } } @@ -379,15 +379,15 @@ namespace CalamityMod.NPCs.DesertScourge NPC.localAI[1] = 0f; } - float num17 = 16f; + float maxChaseSpeed = 16f; if (player.dead) { - flag2 = false; + shouldFly = false; NPC.velocity.Y += 1f; if ((double)NPC.position.Y > Main.worldSurface * 16.0) { NPC.velocity.Y += 1f; - num17 = 32f; + maxChaseSpeed = 32f; } if ((double)NPC.position.Y > Main.rockLayer * 16.0) { @@ -402,21 +402,21 @@ namespace CalamityMod.NPCs.DesertScourge } } - float num18 = speed; - float num19 = turnSpeed; + float speedCopy = speed; + float turnSpeedCopy = turnSpeed; float burrowDistance = bossRush ? 500f : 800f; float burrowTarget = player.Center.Y + burrowDistance; float lungeTarget = NPC.Calamity().newAI[3]; - Vector2 vector3 = NPC.Center; - float num20 = player.Center.X; - float num21 = lungeUpward ? lungeTarget : burrow ? burrowTarget : player.Center.Y; - num20 = (float)((int)(num20 / 16f) * 16); - num21 = (float)((int)(num21 / 16f) * 16); - vector3.X = (float)((int)(vector3.X / 16f) * 16); - vector3.Y = (float)((int)(vector3.Y / 16f) * 16); - num20 -= vector3.X; - num21 -= vector3.Y; - float num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); + Vector2 npcCenter = NPC.Center; + float playerX = player.Center.X; + float targettingPosition = lungeUpward ? lungeTarget : burrow ? burrowTarget : player.Center.Y; + playerX = (float)((int)(playerX / 16f) * 16); + targettingPosition = (float)((int)(targettingPosition / 16f) * 16); + npcCenter.X = (float)((int)(npcCenter.X / 16f) * 16); + npcCenter.Y = (float)((int)(npcCenter.Y / 16f) * 16); + playerX -= npcCenter.X; + targettingPosition -= npcCenter.Y; + float targetDistance = (float)Math.Sqrt((double)(playerX * playerX + targettingPosition * targettingPosition)); // Lunge up towards target if (burrow && NPC.Center.Y >= burrowTarget - 16f) @@ -481,45 +481,45 @@ namespace CalamityMod.NPCs.DesertScourge NPC.Calamity().newAI[1] = 0f; } - if (!flag2) + if (!shouldFly) { NPC.TargetClosest(); NPC.velocity.Y = NPC.velocity.Y + 0.15f; - if (NPC.velocity.Y > num17) + if (NPC.velocity.Y > maxChaseSpeed) { - NPC.velocity.Y = num17; + NPC.velocity.Y = maxChaseSpeed; } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)num17 * 0.4) + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)maxChaseSpeed * 0.4) { if (NPC.velocity.X < 0f) { - NPC.velocity.X = NPC.velocity.X - num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X - speedCopy * 1.1f; } else { - NPC.velocity.X = NPC.velocity.X + num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X + speedCopy * 1.1f; } } - else if (NPC.velocity.Y == num17) + else if (NPC.velocity.Y == maxChaseSpeed) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < playerX) { - NPC.velocity.X = NPC.velocity.X + num18; + NPC.velocity.X = NPC.velocity.X + speedCopy; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > playerX) { - NPC.velocity.X = NPC.velocity.X - num18; + NPC.velocity.X = NPC.velocity.X - speedCopy; } } else if (NPC.velocity.Y > 4f) { if (NPC.velocity.X < 0f) { - NPC.velocity.X = NPC.velocity.X + num18 * 0.9f; + NPC.velocity.X = NPC.velocity.X + speedCopy * 0.9f; } else { - NPC.velocity.X = NPC.velocity.X - num18 * 0.9f; + NPC.velocity.X = NPC.velocity.X - speedCopy * 0.9f; } } } @@ -527,131 +527,131 @@ namespace CalamityMod.NPCs.DesertScourge { if (NPC.soundDelay == 0) { - float num24 = num22 / 40f; - if (num24 < 10f) + float soundDelay = targetDistance / 40f; + if (soundDelay < 10f) { - num24 = 10f; + soundDelay = 10f; } - if (num24 > 20f) + if (soundDelay > 20f) { - num24 = 20f; + soundDelay = 20f; } - NPC.soundDelay = (int)num24; + NPC.soundDelay = (int)soundDelay; SoundEngine.PlaySound(SoundID.WormDig, NPC.Center); } - num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); - float num25 = Math.Abs(num20); - float num26 = Math.Abs(num21); - float num27 = num17 / num22; - num20 *= num27; - num21 *= num27; - if (((NPC.velocity.X > 0f && num20 > 0f) || (NPC.velocity.X < 0f && num20 < 0f)) && ((NPC.velocity.Y > 0f && num21 > 0f) || (NPC.velocity.Y < 0f && num21 < 0f))) + targetDistance = (float)Math.Sqrt((double)(playerX * playerX + targettingPosition * targettingPosition)); + float absolutePlayerX = Math.Abs(playerX); + float absoluteTargetPos = Math.Abs(targettingPosition); + float timeToReachTarget = maxChaseSpeed / targetDistance; + playerX *= timeToReachTarget; + targettingPosition *= timeToReachTarget; + if (((NPC.velocity.X > 0f && playerX > 0f) || (NPC.velocity.X < 0f && playerX < 0f)) && ((NPC.velocity.Y > 0f && targettingPosition > 0f) || (NPC.velocity.Y < 0f && targettingPosition < 0f))) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < playerX) { - NPC.velocity.X = NPC.velocity.X + num19; + NPC.velocity.X = NPC.velocity.X + turnSpeedCopy; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > playerX) { - NPC.velocity.X = NPC.velocity.X - num19; + NPC.velocity.X = NPC.velocity.X - turnSpeedCopy; } - if (NPC.velocity.Y < num21) + if (NPC.velocity.Y < targettingPosition) { - NPC.velocity.Y = NPC.velocity.Y + num19; + NPC.velocity.Y = NPC.velocity.Y + turnSpeedCopy; } - else if (NPC.velocity.Y > num21) + else if (NPC.velocity.Y > targettingPosition) { - NPC.velocity.Y = NPC.velocity.Y - num19; + NPC.velocity.Y = NPC.velocity.Y - turnSpeedCopy; } } - if ((NPC.velocity.X > 0f && num20 > 0f) || (NPC.velocity.X < 0f && num20 < 0f) || (NPC.velocity.Y > 0f && num21 > 0f) || (NPC.velocity.Y < 0f && num21 < 0f)) + if ((NPC.velocity.X > 0f && playerX > 0f) || (NPC.velocity.X < 0f && playerX < 0f) || (NPC.velocity.Y > 0f && targettingPosition > 0f) || (NPC.velocity.Y < 0f && targettingPosition < 0f)) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < playerX) { - NPC.velocity.X = NPC.velocity.X + num18; + NPC.velocity.X = NPC.velocity.X + speedCopy; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > playerX) { - NPC.velocity.X = NPC.velocity.X - num18; + NPC.velocity.X = NPC.velocity.X - speedCopy; } - if (NPC.velocity.Y < num21) + if (NPC.velocity.Y < targettingPosition) { - NPC.velocity.Y = NPC.velocity.Y + num18; + NPC.velocity.Y = NPC.velocity.Y + speedCopy; } - else if (NPC.velocity.Y > num21) + else if (NPC.velocity.Y > targettingPosition) { - NPC.velocity.Y = NPC.velocity.Y - num18; + NPC.velocity.Y = NPC.velocity.Y - speedCopy; } - if ((double)Math.Abs(num21) < (double)num17 * 0.2 && ((NPC.velocity.X > 0f && num20 < 0f) || (NPC.velocity.X < 0f && num20 > 0f))) + if ((double)Math.Abs(targettingPosition) < (double)maxChaseSpeed * 0.2 && ((NPC.velocity.X > 0f && playerX < 0f) || (NPC.velocity.X < 0f && playerX > 0f))) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num18 * 2f; + NPC.velocity.Y = NPC.velocity.Y + speedCopy * 2f; } else { - NPC.velocity.Y = NPC.velocity.Y - num18 * 2f; + NPC.velocity.Y = NPC.velocity.Y - speedCopy * 2f; } } - if ((double)Math.Abs(num20) < (double)num17 * 0.2 && ((NPC.velocity.Y > 0f && num21 < 0f) || (NPC.velocity.Y < 0f && num21 > 0f))) + if ((double)Math.Abs(playerX) < (double)maxChaseSpeed * 0.2 && ((NPC.velocity.Y > 0f && targettingPosition < 0f) || (NPC.velocity.Y < 0f && targettingPosition > 0f))) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num18 * 2f; + NPC.velocity.X = NPC.velocity.X + speedCopy * 2f; } else { - NPC.velocity.X = NPC.velocity.X - num18 * 2f; + NPC.velocity.X = NPC.velocity.X - speedCopy * 2f; } } } - else if (num25 > num26) + else if (absolutePlayerX > absoluteTargetPos) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < playerX) { - NPC.velocity.X = NPC.velocity.X + num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X + speedCopy * 1.1f; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > playerX) { - NPC.velocity.X = NPC.velocity.X - num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X - speedCopy * 1.1f; } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)num17 * 0.5) + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)maxChaseSpeed * 0.5) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num18; + NPC.velocity.Y = NPC.velocity.Y + speedCopy; } else { - NPC.velocity.Y = NPC.velocity.Y - num18; + NPC.velocity.Y = NPC.velocity.Y - speedCopy; } } } else { - if (NPC.velocity.Y < num21) + if (NPC.velocity.Y < targettingPosition) { - NPC.velocity.Y = NPC.velocity.Y + num18 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y + speedCopy * 1.1f; } - else if (NPC.velocity.Y > num21) + else if (NPC.velocity.Y > targettingPosition) { - NPC.velocity.Y = NPC.velocity.Y - num18 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y - speedCopy * 1.1f; } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)num17 * 0.5) + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)maxChaseSpeed * 0.5) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num18; + NPC.velocity.X = NPC.velocity.X + speedCopy; } else { - NPC.velocity.X = NPC.velocity.X - num18; + NPC.velocity.X = NPC.velocity.X - speedCopy; } } } } NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) + 1.57f; - if (flag2) + if (shouldFly) { if (NPC.localAI[0] != 1f) { @@ -726,10 +726,10 @@ namespace CalamityMod.NPCs.DesertScourge // Weapons and accessories int[] items = new int[] { - ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType() }; normalOnly.Add(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, items)); @@ -760,7 +760,7 @@ namespace CalamityMod.NPCs.DesertScourge npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB Sand Shark Tooth Necklace drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType()); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedDesertScourge, ModContent.ItemType(), desc: DropHelper.FirstKillText); diff --git a/NPCs/DesertScourge/DesertScourgeTail.cs b/NPCs/DesertScourge/DesertScourgeTail.cs index 606841f272..cf3751c621 100644 --- a/NPCs/DesertScourge/DesertScourgeTail.cs +++ b/NPCs/DesertScourge/DesertScourgeTail.cs @@ -108,40 +108,39 @@ namespace CalamityMod.NPCs.DesertScourge if (Main.player[NPC.target].dead) NPC.TargetClosest(false); - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentTilePos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float playerXPos = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float playerYPos = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + playerXPos = (float)((int)(playerXPos / 16f) * 16); + playerYPos = (float)((int)(playerYPos / 16f) * 16); + segmentTilePos.X = (float)((int)(segmentTilePos.X / 16f) * 16); + segmentTilePos.Y = (float)((int)(segmentTilePos.Y / 16f) * 16); + playerXPos -= segmentTilePos.X; + playerYPos -= segmentTilePos.Y; + float playerDistance = (float)System.Math.Sqrt((double)(playerXPos * playerXPos + playerYPos * playerYPos)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentTilePos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + playerXPos = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentTilePos.X; + playerYPos = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentTilePos.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)playerYPos, (double)playerXPos) + 1.57f; + playerDistance = (float)System.Math.Sqrt((double)(playerXPos * playerXPos + playerYPos * playerYPos)); + playerDistance = (playerDistance - (float)(NPC.width)) / playerDistance; + playerXPos *= playerDistance; + playerYPos *= playerDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + playerXPos; + NPC.position.Y = NPC.position.Y + playerYPos; - if (num191 < 0f) + if (playerXPos < 0f) NPC.spriteDirection = 1; - else if (num191 > 0f) + else if (playerXPos > 0f) NPC.spriteDirection = -1; } } diff --git a/NPCs/DevourerofGods/CosmicGuardianBody.cs b/NPCs/DevourerofGods/CosmicGuardianBody.cs index 953fa54f05..f9eda53cda 100644 --- a/NPCs/DevourerofGods/CosmicGuardianBody.cs +++ b/NPCs/DevourerofGods/CosmicGuardianBody.cs @@ -106,36 +106,36 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.Opacity = Main.npc[(int)NPC.ai[2]].Opacity; - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); + Vector2 segmentPosition = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); + float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); + targetX = (int)(targetX / 16f) * 16; + targetY = (int)(targetY / 16f) * 16; + segmentPosition.X = (int)(segmentPosition.X / 16f) * 16; + segmentPosition.Y = (int)(segmentPosition.Y / 16f) * 16; + targetX -= segmentPosition.X; + targetY -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + targetX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2(num192, num191) + 1.57f; - num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = NPC.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2(targetY, targetX) + 1.57f; + targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - segmentWidth) / targetDistance; + targetX *= targetDistance; + targetY *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetX; + NPC.position.Y = NPC.position.Y + targetY; } } @@ -146,17 +146,17 @@ namespace CalamityMod.NPCs.DevourerofGods spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/DevourerofGods/CosmicGuardianBodyGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + Color glowmaskColor = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -190,23 +190,23 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.height = 50; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int cosmiliteDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[cosmiliteDust].scale = 0.5f; + Main.dust[cosmiliteDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[cosmiliteDust2].noGravity = true; + Main.dust[cosmiliteDust2].velocity *= 5f; + cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust2].velocity *= 2f; } } } diff --git a/NPCs/DevourerofGods/CosmicGuardianHead.cs b/NPCs/DevourerofGods/CosmicGuardianHead.cs index 8158143871..24aa6058cd 100644 --- a/NPCs/DevourerofGods/CosmicGuardianHead.cs +++ b/NPCs/DevourerofGods/CosmicGuardianHead.cs @@ -24,7 +24,7 @@ namespace CalamityMod.NPCs.DevourerofGods public override void SetStaticDefaults() { NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.75f, PortraitScale = 0.75f, @@ -175,151 +175,151 @@ namespace CalamityMod.NPCs.DevourerofGods return; } - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num191 = Main.npc[CalamityGlobalNPC.DoGHead].position.X + (Main.npc[CalamityGlobalNPC.DoGHead].width / 2); - float num192 = Main.npc[CalamityGlobalNPC.DoGHead].position.Y + (Main.npc[CalamityGlobalNPC.DoGHead].height / 2); - float num188 = BossRushEvent.BossRushActive ? 30f : CalamityWorld.revenge ? 25f : 23f; - float num189 = BossRushEvent.BossRushActive ? 0.9f : CalamityWorld.revenge ? 0.75f : 0.23f; + Vector2 segmentDirection = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float dogHeadX = Main.npc[CalamityGlobalNPC.DoGHead].position.X + (Main.npc[CalamityGlobalNPC.DoGHead].width / 2); + float dogHeadY = Main.npc[CalamityGlobalNPC.DoGHead].position.Y + (Main.npc[CalamityGlobalNPC.DoGHead].height / 2); + float maxDistanceFromDoG = BossRushEvent.BossRushActive ? 30f : CalamityWorld.revenge ? 25f : 23f; + float velocityMult = BossRushEvent.BossRushActive ? 0.9f : CalamityWorld.revenge ? 0.75f : 0.23f; if (increaseSpeedMore) - num189 *= 4f; + velocityMult *= 4f; else if (increaseSpeed) - num189 *= 2f; + velocityMult *= 2f; - for (int num52 = 0; num52 < Main.maxNPCs; num52++) + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num52].active && (Main.npc[num52].type == NPC.type || Main.npc[num52].type == ModContent.NPCType()) && num52 != NPC.whoAmI) + if (Main.npc[i].active && (Main.npc[i].type == NPC.type || Main.npc[i].type == ModContent.NPCType()) && i != NPC.whoAmI) { - Vector2 vector4 = Main.npc[num52].Center - NPC.Center; - if (vector4.Length() < 400f) + Vector2 distFromHead = Main.npc[i].Center - NPC.Center; + if (distFromHead.Length() < 400f) { - vector4.Normalize(); - vector4 *= 400f; - num191 -= vector4.X; - num192 -= vector4.Y; + distFromHead.Normalize(); + distFromHead *= 400f; + dogHeadX -= distFromHead.X; + dogHeadY -= distFromHead.Y; } } } - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = NPC.velocity.Length(); - if (num50 > 0f) + float higherMaxDistance = maxDistanceFromDoG * 1.3f; + float lowerMaxDistance = maxDistanceFromDoG * 0.7f; + float npcSpeed = NPC.velocity.Length(); + if (npcSpeed > 0f) { - if (num50 > num48) + if (npcSpeed > higherMaxDistance) { NPC.velocity.Normalize(); - NPC.velocity *= num48; + NPC.velocity *= higherMaxDistance; } - else if (num50 < num49) + else if (npcSpeed < lowerMaxDistance) { NPC.velocity.Normalize(); - NPC.velocity *= num49; + NPC.velocity *= lowerMaxDistance; } } - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); - float num196 = Math.Abs(num191); - float num197 = Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; - if ((NPC.velocity.X > 0f && num191 > 0f) || (NPC.velocity.X < 0f && num191 < 0f) || (NPC.velocity.Y > 0f && num192 > 0f) || (NPC.velocity.Y < 0f && num192 < 0f)) + dogHeadX = (int)(dogHeadX / 16f) * 16; + dogHeadY = (int)(dogHeadY / 16f) * 16; + segmentDirection.X = (int)(segmentDirection.X / 16f) * 16; + segmentDirection.Y = (int)(segmentDirection.Y / 16f) * 16; + dogHeadX -= segmentDirection.X; + dogHeadY -= segmentDirection.Y; + float targetDistance = (float)Math.Sqrt(dogHeadX * dogHeadX + dogHeadY * dogHeadY); + float absoluteDoGX = Math.Abs(dogHeadX); + float absoluteDoGY = Math.Abs(dogHeadY); + float timeToReachTarget = maxDistanceFromDoG / targetDistance; + dogHeadX *= timeToReachTarget; + dogHeadY *= timeToReachTarget; + if ((NPC.velocity.X > 0f && dogHeadX > 0f) || (NPC.velocity.X < 0f && dogHeadX < 0f) || (NPC.velocity.Y > 0f && dogHeadY > 0f) || (NPC.velocity.Y < 0f && dogHeadY < 0f)) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < dogHeadX) { - NPC.velocity.X = NPC.velocity.X + num189; + NPC.velocity.X = NPC.velocity.X + velocityMult; } else { - if (NPC.velocity.X > num191) + if (NPC.velocity.X > dogHeadX) { - NPC.velocity.X = NPC.velocity.X - num189; + NPC.velocity.X = NPC.velocity.X - velocityMult; } } - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < dogHeadY) { - NPC.velocity.Y = NPC.velocity.Y + num189; + NPC.velocity.Y = NPC.velocity.Y + velocityMult; } else { - if (NPC.velocity.Y > num192) + if (NPC.velocity.Y > dogHeadY) { - NPC.velocity.Y = NPC.velocity.Y - num189; + NPC.velocity.Y = NPC.velocity.Y - velocityMult; } } - if (Math.Abs(num192) < num188 * 0.2 && ((NPC.velocity.X > 0f && num191 < 0f) || (NPC.velocity.X < 0f && num191 > 0f))) + if (Math.Abs(dogHeadY) < maxDistanceFromDoG * 0.2 && ((NPC.velocity.X > 0f && dogHeadX < 0f) || (NPC.velocity.X < 0f && dogHeadX > 0f))) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num189 * 2f; + NPC.velocity.Y = NPC.velocity.Y + velocityMult * 2f; } else { - NPC.velocity.Y = NPC.velocity.Y - num189 * 2f; + NPC.velocity.Y = NPC.velocity.Y - velocityMult * 2f; } } - if (Math.Abs(num191) < num188 * 0.2 && ((NPC.velocity.Y > 0f && num192 < 0f) || (NPC.velocity.Y < 0f && num192 > 0f))) + if (Math.Abs(dogHeadX) < maxDistanceFromDoG * 0.2 && ((NPC.velocity.Y > 0f && dogHeadY < 0f) || (NPC.velocity.Y < 0f && dogHeadY > 0f))) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num189 * 2f; //changed from 2 + NPC.velocity.X = NPC.velocity.X + velocityMult * 2f; //changed from 2 } else { - NPC.velocity.X = NPC.velocity.X - num189 * 2f; //changed from 2 + NPC.velocity.X = NPC.velocity.X - velocityMult * 2f; //changed from 2 } } } else { - if (num196 > num197) + if (absoluteDoGX > absoluteDoGY) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < dogHeadX) { - NPC.velocity.X = NPC.velocity.X + num189 * 1.1f; //changed from 1.1 + NPC.velocity.X = NPC.velocity.X + velocityMult * 1.1f; //changed from 1.1 } - else if (NPC.velocity.X > num191) + else if (NPC.velocity.X > dogHeadX) { - NPC.velocity.X = NPC.velocity.X - num189 * 1.1f; //changed from 1.1 + NPC.velocity.X = NPC.velocity.X - velocityMult * 1.1f; //changed from 1.1 } - if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < num188 * 0.5) + if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < maxDistanceFromDoG * 0.5) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num189; + NPC.velocity.Y = NPC.velocity.Y + velocityMult; } else { - NPC.velocity.Y = NPC.velocity.Y - num189; + NPC.velocity.Y = NPC.velocity.Y - velocityMult; } } } else { - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < dogHeadY) { - NPC.velocity.Y = NPC.velocity.Y + num189 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y + velocityMult * 1.1f; } - else if (NPC.velocity.Y > num192) + else if (NPC.velocity.Y > dogHeadY) { - NPC.velocity.Y = NPC.velocity.Y - num189 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y - velocityMult * 1.1f; } - if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < num188 * 0.5) + if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < maxDistanceFromDoG * 0.5) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num189; + NPC.velocity.X = NPC.velocity.X + velocityMult; } else { - NPC.velocity.X = NPC.velocity.X - num189; + NPC.velocity.X = NPC.velocity.X - velocityMult; } } } @@ -337,22 +337,22 @@ namespace CalamityMod.NPCs.DevourerofGods spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 distFromHead3 = NPC.Center - screenPos; + distFromHead3 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; + distFromHead3 += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, distFromHead3, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/DevourerofGods/CosmicGuardianHeadGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + Color glowmaskColor = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, distFromHead3, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/DevourerofGods/CosmicGuardianHeadGlow2").Value; - color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + glowmaskColor = Color.Lerp(Color.White, Color.Cyan, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, distFromHead3, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -395,23 +395,23 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.height = 50; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 15; num621++) + for (int i = 0; i < 15; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int cosmiliteDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[cosmiliteDust].scale = 0.5f; + Main.dust[cosmiliteDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[cosmiliteDust2].noGravity = true; + Main.dust[cosmiliteDust2].velocity *= 5f; + cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust2].velocity *= 2f; } } } diff --git a/NPCs/DevourerofGods/CosmicGuardianTail.cs b/NPCs/DevourerofGods/CosmicGuardianTail.cs index 5549188e1a..f7688b5818 100644 --- a/NPCs/DevourerofGods/CosmicGuardianTail.cs +++ b/NPCs/DevourerofGods/CosmicGuardianTail.cs @@ -103,36 +103,36 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.Opacity = Main.npc[(int)NPC.ai[2]].Opacity; - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); + Vector2 segmentPosition = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); + float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); + targetX = (int)(targetX / 16f) * 16; + targetY = (int)(targetY / 16f) * 16; + segmentPosition.X = (int)(segmentPosition.X / 16f) * 16; + segmentPosition.Y = (int)(segmentPosition.Y / 16f) * 16; + targetX -= segmentPosition.X; + targetY -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + targetX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2(num192, num191) + 1.57f; - num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = NPC.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2(targetY, targetX) + 1.57f; + targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - segmentWidth) / targetDistance; + targetX *= targetDistance; + targetY *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetX; + NPC.position.Y = NPC.position.Y + targetY; } } @@ -143,17 +143,17 @@ namespace CalamityMod.NPCs.DevourerofGods spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/DevourerofGods/CosmicGuardianTailGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + Color glowmaskColor = Color.Lerp(Color.White, Color.Cyan, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -182,23 +182,23 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.height = 50; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int cosmiliteDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[cosmiliteDust].scale = 0.5f; + Main.dust[cosmiliteDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[cosmiliteDust2].noGravity = true; + Main.dust[cosmiliteDust2].velocity *= 5f; + cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust2].velocity *= 2f; } } } diff --git a/NPCs/DevourerofGods/DevourerofGodsBody.cs b/NPCs/DevourerofGods/DevourerofGodsBody.cs index e1660807f8..4d138aa544 100644 --- a/NPCs/DevourerofGods/DevourerofGodsBody.cs +++ b/NPCs/DevourerofGods/DevourerofGodsBody.cs @@ -232,14 +232,13 @@ namespace CalamityMod.NPCs.DevourerofGods { NPC.TargetClosest(); SoundEngine.PlaySound(SoundID.Item12, player.Center); - float maxProjectileVelocity = bossRush ? 8f : death ? 7.5f : revenge ? 7.25f : expertMode ? 7f : 6.5f; + float maxProjectileVelocity = bossRush ? 24f : death ? 20f : revenge ? 18.25f : expertMode ? 17.5f : 16f; float minProjectileVelocity = maxProjectileVelocity * 0.25f; float projectileVelocity = MathHelper.Clamp(Vector2.Distance(player.Center, NPC.Center) * 0.01f, minProjectileVelocity, maxProjectileVelocity); Vector2 velocityVector = Vector2.Normalize(player.Center - NPC.Center) * projectileVelocity; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocityVector, type, damage, 0f, Main.myPlayer); - Main.projectile[proj].timeLeft = 1800; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocityVector, type, damage, 0f, Main.myPlayer); } } } @@ -258,14 +257,13 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.TargetClosest(); SoundEngine.PlaySound(SoundID.Item12, player.Center); NPC.localAI[0] = 0f; - float maxProjectileVelocity = bossRush ? 7.5f : death ? 7f : revenge ? 6.75f : expertMode ? 6.5f : 6f; + float maxProjectileVelocity = bossRush ? 22f : death ? 18f : revenge ? 16.25f : expertMode ? 15.5f : 14f; float minProjectileVelocity = maxProjectileVelocity * 0.25f; float projectileVelocity = MathHelper.Clamp(Vector2.Distance(player.Center, NPC.Center) * 0.01f, minProjectileVelocity, maxProjectileVelocity); Vector2 velocityVector = Vector2.Normalize(player.Center - NPC.Center) * projectileVelocity; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocityVector, type, damage, 0f, Main.myPlayer); - Main.projectile[proj].timeLeft = 1800; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocityVector, type, damage, 0f, Main.myPlayer); } } } @@ -367,27 +365,27 @@ namespace CalamityMod.NPCs.DevourerofGods bool useOtherTextures = phase2Started && Main.npc[(int)NPC.ai[2]].localAI[2] <= 60f; Texture2D texture2D15 = useOtherTextures ? ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodyS").Value : TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); + Vector2 halfSizeTexture = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); if (!NPC.dontTakeDamage) { if (useOtherTextures) { texture2D15 = ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodySGlow").Value; - Color color36 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + Color glowmaskColor = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color36, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } texture2D15 = useOtherTextures ? ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodySGlow2").Value : ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodyGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + Color glowmaskColor2 = Color.Lerp(Color.White, Color.Cyan, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor2, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } if (disintegrationFactor > 0f) @@ -402,18 +400,18 @@ namespace CalamityMod.NPCs.DevourerofGods Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= (phase2Started ? 55f : 40f) * NPC.scale && NPC.Opacity >= 1f && invinceTime <= 0; } @@ -480,23 +478,23 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.height = (int)(100 * NPC.scale); NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int cosmiliteDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[cosmiliteDust].scale = 0.5f; + Main.dust[cosmiliteDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[cosmiliteDust2].noGravity = true; + Main.dust[cosmiliteDust2].velocity *= 5f; + cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust2].velocity *= 2f; } } } diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index 1ae5cb3fec..aa673bc98f 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -61,7 +61,7 @@ namespace CalamityMod.NPCs.DevourerofGods } // Laser velocity - private const float laserVelocity = 2.333f; + private const float laserVelocity = 14f; // Phase 1 variables @@ -156,7 +156,7 @@ namespace CalamityMod.NPCs.DevourerofGods public override void SetStaticDefaults() { NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.6f, PortraitScale = 0.6f, @@ -1023,19 +1023,19 @@ namespace CalamityMod.NPCs.DevourerofGods } // Movement - int num180 = (int)(NPC.position.X / 16f) - 1; - int num181 = (int)((NPC.position.X + NPC.width) / 16f) + 2; - int num182 = (int)(NPC.position.Y / 16f) - 1; - int num183 = (int)((NPC.position.Y + NPC.height) / 16f) + 2; + int tilePositionX = (int)(NPC.position.X / 16f) - 1; + int tileWidthPosX = (int)((NPC.position.X + NPC.width) / 16f) + 2; + int tilePositionY = (int)(NPC.position.Y / 16f) - 1; + int tileWidthPosY = (int)((NPC.position.Y + NPC.height) / 16f) + 2; - if (num180 < 0) - num180 = 0; - if (num181 > Main.maxTilesX) - num181 = Main.maxTilesX; - if (num182 < 0) - num182 = 0; - if (num183 > Main.maxTilesY) - num183 = Main.maxTilesY; + if (tilePositionX < 0) + tilePositionX = 0; + if (tileWidthPosX > Main.maxTilesX) + tileWidthPosX = Main.maxTilesX; + if (tilePositionY < 0) + tilePositionY = 0; + if (tileWidthPosY > Main.maxTilesY) + tileWidthPosY = Main.maxTilesY; if (NPC.velocity.X < 0f) NPC.spriteDirection = -1; @@ -1073,160 +1073,160 @@ namespace CalamityMod.NPCs.DevourerofGods else calamityGlobalNPC.newAI[2] += 2f; - float num188 = speed; - float num189 = turnSpeed; - Vector2 vector18 = NPC.Center; - float num191 = destination.X; - float num192 = destination.Y; - int num42 = -1; - int num43 = (int)(destination.X / 16f); - int num44 = (int)(destination.Y / 16f); + float speedCopy = speed; + float turnSpeedCopy = turnSpeed; + Vector2 npcCenter = NPC.Center; + float targetX = destination.X; + float targetY = destination.Y; + int flyYLevel = -1; + int destinationTileX = (int)(destination.X / 16f); + int destinationTileY = (int)(destination.Y / 16f); // Charge at target for 1.5 seconds bool flyAtTarget = (!phase4 || spawnedGuardians3) && calamityGlobalNPC.newAI[2] > phaseLimit - 90 && revenge; - for (int num45 = num43 - 2; num45 <= num43 + 2; num45++) + for (int i = destinationTileX - 2; i <= destinationTileX + 2; i++) { - for (int num46 = num44; num46 <= num44 + 15; num46++) + for (int j = destinationTileY; j <= destinationTileY + 15; j++) { - if (WorldGen.SolidTile2(num45, num46)) + if (WorldGen.SolidTile2(i, j)) { - num42 = num46; + flyYLevel = j; break; } } - if (num42 > 0) + if (flyYLevel > 0) break; } if (!flyAtTarget && destination == player.Center) { - if (num42 > 0) + if (flyYLevel > 0) { - num42 *= 16; - float num47 = num42 - 800; - if (player.position.Y > num47) + flyYLevel *= 16; + float chaseFlyLevel = flyYLevel - 800; + if (player.position.Y > chaseFlyLevel) { - num192 = num47; + targetY = chaseFlyLevel; if (Math.Abs(NPC.Center.X - destination.X) < 500f) { if (NPC.velocity.X > 0f) - num191 = destination.X + 600f; + targetX = destination.X + 600f; else - num191 = destination.X - 600f; + targetX = destination.X - 600f; } } } } else { - num188 = homingSpeed; - num189 = homingTurnSpeed; + speedCopy = homingSpeed; + turnSpeedCopy = homingTurnSpeed; } - num188 += Vector2.Distance(destination, NPC.Center) * 0.005f; - num189 += Vector2.Distance(destination, NPC.Center) * 0.00025f; + speedCopy += Vector2.Distance(destination, NPC.Center) * 0.005f; + turnSpeedCopy += Vector2.Distance(destination, NPC.Center) * 0.00025f; if (CalamityWorld.LegendaryMode && revenge) { if (NPC.SafeDirectionTo(player.Center).AngleBetween((NPC.rotation - MathHelper.PiOver2).ToRotationVector2()) < MathHelper.ToRadians(10f)) - num188 *= 2f; + speedCopy *= 2f; } - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = NPC.velocity.Length(); - if (num50 > 0f) + float fasterSpeedMult = speedCopy * 1.3f; + float slowerSpeedMult = speedCopy * 0.7f; + float npcSpeed = NPC.velocity.Length(); + if (npcSpeed > 0f) { - if (num50 > num48) + if (npcSpeed > fasterSpeedMult) { NPC.velocity.Normalize(); - NPC.velocity *= num48; + NPC.velocity *= fasterSpeedMult; } - else if (num50 < num49) + else if (npcSpeed < slowerSpeedMult) { NPC.velocity.Normalize(); - NPC.velocity *= num49; + NPC.velocity *= slowerSpeedMult; } } - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); - float num196 = Math.Abs(num191); - float num197 = Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; + targetX = (int)(targetX / 16f) * 16; + targetY = (int)(targetY / 16f) * 16; + npcCenter.X = (int)(npcCenter.X / 16f) * 16; + npcCenter.Y = (int)(npcCenter.Y / 16f) * 16; + targetX -= npcCenter.X; + targetY -= npcCenter.Y; + float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); + float absoluteTargetX = Math.Abs(targetX); + float absoluteTargetY = Math.Abs(targetY); + float timeToReachTarget = speedCopy / targetDistance; + targetX *= timeToReachTarget; + targetY *= timeToReachTarget; - if ((NPC.velocity.X > 0f && num191 > 0f) || (NPC.velocity.X < 0f && num191 < 0f) || (NPC.velocity.Y > 0f && num192 > 0f) || (NPC.velocity.Y < 0f && num192 < 0f)) + if ((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f) || (NPC.velocity.Y > 0f && targetY > 0f) || (NPC.velocity.Y < 0f && targetY < 0f)) { - if (NPC.velocity.X < num191) - NPC.velocity.X += num189; + if (NPC.velocity.X < targetX) + NPC.velocity.X += turnSpeedCopy; else { - if (NPC.velocity.X > num191) - NPC.velocity.X -= num189; + if (NPC.velocity.X > targetX) + NPC.velocity.X -= turnSpeedCopy; } - if (NPC.velocity.Y < num192) - NPC.velocity.Y += num189; + if (NPC.velocity.Y < targetY) + NPC.velocity.Y += turnSpeedCopy; else { - if (NPC.velocity.Y > num192) - NPC.velocity.Y -= num189; + if (NPC.velocity.Y > targetY) + NPC.velocity.Y -= turnSpeedCopy; } - if (Math.Abs(num192) < num188 * 0.2 && ((NPC.velocity.X > 0f && num191 < 0f) || (NPC.velocity.X < 0f && num191 > 0f))) + if (Math.Abs(targetY) < speedCopy * 0.2 && ((NPC.velocity.X > 0f && targetX < 0f) || (NPC.velocity.X < 0f && targetX > 0f))) { if (NPC.velocity.Y > 0f) - NPC.velocity.Y += num189 * 2f; + NPC.velocity.Y += turnSpeedCopy * 2f; else - NPC.velocity.Y -= num189 * 2f; + NPC.velocity.Y -= turnSpeedCopy * 2f; } - if (Math.Abs(num191) < num188 * 0.2 && ((NPC.velocity.Y > 0f && num192 < 0f) || (NPC.velocity.Y < 0f && num192 > 0f))) + if (Math.Abs(targetX) < speedCopy * 0.2 && ((NPC.velocity.Y > 0f && targetY < 0f) || (NPC.velocity.Y < 0f && targetY > 0f))) { if (NPC.velocity.X > 0f) - NPC.velocity.X += num189 * 2f; + NPC.velocity.X += turnSpeedCopy * 2f; else - NPC.velocity.X -= num189 * 2f; + NPC.velocity.X -= turnSpeedCopy * 2f; } } else { - if (num196 > num197) + if (absoluteTargetX > absoluteTargetY) { - if (NPC.velocity.X < num191) - NPC.velocity.X += num189 * 1.1f; - else if (NPC.velocity.X > num191) - NPC.velocity.X -= num189 * 1.1f; + if (NPC.velocity.X < targetX) + NPC.velocity.X += turnSpeedCopy * 1.1f; + else if (NPC.velocity.X > targetX) + NPC.velocity.X -= turnSpeedCopy * 1.1f; - if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < num188 * 0.5) + if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < speedCopy * 0.5) { if (NPC.velocity.Y > 0f) - NPC.velocity.Y += num189; + NPC.velocity.Y += turnSpeedCopy; else - NPC.velocity.Y -= num189; + NPC.velocity.Y -= turnSpeedCopy; } } else { - if (NPC.velocity.Y < num192) - NPC.velocity.Y += num189 * 1.1f; - else if (NPC.velocity.Y > num192) - NPC.velocity.Y -= num189 * 1.1f; + if (NPC.velocity.Y < targetY) + NPC.velocity.Y += turnSpeedCopy * 1.1f; + else if (NPC.velocity.Y > targetY) + NPC.velocity.Y -= turnSpeedCopy * 1.1f; - if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < num188 * 0.5) + if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < speedCopy * 0.5) { if (NPC.velocity.X > 0f) - NPC.velocity.X += num189; + NPC.velocity.X += turnSpeedCopy; else - NPC.velocity.X -= num189; + NPC.velocity.X -= turnSpeedCopy; } } } @@ -1296,16 +1296,16 @@ namespace CalamityMod.NPCs.DevourerofGods if (!flies) { - for (int num952 = num180; num952 < num181; num952++) + for (int r = tilePositionX; r < tileWidthPosX; r++) { - for (int num953 = num182; num953 < num183; num953++) + for (int s = tilePositionY; s < tileWidthPosY; s++) { - if (Main.tile[num952, num953] != null && ((Main.tile[num952, num953].HasUnactuatedTile && (Main.tileSolid[Main.tile[num952, num953].TileType] || (Main.tileSolidTop[Main.tile[num952, num953].TileType] && Main.tile[num952, num953].TileFrameY == 0))) || Main.tile[num952, num953].LiquidAmount > 64)) + if (Main.tile[r, s] != null && ((Main.tile[r, s].HasUnactuatedTile && (Main.tileSolid[Main.tile[r, s].TileType] || (Main.tileSolidTop[Main.tile[r, s].TileType] && Main.tile[r, s].TileFrameY == 0))) || Main.tile[r, s].LiquidAmount > 64)) { - Vector2 vector105; - vector105.X = num952 * 16; - vector105.Y = num953 * 16; - if (NPC.position.X + NPC.width > vector105.X && NPC.position.X < vector105.X + 16f && NPC.position.Y + NPC.height > vector105.Y && NPC.position.Y < vector105.Y + 16f) + Vector2 positionCheck; + positionCheck.X = r * 16; + positionCheck.Y = s * 16; + if (NPC.position.X + NPC.width > positionCheck.X && NPC.position.X < positionCheck.X + 16f && NPC.position.Y + NPC.height > positionCheck.Y && NPC.position.Y < positionCheck.Y + 16f) { flies = true; break; @@ -1321,46 +1321,46 @@ namespace CalamityMod.NPCs.DevourerofGods Rectangle rectangle12 = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); - int num954 = death ? 1125 : 1200; + int directChargeRange = death ? 1125 : 1200; if (expertMode) - num954 -= (int)(150f * (1f - lifeRatio)); + directChargeRange -= (int)(150f * (1f - lifeRatio)); - if (num954 < 1050) - num954 = 1050; + if (directChargeRange < 1050) + directChargeRange = 1050; - bool flag95 = true; + bool canDirectlyCharge = true; if (NPC.position.Y > player.position.Y) { - for (int num955 = 0; num955 < Main.maxPlayers; num955++) + for (int k = 0; k < Main.maxPlayers; k++) { - if (Main.player[num955].active) + if (Main.player[k].active) { - Rectangle rectangle13 = new Rectangle((int)Main.player[num955].position.X - 1000, (int)Main.player[num955].position.Y - 1000, 2000, num954); + Rectangle rectangle13 = new Rectangle((int)Main.player[k].position.X - 1000, (int)Main.player[k].position.Y - 1000, 2000, directChargeRange); if (rectangle12.Intersects(rectangle13)) { - flag95 = false; + canDirectlyCharge = false; break; } } } - if (flag95) + if (canDirectlyCharge) flies = true; } } else NPC.localAI[1] = 0f; - float num189 = groundPhaseTurnSpeed; - Vector2 vector18 = NPC.Center; - float num191 = destination.X; - float num192 = destination.Y; - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; + float turnSpeedCopy = groundPhaseTurnSpeed; + Vector2 npcCenter = NPC.Center; + float targetX = destination.X; + float targetY = destination.Y; + targetX = (int)(targetX / 16f) * 16; + targetY = (int)(targetY / 16f) * 16; + npcCenter.X = (int)(npcCenter.X / 16f) * 16; + npcCenter.Y = (int)(npcCenter.Y / 16f) * 16; + targetX -= npcCenter.X; + targetY -= npcCenter.Y; if (!flies) { @@ -1371,23 +1371,23 @@ namespace CalamityMod.NPCs.DevourerofGods if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < fallSpeed * 2.2) { if (NPC.velocity.X < 0f) - NPC.velocity.X -= num189 * 1.1f; + NPC.velocity.X -= turnSpeedCopy * 1.1f; else - NPC.velocity.X += num189 * 1.1f; + NPC.velocity.X += turnSpeedCopy * 1.1f; } else if (NPC.velocity.Y == fallSpeed) { - if (NPC.velocity.X < num191) - NPC.velocity.X += num189; - else if (NPC.velocity.X > num191) - NPC.velocity.X -= num189; + if (NPC.velocity.X < targetX) + NPC.velocity.X += turnSpeedCopy; + else if (NPC.velocity.X > targetX) + NPC.velocity.X -= turnSpeedCopy; } else if (NPC.velocity.Y > 4f) { if (NPC.velocity.X < 0f) - NPC.velocity.X += num189 * 0.9f; + NPC.velocity.X += turnSpeedCopy * 0.9f; else - NPC.velocity.X -= num189 * 0.9f; + NPC.velocity.X -= turnSpeedCopy * 0.9f; } } else @@ -1401,39 +1401,39 @@ namespace CalamityMod.NPCs.DevourerofGods maximumSpeed2 += 0.2f * (1f - lifeRatio); } - float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); - float num25 = Math.Abs(num191); - float num26 = Math.Abs(num192); - float num27 = fallSpeed / num193; - num191 *= num27; - num192 *= num27; + float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); + float absoluteTargetX2 = Math.Abs(targetX); + float absoluteTargetY2 = Math.Abs(targetY); + float timeToReachTarget2 = fallSpeed / targetDistance; + targetX *= timeToReachTarget2; + targetY *= timeToReachTarget2; - if (((NPC.velocity.X > 0f && num191 > 0f) || (NPC.velocity.X < 0f && num191 < 0f)) && ((NPC.velocity.Y > 0f && num192 > 0f) || (NPC.velocity.Y < 0f && num192 < 0f))) + if (((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f)) && ((NPC.velocity.Y > 0f && targetY > 0f) || (NPC.velocity.Y < 0f && targetY < 0f))) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetX) NPC.velocity.X += groundPhaseTurnSpeed * 1.5f; - else if (NPC.velocity.X > num191) + else if (NPC.velocity.X > targetX) NPC.velocity.X -= groundPhaseTurnSpeed * 1.5f; - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetY) NPC.velocity.Y += groundPhaseTurnSpeed * 1.5f; - else if (NPC.velocity.Y > num192) + else if (NPC.velocity.Y > targetY) NPC.velocity.Y -= groundPhaseTurnSpeed * 1.5f; } - if ((NPC.velocity.X > 0f && num191 > 0f) || (NPC.velocity.X < 0f && num191 < 0f) || (NPC.velocity.Y > 0f && num192 > 0f) || (NPC.velocity.Y < 0f && num192 < 0f)) + if ((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f) || (NPC.velocity.Y > 0f && targetY > 0f) || (NPC.velocity.Y < 0f && targetY < 0f)) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetX) NPC.velocity.X += groundPhaseTurnSpeed; - else if (NPC.velocity.X > num191) + else if (NPC.velocity.X > targetX) NPC.velocity.X -= groundPhaseTurnSpeed; - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetY) NPC.velocity.Y += groundPhaseTurnSpeed; - else if (NPC.velocity.Y > num192) + else if (NPC.velocity.Y > targetY) NPC.velocity.Y -= groundPhaseTurnSpeed; - if (Math.Abs(num192) < fallSpeed * maximumSpeed1 && ((NPC.velocity.X > 0f && num191 < 0f) || (NPC.velocity.X < 0f && num191 > 0f))) + if (Math.Abs(targetY) < fallSpeed * maximumSpeed1 && ((NPC.velocity.X > 0f && targetX < 0f) || (NPC.velocity.X < 0f && targetX > 0f))) { if (NPC.velocity.Y > 0f) NPC.velocity.Y += groundPhaseTurnSpeed * 2f; @@ -1441,7 +1441,7 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.velocity.Y -= groundPhaseTurnSpeed * 2f; } - if (Math.Abs(num191) < fallSpeed * maximumSpeed1 && ((NPC.velocity.Y > 0f && num192 < 0f) || (NPC.velocity.Y < 0f && num192 > 0f))) + if (Math.Abs(targetX) < fallSpeed * maximumSpeed1 && ((NPC.velocity.Y > 0f && targetY < 0f) || (NPC.velocity.Y < 0f && targetY > 0f))) { if (NPC.velocity.X > 0f) NPC.velocity.X += groundPhaseTurnSpeed * 2f; @@ -1449,11 +1449,11 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.velocity.X -= groundPhaseTurnSpeed * 2f; } } - else if (num25 > num26) + else if (absoluteTargetX2 > absoluteTargetY2) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetX) NPC.velocity.X += groundPhaseTurnSpeed * 1.1f; - else if (NPC.velocity.X > num191) + else if (NPC.velocity.X > targetX) NPC.velocity.X -= groundPhaseTurnSpeed * 1.1f; if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < fallSpeed * maximumSpeed2) @@ -1466,9 +1466,9 @@ namespace CalamityMod.NPCs.DevourerofGods } else { - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetY) NPC.velocity.Y += groundPhaseTurnSpeed * 1.1f; - else if (NPC.velocity.Y > num192) + else if (NPC.velocity.Y > targetY) NPC.velocity.Y -= groundPhaseTurnSpeed * 1.1f; if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < fallSpeed * maximumSpeed2) @@ -1813,19 +1813,19 @@ namespace CalamityMod.NPCs.DevourerofGods } // Movement - int num180 = (int)(NPC.position.X / 16f) - 1; - int num181 = (int)((NPC.position.X + NPC.width) / 16f) + 2; - int num182 = (int)(NPC.position.Y / 16f) - 1; - int num183 = (int)((NPC.position.Y + NPC.height) / 16f) + 2; + int tilePositionX = (int)(NPC.position.X / 16f) - 1; + int tileWidthPosX = (int)((NPC.position.X + NPC.width) / 16f) + 2; + int tilePositionY = (int)(NPC.position.Y / 16f) - 1; + int tileWidthPosY = (int)((NPC.position.Y + NPC.height) / 16f) + 2; - if (num180 < 0) - num180 = 0; - if (num181 > Main.maxTilesX) - num181 = Main.maxTilesX; - if (num182 < 0) - num182 = 0; - if (num183 > Main.maxTilesY) - num183 = Main.maxTilesY; + if (tilePositionX < 0) + tilePositionX = 0; + if (tileWidthPosX > Main.maxTilesX) + tileWidthPosX = Main.maxTilesX; + if (tilePositionY < 0) + tilePositionY = 0; + if (tileWidthPosY > Main.maxTilesY) + tileWidthPosY = Main.maxTilesY; if (NPC.velocity.X < 0f) NPC.spriteDirection = -1; @@ -1852,157 +1852,157 @@ namespace CalamityMod.NPCs.DevourerofGods else if (increaseSpeed) calamityGlobalNPC.newAI[2] += 2f; - float num188 = speed; - float num189 = turnSpeed; - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num191 = player.position.X + (player.width / 2); - float num192 = player.position.Y + (player.height / 2); - int num42 = -1; - int num43 = (int)(destination.X / 16f); - int num44 = (int)(destination.Y / 16f); + float speedCopy = speed; + float turnSpeedCopy = turnSpeed; + Vector2 npcCenter = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float targetX = player.position.X + (player.width / 2); + float targetY = player.position.Y + (player.height / 2); + int flyYLevel = -1; + int destinationTileX = (int)(destination.X / 16f); + int destinationTileY = (int)(destination.Y / 16f); - for (int num45 = num43 - 2; num45 <= num43 + 2; num45++) + for (int i = destinationTileX - 2; i <= destinationTileX + 2; i++) { - for (int num46 = num44; num46 <= num44 + 15; num46++) + for (int j = destinationTileY; j <= destinationTileY + 15; j++) { - if (WorldGen.SolidTile2(num45, num46)) + if (WorldGen.SolidTile2(i, j)) { - num42 = num46; + flyYLevel = j; break; } } - if (num42 > 0) + if (flyYLevel > 0) break; } - if (num42 > 0) + if (flyYLevel > 0) { - num42 *= 16; - float num47 = num42 - 800; - if (player.position.Y > num47) + flyYLevel *= 16; + float chaseFlyLevel = flyYLevel - 800; + if (player.position.Y > chaseFlyLevel) { - num192 = num47; + targetY = chaseFlyLevel; if (Math.Abs(NPC.Center.X - destination.X) < 500f) { if (NPC.velocity.X > 0f) - num191 = destination.X + 600f; + targetX = destination.X + 600f; else - num191 = destination.X - 600f; + targetX = destination.X - 600f; } } } else { - num188 = homingSpeed; - num189 = homingTurnSpeed; + speedCopy = homingSpeed; + turnSpeedCopy = homingTurnSpeed; } if (expertMode) { - num188 += distanceFromTarget * 0.005f * (1f - lifeRatio); - num189 += distanceFromTarget * 0.0001f * (1f - lifeRatio); + speedCopy += distanceFromTarget * 0.005f * (1f - lifeRatio); + turnSpeedCopy += distanceFromTarget * 0.0001f * (1f - lifeRatio); } if (CalamityWorld.LegendaryMode && revenge) { if (NPC.SafeDirectionTo(player.Center).AngleBetween((NPC.rotation - MathHelper.PiOver2).ToRotationVector2()) < MathHelper.ToRadians(10f)) - num188 *= 2f; + speedCopy *= 2f; } - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = NPC.velocity.Length(); - if (num50 > 0f) + float fasterSpeedMult = speedCopy * 1.3f; + float slowerSpeedMult = speedCopy * 0.7f; + float npcSpeed = NPC.velocity.Length(); + if (npcSpeed > 0f) { - if (num50 > num48) + if (npcSpeed > fasterSpeedMult) { NPC.velocity.Normalize(); - NPC.velocity *= num48; + NPC.velocity *= fasterSpeedMult; } - else if (num50 < num49) + else if (npcSpeed < slowerSpeedMult) { NPC.velocity.Normalize(); - NPC.velocity *= num49; + NPC.velocity *= slowerSpeedMult; } } - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); - float num196 = Math.Abs(num191); - float num197 = Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; + targetX = (int)(targetX / 16f) * 16; + targetY = (int)(targetY / 16f) * 16; + npcCenter.X = (int)(npcCenter.X / 16f) * 16; + npcCenter.Y = (int)(npcCenter.Y / 16f) * 16; + targetX -= npcCenter.X; + targetY -= npcCenter.Y; + float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); + float absoluteTargetX = Math.Abs(targetX); + float absoluteTargetY = Math.Abs(targetY); + float timeToReachTarget = speedCopy / targetDistance; + targetX *= timeToReachTarget; + targetY *= timeToReachTarget; - if ((NPC.velocity.X > 0f && num191 > 0f) || (NPC.velocity.X < 0f && num191 < 0f) || (NPC.velocity.Y > 0f && num192 > 0f) || (NPC.velocity.Y < 0f && num192 < 0f)) + if ((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f) || (NPC.velocity.Y > 0f && targetY > 0f) || (NPC.velocity.Y < 0f && targetY < 0f)) { - if (NPC.velocity.X < num191) - NPC.velocity.X += num189; + if (NPC.velocity.X < targetX) + NPC.velocity.X += turnSpeedCopy; else { - if (NPC.velocity.X > num191) - NPC.velocity.X -= num189; + if (NPC.velocity.X > targetX) + NPC.velocity.X -= turnSpeedCopy; } - if (NPC.velocity.Y < num192) - NPC.velocity.Y += num189; + if (NPC.velocity.Y < targetY) + NPC.velocity.Y += turnSpeedCopy; else { - if (NPC.velocity.Y > num192) - NPC.velocity.Y -= num189; + if (NPC.velocity.Y > targetY) + NPC.velocity.Y -= turnSpeedCopy; } - if (Math.Abs(num192) < num188 * 0.2 && ((NPC.velocity.X > 0f && num191 < 0f) || (NPC.velocity.X < 0f && num191 > 0f))) + if (Math.Abs(targetY) < speedCopy * 0.2 && ((NPC.velocity.X > 0f && targetX < 0f) || (NPC.velocity.X < 0f && targetX > 0f))) { if (NPC.velocity.Y > 0f) - NPC.velocity.Y += num189 * 2f; + NPC.velocity.Y += turnSpeedCopy * 2f; else - NPC.velocity.Y -= num189 * 2f; + NPC.velocity.Y -= turnSpeedCopy * 2f; } - if (Math.Abs(num191) < num188 * 0.2 && ((NPC.velocity.Y > 0f && num192 < 0f) || (NPC.velocity.Y < 0f && num192 > 0f))) + if (Math.Abs(targetX) < speedCopy * 0.2 && ((NPC.velocity.Y > 0f && targetY < 0f) || (NPC.velocity.Y < 0f && targetY > 0f))) { if (NPC.velocity.X > 0f) - NPC.velocity.X += num189 * 2f; + NPC.velocity.X += turnSpeedCopy * 2f; else - NPC.velocity.X -= num189 * 2f; + NPC.velocity.X -= turnSpeedCopy * 2f; } } else { - if (num196 > num197) + if (absoluteTargetX > absoluteTargetY) { - if (NPC.velocity.X < num191) - NPC.velocity.X += num189 * 1.1f; - else if (NPC.velocity.X > num191) - NPC.velocity.X -= num189 * 1.1f; + if (NPC.velocity.X < targetX) + NPC.velocity.X += turnSpeedCopy * 1.1f; + else if (NPC.velocity.X > targetX) + NPC.velocity.X -= turnSpeedCopy * 1.1f; - if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < num188 * 0.5) + if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < speedCopy * 0.5) { if (NPC.velocity.Y > 0f) - NPC.velocity.Y += num189; + NPC.velocity.Y += turnSpeedCopy; else - NPC.velocity.Y -= num189; + NPC.velocity.Y -= turnSpeedCopy; } } else { - if (NPC.velocity.Y < num192) - NPC.velocity.Y += num189 * 1.1f; - else if (NPC.velocity.Y > num192) - NPC.velocity.Y -= num189 * 1.1f; + if (NPC.velocity.Y < targetY) + NPC.velocity.Y += turnSpeedCopy * 1.1f; + else if (NPC.velocity.Y > targetY) + NPC.velocity.Y -= turnSpeedCopy * 1.1f; - if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < num188 * 0.5) + if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < speedCopy * 0.5) { if (NPC.velocity.X > 0f) - NPC.velocity.X += num189; + NPC.velocity.X += turnSpeedCopy; else - NPC.velocity.X -= num189; + NPC.velocity.X -= turnSpeedCopy; } } } @@ -2060,16 +2060,16 @@ namespace CalamityMod.NPCs.DevourerofGods if (!flies) { - for (int num952 = num180; num952 < num181; num952++) + for (int r = tilePositionX; r < tileWidthPosX; r++) { - for (int num953 = num182; num953 < num183; num953++) + for (int s = tilePositionY; s < tileWidthPosY; s++) { - if (Main.tile[num952, num953] != null && ((Main.tile[num952, num953].HasUnactuatedTile && (Main.tileSolid[Main.tile[num952, num953].TileType] || (Main.tileSolidTop[Main.tile[num952, num953].TileType] && Main.tile[num952, num953].TileFrameY == 0))) || Main.tile[num952, num953].LiquidAmount > 64)) + if (Main.tile[r, s] != null && ((Main.tile[r, s].HasUnactuatedTile && (Main.tileSolid[Main.tile[r, s].TileType] || (Main.tileSolidTop[Main.tile[r, s].TileType] && Main.tile[r, s].TileFrameY == 0))) || Main.tile[r, s].LiquidAmount > 64)) { - Vector2 vector105; - vector105.X = num952 * 16; - vector105.Y = num953 * 16; - if (NPC.position.X + NPC.width > vector105.X && NPC.position.X < vector105.X + 16f && NPC.position.Y + NPC.height > vector105.Y && NPC.position.Y < vector105.Y + 16f) + Vector2 positionCheck; + positionCheck.X = r * 16; + positionCheck.Y = s * 16; + if (NPC.position.X + NPC.width > positionCheck.X && NPC.position.X < positionCheck.X + 16f && NPC.position.Y + NPC.height > positionCheck.Y && NPC.position.Y < positionCheck.Y + 16f) { flies = true; break; @@ -2085,46 +2085,46 @@ namespace CalamityMod.NPCs.DevourerofGods Rectangle rectangle12 = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); - int num954 = death ? 1125 : 1200; + int directChargeRange = death ? 1125 : 1200; if (expertMode) - num954 -= (int)(150f * (1f - lifeRatio)); + directChargeRange -= (int)(150f * (1f - lifeRatio)); - if (num954 < 1050) - num954 = 1050; + if (directChargeRange < 1050) + directChargeRange = 1050; - bool flag95 = true; + bool canDirectlyCharge = true; if (NPC.position.Y > player.position.Y) { - for (int num955 = 0; num955 < 255; num955++) + for (int k = 0; k < 255; k++) { - if (Main.player[num955].active) + if (Main.player[k].active) { - Rectangle rectangle13 = new Rectangle((int)Main.player[num955].position.X - 1000, (int)Main.player[num955].position.Y - 1000, 2000, num954); + Rectangle rectangle13 = new Rectangle((int)Main.player[k].position.X - 1000, (int)Main.player[k].position.Y - 1000, 2000, directChargeRange); if (rectangle12.Intersects(rectangle13)) { - flag95 = false; + canDirectlyCharge = false; break; } } } - if (flag95) + if (canDirectlyCharge) flies = true; } } else NPC.localAI[1] = 0f; - float num189 = groundPhaseTurnSpeed; - Vector2 vector18 = NPC.Center; - float num191 = destination.X; - float num192 = destination.Y; - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; + float turnSpeedCopy = groundPhaseTurnSpeed; + Vector2 npcCenter = NPC.Center; + float targetX = destination.X; + float targetY = destination.Y; + targetX = (int)(targetX / 16f) * 16; + targetY = (int)(targetY / 16f) * 16; + npcCenter.X = (int)(npcCenter.X / 16f) * 16; + npcCenter.Y = (int)(npcCenter.Y / 16f) * 16; + targetX -= npcCenter.X; + targetY -= npcCenter.Y; if (!flies) { @@ -2135,23 +2135,23 @@ namespace CalamityMod.NPCs.DevourerofGods if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < fallSpeed * 2.2) { if (NPC.velocity.X < 0f) - NPC.velocity.X -= num189 * 1.1f; + NPC.velocity.X -= turnSpeedCopy * 1.1f; else - NPC.velocity.X += num189 * 1.1f; + NPC.velocity.X += turnSpeedCopy * 1.1f; } else if (NPC.velocity.Y == fallSpeed) { - if (NPC.velocity.X < num191) - NPC.velocity.X += num189; - else if (NPC.velocity.X > num191) - NPC.velocity.X -= num189; + if (NPC.velocity.X < targetX) + NPC.velocity.X += turnSpeedCopy; + else if (NPC.velocity.X > targetX) + NPC.velocity.X -= turnSpeedCopy; } else if (NPC.velocity.Y > 4f) { if (NPC.velocity.X < 0f) - NPC.velocity.X += num189 * 0.9f; + NPC.velocity.X += turnSpeedCopy * 0.9f; else - NPC.velocity.X -= num189 * 0.9f; + NPC.velocity.X -= turnSpeedCopy * 0.9f; } } else @@ -2165,39 +2165,39 @@ namespace CalamityMod.NPCs.DevourerofGods maximumSpeed2 += 0.2f * (1f - lifeRatio); } - float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); - float num25 = Math.Abs(num191); - float num26 = Math.Abs(num192); - float num27 = fallSpeed / num193; - num191 *= num27; - num192 *= num27; + float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); + float absoluteTargetX2 = Math.Abs(targetX); + float absoluteTargetY2 = Math.Abs(targetY); + float timeToReachTarget2 = fallSpeed / targetDistance; + targetX *= timeToReachTarget2; + targetY *= timeToReachTarget2; - if (((NPC.velocity.X > 0f && num191 > 0f) || (NPC.velocity.X < 0f && num191 < 0f)) && ((NPC.velocity.Y > 0f && num192 > 0f) || (NPC.velocity.Y < 0f && num192 < 0f))) + if (((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f)) && ((NPC.velocity.Y > 0f && targetY > 0f) || (NPC.velocity.Y < 0f && targetY < 0f))) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetX) NPC.velocity.X += groundPhaseTurnSpeed * 1.5f; - else if (NPC.velocity.X > num191) + else if (NPC.velocity.X > targetX) NPC.velocity.X -= groundPhaseTurnSpeed * 1.5f; - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetY) NPC.velocity.Y += groundPhaseTurnSpeed * 1.5f; - else if (NPC.velocity.Y > num192) + else if (NPC.velocity.Y > targetY) NPC.velocity.Y -= groundPhaseTurnSpeed * 1.5f; } - if ((NPC.velocity.X > 0f && num191 > 0f) || (NPC.velocity.X < 0f && num191 < 0f) || (NPC.velocity.Y > 0f && num192 > 0f) || (NPC.velocity.Y < 0f && num192 < 0f)) + if ((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f) || (NPC.velocity.Y > 0f && targetY > 0f) || (NPC.velocity.Y < 0f && targetY < 0f)) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetX) NPC.velocity.X += groundPhaseTurnSpeed; - else if (NPC.velocity.X > num191) + else if (NPC.velocity.X > targetX) NPC.velocity.X -= groundPhaseTurnSpeed; - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetY) NPC.velocity.Y += groundPhaseTurnSpeed; - else if (NPC.velocity.Y > num192) + else if (NPC.velocity.Y > targetY) NPC.velocity.Y -= groundPhaseTurnSpeed; - if (Math.Abs(num192) < fallSpeed * maximumSpeed1 && ((NPC.velocity.X > 0f && num191 < 0f) || (NPC.velocity.X < 0f && num191 > 0f))) + if (Math.Abs(targetY) < fallSpeed * maximumSpeed1 && ((NPC.velocity.X > 0f && targetX < 0f) || (NPC.velocity.X < 0f && targetX > 0f))) { if (NPC.velocity.Y > 0f) NPC.velocity.Y += groundPhaseTurnSpeed * 2f; @@ -2205,7 +2205,7 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.velocity.Y -= groundPhaseTurnSpeed * 2f; } - if (Math.Abs(num191) < fallSpeed * maximumSpeed1 && ((NPC.velocity.Y > 0f && num192 < 0f) || (NPC.velocity.Y < 0f && num192 > 0f))) + if (Math.Abs(targetX) < fallSpeed * maximumSpeed1 && ((NPC.velocity.Y > 0f && targetY < 0f) || (NPC.velocity.Y < 0f && targetY > 0f))) { if (NPC.velocity.X > 0f) NPC.velocity.X += groundPhaseTurnSpeed * 2f; @@ -2213,11 +2213,11 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.velocity.X -= groundPhaseTurnSpeed * 2f; } } - else if (num25 > num26) + else if (absoluteTargetX2 > absoluteTargetY2) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetX) NPC.velocity.X += groundPhaseTurnSpeed * 1.1f; - else if (NPC.velocity.X > num191) + else if (NPC.velocity.X > targetX) NPC.velocity.X -= groundPhaseTurnSpeed * 1.1f; if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < fallSpeed * maximumSpeed2) @@ -2230,9 +2230,9 @@ namespace CalamityMod.NPCs.DevourerofGods } else { - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetY) NPC.velocity.Y += groundPhaseTurnSpeed * 1.1f; - else if (NPC.velocity.Y > num192) + else if (NPC.velocity.Y > targetY) NPC.velocity.Y -= groundPhaseTurnSpeed * 1.1f; if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < fallSpeed * maximumSpeed2) @@ -2566,26 +2566,26 @@ namespace CalamityMod.NPCs.DevourerofGods bool useOtherTextures = (Phase2Started && NPC.localAI[2] <= 60f) || NPC.IsABestiaryIconDummy; Texture2D texture2D15 = useOtherTextures ? ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadS").Value : TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); + Vector2 halfSizeTexture = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); if (NPC.IsABestiaryIconDummy) NPC.frame = texture2D15.Frame(); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); if (!NPC.dontTakeDamage) { texture2D15 = useOtherTextures ? ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadSGlow").Value : ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + Color glowmaskLerp = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskLerp, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = useOtherTextures ? ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadSGlow2").Value : ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadGlow2").Value; - color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + glowmaskLerp = Color.Lerp(Color.White, Color.Cyan, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskLerp, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } if (disintegrationFactor > 0f) @@ -2680,42 +2680,42 @@ namespace CalamityMod.NPCs.DevourerofGods // GFB torch and Wand drops var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ModContent.ItemType()); + GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); // this will be disastrous for the torch economy int dropRate = 10; int dropMin = 1; int dropMax = 9999; - GFBOnly.Add(ItemID.Torch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.PurpleTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.YellowTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.GreenTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.RedTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.WhiteTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.OrangeTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.PinkTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.RainbowTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.IceTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.BoneTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.UltrabrightTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.DemonTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.CursedTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.IchorTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.DesertTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.CoralTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.CorruptTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.CrimsonTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.HallowedTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.JungleTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.MushroomTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ItemID.ShimmerTorch, dropRate, dropMin, dropMax); - GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax); - GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax); - GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax); - GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax); - GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax); - GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax); - GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax); + GFBOnly.Add(ItemID.Torch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.PurpleTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.YellowTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.GreenTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.RedTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.WhiteTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.OrangeTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.PinkTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.RainbowTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.IceTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.BoneTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.UltrabrightTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.DemonTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.CursedTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.IchorTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.DesertTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.CoralTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.CorruptTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.CrimsonTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.HallowedTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.JungleTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.MushroomTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ItemID.ShimmerTorch, dropRate, dropMin, dropMax, true); + GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax, true); + GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax, true); + GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax, true); + GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax, true); + GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax, true); + GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax, true); + GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax, true); } // Trophy (always directly from boss, never in bag) @@ -2732,18 +2732,18 @@ namespace CalamityMod.NPCs.DevourerofGods Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= (Phase2Started ? 80f : 55f) * NPC.scale && (NPC.Opacity >= 1f || postTeleportTimer > 0); } @@ -2809,23 +2809,23 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.height = (int)(100 * NPC.scale); NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 15; num621++) + for (int i = 0; i < 15; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int cosmiliteDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[cosmiliteDust].scale = 0.5f; + Main.dust[cosmiliteDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[cosmiliteDust2].noGravity = true; + Main.dust[cosmiliteDust2].velocity *= 5f; + cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust2].velocity *= 2f; } } } diff --git a/NPCs/DevourerofGods/DevourerofGodsTail.cs b/NPCs/DevourerofGods/DevourerofGodsTail.cs index 4c043d0e79..1387a0a641 100644 --- a/NPCs/DevourerofGods/DevourerofGodsTail.cs +++ b/NPCs/DevourerofGods/DevourerofGodsTail.cs @@ -266,39 +266,39 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.Opacity = Main.npc[(int)NPC.ai[2]].Opacity; } - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num191 = player.position.X + (player.width / 2); - float num192 = player.position.Y + (player.height / 2); - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); + Vector2 segmentDirection = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float playerXDist = player.position.X + (player.width / 2); + float playerYDist = player.position.Y + (player.height / 2); + playerXDist = (int)(playerXDist / 16f) * 16; + playerYDist = (int)(playerYDist / 16f) * 16; + segmentDirection.X = (int)(segmentDirection.X / 16f) * 16; + segmentDirection.Y = (int)(segmentDirection.Y / 16f) * 16; + playerXDist -= segmentDirection.X; + playerYDist -= segmentDirection.Y; + float playerDistance = (float)System.Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentDirection = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + playerXDist = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - segmentDirection.X; + playerYDist = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - segmentDirection.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2(num192, num191) + MathHelper.PiOver2; - num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = NPC.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2(playerYDist, playerXDist) + MathHelper.PiOver2; + playerDistance = (float)System.Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); + int segmentWidth = NPC.width; + playerDistance = (playerDistance - segmentWidth) / playerDistance; + playerXDist *= playerDistance; + playerYDist *= playerDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + playerXDist; + NPC.position.Y = NPC.position.Y + playerYDist; - if (num191 < 0f) + if (playerXDist < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (playerXDist > 0f) NPC.spriteDirection = 1; } } @@ -326,24 +326,24 @@ namespace CalamityMod.NPCs.DevourerofGods bool useOtherTextures = phase2Started && Main.npc[(int)NPC.ai[2]].localAI[2] <= 60f; Texture2D texture2D15 = useOtherTextures ? ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailS").Value : TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); + Vector2 halfSizeTexture = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawPosition = NPC.Center - screenPos; + drawPosition -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; + drawPosition += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawPosition, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); if (!NPC.dontTakeDamage) { texture2D15 = useOtherTextures ? ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailSGlow").Value : ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + Color glowmaskColor = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawPosition, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = useOtherTextures ? ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailSGlow2").Value : ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailGlow2").Value; - color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + glowmaskColor = Color.Lerp(Color.White, Color.Cyan, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawPosition, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } if (disintegrationFactor > 0f) @@ -358,18 +358,18 @@ namespace CalamityMod.NPCs.DevourerofGods Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= (phase2Started ? 70f : 35f) * NPC.scale && NPC.Opacity >= 1f; } @@ -395,23 +395,23 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.height = (int)(100 * NPC.scale); NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int cosmiliteDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[cosmiliteDust].scale = 0.5f; + Main.dust[cosmiliteDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[cosmiliteDust2].noGravity = true; + Main.dust[cosmiliteDust2].velocity *= 5f; + cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust2].velocity *= 2f; } } } diff --git a/NPCs/DraedonLabThings/Androomba.cs b/NPCs/DraedonLabThings/Androomba.cs index b07f484841..99458991a0 100644 --- a/NPCs/DraedonLabThings/Androomba.cs +++ b/NPCs/DraedonLabThings/Androomba.cs @@ -21,7 +21,7 @@ namespace CalamityMod.NPCs.DraedonLabThings NPCID.Sets.CountsAsCritter[NPC.type] = true; Main.npcCatchable[NPC.type] = true; NPCID.Sets.NormalGoldCritterBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0); value.Position.Y += 18; value.PortraitPositionYOverride = 38f; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; diff --git a/NPCs/DraedonLabThings/RepairUnitCritter.cs b/NPCs/DraedonLabThings/RepairUnitCritter.cs index b5a3e82a84..9f8d5e76b0 100644 --- a/NPCs/DraedonLabThings/RepairUnitCritter.cs +++ b/NPCs/DraedonLabThings/RepairUnitCritter.cs @@ -57,7 +57,7 @@ namespace CalamityMod.NPCs.DraedonLabThings NPCID.Sets.CountsAsCritter[NPC.type] = true; NPCID.Sets.CantTakeLunchMoney[Type] = true; NPCID.Sets.NormalGoldCritterBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0); value.Position.Y += 12; value.PortraitPositionYOverride = 32f; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; diff --git a/NPCs/ExoMechs/Apollo/Apollo.cs b/NPCs/ExoMechs/Apollo/Apollo.cs index e03ad29819..eec03a58fc 100644 --- a/NPCs/ExoMechs/Apollo/Apollo.cs +++ b/NPCs/ExoMechs/Apollo/Apollo.cs @@ -151,7 +151,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo NPC.GetNPCDamage(); NPC.width = 204; NPC.height = 226; - NPC.defense = 80; + NPC.defense = 100; NPC.DR_NERD(0.25f); NPC.LifeMaxNERB(1250000, 1495000, 650000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; @@ -1354,18 +1354,18 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= 100f && NPC.Opacity == 1f && AIState == (float)Phase.ChargeCombo; } @@ -1735,14 +1735,14 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo { Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); } - for (int num194 = 0; num194 < 20; num194++) + for (int i = 0; i < 20; i++) { - int num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[plasmaDust].noGravity = true; + Main.dust[plasmaDust].velocity *= 3f; + plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[plasmaDust].velocity *= 2f; + Main.dust[plasmaDust].noGravity = true; } if (Main.netMode != NetmodeID.Server) diff --git a/NPCs/ExoMechs/Ares/AresBody.cs b/NPCs/ExoMechs/Ares/AresBody.cs index e45a9c1494..30a8c47ef6 100644 --- a/NPCs/ExoMechs/Ares/AresBody.cs +++ b/NPCs/ExoMechs/Ares/AresBody.cs @@ -1536,7 +1536,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // GFB Broken Water Filter var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ModContent.ItemType()); + GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); } // Lore item @@ -1607,18 +1607,18 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if (NPC.life <= 0) { - for (int num193 = 0; num193 < 2; num193++) + for (int i = 0; i < 2; i++) { Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); } - for (int num194 = 0; num194 < 20; num194++) + for (int j = 0; j < 20; j++) { - int num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[plasmaDust].noGravity = true; + Main.dust[plasmaDust].velocity *= 3f; + plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[plasmaDust].velocity *= 2f; + Main.dust[plasmaDust].noGravity = true; } if (Main.netMode != NetmodeID.Server) diff --git a/NPCs/ExoMechs/Ares/AresGaussNuke.cs b/NPCs/ExoMechs/Ares/AresGaussNuke.cs index 7931ad3138..29b0f0717e 100644 --- a/NPCs/ExoMechs/Ares/AresGaussNuke.cs +++ b/NPCs/ExoMechs/Ares/AresGaussNuke.cs @@ -83,7 +83,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares NPC.damage = 100; NPC.width = 170; NPC.height = 120; - NPC.defense = 80; + NPC.defense = 100; NPC.DR_NERD(0.35f); NPC.LifeMaxNERB(1250000, 1495000, 650000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; @@ -665,18 +665,18 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if (NPC.life <= 0) { - for (int num193 = 0; num193 < 2; num193++) + for (int i = 0; i < 2; i++) { Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); } - for (int num194 = 0; num194 < 20; num194++) + for (int j = 0; j < 20; j++) { - int num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[plasmaDust].noGravity = true; + Main.dust[plasmaDust].velocity *= 3f; + plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[plasmaDust].velocity *= 2f; + Main.dust[plasmaDust].noGravity = true; } if (Main.netMode != NetmodeID.Server) diff --git a/NPCs/ExoMechs/Ares/AresLaserCannon.cs b/NPCs/ExoMechs/Ares/AresLaserCannon.cs index 03a1228c90..10988c9039 100644 --- a/NPCs/ExoMechs/Ares/AresLaserCannon.cs +++ b/NPCs/ExoMechs/Ares/AresLaserCannon.cs @@ -86,7 +86,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares NPC.damage = 100; NPC.width = 154; NPC.height = 90; - NPC.defense = 80; + NPC.defense = 100; NPC.DR_NERD(0.35f); NPC.LifeMaxNERB(1250000, 1495000, 650000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; @@ -715,18 +715,18 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if (NPC.life <= 0) { - for (int num193 = 0; num193 < 2; num193++) + for (int i = 0; i < 2; i++) { Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); } - for (int num194 = 0; num194 < 20; num194++) + for (int j = 0; j < 20; j++) { - int num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[plasmaDust].noGravity = true; + Main.dust[plasmaDust].velocity *= 3f; + plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[plasmaDust].velocity *= 2f; + Main.dust[plasmaDust].noGravity = true; } if (Main.netMode != NetmodeID.Server) diff --git a/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs b/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs index 6d056c6235..00ff522bd8 100644 --- a/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs +++ b/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs @@ -80,7 +80,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares NPC.damage = 100; NPC.width = 152; NPC.height = 90; - NPC.defense = 80; + NPC.defense = 100; NPC.DR_NERD(0.35f); NPC.LifeMaxNERB(1250000, 1495000, 650000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; @@ -664,18 +664,18 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if (NPC.life <= 0) { - for (int num193 = 0; num193 < 2; num193++) + for (int i = 0; i < 2; i++) { Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); } - for (int num194 = 0; num194 < 20; num194++) + for (int j = 0; j < 20; j++) { - int num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[plasmaDust].noGravity = true; + Main.dust[plasmaDust].velocity *= 3f; + plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[plasmaDust].velocity *= 2f; + Main.dust[plasmaDust].noGravity = true; } if (Main.netMode != NetmodeID.Server) diff --git a/NPCs/ExoMechs/Ares/AresTeslaCannon.cs b/NPCs/ExoMechs/Ares/AresTeslaCannon.cs index e2f5026ff2..f790886216 100644 --- a/NPCs/ExoMechs/Ares/AresTeslaCannon.cs +++ b/NPCs/ExoMechs/Ares/AresTeslaCannon.cs @@ -81,7 +81,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares NPC.damage = 100; NPC.width = 172; NPC.height = 108; - NPC.defense = 80; + NPC.defense = 100; NPC.DR_NERD(0.35f); NPC.LifeMaxNERB(1250000, 1495000, 650000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; @@ -658,18 +658,18 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if (NPC.life <= 0) { - for (int num193 = 0; num193 < 2; num193++) + for (int i = 0; i < 2; i++) { Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); } - for (int num194 = 0; num194 < 20; num194++) + for (int j = 0; j < 20; j++) { - int num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[plasmaDust].noGravity = true; + Main.dust[plasmaDust].velocity *= 3f; + plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[plasmaDust].velocity *= 2f; + Main.dust[plasmaDust].noGravity = true; } if (Main.netMode != NetmodeID.Server) diff --git a/NPCs/ExoMechs/Artemis/Artemis.cs b/NPCs/ExoMechs/Artemis/Artemis.cs index f1b2de595d..b97a1a5fd9 100644 --- a/NPCs/ExoMechs/Artemis/Artemis.cs +++ b/NPCs/ExoMechs/Artemis/Artemis.cs @@ -183,7 +183,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis NPC.GetNPCDamage(); NPC.width = 204; NPC.height = 226; - NPC.defense = 80; + NPC.defense = 100; NPC.DR_NERD(0.25f); NPC.LifeMaxNERB(1250000, 1495000, 650000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; @@ -1248,18 +1248,18 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= 100f && NPC.Opacity == 1f && AIState == (float)Phase.Charge; } @@ -1562,18 +1562,18 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis if (NPC.life <= 0) { - for (int num193 = 0; num193 < 2; num193++) + for (int i = 0; i < 2; i++) { Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); } - for (int num194 = 0; num194 < 20; num194++) + for (int j = 0; j < 20; j++) { - int num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[plasmaDust].noGravity = true; + Main.dust[plasmaDust].velocity *= 3f; + plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[plasmaDust].velocity *= 2f; + Main.dust[plasmaDust].noGravity = true; } if (Main.netMode != NetmodeID.Server) diff --git a/NPCs/ExoMechs/Draedon.cs b/NPCs/ExoMechs/Draedon.cs index 587fd7ddf2..cf784fd48c 100644 --- a/NPCs/ExoMechs/Draedon.cs +++ b/NPCs/ExoMechs/Draedon.cs @@ -84,7 +84,7 @@ namespace CalamityMod.NPCs.ExoMechs public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 12; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { PortraitPositionYOverride = 40f, Scale = 0.7f, diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs b/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs index 6ef5556299..b262f0b856 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs @@ -515,18 +515,18 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= 50f && NPC.Opacity == 1f && noContactDamageTimer <= 0; } @@ -629,17 +629,17 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (NPC.life <= 0) { - for (int num193 = 0; num193 < 2; num193++) + for (int i = 0; i < 2; i++) Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - for (int num194 = 0; num194 < 20; num194++) + for (int j = 0; j < 20; j++) { - int num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[plasmaDust].noGravity = true; + Main.dust[plasmaDust].velocity *= 3f; + plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[plasmaDust].velocity *= 2f; + Main.dust[plasmaDust].noGravity = true; } if (Main.netMode != NetmodeID.Server) diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs b/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs index 7582176e24..8c4d93d0a7 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs @@ -517,18 +517,18 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= 50f && NPC.Opacity == 1f && noContactDamageTimer <= 0; } @@ -632,18 +632,18 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (NPC.life <= 0) { - for (int num193 = 0; num193 < 2; num193++) + for (int i = 0; i < 2; i++) { Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); } - for (int num194 = 0; num194 < 20; num194++) + for (int j = 0; j < 20; j++) { - int num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[plasmaDust].noGravity = true; + Main.dust[plasmaDust].velocity *= 3f; + plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[plasmaDust].velocity *= 2f; + Main.dust[plasmaDust].noGravity = true; } if (Main.netMode != NetmodeID.Server) diff --git a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs index 032179aa03..aeb518a29a 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs @@ -148,7 +148,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos NPC.GetNPCDamage(); NPC.width = 164; NPC.height = 164; - NPC.defense = 80; + NPC.defense = 100; NPC.DR_NERD(0.9999f); NPC.Calamity().unbreakableDR = true; NPC.LifeMaxNERB(960000, 1150000, 600000); @@ -1018,18 +1018,18 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= 50f && NPC.Opacity == 1f && noContactDamageTimer <= 0; } @@ -1265,18 +1265,18 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (NPC.life <= 0) { - for (int num193 = 0; num193 < 2; num193++) + for (int i = 0; i < 2; i++) { Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); } - for (int num194 = 0; num194 < 20; num194++) + for (int j = 0; j < 20; j++) { - int num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[plasmaDust].noGravity = true; + Main.dust[plasmaDust].velocity *= 3f; + plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[plasmaDust].velocity *= 2f; + Main.dust[plasmaDust].noGravity = true; } if (Main.netMode != NetmodeID.Server) diff --git a/NPCs/ExoMechs/Thanatos/ThanatosTail.cs b/NPCs/ExoMechs/Thanatos/ThanatosTail.cs index ac1bba95a2..73454ad0cf 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosTail.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosTail.cs @@ -61,7 +61,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos NPC.GetNPCDamage(); NPC.width = 76; NPC.height = 110; - NPC.defense = 120; + NPC.defense = 100; NPC.DR_NERD(0.9999f); NPC.Calamity().unbreakableDR = true; NPC.LifeMaxNERB(960000, 1150000, 600000); @@ -515,18 +515,18 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= 45f && NPC.Opacity == 1f && noContactDamageTimer <= 0; } @@ -630,18 +630,18 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (NPC.life <= 0) { - for (int num193 = 0; num193 < 2; num193++) + for (int i = 0; i < 2; i++) { Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); } - for (int num194 = 0; num194 < 20; num194++) + for (int j = 0; j < 20; j++) { - int num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[plasmaDust].noGravity = true; + Main.dust[plasmaDust].velocity *= 3f; + plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[plasmaDust].velocity *= 2f; + Main.dust[plasmaDust].noGravity = true; } if (Main.netMode != NetmodeID.Server) diff --git a/NPCs/GreatSandShark/GreatSandShark.cs b/NPCs/GreatSandShark/GreatSandShark.cs index 06db70715f..4298f8a3d5 100644 --- a/NPCs/GreatSandShark/GreatSandShark.cs +++ b/NPCs/GreatSandShark/GreatSandShark.cs @@ -24,12 +24,14 @@ namespace CalamityMod.NPCs.GreatSandShark private bool resetAI = false; public static readonly SoundStyle RoarSound = new("CalamityMod/Sounds/Custom/GreatSandSharkRoar"); + public static readonly SoundStyle HurtSound = new("CalamityMod/Sounds/NPCHit/GreatSandSharkHit"); + public static readonly SoundStyle DeathSound = new("CalamityMod/Sounds/NPCKilled/GreatSandSharkDeath"); public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 8; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.6f, PortraitPositionXOverride = 70f @@ -59,8 +61,7 @@ namespace CalamityMod.NPCs.GreatSandShark NPCID.Sets.TrailingMode[NPC.type] = 1; NPC.behindTiles = true; NPC.netAlways = true; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; + NPC.DeathSound = DeathSound; NPC.timeLeft = NPC.activeTime * 30; NPC.rarity = 2; if (Main.zenithWorld) @@ -139,33 +140,33 @@ namespace CalamityMod.NPCs.GreatSandShark NPC.netUpdate = true; } - int num2 = expertMode ? 35 : 50; - float num3 = expertMode ? 0.5f : 0.42f; - float scaleFactor = expertMode ? 7.5f : 6.7f; - int num4 = expertMode ? 28 : 30; - float num5 = expertMode ? 15.5f : 14f; + int chargeTime = expertMode ? 35 : 50; + float chargeAcceleration = expertMode ? 0.5f : 0.42f; + float chargeThreshold = expertMode ? 7.5f : 6.7f; + int chargeDelay = expertMode ? 28 : 30; + float chargeVelocity = expertMode ? 15.5f : 14f; if (revenge || lowerLife) { - num3 *= 1.1f; - scaleFactor *= 1.1f; - num5 *= 1.1f; + chargeAcceleration *= 1.1f; + chargeThreshold *= 1.1f; + chargeVelocity *= 1.1f; } if (death) { - num3 *= 1.1f; - scaleFactor *= 1.1f; - num5 *= 1.1f; - num4 = 25; + chargeAcceleration *= 1.1f; + chargeThreshold *= 1.1f; + chargeVelocity *= 1.1f; + chargeDelay = 25; } if (youMustDie) { - num3 *= 1.5f; - scaleFactor *= 1.5f; - num5 *= 1.5f; - num4 = 20; + chargeAcceleration *= 1.5f; + chargeThreshold *= 1.5f; + chargeVelocity *= 1.5f; + chargeDelay = 20; } - Vector2 vector = NPC.Center; + Vector2 shorkCenter = NPC.Center; Player player = Main.player[NPC.target]; if (NPC.target < 0 || NPC.target == Main.maxPlayers || player.dead || !player.active) @@ -175,7 +176,7 @@ namespace CalamityMod.NPCs.GreatSandShark NPC.netUpdate = true; } - if (player.dead || Vector2.Distance(player.Center, vector) > 5600f) + if (player.dead || Vector2.Distance(player.Center, shorkCenter) > 5600f) { NPC.velocity.Y += 0.4f; if (NPC.timeLeft > 10) @@ -185,82 +186,82 @@ namespace CalamityMod.NPCs.GreatSandShark NPC.ai[2] = 0f; } - float num17 = (float)Math.Atan2(player.Center.Y - vector.Y, player.Center.X - vector.X); + float getRotatedIdiot = (float)Math.Atan2(player.Center.Y - shorkCenter.Y, player.Center.X - shorkCenter.X); if (NPC.spriteDirection == 1) - num17 += MathHelper.Pi; - if (num17 < 0f) - num17 += MathHelper.TwoPi; - if (num17 > MathHelper.TwoPi) - num17 -= MathHelper.TwoPi; + getRotatedIdiot += MathHelper.Pi; + if (getRotatedIdiot < 0f) + getRotatedIdiot += MathHelper.TwoPi; + if (getRotatedIdiot > MathHelper.TwoPi) + getRotatedIdiot -= MathHelper.TwoPi; - float num18 = 0.04f; + float rotationSpeed = 0.04f; if (NPC.ai[0] == 1f) - num18 = 0f; + rotationSpeed = 0f; - if (NPC.rotation < num17) + if (NPC.rotation < getRotatedIdiot) { - if ((double)(num17 - NPC.rotation) > MathHelper.Pi) - NPC.rotation -= num18; + if ((double)(getRotatedIdiot - NPC.rotation) > MathHelper.Pi) + NPC.rotation -= rotationSpeed; else - NPC.rotation += num18; + NPC.rotation += rotationSpeed; } - if (NPC.rotation > num17) + if (NPC.rotation > getRotatedIdiot) { - if ((double)(NPC.rotation - num17) > MathHelper.Pi) - NPC.rotation += num18; + if ((double)(NPC.rotation - getRotatedIdiot) > MathHelper.Pi) + NPC.rotation += rotationSpeed; else - NPC.rotation -= num18; + NPC.rotation -= rotationSpeed; } - if (NPC.rotation > num17 - num18 && NPC.rotation < num17 + num18) - NPC.rotation = num17; + if (NPC.rotation > getRotatedIdiot - rotationSpeed && NPC.rotation < getRotatedIdiot + rotationSpeed) + NPC.rotation = getRotatedIdiot; if (NPC.rotation < 0f) NPC.rotation += MathHelper.TwoPi; if (NPC.rotation > MathHelper.TwoPi) NPC.rotation -= MathHelper.TwoPi; - if (NPC.rotation > num17 - num18 && NPC.rotation < num17 + num18) - NPC.rotation = num17; + if (NPC.rotation > getRotatedIdiot - rotationSpeed && NPC.rotation < getRotatedIdiot + rotationSpeed) + NPC.rotation = getRotatedIdiot; if (NPC.ai[0] == 0f && !player.dead) { if (NPC.ai[1] == 0f) - NPC.ai[1] = 300 * Math.Sign((vector - player.Center).X); + NPC.ai[1] = 300 * Math.Sign((shorkCenter - player.Center).X); - Vector2 vector3 = Vector2.Normalize(player.Center + new Vector2(NPC.ai[1], -200f) - vector - NPC.velocity) * scaleFactor; - if (NPC.velocity.X < vector3.X) + Vector2 chargeDirection = Vector2.Normalize(player.Center + new Vector2(NPC.ai[1], -200f) - shorkCenter - NPC.velocity) * chargeThreshold; + if (NPC.velocity.X < chargeDirection.X) { - NPC.velocity.X += num3; - if (NPC.velocity.X < 0f && vector3.X > 0f) - NPC.velocity.X += num3; + NPC.velocity.X += chargeAcceleration; + if (NPC.velocity.X < 0f && chargeDirection.X > 0f) + NPC.velocity.X += chargeAcceleration; } - else if (NPC.velocity.X > vector3.X) + else if (NPC.velocity.X > chargeDirection.X) { - NPC.velocity.X -= num3; - if (NPC.velocity.X > 0f && vector3.X < 0f) - NPC.velocity.X -= num3; + NPC.velocity.X -= chargeAcceleration; + if (NPC.velocity.X > 0f && chargeDirection.X < 0f) + NPC.velocity.X -= chargeAcceleration; } - if (NPC.velocity.Y < vector3.Y) + if (NPC.velocity.Y < chargeDirection.Y) { - NPC.velocity.Y += num3; - if (NPC.velocity.Y < 0f && vector3.Y > 0f) - NPC.velocity.Y += num3; + NPC.velocity.Y += chargeAcceleration; + if (NPC.velocity.Y < 0f && chargeDirection.Y > 0f) + NPC.velocity.Y += chargeAcceleration; } - else if (NPC.velocity.Y > vector3.Y) + else if (NPC.velocity.Y > chargeDirection.Y) { - NPC.velocity.Y -= num3; - if (NPC.velocity.Y > 0f && vector3.Y < 0f) - NPC.velocity.Y -= num3; + NPC.velocity.Y -= chargeAcceleration; + if (NPC.velocity.Y > 0f && chargeDirection.Y < 0f) + NPC.velocity.Y -= chargeAcceleration; } - int num22 = Math.Sign(player.Center.X - vector.X); - if (num22 != 0) + int shorkFaceDirection = Math.Sign(player.Center.X - shorkCenter.X); + if (shorkFaceDirection != 0) { - if (NPC.ai[2] == 0f && num22 != NPC.direction) + if (NPC.ai[2] == 0f && shorkFaceDirection != NPC.direction) NPC.rotation += MathHelper.Pi; - NPC.direction = num22; + NPC.direction = shorkFaceDirection; if (NPC.spriteDirection != -NPC.direction) NPC.rotation += MathHelper.Pi; @@ -268,17 +269,17 @@ namespace CalamityMod.NPCs.GreatSandShark } NPC.ai[2] += 1f; - if (NPC.ai[2] >= num2) + if (NPC.ai[2] >= chargeTime) { NPC.ai[0] = 1f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; - NPC.velocity = Vector2.Normalize(player.Center - vector) * num5; + NPC.velocity = Vector2.Normalize(player.Center - shorkCenter) * chargeVelocity; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); - if (num22 != 0) + if (shorkFaceDirection != 0) { - NPC.direction = num22; + NPC.direction = shorkFaceDirection; if (NPC.spriteDirection == 1) NPC.rotation += MathHelper.Pi; @@ -292,7 +293,7 @@ namespace CalamityMod.NPCs.GreatSandShark else if (NPC.ai[0] == 1f) { NPC.ai[2] += 1f; - if (NPC.ai[2] >= num4) + if (NPC.ai[2] >= chargeDelay) { NPC.localAI[3] += 1f; if (NPC.localAI[3] >= 2f) @@ -312,15 +313,15 @@ namespace CalamityMod.NPCs.GreatSandShark if (NPC.direction == 0) NPC.TargetClosest(); - Point point15 = NPC.Center.ToTileCoordinates(); - Tile tileSafely = Framing.GetTileSafely(point15); - bool flag121 = tileSafely.HasUnactuatedTile || tileSafely.LiquidAmount > 0; - bool flag122 = false; + Point shorkTileCenter = NPC.Center.ToTileCoordinates(); + Tile tileSafely = Framing.GetTileSafely(shorkTileCenter); + bool isInSolidTile = tileSafely.HasUnactuatedTile || tileSafely.LiquidAmount > 0; + bool shouldDoLunge = false; NPC.TargetClosest(false); - Vector2 vector260 = NPC.targetRect.Center.ToVector2(); - if (Main.player[NPC.target].velocity.Y > -0.1f && !Main.player[NPC.target].dead && NPC.Distance(vector260) > 150f) - flag122 = true; + Vector2 targetLungeDirection = NPC.targetRect.Center.ToVector2(); + if (Main.player[NPC.target].velocity.Y > -0.1f && !Main.player[NPC.target].dead && NPC.Distance(targetLungeDirection) > 150f) + shouldDoLunge = true; NPC.localAI[1] += 1f; @@ -364,25 +365,24 @@ namespace CalamityMod.NPCs.GreatSandShark NPC.netUpdate = true; } - if (NPC.localAI[0] == -1f && !flag121) + if (NPC.localAI[0] == -1f && !isInSolidTile) NPC.localAI[0] = 20f; if (NPC.localAI[0] > 0f) NPC.localAI[0] -= 1f; - if (flag121) + if (isInSolidTile) { - float num1534 = NPC.ai[1]; - bool flag123 = false; - point15 = (NPC.Center + new Vector2(0f, 24f)).ToTileCoordinates(); - tileSafely = Framing.GetTileSafely(point15.X, point15.Y - 2); + bool lungeShouldDecelerate = false; + shorkTileCenter = (NPC.Center + new Vector2(0f, 24f)).ToTileCoordinates(); + tileSafely = Framing.GetTileSafely(shorkTileCenter.X, shorkTileCenter.Y - 2); if (tileSafely.HasUnactuatedTile) - flag123 = true; + lungeShouldDecelerate = true; - NPC.ai[1] = flag123.ToInt(); + NPC.ai[1] = lungeShouldDecelerate.ToInt(); if (NPC.ai[2] < 30f) NPC.ai[2] += 1f; - if (flag122) + if (shouldDoLunge) { NPC.TargetClosest(); NPC.velocity.X += NPC.direction * 0.15f; @@ -416,34 +416,34 @@ namespace CalamityMod.NPCs.GreatSandShark } NPC.velocity.X = MathHelper.Clamp(NPC.velocity.X, -velocityX, velocityX); NPC.velocity.Y = MathHelper.Clamp(NPC.velocity.Y, -velocityY, velocityY); - Vector2 vec4 = NPC.Center + NPC.velocity.SafeNormalize(Vector2.Zero) * NPC.Size.Length() / 2f + NPC.velocity; - point15 = vec4.ToTileCoordinates(); - tileSafely = Framing.GetTileSafely(point15); - bool flag124 = tileSafely.HasUnactuatedTile; - if (!flag124 && Math.Sign(NPC.velocity.X) == NPC.direction && (NPC.Distance(vector260) < 600f || youMustDie) && (NPC.ai[2] >= 30f || NPC.ai[2] < 0f)) + Vector2 shorkDirection = NPC.Center + NPC.velocity.SafeNormalize(Vector2.Zero) * NPC.Size.Length() / 2f + NPC.velocity; + shorkTileCenter = shorkDirection.ToTileCoordinates(); + tileSafely = Framing.GetTileSafely(shorkTileCenter); + bool isInTile = tileSafely.HasUnactuatedTile; + if (!isInTile && Math.Sign(NPC.velocity.X) == NPC.direction && (NPC.Distance(targetLungeDirection) < 600f || youMustDie) && (NPC.ai[2] >= 30f || NPC.ai[2] < 0f)) { if (NPC.localAI[0] == 0f) { SoundEngine.PlaySound(SoundID.NPCDeath15, NPC.position); NPC.localAI[0] = -1f; - for (int num621 = 0; num621 < 25; num621++) + for (int i = 0; i < 25; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 32, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity.Y *= 6f; - Main.dust[num622].velocity.X *= 3f; + int burrowDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 32, 0f, 0f, 100, default, 2f); + Main.dust[burrowDust].velocity.Y *= 6f; + Main.dust[burrowDust].velocity.X *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[burrowDust].scale = 0.5f; + Main.dust[burrowDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 50; num623++) + for (int j = 0; j < 50; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 85, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity.Y *= 10f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 268, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity.X *= 2f; + int burrowDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 85, 0f, 0f, 100, default, 3f); + Main.dust[burrowDust2].noGravity = true; + Main.dust[burrowDust2].velocity.Y *= 10f; + burrowDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 268, 0f, 0f, 100, default, 2f); + Main.dust[burrowDust2].velocity.X *= 2f; } int spawnX = (int)(NPC.width / 2); int projType = Main.zenithWorld ? ModContent.ProjectileType() : ModContent.ProjectileType(); @@ -453,34 +453,34 @@ namespace CalamityMod.NPCs.GreatSandShark } NPC.ai[2] = -30f; - Vector2 upwardChargeDirection = NPC.SafeDirectionTo(vector260 + new Vector2(0f, -80f), -Vector2.UnitY); + Vector2 upwardChargeDirection = NPC.SafeDirectionTo(targetLungeDirection + new Vector2(0f, -80f), -Vector2.UnitY); NPC.velocity = upwardChargeDirection * 18f; } } else { - float num1535 = 6f; + float decelerationXThreshold = 6f; NPC.velocity.X += NPC.direction * 0.1f; - if (NPC.velocity.X < -num1535 || NPC.velocity.X > num1535) + if (NPC.velocity.X < -decelerationXThreshold || NPC.velocity.X > decelerationXThreshold) NPC.velocity.X *= 0.95f; - if (flag123) + if (lungeShouldDecelerate) NPC.ai[0] = -1f; else NPC.ai[0] = 1f; - float num1536 = 0.06f; - float num1537 = 0.01f; + float decelerationYThreshold = 0.06f; + float decelerationAmt = 0.01f; if (NPC.ai[0] == -1f) { - NPC.velocity.Y -= num1537; - if (NPC.velocity.Y < -num1536) + NPC.velocity.Y -= decelerationAmt; + if (NPC.velocity.Y < -decelerationYThreshold) NPC.ai[0] = 1f; } else { - NPC.velocity.Y += num1537; - if (NPC.velocity.Y > num1536) + NPC.velocity.Y += decelerationAmt; + if (NPC.velocity.Y > decelerationYThreshold) NPC.ai[0] = -1f; } @@ -492,12 +492,12 @@ namespace CalamityMod.NPCs.GreatSandShark { if (NPC.velocity.Y == 0f) { - if (flag122) + if (shouldDoLunge) NPC.TargetClosest(); - float num1538 = 1f; + float smallDecelerationXThreshold = 1f; NPC.velocity.X += NPC.direction * 0.1f; - if (NPC.velocity.X < -num1538 || NPC.velocity.X > num1538) + if (NPC.velocity.X < -smallDecelerationXThreshold || NPC.velocity.X > smallDecelerationXThreshold) NPC.velocity.X *= 0.95f; } @@ -586,75 +586,80 @@ namespace CalamityMod.NPCs.GreatSandShark { spriteEffects = SpriteEffects.FlipHorizontally; } - Color color24 = NPC.GetAlpha(drawColor); - Color color25 = Lighting.GetColor((int)((double)NPC.position.X + (double)NPC.width * 0.5) / 16, (int)(((double)NPC.position.Y + (double)NPC.height * 0.5) / 16.0)); + Color mainAfterimageColor = NPC.GetAlpha(drawColor); + Color extraAfterimageColor = Lighting.GetColor((int)((double)NPC.position.X + (double)NPC.width * 0.5) / 16, (int)(((double)NPC.position.Y + (double)NPC.height * 0.5) / 16.0)); if (Main.zenithWorld) { - color24 = Color.Silver; - color25 = Color.Orange; + mainAfterimageColor = Color.Silver; + extraAfterimageColor = Color.Orange; } Texture2D texture2D3 = TextureAssets.Npc[NPC.type].Value; - int num156 = TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type]; - int y3 = num156 * (int)NPC.frameCounter; - Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, num156); - Vector2 origin2 = rectangle.Size() / 2f; - int num157 = 8; - int num158 = 2; - int num159 = 1; - float num160 = 0f; - int num161 = num159; - while (((num158 > 0 && num161 < num157) || (num158 < 0 && num161 > num157)) && CalamityConfig.Instance.Afterimages) + int currentFrame = TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type]; + int y3 = currentFrame * (int)NPC.frameCounter; + Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, currentFrame); + Vector2 halfRectSize = rectangle.Size() / 2f; + int eightConst = 8; + int afterimageInc = 2; + int afterimageCounter = 1; + while (((afterimageInc > 0 && afterimageCounter < eightConst) || (afterimageInc < 0 && afterimageCounter > eightConst)) && CalamityConfig.Instance.Afterimages) { - Color color26 = NPC.GetAlpha(color25); + Color alphaAfterimageColor = NPC.GetAlpha(extraAfterimageColor); { goto IL_6899; } IL_6881: - num161 += num158; + afterimageCounter += afterimageInc; continue; IL_6899: - float num164 = (float)(num157 - num161); - if (num158 < 0) + float afterimagesRemaining = (float)(eightConst - afterimageCounter); + if (afterimageInc < 0) { - num164 = (float)(num159 - num161); + afterimagesRemaining = (float)(1 - afterimageCounter); } - color26 *= num164 / ((float)NPCID.Sets.TrailCacheLength[NPC.type] * 1.5f); - Vector2 value4 = NPC.oldPos[num161]; - float num165 = NPC.rotation; - Main.spriteBatch.Draw(texture2D3, value4 + NPC.Size / 2f - screenPos + new Vector2(0, NPC.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, num165 + NPC.rotation * num160 * (float)(num161 - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, NPC.scale, spriteEffects, 0f); + alphaAfterimageColor *= afterimagesRemaining / ((float)NPCID.Sets.TrailCacheLength[NPC.type] * 1.5f); + Vector2 afterimagePos = NPC.oldPos[afterimageCounter]; + float afterimageRotation = NPC.rotation; + Main.spriteBatch.Draw(texture2D3, afterimagePos + NPC.Size / 2f - screenPos + new Vector2(0, NPC.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), alphaAfterimageColor, afterimageRotation + NPC.rotation * 0f * (float)(afterimageCounter - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), halfRectSize, NPC.scale, spriteEffects, 0f); goto IL_6881; } var something = NPC.direction == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; - spriteBatch.Draw(texture2D3, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY), NPC.frame, color24, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, something, 0); + spriteBatch.Draw(texture2D3, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY), NPC.frame, mainAfterimageColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, something, 0); return false; } public override void HitEffect(NPC.HitInfo hit) { + // Hit sound + if (NPC.soundDelay == 0) + { + NPC.soundDelay = 15; + SoundEngine.PlaySound(HurtSound, NPC.Center); + } + for (int k = 0; k < 5; k++) { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f, 0, default, 1f); } if (NPC.life <= 0) { - for (int num621 = 0; num621 < 50; num621++) + for (int i = 0; i < 50; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int burrowDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 2f); + Main.dust[burrowDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[burrowDust].scale = 0.5f; + Main.dust[burrowDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 100; num623++) + for (int j = 0; j < 100; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int burrowDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 3f); + Main.dust[burrowDust2].noGravity = true; + Main.dust[burrowDust2].velocity *= 5f; + burrowDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 2f); + Main.dust[burrowDust2].velocity *= 2f; } } } diff --git a/NPCs/HiveMind/DankCreeper.cs b/NPCs/HiveMind/DankCreeper.cs index 16f694fa92..3ea8d6943c 100644 --- a/NPCs/HiveMind/DankCreeper.cs +++ b/NPCs/HiveMind/DankCreeper.cs @@ -65,17 +65,17 @@ namespace CalamityMod.NPCs.HiveMind NPC.rotation = NPC.velocity.X * 0.05f; - Vector2 vector167 = new Vector2(NPC.Center.X + (NPC.direction * 20), NPC.Center.Y + 6f); - float num1373 = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - vector167.X; - float num1374 = Main.player[NPC.target].Center.Y - vector167.Y; - float num1375 = (float)Math.Sqrt(num1373 * num1373 + num1374 * num1374); - float num1376 = speed / num1375; - num1373 *= num1376; - num1374 *= num1376; + Vector2 targetDirection = new Vector2(NPC.Center.X + (NPC.direction * 20), NPC.Center.Y + 6f); + float playerXDist = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - targetDirection.X; + float playerYDist = Main.player[NPC.target].Center.Y - targetDirection.Y; + float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); + float timeToReachTarget = speed / playerDistance; + playerXDist *= timeToReachTarget; + playerYDist *= timeToReachTarget; NPC.ai[0] -= 1f; - if (num1375 < 200f || NPC.ai[0] > 0f) + if (playerDistance < 200f || NPC.ai[0] > 0f) { - if (num1375 < 200f) + if (playerDistance < 200f) { NPC.ai[0] = 20f; } @@ -89,17 +89,17 @@ namespace CalamityMod.NPCs.HiveMind } return; } - NPC.velocity.X = (NPC.velocity.X * 50f + num1373) / 51f; - NPC.velocity.Y = (NPC.velocity.Y * 50f + num1374) / 51f; - if (num1375 < 350f) + NPC.velocity.X = (NPC.velocity.X * 50f + playerXDist) / 51f; + NPC.velocity.Y = (NPC.velocity.Y * 50f + playerYDist) / 51f; + if (playerDistance < 350f) { - NPC.velocity.X = (NPC.velocity.X * 10f + num1373) / 11f; - NPC.velocity.Y = (NPC.velocity.Y * 10f + num1374) / 11f; + NPC.velocity.X = (NPC.velocity.X * 10f + playerXDist) / 11f; + NPC.velocity.Y = (NPC.velocity.Y * 10f + playerYDist) / 11f; } - if (num1375 < 300f) + if (playerDistance < 300f) { - NPC.velocity.X = (NPC.velocity.X * 7f + num1373) / 8f; - NPC.velocity.Y = (NPC.velocity.Y * 7f + num1374) / 8f; + NPC.velocity.X = (NPC.velocity.X * 7f + playerXDist) / 8f; + NPC.velocity.Y = (NPC.velocity.Y * 7f + playerYDist) / 8f; } } diff --git a/NPCs/HiveMind/DarkHeart.cs b/NPCs/HiveMind/DarkHeart.cs index 5cb35d4be0..ac0d023d96 100644 --- a/NPCs/HiveMind/DarkHeart.cs +++ b/NPCs/HiveMind/DarkHeart.cs @@ -63,59 +63,59 @@ namespace CalamityMod.NPCs.HiveMind bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; NPC.TargetClosest(); - float num1164 = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 8f : revenge ? 4.5f : 4f; - float num1165 = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 1f : revenge ? 0.8f : 0.75f; + float npcSpeed = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 8f : revenge ? 4.5f : 4f; + float velocityMult = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 1f : revenge ? 0.8f : 0.75f; if (BossRushEvent.BossRushActive) { - num1164 *= 2f; - num1165 *= 2f; + npcSpeed *= 2f; + velocityMult *= 2f; } - Vector2 vector133 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num1166 = Main.player[NPC.target].Center.X - vector133.X; - float num1167 = Main.player[NPC.target].Center.Y - vector133.Y - ((CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 500f : 400f); - float num1168 = (float)Math.Sqrt(num1166 * num1166 + num1167 * num1167); - if (num1168 < ((CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 10f : 20f)) + Vector2 npcCenter = new Vector2(NPC.Center.X, NPC.Center.Y); + float playerXDist = Main.player[NPC.target].Center.X - npcCenter.X; + float playerYDist = Main.player[NPC.target].Center.Y - npcCenter.Y - ((CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 500f : 400f); + float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); + if (playerDistance < ((CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 10f : 20f)) { - num1166 = NPC.velocity.X; - num1167 = NPC.velocity.Y; + playerXDist = NPC.velocity.X; + playerYDist = NPC.velocity.Y; } else { - num1168 = num1164 / num1168; - num1166 *= num1168; - num1167 *= num1168; + playerDistance = npcSpeed / playerDistance; + playerXDist *= playerDistance; + playerYDist *= playerDistance; } - if (NPC.velocity.X < num1166) + if (NPC.velocity.X < playerXDist) { - NPC.velocity.X = NPC.velocity.X + num1165; - if (NPC.velocity.X < 0f && num1166 > 0f) + NPC.velocity.X = NPC.velocity.X + velocityMult; + if (NPC.velocity.X < 0f && playerXDist > 0f) { - NPC.velocity.X = NPC.velocity.X + num1165 * 2f; + NPC.velocity.X = NPC.velocity.X + velocityMult * 2f; } } - else if (NPC.velocity.X > num1166) + else if (NPC.velocity.X > playerXDist) { - NPC.velocity.X = NPC.velocity.X - num1165; - if (NPC.velocity.X > 0f && num1166 < 0f) + NPC.velocity.X = NPC.velocity.X - velocityMult; + if (NPC.velocity.X > 0f && playerXDist < 0f) { - NPC.velocity.X = NPC.velocity.X - num1165 * 2f; + NPC.velocity.X = NPC.velocity.X - velocityMult * 2f; } } - if (NPC.velocity.Y < num1167) + if (NPC.velocity.Y < playerYDist) { - NPC.velocity.Y = NPC.velocity.Y + num1165; - if (NPC.velocity.Y < 0f && num1167 > 0f) + NPC.velocity.Y = NPC.velocity.Y + velocityMult; + if (NPC.velocity.Y < 0f && playerYDist > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num1165 * 2f; + NPC.velocity.Y = NPC.velocity.Y + velocityMult * 2f; } } - else if (NPC.velocity.Y > num1167) + else if (NPC.velocity.Y > playerYDist) { - NPC.velocity.Y = NPC.velocity.Y - num1165; - if (NPC.velocity.Y > 0f && num1167 < 0f) + NPC.velocity.Y = NPC.velocity.Y - velocityMult; + if (NPC.velocity.Y > 0f && playerYDist < 0f) { - NPC.velocity.Y = NPC.velocity.Y - num1165 * 2f; + NPC.velocity.Y = NPC.velocity.Y - velocityMult * 2f; } } if (NPC.position.X + NPC.width > Main.player[NPC.target].position.X && NPC.position.X < Main.player[NPC.target].position.X + Main.player[NPC.target].width && NPC.position.Y + NPC.height < Main.player[NPC.target].position.Y && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && Main.netMode != NetmodeID.MultiplayerClient) @@ -124,12 +124,12 @@ namespace CalamityMod.NPCs.HiveMind if (NPC.ai[0] >= (Main.getGoodWorld ? 12f : 24f)) { NPC.ai[0] = 0f; - int num1169 = (int)(NPC.position.X + 10f + Main.rand.Next(NPC.width - 20)); - int num1170 = (int)(NPC.position.Y + NPC.height + 4f); + int shaderainXPos = (int)(NPC.position.X + 10f + Main.rand.Next(NPC.width - 20)); + int shaderainYos = (int)(NPC.position.Y + NPC.height + 4f); int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); float randomXVelocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? Main.rand.NextFloat() * 5f : 0f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), num1169, num1170, randomXVelocity, 4f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shaderainXPos, shaderainYos, randomXVelocity, 4f, type, damage, 0f, Main.myPlayer); } } } diff --git a/NPCs/HiveMind/HiveBlob.cs b/NPCs/HiveMind/HiveBlob.cs index 7eae50d146..f8799cd8c3 100644 --- a/NPCs/HiveMind/HiveBlob.cs +++ b/NPCs/HiveMind/HiveBlob.cs @@ -60,8 +60,8 @@ namespace CalamityMod.NPCs.HiveMind bool getFuckedAI = Main.zenithWorld; - int num750 = CalamityGlobalNPC.hiveMind; - if (num750 < 0 || !Main.npc[num750].active) + int hiveMind = CalamityGlobalNPC.hiveMind; + if (hiveMind < 0 || !Main.npc[hiveMind].active) { NPC.life = 0; NPC.HitEffect(); @@ -71,7 +71,7 @@ namespace CalamityMod.NPCs.HiveMind } if (NPC.ai[3] > 0f) - num750 = (int)NPC.ai[3] - 1; + hiveMind = (int)NPC.ai[3] - 1; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -88,45 +88,44 @@ namespace CalamityMod.NPCs.HiveMind NPC.TargetClosest(true); - float num751 = getFuckedAI ? 1.2f : death ? 0.8f : revenge ? 0.7f : expertMode ? 0.6f : 0.5f; - float num752 = Main.getGoodWorld ? 256f : 128f; - Vector2 vector22 = new Vector2(NPC.ai[0] * 16f + 8f, NPC.ai[1] * 16f + 8f); - float num189 = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2) - (NPC.width / 2) - vector22.X; - float num190 = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2) - (NPC.height / 2) - vector22.Y; - float num191 = (float)Math.Sqrt(num189 * num189 + num190 * num190); - float num754 = Main.npc[num750].position.X + (Main.npc[num750].width / 2); - float num755 = Main.npc[num750].position.Y + (Main.npc[num750].height / 2); - Vector2 vector93 = new Vector2(num754, num755); - float num756 = num754 + NPC.ai[0]; - float num757 = num755 + NPC.ai[1]; - float num758 = num756 - vector93.X; - float num759 = num757 - vector93.Y; - float num760 = (float)Math.Sqrt(num758 * num758 + num759 * num759); - num760 = num752 / num760; - num758 *= num760; - num759 *= num760; - if (NPC.position.X < num754 + num758) + float relocateSpeed = getFuckedAI ? 1.2f : death ? 0.8f : revenge ? 0.7f : expertMode ? 0.6f : 0.5f; + Vector2 randomLocationVector = new Vector2(NPC.ai[0] * 16f + 8f, NPC.ai[1] * 16f + 8f); + float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2) - (NPC.width / 2) - randomLocationVector.X; + float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2) - (NPC.height / 2) - randomLocationVector.Y; + float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); + float hiveMindX = Main.npc[hiveMind].position.X + (Main.npc[hiveMind].width / 2); + float hiveMindY = Main.npc[hiveMind].position.Y + (Main.npc[hiveMind].height / 2); + Vector2 hiveMindPos = new Vector2(hiveMindX, hiveMindY); + float randomPosX = hiveMindX + NPC.ai[0]; + float randomPosY = hiveMindY + NPC.ai[1]; + float finalRandPosX = randomPosX - hiveMindPos.X; + float finalRandPosY = randomPosY - hiveMindPos.Y; + float finalRandDistance = (float)Math.Sqrt(finalRandPosX * finalRandPosX + finalRandPosY * finalRandPosY); + finalRandDistance = (Main.getGoodWorld ? 256f : 128f) / finalRandDistance; + finalRandPosX *= finalRandDistance; + finalRandPosY *= finalRandDistance; + if (NPC.position.X < hiveMindX + finalRandPosX) { - NPC.velocity.X = NPC.velocity.X + num751; - if (NPC.velocity.X < 0f && num758 > 0f) + NPC.velocity.X = NPC.velocity.X + relocateSpeed; + if (NPC.velocity.X < 0f && finalRandPosX > 0f) NPC.velocity.X = NPC.velocity.X * 0.8f; } - else if (NPC.position.X > num754 + num758) + else if (NPC.position.X > hiveMindX + finalRandPosX) { - NPC.velocity.X = NPC.velocity.X - num751; - if (NPC.velocity.X > 0f && num758 < 0f) + NPC.velocity.X = NPC.velocity.X - relocateSpeed; + if (NPC.velocity.X > 0f && finalRandPosX < 0f) NPC.velocity.X = NPC.velocity.X * 0.8f; } - if (NPC.position.Y < num755 + num759) + if (NPC.position.Y < hiveMindY + finalRandPosY) { - NPC.velocity.Y = NPC.velocity.Y + num751; - if (NPC.velocity.Y < 0f && num759 > 0f) + NPC.velocity.Y = NPC.velocity.Y + relocateSpeed; + if (NPC.velocity.Y < 0f && finalRandPosY > 0f) NPC.velocity.Y = NPC.velocity.Y * 0.8f; } - else if (NPC.position.Y > num755 + num759) + else if (NPC.position.Y > hiveMindY + finalRandPosY) { - NPC.velocity.Y = NPC.velocity.Y - num751; - if (NPC.velocity.Y > 0f && num759 < 0f) + NPC.velocity.Y = NPC.velocity.Y - relocateSpeed; + if (NPC.velocity.Y > 0f && finalRandPosY < 0f) NPC.velocity.Y = NPC.velocity.Y * 0.8f; } @@ -152,26 +151,26 @@ namespace CalamityMod.NPCs.HiveMind NPC.TargetClosest(true); if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { - float num941 = death ? 5f : revenge ? 4.5f : expertMode ? 4f : 3.5f; + float projSpeed = death ? 5f : revenge ? 4.5f : expertMode ? 4f : 3.5f; if (Main.getGoodWorld) - num941 *= 2.4f; + projSpeed *= 2.4f; - Vector2 vector104 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + (NPC.height / 2)); - float num942 = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - vector104.X; - float num943 = Main.player[NPC.target].position.Y + Main.player[NPC.target].height * 0.5f - vector104.Y; - float num944 = (float)Math.Sqrt(num942 * num942 + num943 * num943); - num944 = num941 / num944; - num942 *= num944; - num943 *= num944; + Vector2 projDirection = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + (NPC.height / 2)); + float playerX = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - projDirection.X; + float playerY = Main.player[NPC.target].position.Y + Main.player[NPC.target].height * 0.5f - projDirection.Y; + float playerDist = (float)Math.Sqrt(playerX * playerX + playerY * playerY); + playerDist = projSpeed / playerDist; + playerX *= playerDist; + playerY *= playerDist; int type = (CalamityWorld.LegendaryMode && CalamityWorld.revenge && Main.rand.NextBool(5)) ? ProjectileID.CursedFlameHostile : ModContent.ProjectileType(); int damage = type == ProjectileID.CursedFlameHostile ? 30 : NPC.GetProjectileDamage(type); - Vector2 projectileVelocity = new Vector2(num942, num943); + Vector2 projectileVelocity = new Vector2(playerX, playerY); if (type == ProjectileID.CursedFlameHostile) { Vector2 v = Main.player[NPC.target].Center - NPC.Center - Main.player[NPC.target].velocity * 20f; - projectileVelocity = v.SafeNormalize(Vector2.UnitY) * num941; + projectileVelocity = v.SafeNormalize(Vector2.UnitY) * projSpeed; } - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector104, projectileVelocity, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), projDirection, projectileVelocity, type, damage, 0f, Main.myPlayer); NPC.netUpdate = true; } } diff --git a/NPCs/HiveMind/HiveBlob2.cs b/NPCs/HiveMind/HiveBlob2.cs index 62bcc4dc41..d03b7d9c41 100644 --- a/NPCs/HiveMind/HiveBlob2.cs +++ b/NPCs/HiveMind/HiveBlob2.cs @@ -62,8 +62,8 @@ namespace CalamityMod.NPCs.HiveMind bool getFuckedAI = Main.zenithWorld; - int num750 = CalamityGlobalNPC.hiveMind; - if (num750 < 0 || !Main.npc[num750].active) + int hiveMind = CalamityGlobalNPC.hiveMind; + if (hiveMind < 0 || !Main.npc[hiveMind].active) { NPC.life = 0; NPC.HitEffect(); @@ -73,7 +73,7 @@ namespace CalamityMod.NPCs.HiveMind } if (NPC.ai[3] > 0f) - num750 = (int)NPC.ai[3] - 1; + hiveMind = (int)NPC.ai[3] - 1; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -90,45 +90,44 @@ namespace CalamityMod.NPCs.HiveMind NPC.TargetClosest(true); - float num751 = getFuckedAI ? 1.2f : death ? 0.8f : revenge ? 0.7f : expertMode ? 0.6f : 0.5f; - float num752 = Main.getGoodWorld ? 192f : 96f; - Vector2 vector22 = new Vector2(NPC.ai[0] * 16f + 8f, NPC.ai[1] * 16f + 8f); - float num189 = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2) - (NPC.width / 2) - vector22.X; - float num190 = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2) - (NPC.height / 2) - vector22.Y; - float num191 = (float)Math.Sqrt(num189 * num189 + num190 * num190); - float num754 = Main.npc[num750].position.X + (Main.npc[num750].width / 2); - float num755 = Main.npc[num750].position.Y + (Main.npc[num750].height / 2); - Vector2 vector93 = new Vector2(num754, num755); - float num756 = num754 + NPC.ai[0]; - float num757 = num755 + NPC.ai[1]; - float num758 = num756 - vector93.X; - float num759 = num757 - vector93.Y; - float num760 = (float)Math.Sqrt(num758 * num758 + num759 * num759); - num760 = num752 / num760; - num758 *= num760; - num759 *= num760; - if (NPC.position.X < num754 + num758) + float relocateSpeed = getFuckedAI ? 1.2f : death ? 0.8f : revenge ? 0.7f : expertMode ? 0.6f : 0.5f; + Vector2 randomRelocateVector = new Vector2(NPC.ai[0] * 16f + 8f, NPC.ai[1] * 16f + 8f); + float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2) - (NPC.width / 2) - randomRelocateVector.X; + float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2) - (NPC.height / 2) - randomRelocateVector.Y; + float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); + float hiveMindX = Main.npc[hiveMind].position.X + (Main.npc[hiveMind].width / 2); + float hiveMindY = Main.npc[hiveMind].position.Y + (Main.npc[hiveMind].height / 2); + Vector2 hiveMindPos = new Vector2(hiveMindX, hiveMindY); + float randomPosX = hiveMindX + NPC.ai[0]; + float randomPosY = hiveMindY + NPC.ai[1]; + float finalRandPosX = randomPosX - hiveMindPos.X; + float finalRandPosY = randomPosY - hiveMindPos.Y; + float finalRandDistance = (float)Math.Sqrt(finalRandPosX * finalRandPosX + finalRandPosY * finalRandPosY); + finalRandDistance = (Main.getGoodWorld ? 192f : 96f) / finalRandDistance; + finalRandPosX *= finalRandDistance; + finalRandPosY *= finalRandDistance; + if (NPC.position.X < hiveMindX + finalRandPosX) { - NPC.velocity.X = NPC.velocity.X + num751; - if (NPC.velocity.X < 0f && num758 > 0f) + NPC.velocity.X = NPC.velocity.X + relocateSpeed; + if (NPC.velocity.X < 0f && finalRandPosX > 0f) NPC.velocity.X = NPC.velocity.X * 0.8f; } - else if (NPC.position.X > num754 + num758) + else if (NPC.position.X > hiveMindX + finalRandPosX) { - NPC.velocity.X = NPC.velocity.X - num751; - if (NPC.velocity.X > 0f && num758 < 0f) + NPC.velocity.X = NPC.velocity.X - relocateSpeed; + if (NPC.velocity.X > 0f && finalRandPosX < 0f) NPC.velocity.X = NPC.velocity.X * 0.8f; } - if (NPC.position.Y < num755 + num759) + if (NPC.position.Y < hiveMindY + finalRandPosY) { - NPC.velocity.Y = NPC.velocity.Y + num751; - if (NPC.velocity.Y < 0f && num759 > 0f) + NPC.velocity.Y = NPC.velocity.Y + relocateSpeed; + if (NPC.velocity.Y < 0f && finalRandPosY > 0f) NPC.velocity.Y = NPC.velocity.Y * 0.8f; } - else if (NPC.position.Y > num755 + num759) + else if (NPC.position.Y > hiveMindY + finalRandPosY) { - NPC.velocity.Y = NPC.velocity.Y - num751; - if (NPC.velocity.Y > 0f && num759 < 0f) + NPC.velocity.Y = NPC.velocity.Y - relocateSpeed; + if (NPC.velocity.Y > 0f && finalRandPosY < 0f) NPC.velocity.Y = NPC.velocity.Y * 0.8f; } @@ -154,26 +153,26 @@ namespace CalamityMod.NPCs.HiveMind NPC.TargetClosest(true); if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { - float num941 = death ? 5f : revenge ? 4.5f : expertMode ? 4f : 3.5f; + float projSpeed = death ? 5f : revenge ? 4.5f : expertMode ? 4f : 3.5f; if (Main.getGoodWorld) - num941 *= 2.4f; + projSpeed *= 2.4f; - Vector2 vector104 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + (NPC.height / 2)); - float num942 = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - vector104.X; - float num943 = Main.player[NPC.target].position.Y + Main.player[NPC.target].height * 0.5f - vector104.Y; - float num944 = (float)Math.Sqrt(num942 * num942 + num943 * num943); - num944 = num941 / num944; - num942 *= num944; - num943 *= num944; + Vector2 projDirection = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + (NPC.height / 2)); + float playerX = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - projDirection.X; + float playerY = Main.player[NPC.target].position.Y + Main.player[NPC.target].height * 0.5f - projDirection.Y; + float playerDist = (float)Math.Sqrt(playerX * playerX + playerY * playerY); + playerDist = projSpeed / playerDist; + playerX *= playerDist; + playerY *= playerDist; int type = (CalamityWorld.LegendaryMode && CalamityWorld.revenge && Main.rand.NextBool(5)) ? ProjectileID.CursedFlameHostile : ModContent.ProjectileType(); int damage = type == ProjectileID.CursedFlameHostile ? 30 : NPC.GetProjectileDamage(type); - Vector2 projectileVelocity = new Vector2(num942, num943); + Vector2 projectileVelocity = new Vector2(playerX, playerY); if (type == ProjectileID.CursedFlameHostile) { Vector2 v = Main.player[NPC.target].Center - NPC.Center - Main.player[NPC.target].velocity * 20f; - projectileVelocity = v.SafeNormalize(Vector2.UnitY) * num941; + projectileVelocity = v.SafeNormalize(Vector2.UnitY) * projSpeed; } - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector104, projectileVelocity, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), projDirection, projectileVelocity, type, damage, 0f, Main.myPlayer); NPC.netUpdate = true; } } diff --git a/NPCs/HiveMind/HiveMind.cs b/NPCs/HiveMind/HiveMind.cs index 7741feb9ba..0d711521f0 100644 --- a/NPCs/HiveMind/HiveMind.cs +++ b/NPCs/HiveMind/HiveMind.cs @@ -93,7 +93,7 @@ namespace CalamityMod.NPCs.HiveMind NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.TrailCacheLength[NPC.type] = NPC.oldPos.Length; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.4f, PortraitPositionYOverride = 3f @@ -526,15 +526,15 @@ namespace CalamityMod.NPCs.HiveMind { if (Main.netMode != NetmodeID.MultiplayerClient) { - int num660 = (int)(NPC.lifeMax * 0.05); - if ((NPC.life + num660) < NPC.ai[3]) + int fivePercentHP = (int)(NPC.lifeMax * 0.05); + if ((NPC.life + fivePercentHP) < NPC.ai[3]) { NPC.ai[3] = NPC.life; int maxSpawns = bossRush ? 10 : death ? 5 : revenge ? 4 : expertMode ? Main.rand.Next(3, 5) : Main.rand.Next(2, 4); int maxDankSpawns = bossRush ? 4 : death ? Main.rand.Next(2, 4) : revenge ? 2 : expertMode ? Main.rand.Next(1, 3) : 1; - for (int num662 = 0; num662 < maxSpawns; num662++) + for (int i = 0; i < maxSpawns; i++) { int x = (int)(NPC.position.X + Main.rand.Next(NPC.width - 32)); int y = (int)(NPC.position.Y + Main.rand.Next(NPC.height - 32)); @@ -543,10 +543,10 @@ namespace CalamityMod.NPCs.HiveMind if (NPC.CountNPCS(ModContent.NPCType()) < maxDankSpawns) type = ModContent.NPCType(); - int num664 = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, type); - Main.npc[num664].SetDefaults(type); - if (Main.netMode == NetmodeID.Server && num664 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0); + int fivePercentMinions = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, type); + Main.npc[fivePercentMinions].SetDefaults(type); + if (Main.netMode == NetmodeID.Server && fivePercentMinions < Main.maxNPCs) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, fivePercentMinions, 0f, 0f, 0f, 0, 0, 0); } return; @@ -571,21 +571,21 @@ namespace CalamityMod.NPCs.HiveMind NPC.scale += 0.0165f; NPC.alpha -= 4; - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.Center.Y), NPC.width, NPC.height / 2, 14, 0f, -3f, 100, default, 2.5f * NPC.scale); - Main.dust[num622].velocity *= 2f; + int burrowedDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.Center.Y), NPC.width, NPC.height / 2, 14, 0f, -3f, 100, default, 2.5f * NPC.scale); + Main.dust[burrowedDust].velocity *= 2f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[burrowedDust].scale = 0.5f; + Main.dust[burrowedDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } for (int i = 0; i < 2; i++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.Center.Y), NPC.width, NPC.height / 2, 14, 0f, -3f, 100, default, 3.5f * NPC.scale); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 3.5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.Center.Y), NPC.width, NPC.height / 2, 14, 0f, -3f, 100, default, 2.5f * NPC.scale); - Main.dust[num624].velocity *= 1f; + int burrowedDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.Center.Y), NPC.width, NPC.height / 2, 14, 0f, -3f, 100, default, 3.5f * NPC.scale); + Main.dust[burrowedDust2].noGravity = true; + Main.dust[burrowedDust2].velocity *= 3.5f; + burrowedDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.Center.Y), NPC.width, NPC.height / 2, 14, 0f, -3f, 100, default, 2.5f * NPC.scale); + Main.dust[burrowedDust2].velocity *= 1f; } } else if (burrowTimer == -60) @@ -605,27 +605,28 @@ namespace CalamityMod.NPCs.HiveMind } } NPC.netUpdate = true; + NPC.netSpam = 0; } else if (burrowTimer < 0) { NPC.scale -= 0.0165f; NPC.alpha += 4; - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.Center.Y), NPC.width, NPC.height / 2, 14, 0f, -3f, 100, default, 2.5f * NPC.scale); - Main.dust[num622].velocity *= 2f; + int burrowedDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.Center.Y), NPC.width, NPC.height / 2, 14, 0f, -3f, 100, default, 2.5f * NPC.scale); + Main.dust[burrowedDust].velocity *= 2f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[burrowedDust].scale = 0.5f; + Main.dust[burrowedDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } for (int i = 0; i < 2; i++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.Center.Y), NPC.width, NPC.height / 2, 14, 0f, -3f, 100, default, 3.5f * NPC.scale); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 3.5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.Center.Y), NPC.width, NPC.height / 2, 14, 0f, -3f, 100, default, 2.5f * NPC.scale); - Main.dust[num624].velocity *= 1f; + int burrowedDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.Center.Y), NPC.width, NPC.height / 2, 14, 0f, -3f, 100, default, 3.5f * NPC.scale); + Main.dust[burrowedDust2].noGravity = true; + Main.dust[burrowedDust2].velocity *= 3.5f; + burrowedDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.Center.Y), NPC.width, NPC.height / 2, 14, 0f, -3f, 100, default, 2.5f * NPC.scale); + Main.dust[burrowedDust2].velocity *= 1f; } } else if (burrowTimer == 0) @@ -714,6 +715,7 @@ namespace CalamityMod.NPCs.HiveMind rotation = MathHelper.ToRadians(Main.rand.Next(360)); NPC.netUpdate = true; + NPC.netSpam = 0; } if (!player.active || player.dead || Vector2.Distance(NPC.Center, player.Center) > 5000f) @@ -751,6 +753,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.velocity *= 2f / 255f * (reelbackFade + 2 * (int)enrageScale); ReelBack(); NPC.netUpdate = true; + NPC.netSpam = 0; } else { @@ -782,6 +785,7 @@ namespace CalamityMod.NPCs.HiveMind phase2timer = minimumDriftTime + Main.rand.Next(121); NPC.netUpdate = true; + NPC.netSpam = 0; } else if (NPC.ai[1] == 0f && NPC.ai[2] == 0f) { @@ -794,6 +798,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.ai[1] = posX; NPC.ai[2] = posY; NPC.netUpdate = true; + NPC.netSpam = 0; break; } } @@ -834,6 +839,7 @@ namespace CalamityMod.NPCs.HiveMind case 3: // Lunge NPC.netUpdate = true; + NPC.netSpam = 0; if (NPC.alpha > 0) { NPC.alpha -= lungeFade; @@ -890,6 +896,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.position.Y += teleportRadius; } NPC.netUpdate = true; + NPC.netSpam = 0; } else { @@ -900,6 +907,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.velocity.X = MathHelper.Pi * teleportRadius / arcTime; NPC.velocity *= rotationDirection; NPC.netUpdate = true; + NPC.netSpam = 0; } else { @@ -947,6 +955,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.position.X += teleportRadius * rotationDirection; } NPC.netUpdate = true; + NPC.netSpam = 0; } else { @@ -957,6 +966,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.velocity.X = teleportRadius / arcTime * 3; NPC.velocity *= -rotationDirection; NPC.netUpdate = true; + NPC.netSpam = 0; } else { @@ -995,6 +1005,7 @@ namespace CalamityMod.NPCs.HiveMind phase2timer = minimumDriftTime + Main.rand.Next(121); state = 0; NPC.netUpdate = true; + NPC.netSpam = 0; } break; @@ -1008,18 +1019,18 @@ namespace CalamityMod.NPCs.HiveMind { Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= 60f && NPC.alpha == 0 && NPC.scale == 1f; // No damage while not fully visible or shrunk } @@ -1033,6 +1044,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.velocity *= -4f; ReelBack(); NPC.netUpdate = true; + NPC.netSpam = 0; } } @@ -1091,23 +1103,23 @@ namespace CalamityMod.NPCs.HiveMind NPC.height = 150; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 14, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int killDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 14, 0f, 0f, 100, default, 2f); + Main.dust[killDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[killDust].scale = 0.5f; + Main.dust[killDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 14, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 14, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int killDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 14, 0f, 0f, 100, default, 3f); + Main.dust[killDust2].noGravity = true; + Main.dust[killDust2].velocity *= 5f; + killDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 14, 0f, 0f, 100, default, 2f); + Main.dust[killDust2].velocity *= 2f; } } } @@ -1178,11 +1190,11 @@ namespace CalamityMod.NPCs.HiveMind // GFB class emblem drops var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ItemID.WarriorEmblem); - GFBOnly.Add(ItemID.RangerEmblem); - GFBOnly.Add(ItemID.SorcererEmblem); - GFBOnly.Add(ItemID.SummonerEmblem); - GFBOnly.Add(ModContent.ItemType()); + GFBOnly.Add(ItemID.WarriorEmblem, hideLootReport: true); + GFBOnly.Add(ItemID.RangerEmblem, hideLootReport: true); + GFBOnly.Add(ItemID.SorcererEmblem, hideLootReport: true); + GFBOnly.Add(ItemID.SummonerEmblem, hideLootReport: true); + GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); } // Lore diff --git a/NPCs/Leviathan/Anahita.cs b/NPCs/Leviathan/Anahita.cs index 17e7389046..6007a3c6b1 100644 --- a/NPCs/Leviathan/Anahita.cs +++ b/NPCs/Leviathan/Anahita.cs @@ -41,7 +41,7 @@ namespace CalamityMod.NPCs.Leviathan { Main.npcFrameCount[NPC.type] = 6; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.5f }; @@ -248,17 +248,17 @@ namespace CalamityMod.NPCs.Leviathan { if (NPC.ai[3] == 0f && NPC.localAI[1] == 0f && Main.netMode != NetmodeID.MultiplayerClient) { - int num6 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType(), NPC.whoAmI); - NPC.ai[3] = num6 + 1; + int iceShieldSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType(), NPC.whoAmI); + NPC.ai[3] = iceShieldSpawn + 1; NPC.localAI[1] = -1f; NPC.localAI[2] += 1f; NPC.netUpdate = true; - Main.npc[num6].ai[0] = NPC.whoAmI; - Main.npc[num6].netUpdate = true; + Main.npc[iceShieldSpawn].ai[0] = NPC.whoAmI; + Main.npc[iceShieldSpawn].netUpdate = true; } - int num7 = (int)NPC.ai[3] - 1; - if (num7 != -1 && Main.npc[num7].active && Main.npc[num7].type == ModContent.NPCType()) + int iceShieldCheck = (int)NPC.ai[3] - 1; + if (iceShieldCheck != -1 && Main.npc[iceShieldCheck].active && Main.npc[iceShieldCheck].type == ModContent.NPCType()) NPC.dontTakeDamage = true; else { @@ -287,8 +287,8 @@ namespace CalamityMod.NPCs.Leviathan { NPC.dontTakeDamage = false; - int num7 = (int)NPC.ai[3] - 1; - if (num7 != -1 && Main.npc[num7].active && Main.npc[num7].type == ModContent.NPCType()) + int iceShieldCheck = (int)NPC.ai[3] - 1; + if (iceShieldCheck != -1 && Main.npc[iceShieldCheck].active && Main.npc[iceShieldCheck].type == ModContent.NPCType()) NPC.dontTakeDamage = true; } @@ -395,11 +395,11 @@ namespace CalamityMod.NPCs.Leviathan if (NPC.ai[0] == -1f) { int random = ((phase2 && expertMode && !leviAlive) || phase4 || death) ? 4 : 3; - int num618; - do num618 = Main.rand.Next(random); - while (num618 == NPC.ai[1] || num618 == 1); + int nextAttack; + do nextAttack = Main.rand.Next(random); + while (nextAttack == NPC.ai[1] || nextAttack == 1); - NPC.ai[0] = num618; + NPC.ai[0] = nextAttack; if (NPC.ai[0] != 3f) { @@ -422,13 +422,13 @@ namespace CalamityMod.NPCs.Leviathan NPC.rotation = NPC.velocity.X * 0.02f; NPC.spriteDirection = NPC.direction; - Vector2 vector118 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num1055 = player.position.X + (player.width / 2) - vector118.X; - float num1056 = player.position.Y + (player.height / 2) - 200f * NPC.scale - vector118.Y; - float num1057 = (float)Math.Sqrt(num1055 * num1055 + num1056 * num1056); + Vector2 anahitaPos = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float playerXDist = player.position.X + (player.width / 2) - anahitaPos.X; + float playerYDist = player.position.Y + (player.height / 2) - 200f * NPC.scale - anahitaPos.Y; + float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); NPC.Calamity().newAI[0] += 1f; - if (num1057 < 600f * NPC.scale || NPC.Calamity().newAI[0] >= 180f) + if (playerDistance < 600f * NPC.scale || NPC.Calamity().newAI[0] >= 180f) { NPC.ai[0] = 1f; NPC.ai[1] = 0f; @@ -482,41 +482,41 @@ namespace CalamityMod.NPCs.Leviathan else if (NPC.ai[0] == 1f) { NPC.rotation = NPC.velocity.X * 0.02f; - Vector2 vector119 = new Vector2(NPC.position.X + (NPC.width / 2) + (15 * NPC.direction * NPC.scale), NPC.position.Y + 30 * NPC.scale); - Vector2 vector120 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num1058 = player.position.X + (player.width / 2) - vector120.X; - float num1059 = player.position.Y + (player.height / 2) - vector120.Y; - float num1060 = (float)Math.Sqrt(num1058 * num1058 + num1059 * num1059); + Vector2 bubbleSpawnPos = new Vector2(NPC.position.X + (NPC.width / 2) + (15 * NPC.direction * NPC.scale), NPC.position.Y + 30 * NPC.scale); + Vector2 restingPos = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float restingPlayerXDist = player.position.X + (player.width / 2) - restingPos.X; + float restingPlayerYDist = player.position.Y + (player.height / 2) - restingPos.Y; + float restingPlayerDistance = (float)Math.Sqrt(restingPlayerXDist * restingPlayerXDist + restingPlayerYDist * restingPlayerYDist); NPC.ai[1] += 1f; - int num638 = 0; - for (int num639 = 0; num639 < 255; num639++) + int activePlayerAmt = 0; + for (int i = 0; i < 255; i++) { - if (Main.player[num639].active && !Main.player[num639].dead && (vector - Main.player[num639].Center).Length() < 1000f) - num638++; + if (Main.player[i].active && !Main.player[i].dead && (vector - Main.player[i].Center).Length() < 1000f) + activePlayerAmt++; } - NPC.ai[1] += num638 / 2; + NPC.ai[1] += activePlayerAmt / 2; - bool flag103 = false; - float num640 = 20f; + bool spawnedBubble = false; + float bubbleDelay = 20f; if (!leviAlive || phase4) - num640 -= death ? 15f * (1f - lifeRatio) : 12f * (1f - lifeRatio); + bubbleDelay -= death ? 15f * (1f - lifeRatio) : 12f * (1f - lifeRatio); - if (NPC.ai[1] > num640) + if (NPC.ai[1] > bubbleDelay) { NPC.ai[1] = 0f; NPC.ai[2] += 1f; - flag103 = true; + spawnedBubble = true; } - if (Collision.CanHit(vector119, 1, 1, player.position, player.width, player.height) && flag103) + if (Collision.CanHit(bubbleSpawnPos, 1, 1, player.position, player.width, player.height) && spawnedBubble) { SoundEngine.PlaySound(SoundID.Item85, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - int spawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)vector119.X, (int)vector119.Y, NPCID.DetonatingBubble); + int spawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)bubbleSpawnPos.X, (int)bubbleSpawnPos.Y, NPCID.DetonatingBubble); Main.npc[spawn].target = NPC.target; - Main.npc[spawn].velocity = player.Center - vector119; + Main.npc[spawn].velocity = player.Center - bubbleSpawnPos; Main.npc[spawn].velocity.Normalize(); Main.npc[spawn].velocity *= bubbleVelocity; Main.npc[spawn].netUpdate = true; @@ -524,7 +524,7 @@ namespace CalamityMod.NPCs.Leviathan } } - if (num1060 > 600f * NPC.scale) + if (restingPlayerDistance > 600f * NPC.scale) { float maxVelocityY = death ? 3f : 4f; float maxVelocityX = death ? 7f : 8f; @@ -594,7 +594,7 @@ namespace CalamityMod.NPCs.Leviathan if (Main.getGoodWorld) velocity *= 1.15f; - Vector2 vector3 = Vector2.Normalize(targetVector - vector - NPC.velocity) * velocity; + Vector2 chargeSetupLocation = Vector2.Normalize(targetVector - vector - NPC.velocity) * velocity; float acceleration = death ? 0.28f : 0.25f; acceleration += 0.2f * enrageScale; @@ -602,7 +602,7 @@ namespace CalamityMod.NPCs.Leviathan acceleration *= 1.15f; if (Math.Abs(NPC.Center.Y - targetVector.Y) > 50f * NPC.scale || Math.Abs(NPC.Center.X - player.Center.X) > 350f * NPC.scale) - NPC.SimpleFlyMovement(vector3, acceleration); + NPC.SimpleFlyMovement(chargeSetupLocation, acceleration); NPC.ai[1] += 1f; @@ -742,10 +742,10 @@ namespace CalamityMod.NPCs.Leviathan NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); // Direction - int num22 = Math.Sign(player.Center.X - vector.X); - if (num22 != 0) + int chargeDirection = Math.Sign(player.Center.X - vector.X); + if (chargeDirection != 0) { - NPC.direction = num22; + NPC.direction = chargeDirection; if (NPC.spriteDirection == 1) NPC.rotation += MathHelper.Pi; @@ -764,12 +764,12 @@ namespace CalamityMod.NPCs.Leviathan if (CalamityWorld.LegendaryMode && CalamityWorld.revenge && NPC.ai[1] % 5f == 0f) { SoundEngine.PlaySound(SoundID.Item85, NPC.Center); - Vector2 vector119 = new Vector2(NPC.position.X + (NPC.width / 2) + (15 * NPC.direction * NPC.scale), NPC.position.Y + 30 * NPC.scale); + Vector2 bubbleSpawnPos = new Vector2(NPC.position.X + (NPC.width / 2) + (15 * NPC.direction * NPC.scale), NPC.position.Y + 30 * NPC.scale); if (Main.netMode != NetmodeID.MultiplayerClient) { - int spawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)vector119.X, (int)vector119.Y, NPCID.DetonatingBubble); + int spawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)bubbleSpawnPos.X, (int)bubbleSpawnPos.Y, NPCID.DetonatingBubble); Main.npc[spawn].target = NPC.target; - Main.npc[spawn].velocity = player.Center - vector119; + Main.npc[spawn].velocity = player.Center - bubbleSpawnPos; Main.npc[spawn].velocity.Normalize(); Main.npc[spawn].velocity *= bubbleVelocity; Main.npc[spawn].netUpdate = true; @@ -778,16 +778,16 @@ namespace CalamityMod.NPCs.Leviathan } // Spawn dust - int num24 = 7; - for (int j = 0; j < num24; j++) + int dustAmt = 7; + for (int j = 0; j < dustAmt; j++) { - Vector2 arg_E1C_0 = (Vector2.Normalize(NPC.velocity) * new Vector2((NPC.width + 50) / 2f, NPC.height) * 0.75f).RotatedBy((j - (num24 / 2 - 1)) * MathHelper.Pi / num24) + vector; + Vector2 arg_E1C_0 = (Vector2.Normalize(NPC.velocity) * new Vector2((NPC.width + 50) / 2f, NPC.height) * 0.75f).RotatedBy((j - (dustAmt / 2 - 1)) * MathHelper.Pi / dustAmt) + vector; Vector2 vector4 = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num25 = Dust.NewDust(arg_E1C_0 + vector4, 0, 0, 172, vector4.X * 2f, vector4.Y * 2f, 100, default, 1.4f); - Main.dust[num25].noGravity = true; - Main.dust[num25].noLight = true; - Main.dust[num25].velocity /= 4f; - Main.dust[num25].velocity -= NPC.velocity; + int waterDust = Dust.NewDust(arg_E1C_0 + vector4, 0, 0, 172, vector4.X * 2f, vector4.Y * 2f, 100, default, 1.4f); + Main.dust[waterDust].noGravity = true; + Main.dust[waterDust].noLight = true; + Main.dust[waterDust].velocity /= 4f; + Main.dust[waterDust].velocity -= NPC.velocity; } NPC.ai[1] += 1f; @@ -804,20 +804,20 @@ namespace CalamityMod.NPCs.Leviathan // Rotation when charging private void ChargeRotation(Player player, Vector2 vector) { - float num17 = (float)Math.Atan2(player.Center.Y - vector.Y, player.Center.X - vector.X); + float playerDirection = (float)Math.Atan2(player.Center.Y - vector.Y, player.Center.X - vector.X); if (NPC.spriteDirection == 1) - num17 += MathHelper.Pi; - if (num17 < 0f) - num17 += MathHelper.TwoPi; - if (num17 > MathHelper.TwoPi) - num17 -= MathHelper.TwoPi; + playerDirection += MathHelper.Pi; + if (playerDirection < 0f) + playerDirection += MathHelper.TwoPi; + if (playerDirection > MathHelper.TwoPi) + playerDirection -= MathHelper.TwoPi; - float num18 = 0.04f; + float rotationSpeed = 0.04f; if (NPC.ai[0] == 4f) - num18 = 0f; + rotationSpeed = 0f; - if (num18 != 0f) - NPC.rotation = NPC.rotation.AngleTowards(num17, num18); + if (rotationSpeed != 0f) + NPC.rotation = NPC.rotation.AngleTowards(playerDirection, rotationSpeed); } // Move to charge location @@ -829,21 +829,21 @@ namespace CalamityMod.NPCs.Leviathan if (NPC.localAI[0] == 0f) NPC.localAI[0] = (int)distance * Math.Sign((vector - player.Center).X); - Vector2 vector3 = Vector2.Normalize(player.Center + new Vector2(NPC.localAI[0], -distance) - vector - NPC.velocity) * 12f; + Vector2 chargeSetupLocation = Vector2.Normalize(player.Center + new Vector2(NPC.localAI[0], -distance) - vector - NPC.velocity) * 12f; float acceleration = revenge ? 0.75f : 0.5f; if (Main.getGoodWorld) acceleration *= 1.15f; - NPC.SimpleFlyMovement(vector3, acceleration); + NPC.SimpleFlyMovement(chargeSetupLocation, acceleration); // Rotation - int num22 = Math.Sign(player.Center.X - vector.X); - if (num22 != 0) + int chargeDirection = Math.Sign(player.Center.X - vector.X); + if (chargeDirection != 0) { - if (NPC.ai[1] == 0f && num22 != NPC.direction) + if (NPC.ai[1] == 0f && chargeDirection != NPC.direction) NPC.rotation += MathHelper.Pi; - NPC.direction = num22; + NPC.direction = chargeDirection; if (NPC.spriteDirection != -NPC.direction) NPC.rotation += MathHelper.Pi; diff --git a/NPCs/Leviathan/AnahitasIceShield.cs b/NPCs/Leviathan/AnahitasIceShield.cs index eebcf5f608..d919bf4115 100644 --- a/NPCs/Leviathan/AnahitasIceShield.cs +++ b/NPCs/Leviathan/AnahitasIceShield.cs @@ -56,28 +56,28 @@ namespace CalamityMod.NPCs.Leviathan public override void AI() { - int num989 = (int)NPC.ai[0]; - if (Main.npc[num989].active && Main.npc[num989].type == ModContent.NPCType()) + int anahitaID = (int)NPC.ai[0]; + if (Main.npc[anahitaID].active && Main.npc[anahitaID].type == ModContent.NPCType()) { if (NPC.alpha > 100 && NPC.ai[1] == 0f) NPC.alpha -= 2; - if (Main.npc[num989].damage == 0) + if (Main.npc[anahitaID].damage == 0) NPC.ai[1] = 1f; else NPC.ai[1] = 0f; if (NPC.ai[1] == 1f) - NPC.alpha = Main.npc[num989].alpha; + NPC.alpha = Main.npc[anahitaID].alpha; - NPC.dontTakeDamage = Main.npc[num989].damage == 0; - NPC.rotation = Main.npc[num989].rotation; - NPC.spriteDirection = Main.npc[num989].direction; + NPC.dontTakeDamage = Main.npc[anahitaID].damage == 0; + NPC.rotation = Main.npc[anahitaID].rotation; + NPC.spriteDirection = Main.npc[anahitaID].direction; NPC.velocity = Vector2.Zero; - NPC.position = Main.npc[num989].Center; + NPC.position = Main.npc[anahitaID].Center; NPC.position.X = NPC.position.X - (NPC.width / 2) + ((NPC.spriteDirection == 1) ? -20f : 20f) * NPC.scale; NPC.position.Y = NPC.position.Y - (NPC.height / 2) - (int)(30 * NPC.scale); - NPC.gfxOffY = Main.npc[num989].gfxOffY; + NPC.gfxOffY = Main.npc[anahitaID].gfxOffY; Lighting.AddLight((int)NPC.Center.X / 16, (int)NPC.Center.Y / 16, 0f, 0.8f, 1.1f); return; } @@ -89,21 +89,6 @@ namespace CalamityMod.NPCs.Leviathan NPC.netUpdate = true; } - public override void ModifyHitByProjectile(Projectile projectile, ref NPC.HitModifiers modifiers) - { - if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => projectile.type != x)) - { - if (projectile.penetrate == -1 && !projectile.minion) - { - projectile.penetrate = 1; - } - else if (projectile.penetrate >= 1) - { - projectile.penetrate = 1; - } - } - } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) => NPC.ai[1] == 0f; public override Color? GetAlpha(Color drawColor) => NPC.ai[1] == 1f ? Color.Transparent : new Color(200, 200, 200, drawColor.A) * NPC.Opacity; @@ -116,6 +101,8 @@ namespace CalamityMod.NPCs.Leviathan target.AddBuff(BuffID.Frostburn, 240, true); } + public override bool CheckActive() => false; + public override void HitEffect(NPC.HitInfo hit) { for (int k = 0; k < 5; k++) diff --git a/NPCs/Leviathan/AquaticAberration.cs b/NPCs/Leviathan/AquaticAberration.cs index ed9a2a9998..4d238e6259 100644 --- a/NPCs/Leviathan/AquaticAberration.cs +++ b/NPCs/Leviathan/AquaticAberration.cs @@ -17,7 +17,7 @@ namespace CalamityMod.NPCs.Leviathan { Main.npcFrameCount[NPC.type] = 7; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0); value.Position.X += 25; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; } @@ -123,32 +123,30 @@ namespace CalamityMod.NPCs.Leviathan if (!sirenAlive || leviathanInPhase4) inertia *= 0.75f; - float num1006 = 0.111111117f * inertia; if (NPC.ai[0] == 0f) { - float scaleFactor6 = bossRush ? 14f : death ? 12f : revenge ? 11f : expertMode ? 10f : 8f; + float lungeSpeed = bossRush ? 14f : death ? 12f : revenge ? 11f : expertMode ? 10f : 8f; if (!sirenAlive || leviathanInPhase4) - scaleFactor6 *= 1.25f; + lungeSpeed *= 1.25f; - Vector2 center4 = NPC.Center; - Vector2 center5 = Main.player[NPC.target].Center; - Vector2 vector126 = center5 - center4; - Vector2 vector127 = vector126 - Vector2.UnitY * 300f * NPC.scale; - float num1013 = vector126.Length(); - vector126 = Vector2.Normalize(vector126) * scaleFactor6; - vector127 = Vector2.Normalize(vector127) * scaleFactor6; - bool flag64 = Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1); + Vector2 npcCenter = NPC.Center; + Vector2 targetCenter = Main.player[NPC.target].Center; + Vector2 targetDirection = targetCenter - npcCenter; + Vector2 beginLungeYDist = targetDirection - Vector2.UnitY * 300f * NPC.scale; + float targetDist = targetDirection.Length(); + targetDirection = Vector2.Normalize(targetDirection) * lungeSpeed; + beginLungeYDist = Vector2.Normalize(beginLungeYDist) * lungeSpeed; + bool canHitPlayer = Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1); if (NPC.ai[3] >= 120f) { - flag64 = true; + canHitPlayer = true; } - float num1014 = 8f; - flag64 = flag64 && vector126.ToRotation() > MathHelper.Pi / num1014 && vector126.ToRotation() < MathHelper.Pi - MathHelper.Pi / num1014; - if (num1013 > 800f * NPC.scale || !flag64) + canHitPlayer = canHitPlayer && targetDirection.ToRotation() > MathHelper.Pi / 8f && targetDirection.ToRotation() < MathHelper.Pi - MathHelper.Pi / 8f; + if (targetDist > 800f * NPC.scale || !canHitPlayer) { - NPC.velocity.X = (NPC.velocity.X * (inertia - 1f) + vector127.X) / inertia; - NPC.velocity.Y = (NPC.velocity.Y * (inertia - 1f) + vector127.Y) / inertia; - if (!flag64) + NPC.velocity.X = (NPC.velocity.X * (inertia - 1f) + beginLungeYDist.X) / inertia; + NPC.velocity.Y = (NPC.velocity.Y * (inertia - 1f) + beginLungeYDist.Y) / inertia; + if (!canHitPlayer) { NPC.ai[3] += 1f; if (NPC.ai[3] == 120f) @@ -164,8 +162,8 @@ namespace CalamityMod.NPCs.Leviathan else { NPC.ai[0] = 1f; - NPC.ai[2] = vector126.X; - NPC.ai[3] = vector126.Y; + NPC.ai[2] = targetDirection.X; + NPC.ai[3] = targetDirection.Y; NPC.netUpdate = true; } } @@ -187,8 +185,8 @@ namespace CalamityMod.NPCs.Leviathan else if (NPC.ai[0] == 2f) { NPC.ai[1] += 1f; - bool flag65 = NPC.Center.Y + 50f > Main.player[NPC.target].Center.Y; - if ((NPC.ai[1] >= 90f && flag65) || NPC.velocity.Length() < ((!sirenAlive || leviathanInPhase4) ? 10f : 8f)) + bool doLunge = NPC.Center.Y + 50f > Main.player[NPC.target].Center.Y; + if ((NPC.ai[1] >= 90f && doLunge) || NPC.velocity.Length() < ((!sirenAlive || leviathanInPhase4) ? 10f : 8f)) { NPC.ai[0] = 3f; NPC.ai[1] = 45f; @@ -199,15 +197,15 @@ namespace CalamityMod.NPCs.Leviathan } else { - Vector2 center6 = NPC.Center; - Vector2 center7 = Main.player[NPC.target].Center; - Vector2 vec2 = center7 - center6; + Vector2 npcCenterAgain = NPC.Center; + Vector2 targetCenterAgain = Main.player[NPC.target].Center; + Vector2 vec2 = targetCenterAgain - npcCenterAgain; vec2.Normalize(); if (vec2.HasNaNs()) { vec2 = new Vector2((float)NPC.direction, 0f); } - NPC.velocity = (NPC.velocity * (inertia - 1f) + vec2 * (NPC.velocity.Length() + num1006)) / inertia; + NPC.velocity = (NPC.velocity * (inertia - 1f) + vec2 * (NPC.velocity.Length() + (0.111111117f * inertia))) / inertia; } } else if (NPC.ai[0] == 3f) diff --git a/NPCs/Leviathan/Leviathan.cs b/NPCs/Leviathan/Leviathan.cs index 374621600d..79137af19c 100644 --- a/NPCs/Leviathan/Leviathan.cs +++ b/NPCs/Leviathan/Leviathan.cs @@ -50,7 +50,6 @@ namespace CalamityMod.NPCs.Leviathan { Main.npcFrameCount[NPC.type] = 3; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); if (!Main.dedServ) AttackTexture = ModContent.Request("CalamityMod/NPCs/Leviathan/LeviathanAttack", AssetRequestMode.ImmediateLoad).Value; } @@ -132,7 +131,7 @@ namespace CalamityMod.NPCs.Leviathan bool death = CalamityWorld.death || bossRush; bool revenge = CalamityWorld.revenge || bossRush; bool expertMode = Main.expertMode || bossRush; - Vector2 vector = NPC.Center; + Vector2 npcCenter = NPC.Center; // Is in spawning animation float spawnAnimationTime = 180f; @@ -188,14 +187,14 @@ namespace CalamityMod.NPCs.Leviathan extrapitch = Main.zenithWorld ? 0.3f : 0f; if (Main.rand.NextBool(600) && !spawnAnimation) - SoundEngine.PlaySound(((sirenAlive && !death) ? soundChoice : soundChoiceRage) with { Pitch = soundChoice.Pitch + extrapitch }, vector); + SoundEngine.PlaySound(((sirenAlive && !death) ? soundChoice : soundChoiceRage) with { Pitch = soundChoice.Pitch + extrapitch }, npcCenter); // 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, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles) + if (Vector2.Distance(Main.player[NPC.target].Center, npcCenter) > CalamityGlobalNPC.CatchUpDistance200Tiles) NPC.TargetClosest(); Player player = Main.player[NPC.target]; @@ -234,11 +233,11 @@ namespace CalamityMod.NPCs.Leviathan NPC.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; NPC.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; - if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) + if (!player.active || player.dead || Vector2.Distance(player.Center, npcCenter) > 5600f) { NPC.TargetClosest(false); player = Main.player[NPC.target]; - if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) + if (!player.active || player.dead || Vector2.Distance(player.Center, npcCenter) > 5600f) { if (NPC.velocity.Y < -3f) NPC.velocity.Y = -3f; @@ -285,8 +284,8 @@ namespace CalamityMod.NPCs.Leviathan if (calamityGlobalNPC.newAI[3] == 10f) { - SoundEngine.PlaySound(EmergeSound, vector); - SoundEngine.PlaySound(soundChoiceRage with { Pitch = soundChoiceRage.Pitch + extrapitch }, vector); + SoundEngine.PlaySound(EmergeSound, npcCenter); + SoundEngine.PlaySound(soundChoiceRage with { Pitch = soundChoiceRage.Pitch + extrapitch }, npcCenter); } NPC.Opacity = MathHelper.Clamp(calamityGlobalNPC.newAI[3] / spawnAnimationTime, 0f, 1f); @@ -298,62 +297,62 @@ namespace CalamityMod.NPCs.Leviathan if (NPC.ai[0] == 0f) { - float num412 = (sirenAlive && !phase4) ? 3.5f : 7f; - float num413 = (sirenAlive && !phase4) ? 0.1f : 0.2f; - num412 += 2f * enrageScale; - num413 += 0.05f * enrageScale; + float hoverSpeed = (sirenAlive && !phase4) ? 3.5f : 7f; + float hoverAcceleration = (sirenAlive && !phase4) ? 0.1f : 0.2f; + hoverSpeed += 2f * enrageScale; + hoverAcceleration += 0.05f * enrageScale; if (expertMode && (!sirenAlive || phase4)) { - num412 += death ? 6f * (1f - lifeRatio) : 3.5f * (1f - lifeRatio); - num413 += death ? 0.15f * (1f - lifeRatio) : 0.1f * (1f - lifeRatio); + hoverSpeed += death ? 6f * (1f - lifeRatio) : 3.5f * (1f - lifeRatio); + hoverAcceleration += death ? 0.15f * (1f - lifeRatio) : 0.1f * (1f - lifeRatio); } if (Main.getGoodWorld) { - num412 *= 1.15f; - num413 *= 1.15f; + hoverSpeed *= 1.15f; + hoverAcceleration *= 1.15f; } - int num414 = 1; - if (vector.X < player.position.X + player.width) - num414 = -1; + int posXSign = 1; + if (npcCenter.X < player.position.X + player.width) + posXSign = -1; - Vector2 vector40 = vector; - float num415 = player.Center.X + (num414 * ((sirenAlive && !phase4) ? 1000f : 800f) * NPC.scale) - vector40.X; - float num416 = player.Center.Y - vector40.Y; - float num417 = (float)Math.Sqrt(num415 * num415 + num416 * num416); - num417 = num412 / num417; - num415 *= num417; - num416 *= num417; + Vector2 leviCenter = npcCenter; + float xDestination = player.Center.X + (posXSign * ((sirenAlive && !phase4) ? 1000f : 800f) * NPC.scale) - leviCenter.X; + float yDestination = player.Center.Y - leviCenter.Y; + float destinationDist = (float)Math.Sqrt(xDestination * xDestination + yDestination * yDestination); + destinationDist = hoverSpeed / destinationDist; + xDestination *= destinationDist; + yDestination *= destinationDist; - if (NPC.velocity.X < num415) + if (NPC.velocity.X < xDestination) { - NPC.velocity.X += num413; - if (NPC.velocity.X < 0f && num415 > 0f) - NPC.velocity.X += num413; + NPC.velocity.X += hoverAcceleration; + if (NPC.velocity.X < 0f && xDestination > 0f) + NPC.velocity.X += hoverAcceleration; } - else if (NPC.velocity.X > num415) + else if (NPC.velocity.X > xDestination) { - NPC.velocity.X -= num413; - if (NPC.velocity.X > 0f && num415 < 0f) - NPC.velocity.X -= num413; + NPC.velocity.X -= hoverAcceleration; + if (NPC.velocity.X > 0f && xDestination < 0f) + NPC.velocity.X -= hoverAcceleration; } - if (NPC.velocity.Y < num416) + if (NPC.velocity.Y < yDestination) { - NPC.velocity.Y += num413; - if (NPC.velocity.Y < 0f && num416 > 0f) - NPC.velocity.Y += num413; + NPC.velocity.Y += hoverAcceleration; + if (NPC.velocity.Y < 0f && yDestination > 0f) + NPC.velocity.Y += hoverAcceleration; } - else if (NPC.velocity.Y > num416) + else if (NPC.velocity.Y > yDestination) { - NPC.velocity.Y -= num413; - if (NPC.velocity.Y > 0f && num416 < 0f) - NPC.velocity.Y -= num413; + NPC.velocity.Y -= hoverAcceleration; + if (NPC.velocity.Y > 0f && yDestination < 0f) + NPC.velocity.Y -= hoverAcceleration; } - float playerLocation = vector.X - player.Center.X; + float playerLocation = npcCenter.X - player.Center.X; NPC.direction = playerLocation < 0 ? 1 : -1; NPC.spriteDirection = NPC.direction; @@ -382,9 +381,9 @@ namespace CalamityMod.NPCs.Leviathan if (NPC.ai[2] >= 75f) { NPC.ai[2] = 0f; - vector40 = new Vector2(vector.X, vector.Y + 20f); - num415 = vector40.X + 1000f * NPC.direction - vector40.X; - num416 = player.Center.Y - vector40.Y; + leviCenter = new Vector2(npcCenter.X, npcCenter.Y + 20f); + xDestination = leviCenter.X + 1000f * NPC.direction - leviCenter.X; + yDestination = player.Center.Y - leviCenter.Y; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -400,28 +399,28 @@ namespace CalamityMod.NPCs.Leviathan if (!sirenAlive || phase4) speed += 3f * (1f - lifeRatio); - num417 = (float)Math.Sqrt(num415 * num415 + num416 * num416); - num417 = speed / num417; - num415 *= num417; - num416 *= num417; - vector40.X += num415 * 4f; - vector40.Y += num416 * 4f; + destinationDist = (float)Math.Sqrt(xDestination * xDestination + yDestination * yDestination); + destinationDist = speed / destinationDist; + xDestination *= destinationDist; + yDestination *= destinationDist; + leviCenter.X += xDestination * 4f; + leviCenter.Y += yDestination * 4f; if (Main.zenithWorld) { type = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? ProjectileID.BouncyBoulder : ProjectileID.Boulder; - vector40.Y -= 5; //Shoot a bit more up since boulders are affected by gravity + leviCenter.Y -= 5; //Shoot a bit more up since boulders are affected by gravity damage *= 2; } - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), vector40.X, vector40.Y, num415, num416, type, damage, 0f, Main.myPlayer); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), leviCenter.X, leviCenter.Y, xDestination, yDestination, type, damage, 0f, Main.myPlayer); if (Main.zenithWorld) Main.projectile[proj].scale *= 5f; if (soundDelay <= 0) { soundDelay = 120; - SoundEngine.PlaySound(RoarMeteorSound with { Pitch = RoarMeteorSound.Pitch + extrapitch }, vector); + SoundEngine.PlaySound(RoarMeteorSound with { Pitch = RoarMeteorSound.Pitch + extrapitch }, npcCenter); } } } @@ -429,79 +428,79 @@ namespace CalamityMod.NPCs.Leviathan } else if (NPC.ai[0] == 1f) { - Vector2 vector119 = new Vector2(vector.X, NPC.position.Y + NPC.height * 0.8f); - Vector2 vector120 = vector; - float num1058 = player.Center.X - vector120.X; - float num1059 = player.Center.Y - vector120.Y; - float num1060 = (float)Math.Sqrt(num1058 * num1058 + num1059 * num1059); + Vector2 aberrationSpawn = new Vector2(npcCenter.X, NPC.position.Y + NPC.height * 0.8f); + Vector2 leviCenterAberration = npcCenter; + float playerXDist = player.Center.X - leviCenterAberration.X; + float playerYDist = player.Center.Y - leviCenterAberration.Y; + float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); NPC.ai[1] += 1f; - int num638 = 0; - for (int num639 = 0; num639 < Main.maxPlayers; num639++) + int activePlayerAmt = 0; + for (int i = 0; i < Main.maxPlayers; i++) { - if (Main.player[num639].active && !Main.player[num639].dead && (vector - Main.player[num639].Center).Length() < 1000f) - num638++; + if (Main.player[i].active && !Main.player[i].dead && (npcCenter - Main.player[i].Center).Length() < 1000f) + activePlayerAmt++; } - NPC.ai[1] += num638 / 2; + NPC.ai[1] += activePlayerAmt / 2; - bool flag103 = false; - float num640 = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 20f : (!sirenAlive || phase4) ? 60f : 40f; - if (NPC.ai[1] > num640) + bool spawnedAberration = false; + float aberrationSpawnDelay = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 20f : (!sirenAlive || phase4) ? 60f : 40f; + if (NPC.ai[1] > aberrationSpawnDelay) { NPC.ai[1] = 0f; NPC.ai[2] += 1f; - flag103 = true; + spawnedAberration = true; } int spawnLimit = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 10 : (sirenAlive && !phase4) ? 1 : (death ? 2 : 3); - if (flag103 && NPC.CountNPCS(ModContent.NPCType()) < spawnLimit) + if (spawnedAberration && NPC.CountNPCS(ModContent.NPCType()) < spawnLimit) { - SoundEngine.PlaySound(soundChoice with { Pitch = soundChoice.Pitch + extrapitch }, vector); + SoundEngine.PlaySound(soundChoice with { Pitch = soundChoice.Pitch + extrapitch }, npcCenter); if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)vector119.X, (int)vector119.Y, ModContent.NPCType()); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)aberrationSpawn.X, (int)aberrationSpawn.Y, ModContent.NPCType()); } - if (num1060 > ((sirenAlive && !phase4) ? 1000f : 800f) * NPC.scale) + if (playerDistance > ((sirenAlive && !phase4) ? 1000f : 800f) * NPC.scale) { - float num1064 = (sirenAlive && !phase4) ? 0.05f : 0.065f; - num1064 += 0.04f * enrageScale; + float aberrationAccel = (sirenAlive && !phase4) ? 0.05f : 0.065f; + aberrationAccel += 0.04f * enrageScale; if (expertMode && (!sirenAlive || phase4)) - num1064 += death ? 0.05f * (1f - lifeRatio) : 0.03f * (1f - lifeRatio); + aberrationAccel += death ? 0.05f * (1f - lifeRatio) : 0.03f * (1f - lifeRatio); - vector120 = vector119; - num1058 = player.Center.X - vector120.X; - num1059 = player.Center.Y - vector120.Y; + leviCenterAberration = aberrationSpawn; + playerXDist = player.Center.X - leviCenterAberration.X; + playerYDist = player.Center.Y - leviCenterAberration.Y; - if (NPC.velocity.X < num1058) + if (NPC.velocity.X < playerXDist) { - NPC.velocity.X += num1064; - if (NPC.velocity.X < 0f && num1058 > 0f) - NPC.velocity.X += num1064; + NPC.velocity.X += aberrationAccel; + if (NPC.velocity.X < 0f && playerXDist > 0f) + NPC.velocity.X += aberrationAccel; } - else if (NPC.velocity.X > num1058) + else if (NPC.velocity.X > playerXDist) { - NPC.velocity.X -= num1064; - if (NPC.velocity.X > 0f && num1058 < 0f) - NPC.velocity.X -= num1064; + NPC.velocity.X -= aberrationAccel; + if (NPC.velocity.X > 0f && playerXDist < 0f) + NPC.velocity.X -= aberrationAccel; } - if (NPC.velocity.Y < num1059) + if (NPC.velocity.Y < playerYDist) { - NPC.velocity.Y += num1064; - if (NPC.velocity.Y < 0f && num1059 > 0f) - NPC.velocity.Y += num1064; + NPC.velocity.Y += aberrationAccel; + if (NPC.velocity.Y < 0f && playerYDist > 0f) + NPC.velocity.Y += aberrationAccel; } - else if (NPC.velocity.Y > num1059) + else if (NPC.velocity.Y > playerYDist) { - NPC.velocity.Y -= num1064; - if (NPC.velocity.Y > 0f && num1059 < 0f) - NPC.velocity.Y -= num1064; + NPC.velocity.Y -= aberrationAccel; + if (NPC.velocity.Y > 0f && playerYDist < 0f) + NPC.velocity.Y -= aberrationAccel; } } else NPC.velocity *= 0.9f; - float playerLocation = vector.X - player.Center.X; + float playerLocation = npcCenter.X - player.Center.X; NPC.direction = playerLocation < 0 ? 1 : -1; NPC.spriteDirection = NPC.direction; @@ -516,7 +515,7 @@ namespace CalamityMod.NPCs.Leviathan } else if (NPC.ai[0] == 2f) { - Vector2 distFromPlayer = player.Center - vector; + Vector2 distFromPlayer = player.Center - npcCenter; float chargeAmt = death ? (phase4 ? 3f : phase3 ? 2f : 1f) : 1f; if (NPC.ai[1] >= chargeAmt * 2f || distFromPlayer.Length() > 2400f) { @@ -536,16 +535,16 @@ namespace CalamityMod.NPCs.Leviathan if (NPC.ai[1] % 2f == 0f) { - int num24 = 7; - for (int j = 0; j < num24; j++) + int dustAmt = 7; + for (int j = 0; j < dustAmt; j++) { - Vector2 arg_E1C_0 = (Vector2.Normalize(NPC.velocity) * new Vector2((NPC.width + 50) / 2f, NPC.height) * 0.75f).RotatedBy((j - (num24 / 2 - 1)) * MathHelper.Pi / num24) + vector; - Vector2 vector4 = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num25 = Dust.NewDust(arg_E1C_0 + vector4, 0, 0, 172, vector4.X * 2f, vector4.Y * 2f, 100, default, 1.4f); - Main.dust[num25].noGravity = true; - Main.dust[num25].noLight = true; - Main.dust[num25].velocity /= 4f; - Main.dust[num25].velocity -= NPC.velocity; + Vector2 arg_E1C_0 = (Vector2.Normalize(NPC.velocity) * new Vector2((NPC.width + 50) / 2f, NPC.height) * 0.75f).RotatedBy((j - (dustAmt / 2 - 1)) * MathHelper.Pi / dustAmt) + npcCenter; + Vector2 dustRotation = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); + int waterDust = Dust.NewDust(arg_E1C_0 + dustRotation, 0, 0, 172, dustRotation.X * 2f, dustRotation.Y * 2f, 100, default, 1.4f); + Main.dust[waterDust].noGravity = true; + Main.dust[waterDust].noLight = true; + Main.dust[waterDust].velocity /= 4f; + Main.dust[waterDust].velocity -= NPC.velocity; } if (Math.Abs(NPC.position.Y + (NPC.height / 2) - (player.position.Y + (player.height / 2))) < 20f) @@ -553,72 +552,72 @@ namespace CalamityMod.NPCs.Leviathan NPC.ai[1] += 1f; NPC.ai[2] = 0f; - float num1044 = revenge ? 20f : 18f; - num1044 += 2f * enrageScale; + float lineupSpeed = revenge ? 20f : 18f; + lineupSpeed += 2f * enrageScale; if (revenge && (!sirenAlive || phase4)) - num1044 += death ? 9f * (1f - lifeRatio) : 6f * (1f - lifeRatio); + lineupSpeed += death ? 9f * (1f - lifeRatio) : 6f * (1f - lifeRatio); if (Main.getGoodWorld) - num1044 *= 1.15f; + lineupSpeed *= 1.15f; - Vector2 vector117 = vector; - float num1045 = player.Center.X - vector117.X; - float num1046 = player.Center.Y - vector117.Y; - float num1047 = (float)Math.Sqrt(num1045 * num1045 + num1046 * num1046); - num1047 = num1044 / num1047; - NPC.velocity.X = num1045 * num1047; - NPC.velocity.Y = num1046 * num1047; + Vector2 leviChargeCenter = npcCenter; + float playerXDistCharge = player.Center.X - leviChargeCenter.X; + float playerYDistCharge = player.Center.Y - leviChargeCenter.Y; + float playerDistanceCharge = (float)Math.Sqrt(playerXDistCharge * playerXDistCharge + playerYDistCharge * playerYDistCharge); + playerDistanceCharge = lineupSpeed / playerDistanceCharge; + NPC.velocity.X = playerXDistCharge * playerDistanceCharge; + NPC.velocity.Y = playerYDistCharge * playerDistanceCharge; - float playerLocation = vector.X - player.Center.X; + float playerLocation = npcCenter.X - player.Center.X; NPC.direction = playerLocation < 0 ? 1 : -1; NPC.spriteDirection = NPC.direction; - SoundEngine.PlaySound(RoarChargeSound with { Pitch = RoarChargeSound.Pitch + extrapitch }, vector); + SoundEngine.PlaySound(RoarChargeSound with { Pitch = RoarChargeSound.Pitch + extrapitch }, npcCenter); return; } - float num1048 = revenge ? 7.5f : 6.5f; - float num1049 = revenge ? 0.12f : 0.11f; - num1048 += 2f * enrageScale; - num1049 += 0.04f * enrageScale; + float chargeSpeed = revenge ? 7.5f : 6.5f; + float chargeAcceleration = revenge ? 0.12f : 0.11f; + chargeSpeed += 2f * enrageScale; + chargeAcceleration += 0.04f * enrageScale; if (revenge && (!sirenAlive || phase4)) { - num1048 += death ? 9f * (1f - lifeRatio) : 6f * (1f - lifeRatio); - num1049 += death ? 0.15f * (1f - lifeRatio) : 0.1f * (1f - lifeRatio); + chargeSpeed += death ? 9f * (1f - lifeRatio) : 6f * (1f - lifeRatio); + chargeAcceleration += death ? 0.15f * (1f - lifeRatio) : 0.1f * (1f - lifeRatio); } if (Main.getGoodWorld) { - num1048 *= 1.15f; - num1049 *= 1.15f; + chargeSpeed *= 1.15f; + chargeAcceleration *= 1.15f; } - if (vector.Y < player.Center.Y) - NPC.velocity.Y += num1049; + if (npcCenter.Y < player.Center.Y) + NPC.velocity.Y += chargeAcceleration; else - NPC.velocity.Y -= num1049; + NPC.velocity.Y -= chargeAcceleration; - if (NPC.velocity.Y < -num1048) - NPC.velocity.Y = -num1048; - if (NPC.velocity.Y > num1048) - NPC.velocity.Y = num1048; + if (NPC.velocity.Y < -chargeSpeed) + NPC.velocity.Y = -chargeSpeed; + if (NPC.velocity.Y > chargeSpeed) + NPC.velocity.Y = chargeSpeed; - if (Math.Abs(vector.X - player.Center.X) > chargeDistance + 200f) - NPC.velocity.X += num1049 * NPC.direction; - else if (Math.Abs(vector.X - player.Center.X) < chargeDistance) - NPC.velocity.X -= num1049 * NPC.direction; + if (Math.Abs(npcCenter.X - player.Center.X) > chargeDistance + 200f) + NPC.velocity.X += chargeAcceleration * NPC.direction; + else if (Math.Abs(npcCenter.X - player.Center.X) < chargeDistance) + NPC.velocity.X -= chargeAcceleration * NPC.direction; else NPC.velocity.X *= 0.8f; - if (NPC.velocity.X < -num1048) - NPC.velocity.X = -num1048; - if (NPC.velocity.X > num1048) - NPC.velocity.X = num1048; + if (NPC.velocity.X < -chargeSpeed) + NPC.velocity.X = -chargeSpeed; + if (NPC.velocity.X > chargeSpeed) + NPC.velocity.X = chargeSpeed; - float playerLocation2 = vector.X - player.Center.X; + float playerLocation2 = npcCenter.X - player.Center.X; NPC.direction = playerLocation2 < 0 ? 1 : -1; NPC.spriteDirection = NPC.direction; } @@ -631,30 +630,30 @@ namespace CalamityMod.NPCs.Leviathan NPC.spriteDirection = NPC.direction; - int num1051 = 1; - if (vector.X < player.Center.X) - num1051 = -1; - if (NPC.direction == num1051 && Math.Abs(vector.X - player.Center.X) > chargeDistance) + int chargeXDirectSign = 1; + if (npcCenter.X < player.Center.X) + chargeXDirectSign = -1; + if (NPC.direction == chargeXDirectSign && Math.Abs(npcCenter.X - player.Center.X) > chargeDistance) NPC.ai[2] = 1f; if (NPC.ai[2] != 1f) return; - float playerLocation = vector.X - player.Center.X; + float playerLocation = npcCenter.X - player.Center.X; NPC.direction = playerLocation < 0 ? 1 : -1; NPC.spriteDirection = NPC.direction; NPC.velocity *= 0.9f; - float num1052 = revenge ? 0.11f : 0.1f; - num1052 += 0.02f * enrageScale; + float chargeStopSpeed = revenge ? 0.11f : 0.1f; + chargeStopSpeed += 0.02f * enrageScale; if (revenge && (!sirenAlive || phase4)) { NPC.velocity *= death ? MathHelper.Lerp(0.75f, 1f, lifeRatio) : MathHelper.Lerp(0.81f, 1f, lifeRatio); - num1052 += death ? 0.15f * (1f - lifeRatio) : 0.1f * (1f - lifeRatio); + chargeStopSpeed += death ? 0.15f * (1f - lifeRatio) : 0.1f * (1f - lifeRatio); } - if (Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) < num1052) + if (Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) < chargeStopSpeed) { NPC.ai[2] = 0f; NPC.ai[1] += 1f; @@ -744,23 +743,23 @@ namespace CalamityMod.NPCs.Leviathan NPC.position.Y = NPC.position.Y + (NPC.height / 2); NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int bloody = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 2f); + Main.dust[bloody].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[bloody].scale = 0.5f; + Main.dust[bloody].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int bloody2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 3f); + Main.dust[bloody2].noGravity = true; + Main.dust[bloody2].velocity *= 5f; + bloody2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 2f); + Main.dust[bloody2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) { @@ -837,10 +836,10 @@ namespace CalamityMod.NPCs.Leviathan // GFB Boulder, Pizza and Ring drop var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ItemID.BouncyBoulder, 1, 1, 9999); - GFBOnly.Add(ItemID.Boulder, 1, 1, 9999); - GFBOnly.Add(ItemID.Pizza, 1, 1, 9999); - GFBOnly.Add(ItemID.GreedyRing); + GFBOnly.Add(ItemID.BouncyBoulder, 1, 1, 9999, true); + GFBOnly.Add(ItemID.Boulder, 1, 1, 9999, true); + GFBOnly.Add(ItemID.Pizza, 1, 1, 9999, true); + GFBOnly.Add(ItemID.GreedyRing, hideLootReport: true); } // Lore @@ -892,7 +891,7 @@ namespace CalamityMod.NPCs.Leviathan { int width = 1011; int height = 486; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.2f, PortraitScale = 0.3f, diff --git a/NPCs/Leviathan/LeviathanStart.cs b/NPCs/Leviathan/LeviathanStart.cs index 095ab8601f..f41f449409 100644 --- a/NPCs/Leviathan/LeviathanStart.cs +++ b/NPCs/Leviathan/LeviathanStart.cs @@ -18,7 +18,7 @@ namespace CalamityMod.NPCs.Leviathan Main.npcFrameCount[NPC.type] = 6; NPCID.Sets.CantTakeLunchMoney[Type] = true; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { PortraitPositionYOverride = -6f, Scale = 0.65f, diff --git a/NPCs/NormalNPCs/AeroSlime.cs b/NPCs/NormalNPCs/AeroSlime.cs index eb65e6b7fc..ad824856cd 100644 --- a/NPCs/NormalNPCs/AeroSlime.cs +++ b/NPCs/NormalNPCs/AeroSlime.cs @@ -14,7 +14,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 4; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0); value.Position.Y -= 6; value.PortraitPositionYOverride = -36f; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; diff --git a/NPCs/NormalNPCs/ArmoredDiggerBody.cs b/NPCs/NormalNPCs/ArmoredDiggerBody.cs index 7b5e104bf5..0a3b9e0fb0 100644 --- a/NPCs/NormalNPCs/ArmoredDiggerBody.cs +++ b/NPCs/NormalNPCs/ArmoredDiggerBody.cs @@ -57,16 +57,16 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.TargetClosest(true); } - bool flag = false; + bool shouldDie = false; if (NPC.ai[1] <= 0f) { - flag = true; + shouldDie = true; } else if (Main.npc[(int)NPC.ai[1]].life <= 0) { - flag = true; + shouldDie = true; } - if (flag) + if (shouldDie) { if (!Main.zenithWorld) { @@ -87,7 +87,7 @@ namespace CalamityMod.NPCs.NormalNPCs break; } } - // if it goes through the loop withuot finding an npc to attatch to (aka, ai[1] never changes and the head is still dead) kill as normal + // if it goes through the loop without finding an npc to attatch to (aka, ai[1] never changes and the head is still dead) kill as normal if (Main.npc[(int)NPC.ai[1]].life <= 0) { NPC.life = 0; @@ -107,51 +107,50 @@ namespace CalamityMod.NPCs.NormalNPCs Main.player[NPC.target].width, Main.player[NPC.target].height)) { float speed = 7f; - Vector2 vector = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)(NPC.height / 2)); - float num6 = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - vector.X + (float)Main.rand.Next(-20, 21); - float num7 = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - vector.Y + (float)Main.rand.Next(-20, 21); - float num8 = (float)Math.Sqrt((double)(num6 * num6 + num7 * num7)); - num8 = speed / num8; - num6 *= num8; - num7 *= num8; - int num9 = 30; - int num10 = Main.zenithWorld ? ModContent.ProjectileType() : ProjectileID.SaucerScrap; - vector.X += num6 * 5f; - vector.Y += num7 * 5f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector.X, vector.Y, num6, num7, num10, num9, 0f, Main.myPlayer, 0f, 0f); + Vector2 projFirePosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)(NPC.height / 2)); + float projTargetX = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - projFirePosition.X + (float)Main.rand.Next(-20, 21); + float projTargetY = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - projFirePosition.Y + (float)Main.rand.Next(-20, 21); + float projTargetDist = (float)Math.Sqrt((double)(projTargetX * projTargetX + projTargetY * projTargetY)); + projTargetDist = speed / projTargetDist; + projTargetX *= projTargetDist; + projTargetY *= projTargetDist; + int projType = Main.zenithWorld ? ModContent.ProjectileType() : ProjectileID.SaucerScrap; + projFirePosition.X += projTargetX * 5f; + projFirePosition.Y += projTargetY * 5f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), projFirePosition.X, projFirePosition.Y, projTargetX, projTargetY, projType, 30, 0f, Main.myPlayer, 0f, 0f); NPC.netUpdate = true; } } } - Vector2 vector3 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num20 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num21 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num20 = (float)((int)(num20 / 16f) * 16); - num21 = (float)((int)(num21 / 16f) * 16); - vector3.X = (float)((int)(vector3.X / 16f) * 16); - vector3.Y = (float)((int)(vector3.Y / 16f) * 16); - num20 -= vector3.X; - num21 -= vector3.Y; - float num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDist = (float)((int)(targetXDist / 16f) * 16); + targetYDist = (float)((int)(targetYDist / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDist -= segmentPosition.X; + targetYDist -= segmentPosition.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector3 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num20 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector3.X; - num21 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector3.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDist = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDist = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)Math.Atan2((double)num21, (double)num20) + 1.57f; - num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); - int num23 = (int)(44f * NPC.scale); - num22 = (num22 - (float)num23) / num22; - num20 *= num22; - num21 *= num22; + NPC.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist) + 1.57f; + targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + int segmentWidth = (int)(44f * NPC.scale); + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num20; - NPC.position.Y = NPC.position.Y + num21; + NPC.position.X = NPC.position.X + targetXDist; + NPC.position.Y = NPC.position.Y + targetYDist; } } diff --git a/NPCs/NormalNPCs/ArmoredDiggerHead.cs b/NPCs/NormalNPCs/ArmoredDiggerHead.cs index 9f162a8846..a97631312d 100644 --- a/NPCs/NormalNPCs/ArmoredDiggerHead.cs +++ b/NPCs/NormalNPCs/ArmoredDiggerHead.cs @@ -19,7 +19,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { CustomTexturePath = "CalamityMod/ExtraTextures/Bestiary/ArmoredDigger_Bestiary", PortraitPositionXOverride = 40, @@ -96,90 +96,90 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.ai[3] = (float)NPC.whoAmI; NPC.realLife = NPC.whoAmI; - int num2 = NPC.whoAmI; - int num3 = 30; - for (int j = 0; j <= num3; j++) + int thisSegment = NPC.whoAmI; + int segmentAmt = 30; + for (int j = 0; j <= segmentAmt; j++) { - int num4 = ModContent.NPCType(); - if (j == num3) + int segmentType = ModContent.NPCType(); + if (j == segmentAmt) { - num4 = ModContent.NPCType(); + segmentType = ModContent.NPCType(); } - int num5 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (float)(NPC.width / 2)), (int)(NPC.position.Y + (float)NPC.height), num4, NPC.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num5].ai[3] = (float)NPC.whoAmI; - Main.npc[num5].realLife = NPC.whoAmI; - Main.npc[num5].ai[1] = (float)num2; - Main.npc[num2].ai[0] = (float)num5; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num5, 0f, 0f, 0f, 0, 0, 0); - num2 = num5; + int newSegment = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (float)(NPC.width / 2)), (int)(NPC.position.Y + (float)NPC.height), segmentType, NPC.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[newSegment].ai[3] = (float)NPC.whoAmI; + Main.npc[newSegment].realLife = NPC.whoAmI; + Main.npc[newSegment].ai[1] = (float)thisSegment; + Main.npc[thisSegment].ai[0] = (float)newSegment; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, newSegment, 0f, 0f, 0f, 0, 0, 0); + thisSegment = newSegment; } TailSpawned = true; } } - int num12 = (int)(NPC.position.X / 16f) - 1; - int num13 = (int)((NPC.position.X + (float)NPC.width) / 16f) + 2; - int num14 = (int)(NPC.position.Y / 16f) - 1; - int num15 = (int)((NPC.position.Y + (float)NPC.height) / 16f) + 2; - if (num12 < 0) + int tileXPosition = (int)(NPC.position.X / 16f) - 1; + int tileWidthXPos = (int)((NPC.position.X + (float)NPC.width) / 16f) + 2; + int tileYPosition = (int)(NPC.position.Y / 16f) - 1; + int tileWidthYPos = (int)((NPC.position.Y + (float)NPC.height) / 16f) + 2; + if (tileXPosition < 0) { - num12 = 0; + tileXPosition = 0; } - if (num13 > Main.maxTilesX) + if (tileWidthXPos > Main.maxTilesX) { - num13 = Main.maxTilesX; + tileWidthXPos = Main.maxTilesX; } - if (num14 < 0) + if (tileYPosition < 0) { - num14 = 0; + tileYPosition = 0; } - if (num15 > Main.maxTilesY) + if (tileWidthYPos > Main.maxTilesY) { - num15 = Main.maxTilesY; + tileWidthYPos = Main.maxTilesY; } - bool flag2 = false; - if (!flag2) + bool flying = false; + if (!flying) { - for (int k = num12; k < num13; k++) + for (int k = tileXPosition; k < tileWidthXPos; k++) { - for (int l = num14; l < num15; l++) + for (int l = tileYPosition; l < tileWidthYPos; l++) { if (Main.tile[k, l] != null && ((Main.tile[k, l].HasUnactuatedTile && (Main.tileSolid[(int)Main.tile[k, l].TileType] || (Main.tileSolidTop[(int)Main.tile[k, l].TileType] && Main.tile[k, l].TileFrameY == 0))) || Main.tile[k, l].LiquidAmount > 64)) { - Vector2 vector2; - vector2.X = (float)(k * 16); - vector2.Y = (float)(l * 16); - if (NPC.position.X + (float)NPC.width > vector2.X && NPC.position.X < vector2.X + 16f && NPC.position.Y + (float)NPC.height > vector2.Y && NPC.position.Y < vector2.Y + 16f) + Vector2 segmentPos; + segmentPos.X = (float)(k * 16); + segmentPos.Y = (float)(l * 16); + if (NPC.position.X + (float)NPC.width > segmentPos.X && NPC.position.X < segmentPos.X + 16f && NPC.position.Y + (float)NPC.height > segmentPos.Y && NPC.position.Y < segmentPos.Y + 16f) { - flag2 = true; + flying = true; break; } } } } } - if (!flag2) + if (!flying) { NPC.localAI[1] = 1f; Rectangle rectangle = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); - int num16 = 1000; - bool flag3 = true; + int noFlyZone = 1000; + bool outsideNoFlyZone = true; if (NPC.position.Y > Main.player[NPC.target].position.Y) { for (int m = 0; m < 255; m++) { if (Main.player[m].active) { - Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - num16, (int)Main.player[m].position.Y - num16, num16 * 2, num16 * 2); - if (rectangle.Intersects(rectangle2)) + Rectangle noFlyArea = new Rectangle((int)Main.player[m].position.X - noFlyZone, (int)Main.player[m].position.Y - noFlyZone, noFlyZone * 2, noFlyZone * 2); + if (rectangle.Intersects(noFlyArea)) { - flag3 = false; + outsideNoFlyZone = false; break; } } } - if (flag3) + if (outsideNoFlyZone) { - flag2 = true; + flying = true; } } } @@ -187,15 +187,15 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.localAI[1] = 0f; } - float num17 = death ? 13.5f : 10f; + float fallSpeed = death ? 13.5f : 10f; if (Main.player[NPC.target].dead || (!Main.zenithWorld && (double)Main.player[NPC.target].position.Y < Main.rockLayer * 16.0)) { - flag2 = false; + flying = false; NPC.velocity.Y = NPC.velocity.Y + 1f; if ((double)NPC.position.Y > Main.rockLayer * 16.0) { NPC.velocity.Y = NPC.velocity.Y + 1f; - num17 = death ? 27f : 20f; + fallSpeed = death ? 27f : 20f; } if ((double)NPC.position.Y > (double)((Main.maxTilesY - 200) * 16)) { @@ -209,57 +209,57 @@ namespace CalamityMod.NPCs.NormalNPCs } } } - float num18 = death ? 0.0675f : 0.05f; - float num19 = death ? 0.10125f : 0.075f; - Vector2 vector3 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num20 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num21 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num20 = (float)((int)(num20 / 16f) * 16); - num21 = (float)((int)(num21 / 16f) * 16); - vector3.X = (float)((int)(vector3.X / 16f) * 16); - vector3.Y = (float)((int)(vector3.Y / 16f) * 16); - num20 -= vector3.X; - num21 -= vector3.Y; - float num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); - if (!flag2) + float acceleration = death ? 0.0675f : 0.05f; + float deceleration = death ? 0.10125f : 0.075f; + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDist = (float)((int)(targetXDist / 16f) * 16); + targetYDist = (float)((int)(targetYDist / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDist -= segmentPosition.X; + targetYDist -= segmentPosition.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + if (!flying) { NPC.TargetClosest(true); NPC.velocity.Y = NPC.velocity.Y + 0.15f; - if (NPC.velocity.Y > num17) + if (NPC.velocity.Y > fallSpeed) { - NPC.velocity.Y = num17; + NPC.velocity.Y = fallSpeed; } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)num17 * 0.4) + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)fallSpeed * 0.4) { if (NPC.velocity.X < 0f) { - NPC.velocity.X = NPC.velocity.X - num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X - acceleration * 1.1f; } else { - NPC.velocity.X = NPC.velocity.X + num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X + acceleration * 1.1f; } } - else if (NPC.velocity.Y == num17) + else if (NPC.velocity.Y == fallSpeed) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < targetXDist) { - NPC.velocity.X = NPC.velocity.X + num18; + NPC.velocity.X = NPC.velocity.X + acceleration; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > targetXDist) { - NPC.velocity.X = NPC.velocity.X - num18; + NPC.velocity.X = NPC.velocity.X - acceleration; } } else if (NPC.velocity.Y > 4f) { if (NPC.velocity.X < 0f) { - NPC.velocity.X = NPC.velocity.X + num18 * 0.9f; + NPC.velocity.X = NPC.velocity.X + acceleration * 0.9f; } else { - NPC.velocity.X = NPC.velocity.X - num18 * 0.9f; + NPC.velocity.X = NPC.velocity.X - acceleration * 0.9f; } } } @@ -267,131 +267,131 @@ namespace CalamityMod.NPCs.NormalNPCs { if (NPC.soundDelay == 0) { - float num24 = num22 / 40f; - if (num24 < 10f) + float soundDelay = targetDistance / 40f; + if (soundDelay < 10f) { - num24 = 10f; + soundDelay = 10f; } - if (num24 > 20f) + if (soundDelay > 20f) { - num24 = 20f; + soundDelay = 20f; } - NPC.soundDelay = (int)num24; + NPC.soundDelay = (int)soundDelay; SoundEngine.PlaySound(SoundID.WormDig, NPC.Center); } - num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); - float num25 = Math.Abs(num20); - float num26 = Math.Abs(num21); - float num27 = num17 / num22; - num20 *= num27; - num21 *= num27; - if (((NPC.velocity.X > 0f && num20 > 0f) || (NPC.velocity.X < 0f && num20 < 0f)) && ((NPC.velocity.Y > 0f && num21 > 0f) || (NPC.velocity.Y < 0f && num21 < 0f))) + targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + float absoluteTargetX = Math.Abs(targetXDist); + float absoluteTargetY = Math.Abs(targetYDist); + float timeToReachTarget = fallSpeed / targetDistance; + targetXDist *= timeToReachTarget; + targetYDist *= timeToReachTarget; + if (((NPC.velocity.X > 0f && targetXDist > 0f) || (NPC.velocity.X < 0f && targetXDist < 0f)) && ((NPC.velocity.Y > 0f && targetYDist > 0f) || (NPC.velocity.Y < 0f && targetYDist < 0f))) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < targetXDist) { - NPC.velocity.X = NPC.velocity.X + num19; + NPC.velocity.X = NPC.velocity.X + deceleration; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > targetXDist) { - NPC.velocity.X = NPC.velocity.X - num19; + NPC.velocity.X = NPC.velocity.X - deceleration; } - if (NPC.velocity.Y < num21) + if (NPC.velocity.Y < targetYDist) { - NPC.velocity.Y = NPC.velocity.Y + num19; + NPC.velocity.Y = NPC.velocity.Y + deceleration; } - else if (NPC.velocity.Y > num21) + else if (NPC.velocity.Y > targetYDist) { - NPC.velocity.Y = NPC.velocity.Y - num19; + NPC.velocity.Y = NPC.velocity.Y - deceleration; } } - if ((NPC.velocity.X > 0f && num20 > 0f) || (NPC.velocity.X < 0f && num20 < 0f) || (NPC.velocity.Y > 0f && num21 > 0f) || (NPC.velocity.Y < 0f && num21 < 0f)) + if ((NPC.velocity.X > 0f && targetXDist > 0f) || (NPC.velocity.X < 0f && targetXDist < 0f) || (NPC.velocity.Y > 0f && targetYDist > 0f) || (NPC.velocity.Y < 0f && targetYDist < 0f)) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < targetXDist) { - NPC.velocity.X = NPC.velocity.X + num18; + NPC.velocity.X = NPC.velocity.X + acceleration; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > targetXDist) { - NPC.velocity.X = NPC.velocity.X - num18; + NPC.velocity.X = NPC.velocity.X - acceleration; } - if (NPC.velocity.Y < num21) + if (NPC.velocity.Y < targetYDist) { - NPC.velocity.Y = NPC.velocity.Y + num18; + NPC.velocity.Y = NPC.velocity.Y + acceleration; } - else if (NPC.velocity.Y > num21) + else if (NPC.velocity.Y > targetYDist) { - NPC.velocity.Y = NPC.velocity.Y - num18; + NPC.velocity.Y = NPC.velocity.Y - acceleration; } - if ((double)Math.Abs(num21) < (double)num17 * 0.2 && ((NPC.velocity.X > 0f && num20 < 0f) || (NPC.velocity.X < 0f && num20 > 0f))) + if ((double)Math.Abs(targetYDist) < (double)fallSpeed * 0.2 && ((NPC.velocity.X > 0f && targetXDist < 0f) || (NPC.velocity.X < 0f && targetXDist > 0f))) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num18 * 2f; + NPC.velocity.Y = NPC.velocity.Y + acceleration * 2f; } else { - NPC.velocity.Y = NPC.velocity.Y - num18 * 2f; + NPC.velocity.Y = NPC.velocity.Y - acceleration * 2f; } } - if ((double)Math.Abs(num20) < (double)num17 * 0.2 && ((NPC.velocity.Y > 0f && num21 < 0f) || (NPC.velocity.Y < 0f && num21 > 0f))) + if ((double)Math.Abs(targetXDist) < (double)fallSpeed * 0.2 && ((NPC.velocity.Y > 0f && targetYDist < 0f) || (NPC.velocity.Y < 0f && targetYDist > 0f))) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num18 * 2f; + NPC.velocity.X = NPC.velocity.X + acceleration * 2f; } else { - NPC.velocity.X = NPC.velocity.X - num18 * 2f; + NPC.velocity.X = NPC.velocity.X - acceleration * 2f; } } } - else if (num25 > num26) + else if (absoluteTargetX > absoluteTargetY) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < targetXDist) { - NPC.velocity.X = NPC.velocity.X + num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X + acceleration * 1.1f; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > targetXDist) { - NPC.velocity.X = NPC.velocity.X - num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X - acceleration * 1.1f; } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)num17 * 0.5) + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)fallSpeed * 0.5) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num18; + NPC.velocity.Y = NPC.velocity.Y + acceleration; } else { - NPC.velocity.Y = NPC.velocity.Y - num18; + NPC.velocity.Y = NPC.velocity.Y - acceleration; } } } else { - if (NPC.velocity.Y < num21) + if (NPC.velocity.Y < targetYDist) { - NPC.velocity.Y = NPC.velocity.Y + num18 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y + acceleration * 1.1f; } - else if (NPC.velocity.Y > num21) + else if (NPC.velocity.Y > targetYDist) { - NPC.velocity.Y = NPC.velocity.Y - num18 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y - acceleration * 1.1f; } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)num17 * 0.5) + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)fallSpeed * 0.5) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num18; + NPC.velocity.X = NPC.velocity.X + acceleration; } else { - NPC.velocity.X = NPC.velocity.X - num18; + NPC.velocity.X = NPC.velocity.X - acceleration; } } } } NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) + 1.57f; - if (flag2) + if (flying) { if (NPC.localAI[0] != 1f) { diff --git a/NPCs/NormalNPCs/ArmoredDiggerTail.cs b/NPCs/NormalNPCs/ArmoredDiggerTail.cs index cad5a06399..bb5027f029 100644 --- a/NPCs/NormalNPCs/ArmoredDiggerTail.cs +++ b/NPCs/NormalNPCs/ArmoredDiggerTail.cs @@ -56,50 +56,50 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.TargetClosest(true); } - bool flag = false; + bool shouldDie = false; if (NPC.ai[1] <= 0f) { - flag = true; + shouldDie = true; } else if (Main.npc[(int)NPC.ai[1]].life <= 0) { - flag = true; + shouldDie = true; } - if (flag && !Main.zenithWorld) + if (shouldDie && !Main.zenithWorld) { NPC.life = 0; NPC.HitEffect(0, 10.0); NPC.checkDead(); } - Vector2 vector3 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num20 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num21 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num20 = (float)((int)(num20 / 16f) * 16); - num21 = (float)((int)(num21 / 16f) * 16); - vector3.X = (float)((int)(vector3.X / 16f) * 16); - vector3.Y = (float)((int)(vector3.Y / 16f) * 16); - num20 -= vector3.X; - num21 -= vector3.Y; - float num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDist = (float)((int)(targetXDist / 16f) * 16); + targetYDist = (float)((int)(targetYDist / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDist -= segmentPosition.X; + targetYDist -= segmentPosition.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector3 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num20 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector3.X; - num21 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector3.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDist = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDist = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)Math.Atan2((double)num21, (double)num20) + 1.57f; - num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); - int num23 = (int)(44f * NPC.scale); - num22 = (num22 - (float)num23) / num22; - num20 *= num22; - num21 *= num22; + NPC.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist) + 1.57f; + targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + int segmentWidth = (int)(44f * NPC.scale); + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num20; - NPC.position.Y = NPC.position.Y + num21; + NPC.position.X = NPC.position.X + targetXDist; + NPC.position.Y = NPC.position.Y + targetYDist; } } diff --git a/NPCs/NormalNPCs/AuroraSpirit.cs b/NPCs/NormalNPCs/AuroraSpirit.cs index 6a26605ea5..da912b3ae0 100644 --- a/NPCs/NormalNPCs/AuroraSpirit.cs +++ b/NPCs/NormalNPCs/AuroraSpirit.cs @@ -13,7 +13,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 5; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { SpriteDirection = -1, PortraitPositionYOverride = -20f @@ -53,12 +53,12 @@ namespace CalamityMod.NPCs.NormalNPCs public override void FindFrame(int frameHeight) { - int num1 = 1; + int currentFrame = 1; if (!Main.dedServ) { if (TextureAssets.Npc[NPC.type].Value == null) return; - num1 = TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type]; + currentFrame = TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type]; } if (!NPC.IsABestiaryIconDummy) @@ -77,10 +77,10 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.frameCounter++; if (NPC.frameCounter > 4) { - NPC.frame.Y += num1; + NPC.frame.Y += currentFrame; NPC.frameCounter = 0; } - if (NPC.frame.Y / num1 >= Main.npcFrameCount[NPC.type]) + if (NPC.frame.Y / currentFrame >= Main.npcFrameCount[NPC.type]) NPC.frame.Y = 0; } diff --git a/NPCs/NormalNPCs/Cnidrion.cs b/NPCs/NormalNPCs/Cnidrion.cs index 1572a6794f..650c200b5d 100644 --- a/NPCs/NormalNPCs/Cnidrion.cs +++ b/NPCs/NormalNPCs/Cnidrion.cs @@ -16,7 +16,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 10; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.8f, }; @@ -95,22 +95,22 @@ namespace CalamityMod.NPCs.NormalNPCs Player player = Main.player[NPC.target]; bool expertMode = Main.expertMode; NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; - float num823 = 1f; + float movementSpeed = 1f; NPC.TargetClosest(true); - bool flag51 = false; + bool stopMoving = false; int offsetX = 80; int projectileDamage = expertMode ? 9 : 12; if (NPC.life < NPC.lifeMax * 0.33 && CalamityWorld.death) { - num823 = 2f; + movementSpeed = 2f; } if (NPC.life < NPC.lifeMax * 0.1 && CalamityWorld.death) { - num823 = 4f; + movementSpeed = 4f; } if (Main.zenithWorld) { - num823 = 8f; + movementSpeed = 8f; } if (NPC.ai[0] == 0f) { @@ -143,22 +143,22 @@ namespace CalamityMod.NPCs.NormalNPCs } else if (NPC.ai[0] == 1f) { - flag51 = true; + stopMoving = true; NPC.ai[1] += 1f; if (NPC.ai[1] % 30f == 0f) { - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + 20f); - vector18.X += offsetX * NPC.direction; - float num829 = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - vector18.X; - float num830 = Main.player[NPC.target].position.Y - vector18.Y; - float num831 = (float)Math.Sqrt(num829 * num829 + num830 * num830); - float num832 = 6f; - num831 = num832 / num831; - num829 *= num831; - num830 *= num831; - num829 *= 1f + Main.rand.Next(-10, 11) * 0.01f; - num830 *= 1f + Main.rand.Next(-10, 11) * 0.01f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector18.X, vector18.Y, num829, num830, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer); + Vector2 npcPosition = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + 20f); + npcPosition.X += offsetX * NPC.direction; + float targetXDist = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - npcPosition.X; + float targetYDist = Main.player[NPC.target].position.Y - npcPosition.Y; + float targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); + float waterSpeed = 6f; + targetDistance = waterSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + targetXDist *= 1f + Main.rand.Next(-10, 11) * 0.01f; + targetYDist *= 1f + Main.rand.Next(-10, 11) * 0.01f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), npcPosition.X, npcPosition.Y, targetXDist, targetYDist, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer); } if (NPC.ai[1] >= 120f) { @@ -168,22 +168,22 @@ namespace CalamityMod.NPCs.NormalNPCs } else if (NPC.ai[0] == 2f) { - flag51 = true; + stopMoving = true; NPC.ai[1] += 1f; if (NPC.ai[1] > 60f && NPC.ai[1] < 240f && NPC.ai[1] % 16f == 0f) { - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + 20f); - vector18.X += offsetX * NPC.direction; - float num829 = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - vector18.X; - float num830 = Main.player[NPC.target].position.Y - vector18.Y; - float num831 = (float)Math.Sqrt(num829 * num829 + num830 * num830); - float num832 = 8f; - num831 = num832 / num831; - num829 *= num831; - num830 *= num831; - num829 *= 1f + Main.rand.Next(-15, 16) * 0.01f; - num830 *= 1f + Main.rand.Next(-15, 16) * 0.01f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector18.X, vector18.Y, num829, num830, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer); + Vector2 npcPosition = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + 20f); + npcPosition.X += offsetX * NPC.direction; + float targetXDist = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - npcPosition.X; + float targetYDist = Main.player[NPC.target].position.Y - npcPosition.Y; + float targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); + float waterSpeed = 8f; + targetDistance = waterSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + targetXDist *= 1f + Main.rand.Next(-15, 16) * 0.01f; + targetYDist *= 1f + Main.rand.Next(-15, 16) * 0.01f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), npcPosition.X, npcPosition.Y, targetXDist, targetYDist, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer); } if (NPC.ai[1] >= 300f) { @@ -193,22 +193,22 @@ namespace CalamityMod.NPCs.NormalNPCs } else if (NPC.ai[0] == 3f) { - num823 = 4f; + movementSpeed = 4f; NPC.ai[1] += 1f; if (NPC.ai[1] % 30f == 0f) { - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + 20f); - vector18.X += offsetX * NPC.direction; - float num844 = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - vector18.X; - float num845 = Main.player[NPC.target].position.Y - vector18.Y; - float num846 = (float)Math.Sqrt(num844 * num844 + num845 * num845); - float num847 = 10f; - num846 = num847 / num846; - num844 *= num846; - num845 *= num846; - num844 *= 1f + Main.rand.Next(-10, 11) * 0.001f; - num845 *= 1f + Main.rand.Next(-10, 11) * 0.001f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector18.X, vector18.Y, num844, num845, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer); + Vector2 npcPosition = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + 20f); + npcPosition.X += offsetX * NPC.direction; + float fastTargetXDist = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - npcPosition.X; + float fastTargetYDist = Main.player[NPC.target].position.Y - npcPosition.Y; + float fastTargetDistance = (float)Math.Sqrt(fastTargetXDist * fastTargetXDist + fastTargetYDist * fastTargetYDist); + float fastWaterSpeed = 10f; + fastTargetDistance = fastWaterSpeed / fastTargetDistance; + fastTargetXDist *= fastTargetDistance; + fastTargetYDist *= fastTargetDistance; + fastTargetXDist *= 1f + Main.rand.Next(-10, 11) * 0.001f; + fastTargetYDist *= 1f + Main.rand.Next(-10, 11) * 0.001f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), npcPosition.X, npcPosition.Y, fastTargetXDist, fastTargetYDist, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer); } if (NPC.ai[1] >= 120f) { @@ -218,22 +218,22 @@ namespace CalamityMod.NPCs.NormalNPCs } else if (NPC.ai[0] == 4f) { - num823 = 4f; + movementSpeed = 4f; NPC.ai[1] += 1f; if (NPC.ai[1] % 20f == 0f) { - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + 20f); - vector18.X += offsetX * NPC.direction; - float num829 = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - vector18.X; - float num830 = Main.player[NPC.target].position.Y - vector18.Y; - float num831 = (float)Math.Sqrt(num829 * num829 + num830 * num830); - float num832 = 11f; - num831 = num832 / num831; - num829 *= num831; - num830 *= num831; - num829 *= 1f + Main.rand.Next(-5, 6) * 0.01f; - num830 *= 1f + Main.rand.Next(-5, 6) * 0.01f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector18.X, vector18.Y, num829, num830, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer); + Vector2 npcPosition = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + 20f); + npcPosition.X += offsetX * NPC.direction; + float targetXDist = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - npcPosition.X; + float targetYDist = Main.player[NPC.target].position.Y - npcPosition.Y; + float targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); + float waterSpeed = 11f; + targetDistance = waterSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + targetXDist *= 1f + Main.rand.Next(-5, 6) * 0.01f; + targetYDist *= 1f + Main.rand.Next(-5, 6) * 0.01f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), npcPosition.X, npcPosition.Y, targetXDist, targetYDist, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer); } if (NPC.ai[1] >= 240f) { @@ -243,9 +243,9 @@ namespace CalamityMod.NPCs.NormalNPCs } if (Math.Abs(NPC.Center.X - player.Center.X) < 50f) - flag51 = true; + stopMoving = true; - if (flag51) + if (stopMoving) { NPC.velocity.X *= 0.9f; if (NPC.velocity.X > -0.1 && NPC.velocity.X < 0.1) @@ -257,9 +257,9 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.direction = playerLocation < 0 ? 1 : -1; if (NPC.direction > 0) - NPC.velocity.X = (NPC.velocity.X * 20f + num823) / 21f; + NPC.velocity.X = (NPC.velocity.X * 20f + movementSpeed) / 21f; if (NPC.direction < 0) - NPC.velocity.X = (NPC.velocity.X * 20f - num823) / 21f; + NPC.velocity.X = (NPC.velocity.X * 20f - movementSpeed) / 21f; } if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height) && player.position.Y <= NPC.position.Y + NPC.height && !NPC.collideX) @@ -272,10 +272,10 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.noGravity = true; NPC.noTileCollide = true; - int num854 = 80; - int num855 = 20; - Vector2 position2 = new Vector2(NPC.Center.X - (num854 / 2), NPC.position.Y + NPC.height - num855); - if (Collision.SolidCollision(position2, num854, num855)) + int collisionWidth = 80; + int collisionHeight = 20; + Vector2 collisionSize = new Vector2(NPC.Center.X - (collisionWidth / 2), NPC.position.Y + NPC.height - collisionHeight); + if (Collision.SolidCollision(collisionSize, collisionWidth, collisionHeight)) { if (NPC.velocity.Y > 0f) NPC.velocity.Y = 0f; diff --git a/NPCs/NormalNPCs/Cryon.cs b/NPCs/NormalNPCs/Cryon.cs index ec78cecc97..68727d6303 100644 --- a/NPCs/NormalNPCs/Cryon.cs +++ b/NPCs/NormalNPCs/Cryon.cs @@ -13,7 +13,6 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 6; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); } public override void SetDefaults() diff --git a/NPCs/NormalNPCs/Eidolist.cs b/NPCs/NormalNPCs/Eidolist.cs index 755973f19a..46fdd03225 100644 --- a/NPCs/NormalNPCs/Eidolist.cs +++ b/NPCs/NormalNPCs/Eidolist.cs @@ -24,7 +24,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 6; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.75f, PortraitPositionYOverride = 16f @@ -152,22 +152,22 @@ namespace CalamityMod.NPCs.NormalNPCs return; } NPC.noTileCollide = true; - float num1446 = adultWyrmAlive ? 14f : 7f; - float num1447 = 480f; + float moveVelocity = adultWyrmAlive ? 14f : 7f; + float teleportTimer = 480f; if (NPC.localAI[1] == 1f) { NPC.localAI[1] = 0f; if (Main.rand.NextBool(4)) { - NPC.ai[0] = num1447; + NPC.ai[0] = teleportTimer; } } NPC.TargetClosest(true); NPC.rotation = Math.Abs(NPC.velocity.X) * (float)NPC.direction * 0.1f; NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; - Vector2 value53 = NPC.Center + new Vector2((float)(NPC.direction * 20), 6f); - Vector2 vector251 = Main.player[NPC.target].Center - value53; - bool flag104 = Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1); + Vector2 moveDirection = NPC.Center + new Vector2((float)(NPC.direction * 20), 6f); + Vector2 attackDirection = Main.player[NPC.target].Center - moveDirection; + bool canAttackTarget = Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1); if (NPC.justHit) NPC.localAI[0] = -90f; @@ -195,29 +195,29 @@ namespace CalamityMod.NPCs.NormalNPCs } else { - Vector2 vec = Vector2.Normalize(Main.player[NPC.target].Center - NPC.Center + Main.player[NPC.target].velocity * 20f); - if (vec.HasNaNs()) + Vector2 iceMistDirection = Vector2.Normalize(Main.player[NPC.target].Center - NPC.Center + Main.player[NPC.target].velocity * 20f); + if (iceMistDirection.HasNaNs()) { - vec = new Vector2((float)NPC.direction, 0f); + iceMistDirection = new Vector2((float)NPC.direction, 0f); } for (int n = 0; n < 1; n++) { - Vector2 vector4 = vec * 4f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, vector4, ProjectileID.CultistBossIceMist, damage, 0f, Main.myPlayer, 0f, 1f); + Vector2 iceMistVelocity = iceMistDirection * 4f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, iceMistVelocity, ProjectileID.CultistBossIceMist, damage, 0f, Main.myPlayer, 0f, 1f); } } } } - if (vector251.Length() > 400f || !flag104) + if (attackDirection.Length() > 400f || !canAttackTarget) { - Vector2 value54 = vector251; - if (value54.Length() > num1446) + Vector2 tooFarMoveVelocity = attackDirection; + if (tooFarMoveVelocity.Length() > moveVelocity) { - value54.Normalize(); - value54 *= num1446; + tooFarMoveVelocity.Normalize(); + tooFarMoveVelocity *= moveVelocity; } - int num1448 = 30; - NPC.velocity = (NPC.velocity * (float)(num1448 - 1) + value54) / (float)num1448; + int tooFarVelMult = 30; + NPC.velocity = (NPC.velocity * (float)(tooFarVelMult - 1) + tooFarMoveVelocity) / (float)tooFarVelMult; } else { @@ -226,10 +226,10 @@ namespace CalamityMod.NPCs.NormalNPCs if (NPC.ai[2] != 0f && NPC.ai[3] != 0f) { SoundEngine.PlaySound(SoundID.Item8, NPC.Center); - for (int num1449 = 0; num1449 < 20; num1449++) + for (int i = 0; i < 20; i++) { - int num1450 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 20, 0f, 0f, 100, Color.Transparent, 1f); - Dust dust = Main.dust[num1450]; + int eidolistDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 20, 0f, 0f, 100, Color.Transparent, 1f); + Dust dust = Main.dust[eidolistDust]; dust.velocity *= 3f; dust.noGravity = true; dust.scale = 2.5f; @@ -239,51 +239,51 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.ai[2] = 0f; NPC.ai[3] = 0f; SoundEngine.PlaySound(SoundID.Item8, NPC.Center); - for (int num1451 = 0; num1451 < 20; num1451++) + for (int j = 0; j < 20; j++) { - int num1452 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 20, 0f, 0f, 100, Color.Transparent, 1f); - Dust dust = Main.dust[num1452]; + int eidolistDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 20, 0f, 0f, 100, Color.Transparent, 1f); + Dust dust = Main.dust[eidolistDust2]; dust.velocity *= 3f; dust.noGravity = true; dust.scale = 2.5f; } } NPC.ai[0] += 1f; - if (NPC.ai[0] >= num1447 && Main.netMode != NetmodeID.MultiplayerClient) + if (NPC.ai[0] >= teleportTimer && Main.netMode != NetmodeID.MultiplayerClient) { NPC.ai[0] = 0f; - Point point12 = NPC.Center.ToTileCoordinates(); - Point point13 = Main.player[NPC.target].Center.ToTileCoordinates(); - int num1453 = 20; - int num1454 = 3; - int num1455 = 10; - int num1456 = 1; - int num1457 = 0; - bool flag106 = false; - if (vector251.Length() > 2000f) + Point npcTileCenter = NPC.Center.ToTileCoordinates(); + Point targetTileCenter = Main.player[NPC.target].Center.ToTileCoordinates(); + int randTeleportOffset = 20; + int npcTeleportRadius = 3; + int targetTeleportRadius = 10; + int teleportTileCheckRadius = 1; + int teleportTries = 0; + bool canTeleport = false; + if (attackDirection.Length() > 2000f) { - flag106 = true; + canTeleport = true; } - while (!flag106 && num1457 < 100) + while (!canTeleport && teleportTries < 100) { - num1457++; - int num1458 = Main.rand.Next(point13.X - num1453, point13.X + num1453 + 1); - int num1459 = Main.rand.Next(point13.Y - num1453, point13.Y + num1453 + 1); - if ((num1459 < point13.Y - num1455 || num1459 > point13.Y + num1455 || num1458 < point13.X - num1455 || num1458 > point13.X + num1455) && (num1459 < point12.Y - num1454 || num1459 > point12.Y + num1454 || num1458 < point12.X - num1454 || num1458 > point12.X + num1454) && !Main.tile[num1458, num1459].HasUnactuatedTile) + teleportTries++; + int teleportTileX = Main.rand.Next(targetTileCenter.X - randTeleportOffset, targetTileCenter.X + randTeleportOffset + 1); + int teleportTileY = Main.rand.Next(targetTileCenter.Y - randTeleportOffset, targetTileCenter.Y + randTeleportOffset + 1); + if ((teleportTileY < targetTileCenter.Y - targetTeleportRadius || teleportTileY > targetTileCenter.Y + targetTeleportRadius || teleportTileX < targetTileCenter.X - targetTeleportRadius || teleportTileX > targetTileCenter.X + targetTeleportRadius) && (teleportTileY < npcTileCenter.Y - npcTeleportRadius || teleportTileY > npcTileCenter.Y + npcTeleportRadius || teleportTileX < npcTileCenter.X - npcTeleportRadius || teleportTileX > npcTileCenter.X + npcTeleportRadius) && !Main.tile[teleportTileX, teleportTileY].HasUnactuatedTile) { - bool flag107 = true; - if (flag107 && Main.tile[num1458, num1459].LiquidType == LiquidID.Lava) + bool teleportSuccessful = true; + if (teleportSuccessful && Main.tile[teleportTileX, teleportTileY].LiquidType == LiquidID.Lava) { - flag107 = false; + teleportSuccessful = false; } - if (flag107 && Collision.SolidTiles(num1458 - num1456, num1458 + num1456, num1459 - num1456, num1459 + num1456)) + if (teleportSuccessful && Collision.SolidTiles(teleportTileX - teleportTileCheckRadius, teleportTileX + teleportTileCheckRadius, teleportTileY - teleportTileCheckRadius, teleportTileY + teleportTileCheckRadius)) { - flag107 = false; + teleportSuccessful = false; } - if (flag107) + if (teleportSuccessful) { - NPC.ai[2] = (float)num1458; - NPC.ai[3] = (float)num1459; + NPC.ai[2] = (float)teleportTileX; + NPC.ai[3] = (float)teleportTileY; break; } } diff --git a/NPCs/NormalNPCs/FearlessGoldfishWarrior.cs b/NPCs/NormalNPCs/FearlessGoldfishWarrior.cs index b4fa74c3b0..323ad15220 100644 --- a/NPCs/NormalNPCs/FearlessGoldfishWarrior.cs +++ b/NPCs/NormalNPCs/FearlessGoldfishWarrior.cs @@ -52,23 +52,23 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { - bool flag3 = false; + bool noXMovement = false; if (NPC.velocity.X == 0f) { - flag3 = true; + noXMovement = true; } if (NPC.justHit) { - flag3 = false; + noXMovement = false; } - bool flag4 = false; - bool flag5 = false; - int num35 = 60; + bool isWalking = false; + bool unusedFlag = false; + int backUpTimer = 60; if (NPC.velocity.Y == 0f && ((NPC.velocity.X > 0f && NPC.direction < 0) || (NPC.velocity.X < 0f && NPC.direction > 0))) { - flag4 = true; + isWalking = true; } - if ((NPC.position.X == NPC.oldPosition.X || NPC.ai[3] >= (float)num35) | flag4) + if ((NPC.position.X == NPC.oldPosition.X || NPC.ai[3] >= (float)backUpTimer) | isWalking) { NPC.ai[3] += 1f; } @@ -76,7 +76,7 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.ai[3] -= 1f; } - if (NPC.ai[3] > (float)(num35 * 10)) + if (NPC.ai[3] > (float)(backUpTimer * 10)) { NPC.ai[3] = 0f; } @@ -84,11 +84,11 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.ai[3] = 0f; } - if (NPC.ai[3] == (float)num35) + if (NPC.ai[3] == (float)backUpTimer) { NPC.netUpdate = true; } - if (NPC.ai[3] < (float)num35) + if (NPC.ai[3] < (float)backUpTimer) { NPC.TargetClosest(true); } @@ -124,81 +124,81 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.velocity.X = 0f; return; } - float num65 = CalamityWorld.death ? 3f : CalamityWorld.revenge ? 2f : 1f; - float num66 = CalamityWorld.death ? 0.28f : CalamityWorld.revenge ? 0.18f : 0.08f; - num65 += (1f - (float)NPC.life / (float)NPC.lifeMax) * 2f; - num66 += (1f - (float)NPC.life / (float)NPC.lifeMax) * 0.2f; - if (NPC.velocity.X < -num65 || NPC.velocity.X > num65) + float maxVelocity = CalamityWorld.death ? 3f : CalamityWorld.revenge ? 2f : 1f; + float acceleration = CalamityWorld.death ? 0.28f : CalamityWorld.revenge ? 0.18f : 0.08f; + maxVelocity += (1f - (float)NPC.life / (float)NPC.lifeMax) * 2f; + acceleration += (1f - (float)NPC.life / (float)NPC.lifeMax) * 0.2f; + if (NPC.velocity.X < -maxVelocity || NPC.velocity.X > maxVelocity) { if (NPC.velocity.Y == 0f) NPC.velocity *= 0.7f; } - else if (NPC.velocity.X < num65 && NPC.direction == 1) + else if (NPC.velocity.X < maxVelocity && NPC.direction == 1) { - NPC.velocity.X = NPC.velocity.X + num66; - if (NPC.velocity.X > num65) - NPC.velocity.X = num65; + NPC.velocity.X = NPC.velocity.X + acceleration; + if (NPC.velocity.X > maxVelocity) + NPC.velocity.X = maxVelocity; } - else if (NPC.velocity.X > -num65 && NPC.direction == -1) + else if (NPC.velocity.X > -maxVelocity && NPC.direction == -1) { - NPC.velocity.X = NPC.velocity.X - num66; - if (NPC.velocity.X < -num65) - NPC.velocity.X = -num65; + NPC.velocity.X = NPC.velocity.X - acceleration; + if (NPC.velocity.X < -maxVelocity) + NPC.velocity.X = -maxVelocity; } - bool flag22 = false; + bool isOnSolidTile = false; if (NPC.velocity.Y == 0f) { - int num161 = (int)(NPC.position.Y + (float)NPC.height + 7f) / 16; - int arg_A8FB_0 = (int)NPC.position.X / 16; - int num162 = (int)(NPC.position.X + (float)NPC.width) / 16; - for (int num163 = arg_A8FB_0; num163 <= num162; num163++) + int yTile = (int)(NPC.position.Y + (float)NPC.height + 7f) / 16; + int initialXTile = (int)NPC.position.X / 16; + int maxXTile = (int)(NPC.position.X + (float)NPC.width) / 16; + for (int xTile = initialXTile; xTile <= maxXTile; xTile++) { - if (Main.tile[num163, num161] == null) + if (Main.tile[xTile, yTile] == null) { return; } - if (Main.tile[num163, num161].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num163, num161].TileType]) + if (Main.tile[xTile, yTile].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[xTile, yTile].TileType]) { - flag22 = true; + isOnSolidTile = true; break; } } } if (NPC.velocity.Y >= 0f) { - int num164 = 0; + int fallFaceDirection = 0; if (NPC.velocity.X < 0f) { - num164 = -1; + fallFaceDirection = -1; } if (NPC.velocity.X > 0f) { - num164 = 1; + fallFaceDirection = 1; } - Vector2 position2 = NPC.position; - position2.X += NPC.velocity.X; - int num165 = (int)((position2.X + (float)(NPC.width / 2) + (float)((NPC.width / 2 + 1) * num164)) / 16f); - int num166 = (int)((position2.Y + (float)NPC.height - 1f) / 16f); - if ((float)(num165 * 16) < position2.X + (float)NPC.width && (float)(num165 * 16 + 16) > position2.X && ((Main.tile[num165, num166].HasUnactuatedTile && !Main.tile[num165, num166].TopSlope && !Main.tile[num165, num166 - 1].TopSlope && Main.tileSolid[(int)Main.tile[num165, num166].TileType] && !Main.tileSolidTop[(int)Main.tile[num165, num166].TileType]) || (Main.tile[num165, num166 - 1].IsHalfBlock && Main.tile[num165, num166 - 1].HasUnactuatedTile)) && (!Main.tile[num165, num166 - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num165, num166 - 1].TileType] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 1].TileType] || (Main.tile[num165, num166 - 1].IsHalfBlock && (!Main.tile[num165, num166 - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num165, num166 - 4].TileType] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 4].TileType]))) && (!Main.tile[num165, num166 - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num165, num166 - 2].TileType] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 2].TileType]) && (!Main.tile[num165, num166 - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num165, num166 - 3].TileType] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 3].TileType]) && (!Main.tile[num165 - num164, num166 - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num165 - num164, num166 - 3].TileType])) + Vector2 fishePosition = NPC.position; + fishePosition.X += NPC.velocity.X; + int xTileBelow = (int)((fishePosition.X + (float)(NPC.width / 2) + (float)((NPC.width / 2 + 1) * fallFaceDirection)) / 16f); + int yTileBelow = (int)((fishePosition.Y + (float)NPC.height - 1f) / 16f); + if ((float)(xTileBelow * 16) < fishePosition.X + (float)NPC.width && (float)(xTileBelow * 16 + 16) > fishePosition.X && ((Main.tile[xTileBelow, yTileBelow].HasUnactuatedTile && !Main.tile[xTileBelow, yTileBelow].TopSlope && !Main.tile[xTileBelow, yTileBelow - 1].TopSlope && Main.tileSolid[(int)Main.tile[xTileBelow, yTileBelow].TileType] && !Main.tileSolidTop[(int)Main.tile[xTileBelow, yTileBelow].TileType]) || (Main.tile[xTileBelow, yTileBelow - 1].IsHalfBlock && Main.tile[xTileBelow, yTileBelow - 1].HasUnactuatedTile)) && (!Main.tile[xTileBelow, yTileBelow - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[xTileBelow, yTileBelow - 1].TileType] || Main.tileSolidTop[(int)Main.tile[xTileBelow, yTileBelow - 1].TileType] || (Main.tile[xTileBelow, yTileBelow - 1].IsHalfBlock && (!Main.tile[xTileBelow, yTileBelow - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[xTileBelow, yTileBelow - 4].TileType] || Main.tileSolidTop[(int)Main.tile[xTileBelow, yTileBelow - 4].TileType]))) && (!Main.tile[xTileBelow, yTileBelow - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[xTileBelow, yTileBelow - 2].TileType] || Main.tileSolidTop[(int)Main.tile[xTileBelow, yTileBelow - 2].TileType]) && (!Main.tile[xTileBelow, yTileBelow - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[xTileBelow, yTileBelow - 3].TileType] || Main.tileSolidTop[(int)Main.tile[xTileBelow, yTileBelow - 3].TileType]) && (!Main.tile[xTileBelow - fallFaceDirection, yTileBelow - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[xTileBelow - fallFaceDirection, yTileBelow - 3].TileType])) { - float num167 = (float)(num166 * 16); - if (Main.tile[num165, num166].IsHalfBlock) + float yPixelDistance = (float)(yTileBelow * 16); + if (Main.tile[xTileBelow, yTileBelow].IsHalfBlock) { - num167 += 8f; + yPixelDistance += 8f; } - if (Main.tile[num165, num166 - 1].IsHalfBlock) + if (Main.tile[xTileBelow, yTileBelow - 1].IsHalfBlock) { - num167 -= 8f; + yPixelDistance -= 8f; } - if (num167 < position2.Y + (float)NPC.height) + if (yPixelDistance < fishePosition.Y + (float)NPC.height) { - float num168 = position2.Y + (float)NPC.height - num167; - float num169 = 16.1f; - if (num168 <= num169) + float percentageTileRisen = fishePosition.Y + (float)NPC.height - yPixelDistance; + float fullTileAmt = 16.1f; + if (percentageTileRisen <= fullTileAmt) { - NPC.gfxOffY += NPC.position.Y + (float)NPC.height - num167; - NPC.position.Y = num167 - (float)NPC.height; - if (num168 < 9f) + NPC.gfxOffY += NPC.position.Y + (float)NPC.height - yPixelDistance; + NPC.position.Y = yPixelDistance - (float)NPC.height; + if (percentageTileRisen < 9f) { NPC.stepSpeed = 1f; } @@ -210,57 +210,57 @@ namespace CalamityMod.NPCs.NormalNPCs } } } - if (flag22) + if (isOnSolidTile) { - int num170 = (int)((NPC.position.X + (float)(NPC.width / 2) + (float)(15 * NPC.direction)) / 16f); - int num171 = (int)((NPC.position.Y + (float)NPC.height - 15f) / 16f); - if ((Main.tile[num170, num171 - 1].HasUnactuatedTile && (Main.tile[num170, num171 - 1].TileType == 10 || Main.tile[num170, num171 - 1].TileType == 388)) & flag5) + int doorCheckX = (int)((NPC.position.X + (float)(NPC.width / 2) + (float)(15 * NPC.direction)) / 16f); + int doorCheckY = (int)((NPC.position.Y + (float)NPC.height - 15f) / 16f); + if ((Main.tile[doorCheckX, doorCheckY - 1].HasUnactuatedTile && (Main.tile[doorCheckX, doorCheckY - 1].TileType == 10 || Main.tile[doorCheckX, doorCheckY - 1].TileType == 388)) & unusedFlag) { NPC.ai[2] += 1f; NPC.ai[3] = 0f; if (NPC.ai[2] >= 60f) { NPC.velocity.X = 0.5f * (float)-(float)NPC.direction; - int num172 = 5; - if (Main.tile[num170, num171 - 1].TileType == 388) + int doorOpenInc = 5; + if (Main.tile[doorCheckX, doorCheckY - 1].TileType == 388) { - num172 = 2; + doorOpenInc = 2; } - NPC.ai[1] += (float)num172; + NPC.ai[1] += (float)doorOpenInc; NPC.ai[2] = 0f; - bool flag23 = false; + bool letMeIn = false; if (NPC.ai[1] >= 10f) { - flag23 = true; + letMeIn = true; NPC.ai[1] = 10f; } - WorldGen.KillTile(num170, num171 - 1, true, false, false); - if ((Main.netMode != NetmodeID.MultiplayerClient || !flag23) && flag23 && Main.netMode != NetmodeID.MultiplayerClient) + WorldGen.KillTile(doorCheckX, doorCheckY - 1, true, false, false); + if ((Main.netMode != NetmodeID.MultiplayerClient || !letMeIn) && letMeIn && Main.netMode != NetmodeID.MultiplayerClient) { - if (Main.tile[num170, num171 - 1].TileType == 10) + if (Main.tile[doorCheckX, doorCheckY - 1].TileType == 10) { - bool flag24 = WorldGen.OpenDoor(num170, num171 - 1, NPC.direction); - if (!flag24) + bool canOpenDoor = WorldGen.OpenDoor(doorCheckX, doorCheckY - 1, NPC.direction); + if (!canOpenDoor) { - NPC.ai[3] = (float)num35; + NPC.ai[3] = (float)backUpTimer; NPC.netUpdate = true; } - if (Main.netMode == NetmodeID.Server & flag24) + if (Main.netMode == NetmodeID.Server & canOpenDoor) { - NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 0, (float)num170, (float)(num171 - 1), (float)NPC.direction, 0, 0, 0); + NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 0, (float)doorCheckX, (float)(doorCheckY - 1), (float)NPC.direction, 0, 0, 0); } } - if (Main.tile[num170, num171 - 1].TileType == 388) + if (Main.tile[doorCheckX, doorCheckY - 1].TileType == 388) { - bool flag25 = WorldGen.ShiftTallGate(num170, num171 - 1, false); - if (!flag25) + bool canOpenTallGate = WorldGen.ShiftTallGate(doorCheckX, doorCheckY - 1, false); + if (!canOpenTallGate) { - NPC.ai[3] = (float)num35; + NPC.ai[3] = (float)backUpTimer; NPC.netUpdate = true; } - if (Main.netMode == NetmodeID.Server & flag25) + if (Main.netMode == NetmodeID.Server & canOpenTallGate) { - NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 4, (float)num170, (float)(num171 - 1), 0f, 0, 0, 0); + NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 4, (float)doorCheckX, (float)(doorCheckY - 1), 0f, 0, 0, 0); } } } @@ -268,12 +268,12 @@ namespace CalamityMod.NPCs.NormalNPCs } else { - int num173 = NPC.spriteDirection; - if ((NPC.velocity.X < 0f && num173 == -1) || (NPC.velocity.X > 0f && num173 == 1)) + int faceDirection = NPC.spriteDirection; + if ((NPC.velocity.X < 0f && faceDirection == -1) || (NPC.velocity.X > 0f && faceDirection == 1)) { - if (NPC.height >= 32 && Main.tile[num170, num171 - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num170, num171 - 2].TileType]) + if (NPC.height >= 32 && Main.tile[doorCheckX, doorCheckY - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[doorCheckX, doorCheckY - 2].TileType]) { - if (Main.tile[num170, num171 - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num170, num171 - 3].TileType]) + if (Main.tile[doorCheckX, doorCheckY - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[doorCheckX, doorCheckY - 3].TileType]) { NPC.velocity.Y = -8f; NPC.netUpdate = true; @@ -284,35 +284,35 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.netUpdate = true; } } - else if (Main.tile[num170, num171 - 1].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num170, num171 - 1].TileType]) + else if (Main.tile[doorCheckX, doorCheckY - 1].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[doorCheckX, doorCheckY - 1].TileType]) { NPC.velocity.Y = -6f; NPC.netUpdate = true; } - else if (NPC.position.Y + (float)NPC.height - (float)(num171 * 16) > 20f && Main.tile[num170, num171].HasUnactuatedTile && !Main.tile[num170, num171].TopSlope && Main.tileSolid[(int)Main.tile[num170, num171].TileType]) + else if (NPC.position.Y + (float)NPC.height - (float)(doorCheckY * 16) > 20f && Main.tile[doorCheckX, doorCheckY].HasUnactuatedTile && !Main.tile[doorCheckX, doorCheckY].TopSlope && Main.tileSolid[(int)Main.tile[doorCheckX, doorCheckY].TileType]) { NPC.velocity.Y = -5f; NPC.netUpdate = true; } - else if (NPC.directionY < 0 && (!Main.tile[num170, num171 + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num170, num171 + 1].TileType]) && (!Main.tile[num170 + NPC.direction, num171 + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num170 + NPC.direction, num171 + 1].TileType])) + else if (NPC.directionY < 0 && (!Main.tile[doorCheckX, doorCheckY + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[doorCheckX, doorCheckY + 1].TileType]) && (!Main.tile[doorCheckX + NPC.direction, doorCheckY + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[doorCheckX + NPC.direction, doorCheckY + 1].TileType])) { NPC.velocity.Y = -8f; NPC.velocity.X = NPC.velocity.X * 1.5f; NPC.netUpdate = true; } - else if (flag5) + else if (unusedFlag) { NPC.ai[1] = 0f; NPC.ai[2] = 0f; } - if ((NPC.velocity.Y == 0f & flag3) && NPC.ai[3] == 1f) + if ((NPC.velocity.Y == 0f & noXMovement) && NPC.ai[3] == 1f) { NPC.velocity.Y = -5f; } } } } - else if (flag5) + else if (unusedFlag) { NPC.ai[1] = 0f; NPC.ai[2] = 0f; diff --git a/NPCs/NormalNPCs/Frogfish.cs b/NPCs/NormalNPCs/Frogfish.cs index 9c5ac48c1b..9519f06eeb 100644 --- a/NPCs/NormalNPCs/Frogfish.cs +++ b/NPCs/NormalNPCs/Frogfish.cs @@ -13,7 +13,6 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 4; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); } public override void SetDefaults() @@ -51,10 +50,10 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; - int num = 200; + int alphaControl = 200; if (NPC.ai[2] == 0f) { - NPC.alpha = num; + NPC.alpha = alphaControl; NPC.TargetClosest(true); if (!Main.player[NPC.target].dead && (Main.player[NPC.target].Center - NPC.Center).Length() < 170f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) @@ -71,7 +70,7 @@ namespace CalamityMod.NPCs.NormalNPCs { if (NPC.alpha > 0) { - NPC.alpha -= num / 16; + NPC.alpha -= alphaControl / 16; if (NPC.alpha < 0) { NPC.alpha = 0; diff --git a/NPCs/NormalNPCs/Horse.cs b/NPCs/NormalNPCs/Horse.cs index 44ddff656a..927c78fb78 100644 --- a/NPCs/NormalNPCs/Horse.cs +++ b/NPCs/NormalNPCs/Horse.cs @@ -21,7 +21,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 6; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.4f, PortraitScale = 0.6f, @@ -127,23 +127,23 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.height = 160; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 31, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int earthDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 31, 0f, 0f, 100, default, 2f); + Main.dust[earthDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[earthDust].scale = 0.5f; + Main.dust[earthDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int earthDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default, 3f); + Main.dust[earthDust2].noGravity = true; + Main.dust[earthDust2].velocity *= 5f; + earthDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default, 2f); + Main.dust[earthDust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) @@ -238,31 +238,30 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.TargetClosest(); if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { - float num179 = 4f; - Vector2 value9 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num180 = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - value9.X; - float num181 = Math.Abs(num180) * 0.1f; - float num182 = Main.player[NPC.target].position.Y + Main.player[NPC.target].height * 0.5f - value9.Y - num181; - float num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); - num183 = num179 / num183; - num180 *= num183; - num182 *= num183; - int num184 = 30; - int num185 = ModContent.ProjectileType(); - value9.X += num180; - value9.Y += num182; - for (int num186 = 0; num186 < 4; num186++) + float rockSpeed = 4f; + Vector2 projPosition = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - projPosition.X; + float absoluteTargetX = Math.Abs(targetXDist) * 0.1f; + float targetYDist = Main.player[NPC.target].position.Y + Main.player[NPC.target].height * 0.5f - projPosition.Y - absoluteTargetX; + float targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); + targetDistance = rockSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + int rockType = ModContent.ProjectileType(); + projPosition.X += targetXDist; + projPosition.Y += targetYDist; + for (int k = 0; k < 4; k++) { - num185 = Main.rand.NextBool(4) ? ModContent.ProjectileType() : ModContent.ProjectileType(); - num180 = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - value9.X; - num182 = Main.player[NPC.target].position.Y + Main.player[NPC.target].height * 0.5f - value9.Y; - num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); - num183 = num179 / num183; - num180 += Main.rand.Next(-40, 41); - num182 += Main.rand.Next(-40, 41); - num180 *= num183; - num182 *= num183; - Projectile.NewProjectile(NPC.GetSource_FromAI(), value9.X, value9.Y, num180, num182, num185, num184, 0f, Main.myPlayer, 0f, 0f); + rockType = Main.rand.NextBool(4) ? ModContent.ProjectileType() : ModContent.ProjectileType(); + targetXDist = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - projPosition.X; + targetYDist = Main.player[NPC.target].position.Y + Main.player[NPC.target].height * 0.5f - projPosition.Y; + targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); + targetDistance = rockSpeed / targetDistance; + targetXDist += Main.rand.Next(-40, 41); + targetYDist += Main.rand.Next(-40, 41); + targetXDist *= targetDistance; + targetYDist *= targetDistance; + Projectile.NewProjectile(NPC.GetSource_FromAI(), projPosition.X, projPosition.Y, targetXDist, targetYDist, rockType, 30, 0f, Main.myPlayer, 0f, 0f); } } } diff --git a/NPCs/NormalNPCs/IceClasper.cs b/NPCs/NormalNPCs/IceClasper.cs index 0463aa5254..b68a91fd1d 100644 --- a/NPCs/NormalNPCs/IceClasper.cs +++ b/NPCs/NormalNPCs/IceClasper.cs @@ -66,10 +66,8 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 6; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); - value.Rotation = MathHelper.ToRadians(45); - value.Position.Y += 12; - value.PortraitPositionYOverride = 12f; + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0); + value.Rotation = MathHelper.ToRadians(135); NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; NPCID.Sets.TrailingMode[NPC.type] = 0; NPCID.Sets.TrailCacheLength[NPC.type] = 6; diff --git a/NPCs/NormalNPCs/ImpiousImmolator.cs b/NPCs/NormalNPCs/ImpiousImmolator.cs index ce2b86ec15..7278c038d5 100644 --- a/NPCs/NormalNPCs/ImpiousImmolator.cs +++ b/NPCs/NormalNPCs/ImpiousImmolator.cs @@ -87,13 +87,13 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.chaseable = hasBeenHit; if (!NPC.wet) { - bool flag14 = hasBeenHit; + bool canAttack = hasBeenHit; NPC.TargetClosest(false); - if ((Main.player[NPC.target].wet || Main.player[NPC.target].dead) && flag14) + if ((Main.player[NPC.target].wet || Main.player[NPC.target].dead) && canAttack) { - flag14 = false; + canAttack = false; } - if (!flag14) + if (!canAttack) { if (NPC.collideX) { @@ -118,7 +118,7 @@ namespace CalamityMod.NPCs.NormalNPCs } } } - if (flag14) + if (canAttack) { NPC.TargetClosest(true); NPC.velocity.X = NPC.velocity.X + (float)NPC.direction * 0.2f; @@ -151,19 +151,19 @@ namespace CalamityMod.NPCs.NormalNPCs if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { float speed = 12f; - Vector2 vector = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)(NPC.height / 2)); - float num6 = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - vector.X + (float)Main.rand.Next(-20, 21); - float num7 = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - vector.Y + (float)Main.rand.Next(-20, 21); - float num8 = (float)Math.Sqrt((double)(num6 * num6 + num7 * num7)); - num8 = speed / num8; - num6 *= num8; - num7 *= num8; + Vector2 beamPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)(NPC.height / 2)); + float targetXDist = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - beamPosition.X + (float)Main.rand.Next(-20, 21); + float targetYDist = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - beamPosition.Y + (float)Main.rand.Next(-20, 21); + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + targetDistance = speed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; int damage = 55; if (Main.expertMode) { damage = 42; } - int beam = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, num6, num7, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); + int beam = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, targetXDist, targetYDist, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); Main.projectile[beam].tileCollide = true; } } @@ -192,15 +192,15 @@ namespace CalamityMod.NPCs.NormalNPCs } } } - int num258 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num259 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount < 128) //problem? + int tileCheckX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int tileCheckY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[tileCheckX, tileCheckY - 1].LiquidAmount < 128) //problem? { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[tileCheckX, tileCheckY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[tileCheckX, tileCheckY + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/NormalNPCs/KingSlimeJewel.cs b/NPCs/NormalNPCs/KingSlimeJewel.cs index 939d93d677..bc10f7bc3a 100644 --- a/NPCs/NormalNPCs/KingSlimeJewel.cs +++ b/NPCs/NormalNPCs/KingSlimeJewel.cs @@ -19,7 +19,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { - NPCID.Sets.NPCBestiaryDrawModifiers bestiaryData = new NPCID.Sets.NPCBestiaryDrawModifiers() { Hide = true }; + NPCID.Sets.NPCBestiaryDrawModifiers bestiaryData = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Hide = true }; NPCID.Sets.NPCBestiaryDrawOffset.Add(Type, bestiaryData); } @@ -189,23 +189,23 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.height = 45; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 2; num621++) + for (int i = 0; i < 2; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 90, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int rubyDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 90, 0f, 0f, 100, default, 2f); + Main.dust[rubyDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].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; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 90, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 90, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int rubyDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 90, 0f, 0f, 100, default, 3f); + Main.dust[rubyDust2].noGravity = true; + Main.dust[rubyDust2].velocity *= 5f; + rubyDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 90, 0f, 0f, 100, default, 2f); + Main.dust[rubyDust2].velocity *= 2f; } } } diff --git a/NPCs/NormalNPCs/MantisShrimp.cs b/NPCs/NormalNPCs/MantisShrimp.cs index 0cbdd09dde..2ccd64a058 100644 --- a/NPCs/NormalNPCs/MantisShrimp.cs +++ b/NPCs/NormalNPCs/MantisShrimp.cs @@ -15,7 +15,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 6; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { SpriteDirection = 1 }; @@ -55,43 +55,43 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { NPC.spriteDirection = (NPC.direction > 0) ? -1 : 1; - float num79 = (Main.player[NPC.target].Center - NPC.Center).Length(); - num79 *= 0.0025f; - if ((double)num79 > 1.5) + float targetDist = (Main.player[NPC.target].Center - NPC.Center).Length(); + targetDist *= 0.0025f; + if ((double)targetDist > 1.5) { - num79 = 1.5f; + targetDist = 1.5f; } - float num78; + float maxSpeed; if (Main.expertMode) { - num78 = 3f - num79; + maxSpeed = 3f - targetDist; } else { - num78 = 2.5f - num79; + maxSpeed = 2.5f - targetDist; } - num78 *= (CalamityWorld.death ? 1.2f : CalamityWorld.revenge ? 1f : 0.8f); - if (NPC.velocity.X < -num78 || NPC.velocity.X > num78) + maxSpeed *= (CalamityWorld.death ? 1.2f : CalamityWorld.revenge ? 1f : 0.8f); + if (NPC.velocity.X < -maxSpeed || NPC.velocity.X > maxSpeed) { if (NPC.velocity.Y == 0f) { NPC.velocity *= 0.8f; } } - else if (NPC.velocity.X < num78 && NPC.direction == 1) + else if (NPC.velocity.X < maxSpeed && NPC.direction == 1) { NPC.velocity.X = NPC.velocity.X + 1f; - if (NPC.velocity.X > num78) + if (NPC.velocity.X > maxSpeed) { - NPC.velocity.X = num78; + NPC.velocity.X = maxSpeed; } } - else if (NPC.velocity.X > -num78 && NPC.direction == -1) + else if (NPC.velocity.X > -maxSpeed && NPC.direction == -1) { NPC.velocity.X = NPC.velocity.X - 1f; - if (NPC.velocity.X < -num78) + if (NPC.velocity.X < -maxSpeed) { - NPC.velocity.X = -num78; + NPC.velocity.X = -maxSpeed; } } } diff --git a/NPCs/NormalNPCs/OverloadedSoldier.cs b/NPCs/NormalNPCs/OverloadedSoldier.cs index c809377f28..b9911088c5 100644 --- a/NPCs/NormalNPCs/OverloadedSoldier.cs +++ b/NPCs/NormalNPCs/OverloadedSoldier.cs @@ -104,23 +104,23 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { Lighting.AddLight((int)((NPC.position.X + (float)(NPC.width / 2)) / 16f), (int)((NPC.position.Y + (float)(NPC.height / 2)) / 16f), 0.35f, 0f, 0.15f); - bool flag3 = false; + bool noXMovement = false; if (NPC.velocity.X == 0f) { - flag3 = true; + noXMovement = true; } if (NPC.justHit) { - flag3 = false; + noXMovement = false; } - bool flag4 = false; - bool flag5 = false; - int num35 = 60; + bool isWalking = false; + bool unusedFlag = false; + int backUpTimer = 60; if (NPC.velocity.Y == 0f && ((NPC.velocity.X > 0f && NPC.direction < 0) || (NPC.velocity.X < 0f && NPC.direction > 0))) { - flag4 = true; + isWalking = true; } - if ((NPC.position.X == NPC.oldPosition.X || NPC.ai[3] >= (float)num35) | flag4) + if ((NPC.position.X == NPC.oldPosition.X || NPC.ai[3] >= (float)backUpTimer) | isWalking) { NPC.ai[3] += 1f; } @@ -128,7 +128,7 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.ai[3] -= 1f; } - if (NPC.ai[3] > (float)(num35 * 10)) + if (NPC.ai[3] > (float)(backUpTimer * 10)) { NPC.ai[3] = 0f; } @@ -136,11 +136,11 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.ai[3] = 0f; } - if (NPC.ai[3] == (float)num35) + if (NPC.ai[3] == (float)backUpTimer) { NPC.netUpdate = true; } - if (NPC.ai[3] < (float)num35) + if (NPC.ai[3] < (float)backUpTimer) { NPC.TargetClosest(true); } @@ -168,88 +168,88 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.direction = 1; } } - float num65 = 1.5f; - float num66 = 0.1f; + float maxVelocity = 1.5f; + float acceleration = 0.1f; if (CalamityWorld.death) { - num65 *= 1.5f; - num66 *= 1.5f; + maxVelocity *= 1.5f; + acceleration *= 1.5f; } if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) < 400f) { - num65 += (CalamityWorld.death ? 8f : CalamityWorld.revenge ? 6f : 4f) - ((Main.player[NPC.target].Center - NPC.Center).Length() * 0.01f); + maxVelocity += (CalamityWorld.death ? 8f : CalamityWorld.revenge ? 6f : 4f) - ((Main.player[NPC.target].Center - NPC.Center).Length() * 0.01f); } - if (NPC.velocity.X < -num65 || NPC.velocity.X > num65) + if (NPC.velocity.X < -maxVelocity || NPC.velocity.X > maxVelocity) { if (NPC.velocity.Y == 0f) NPC.velocity *= 0.7f; } - else if (NPC.velocity.X < num65 && NPC.direction == 1) + else if (NPC.velocity.X < maxVelocity && NPC.direction == 1) { - NPC.velocity.X = NPC.velocity.X + num66; - if (NPC.velocity.X > num65) - NPC.velocity.X = num65; + NPC.velocity.X = NPC.velocity.X + acceleration; + if (NPC.velocity.X > maxVelocity) + NPC.velocity.X = maxVelocity; } - else if (NPC.velocity.X > -num65 && NPC.direction == -1) + else if (NPC.velocity.X > -maxVelocity && NPC.direction == -1) { - NPC.velocity.X = NPC.velocity.X - num66; - if (NPC.velocity.X < -num65) - NPC.velocity.X = -num65; + NPC.velocity.X = NPC.velocity.X - acceleration; + if (NPC.velocity.X < -maxVelocity) + NPC.velocity.X = -maxVelocity; } - bool flag22 = false; + bool isOnSolidTile = false; if (NPC.velocity.Y == 0f) { - int num161 = (int)(NPC.position.Y + (float)NPC.height + 7f) / 16; - int arg_A8FB_0 = (int)NPC.position.X / 16; - int num162 = (int)(NPC.position.X + (float)NPC.width) / 16; - for (int num163 = arg_A8FB_0; num163 <= num162; num163++) + int yTile = (int)(NPC.position.Y + (float)NPC.height + 7f) / 16; + int initialXTile = (int)NPC.position.X / 16; + int maxXTile = (int)(NPC.position.X + (float)NPC.width) / 16; + for (int xTile = initialXTile; xTile <= maxXTile; xTile++) { - if (Main.tile[num163, num161] == null) + if (Main.tile[xTile, yTile] == null) { return; } - if (Main.tile[num163, num161].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num163, num161].TileType]) + if (Main.tile[xTile, yTile].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[xTile, yTile].TileType]) { - flag22 = true; + isOnSolidTile = true; break; } } } if (NPC.velocity.Y >= 0f) { - int num164 = 0; + int fallFaceDirection = 0; if (NPC.velocity.X < 0f) { - num164 = -1; + fallFaceDirection = -1; } if (NPC.velocity.X > 0f) { - num164 = 1; + fallFaceDirection = 1; } - Vector2 position2 = NPC.position; - position2.X += NPC.velocity.X; - int num165 = (int)((position2.X + (float)(NPC.width / 2) + (float)((NPC.width / 2 + 1) * num164)) / 16f); - int num166 = (int)((position2.Y + (float)NPC.height - 1f) / 16f); - if ((float)(num165 * 16) < position2.X + (float)NPC.width && (float)(num165 * 16 + 16) > position2.X && ((Main.tile[num165, num166].HasUnactuatedTile && !Main.tile[num165, num166].TopSlope && !Main.tile[num165, num166 - 1].TopSlope && Main.tileSolid[(int)Main.tile[num165, num166].TileType] && !Main.tileSolidTop[(int)Main.tile[num165, num166].TileType]) || (Main.tile[num165, num166 - 1].IsHalfBlock && Main.tile[num165, num166 - 1].HasUnactuatedTile)) && (!Main.tile[num165, num166 - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num165, num166 - 1].TileType] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 1].TileType] || (Main.tile[num165, num166 - 1].IsHalfBlock && (!Main.tile[num165, num166 - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num165, num166 - 4].TileType] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 4].TileType]))) && (!Main.tile[num165, num166 - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num165, num166 - 2].TileType] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 2].TileType]) && (!Main.tile[num165, num166 - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num165, num166 - 3].TileType] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 3].TileType]) && (!Main.tile[num165 - num164, num166 - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num165 - num164, num166 - 3].TileType])) + Vector2 ghostPosition = NPC.position; + ghostPosition.X += NPC.velocity.X; + int xTileBelow = (int)((ghostPosition.X + (float)(NPC.width / 2) + (float)((NPC.width / 2 + 1) * fallFaceDirection)) / 16f); + int yTileBelow = (int)((ghostPosition.Y + (float)NPC.height - 1f) / 16f); + if ((float)(xTileBelow * 16) < ghostPosition.X + (float)NPC.width && (float)(xTileBelow * 16 + 16) > ghostPosition.X && ((Main.tile[xTileBelow, yTileBelow].HasUnactuatedTile && !Main.tile[xTileBelow, yTileBelow].TopSlope && !Main.tile[xTileBelow, yTileBelow - 1].TopSlope && Main.tileSolid[(int)Main.tile[xTileBelow, yTileBelow].TileType] && !Main.tileSolidTop[(int)Main.tile[xTileBelow, yTileBelow].TileType]) || (Main.tile[xTileBelow, yTileBelow - 1].IsHalfBlock && Main.tile[xTileBelow, yTileBelow - 1].HasUnactuatedTile)) && (!Main.tile[xTileBelow, yTileBelow - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[xTileBelow, yTileBelow - 1].TileType] || Main.tileSolidTop[(int)Main.tile[xTileBelow, yTileBelow - 1].TileType] || (Main.tile[xTileBelow, yTileBelow - 1].IsHalfBlock && (!Main.tile[xTileBelow, yTileBelow - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[xTileBelow, yTileBelow - 4].TileType] || Main.tileSolidTop[(int)Main.tile[xTileBelow, yTileBelow - 4].TileType]))) && (!Main.tile[xTileBelow, yTileBelow - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[xTileBelow, yTileBelow - 2].TileType] || Main.tileSolidTop[(int)Main.tile[xTileBelow, yTileBelow - 2].TileType]) && (!Main.tile[xTileBelow, yTileBelow - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[xTileBelow, yTileBelow - 3].TileType] || Main.tileSolidTop[(int)Main.tile[xTileBelow, yTileBelow - 3].TileType]) && (!Main.tile[xTileBelow - fallFaceDirection, yTileBelow - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[xTileBelow - fallFaceDirection, yTileBelow - 3].TileType])) { - float num167 = (float)(num166 * 16); - if (Main.tile[num165, num166].IsHalfBlock) + float yPixelDistance = (float)(yTileBelow * 16); + if (Main.tile[xTileBelow, yTileBelow].IsHalfBlock) { - num167 += 8f; + yPixelDistance += 8f; } - if (Main.tile[num165, num166 - 1].IsHalfBlock) + if (Main.tile[xTileBelow, yTileBelow - 1].IsHalfBlock) { - num167 -= 8f; + yPixelDistance -= 8f; } - if (num167 < position2.Y + (float)NPC.height) + if (yPixelDistance < ghostPosition.Y + (float)NPC.height) { - float num168 = position2.Y + (float)NPC.height - num167; - float num169 = 16.1f; - if (num168 <= num169) + float percentageTileRisen = ghostPosition.Y + (float)NPC.height - yPixelDistance; + float fullTileAmt = 16.1f; + if (percentageTileRisen <= fullTileAmt) { - NPC.gfxOffY += NPC.position.Y + (float)NPC.height - num167; - NPC.position.Y = num167 - (float)NPC.height; - if (num168 < 9f) + NPC.gfxOffY += NPC.position.Y + (float)NPC.height - yPixelDistance; + NPC.position.Y = yPixelDistance - (float)NPC.height; + if (percentageTileRisen < 9f) { NPC.stepSpeed = 1f; } @@ -261,57 +261,57 @@ namespace CalamityMod.NPCs.NormalNPCs } } } - if (flag22) + if (isOnSolidTile) { - int num170 = (int)((NPC.position.X + (float)(NPC.width / 2) + (float)(15 * NPC.direction)) / 16f); - int num171 = (int)((NPC.position.Y + (float)NPC.height - 15f) / 16f); - if ((Main.tile[num170, num171 - 1].HasUnactuatedTile && (Main.tile[num170, num171 - 1].TileType == 10 || Main.tile[num170, num171 - 1].TileType == 388)) & flag5) + int doorCheckX = (int)((NPC.position.X + (float)(NPC.width / 2) + (float)(15 * NPC.direction)) / 16f); + int doorCheckY = (int)((NPC.position.Y + (float)NPC.height - 15f) / 16f); + if ((Main.tile[doorCheckX, doorCheckY - 1].HasUnactuatedTile && (Main.tile[doorCheckX, doorCheckY - 1].TileType == 10 || Main.tile[doorCheckX, doorCheckY - 1].TileType == 388)) & unusedFlag) { NPC.ai[2] += 1f; NPC.ai[3] = 0f; if (NPC.ai[2] >= 60f) { NPC.velocity.X = 0.5f * (float)-(float)NPC.direction; - int num172 = 5; - if (Main.tile[num170, num171 - 1].TileType == 388) + int doorOpenInc = 5; + if (Main.tile[doorCheckX, doorCheckY - 1].TileType == 388) { - num172 = 2; + doorOpenInc = 2; } - NPC.ai[1] += (float)num172; + NPC.ai[1] += (float)doorOpenInc; NPC.ai[2] = 0f; - bool flag23 = false; + bool letMeIn = false; if (NPC.ai[1] >= 10f) { - flag23 = true; + letMeIn = true; NPC.ai[1] = 10f; } - WorldGen.KillTile(num170, num171 - 1, true, false, false); - if ((Main.netMode != NetmodeID.MultiplayerClient || !flag23) && flag23 && Main.netMode != NetmodeID.MultiplayerClient) + WorldGen.KillTile(doorCheckX, doorCheckY - 1, true, false, false); + if ((Main.netMode != NetmodeID.MultiplayerClient || !letMeIn) && letMeIn && Main.netMode != NetmodeID.MultiplayerClient) { - if (Main.tile[num170, num171 - 1].TileType == 10) + if (Main.tile[doorCheckX, doorCheckY - 1].TileType == 10) { - bool flag24 = WorldGen.OpenDoor(num170, num171 - 1, NPC.direction); - if (!flag24) + bool canOpenDoor = WorldGen.OpenDoor(doorCheckX, doorCheckY - 1, NPC.direction); + if (!canOpenDoor) { - NPC.ai[3] = (float)num35; + NPC.ai[3] = (float)backUpTimer; NPC.netUpdate = true; } - if (Main.netMode == NetmodeID.Server & flag24) + if (Main.netMode == NetmodeID.Server & canOpenDoor) { - NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 0, (float)num170, (float)(num171 - 1), (float)NPC.direction, 0, 0, 0); + NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 0, (float)doorCheckX, (float)(doorCheckY - 1), (float)NPC.direction, 0, 0, 0); } } - if (Main.tile[num170, num171 - 1].TileType == 388) + if (Main.tile[doorCheckX, doorCheckY - 1].TileType == 388) { - bool flag25 = WorldGen.ShiftTallGate(num170, num171 - 1, false); - if (!flag25) + bool canOpenTallGate = WorldGen.ShiftTallGate(doorCheckX, doorCheckY - 1, false); + if (!canOpenTallGate) { - NPC.ai[3] = (float)num35; + NPC.ai[3] = (float)backUpTimer; NPC.netUpdate = true; } - if (Main.netMode == NetmodeID.Server & flag25) + if (Main.netMode == NetmodeID.Server & canOpenTallGate) { - NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 4, (float)num170, (float)(num171 - 1), 0f, 0, 0, 0); + NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 4, (float)doorCheckX, (float)(doorCheckY - 1), 0f, 0, 0, 0); } } } @@ -319,12 +319,12 @@ namespace CalamityMod.NPCs.NormalNPCs } else { - int num173 = NPC.spriteDirection; - if ((NPC.velocity.X < 0f && num173 == -1) || (NPC.velocity.X > 0f && num173 == 1)) + int faceDirection = NPC.spriteDirection; + if ((NPC.velocity.X < 0f && faceDirection == -1) || (NPC.velocity.X > 0f && faceDirection == 1)) { - if (NPC.height >= 32 && Main.tile[num170, num171 - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num170, num171 - 2].TileType]) + if (NPC.height >= 32 && Main.tile[doorCheckX, doorCheckY - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[doorCheckX, doorCheckY - 2].TileType]) { - if (Main.tile[num170, num171 - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num170, num171 - 3].TileType]) + if (Main.tile[doorCheckX, doorCheckY - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[doorCheckX, doorCheckY - 3].TileType]) { NPC.velocity.Y = -8f; NPC.netUpdate = true; @@ -335,35 +335,35 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.netUpdate = true; } } - else if (Main.tile[num170, num171 - 1].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num170, num171 - 1].TileType]) + else if (Main.tile[doorCheckX, doorCheckY - 1].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[doorCheckX, doorCheckY - 1].TileType]) { NPC.velocity.Y = -6f; NPC.netUpdate = true; } - else if (NPC.position.Y + (float)NPC.height - (float)(num171 * 16) > 20f && Main.tile[num170, num171].HasUnactuatedTile && !Main.tile[num170, num171].TopSlope && Main.tileSolid[(int)Main.tile[num170, num171].TileType]) + else if (NPC.position.Y + (float)NPC.height - (float)(doorCheckY * 16) > 20f && Main.tile[doorCheckX, doorCheckY].HasUnactuatedTile && !Main.tile[doorCheckX, doorCheckY].TopSlope && Main.tileSolid[(int)Main.tile[doorCheckX, doorCheckY].TileType]) { NPC.velocity.Y = -5f; NPC.netUpdate = true; } - else if (NPC.directionY < 0 && (!Main.tile[num170, num171 + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num170, num171 + 1].TileType]) && (!Main.tile[num170 + NPC.direction, num171 + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num170 + NPC.direction, num171 + 1].TileType])) + else if (NPC.directionY < 0 && (!Main.tile[doorCheckX, doorCheckY + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[doorCheckX, doorCheckY + 1].TileType]) && (!Main.tile[doorCheckX + NPC.direction, doorCheckY + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[doorCheckX + NPC.direction, doorCheckY + 1].TileType])) { NPC.velocity.Y = -8f; NPC.velocity.X = NPC.velocity.X * 1.5f; NPC.netUpdate = true; } - else if (flag5) + else if (unusedFlag) { NPC.ai[1] = 0f; NPC.ai[2] = 0f; } - if ((NPC.velocity.Y == 0f & flag3) && NPC.ai[3] == 1f) + if ((NPC.velocity.Y == 0f & noXMovement) && NPC.ai[3] == 1f) { NPC.velocity.Y = -5f; } } } } - else if (flag5) + else if (unusedFlag) { NPC.ai[1] = 0f; NPC.ai[2] = 0f; diff --git a/NPCs/NormalNPCs/PhantomSpirit.cs b/NPCs/NormalNPCs/PhantomSpirit.cs index 10dd45904b..a7e0bf2637 100644 --- a/NPCs/NormalNPCs/PhantomSpirit.cs +++ b/NPCs/NormalNPCs/PhantomSpirit.cs @@ -50,8 +50,8 @@ namespace CalamityMod.NPCs.NormalNPCs { float speed = CalamityWorld.death ? 22f : CalamityWorld.revenge ? 19.5f : 17f; CalamityAI.DungeonSpiritAI(NPC, Mod, speed, -MathHelper.PiOver2); - int num822 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num822]; + int polterDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[polterDust]; dust.velocity *= 0.1f; dust.scale = 1.3f; dust.noGravity = true; @@ -65,10 +65,10 @@ namespace CalamityMod.NPCs.NormalNPCs } if (NPC.life <= 0) { - for (int num288 = 0; num288 < 50; num288++) + for (int i = 0; i < 50; i++) { - int num289 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, NPC.velocity.X, NPC.velocity.Y, 0, default, 1f); - Dust dust = Main.dust[num289]; + int hitPolterDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, NPC.velocity.X, NPC.velocity.Y, 0, default, 1f); + Dust dust = Main.dust[hitPolterDust]; dust.velocity *= 2f; dust.noGravity = true; dust.scale = 1.4f; diff --git a/NPCs/NormalNPCs/PhantomSpiritL.cs b/NPCs/NormalNPCs/PhantomSpiritL.cs index 686af1f815..233e0ef259 100644 --- a/NPCs/NormalNPCs/PhantomSpiritL.cs +++ b/NPCs/NormalNPCs/PhantomSpiritL.cs @@ -64,15 +64,15 @@ namespace CalamityMod.NPCs.NormalNPCs { float speed = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 16f : CalamityWorld.revenge ? 14f : 12f; CalamityAI.DungeonSpiritAI(NPC, Mod, speed, -MathHelper.PiOver2); - int num822 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num822]; + int polterDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[polterDust]; dust.velocity *= 0.1f; dust.scale = 1.3f; dust.noGravity = true; - Vector2 vector17 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num147 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - vector17.X; - float num148 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - vector17.Y; - float num149 = (float)Math.Sqrt((double)(num147 * num147 + num148 * num148)); + Vector2 spiritPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - spiritPosition.X; + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - spiritPosition.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); if (NPC.justHit) NPC.ai[2] = 0f; @@ -81,13 +81,13 @@ namespace CalamityMod.NPCs.NormalNPCs if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[2] >= 150f) { NPC.ai[2] = 0f; - float num151 = 10f; + float projSpeed = 10f; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - num149 = num151 / num149; - num147 *= num149; - num148 *= num149; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector17.X, vector17.Y, num147, num148, type, damage, 0f, Main.myPlayer, 0f, 0f); + targetDistance = projSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + Projectile.NewProjectile(NPC.GetSource_FromAI(), spiritPosition.X, spiritPosition.Y, targetXDist, targetYDist, type, damage, 0f, Main.myPlayer, 0f, 0f); } } @@ -99,10 +99,10 @@ namespace CalamityMod.NPCs.NormalNPCs } if (NPC.life <= 0) { - for (int num288 = 0; num288 < 50; num288++) + for (int i = 0; i < 50; i++) { - int num289 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, NPC.velocity.X, NPC.velocity.Y, 0, default, 1f); - Dust dust = Main.dust[num289]; + int hitPolterDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, NPC.velocity.X, NPC.velocity.Y, 0, default, 1f); + Dust dust = Main.dust[hitPolterDust]; dust.velocity *= 2f; dust.noGravity = true; dust.scale = 1.4f; diff --git a/NPCs/NormalNPCs/PhantomSpiritM.cs b/NPCs/NormalNPCs/PhantomSpiritM.cs index d77ab006b9..3c6729f09c 100644 --- a/NPCs/NormalNPCs/PhantomSpiritM.cs +++ b/NPCs/NormalNPCs/PhantomSpiritM.cs @@ -60,8 +60,8 @@ namespace CalamityMod.NPCs.NormalNPCs { float speed = CalamityWorld.death ? 18f : CalamityWorld.revenge ? 15.75f : 13.5f; CalamityAI.DungeonSpiritAI(NPC, Mod, speed, -MathHelper.PiOver2); - int num822 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num822]; + int polterDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[polterDust]; dust.velocity *= 0.1f; dust.scale = 1.3f; dust.noGravity = true; @@ -76,10 +76,10 @@ namespace CalamityMod.NPCs.NormalNPCs } if (NPC.life <= 0) { - for (int num288 = 0; num288 < 50; num288++) + for (int i = 0; i < 50; i++) { - int num289 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, NPC.velocity.X, NPC.velocity.Y, 0, default, 1f); - Dust dust = Main.dust[num289]; + int hitPolterDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, NPC.velocity.X, NPC.velocity.Y, 0, default, 1f); + Dust dust = Main.dust[hitPolterDust]; dust.velocity *= 2f; dust.noGravity = true; dust.scale = 1.4f; diff --git a/NPCs/NormalNPCs/PhantomSpiritS.cs b/NPCs/NormalNPCs/PhantomSpiritS.cs index 4397bae9ae..de9a48fb3f 100644 --- a/NPCs/NormalNPCs/PhantomSpiritS.cs +++ b/NPCs/NormalNPCs/PhantomSpiritS.cs @@ -59,8 +59,8 @@ namespace CalamityMod.NPCs.NormalNPCs { float speed = CalamityWorld.death ? 20f : CalamityWorld.revenge ? 17.5f : 15f; CalamityAI.DungeonSpiritAI(NPC, Mod, speed, -MathHelper.PiOver2); - int num822 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num822]; + int polterDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[polterDust]; dust.velocity *= 0.1f; dust.scale = 1.3f; dust.noGravity = true; @@ -74,10 +74,10 @@ namespace CalamityMod.NPCs.NormalNPCs } if (NPC.life <= 0) { - for (int num288 = 0; num288 < 50; num288++) + for (int i = 0; i < 50; i++) { - int num289 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, NPC.velocity.X, NPC.velocity.Y, 0, default, 1f); - Dust dust = Main.dust[num289]; + int hitPolterDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, NPC.velocity.X, NPC.velocity.Y, 0, default, 1f); + Dust dust = Main.dust[hitPolterDust]; dust.velocity *= 2f; dust.noGravity = true; dust.scale = 1.4f; diff --git a/NPCs/NormalNPCs/Piggy.cs b/NPCs/NormalNPCs/Piggy.cs index ffe3b010ba..0b37b5a1ba 100644 --- a/NPCs/NormalNPCs/Piggy.cs +++ b/NPCs/NormalNPCs/Piggy.cs @@ -15,7 +15,7 @@ namespace CalamityMod.NPCs.NormalNPCs Main.npcFrameCount[NPC.type] = 5; Main.npcCatchable[NPC.type] = true; NPCID.Sets.CountsAsCritter[NPC.type] = true; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { SpriteDirection = 1 }; diff --git a/NPCs/NormalNPCs/PlanterasFreeTentacle.cs b/NPCs/NormalNPCs/PlanterasFreeTentacle.cs index bf79b29a9c..705e426cab 100644 --- a/NPCs/NormalNPCs/PlanterasFreeTentacle.cs +++ b/NPCs/NormalNPCs/PlanterasFreeTentacle.cs @@ -22,7 +22,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 4; - NPCID.Sets.NPCBestiaryDrawModifiers bestiaryData = new NPCID.Sets.NPCBestiaryDrawModifiers() { Hide = true }; + NPCID.Sets.NPCBestiaryDrawModifiers bestiaryData = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Hide = true }; NPCID.Sets.NPCBestiaryDrawOffset.Add(Type, bestiaryData); } diff --git a/NPCs/NormalNPCs/ProfanedEnergyBody.cs b/NPCs/NormalNPCs/ProfanedEnergyBody.cs index 7645c40956..ab7645b8ed 100644 --- a/NPCs/NormalNPCs/ProfanedEnergyBody.cs +++ b/NPCs/NormalNPCs/ProfanedEnergyBody.cs @@ -12,7 +12,7 @@ namespace CalamityMod.NPCs.NormalNPCs { public override void SetStaticDefaults() { - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { //Preferably would have two animated lanterns, but this static one-headded wiki image will do for now PortraitPositionYOverride = 0, diff --git a/NPCs/NormalNPCs/ProfanedEnergyLantern.cs b/NPCs/NormalNPCs/ProfanedEnergyLantern.cs index 880e72f1db..e68b2d29f5 100644 --- a/NPCs/NormalNPCs/ProfanedEnergyLantern.cs +++ b/NPCs/NormalNPCs/ProfanedEnergyLantern.cs @@ -45,10 +45,10 @@ namespace CalamityMod.NPCs.NormalNPCs return; } - int num750 = CalamityGlobalNPC.energyFlame; + int energyBase = CalamityGlobalNPC.energyFlame; if (NPC.ai[3] > 0f) { - num750 = (int)NPC.ai[3] - 1; + energyBase = (int)NPC.ai[3] - 1; } if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -62,23 +62,23 @@ namespace CalamityMod.NPCs.NormalNPCs } } NPC.TargetClosest(true); - float num751 = 0.1f; - float num752 = 500f; + float lanternAcceleration = 0.1f; + float lanternSpeed = 500f; if ((double)Main.npc[CalamityGlobalNPC.energyFlame].life < (double)Main.npc[CalamityGlobalNPC.energyFlame].lifeMax * 0.25) { - num752 += 50f; + lanternSpeed += 50f; } if ((double)Main.npc[CalamityGlobalNPC.energyFlame].life < (double)Main.npc[CalamityGlobalNPC.energyFlame].lifeMax * 0.1) { - num752 += 50f; + lanternSpeed += 50f; } if (Main.expertMode) { - float num753 = 1f - (float)NPC.life / (float)NPC.lifeMax; - num752 += num753 * 200f; - num751 += 0.15f; + float expertSpeedMult = 1f - (float)NPC.life / (float)NPC.lifeMax; + lanternSpeed += expertSpeedMult * 200f; + lanternAcceleration += 0.15f; } - if (!Main.npc[num750].active || CalamityGlobalNPC.energyFlame < 0) + if (!Main.npc[energyBase].active || CalamityGlobalNPC.energyFlame < 0) { NPC.life = 0; NPC.HitEffect(); @@ -86,49 +86,49 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.netUpdate = true; return; } - Vector2 vector22 = new Vector2(NPC.ai[0] * 16f + 8f, NPC.ai[1] * 16f + 8f); - float num189 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - (float)(NPC.width / 2) - vector22.X; - float num190 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - (float)(NPC.height / 2) - vector22.Y; - float num191 = (float)Math.Sqrt((double)(num189 * num189 + num190 * num190)); - float num754 = Main.npc[num750].position.X + (float)(Main.npc[num750].width / 2); - float num755 = Main.npc[num750].position.Y + (float)(Main.npc[num750].height / 2); - Vector2 vector93 = new Vector2(num754, num755); - float num756 = num754 + NPC.ai[0]; - float num757 = num755 + NPC.ai[1]; - float num758 = num756 - vector93.X; - float num759 = num757 - vector93.Y; - float num760 = (float)Math.Sqrt((double)(num758 * num758 + num759 * num759)); - num760 = num752 / num760; - num758 *= num760; - num759 *= num760; - if (NPC.position.X < num754 + num758) + Vector2 lanternRelocation = new Vector2(NPC.ai[0] * 16f + 8f, NPC.ai[1] * 16f + 8f); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - (float)(NPC.width / 2) - lanternRelocation.X; + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - (float)(NPC.height / 2) - lanternRelocation.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + float baseXPos = Main.npc[energyBase].position.X + (float)(Main.npc[energyBase].width / 2); + float baseYPos = Main.npc[energyBase].position.Y + (float)(Main.npc[energyBase].height / 2); + Vector2 baseCurrentPos = new Vector2(baseXPos, baseYPos); + float basePosition = baseXPos + NPC.ai[0]; + float newLanternPos = baseYPos + NPC.ai[1]; + float baseXDist = basePosition - baseCurrentPos.X; + float baseYDist = newLanternPos - baseCurrentPos.Y; + float baseDistance = (float)Math.Sqrt((double)(baseXDist * baseXDist + baseYDist * baseYDist)); + baseDistance = lanternSpeed / baseDistance; + baseXDist *= baseDistance; + baseYDist *= baseDistance; + if (NPC.position.X < baseXPos + baseXDist) { - NPC.velocity.X = NPC.velocity.X + num751; - if (NPC.velocity.X < 0f && num758 > 0f) + NPC.velocity.X = NPC.velocity.X + lanternAcceleration; + if (NPC.velocity.X < 0f && baseXDist > 0f) { NPC.velocity.X = NPC.velocity.X * 0.9f; } } - else if (NPC.position.X > num754 + num758) + else if (NPC.position.X > baseXPos + baseXDist) { - NPC.velocity.X = NPC.velocity.X - num751; - if (NPC.velocity.X > 0f && num758 < 0f) + NPC.velocity.X = NPC.velocity.X - lanternAcceleration; + if (NPC.velocity.X > 0f && baseXDist < 0f) { NPC.velocity.X = NPC.velocity.X * 0.9f; } } - if (NPC.position.Y < num755 + num759) + if (NPC.position.Y < baseYPos + baseYDist) { - NPC.velocity.Y = NPC.velocity.Y + num751; - if (NPC.velocity.Y < 0f && num759 > 0f) + NPC.velocity.Y = NPC.velocity.Y + lanternAcceleration; + if (NPC.velocity.Y < 0f && baseYDist > 0f) { NPC.velocity.Y = NPC.velocity.Y * 0.9f; } } - else if (NPC.position.Y > num755 + num759) + else if (NPC.position.Y > baseYPos + baseYDist) { - NPC.velocity.Y = NPC.velocity.Y - num751; - if (NPC.velocity.Y > 0f && num759 < 0f) + NPC.velocity.Y = NPC.velocity.Y - lanternAcceleration; + if (NPC.velocity.Y > 0f && baseYDist < 0f) { NPC.velocity.Y = NPC.velocity.Y * 0.9f; } @@ -158,21 +158,20 @@ namespace CalamityMod.NPCs.NormalNPCs { if (!Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) { - float num196 = 11f; - vector22 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num189 = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - vector22.X + (float)Main.rand.Next(-10, 11); - float num197 = Math.Abs(num189 * 0.1f); - if (num190 > 0f) + float projSpeed = 11f; + lanternRelocation = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDist = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - lanternRelocation.X + (float)Main.rand.Next(-10, 11); + float absoluteTargetX = Math.Abs(targetXDist * 0.1f); + if (targetYDist > 0f) { - num197 = 0f; + absoluteTargetX = 0f; } - num190 = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - vector22.Y + (float)Main.rand.Next(-10, 11) - num197; - num191 = (float)Math.Sqrt((double)(num189 * num189 + num190 * num190)); - num191 = num196 / num191; - num189 *= num191; - num190 *= num191; - int num9 = ModContent.ProjectileType(); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, num189, num190, num9, 40, 0f, Main.myPlayer, 0f, 0f); + targetYDist = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - lanternRelocation.Y + (float)Main.rand.Next(-10, 11) - absoluteTargetX; + targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + targetDistance = projSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, targetXDist, targetYDist, ModContent.ProjectileType(), 40, 0f, Main.myPlayer, 0f, 0f); NPC.localAI[1] = 0f; return; } diff --git a/NPCs/NormalNPCs/Rimehound.cs b/NPCs/NormalNPCs/Rimehound.cs index ebbcc6a879..610fa51baa 100644 --- a/NPCs/NormalNPCs/Rimehound.cs +++ b/NPCs/NormalNPCs/Rimehound.cs @@ -20,7 +20,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 9; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.7f, PortraitPositionXOverride = 10f, diff --git a/NPCs/NormalNPCs/ScornEater.cs b/NPCs/NormalNPCs/ScornEater.cs index 41e0a3f93b..830218703a 100644 --- a/NPCs/NormalNPCs/ScornEater.cs +++ b/NPCs/NormalNPCs/ScornEater.cs @@ -22,7 +22,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 7; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.4f, PortraitScale = 0.67f, @@ -76,20 +76,20 @@ namespace CalamityMod.NPCs.NormalNPCs if (NPC.velocity.Y == 0f) { NPC.ai[2] += 1f; - int num321 = 20; + int decelerationDelay = 20; if (NPC.ai[1] == 0f) { - num321 = 12; + decelerationDelay = 12; } if (CalamityWorld.revenge) { - num321 /= 2; + decelerationDelay /= 2; } if (CalamityWorld.death) { - num321 /= 2; + decelerationDelay /= 2; } - if (NPC.ai[2] < (float)num321) + if (NPC.ai[2] < (float)decelerationDelay) { NPC.velocity.X = NPC.velocity.X * 0.9f; return; diff --git a/NPCs/NormalNPCs/SeaUrchin.cs b/NPCs/NormalNPCs/SeaUrchin.cs index b2a4706695..b858743f58 100644 --- a/NPCs/NormalNPCs/SeaUrchin.cs +++ b/NPCs/NormalNPCs/SeaUrchin.cs @@ -10,11 +10,6 @@ namespace CalamityMod.NPCs.NormalNPCs { public class SeaUrchin : ModNPC { - public override void SetStaticDefaults() - { - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); - } - public override void SetDefaults() { NPC.aiStyle = -1; diff --git a/NPCs/NormalNPCs/ShockstormShuttle.cs b/NPCs/NormalNPCs/ShockstormShuttle.cs index e6617d3d0d..ea56e034a8 100644 --- a/NPCs/NormalNPCs/ShockstormShuttle.cs +++ b/NPCs/NormalNPCs/ShockstormShuttle.cs @@ -18,7 +18,6 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 4; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); } public override void SetDefaults() @@ -89,7 +88,7 @@ namespace CalamityMod.NPCs.NormalNPCs npcPos.X += velocity.X; npcPos.Y += velocity.Y; int spread = Main.getGoodWorld ? 100 : 20; - for (int num186 = 0; num186 < (Main.getGoodWorld ? 10 : 2); num186++) + for (int i = 0; i < (Main.getGoodWorld ? 10 : 2); i++) { velocity = Main.player[NPC.target].Center - npcPos; targetDist = velocity.Length(); @@ -107,15 +106,15 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.localAI[3] = 1f; } - Vector2 center16 = NPC.Center; - Player player8 = Main.player[NPC.target]; - if (NPC.target < 0 || NPC.target == Main.maxPlayers || player8.dead || !player8.active) + Vector2 shuttleCenter = NPC.Center; + Player targetedPlayer = Main.player[NPC.target]; + if (NPC.target < 0 || NPC.target == Main.maxPlayers || targetedPlayer.dead || !targetedPlayer.active) { NPC.TargetClosest(); - player8 = Main.player[NPC.target]; + targetedPlayer = Main.player[NPC.target]; NPC.netUpdate = true; } - if ((player8.dead || Vector2.Distance(player8.Center, center16) > 3200f) && NPC.ai[0] != 1f) + if ((targetedPlayer.dead || Vector2.Distance(targetedPlayer.Center, shuttleCenter) > 3200f) && NPC.ai[0] != 1f) { NPC.ai[0] = -1f; NPC.netUpdate = true; @@ -127,7 +126,7 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.timeLeft = 10; } - if (!player8.dead) + if (!targetedPlayer.dead) { NPC.timeLeft = 300; NPC.ai[1] = 0f; @@ -139,128 +138,127 @@ namespace CalamityMod.NPCs.NormalNPCs } else if (NPC.ai[0] == 0f) { - int num1580 = 0; + int movementPattern = 0; if (NPC.ai[3] >= 580f) { - num1580 = 0; + movementPattern = 0; } else if (NPC.ai[3] >= 440f) { - num1580 = 5; + movementPattern = 5; } else if (NPC.ai[3] >= 420f) { - num1580 = 4; + movementPattern = 4; } else if (NPC.ai[3] >= 280f) { - num1580 = 3; + movementPattern = 3; } else if (NPC.ai[3] >= 260f) { - num1580 = 2; + movementPattern = 2; } else if (NPC.ai[3] >= 20f) { - num1580 = 1; + movementPattern = 1; } NPC.ai[3] += 1f; if (NPC.ai[3] >= 600f) { NPC.ai[3] = 0f; } - int num1581 = num1580; + int patternCompare = movementPattern; if (NPC.ai[3] >= 580f) { - num1580 = 0; + movementPattern = 0; } else if (NPC.ai[3] >= 440f) { - num1580 = 5; + movementPattern = 5; } else if (NPC.ai[3] >= 420f) { - num1580 = 4; + movementPattern = 4; } else if (NPC.ai[3] >= 280f) { - num1580 = 3; + movementPattern = 3; } else if (NPC.ai[3] >= 260f) { - num1580 = 2; + movementPattern = 2; } else if (NPC.ai[3] >= 20f) { - num1580 = 1; + movementPattern = 1; } - if (num1580 != num1581) + if (movementPattern != patternCompare) { - if (num1580 == 0) + if (movementPattern == 0) { NPC.ai[2] = 0f; } - if (num1580 == 1) + if (movementPattern == 1) { - NPC.ai[2] = (float)((Math.Sign((player8.Center - center16).X) == 1) ? 1 : -1); + NPC.ai[2] = (float)((Math.Sign((targetedPlayer.Center - shuttleCenter).X) == 1) ? 1 : -1); } - if (num1580 == 2) + if (movementPattern == 2) { NPC.ai[2] = 0f; } NPC.netUpdate = true; } - if (num1580 == 0) + if (movementPattern == 0) { if (NPC.ai[2] == 0f) { - NPC.ai[2] = (float)(-600 * Math.Sign((center16 - player8.Center).X)); + NPC.ai[2] = (float)(-600 * Math.Sign((shuttleCenter - targetedPlayer.Center).X)); } - Vector2 vector196 = player8.Center + new Vector2(NPC.ai[2], -250f) - center16; - if (vector196.Length() < 50f) + Vector2 targetingDirection = targetedPlayer.Center + new Vector2(NPC.ai[2], -250f) - shuttleCenter; + if (targetingDirection.Length() < 50f) { NPC.ai[3] = 19f; } else { - vector196.Normalize(); - NPC.velocity = Vector2.Lerp(NPC.velocity, vector196 * 16f, 0.1f); + targetingDirection.Normalize(); + NPC.velocity = Vector2.Lerp(NPC.velocity, targetingDirection * 16f, 0.1f); } } - if (num1580 == 1) + if (movementPattern == 1) { - int num1582 = (int)NPC.Center.X / 16; - int num1583 = (int)(NPC.position.Y + (float)NPC.height) / 16; - int num1584 = 0; - bool flag149 = Main.tile[num1582, num1583].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num1582, num1583].TileType] && !Main.tileSolidTop[(int)Main.tile[num1582, num1583].TileType]; - if (flag149) + int npcTileX = (int)NPC.Center.X / 16; + int npcTileY = (int)(NPC.position.Y + (float)NPC.height) / 16; + int upwardMoveAmt = 0; + bool solidTilePresent = Main.tile[npcTileX, npcTileY].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY].TileType] && !Main.tileSolidTop[(int)Main.tile[npcTileX, npcTileY].TileType]; + if (solidTilePresent) { - num1584 = 1; + upwardMoveAmt = 1; } else { - while (num1584 < 150 && num1583 + num1584 < Main.maxTilesY) + while (upwardMoveAmt < 150 && npcTileY + upwardMoveAmt < Main.maxTilesY) { - int num1585 = num1583 + num1584; - bool flag150 = Main.tile[num1582, num1585].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num1582, num1585].TileType] && !Main.tileSolidTop[(int)Main.tile[num1582, num1585].TileType]; - if (flag150) + int npcTileYUp = npcTileY + upwardMoveAmt; + bool solidTilePresentAgain = Main.tile[npcTileX, npcTileYUp].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, npcTileYUp].TileType] && !Main.tileSolidTop[(int)Main.tile[npcTileX, npcTileYUp].TileType]; + if (solidTilePresentAgain) { - num1584--; + upwardMoveAmt--; break; } - num1584++; + upwardMoveAmt++; } } - float num1586 = (float)(num1584 * 16); - float num1587 = 250f; - if (num1586 < num1587) + float pixelsUpAmt = (float)(upwardMoveAmt * 16); + if (pixelsUpAmt < 250f) { - float num1588 = -4f; - if (-num1588 > num1586) + float velocityUpwards = -4f; + if (-velocityUpwards > pixelsUpAmt) { - num1588 = -num1586; + velocityUpwards = -pixelsUpAmt; } - NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, num1588, 0.05f); + NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, velocityUpwards, 0.05f); } else { @@ -268,106 +266,104 @@ namespace CalamityMod.NPCs.NormalNPCs } NPC.velocity.X = 3.5f * NPC.ai[2]; } - if (num1580 == 2) + if (movementPattern == 2) { if (NPC.ai[2] == 0f) { - NPC.ai[2] = (float)(300 * Math.Sign((center16 - player8.Center).X)); + NPC.ai[2] = (float)(300 * Math.Sign((shuttleCenter - targetedPlayer.Center).X)); } - Vector2 vector197 = player8.Center + new Vector2(NPC.ai[2], -170f) - center16; - int num1589 = (int)NPC.Center.X / 16; - int num1590 = (int)(NPC.position.Y + (float)NPC.height) / 16; - int num1591 = 0; - bool flag151 = Main.tile[num1589, num1590].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num1589, num1590].TileType] && !Main.tileSolidTop[(int)Main.tile[num1589, num1590].TileType]; - if (flag151) + Vector2 targetingCenter2 = targetedPlayer.Center + new Vector2(NPC.ai[2], -170f) - shuttleCenter; + int npcTileX2 = (int)NPC.Center.X / 16; + int npcTileY2 = (int)(NPC.position.Y + (float)NPC.height) / 16; + int upwardsMovement = 0; + bool solidTile = Main.tile[npcTileX2, npcTileY2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX2, npcTileY2].TileType] && !Main.tileSolidTop[(int)Main.tile[npcTileX2, npcTileY2].TileType]; + if (solidTile) { - num1591 = 1; + upwardsMovement = 1; } else { - while (num1591 < 150 && num1590 + num1591 < Main.maxTilesY) + while (upwardsMovement < 150 && npcTileY2 + upwardsMovement < Main.maxTilesY) { - int num1592 = num1590 + num1591; - bool flag152 = Main.tile[num1589, num1592].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num1589, num1592].TileType] && !Main.tileSolidTop[(int)Main.tile[num1589, num1592].TileType]; - if (flag152) + int npcTileYUp2 = npcTileY2 + upwardsMovement; + bool solidTileAgain = Main.tile[npcTileX2, npcTileYUp2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX2, npcTileYUp2].TileType] && !Main.tileSolidTop[(int)Main.tile[npcTileX2, npcTileYUp2].TileType]; + if (solidTileAgain) { - num1591--; + upwardsMovement--; break; } - num1591++; + upwardsMovement++; } } - float num1593 = (float)(num1591 * 16); - float num1594 = 170f; - if (num1593 < num1594) + float pixelsUpAmt2 = (float)(upwardsMovement * 16); + if (pixelsUpAmt2 < 170f) { - vector197.Y -= num1594 - num1593; + targetingCenter2.Y -= 170f - pixelsUpAmt2; } - if (vector197.Length() < 70f) + if (targetingCenter2.Length() < 70f) { NPC.ai[3] = 279f; } else { - vector197.Normalize(); - NPC.velocity = Vector2.Lerp(NPC.velocity, vector197 * 20f, 0.1f); + targetingCenter2.Normalize(); + NPC.velocity = Vector2.Lerp(NPC.velocity, targetingCenter2 * 20f, 0.1f); } } - else if (num1580 == 3) + else if (movementPattern == 3) { - float num1595 = 0.85f; - int num1596 = (int)NPC.Center.X / 16; - int num1597 = (int)(NPC.position.Y + (float)NPC.height) / 16; - int num1598 = 0; - bool flag153 = Main.tile[num1596, num1597].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num1596, num1597].TileType] && !Main.tileSolidTop[(int)Main.tile[num1596, num1597].TileType]; - if (flag153) + float decelerationMult = 0.85f; + int npcTileX3 = (int)NPC.Center.X / 16; + int npcTileY3 = (int)(NPC.position.Y + (float)NPC.height) / 16; + int upwardsMovement3 = 0; + bool thereIsSolidTile = Main.tile[npcTileX3, npcTileY3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX3, npcTileY3].TileType] && !Main.tileSolidTop[(int)Main.tile[npcTileX3, npcTileY3].TileType]; + if (thereIsSolidTile) { - num1598 = 1; + upwardsMovement3 = 1; } else { - while (num1598 < 150 && num1597 + num1598 < Main.maxTilesY) + while (upwardsMovement3 < 150 && npcTileY3 + upwardsMovement3 < Main.maxTilesY) { - int num1599 = num1597 + num1598; - bool flag154 = Main.tile[num1596, num1599].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num1596, num1599].TileType] && !Main.tileSolidTop[(int)Main.tile[num1596, num1599].TileType]; - if (flag154) + int npcTileYUp3 = npcTileY3 + upwardsMovement3; + bool thereIsSolidTileAgain = Main.tile[npcTileX3, npcTileYUp3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX3, npcTileYUp3].TileType] && !Main.tileSolidTop[(int)Main.tile[npcTileX3, npcTileYUp3].TileType]; + if (thereIsSolidTileAgain) { - num1598--; + upwardsMovement3--; break; } - num1598++; + upwardsMovement3++; } } - float num1600 = (float)(num1598 * 16); - float num1601 = 170f; - if (num1600 < num1601) + float pixelUpAmt3 = (float)(upwardsMovement3 * 16); + if (pixelUpAmt3 < 170f) { - float num1602 = -4f; - if (-num1602 > num1600) + float velocityUpwards3 = -4f; + if (-velocityUpwards3 > pixelUpAmt3) { - num1602 = -num1600; + velocityUpwards3 = -pixelUpAmt3; } - NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, num1602, 0.05f); + NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, velocityUpwards3, 0.05f); } else { - NPC.velocity.Y = NPC.velocity.Y * num1595; + NPC.velocity.Y = NPC.velocity.Y * decelerationMult; } - NPC.velocity.X = NPC.velocity.X * num1595; + NPC.velocity.X = NPC.velocity.X * decelerationMult; } - if (num1580 == 4) + if (movementPattern == 4) { - Vector2 vector198 = player8.Center + new Vector2(0f, -250f) - center16; - if (vector198.Length() < 50f) + Vector2 targetingCenter4 = targetedPlayer.Center + new Vector2(0f, -250f) - shuttleCenter; + if (targetingCenter4.Length() < 50f) { NPC.ai[3] = 439f; return; } - vector198.Normalize(); - NPC.velocity = Vector2.Lerp(NPC.velocity, vector198 * 16f, 0.1f); + targetingCenter4.Normalize(); + NPC.velocity = Vector2.Lerp(NPC.velocity, targetingCenter4 * 16f, 0.1f); return; } - else if (num1580 == 5) + else if (movementPattern == 5) { NPC.velocity *= 0.85f; return; diff --git a/NPCs/NormalNPCs/Stormlion.cs b/NPCs/NormalNPCs/Stormlion.cs index 7c0b3a5f17..6a2fc01125 100644 --- a/NPCs/NormalNPCs/Stormlion.cs +++ b/NPCs/NormalNPCs/Stormlion.cs @@ -13,7 +13,6 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 6; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); } public override void SetDefaults() diff --git a/NPCs/NormalNPCs/Sunskater.cs b/NPCs/NormalNPCs/Sunskater.cs index fc2ecee203..ffba1f6bff 100644 --- a/NPCs/NormalNPCs/Sunskater.cs +++ b/NPCs/NormalNPCs/Sunskater.cs @@ -24,7 +24,6 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 4; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); } public override void SetDefaults() @@ -86,13 +85,13 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.chaseable = hasBeenHit; if (!NPC.wet) { - bool flag14 = hasBeenHit; + bool canAttack = hasBeenHit; NPC.TargetClosest(false); - if ((Main.player[NPC.target].wet || Main.player[NPC.target].dead) && flag14) + if ((Main.player[NPC.target].wet || Main.player[NPC.target].dead) && canAttack) { - flag14 = false; + canAttack = false; } - if (!flag14) + if (!canAttack) { if (NPC.collideX) { @@ -117,7 +116,7 @@ namespace CalamityMod.NPCs.NormalNPCs } } } - if (flag14) + if (canAttack) { NPC.TargetClosest(true); NPC.velocity.X = NPC.velocity.X + (float)NPC.direction * 0.15f; @@ -149,15 +148,15 @@ namespace CalamityMod.NPCs.NormalNPCs } } } - int num258 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num259 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount < 128) //problem? + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount < 128) //problem? { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/NormalNPCs/ThiccWaifu.cs b/NPCs/NormalNPCs/ThiccWaifu.cs index 0d4665bfd6..45454d331d 100644 --- a/NPCs/NormalNPCs/ThiccWaifu.cs +++ b/NPCs/NormalNPCs/ThiccWaifu.cs @@ -47,7 +47,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 8; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Position = new Vector2(28f, 20f), Scale = 0.65f, diff --git a/NPCs/NormalNPCs/WildBumblefuck.cs b/NPCs/NormalNPCs/WildBumblefuck.cs index 02d2222f43..0aff5466d9 100644 --- a/NPCs/NormalNPCs/WildBumblefuck.cs +++ b/NPCs/NormalNPCs/WildBumblefuck.cs @@ -20,7 +20,7 @@ namespace CalamityMod.NPCs.NormalNPCs { Main.npcFrameCount[NPC.type] = 5; NPCID.Sets.TrailingMode[NPC.type] = 1; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Position = Vector2.UnitX * 36f }; @@ -122,30 +122,28 @@ namespace CalamityMod.NPCs.NormalNPCs spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); - Color color36 = Color.Gold; - float amount9 = 0.5f; - int num153 = NPC.ai[0] == 2.1f ? 7 : 0; + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); + int afterimageAmt = NPC.ai[0] == 2.1f ? 7 : 0; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.Gold, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/NormalNPCs/WulfrumAmplifier.cs b/NPCs/NormalNPCs/WulfrumAmplifier.cs index cdfb8ce5be..2e889b8e30 100644 --- a/NPCs/NormalNPCs/WulfrumAmplifier.cs +++ b/NPCs/NormalNPCs/WulfrumAmplifier.cs @@ -28,10 +28,12 @@ namespace CalamityMod.NPCs.NormalNPCs } public const float ChargeRadiusMax = 495f; public const float SuperchargeTime = 720f; + + public int laserDelay = 150; public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 6; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { SpriteDirection = 1 }; @@ -46,7 +48,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 44; NPC.height = 44; NPC.defense = 4; - NPC.lifeMax = 46; + NPC.lifeMax = Main.zenithWorld ? 72: 46; NPC.knockBackResist = 0f; NPC.value = Item.buyPrice(0, 0, 1, 50); NPC.noGravity = false; @@ -57,6 +59,8 @@ namespace CalamityMod.NPCs.NormalNPCs BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; + if (Main.zenithWorld) + NPC.scale = 1.5f; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -91,7 +95,7 @@ namespace CalamityMod.NPCs.NormalNPCs // Spawn some off-screen enemies to act as threats if the player enters the field. if (Main.netMode != NetmodeID.MultiplayerClient) { - int enemiesToSpawn = CalamityWorld.death ? 3 : CalamityWorld.revenge ? 2 : 1; + int enemiesToSpawn = CalamityWorld.LegendaryMode ? 4 :CalamityWorld.death ? 3 : CalamityWorld.revenge ? 2 : 1; for (int i = 0; i < enemiesToSpawn; i++) { int tries = 0; @@ -107,11 +111,27 @@ namespace CalamityMod.NPCs.NormalNPCs } while (WorldGen.SolidTile(CalamityUtils.ParanoidTileRetrieval((int)spawnPosition.X / 16, (int)spawnPosition.Y / 16))); - if (tries < 500) + if (tries < 500 && !Main.zenithWorld) { int npcToSpawn = Main.rand.NextBool() ? ModContent.NPCType() : ModContent.NPCType(); NPC.NewNPC(NPC.GetSource_FromAI(), (int)spawnPosition.X, (int)spawnPosition.Y, npcToSpawn); } + else if (tries < 500 && Main.zenithWorld) + { + //Summon the army + int npcToSpawn = CalamityWorld.LegendaryMode ? 0 : Main.rand.Next(0,4); + switch (enemiesToSpawn){ + case 0: npcToSpawn = ModContent.NPCType(); + break; + case 1: npcToSpawn = ModContent.NPCType(); + break; + case 2: npcToSpawn = ModContent.NPCType(); + break; + case 3: npcToSpawn = ModContent.NPCType(); + break; + } + NPC.NewNPC(NPC.GetSource_FromAI(), (int)spawnPosition.X, (int)spawnPosition.Y, npcToSpawn); + } } } @@ -165,6 +185,17 @@ namespace CalamityMod.NPCs.NormalNPCs Dust.NewDust(npcAtIndex.position, npcAtIndex.width, npcAtIndex.height, 226); } } + if (CalamityWorld.LegendaryMode) + { + laserDelay--; + NPC.spriteDirection = (player.Center.X - NPC.Center.X < 0).ToDirectionInt(); + for (int times = CalamityWorld.LegendaryMode ? 3 : 2; times > 0 && laserDelay == 0; times--) + { + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.UnitX * 6f * NPC.spriteDirection, NPC.SafeDirectionTo(player.Center, Vector2.UnitY) * 4.5f, ProjectileID.SaucerMissile, 10, 0f); + } + if (laserDelay <= 0) + laserDelay = 150; + } } } @@ -178,14 +209,14 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().ZoneSulphur || !spawnInfo.Player.ZoneOverworldHeight) + if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().ZoneSulphur || (!spawnInfo.Player.ZoneOverworldHeight && !Main.remixWorld) || (!spawnInfo.Player.ZoneNormalCaverns && spawnInfo.Player.ZoneGlowshroom && Main.remixWorld)) return 0f; // Spawn less frequently in the inner third of the world. if (spawnInfo.PlayerFloorX > Main.maxTilesX * 0.333f && spawnInfo.PlayerFloorX < Main.maxTilesX - Main.maxTilesX * 0.333f) - return SpawnCondition.OverworldDaySlime.Chance * (Main.hardMode ? 0.01f : 0.06f) * (!NPC.AnyNPCs(NPC.type) ? 1.3f : 1f); + return (Main.remixWorld ? SpawnCondition.Cavern.Chance : SpawnCondition.OverworldDaySlime.Chance) * (Main.hardMode ? 0.01f : 0.06f) * (!NPC.AnyNPCs(NPC.type) ? 1.3f : 1f); - return SpawnCondition.OverworldDaySlime.Chance * (Main.hardMode ? 0.033f : 0.15f) * (!NPC.AnyNPCs(NPC.type) ? 1.3f : 1f); + return (Main.remixWorld ? SpawnCondition.Cavern.Chance : SpawnCondition.OverworldDaySlime.Chance) * (Main.hardMode ? 0.033f : 0.15f) * (!NPC.AnyNPCs(NPC.type) ? 1.3f : 1f); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/NormalNPCs/WulfrumDrone.cs b/NPCs/NormalNPCs/WulfrumDrone.cs index 45386b4f5b..353f1b91ed 100644 --- a/NPCs/NormalNPCs/WulfrumDrone.cs +++ b/NPCs/NormalNPCs/WulfrumDrone.cs @@ -9,6 +9,10 @@ using Terraria.ModLoader.Utilities; using Microsoft.Xna.Framework; using System.IO; using CalamityMod.Sounds; +using System; +using CalamityMod.World; +using Mono.Cecil; +using Terraria.Audio; namespace CalamityMod.NPCs.NormalNPCs { @@ -51,7 +55,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 6; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { SpriteDirection = 1 }; @@ -100,7 +104,7 @@ namespace CalamityMod.NPCs.NormalNPCs Player player = Main.player[NPC.target]; bool farFromPlayer = NPC.Distance(player.Center) > 960f; - bool obstanceInFrontOfPlayer = !Collision.CanHitLine(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); + bool obstanceInFrontOfPlayer = Main.remixWorld ? false : !Collision.CanHitLine(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); if (NPC.target < 0 || NPC.target >= 255 || farFromPlayer || obstanceInFrontOfPlayer || player.dead || !player.active) { @@ -111,7 +115,7 @@ namespace CalamityMod.NPCs.NormalNPCs // Fly away if there is no living target, or the closest target is too far away. if (player.dead || !player.active || farFromPlayer || obstanceInFrontOfPlayer) { - if (FlyAwayTimer > 360) + if (FlyAwayTimer > 420) { NPC.velocity = Vector2.Lerp(NPC.velocity, Vector2.UnitY * -8f, 0.1f); NPC.rotation = NPC.rotation.AngleTowards(0f, MathHelper.ToRadians(15f)); @@ -160,7 +164,22 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.velocity = Vector2.Lerp(NPC.velocity, NPC.SafeDirectionTo(player.Center) * 6f, 0.1f); if (Supercharged && Main.netMode != NetmodeID.MultiplayerClient && HorizontalChargeTime % 30f == 29f) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.UnitX * 6f * NPC.spriteDirection, NPC.SafeDirectionTo(player.Center, Vector2.UnitY) * 6f, ProjectileID.SaucerLaser, 12, 0f); + { + if (Main.zenithWorld) + { + int spread = 15; + for (int times = CalamityWorld.LegendaryMode ? 3 : 2; times > 0; times--) + { + Vector2 velocity = NPC.SafeDirectionTo(player.Center, Vector2.UnitY) * 6f; + Vector2 perturbedspeed = new Vector2(velocity.X + Main.rand.Next(-2, 3), velocity.Y + Main.rand.Next(-2, 3)).RotatedBy(MathHelper.ToRadians(spread)); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.UnitX * 6f * NPC.spriteDirection, perturbedspeed, ProjectileID.SaucerLaser, 12, 0f); + spread -= Main.rand.Next(5, 8); + } + } + else + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.UnitX * 6f * NPC.spriteDirection, NPC.SafeDirectionTo(player.Center, Vector2.UnitY) * 6f, ProjectileID.SaucerLaser, 12, 0f); + SoundEngine.PlaySound(SoundID.Item12); + } HorizontalChargeTime++; if (HorizontalChargeTime > TotalHorizontalChargeTime) @@ -196,10 +215,10 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().ZoneSulphur || !spawnInfo.Player.ZoneOverworldHeight) + if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().ZoneSulphur || (!spawnInfo.Player.ZoneOverworldHeight && !Main.remixWorld) || (!spawnInfo.Player.ZoneNormalCaverns && spawnInfo.Player.ZoneGlowshroom && Main.remixWorld)) return 0f; - return SpawnCondition.OverworldDaySlime.Chance * (Main.hardMode ? 0.010f : 0.1f) * (NPC.AnyNPCs(ModContent.NPCType()) ? 5.5f : 1f); + return (Main.remixWorld ? SpawnCondition.Cavern.Chance : SpawnCondition.OverworldDaySlime.Chance) * (Main.hardMode ? 0.010f : 0.135f) * (NPC.AnyNPCs(ModContent.NPCType()) ? 5.5f : 1f); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/NormalNPCs/WulfrumGyrator.cs b/NPCs/NormalNPCs/WulfrumGyrator.cs index f38254e04c..a3a1e373a8 100644 --- a/NPCs/NormalNPCs/WulfrumGyrator.cs +++ b/NPCs/NormalNPCs/WulfrumGyrator.cs @@ -2,6 +2,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Projectiles.Rogue; using CalamityMod.Sounds; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -39,7 +40,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 10; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { SpriteDirection = 1 }; @@ -91,7 +92,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { - NPC.TargetClosest(false); + NPC.TargetClosest(Main.zenithWorld ? true : false); Player player = Main.player[NPC.target]; @@ -130,6 +131,22 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.netSpam = 0; NPC.netUpdate = true; } + //GOTTA GO FAST (Legendary only) + if (CalamityWorld.LegendaryMode) + { + NPC.velocity *= 1.01f; + //Overcharged + if (Supercharged && Main.rand.NextBool(3)) + { + int spark = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.UnitX * 6f * NPC.spriteDirection, Vector2.Zero, ModContent.ProjectileType(), 10, 0f); + if (spark.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[spark].friendly = false; + Main.projectile[spark].hostile = true; + Main.projectile[spark].timeLeft = 60; + } + } + } } else if (Main.netMode != NetmodeID.MultiplayerClient && NPC.collideX && NPC.collideY && NPC.velocity.Y == 0f) { @@ -179,10 +196,10 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().ZoneSulphur || !spawnInfo.Player.ZoneOverworldHeight) + if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().ZoneSulphur || (!spawnInfo.Player.ZoneOverworldHeight && !Main.remixWorld) || (!spawnInfo.Player.ZoneNormalCaverns && spawnInfo.Player.ZoneGlowshroom && Main.remixWorld)) return 0f; - return SpawnCondition.OverworldDaySlime.Chance * (Main.hardMode ? 0.020f : 0.115f) * (NPC.AnyNPCs(ModContent.NPCType()) ? 5.5f : 1f); + return (Main.remixWorld ? SpawnCondition.Cavern.Chance : SpawnCondition.OverworldDaySlime.Chance) * (Main.hardMode ? 0.010f : 0.135f) * (NPC.AnyNPCs(ModContent.NPCType()) ? 5.5f : 1f); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/NormalNPCs/WulfrumHovercraft.cs b/NPCs/NormalNPCs/WulfrumHovercraft.cs index 66429c6aba..c50a1a64cb 100644 --- a/NPCs/NormalNPCs/WulfrumHovercraft.cs +++ b/NPCs/NormalNPCs/WulfrumHovercraft.cs @@ -10,6 +10,10 @@ using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; using CalamityMod.Sounds; +using Terraria.Audio; +using CalamityMod.World; +using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Pets; namespace CalamityMod.NPCs.NormalNPCs { @@ -59,7 +63,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 12; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { SpriteDirection = 1 }; @@ -124,7 +128,7 @@ namespace CalamityMod.NPCs.NormalNPCs Player player = Main.player[NPC.target]; bool farFromPlayer = NPC.Distance(player.Center) > 960f; - bool obstanceInFrontOfPlayer = !Collision.CanHitLine(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); + bool obstanceInFrontOfPlayer = Main.remixWorld ? false : !Collision.CanHitLine(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); if (NPC.target < 0 || NPC.target >= 255 || farFromPlayer || obstanceInFrontOfPlayer || player.dead || !player.active) { @@ -132,11 +136,18 @@ namespace CalamityMod.NPCs.NormalNPCs player = Main.player[NPC.target]; farFromPlayer = NPC.Distance(player.Center) > 960f; obstanceInFrontOfPlayer = !Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); - // Fly away if there is no living target, or the closest target is too far away. + // Fly away if there is no living target, or the closest target is too far away... unless its Gfb if (player.dead || !player.active || farFromPlayer || obstanceInFrontOfPlayer) { - if (FlyAwayTimer > 360) + if (FlyAwayTimer > 420) { + // Don't go away from me >:( + if (Main.zenithWorld && player.active && !farFromPlayer) + { + AIState = HovercraftAIState.SwoopDownward; + SoundEngine.PlaySound(SoundID.DD2_KoboldFlyerHurt with { Pitch = SoundID.DD2_KoboldFlyerHurt.Pitch + 0.5f }, NPC.Center); + return; + } NPC.velocity = Vector2.Lerp(NPC.velocity, Vector2.UnitY * -8f, 0.1f); NPC.rotation = NPC.rotation.AngleTowards(0f, MathHelper.ToRadians(15f)); NPC.noTileCollide = true; @@ -263,10 +274,10 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().ZoneSulphur || !spawnInfo.Player.ZoneOverworldHeight) + if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().ZoneSulphur || (!spawnInfo.Player.ZoneOverworldHeight && !Main.remixWorld) || (!spawnInfo.Player.ZoneNormalCaverns && spawnInfo.Player.ZoneGlowshroom && Main.remixWorld)) return 0f; - return SpawnCondition.OverworldDaySlime.Chance * (Main.hardMode ? 0.015f : 0.1f) * (NPC.AnyNPCs(ModContent.NPCType()) ? 5.5f : 1f); + return (Main.remixWorld ? SpawnCondition.Cavern.Chance : SpawnCondition.OverworldDaySlime.Chance) * (Main.hardMode ? 0.010f : 0.135f) * (NPC.AnyNPCs(ModContent.NPCType()) ? 5.5f : 1f); } public override void HitEffect(NPC.HitInfo hit) @@ -296,6 +307,21 @@ namespace CalamityMod.NPCs.NormalNPCs } } } + //Become a spark piñata in Legendary + if (CalamityWorld.LegendaryMode && Supercharged) + { + for (int Sparks = Main.rand.Next(2, 5); Sparks > 0; Sparks--) + { + Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f); + int spark = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.UnitX * 6f * NPC.spriteDirection, velocity, ModContent.ProjectileType(), 10, 0f); + if (spark.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[spark].friendly = false; + Main.projectile[spark].hostile = true; + Main.projectile[spark].timeLeft = 90; + } + } + } } } diff --git a/NPCs/NormalNPCs/WulfrumRover.cs b/NPCs/NormalNPCs/WulfrumRover.cs index b676552d8e..a51327d1ff 100644 --- a/NPCs/NormalNPCs/WulfrumRover.cs +++ b/NPCs/NormalNPCs/WulfrumRover.cs @@ -11,6 +11,7 @@ using Terraria.ModLoader; using Terraria.ModLoader.Utilities; using CalamityMod.Sounds; using Terraria.Graphics.Effects; +using CalamityMod.World; namespace CalamityMod.NPCs.NormalNPCs { @@ -35,10 +36,13 @@ namespace CalamityMod.NPCs.NormalNPCs public const float JumpSpeed = -4f; public bool Supercharged => SuperchargeTimer > 0; + //GetFuckedBoi + public int mineDelay = 0; + public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 16; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { SpriteDirection = 1 }; @@ -54,7 +58,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.height = 40; NPC.defense = 4; NPC.lifeMax = 32; - NPC.knockBackResist = 0.15f; + NPC.knockBackResist = Main.zenithWorld ? 0f : 0.15f; NPC.value = Item.buyPrice(0, 0, 1, 15); NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = CommonCalamitySounds.WulfrumNPCDeathSound; @@ -62,6 +66,8 @@ namespace CalamityMod.NPCs.NormalNPCs BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; + if (Main.zenithWorld) + NPC.scale = 2f; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -91,11 +97,11 @@ namespace CalamityMod.NPCs.NormalNPCs if (Supercharged) { SuperchargeTimer--; - NPC.defense = 13; + NPC.defense = CalamityWorld.LegendaryMode ? 20 : 13; } else if (!Supercharged) { - NPC.defense = 4; + NPC.defense = CalamityWorld.LegendaryMode ? 10 : 4; } Player player = Main.player[NPC.target]; @@ -135,10 +141,10 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().ZoneSulphur || !spawnInfo.Player.ZoneOverworldHeight) + if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().ZoneSulphur || (!spawnInfo.Player.ZoneOverworldHeight && !Main.remixWorld) || (!spawnInfo.Player.ZoneNormalCaverns && spawnInfo.Player.ZoneGlowshroom && Main.remixWorld)) return 0f; - return SpawnCondition.OverworldDaySlime.Chance * (Main.hardMode ? 0.010f : 0.135f) * (NPC.AnyNPCs(ModContent.NPCType()) ? 5.5f : 1f); + return (Main.remixWorld ? SpawnCondition.Cavern.Chance : SpawnCondition.OverworldDaySlime.Chance) * (Main.hardMode ? 0.010f : 0.135f) * (NPC.AnyNPCs(ModContent.NPCType()) ? 5.5f : 1f); } public override void HitEffect(NPC.HitInfo hit) @@ -168,6 +174,20 @@ namespace CalamityMod.NPCs.NormalNPCs } } } + if (Main.zenithWorld && mineDelay == 0) + { + Vector2 roverBase = new Vector2(NPC.Center.X,NPC.Center.Y+5f); + int mine = Projectile.NewProjectile(NPC.GetSource_FromAI(), roverBase, Vector2.Zero, ProjectileID.ProximityMineI, 50, 0f); + if (mine.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[mine].friendly = false; + Main.projectile[mine].hostile = true; + Main.projectile[mine].timeLeft = 60; + } + mineDelay = CalamityWorld.LegendaryMode ? 3 : 5; + } + else if (Main.zenithWorld && mineDelay >= 1) + mineDelay--; } } @@ -191,8 +211,8 @@ namespace CalamityMod.NPCs.NormalNPCs */ //0.6 : The noise upscale - //0.15 the scale its drawn at - float scale = 0.15f + 0.03f * (0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.5f + NPC.whoAmI * 0.2f)); + //0.15 the scale its drawn at usually, 0.2 on Zenith + float scale = (Main.zenithWorld ? 0.2f : 0.15f) + 0.03f * (0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.5f + NPC.whoAmI * 0.2f)); float noiseScale = 0.6f; Effect shieldEffect = Terraria.Graphics.Effects.Filters.Scene["CalamityMod:RoverDriveShield"].GetShader().Shader; diff --git a/NPCs/OldDuke/OldDuke.cs b/NPCs/OldDuke/OldDuke.cs index 4607a903a2..03101af13f 100644 --- a/NPCs/OldDuke/OldDuke.cs +++ b/NPCs/OldDuke/OldDuke.cs @@ -46,7 +46,7 @@ namespace CalamityMod.NPCs.OldDuke Main.npcFrameCount[NPC.type] = 7; NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { SpriteDirection = 1, Scale = 0.45f @@ -136,13 +136,13 @@ namespace CalamityMod.NPCs.OldDuke bool tired = NPC.Calamity().newAI[1] == 1f; if (NPC.ai[0] == 0f || NPC.ai[0] == 5f || NPC.ai[0] == 10f || NPC.ai[0] == 12f) { - int num114 = tired ? 14 : 7; + int frameChangeFrequency = tired ? 14 : 7; if (NPC.ai[0] == 5f || NPC.ai[0] == 12f) { - num114 = tired ? 12 : 6; + frameChangeFrequency = tired ? 12 : 6; } NPC.frameCounter += 1D; - if (NPC.frameCounter > num114) + if (NPC.frameCounter > frameChangeFrequency) { NPC.frameCounter = 0D; NPC.frame.Y += frameHeight; @@ -162,8 +162,8 @@ namespace CalamityMod.NPCs.OldDuke } if (NPC.ai[0] == 3f || NPC.ai[0] == 8f || NPC.ai[0] == 13f || NPC.ai[0] == -1f) { - int num115 = 120; - if (NPC.ai[2] < (num115 - 50) || NPC.ai[2] > (num115 - 10)) + int frameChangeGateValue = 120; + if (NPC.ai[2] < (frameChangeGateValue - 50) || NPC.ai[2] > (frameChangeGateValue - 10)) { NPC.frameCounter += 1D; if (NPC.frameCounter > 7D) @@ -179,7 +179,7 @@ namespace CalamityMod.NPCs.OldDuke else { NPC.frame.Y = frameHeight * 5; - if (NPC.ai[2] > (num115 - 40) && NPC.ai[2] < (num115 - 15)) + if (NPC.ai[2] > (frameChangeGateValue - 40) && NPC.ai[2] < (frameChangeGateValue - 15)) { NPC.frame.Y = frameHeight * 6; } @@ -187,8 +187,8 @@ namespace CalamityMod.NPCs.OldDuke } if (NPC.ai[0] == 4f || NPC.ai[0] == 9f) { - int num116 = 180; - if (NPC.ai[2] < (num116 - 60) || NPC.ai[2] > (num116 - 20)) + int secondFrameChangeGateValue = 180; + if (NPC.ai[2] < (secondFrameChangeGateValue - 60) || NPC.ai[2] > (secondFrameChangeGateValue - 20)) { NPC.frameCounter += 1D; if (NPC.frameCounter > 7D) @@ -204,7 +204,7 @@ namespace CalamityMod.NPCs.OldDuke else { NPC.frame.Y = frameHeight * 5; - if (NPC.ai[2] > (num116 - 50) && NPC.ai[2] < (num116 - 25)) + if (NPC.ai[2] > (secondFrameChangeGateValue - 50) && NPC.ai[2] < (secondFrameChangeGateValue - 25)) { NPC.frame.Y = frameHeight * 6; } @@ -220,43 +220,43 @@ namespace CalamityMod.NPCs.OldDuke spriteEffects = SpriteEffects.FlipHorizontally; } Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(texture2D15.Width / 2, texture2D15.Height / Main.npcFrameCount[NPC.type] / 2); + Vector2 halfSizeTexture = new Vector2(texture2D15.Width / 2, texture2D15.Height / Main.npcFrameCount[NPC.type] / 2); Color color = drawColor; - Color color36 = Color.White; - float amount9 = 0f; - bool flag8 = NPC.ai[0] > 4f; - bool flag9 = NPC.ai[0] > 9f && NPC.ai[0] <= 12f; - int num150 = 120; - int num151 = 60; - if (flag9) + Color drawLerpColor = Color.White; + float drawLerpValue = 0f; + bool halfTiredBuffColor = NPC.ai[0] > 4f; + bool tiredBuffColor = NPC.ai[0] > 9f && NPC.ai[0] <= 12f; + int ai2Compare = 120; + int buffColorDivisor = 60; + if (tiredBuffColor) { color = CalamityGlobalNPC.buffColor(color, 0.4f, 0.8f, 0.4f, 1f); } - else if (flag8) + else if (halfTiredBuffColor) { color = CalamityGlobalNPC.buffColor(color, 0.5f, 0.7f, 0.5f, 1f); } - else if (NPC.ai[0] == 4f && NPC.ai[2] > num150) + else if (NPC.ai[0] == 4f && NPC.ai[2] > ai2Compare) { - float num152 = NPC.ai[2] - num150; - num152 /= num151; - color = CalamityGlobalNPC.buffColor(color, 1f - 0.5f * num152, 1f - 0.3f * num152, 1f - 0.5f * num152, 1f); + float buffColorDampener = NPC.ai[2] - ai2Compare; + buffColorDampener /= buffColorDivisor; + color = CalamityGlobalNPC.buffColor(color, 1f - 0.5f * buffColorDampener, 1f - 0.3f * buffColorDampener, 1f - 0.5f * buffColorDampener, 1f); } - int num153 = 10; - int num154 = 2; + int afterimageAmt = 10; + int afterimageIncrement = 2; if (NPC.ai[0] == -1f) { - num153 = 0; + afterimageAmt = 0; } if (NPC.ai[0] == 0f || NPC.ai[0] == 5f || NPC.ai[0] == 10f || NPC.ai[0] == 12f) { - num153 = 7; + afterimageAmt = 7; } if (NPC.ai[0] == 1f || NPC.ai[0] == 6f || NPC.ai[0] > 9f) { - color36 = Color.Lime; - amount9 = 0.5f; + drawLerpColor = Color.Lime; + drawLerpValue = 0.5f; } else { @@ -265,140 +265,138 @@ namespace CalamityMod.NPCs.OldDuke if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += num154) + for (int i = 1; i < afterimageAmt; i += afterimageIncrement) { - Color color38 = color; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = color; + afterimageColor = Color.Lerp(afterimageColor, drawLerpColor, drawLerpValue); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - int num156 = 0; - float num157 = 0f; - float scaleFactor9 = 0f; + int secondAfterimageAmt = 0; + float afterimageOpacity = 0f; + float afterimageScale = 0f; if (NPC.ai[0] == -1f) { - num156 = 0; + secondAfterimageAmt = 0; } if (NPC.ai[0] == 3f || NPC.ai[0] == 8f || NPC.ai[0] == 13f) { - int num158 = 60; - int num159 = 30; - if (NPC.ai[2] > num158) + if (NPC.ai[2] > 60) { - num156 = 6; - num157 = 1f - (float)Math.Cos((NPC.ai[2] - num158) / num159 * MathHelper.TwoPi); - num157 /= 3f; - scaleFactor9 = 40f; + secondAfterimageAmt = 6; + afterimageOpacity = 1f - (float)Math.Cos((NPC.ai[2] - 60) / 30 * MathHelper.TwoPi); + afterimageOpacity /= 3f; + afterimageScale = 40f; } } - if ((NPC.ai[0] == 4f || NPC.ai[0] == 9f) && NPC.ai[2] > num150) + if ((NPC.ai[0] == 4f || NPC.ai[0] == 9f) && NPC.ai[2] > ai2Compare) { - num156 = 6; - num157 = 1f - (float)Math.Cos((NPC.ai[2] - num150) / num151 * MathHelper.TwoPi); - num157 /= 3f; - scaleFactor9 = 60f; + secondAfterimageAmt = 6; + afterimageOpacity = 1f - (float)Math.Cos((NPC.ai[2] - ai2Compare) / buffColorDivisor * MathHelper.TwoPi); + afterimageOpacity /= 3f; + afterimageScale = 60f; } if (NPC.ai[0] == 12f) { - num156 = 6; - num157 = 1f - (float)Math.Cos(NPC.ai[2] / 30f * MathHelper.TwoPi); - num157 /= 3f; - scaleFactor9 = 20f; + secondAfterimageAmt = 6; + afterimageOpacity = 1f - (float)Math.Cos(NPC.ai[2] / 30f * MathHelper.TwoPi); + afterimageOpacity /= 3f; + afterimageScale = 20f; } if (CalamityConfig.Instance.Afterimages) { - for (int num160 = 0; num160 < num156; num160++) + for (int j = 0; j < secondAfterimageAmt; j++) { - Color color39 = drawColor; - color39 = Color.Lerp(color39, color36, amount9); - color39 = NPC.GetAlpha(color39); - color39 *= 1f - num157; - Vector2 vector42 = NPC.Center + (num160 / (float)num156 * MathHelper.TwoPi + NPC.rotation).ToRotationVector2() * scaleFactor9 * num157 - screenPos; - vector42 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector42 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector42, NPC.frame, color39, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color secondAfterimageColor = drawColor; + secondAfterimageColor = Color.Lerp(secondAfterimageColor, drawLerpColor, drawLerpValue); + secondAfterimageColor = NPC.GetAlpha(secondAfterimageColor); + secondAfterimageColor *= 1f - afterimageOpacity; + Vector2 secondAfterimagePos = NPC.Center + (j / (float)secondAfterimageAmt * MathHelper.TwoPi + NPC.rotation).ToRotationVector2() * afterimageScale * afterimageOpacity - screenPos; + secondAfterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + secondAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, secondAfterimagePos, NPC.frame, secondAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Color color2 = drawColor; - color2 = Color.Lerp(color2, color36, amount9); - color2 = NPC.GetAlpha(color2); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, (NPC.ai[0] > 9f ? color2 : NPC.GetAlpha(drawColor)), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color finalDrawColor = drawColor; + finalDrawColor = Color.Lerp(finalDrawColor, drawLerpColor, drawLerpValue); + finalDrawColor = NPC.GetAlpha(finalDrawColor); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, (NPC.ai[0] > 9f ? finalDrawColor : NPC.GetAlpha(drawColor)), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); if (NPC.ai[0] >= 4f && NPC.Calamity().newAI[1] != 1f) { texture2D15 = ModContent.Request("CalamityMod/NPCs/OldDuke/OldDukeGlow").Value; - Color color40 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - color36 = Color.Yellow; + Color yellowLerpColor = Color.Lerp(Color.White, Color.Yellow, 0.5f); + drawLerpColor = Color.Yellow; - amount9 = 1f; - num157 = 0.5f; - scaleFactor9 = 10f; - num154 = 1; + drawLerpValue = 1f; + afterimageOpacity = 0.5f; + afterimageScale = 10f; + afterimageIncrement = 1; if (NPC.ai[0] == 4f || NPC.ai[0] == 9f) { - float num161 = NPC.ai[2] - num150; - num161 /= num151; - color36 *= num161; - color40 *= num161; + float otherAfterimageOpacity = NPC.ai[2] - ai2Compare; + otherAfterimageOpacity /= buffColorDivisor; + drawLerpColor *= otherAfterimageOpacity; + yellowLerpColor *= otherAfterimageOpacity; } if (NPC.ai[0] == 12f) { - float num162 = NPC.ai[2]; - num162 /= 30f; - if (num162 > 0.5f) + float ai2Opacity = NPC.ai[2]; + ai2Opacity /= 30f; + if (ai2Opacity > 0.5f) { - num162 = 1f - num162; + ai2Opacity = 1f - ai2Opacity; } - num162 *= 2f; - num162 = 1f - num162; - color36 *= num162; - color40 *= num162; + ai2Opacity *= 2f; + ai2Opacity = 1f - ai2Opacity; + drawLerpColor *= ai2Opacity; + yellowLerpColor *= ai2Opacity; } if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163 += num154) + for (int k = 1; k < afterimageAmt; k += afterimageIncrement) { - Color color41 = color40; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color yellowAfterimageColor = yellowLerpColor; + yellowAfterimageColor = Color.Lerp(yellowAfterimageColor, drawLerpColor, drawLerpValue); + yellowAfterimageColor *= (afterimageAmt - k) / 15f; + Vector2 yellowAfterimagePos = NPC.oldPos[k] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + yellowAfterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + yellowAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, yellowAfterimagePos, NPC.frame, yellowAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } - for (int num164 = 1; num164 < num156; num164++) + for (int l = 1; l < secondAfterimageAmt; l++) { - Color color42 = color40; - color42 = Color.Lerp(color42, color36, amount9); - color42 = NPC.GetAlpha(color42); - color42 *= 1f - num157; - Vector2 vector45 = NPC.Center + (num164 / (float)num156 * MathHelper.TwoPi + NPC.rotation).ToRotationVector2() * scaleFactor9 * num157 - screenPos; - vector45 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector45 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector45, NPC.frame, color42, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color secondYellowAfterimageColor = yellowLerpColor; + secondYellowAfterimageColor = Color.Lerp(secondYellowAfterimageColor, drawLerpColor, drawLerpValue); + secondYellowAfterimageColor = NPC.GetAlpha(secondYellowAfterimageColor); + secondYellowAfterimageColor *= 1f - afterimageOpacity; + Vector2 secondYellowAfterimagePos = NPC.Center + (l / (float)secondAfterimageAmt * MathHelper.TwoPi + NPC.rotation).ToRotationVector2() * afterimageScale * afterimageOpacity - screenPos; + secondYellowAfterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + secondYellowAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, secondYellowAfterimagePos, NPC.frame, secondYellowAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color40, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, yellowLerpColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } return false; @@ -458,7 +456,7 @@ namespace CalamityMod.NPCs.OldDuke npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB Shattered Community drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType()); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedBoomerDuke, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -486,16 +484,16 @@ namespace CalamityMod.NPCs.OldDuke { if (NPC.life > 0) { - int num211 = 0; - while (num211 < hit.Damage / NPC.lifeMax * 100.0) + int onHitDust = 0; + while (onHitDust < hit.Damage / NPC.lifeMax * 100.0) { Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.SulfurousSeaAcid, hit.HitDirection, -1f, 0, default, 1f); - num211++; + onHitDust++; } } else { - for (int num212 = 0; num212 < 150; num212++) + for (int r = 0; r < 150; r++) { Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.SulfurousSeaAcid, 2 * hit.HitDirection, -2f, 0, default, 1f); } diff --git a/NPCs/OldDuke/OldDukeToothBall.cs b/NPCs/OldDuke/OldDukeToothBall.cs index e8994c00aa..88cd360c59 100644 --- a/NPCs/OldDuke/OldDukeToothBall.cs +++ b/NPCs/OldDuke/OldDukeToothBall.cs @@ -37,6 +37,7 @@ namespace CalamityMod.NPCs.OldDuke NPC.knockBackResist = 0f; NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath11; + NPC.chaseable = false; NPC.noGravity = true; NPC.noTileCollide = true; NPC.Calamity().VulnerableToHeat = false; @@ -115,18 +116,18 @@ namespace CalamityMod.NPCs.OldDuke velocity += Vector2.Distance(player.Center, NPC.Center) * speedUpMult; } - Vector2 vector167 = new Vector2(NPC.Center.X + NPC.direction * 20, NPC.Center.Y + 6f); - float num1373 = player.position.X + player.width * 0.5f - vector167.X; - float num1374 = player.Center.Y - vector167.Y; - float num1375 = (float)Math.Sqrt(num1373 * num1373 + num1374 * num1374); - float num1376 = velocity / num1375; - num1373 *= num1376; - num1374 *= num1376; + Vector2 toothBallDirection = new Vector2(NPC.Center.X + NPC.direction * 20, NPC.Center.Y + 6f); + float targetXDist = player.position.X + player.width * 0.5f - toothBallDirection.X; + float targetYDist = player.Center.Y - toothBallDirection.Y; + float targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); + float toothBallSpeed = velocity / targetDistance; + targetXDist *= toothBallSpeed; + targetYDist *= toothBallSpeed; NPC.ai[2] -= Main.rand.Next(6); - if (num1375 < 300f || NPC.ai[2] > 0f) + if (targetDistance < 300f || NPC.ai[2] > 0f) { - if (num1375 < 300f) + if (targetDistance < 300f) NPC.ai[2] = 100f; if (NPC.velocity.X < 0f) @@ -138,27 +139,27 @@ namespace CalamityMod.NPCs.OldDuke } float inertia = 50f; - NPC.velocity.X = (NPC.velocity.X * inertia + num1373) / (inertia + 1f); - NPC.velocity.Y = (NPC.velocity.Y * inertia + num1374) / (inertia + 1f); + NPC.velocity.X = (NPC.velocity.X * inertia + targetXDist) / (inertia + 1f); + NPC.velocity.Y = (NPC.velocity.Y * inertia + targetYDist) / (inertia + 1f); - float num1247 = bossRush ? 0.65f : 0.5f; - for (int num1248 = 0; num1248 < Main.maxNPCs; num1248++) + float toothBallAccel = bossRush ? 0.65f : 0.5f; + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num1248].active) + if (Main.npc[i].active) { - if (num1248 != NPC.whoAmI && Main.npc[num1248].type == NPC.type) + if (i != NPC.whoAmI && Main.npc[i].type == NPC.type) { - if (Vector2.Distance(NPC.Center, Main.npc[num1248].Center) < 48f) + if (Vector2.Distance(NPC.Center, Main.npc[i].Center) < 48f) { - if (NPC.position.X < Main.npc[num1248].position.X) - NPC.velocity.X -= num1247; + if (NPC.position.X < Main.npc[i].position.X) + NPC.velocity.X -= toothBallAccel; else - NPC.velocity.X += num1247; + NPC.velocity.X += toothBallAccel; - if (NPC.position.Y < Main.npc[num1248].position.Y) - NPC.velocity.Y -= num1247; + if (NPC.position.Y < Main.npc[i].position.Y) + NPC.velocity.Y -= toothBallAccel; else - NPC.velocity.Y += num1247; + NPC.velocity.Y += toothBallAccel; } } } @@ -184,8 +185,8 @@ namespace CalamityMod.NPCs.OldDuke Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); for (int k = 0; k < totalProjectiles; k++) { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, vector255 * 0.1f, type, damage, 0f, Main.myPlayer, vector255.X, vector255.Y); + Vector2 toothSpikeRotation = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, toothSpikeRotation * 0.1f, type, damage, 0f, Main.myPlayer, toothSpikeRotation.X, toothSpikeRotation.Y); } if (Main.expertMode) @@ -242,26 +243,26 @@ namespace CalamityMod.NPCs.OldDuke NPC.position.X = NPC.position.X - NPC.width / 2; NPC.position.Y = NPC.position.Y - NPC.height / 2; - for (int num621 = 0; num621 < 15; num621++) + for (int i = 0; i < 15; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int bloody = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 2f); + Main.dust[bloody].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[bloody].scale = 0.5f; + Main.dust[bloody].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } - Main.dust[num622].noGravity = true; + Main.dust[bloody].noGravity = true; } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - Main.dust[num624].noGravity = true; + int toxicDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 3f); + Main.dust[toxicDust].noGravity = true; + Main.dust[toxicDust].velocity *= 5f; + toxicDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 2f); + Main.dust[toxicDust].velocity *= 2f; + Main.dust[toxicDust].noGravity = true; } if (Main.netMode != NetmodeID.Server) diff --git a/NPCs/OldDuke/SulphurousSharkron.cs b/NPCs/OldDuke/SulphurousSharkron.cs index f355d92fc8..d75a67bd55 100644 --- a/NPCs/OldDuke/SulphurousSharkron.cs +++ b/NPCs/OldDuke/SulphurousSharkron.cs @@ -45,6 +45,7 @@ namespace CalamityMod.NPCs.OldDuke NPC.DeathSound = SoundID.NPCDeath1; NPC.knockBackResist = 0f; NPC.Opacity = 0f; + NPC.chaseable = false; NPC.noGravity = true; NPC.dontTakeDamage = true; NPC.noTileCollide = true; @@ -140,11 +141,11 @@ namespace CalamityMod.NPCs.OldDuke // Fly towards the target float scaleFactor2 = NPC.velocity.Length(); - Vector2 vector17 = Main.player[NPC.target].Center - NPC.Center; - vector17.Normalize(); - vector17 *= scaleFactor2; + Vector2 targetDistance = Main.player[NPC.target].Center - NPC.Center; + targetDistance.Normalize(); + targetDistance *= scaleFactor2; float inertia = bossRush ? 20f : death ? 23f : revenge ? 25f : expertMode ? 27f : 30f; - NPC.velocity = (NPC.velocity * (inertia - 1f) + vector17) / inertia; + NPC.velocity = (NPC.velocity * (inertia - 1f) + targetDistance) / inertia; NPC.velocity.Normalize(); NPC.velocity *= scaleFactor2; } @@ -240,30 +241,28 @@ namespace CalamityMod.NPCs.OldDuke spriteEffects = SpriteEffects.None; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); - Color color36 = Color.Lime; - float amount9 = 0.5f; - int num153 = 10; + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); + int afterimageAmt = 10; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.Lime, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -298,25 +297,25 @@ namespace CalamityMod.NPCs.OldDuke NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 15; num621++) + for (int i = 0; i < 15; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity.Y *= 6f; - Main.dust[num622].velocity.X *= 3f; + int toxicDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 2f); + Main.dust[toxicDust].velocity.Y *= 6f; + Main.dust[toxicDust].velocity.X *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[toxicDust].scale = 0.5f; + Main.dust[toxicDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity.Y *= 10f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity.X *= 2f; + int bloody = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 3f); + Main.dust[bloody].noGravity = true; + Main.dust[bloody].velocity.Y *= 10f; + bloody = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 2f); + Main.dust[bloody].velocity.X *= 2f; } if (Main.netMode != NetmodeID.Server) diff --git a/NPCs/Other/THELORDE.cs b/NPCs/Other/THELORDE.cs index 8a0631d769..73744b4cd2 100644 --- a/NPCs/Other/THELORDE.cs +++ b/NPCs/Other/THELORDE.cs @@ -201,18 +201,17 @@ namespace CalamityMod.NPCs.Other { NPC.rotation += 5f; NPC.TargetClosest(true); - float num1372 = 69f; - Vector2 vector167 = new Vector2(NPC.Center.X + (float)(NPC.direction * 20), NPC.Center.Y + 6f); - float num1373 = playerLOL.position.X + (float)playerLOL.width * 0.5f - vector167.X; - float num1374 = playerLOL.Center.Y - vector167.Y; - float num1375 = (float)Math.Sqrt((double)(num1373 * num1373 + num1374 * num1374)); - float num1376 = num1372 / num1375; - num1373 *= num1376; - num1374 *= num1376; + Vector2 lordePosition = new Vector2(NPC.Center.X + (float)(NPC.direction * 20), NPC.Center.Y + 6f); + float targetXDist = playerLOL.position.X + (float)playerLOL.width * 0.5f - lordePosition.X; + float targetYDist = playerLOL.Center.Y - lordePosition.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + float velocityMult = 69f / targetDistance; + targetXDist *= velocityMult; + targetYDist *= velocityMult; NPC.ai[0] -= 1f; - if (num1375 < 50f || NPC.ai[0] > 0f) + if (targetDistance < 50f || NPC.ai[0] > 0f) { - if (num1375 < 50f) + if (targetDistance < 50f) { NPC.ai[0] = 20f; } @@ -226,17 +225,17 @@ namespace CalamityMod.NPCs.Other } return; } - NPC.velocity.X = (NPC.velocity.X * 50f + num1373) / 51f; - NPC.velocity.Y = (NPC.velocity.Y * 50f + num1374) / 51f; - if (num1375 < 150f) + NPC.velocity.X = (NPC.velocity.X * 50f + targetXDist) / 51f; + NPC.velocity.Y = (NPC.velocity.Y * 50f + targetYDist) / 51f; + if (targetDistance < 150f) { - NPC.velocity.X = (NPC.velocity.X * 10f + num1373) / 11f; - NPC.velocity.Y = (NPC.velocity.Y * 10f + num1374) / 11f; + NPC.velocity.X = (NPC.velocity.X * 10f + targetXDist) / 11f; + NPC.velocity.Y = (NPC.velocity.Y * 10f + targetYDist) / 11f; } - if (num1375 < 100f) + if (targetDistance < 100f) { - NPC.velocity.X = (NPC.velocity.X * 7f + num1373) / 8f; - NPC.velocity.Y = (NPC.velocity.Y * 7f + num1374) / 8f; + NPC.velocity.X = (NPC.velocity.X * 7f + targetXDist) / 8f; + NPC.velocity.Y = (NPC.velocity.Y * 7f + targetYDist) / 8f; } return; } diff --git a/NPCs/Perforator/PerforatorBodyLarge.cs b/NPCs/Perforator/PerforatorBodyLarge.cs index 144c1e393d..b75c658e6d 100644 --- a/NPCs/Perforator/PerforatorBodyLarge.cs +++ b/NPCs/Perforator/PerforatorBodyLarge.cs @@ -102,40 +102,40 @@ namespace CalamityMod.NPCs.Perforator if (Main.player[NPC.target].dead) NPC.TargetClosest(false); - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetX = (float)((int)(targetX / 16f) * 16); + targetY = (float)((int)(targetY / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetX -= segmentPosition.X; + targetY -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetX * targetX + targetY * targetY)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetX = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetY = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetY, (double)targetX) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetX * targetX + targetY * targetY)); + int npcWidth = NPC.width; + targetDistance = (targetDistance - (float)npcWidth) / targetDistance; + targetX *= targetDistance; + targetY *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetX; + NPC.position.Y = NPC.position.Y + targetY; - if (num191 < 0f) + if (targetX < 0f) NPC.spriteDirection = 1; - else if (num191 > 0f) + else if (targetX > 0f) NPC.spriteDirection = -1; } } @@ -147,17 +147,17 @@ namespace CalamityMod.NPCs.Perforator spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = NPC.localAI[3] == 1f ? ModContent.Request("CalamityMod/NPCs/Perforator/PerforatorBodyLargeAlt").Value : TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = NPC.localAI[3] == 1f ? ModContent.Request("CalamityMod/NPCs/Perforator/PerforatorBodyLargeAltGlow").Value : ModContent.Request("CalamityMod/NPCs/Perforator/PerforatorBodyLargeGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + Color glowmaskColor = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/Perforator/PerforatorBodyMedium.cs b/NPCs/Perforator/PerforatorBodyMedium.cs index 5adbea1d33..8a2da84097 100644 --- a/NPCs/Perforator/PerforatorBodyMedium.cs +++ b/NPCs/Perforator/PerforatorBodyMedium.cs @@ -105,11 +105,11 @@ namespace CalamityMod.NPCs.Perforator { NPC.type = ModContent.NPCType(); int whoAmI = NPC.whoAmI; - float num25 = NPC.life / (float)NPC.lifeMax; - float num26 = NPC.ai[0]; + float lifeRatio = NPC.life / (float)NPC.lifeMax; + float ai0 = NPC.ai[0]; NPC.SetDefaultsKeepPlayerInteraction(NPC.type); - NPC.life = (int)(NPC.lifeMax * num25); - NPC.ai[0] = num26; + NPC.life = (int)(NPC.lifeMax * lifeRatio); + NPC.ai[0] = ai0; NPC.TargetClosest(true); NPC.netUpdate = true; NPC.whoAmI = whoAmI; @@ -117,11 +117,11 @@ namespace CalamityMod.NPCs.Perforator if (!Main.npc[(int)NPC.ai[0]].active || Main.npc[(int)NPC.ai[0]].aiStyle != NPC.aiStyle) { int whoAmI2 = NPC.whoAmI; - float num27 = NPC.life / (float)NPC.lifeMax; - float num28 = NPC.ai[1]; + float otherLifeRatio = NPC.life / (float)NPC.lifeMax; + float ai1 = NPC.ai[1]; NPC.SetDefaultsKeepPlayerInteraction(NPC.type); - NPC.life = (int)(NPC.lifeMax * num27); - NPC.ai[1] = num28; + NPC.life = (int)(NPC.lifeMax * otherLifeRatio); + NPC.ai[1] = ai1; NPC.TargetClosest(true); NPC.netUpdate = true; NPC.whoAmI = whoAmI2; @@ -131,40 +131,40 @@ namespace CalamityMod.NPCs.Perforator NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, NPC.whoAmI, -1f, 0f, 0f, 0, 0, 0); } - Vector2 vector2 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num39 = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); - float num40 = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); + Vector2 segmentDirection = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); + float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); - num39 = (int)(num39 / 16f) * 16; - num40 = (int)(num40 / 16f) * 16; - vector2.X = (int)(vector2.X / 16f) * 16; - vector2.Y = (int)(vector2.Y / 16f) * 16; - num39 -= vector2.X; - num40 -= vector2.Y; - float num52 = (float)Math.Sqrt(num39 * num39 + num40 * num40); + targetX = (int)(targetX / 16f) * 16; + targetY = (int)(targetY / 16f) * 16; + segmentDirection.X = (int)(segmentDirection.X / 16f) * 16; + segmentDirection.Y = (int)(segmentDirection.Y / 16f) * 16; + targetX -= segmentDirection.X; + targetY -= segmentDirection.Y; + float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) { try { - vector2 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - num39 = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - vector2.X; - num40 = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - vector2.Y; + segmentDirection = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + targetX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - segmentDirection.X; + targetY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - segmentDirection.Y; } catch { } - NPC.rotation = (float)Math.Atan2(num40, num39) + MathHelper.PiOver2; - num52 = (float)Math.Sqrt(num39 * num39 + num40 * num40); - int num53 = NPC.width; - num53 = (int)(num53 * NPC.scale); - num52 = (num52 - num53) / num52; - num39 *= num52; - num40 *= num52; + NPC.rotation = (float)Math.Atan2(targetY, targetX) + MathHelper.PiOver2; + targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); + int npcWidth = NPC.width; + npcWidth = (int)(npcWidth * NPC.scale); + targetDistance = (targetDistance - npcWidth) / targetDistance; + targetX *= targetDistance; + targetY *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X += num39; - NPC.position.Y += num40; + NPC.position.X += targetX; + NPC.position.Y += targetY; } } @@ -175,17 +175,17 @@ namespace CalamityMod.NPCs.Perforator spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/Perforator/PerforatorBodyMediumGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + Color glowmaskColor = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/Perforator/PerforatorBodySmall.cs b/NPCs/Perforator/PerforatorBodySmall.cs index 04d1dfe88d..8cacdd5260 100644 --- a/NPCs/Perforator/PerforatorBodySmall.cs +++ b/NPCs/Perforator/PerforatorBodySmall.cs @@ -102,40 +102,40 @@ namespace CalamityMod.NPCs.Perforator if (Main.player[NPC.target].dead) NPC.TargetClosest(false); - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetX = (float)((int)(targetX / 16f) * 16); + targetY = (float)((int)(targetY / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetX -= segmentPosition.X; + targetY -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetX * targetX + targetY * targetY)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetX = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetY = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetY, (double)targetX) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetX * targetX + targetY * targetY)); + int npcWidth = NPC.width; + targetDistance = (targetDistance - (float)npcWidth) / targetDistance; + targetX *= targetDistance; + targetY *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetX; + NPC.position.Y = NPC.position.Y + targetY; - if (num191 < 0f) + if (targetX < 0f) NPC.spriteDirection = 1; - else if (num191 > 0f) + else if (targetX > 0f) NPC.spriteDirection = -1; } } @@ -147,17 +147,17 @@ namespace CalamityMod.NPCs.Perforator spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/Perforator/PerforatorBodySmallGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + Color glowmaskColor = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/Perforator/PerforatorCyst.cs b/NPCs/Perforator/PerforatorCyst.cs index 39327b731d..9826d28e7a 100644 --- a/NPCs/Perforator/PerforatorCyst.cs +++ b/NPCs/Perforator/PerforatorCyst.cs @@ -15,7 +15,7 @@ namespace CalamityMod.NPCs.Perforator Main.npcFrameCount[NPC.type] = 4; NPCID.Sets.CantTakeLunchMoney[Type] = true; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0); NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; } diff --git a/NPCs/Perforator/PerforatorHeadLarge.cs b/NPCs/Perforator/PerforatorHeadLarge.cs index a9ba2a8fcb..74c0216cc6 100644 --- a/NPCs/Perforator/PerforatorHeadLarge.cs +++ b/NPCs/Perforator/PerforatorHeadLarge.cs @@ -24,7 +24,7 @@ namespace CalamityMod.NPCs.Perforator public override void SetStaticDefaults() { NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.75f, PortraitScale = 0.75f, @@ -180,10 +180,10 @@ namespace CalamityMod.NPCs.Perforator { int Previous = NPC.whoAmI; int maxLength = death ? 27 : revenge ? 24 : expertMode ? 21 : 15; - for (int num36 = 0; num36 < maxLength; num36++) + for (int segments = 0; segments < maxLength; segments++) { int lol; - if (num36 >= 0 && num36 < maxLength - 1) + if (segments >= 0 && segments < maxLength - 1) { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); } @@ -191,7 +191,7 @@ namespace CalamityMod.NPCs.Perforator { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); } - if (num36 % 2 == 0) + if (segments % 2 == 0) { Main.npc[lol].localAI[3] = 1f; } @@ -206,32 +206,32 @@ namespace CalamityMod.NPCs.Perforator } } - int num12 = (int)(NPC.position.X / 16f) - 1; - int num13 = (int)((NPC.position.X + (float)NPC.width) / 16f) + 2; - int num14 = (int)(NPC.position.Y / 16f) - 1; - int num15 = (int)((NPC.position.Y + (float)NPC.height) / 16f) + 2; - if (num12 < 0) + int tilePositionX = (int)(NPC.position.X / 16f) - 1; + int tileWidthPosX = (int)((NPC.position.X + (float)NPC.width) / 16f) + 2; + int tilePositionY = (int)(NPC.position.Y / 16f) - 1; + int tileWidthPosY = (int)((NPC.position.Y + (float)NPC.height) / 16f) + 2; + if (tilePositionX < 0) { - num12 = 0; + tilePositionX = 0; } - if (num13 > Main.maxTilesX) + if (tileWidthPosX > Main.maxTilesX) { - num13 = Main.maxTilesX; + tileWidthPosX = Main.maxTilesX; } - if (num14 < 0) + if (tilePositionY < 0) { - num14 = 0; + tilePositionY = 0; } - if (num15 > Main.maxTilesY) + if (tileWidthPosY > Main.maxTilesY) { - num15 = Main.maxTilesY; + tileWidthPosY = Main.maxTilesY; } - bool flag2 = lungeUpward; - if (!flag2) + bool shouldFly = lungeUpward; + if (!shouldFly) { - for (int k = num12; k < num13; k++) + for (int k = tilePositionX; k < tileWidthPosX; k++) { - for (int l = num14; l < num15; l++) + for (int l = tilePositionY; l < tileWidthPosY; l++) { if (Main.tile[k, l] != null && ((Main.tile[k, l].HasUnactuatedTile && (Main.tileSolid[(int)Main.tile[k, l].TileType] || (Main.tileSolidTop[(int)Main.tile[k, l].TileType] && Main.tile[k, l].TileFrameY == 0))) || Main.tile[k, l].LiquidAmount > 64)) { @@ -240,36 +240,36 @@ namespace CalamityMod.NPCs.Perforator vector2.Y = (float)(l * 16); if (NPC.position.X + (float)NPC.width > vector2.X && NPC.position.X < vector2.X + 16f && NPC.position.Y + (float)NPC.height > vector2.Y && NPC.position.Y < vector2.Y + 16f) { - flag2 = true; + shouldFly = true; break; } } } } } - if (!flag2) + if (!shouldFly) { NPC.localAI[1] = 1f; Rectangle rectangle = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); - int num16 = death ? 160 : revenge ? 200 : expertMode ? 240 : 300; - bool flag3 = true; + int stopFlyingRadius = death ? 160 : revenge ? 200 : expertMode ? 240 : 300; + bool outsideFlyingRadius = true; if (NPC.position.Y > player.position.Y) { for (int m = 0; m < 255; m++) { if (Main.player[m].active) { - Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - num16, (int)Main.player[m].position.Y - num16, num16 * 2, num16 * 2); + Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - stopFlyingRadius, (int)Main.player[m].position.Y - stopFlyingRadius, stopFlyingRadius * 2, stopFlyingRadius * 2); if (rectangle.Intersects(rectangle2)) { - flag3 = false; + outsideFlyingRadius = false; break; } } } - if (flag3) + if (outsideFlyingRadius) { - flag2 = true; + shouldFly = true; } } } @@ -278,15 +278,15 @@ namespace CalamityMod.NPCs.Perforator NPC.localAI[1] = 0f; } - float num17 = 16f; + float fallSpeed = 16f; if (player.dead || CalamityGlobalNPC.perfHive < 0 || !Main.npc[CalamityGlobalNPC.perfHive].active) { - flag2 = false; + shouldFly = false; NPC.velocity.Y += 1f; if ((double)NPC.position.Y > Main.worldSurface * 16.0) { NPC.velocity.Y += 1f; - num17 = 32f; + fallSpeed = 32f; } if ((double)NPC.position.Y > Main.rockLayer * 16.0) { @@ -329,21 +329,21 @@ namespace CalamityMod.NPCs.Perforator NPC.Calamity().newAI[3] = -300f; } - float num18 = speed; - float num19 = turnSpeed; + float speedCopy = speed; + float turnSpeedCopy = turnSpeed; float burrowDistance = bossRush ? 500f : 800f; float burrowTarget = player.Center.Y + burrowDistance; float lungeTarget = NPC.Calamity().newAI[2]; - Vector2 vector3 = NPC.Center; - float num20 = player.Center.X; - float num21 = lungeUpward ? lungeTarget : burrow ? burrowTarget : player.Center.Y; - num20 = (float)((int)(num20 / 16f) * 16); - num21 = (float)((int)(num21 / 16f) * 16); - vector3.X = (float)((int)(vector3.X / 16f) * 16); - vector3.Y = (float)((int)(vector3.Y / 16f) * 16); - num20 -= vector3.X; - num21 -= vector3.Y; - float num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); + Vector2 npcCenter = NPC.Center; + float playerX = player.Center.X; + float targettingPosition = lungeUpward ? lungeTarget : burrow ? burrowTarget : player.Center.Y; + playerX = (float)((int)(playerX / 16f) * 16); + targettingPosition = (float)((int)(targettingPosition / 16f) * 16); + npcCenter.X = (float)((int)(npcCenter.X / 16f) * 16); + npcCenter.Y = (float)((int)(npcCenter.Y / 16f) * 16); + playerX -= npcCenter.X; + targettingPosition -= npcCenter.Y; + float targetDistance = (float)Math.Sqrt((double)(playerX * playerX + targettingPosition * targettingPosition)); // Lunge up towards target if (burrow && NPC.Center.Y >= burrowTarget - 16f) @@ -375,45 +375,45 @@ namespace CalamityMod.NPCs.Perforator NPC.Calamity().newAI[1] = 0f; } - if (!flag2) + if (!shouldFly) { NPC.TargetClosest(true); NPC.velocity.Y = NPC.velocity.Y + 0.15f; - if (NPC.velocity.Y > num17) + if (NPC.velocity.Y > fallSpeed) { - NPC.velocity.Y = num17; + NPC.velocity.Y = fallSpeed; } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)num17 * 0.4) + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)fallSpeed * 0.4) { if (NPC.velocity.X < 0f) { - NPC.velocity.X = NPC.velocity.X - num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X - speedCopy * 1.1f; } else { - NPC.velocity.X = NPC.velocity.X + num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X + speedCopy * 1.1f; } } - else if (NPC.velocity.Y == num17) + else if (NPC.velocity.Y == fallSpeed) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < playerX) { - NPC.velocity.X = NPC.velocity.X + num18; + NPC.velocity.X = NPC.velocity.X + speedCopy; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > playerX) { - NPC.velocity.X = NPC.velocity.X - num18; + NPC.velocity.X = NPC.velocity.X - speedCopy; } } else if (NPC.velocity.Y > 4f) { if (NPC.velocity.X < 0f) { - NPC.velocity.X = NPC.velocity.X + num18 * 0.9f; + NPC.velocity.X = NPC.velocity.X + speedCopy * 0.9f; } else { - NPC.velocity.X = NPC.velocity.X - num18 * 0.9f; + NPC.velocity.X = NPC.velocity.X - speedCopy * 0.9f; } } } @@ -421,131 +421,131 @@ namespace CalamityMod.NPCs.Perforator { if (NPC.soundDelay == 0) { - float num24 = num22 / 40f; - if (num24 < 10f) + float soundDelay = targetDistance / 40f; + if (soundDelay < 10f) { - num24 = 10f; + soundDelay = 10f; } - if (num24 > 20f) + if (soundDelay > 20f) { - num24 = 20f; + soundDelay = 20f; } - NPC.soundDelay = (int)num24; + NPC.soundDelay = (int)soundDelay; SoundEngine.PlaySound(SoundID.WormDig, NPC.Center); } - num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); - float num25 = Math.Abs(num20); - float num26 = Math.Abs(num21); - float num27 = num17 / num22; - num20 *= num27; - num21 *= num27; - if (((NPC.velocity.X > 0f && num20 > 0f) || (NPC.velocity.X < 0f && num20 < 0f)) && ((NPC.velocity.Y > 0f && num21 > 0f) || (NPC.velocity.Y < 0f && num21 < 0f))) + targetDistance = (float)Math.Sqrt((double)(playerX * playerX + targettingPosition * targettingPosition)); + float absoluteTargetX = Math.Abs(playerX); + float absoluteTargetPos = Math.Abs(targettingPosition); + float timeToReachTarget = fallSpeed / targetDistance; + playerX *= timeToReachTarget; + targettingPosition *= timeToReachTarget; + if (((NPC.velocity.X > 0f && playerX > 0f) || (NPC.velocity.X < 0f && playerX < 0f)) && ((NPC.velocity.Y > 0f && targettingPosition > 0f) || (NPC.velocity.Y < 0f && targettingPosition < 0f))) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < playerX) { - NPC.velocity.X = NPC.velocity.X + num19; + NPC.velocity.X = NPC.velocity.X + turnSpeedCopy; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > playerX) { - NPC.velocity.X = NPC.velocity.X - num19; + NPC.velocity.X = NPC.velocity.X - turnSpeedCopy; } - if (NPC.velocity.Y < num21) + if (NPC.velocity.Y < targettingPosition) { - NPC.velocity.Y = NPC.velocity.Y + num19; + NPC.velocity.Y = NPC.velocity.Y + turnSpeedCopy; } - else if (NPC.velocity.Y > num21) + else if (NPC.velocity.Y > targettingPosition) { - NPC.velocity.Y = NPC.velocity.Y - num19; + NPC.velocity.Y = NPC.velocity.Y - turnSpeedCopy; } } - if ((NPC.velocity.X > 0f && num20 > 0f) || (NPC.velocity.X < 0f && num20 < 0f) || (NPC.velocity.Y > 0f && num21 > 0f) || (NPC.velocity.Y < 0f && num21 < 0f)) + if ((NPC.velocity.X > 0f && playerX > 0f) || (NPC.velocity.X < 0f && playerX < 0f) || (NPC.velocity.Y > 0f && targettingPosition > 0f) || (NPC.velocity.Y < 0f && targettingPosition < 0f)) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < playerX) { - NPC.velocity.X = NPC.velocity.X + num18; + NPC.velocity.X = NPC.velocity.X + speedCopy; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > playerX) { - NPC.velocity.X = NPC.velocity.X - num18; + NPC.velocity.X = NPC.velocity.X - speedCopy; } - if (NPC.velocity.Y < num21) + if (NPC.velocity.Y < targettingPosition) { - NPC.velocity.Y = NPC.velocity.Y + num18; + NPC.velocity.Y = NPC.velocity.Y + speedCopy; } - else if (NPC.velocity.Y > num21) + else if (NPC.velocity.Y > targettingPosition) { - NPC.velocity.Y = NPC.velocity.Y - num18; + NPC.velocity.Y = NPC.velocity.Y - speedCopy; } - if ((double)Math.Abs(num21) < (double)num17 * 0.2 && ((NPC.velocity.X > 0f && num20 < 0f) || (NPC.velocity.X < 0f && num20 > 0f))) + if ((double)Math.Abs(targettingPosition) < (double)fallSpeed * 0.2 && ((NPC.velocity.X > 0f && playerX < 0f) || (NPC.velocity.X < 0f && playerX > 0f))) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num18 * 2f; + NPC.velocity.Y = NPC.velocity.Y + speedCopy * 2f; } else { - NPC.velocity.Y = NPC.velocity.Y - num18 * 2f; + NPC.velocity.Y = NPC.velocity.Y - speedCopy * 2f; } } - if ((double)Math.Abs(num20) < (double)num17 * 0.2 && ((NPC.velocity.Y > 0f && num21 < 0f) || (NPC.velocity.Y < 0f && num21 > 0f))) + if ((double)Math.Abs(playerX) < (double)fallSpeed * 0.2 && ((NPC.velocity.Y > 0f && targettingPosition < 0f) || (NPC.velocity.Y < 0f && targettingPosition > 0f))) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num18 * 2f; + NPC.velocity.X = NPC.velocity.X + speedCopy * 2f; } else { - NPC.velocity.X = NPC.velocity.X - num18 * 2f; + NPC.velocity.X = NPC.velocity.X - speedCopy * 2f; } } } - else if (num25 > num26) + else if (absoluteTargetX > absoluteTargetPos) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < playerX) { - NPC.velocity.X = NPC.velocity.X + num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X + speedCopy * 1.1f; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > playerX) { - NPC.velocity.X = NPC.velocity.X - num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X - speedCopy * 1.1f; } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)num17 * 0.5) + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)fallSpeed * 0.5) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num18; + NPC.velocity.Y = NPC.velocity.Y + speedCopy; } else { - NPC.velocity.Y = NPC.velocity.Y - num18; + NPC.velocity.Y = NPC.velocity.Y - speedCopy; } } } else { - if (NPC.velocity.Y < num21) + if (NPC.velocity.Y < targettingPosition) { - NPC.velocity.Y = NPC.velocity.Y + num18 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y + speedCopy * 1.1f; } - else if (NPC.velocity.Y > num21) + else if (NPC.velocity.Y > targettingPosition) { - NPC.velocity.Y = NPC.velocity.Y - num18 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y - speedCopy * 1.1f; } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)num17 * 0.5) + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)fallSpeed * 0.5) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num18; + NPC.velocity.X = NPC.velocity.X + speedCopy; } else { - NPC.velocity.X = NPC.velocity.X - num18; + NPC.velocity.X = NPC.velocity.X - speedCopy; } } } } NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) + 1.57f; - if (flag2) + if (shouldFly) { if (NPC.localAI[0] != 1f) { @@ -577,17 +577,17 @@ namespace CalamityMod.NPCs.Perforator spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/Perforator/PerforatorHeadLargeGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + Color glowmaskColor = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/Perforator/PerforatorHeadMedium.cs b/NPCs/Perforator/PerforatorHeadMedium.cs index cf594c29c1..5b958674a2 100644 --- a/NPCs/Perforator/PerforatorHeadMedium.cs +++ b/NPCs/Perforator/PerforatorHeadMedium.cs @@ -20,7 +20,7 @@ namespace CalamityMod.NPCs.Perforator public override void SetStaticDefaults() { NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.7f, PortraitScale = 0.7f, @@ -163,70 +163,70 @@ namespace CalamityMod.NPCs.Perforator } // Movement - int num29 = (int)(NPC.position.X / 16f) - 1; - int num30 = (int)((NPC.position.X + NPC.width) / 16f) + 2; - int num31 = (int)(NPC.position.Y / 16f) - 1; - int num32 = (int)((NPC.position.Y + NPC.height) / 16f) + 2; - if (num29 < 0) - num29 = 0; - if (num30 > Main.maxTilesX) - num30 = Main.maxTilesX; - if (num31 < 0) - num31 = 0; - if (num32 > Main.maxTilesY) - num32 = Main.maxTilesY; + int tilePositionX = (int)(NPC.position.X / 16f) - 1; + int tileWidthPosX = (int)((NPC.position.X + NPC.width) / 16f) + 2; + int tilePositionY = (int)(NPC.position.Y / 16f) - 1; + int tileWidthPosY = (int)((NPC.position.Y + NPC.height) / 16f) + 2; + if (tilePositionX < 0) + tilePositionX = 0; + if (tileWidthPosX > Main.maxTilesX) + tileWidthPosX = Main.maxTilesX; + if (tilePositionY < 0) + tilePositionY = 0; + if (tileWidthPosY > Main.maxTilesY) + tileWidthPosY = Main.maxTilesY; // Fly or not - bool flag2 = false; - if (!flag2) + bool shouldFly = false; + if (!shouldFly) { - for (int num33 = num29; num33 < num30; num33++) + for (int i = tilePositionX; i < tileWidthPosX; i++) { - for (int num34 = num31; num34 < num32; num34++) + for (int j = tilePositionY; j < tileWidthPosY; j++) { - if (Main.tile[num33, num34] != null && ((Main.tile[num33, num34].HasUnactuatedTile && (Main.tileSolid[Main.tile[num33, num34].TileType] || (Main.tileSolidTop[Main.tile[num33, num34].TileType] && Main.tile[num33, num34].TileFrameY == 0))) || Main.tile[num33, num34].LiquidAmount > 64)) + if (Main.tile[i, j] != null && ((Main.tile[i, j].HasUnactuatedTile && (Main.tileSolid[Main.tile[i, j].TileType] || (Main.tileSolidTop[Main.tile[i, j].TileType] && Main.tile[i, j].TileFrameY == 0))) || Main.tile[i, j].LiquidAmount > 64)) { Vector2 vector; - vector.X = num33 * 16; - vector.Y = num34 * 16; + vector.X = i * 16; + vector.Y = j * 16; if (NPC.position.X + NPC.width > vector.X && NPC.position.X < vector.X + 16f && NPC.position.Y + NPC.height > vector.Y && NPC.position.Y < vector.Y + 16f) { - flag2 = true; - if (Main.rand.NextBool(100) && Main.tile[num33, num34].HasUnactuatedTile) + shouldFly = true; + if (Main.rand.NextBool(100) && Main.tile[i, j].HasUnactuatedTile) { - WorldGen.KillTile(num33, num34, true, true, false); + WorldGen.KillTile(i, j, true, true, false); } } } } } } - if (!flag2) + if (!shouldFly) { Rectangle rectangle = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); - int num35 = death ? 160 : revenge ? 200 : expertMode ? 240 : 300; - bool flag3 = true; - for (int num36 = 0; num36 < Main.maxPlayers; num36++) + int stopFlyingRadius = death ? 160 : revenge ? 200 : expertMode ? 240 : 300; + bool outsideFlyRadius = true; + for (int k = 0; k < Main.maxPlayers; k++) { - if (Main.player[num36].active) + if (Main.player[k].active) { - Rectangle rectangle2 = new Rectangle((int)Main.player[num36].position.X - num35, (int)Main.player[num36].position.Y - num35, num35 * 2, num35 * 2); + Rectangle rectangle2 = new Rectangle((int)Main.player[k].position.X - stopFlyingRadius, (int)Main.player[k].position.Y - stopFlyingRadius, stopFlyingRadius * 2, stopFlyingRadius * 2); if (rectangle.Intersects(rectangle2)) { - flag3 = false; + outsideFlyRadius = false; break; } } } - if (flag3) - flag2 = true; + if (outsideFlyRadius) + shouldFly = true; } float fallSpeed = 16f; if (player.dead || CalamityGlobalNPC.perfHive < 0 || !Main.npc[CalamityGlobalNPC.perfHive].active) { NPC.TargetClosest(false); - flag2 = false; + shouldFly = false; NPC.velocity.Y += 1f; if (NPC.position.Y > Main.worldSurface * 16.0) { @@ -235,31 +235,31 @@ namespace CalamityMod.NPCs.Perforator } if (NPC.position.Y > Main.rockLayer * 16.0) { - for (int num957 = 0; num957 < Main.maxNPCs; num957++) + for (int p = 0; p < Main.maxNPCs; p++) { - if (Main.npc[num957].type == NPC.type || Main.npc[num957].type == ModContent.NPCType() || Main.npc[num957].type == ModContent.NPCType()) + if (Main.npc[p].type == NPC.type || Main.npc[p].type == ModContent.NPCType() || Main.npc[p].type == ModContent.NPCType()) { - Main.npc[num957].active = false; + Main.npc[p].active = false; } } } } // Velocity and acceleration - float num37 = speed; - float num38 = turnSpeed; + float speedCopy = speed; + float turnSpeedCopy = turnSpeed; Vector2 vector2 = NPC.Center; - float num39 = player.Center.X; - float num40 = player.Center.Y; + float targetX = player.Center.X; + float targetY = player.Center.Y; - num39 = (int)(num39 / 16f) * 16; - num40 = (int)(num40 / 16f) * 16; + targetX = (int)(targetX / 16f) * 16; + targetY = (int)(targetY / 16f) * 16; vector2.X = (int)(vector2.X / 16f) * 16; vector2.Y = (int)(vector2.Y / 16f) * 16; - num39 -= vector2.X; - num40 -= vector2.Y; - float num52 = (float)Math.Sqrt(num39 * num39 + num40 * num40); + targetX -= vector2.X; + targetY -= vector2.Y; + float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); // Prevent new heads from being slowed when they spawn if (NPC.Calamity().newAI[1] < 3f) @@ -267,10 +267,10 @@ namespace CalamityMod.NPCs.Perforator NPC.Calamity().newAI[1] += 1f; // Set velocity for when a new head spawns - NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * (num37 * (death ? 0.3f : 0.2f)); + NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * (speedCopy * (death ? 0.3f : 0.2f)); } - if (!flag2) + if (!shouldFly) { NPC.velocity.Y += 0.15f; if (NPC.velocity.Y > fallSpeed) @@ -279,23 +279,23 @@ namespace CalamityMod.NPCs.Perforator if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < fallSpeed * 0.4) { if (NPC.velocity.X < 0f) - NPC.velocity.X -= num38 * 1.1f; + NPC.velocity.X -= turnSpeedCopy * 1.1f; else - NPC.velocity.X += num38 * 1.1f; + NPC.velocity.X += turnSpeedCopy * 1.1f; } else if (NPC.velocity.Y == fallSpeed) { - if (NPC.velocity.X < num39) - NPC.velocity.X += num38; - else if (NPC.velocity.X > num39) - NPC.velocity.X -= num38; + if (NPC.velocity.X < targetX) + NPC.velocity.X += turnSpeedCopy; + else if (NPC.velocity.X > targetX) + NPC.velocity.X -= turnSpeedCopy; } else if (NPC.velocity.Y > 4f) { if (NPC.velocity.X < 0f) - NPC.velocity.X += num38 * 0.9f; + NPC.velocity.X += turnSpeedCopy * 0.9f; else - NPC.velocity.X -= num38 * 0.9f; + NPC.velocity.X -= turnSpeedCopy * 0.9f; } } else @@ -303,99 +303,99 @@ namespace CalamityMod.NPCs.Perforator // Sound if (NPC.soundDelay == 0) { - float num54 = num52 / 40f; - if (num54 < 10f) - num54 = 10f; - if (num54 > 20f) - num54 = 20f; + float soundDelay = targetDistance / 40f; + if (soundDelay < 10f) + soundDelay = 10f; + if (soundDelay > 20f) + soundDelay = 20f; - NPC.soundDelay = (int)num54; + NPC.soundDelay = (int)soundDelay; SoundEngine.PlaySound(SoundID.WormDig, NPC.Center); } - num52 = (float)Math.Sqrt(num39 * num39 + num40 * num40); - float num55 = Math.Abs(num39); - float num56 = Math.Abs(num40); - float num57 = fallSpeed / num52; - num39 *= num57; - num40 *= num57; + targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); + float absoluteTargetX = Math.Abs(targetX); + float absoluteTargetY = Math.Abs(targetY); + float timeToReachTarget = fallSpeed / targetDistance; + targetX *= timeToReachTarget; + targetY *= timeToReachTarget; - if (((NPC.velocity.X > 0f && num39 > 0f) || (NPC.velocity.X < 0f && num39 < 0f)) && ((NPC.velocity.Y > 0f && num40 > 0f) || (NPC.velocity.Y < 0f && num40 < 0f))) + if (((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f)) && ((NPC.velocity.Y > 0f && targetY > 0f) || (NPC.velocity.Y < 0f && targetY < 0f))) { - if (NPC.velocity.X < num39) - NPC.velocity.X += num38; - else if (NPC.velocity.X > num39) - NPC.velocity.X -= num38; + if (NPC.velocity.X < targetX) + NPC.velocity.X += turnSpeedCopy; + else if (NPC.velocity.X > targetX) + NPC.velocity.X -= turnSpeedCopy; - if (NPC.velocity.Y < num40) - NPC.velocity.Y += num38; - else if (NPC.velocity.Y > num40) - NPC.velocity.Y -= num38; + if (NPC.velocity.Y < targetY) + NPC.velocity.Y += turnSpeedCopy; + else if (NPC.velocity.Y > targetY) + NPC.velocity.Y -= turnSpeedCopy; } - if ((NPC.velocity.X > 0f && num39 > 0f) || (NPC.velocity.X < 0f && num39 < 0f) || (NPC.velocity.Y > 0f && num40 > 0f) || (NPC.velocity.Y < 0f && num40 < 0f)) + if ((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f) || (NPC.velocity.Y > 0f && targetY > 0f) || (NPC.velocity.Y < 0f && targetY < 0f)) { - if (NPC.velocity.X < num39) - NPC.velocity.X += num37; - else if (NPC.velocity.X > num39) - NPC.velocity.X -= num37; + if (NPC.velocity.X < targetX) + NPC.velocity.X += speedCopy; + else if (NPC.velocity.X > targetX) + NPC.velocity.X -= speedCopy; - if (NPC.velocity.Y < num40) - NPC.velocity.Y += num37; - else if (NPC.velocity.Y > num40) - NPC.velocity.Y -= num37; + if (NPC.velocity.Y < targetY) + NPC.velocity.Y += speedCopy; + else if (NPC.velocity.Y > targetY) + NPC.velocity.Y -= speedCopy; - if (Math.Abs(num40) < fallSpeed * 0.2 && ((NPC.velocity.X > 0f && num39 < 0f) || (NPC.velocity.X < 0f && num39 > 0f))) + if (Math.Abs(targetY) < fallSpeed * 0.2 && ((NPC.velocity.X > 0f && targetX < 0f) || (NPC.velocity.X < 0f && targetX > 0f))) { if (NPC.velocity.Y > 0f) - NPC.velocity.Y += num37 * 2f; + NPC.velocity.Y += speedCopy * 2f; else - NPC.velocity.Y -= num37 * 2f; + NPC.velocity.Y -= speedCopy * 2f; } - if (Math.Abs(num39) < fallSpeed * 0.2 && ((NPC.velocity.Y > 0f && num40 < 0f) || (NPC.velocity.Y < 0f && num40 > 0f))) + if (Math.Abs(targetX) < fallSpeed * 0.2 && ((NPC.velocity.Y > 0f && targetY < 0f) || (NPC.velocity.Y < 0f && targetY > 0f))) { if (NPC.velocity.X > 0f) - NPC.velocity.X += num37 * 2f; + NPC.velocity.X += speedCopy * 2f; else - NPC.velocity.X -= num37 * 2f; + NPC.velocity.X -= speedCopy * 2f; } } - else if (num55 > num56) + else if (absoluteTargetX > absoluteTargetY) { - if (NPC.velocity.X < num39) - NPC.velocity.X += num37 * 1.1f; - else if (NPC.velocity.X > num39) - NPC.velocity.X -= num37 * 1.1f; + if (NPC.velocity.X < targetX) + NPC.velocity.X += speedCopy * 1.1f; + else if (NPC.velocity.X > targetX) + NPC.velocity.X -= speedCopy * 1.1f; if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < fallSpeed * 0.5) { if (NPC.velocity.Y > 0f) - NPC.velocity.Y += num37; + NPC.velocity.Y += speedCopy; else - NPC.velocity.Y -= num37; + NPC.velocity.Y -= speedCopy; } } else { - if (NPC.velocity.Y < num40) - NPC.velocity.Y += num37 * 1.1f; - else if (NPC.velocity.Y > num40) - NPC.velocity.Y -= num37 * 1.1f; + if (NPC.velocity.Y < targetY) + NPC.velocity.Y += speedCopy * 1.1f; + else if (NPC.velocity.Y > targetY) + NPC.velocity.Y -= speedCopy * 1.1f; if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < fallSpeed * 0.5) { if (NPC.velocity.X > 0f) - NPC.velocity.X += num37; + NPC.velocity.X += speedCopy; else - NPC.velocity.X -= num37; + NPC.velocity.X -= speedCopy; } } } NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; - if (flag2) + if (shouldFly) { if (NPC.localAI[0] != 1f) NPC.netUpdate = true; @@ -423,17 +423,17 @@ namespace CalamityMod.NPCs.Perforator spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/Perforator/PerforatorHeadMediumGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + Color glowmaskColor = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/Perforator/PerforatorHeadSmall.cs b/NPCs/Perforator/PerforatorHeadSmall.cs index a5b11a4b80..dd79644dc6 100644 --- a/NPCs/Perforator/PerforatorHeadSmall.cs +++ b/NPCs/Perforator/PerforatorHeadSmall.cs @@ -24,7 +24,7 @@ namespace CalamityMod.NPCs.Perforator public override void SetStaticDefaults() { NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.8f, PortraitScale = 0.8f, @@ -157,10 +157,10 @@ namespace CalamityMod.NPCs.Perforator { int Previous = NPC.whoAmI; int maxLength = death ? 9 : revenge ? 8 : expertMode ? 7 : 5; - for (int num36 = 0; num36 < maxLength; num36++) + for (int segments = 0; segments < maxLength; segments++) { int lol; - if (num36 >= 0 && num36 < maxLength - 1) + if (segments >= 0 && segments < maxLength - 1) { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); } @@ -179,32 +179,32 @@ namespace CalamityMod.NPCs.Perforator } } - int num12 = (int)(NPC.position.X / 16f) - 1; - int num13 = (int)((NPC.position.X + (float)NPC.width) / 16f) + 2; - int num14 = (int)(NPC.position.Y / 16f) - 1; - int num15 = (int)((NPC.position.Y + (float)NPC.height) / 16f) + 2; - if (num12 < 0) + int tilePositionX = (int)(NPC.position.X / 16f) - 1; + int tileWidthPosX = (int)((NPC.position.X + (float)NPC.width) / 16f) + 2; + int tilePositionY = (int)(NPC.position.Y / 16f) - 1; + int tileWidthPosY = (int)((NPC.position.Y + (float)NPC.height) / 16f) + 2; + if (tilePositionX < 0) { - num12 = 0; + tilePositionX = 0; } - if (num13 > Main.maxTilesX) + if (tileWidthPosX > Main.maxTilesX) { - num13 = Main.maxTilesX; + tileWidthPosX = Main.maxTilesX; } - if (num14 < 0) + if (tilePositionY < 0) { - num14 = 0; + tilePositionY = 0; } - if (num15 > Main.maxTilesY) + if (tileWidthPosY > Main.maxTilesY) { - num15 = Main.maxTilesY; + tileWidthPosY = Main.maxTilesY; } - bool flag2 = false; - if (!flag2) + bool shouldFly = false; + if (!shouldFly) { - for (int k = num12; k < num13; k++) + for (int k = tilePositionX; k < tileWidthPosX; k++) { - for (int l = num14; l < num15; l++) + for (int l = tilePositionY; l < tileWidthPosY; l++) { if (Main.tile[k, l] != null && ((Main.tile[k, l].HasUnactuatedTile && (Main.tileSolid[(int)Main.tile[k, l].TileType] || (Main.tileSolidTop[(int)Main.tile[k, l].TileType] && Main.tile[k, l].TileFrameY == 0))) || Main.tile[k, l].LiquidAmount > 64)) { @@ -213,36 +213,36 @@ namespace CalamityMod.NPCs.Perforator vector2.Y = (float)(l * 16); if (NPC.position.X + (float)NPC.width > vector2.X && NPC.position.X < vector2.X + 16f && NPC.position.Y + (float)NPC.height > vector2.Y && NPC.position.Y < vector2.Y + 16f) { - flag2 = true; + shouldFly = true; break; } } } } } - if (!flag2) + if (!shouldFly) { NPC.localAI[1] = 1f; Rectangle rectangle = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); - int num16 = death ? 160 : revenge ? 200 : expertMode ? 240 : 300; - bool flag3 = true; + int stopFlyingRadius = death ? 160 : revenge ? 200 : expertMode ? 240 : 300; + bool outsideFlyRadius = true; if (NPC.position.Y > player.position.Y) { for (int m = 0; m < 255; m++) { if (Main.player[m].active) { - Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - num16, (int)Main.player[m].position.Y - num16, num16 * 2, num16 * 2); + Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - stopFlyingRadius, (int)Main.player[m].position.Y - stopFlyingRadius, stopFlyingRadius * 2, stopFlyingRadius * 2); if (rectangle.Intersects(rectangle2)) { - flag3 = false; + outsideFlyRadius = false; break; } } } - if (flag3) + if (outsideFlyRadius) { - flag2 = true; + shouldFly = true; } } } @@ -250,15 +250,15 @@ namespace CalamityMod.NPCs.Perforator { NPC.localAI[1] = 0f; } - float num17 = 16f; + float maxChargeSpeed = 16f; if (player.dead || CalamityGlobalNPC.perfHive < 0 || !Main.npc[CalamityGlobalNPC.perfHive].active) { - flag2 = false; + shouldFly = false; NPC.velocity.Y += 1f; if ((double)NPC.position.Y > Main.worldSurface * 16.0) { NPC.velocity.Y += 1f; - num17 = 32f; + maxChargeSpeed = 32f; } if ((double)NPC.position.Y > Main.rockLayer * 16.0) { @@ -279,7 +279,7 @@ namespace CalamityMod.NPCs.Perforator //GFB movement if (NPC.ai[0] >= 300f && CalamityGlobalNPC.perfHive >= 0) { - flag2 = false; + shouldFly = false; NPC Hive = Main.npc[CalamityGlobalNPC.perfHive]; Vector2 targetDistance = Hive.Center - NPC.Center; @@ -304,57 +304,57 @@ namespace CalamityMod.NPCs.Perforator //Normal movement else { - float num18 = speed; - float num19 = turnSpeed; - Vector2 vector3 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num20 = player.position.X + (float)(player.width / 2); - float num21 = player.position.Y + (float)(player.height / 2); - num20 = (float)((int)(num20 / 16f) * 16); - num21 = (float)((int)(num21 / 16f) * 16); - vector3.X = (float)((int)(vector3.X / 16f) * 16); - vector3.Y = (float)((int)(vector3.Y / 16f) * 16); - num20 -= vector3.X; - num21 -= vector3.Y; - float num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); - if (!flag2) + float speedCopy = speed; + float turnSpeedCopy = turnSpeed; + Vector2 npcCenter = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetX = player.position.X + (float)(player.width / 2); + float targetY = player.position.Y + (float)(player.height / 2); + targetX = (float)((int)(targetX / 16f) * 16); + targetY = (float)((int)(targetY / 16f) * 16); + npcCenter.X = (float)((int)(npcCenter.X / 16f) * 16); + npcCenter.Y = (float)((int)(npcCenter.Y / 16f) * 16); + targetX -= npcCenter.X; + targetY -= npcCenter.Y; + float targetDistance = (float)Math.Sqrt((double)(targetX * targetX + targetY * targetY)); + if (!shouldFly) { NPC.TargetClosest(true); NPC.velocity.Y = NPC.velocity.Y + 0.15f; - if (NPC.velocity.Y > num17) + if (NPC.velocity.Y > maxChargeSpeed) { - NPC.velocity.Y = num17; + NPC.velocity.Y = maxChargeSpeed; } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)num17 * 0.4) + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)maxChargeSpeed * 0.4) { if (NPC.velocity.X < 0f) { - NPC.velocity.X = NPC.velocity.X - num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X - speedCopy * 1.1f; } else { - NPC.velocity.X = NPC.velocity.X + num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X + speedCopy * 1.1f; } } - else if (NPC.velocity.Y == num17) + else if (NPC.velocity.Y == maxChargeSpeed) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < targetX) { - NPC.velocity.X = NPC.velocity.X + num18; + NPC.velocity.X = NPC.velocity.X + speedCopy; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > targetX) { - NPC.velocity.X = NPC.velocity.X - num18; + NPC.velocity.X = NPC.velocity.X - speedCopy; } } else if (NPC.velocity.Y > 4f) { if (NPC.velocity.X < 0f) { - NPC.velocity.X = NPC.velocity.X + num18 * 0.9f; + NPC.velocity.X = NPC.velocity.X + speedCopy * 0.9f; } else { - NPC.velocity.X = NPC.velocity.X - num18 * 0.9f; + NPC.velocity.X = NPC.velocity.X - speedCopy * 0.9f; } } } @@ -362,132 +362,132 @@ namespace CalamityMod.NPCs.Perforator { if (NPC.soundDelay == 0) { - float num24 = num22 / 40f; - if (num24 < 10f) + float soundDelay = targetDistance / 40f; + if (soundDelay < 10f) { - num24 = 10f; + soundDelay = 10f; } - if (num24 > 20f) + if (soundDelay > 20f) { - num24 = 20f; + soundDelay = 20f; } - NPC.soundDelay = (int)num24; + NPC.soundDelay = (int)soundDelay; SoundEngine.PlaySound(SoundID.WormDig, NPC.Center); } - num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); - float num25 = Math.Abs(num20); - float num26 = Math.Abs(num21); - float num27 = num17 / num22; - num20 *= num27; - num21 *= num27; - if (((NPC.velocity.X > 0f && num20 > 0f) || (NPC.velocity.X < 0f && num20 < 0f)) && ((NPC.velocity.Y > 0f && num21 > 0f) || (NPC.velocity.Y < 0f && num21 < 0f))) + targetDistance = (float)Math.Sqrt((double)(targetX * targetX + targetY * targetY)); + float absoluteTargetX = Math.Abs(targetX); + float absoluteTargetY = Math.Abs(targetY); + float timeToReachTarget = maxChargeSpeed / targetDistance; + targetX *= timeToReachTarget; + targetY *= timeToReachTarget; + if (((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f)) && ((NPC.velocity.Y > 0f && targetY > 0f) || (NPC.velocity.Y < 0f && targetY < 0f))) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < targetX) { - NPC.velocity.X = NPC.velocity.X + num19; + NPC.velocity.X = NPC.velocity.X + turnSpeedCopy; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > targetX) { - NPC.velocity.X = NPC.velocity.X - num19; + NPC.velocity.X = NPC.velocity.X - turnSpeedCopy; } - if (NPC.velocity.Y < num21) + if (NPC.velocity.Y < targetY) { - NPC.velocity.Y = NPC.velocity.Y + num19; + NPC.velocity.Y = NPC.velocity.Y + turnSpeedCopy; } - else if (NPC.velocity.Y > num21) + else if (NPC.velocity.Y > targetY) { - NPC.velocity.Y = NPC.velocity.Y - num19; + NPC.velocity.Y = NPC.velocity.Y - turnSpeedCopy; } } - if ((NPC.velocity.X > 0f && num20 > 0f) || (NPC.velocity.X < 0f && num20 < 0f) || (NPC.velocity.Y > 0f && num21 > 0f) || (NPC.velocity.Y < 0f && num21 < 0f)) + if ((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f) || (NPC.velocity.Y > 0f && targetY > 0f) || (NPC.velocity.Y < 0f && targetY < 0f)) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < targetX) { - NPC.velocity.X = NPC.velocity.X + num18; + NPC.velocity.X = NPC.velocity.X + speedCopy; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > targetX) { - NPC.velocity.X = NPC.velocity.X - num18; + NPC.velocity.X = NPC.velocity.X - speedCopy; } - if (NPC.velocity.Y < num21) + if (NPC.velocity.Y < targetY) { - NPC.velocity.Y = NPC.velocity.Y + num18; + NPC.velocity.Y = NPC.velocity.Y + speedCopy; } - else if (NPC.velocity.Y > num21) + else if (NPC.velocity.Y > targetY) { - NPC.velocity.Y = NPC.velocity.Y - num18; + NPC.velocity.Y = NPC.velocity.Y - speedCopy; } - if ((double)Math.Abs(num21) < (double)num17 * 0.2 && ((NPC.velocity.X > 0f && num20 < 0f) || (NPC.velocity.X < 0f && num20 > 0f))) + if ((double)Math.Abs(targetY) < (double)maxChargeSpeed * 0.2 && ((NPC.velocity.X > 0f && targetX < 0f) || (NPC.velocity.X < 0f && targetX > 0f))) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num18 * 2f; + NPC.velocity.Y = NPC.velocity.Y + speedCopy * 2f; } else { - NPC.velocity.Y = NPC.velocity.Y - num18 * 2f; + NPC.velocity.Y = NPC.velocity.Y - speedCopy * 2f; } } - if ((double)Math.Abs(num20) < (double)num17 * 0.2 && ((NPC.velocity.Y > 0f && num21 < 0f) || (NPC.velocity.Y < 0f && num21 > 0f))) + if ((double)Math.Abs(targetX) < (double)maxChargeSpeed * 0.2 && ((NPC.velocity.Y > 0f && targetY < 0f) || (NPC.velocity.Y < 0f && targetY > 0f))) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num18 * 2f; + NPC.velocity.X = NPC.velocity.X + speedCopy * 2f; } else { - NPC.velocity.X = NPC.velocity.X - num18 * 2f; + NPC.velocity.X = NPC.velocity.X - speedCopy * 2f; } } } - else if (num25 > num26) + else if (absoluteTargetX > absoluteTargetY) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < targetX) { - NPC.velocity.X = NPC.velocity.X + num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X + speedCopy * 1.1f; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > targetX) { - NPC.velocity.X = NPC.velocity.X - num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X - speedCopy * 1.1f; } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)num17 * 0.5) + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)maxChargeSpeed * 0.5) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num18; + NPC.velocity.Y = NPC.velocity.Y + speedCopy; } else { - NPC.velocity.Y = NPC.velocity.Y - num18; + NPC.velocity.Y = NPC.velocity.Y - speedCopy; } } } else { - if (NPC.velocity.Y < num21) + if (NPC.velocity.Y < targetY) { - NPC.velocity.Y = NPC.velocity.Y + num18 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y + speedCopy * 1.1f; } - else if (NPC.velocity.Y > num21) + else if (NPC.velocity.Y > targetY) { - NPC.velocity.Y = NPC.velocity.Y - num18 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y - speedCopy * 1.1f; } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)num17 * 0.5) + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)maxChargeSpeed * 0.5) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num18; + NPC.velocity.X = NPC.velocity.X + speedCopy; } else { - NPC.velocity.X = NPC.velocity.X - num18; + NPC.velocity.X = NPC.velocity.X - speedCopy; } } } } } NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) + 1.57f; - if (flag2) + if (shouldFly) { if (NPC.localAI[0] != 1f) { @@ -519,17 +519,17 @@ namespace CalamityMod.NPCs.Perforator spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 glowmaskDrawLocation = NPC.Center - screenPos; + glowmaskDrawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; + glowmaskDrawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, glowmaskDrawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/Perforator/PerforatorHeadSmallGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + Color glowmaskColor = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, glowmaskDrawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/Perforator/PerforatorHive.cs b/NPCs/Perforator/PerforatorHive.cs index 35f99c2361..7eddc1ae75 100644 --- a/NPCs/Perforator/PerforatorHive.cs +++ b/NPCs/Perforator/PerforatorHive.cs @@ -46,7 +46,7 @@ namespace CalamityMod.NPCs.Perforator { Main.npcFrameCount[NPC.type] = 10; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0); NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; NPCID.Sets.MPAllowedEnemies[Type] = true; } @@ -240,8 +240,8 @@ namespace CalamityMod.NPCs.Perforator { if (Main.netMode != NetmodeID.MultiplayerClient) { - int num660 = (int)(NPC.lifeMax * (Main.getGoodWorld ? 0.15 : 0.25)); - if ((NPC.life + num660) < NPC.ai[3]) + int wormSpawnGateValue = (int)(NPC.lifeMax * (Main.getGoodWorld ? 0.15 : 0.25)); + if ((NPC.life + wormSpawnGateValue) < NPC.ai[3]) { NPC.ai[3] = NPC.life; int wormType = ModContent.NPCType(); @@ -276,24 +276,24 @@ namespace CalamityMod.NPCs.Perforator SoundEngine.PlaySound(SoundID.NPCDeath23, NPC.Center); - for (int num621 = 0; num621 < 16; num621++) + for (int i = 0; i < 16; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 170, 0f, 0f, 100, default, 1f); - Main.dust[num622].velocity *= 2f; + int ichorDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 170, 0f, 0f, 100, default, 1f); + Main.dust[ichorDust].velocity *= 2f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.25f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[ichorDust].scale = 0.25f; + Main.dust[ichorDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 32; num623++) + for (int j = 0; j < 32; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 1.5f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 3f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int bloodDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 1.5f); + Main.dust[bloodDust].noGravity = true; + Main.dust[bloodDust].velocity *= 3f; + bloodDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 1f); + Main.dust[bloodDust].velocity *= 2f; } } } @@ -329,16 +329,16 @@ namespace CalamityMod.NPCs.Perforator SoundEngine.PlaySound(SoundID.NPCDeath23, NPC.Center); - for (int num621 = 0; num621 < 32; num621++) + for (int i = 0; i < 32; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 170, 0f, 0f, 100, default, 1f); - float dustVelocityYAdd = Math.Abs(Main.dust[num622].velocity.Y) * 0.5f; - if (Main.dust[num622].velocity.Y < 0f) - Main.dust[num622].velocity.Y = 2f + dustVelocityYAdd; + int ichorDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 170, 0f, 0f, 100, default, 1f); + float dustVelocityYAdd = Math.Abs(Main.dust[ichorDust].velocity.Y) * 0.5f; + if (Main.dust[ichorDust].velocity.Y < 0f) + Main.dust[ichorDust].velocity.Y = 2f + dustVelocityYAdd; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.25f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[ichorDust].scale = 0.25f; + Main.dust[ichorDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } @@ -393,24 +393,24 @@ namespace CalamityMod.NPCs.Perforator NPC.localAI[0] = 0f; SoundEngine.PlaySound(SoundID.NPCHit20, NPC.Center); - for (int num621 = 0; num621 < 8; num621++) + for (int i = 0; i < 8; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 170, 0f, 0f, 100, default, 1f); - Main.dust[num622].velocity *= 3f; + int ichorDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 170, 0f, 0f, 100, default, 1f); + Main.dust[ichorDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.25f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[ichorDust].scale = 0.25f; + Main.dust[ichorDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 16; num623++) + for (int j = 0; j < 16; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 1.5f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int bloodDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 1.5f); + Main.dust[bloodDust].noGravity = true; + Main.dust[bloodDust].velocity *= 5f; + bloodDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 1f); + Main.dust[bloodDust].velocity *= 2f; } int type = Main.rand.NextBool() ? ModContent.ProjectileType() : ModContent.ProjectileType(); @@ -487,17 +487,17 @@ namespace CalamityMod.NPCs.Perforator spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/Perforator/PerforatorHiveGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + Color glowmaskColor = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -576,7 +576,7 @@ namespace CalamityMod.NPCs.Perforator npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB Bloodfin drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), 1, 1, 9999); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), 1, 1, 9999, true); // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedPerforator, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -609,23 +609,23 @@ namespace CalamityMod.NPCs.Perforator NPC.height = 100; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int ichorDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 2f); + Main.dust[ichorDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[ichorDust].scale = 0.5f; + Main.dust[ichorDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int bloodDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 3f); + Main.dust[bloodDust].noGravity = true; + Main.dust[bloodDust].velocity *= 5f; + bloodDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 2f); + Main.dust[bloodDust].velocity *= 2f; } } } diff --git a/NPCs/Perforator/PerforatorTailLarge.cs b/NPCs/Perforator/PerforatorTailLarge.cs index 3ba822c041..decd23463b 100644 --- a/NPCs/Perforator/PerforatorTailLarge.cs +++ b/NPCs/Perforator/PerforatorTailLarge.cs @@ -102,40 +102,40 @@ namespace CalamityMod.NPCs.Perforator if (Main.player[NPC.target].dead) NPC.TargetClosest(false); - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetX = (float)((int)(targetX / 16f) * 16); + targetY = (float)((int)(targetY / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetX -= segmentPosition.X; + targetY -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetX * targetX + targetY * targetY)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetX = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetY = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetY, (double)targetX) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetX * targetX + targetY * targetY)); + int npcWidth = NPC.width; + targetDistance = (targetDistance - (float)npcWidth) / targetDistance; + targetX *= targetDistance; + targetY *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetX; + NPC.position.Y = NPC.position.Y + targetY; - if (num191 < 0f) + if (targetX < 0f) NPC.spriteDirection = 1; - else if (num191 > 0f) + else if (targetX > 0f) NPC.spriteDirection = -1; } } @@ -147,17 +147,17 @@ namespace CalamityMod.NPCs.Perforator spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/Perforator/PerforatorTailLargeGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + Color glowmaskColor = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/Perforator/PerforatorTailMedium.cs b/NPCs/Perforator/PerforatorTailMedium.cs index 3f89c5fada..a87c5bab46 100644 --- a/NPCs/Perforator/PerforatorTailMedium.cs +++ b/NPCs/Perforator/PerforatorTailMedium.cs @@ -102,40 +102,40 @@ namespace CalamityMod.NPCs.Perforator NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, NPC.whoAmI, -1f, 0f, 0f, 0, 0, 0); } - Vector2 vector2 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num39 = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); - float num40 = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); + Vector2 segmentDirection = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); + float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); - num39 = (int)(num39 / 16f) * 16; - num40 = (int)(num40 / 16f) * 16; - vector2.X = (int)(vector2.X / 16f) * 16; - vector2.Y = (int)(vector2.Y / 16f) * 16; - num39 -= vector2.X; - num40 -= vector2.Y; - float num52 = (float)Math.Sqrt(num39 * num39 + num40 * num40); + targetX = (int)(targetX / 16f) * 16; + targetY = (int)(targetY / 16f) * 16; + segmentDirection.X = (int)(segmentDirection.X / 16f) * 16; + segmentDirection.Y = (int)(segmentDirection.Y / 16f) * 16; + targetX -= segmentDirection.X; + targetY -= segmentDirection.Y; + float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) { try { - vector2 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - num39 = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - vector2.X; - num40 = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - vector2.Y; + segmentDirection = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + targetX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - segmentDirection.X; + targetY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - segmentDirection.Y; } catch { } - NPC.rotation = (float)Math.Atan2(num40, num39) + MathHelper.PiOver2; - num52 = (float)Math.Sqrt(num39 * num39 + num40 * num40); - int num53 = NPC.width; - num53 = (int)(num53 * NPC.scale); - num52 = (num52 - num53) / num52; - num39 *= num52; - num40 *= num52; + NPC.rotation = (float)Math.Atan2(targetY, targetX) + MathHelper.PiOver2; + targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); + int npcWidth = NPC.width; + npcWidth = (int)(npcWidth * NPC.scale); + targetDistance = (targetDistance - npcWidth) / targetDistance; + targetX *= targetDistance; + targetY *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X += num39; - NPC.position.Y += num40; + NPC.position.X += targetX; + NPC.position.Y += targetY; } } @@ -146,17 +146,17 @@ namespace CalamityMod.NPCs.Perforator spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/Perforator/PerforatorTailMediumGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + Color glowmaskColor = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/Perforator/PerforatorTailSmall.cs b/NPCs/Perforator/PerforatorTailSmall.cs index 79e5c04b0f..f64eadc007 100644 --- a/NPCs/Perforator/PerforatorTailSmall.cs +++ b/NPCs/Perforator/PerforatorTailSmall.cs @@ -102,40 +102,40 @@ namespace CalamityMod.NPCs.Perforator if (Main.player[NPC.target].dead) NPC.TargetClosest(false); - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetX = (float)((int)(targetX / 16f) * 16); + targetY = (float)((int)(targetY / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetX -= segmentPosition.X; + targetY -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetX * targetX + targetY * targetY)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetX = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetY = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetY, (double)targetX) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetX * targetX + targetY * targetY)); + int npcWidth = NPC.width; + targetDistance = (targetDistance - (float)npcWidth) / targetDistance; + targetX *= targetDistance; + targetY *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetX; + NPC.position.Y = NPC.position.Y + targetY; - if (num191 < 0f) + if (targetX < 0f) NPC.spriteDirection = 1; - else if (num191 > 0f) + else if (targetX > 0f) NPC.spriteDirection = -1; } } @@ -147,17 +147,17 @@ namespace CalamityMod.NPCs.Perforator spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/Perforator/PerforatorTailSmallGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + Color glowmaskColor = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/PlagueEnemies/Melter.cs b/NPCs/PlagueEnemies/Melter.cs index 4da823b064..29f7a5f612 100644 --- a/NPCs/PlagueEnemies/Melter.cs +++ b/NPCs/PlagueEnemies/Melter.cs @@ -17,7 +17,7 @@ namespace CalamityMod.NPCs.PlagueEnemies public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 4; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0); value.PortraitPositionYOverride = -32f; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; } diff --git a/NPCs/PlagueEnemies/PestilentSlime.cs b/NPCs/PlagueEnemies/PestilentSlime.cs index e0a4d7d3e7..14511f8d49 100644 --- a/NPCs/PlagueEnemies/PestilentSlime.cs +++ b/NPCs/PlagueEnemies/PestilentSlime.cs @@ -23,7 +23,6 @@ namespace CalamityMod.NPCs.PlagueEnemies public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 2; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); } public override void SetDefaults() @@ -66,11 +65,11 @@ namespace CalamityMod.NPCs.PlagueEnemies } if (!NPC.wet && !Main.player[NPC.target].npcTypeNoAggro[NPC.type]) { - Vector2 vector3 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num14 = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - vector3.X; - float num15 = Main.player[NPC.target].position.Y - vector3.Y; - float num16 = (float)Math.Sqrt((double)(num14 * num14 + num15 * num15)); - if (Main.expertMode && num16 < 120f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && NPC.velocity.Y == 0f) + Vector2 slimePosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - slimePosition.X; + float targetYDist = Main.player[NPC.target].position.Y - slimePosition.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + if (Main.expertMode && targetDistance < 120f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && NPC.velocity.Y == 0f) { NPC.ai[0] = -40f; if (NPC.velocity.Y == 0f) @@ -82,17 +81,17 @@ namespace CalamityMod.NPCs.PlagueEnemies SoundEngine.PlaySound(SoundID.Item42, NPC.Center); for (int n = 0; n < 5; n++) { - Vector2 vector4 = new Vector2((float)(n - 2), -4f); - vector4.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; - vector4.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; - vector4.Normalize(); - vector4 *= 4f + (float)Main.rand.Next(-50, 51) * 0.01f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector3.X, vector3.Y, vector4.X, vector4.Y, ModContent.ProjectileType(), 25, 0f, Main.myPlayer, 0f, 0f); + Vector2 spikeVelocity = new Vector2((float)(n - 2), -4f); + spikeVelocity.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; + spikeVelocity.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; + spikeVelocity.Normalize(); + spikeVelocity *= 4f + (float)Main.rand.Next(-50, 51) * 0.01f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), slimePosition.X, slimePosition.Y, spikeVelocity.X, spikeVelocity.Y, ModContent.ProjectileType(), 25, 0f, Main.myPlayer, 0f, 0f); spikeTimer = 30f; } } } - else if (num16 < 360f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && NPC.velocity.Y == 0f) + else if (targetDistance < 360f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && NPC.velocity.Y == 0f) { NPC.ai[0] = -40f; if (NPC.velocity.Y == 0f) @@ -102,13 +101,13 @@ namespace CalamityMod.NPCs.PlagueEnemies if (Main.netMode != NetmodeID.MultiplayerClient && spikeTimer == 0f) { SoundEngine.PlaySound(SoundID.Item42, NPC.Center); - num15 = Main.player[NPC.target].position.Y - vector3.Y - (float)Main.rand.Next(0, 200); - num16 = (float)Math.Sqrt((double)(num14 * num14 + num15 * num15)); - num16 = 6.5f / num16; - num14 *= num16; - num15 *= num16; + targetYDist = Main.player[NPC.target].position.Y - slimePosition.Y - (float)Main.rand.Next(0, 200); + targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + targetDistance = 6.5f / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; spikeTimer = 50f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector3.X, vector3.Y, num14, num15, ModContent.ProjectileType(), 22, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), slimePosition.X, slimePosition.Y, targetXDist, targetYDist, ModContent.ProjectileType(), 22, 0f, Main.myPlayer, 0f, 0f); } } } diff --git a/NPCs/PlagueEnemies/PlagueCharger.cs b/NPCs/PlagueEnemies/PlagueCharger.cs index 4645cf123f..53b533f68b 100644 --- a/NPCs/PlagueEnemies/PlagueCharger.cs +++ b/NPCs/PlagueEnemies/PlagueCharger.cs @@ -22,7 +22,6 @@ namespace CalamityMod.NPCs.PlagueEnemies { Main.npcFrameCount[NPC.type] = 4; NPCID.Sets.TrailingMode[NPC.type] = 1; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); } public override void SetDefaults() @@ -64,49 +63,47 @@ namespace CalamityMod.NPCs.PlagueEnemies spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + int afterimageAmt = 5; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/PlagueEnemies/PlagueChargerGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + Color redEyeColor = Color.Lerp(Color.White, Color.Red, 0.5f); if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color redEyeAfterimageColor = redEyeColor; + redEyeAfterimageColor = Color.Lerp(redEyeAfterimageColor, Color.White, 0.5f); + redEyeAfterimageColor *= (float)(afterimageAmt - j) / 15f; + Vector2 redEyeAfterimagePos = NPC.oldPos[j] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + redEyeAfterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + redEyeAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, redEyeAfterimagePos, NPC.frame, redEyeAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, redEyeColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/PlagueEnemies/PlagueChargerLarge.cs b/NPCs/PlagueEnemies/PlagueChargerLarge.cs index 7fd2290839..e8342aa68f 100644 --- a/NPCs/PlagueEnemies/PlagueChargerLarge.cs +++ b/NPCs/PlagueEnemies/PlagueChargerLarge.cs @@ -24,7 +24,6 @@ namespace CalamityMod.NPCs.PlagueEnemies { Main.npcFrameCount[NPC.type] = 4; NPCID.Sets.TrailingMode[NPC.type] = 1; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); } public override void SetDefaults() @@ -66,49 +65,47 @@ namespace CalamityMod.NPCs.PlagueEnemies spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + int afterimageAmt = 5; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/PlagueEnemies/PlagueChargerGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + Color redEyeColor = Color.Lerp(Color.White, Color.Red, 0.5f); if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color redEyeAfterimageColor = redEyeColor; + redEyeAfterimageColor = Color.Lerp(redEyeAfterimageColor, Color.White, 0.5f); + redEyeAfterimageColor *= (float)(afterimageAmt - j) / 15f; + Vector2 redEyeAfterimagePos = NPC.oldPos[j] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + redEyeAfterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + redEyeAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, redEyeAfterimagePos, NPC.frame, redEyeAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, redEyeColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/PlagueEnemies/PlaguebringerMiniboss.cs b/NPCs/PlagueEnemies/PlaguebringerMiniboss.cs index f5ce09324d..78e7b7d9d7 100644 --- a/NPCs/PlagueEnemies/PlaguebringerMiniboss.cs +++ b/NPCs/PlagueEnemies/PlaguebringerMiniboss.cs @@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.PlagueEnemies { Main.npcFrameCount[NPC.type] = 12; NPCID.Sets.TrailingMode[NPC.type] = 1; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.7f, PortraitScale = 0.8f, @@ -76,10 +76,10 @@ namespace CalamityMod.NPCs.PlagueEnemies public override void AI() { Lighting.AddLight((int)((NPC.position.X + (float)(NPC.width / 2)) / 16f), (int)((NPC.position.Y + (float)(NPC.height / 2)) / 16f), 0.1f, 0.3f, 0f); - bool flag113 = false; + bool outsideJungle = false; if (!Main.player[NPC.target].ZoneJungle) { - flag113 = true; + outsideJungle = true; if (NPC.timeLeft > 150) { NPC.timeLeft = 150; @@ -92,12 +92,12 @@ namespace CalamityMod.NPCs.PlagueEnemies NPC.timeLeft = 750; } } - int num1038 = 0; - for (int num1039 = 0; num1039 < 255; num1039++) + int playerAmt = 0; + for (int i = 0; i < 255; i++) { - if (Main.player[num1039].active && !Main.player[num1039].dead && (NPC.Center - Main.player[num1039].Center).Length() < 1000f) + if (Main.player[i].active && !Main.player[i].dead && (NPC.Center - Main.player[i].Center).Length() < 1000f) { - num1038++; + playerAmt++; } } if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) @@ -129,22 +129,22 @@ namespace CalamityMod.NPCs.PlagueEnemies { if (Main.netMode != NetmodeID.MultiplayerClient) { - float num1041 = NPC.ai[1]; - int num1042; + float currentAttack = NPC.ai[1]; + int nextAttack; do { - num1042 = Main.rand.Next(3); - if (num1042 == 1) + nextAttack = Main.rand.Next(3); + if (nextAttack == 1) { - num1042 = 2; + nextAttack = 2; } - else if (num1042 == 2) + else if (nextAttack == 2) { - num1042 = 3; + nextAttack = 3; } } - while ((float)num1042 == num1041); - NPC.ai[0] = (float)num1042; + while ((float)nextAttack == currentAttack); + NPC.ai[0] = (float)nextAttack; NPC.ai[1] = 0f; NPC.ai[2] = 0f; return; @@ -152,12 +152,12 @@ namespace CalamityMod.NPCs.PlagueEnemies } else if (NPC.ai[0] == 0f) { - int num1043 = 2; //2 - if (flag113) + int chargeDelay = 2; //2 + if (outsideJungle) { - num1043 += 1; + chargeDelay += 1; } - if (NPC.ai[1] > (float)(2 * num1043) && NPC.ai[1] % 2f == 0f) + if (NPC.ai[1] > (float)(2 * chargeDelay) && NPC.ai[1] % 2f == 0f) { NPC.ai[0] = -1f; NPC.ai[1] = 0f; @@ -173,45 +173,45 @@ namespace CalamityMod.NPCs.PlagueEnemies NPC.localAI[0] = 1f; NPC.ai[1] += 1f; NPC.ai[2] = 0f; - float num1044 = 15f; - if (flag113) + float chargeSpeed = 15f; + if (outsideJungle) { - num1044 += 2f; + chargeSpeed += 2f; } - Vector2 vector117 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num1045 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - vector117.X; - float num1046 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - vector117.Y; - float num1047 = (float)Math.Sqrt((double)(num1045 * num1045 + num1046 * num1046)); - num1047 = num1044 / num1047; - NPC.velocity.X = num1045 * num1047; - NPC.velocity.Y = num1046 * num1047; + Vector2 chargeBeePos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float chargeTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - chargeBeePos.X; + float chargeTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - chargeBeePos.Y; + float chargeTargetDist = (float)Math.Sqrt((double)(chargeTargetX * chargeTargetX + chargeTargetY * chargeTargetY)); + chargeTargetDist = chargeSpeed / chargeTargetDist; + NPC.velocity.X = chargeTargetX * chargeTargetDist; + NPC.velocity.Y = chargeTargetY * chargeTargetDist; NPC.spriteDirection = NPC.direction; SoundEngine.PlaySound(SoundID.Roar, NPC.Center); return; } NPC.localAI[0] = 0f; - float num1048 = 12.25f; - float num1049 = 0.155f; - if (flag113) + float lineUpSpeed = 12.25f; + float lineUpAcceleration = 0.155f; + if (outsideJungle) { - num1048 += 1f; - num1049 += 0.075f; + lineUpSpeed += 1f; + lineUpAcceleration += 0.075f; } if (NPC.position.Y + (float)(NPC.height / 2) < Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2)) { - NPC.velocity.Y = NPC.velocity.Y + num1049; + NPC.velocity.Y = NPC.velocity.Y + lineUpAcceleration; } else { - NPC.velocity.Y = NPC.velocity.Y - num1049; + NPC.velocity.Y = NPC.velocity.Y - lineUpAcceleration; } if (NPC.velocity.Y < -12f) { - NPC.velocity.Y = -num1048; + NPC.velocity.Y = -lineUpSpeed; } if (NPC.velocity.Y > 12f) { - NPC.velocity.Y = num1048; + NPC.velocity.Y = lineUpSpeed; } if (Math.Abs(NPC.position.X + (float)(NPC.width / 2) - (Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2))) > 600f) { @@ -246,13 +246,12 @@ namespace CalamityMod.NPCs.PlagueEnemies NPC.direction = 1; } NPC.spriteDirection = NPC.direction; - int num1050 = 500; - int num1051 = 1; + int chargeDirection = 1; if (NPC.position.X + (float)(NPC.width / 2) < Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2)) { - num1051 = -1; + chargeDirection = -1; } - if (NPC.direction == num1051 && Math.Abs(NPC.position.X + (float)(NPC.width / 2) - (Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2))) > (float)num1050) + if (NPC.direction == chargeDirection && Math.Abs(NPC.position.X + (float)(NPC.width / 2) - (Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2))) > 500f) { NPC.ai[2] = 1f; } @@ -265,13 +264,13 @@ namespace CalamityMod.NPCs.PlagueEnemies NPC.spriteDirection = NPC.direction; NPC.localAI[0] = 0f; NPC.velocity *= 0.9f; - float num1052 = 0.105f; - if (flag113) + float chargeDeceleration = 0.105f; + if (outsideJungle) { NPC.velocity *= 0.9f; - num1052 += 0.075f; + chargeDeceleration += 0.075f; } - if (Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) < num1052) + if (Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) < chargeDeceleration) { NPC.ai[2] = 0f; NPC.ai[1] += 1f; @@ -282,54 +281,54 @@ namespace CalamityMod.NPCs.PlagueEnemies { NPC.TargetClosest(true); NPC.spriteDirection = NPC.direction; - float num1053 = 12f; - float num1054 = 0.1f; - if (flag113) + float hoverForBeesSpeed = 12f; + float hoverForBeesAccel = 0.1f; + if (outsideJungle) { - num1054 = 0.12f; + hoverForBeesAccel = 0.12f; } - Vector2 vector118 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num1055 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - vector118.X; - float num1056 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - 200f - vector118.Y; - float num1057 = (float)Math.Sqrt((double)(num1055 * num1055 + num1056 * num1056)); - if (num1057 < 400f) + Vector2 hoverForBeesPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float hoverForBeesTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - hoverForBeesPosition.X; + float hoverForBeesTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - 200f - hoverForBeesPosition.Y; + float hoverForBeesTargetDist = (float)Math.Sqrt((double)(hoverForBeesTargetX * hoverForBeesTargetX + hoverForBeesTargetY * hoverForBeesTargetY)); + if (hoverForBeesTargetDist < 400f) { NPC.ai[0] = 1f; NPC.ai[1] = 0f; NPC.netUpdate = true; return; } - num1057 = num1053 / num1057; - if (NPC.velocity.X < num1055) + hoverForBeesTargetDist = hoverForBeesSpeed / hoverForBeesTargetDist; + if (NPC.velocity.X < hoverForBeesTargetX) { - NPC.velocity.X = NPC.velocity.X + num1054; - if (NPC.velocity.X < 0f && num1055 > 0f) + NPC.velocity.X = NPC.velocity.X + hoverForBeesAccel; + if (NPC.velocity.X < 0f && hoverForBeesTargetX > 0f) { - NPC.velocity.X = NPC.velocity.X + num1054; + NPC.velocity.X = NPC.velocity.X + hoverForBeesAccel; } } - else if (NPC.velocity.X > num1055) + else if (NPC.velocity.X > hoverForBeesTargetX) { - NPC.velocity.X = NPC.velocity.X - num1054; - if (NPC.velocity.X > 0f && num1055 < 0f) + NPC.velocity.X = NPC.velocity.X - hoverForBeesAccel; + if (NPC.velocity.X > 0f && hoverForBeesTargetX < 0f) { - NPC.velocity.X = NPC.velocity.X - num1054; + NPC.velocity.X = NPC.velocity.X - hoverForBeesAccel; } } - if (NPC.velocity.Y < num1056) + if (NPC.velocity.Y < hoverForBeesTargetY) { - NPC.velocity.Y = NPC.velocity.Y + num1054; - if (NPC.velocity.Y < 0f && num1056 > 0f) + NPC.velocity.Y = NPC.velocity.Y + hoverForBeesAccel; + if (NPC.velocity.Y < 0f && hoverForBeesTargetY > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num1054; + NPC.velocity.Y = NPC.velocity.Y + hoverForBeesAccel; } } - else if (NPC.velocity.Y > num1056) + else if (NPC.velocity.Y > hoverForBeesTargetY) { - NPC.velocity.Y = NPC.velocity.Y - num1054; - if (NPC.velocity.Y > 0f && num1056 < 0f) + NPC.velocity.Y = NPC.velocity.Y - hoverForBeesAccel; + if (NPC.velocity.Y > 0f && hoverForBeesTargetY < 0f) { - NPC.velocity.Y = NPC.velocity.Y - num1054; + NPC.velocity.Y = NPC.velocity.Y - hoverForBeesAccel; } } } @@ -337,83 +336,83 @@ namespace CalamityMod.NPCs.PlagueEnemies { NPC.localAI[0] = 0f; NPC.TargetClosest(true); - Vector2 vector119 = new Vector2(NPC.position.X + (float)(NPC.width / 2) + (float)(40 * NPC.direction), NPC.position.Y + (float)NPC.height * 0.8f); - Vector2 vector120 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num1058 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - vector120.X; - float num1059 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - vector120.Y; - float num1060 = (float)Math.Sqrt((double)(num1058 * num1058 + num1059 * num1059)); + Vector2 beeSpawnPosition = new Vector2(NPC.position.X + (float)(NPC.width / 2) + (float)(40 * NPC.direction), NPC.position.Y + (float)NPC.height * 0.8f); + Vector2 plaguebringerBeeSpawnPos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float beeSpawnTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - plaguebringerBeeSpawnPos.X; + float beeSpawnTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - plaguebringerBeeSpawnPos.Y; + float beeSpawnTargetDist = (float)Math.Sqrt((double)(beeSpawnTargetX * beeSpawnTargetX + beeSpawnTargetY * beeSpawnTargetY)); NPC.ai[1] += 1f; - NPC.ai[1] += (float)(num1038 / 2); - bool flag103 = false; + NPC.ai[1] += (float)(playerAmt / 2); + bool canSpawnBee = false; if (NPC.ai[1] > 10f) { NPC.ai[1] = 0f; NPC.ai[2] += 1f; - flag103 = true; + canSpawnBee = true; } - if (Collision.CanHit(vector119, 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && flag103) + if (Collision.CanHit(beeSpawnPosition, 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && canSpawnBee) { SoundEngine.PlaySound(SoundID.NPCHit8, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - int num1061; + int beeType; if (Main.rand.NextBool(4)) { - num1061 = ModContent.NPCType(); + beeType = ModContent.NPCType(); } else { - num1061 = ModContent.NPCType(); + beeType = ModContent.NPCType(); } if (NPC.CountNPCS(ModContent.NPCType()) < 3) { - int num1062 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)vector119.X, (int)vector119.Y, num1061, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[num1062].velocity.X = (float)Main.rand.Next(-200, 201) * 0.005f; - Main.npc[num1062].velocity.Y = (float)Main.rand.Next(-200, 201) * 0.005f; - Main.npc[num1062].localAI[0] = 60f; - Main.npc[num1062].netUpdate = true; + int notTheBees = NPC.NewNPC(NPC.GetSource_FromAI(), (int)beeSpawnPosition.X, (int)beeSpawnPosition.Y, beeType, 0, 0f, 0f, 0f, 0f, 255); + Main.npc[notTheBees].velocity.X = (float)Main.rand.Next(-200, 201) * 0.005f; + Main.npc[notTheBees].velocity.Y = (float)Main.rand.Next(-200, 201) * 0.005f; + Main.npc[notTheBees].localAI[0] = 60f; + Main.npc[notTheBees].netUpdate = true; } } } - if (num1060 > 400f || !Collision.CanHit(new Vector2(vector119.X, vector119.Y - 30f), 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + if (beeSpawnTargetDist > 400f || !Collision.CanHit(new Vector2(beeSpawnPosition.X, beeSpawnPosition.Y - 30f), 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { - float num1063 = 14.5f; - float num1064 = 0.105f; - vector120 = vector119; - num1058 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - vector120.X; - num1059 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - vector120.Y; - num1060 = (float)Math.Sqrt((double)(num1058 * num1058 + num1059 * num1059)); - num1060 = num1063 / num1060; - if (NPC.velocity.X < num1058) + float beeSpawnSpeed = 14.5f; + float beeSpawnAcceleration = 0.105f; + plaguebringerBeeSpawnPos = beeSpawnPosition; + beeSpawnTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - plaguebringerBeeSpawnPos.X; + beeSpawnTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - plaguebringerBeeSpawnPos.Y; + beeSpawnTargetDist = (float)Math.Sqrt((double)(beeSpawnTargetX * beeSpawnTargetX + beeSpawnTargetY * beeSpawnTargetY)); + beeSpawnTargetDist = beeSpawnSpeed / beeSpawnTargetDist; + if (NPC.velocity.X < beeSpawnTargetX) { - NPC.velocity.X = NPC.velocity.X + num1064; - if (NPC.velocity.X < 0f && num1058 > 0f) + NPC.velocity.X = NPC.velocity.X + beeSpawnAcceleration; + if (NPC.velocity.X < 0f && beeSpawnTargetX > 0f) { - NPC.velocity.X = NPC.velocity.X + num1064; + NPC.velocity.X = NPC.velocity.X + beeSpawnAcceleration; } } - else if (NPC.velocity.X > num1058) + else if (NPC.velocity.X > beeSpawnTargetX) { - NPC.velocity.X = NPC.velocity.X - num1064; - if (NPC.velocity.X > 0f && num1058 < 0f) + NPC.velocity.X = NPC.velocity.X - beeSpawnAcceleration; + if (NPC.velocity.X > 0f && beeSpawnTargetX < 0f) { - NPC.velocity.X = NPC.velocity.X - num1064; + NPC.velocity.X = NPC.velocity.X - beeSpawnAcceleration; } } - if (NPC.velocity.Y < num1059) + if (NPC.velocity.Y < beeSpawnTargetY) { - NPC.velocity.Y = NPC.velocity.Y + num1064; - if (NPC.velocity.Y < 0f && num1059 > 0f) + NPC.velocity.Y = NPC.velocity.Y + beeSpawnAcceleration; + if (NPC.velocity.Y < 0f && beeSpawnTargetY > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num1064; + NPC.velocity.Y = NPC.velocity.Y + beeSpawnAcceleration; } } - else if (NPC.velocity.Y > num1059) + else if (NPC.velocity.Y > beeSpawnTargetY) { - NPC.velocity.Y = NPC.velocity.Y - num1064; - if (NPC.velocity.Y > 0f && num1059 < 0f) + NPC.velocity.Y = NPC.velocity.Y - beeSpawnAcceleration; + if (NPC.velocity.Y > 0f && beeSpawnTargetY < 0f) { - NPC.velocity.Y = NPC.velocity.Y - num1064; + NPC.velocity.Y = NPC.velocity.Y - beeSpawnAcceleration; } } } @@ -431,123 +430,123 @@ namespace CalamityMod.NPCs.PlagueEnemies } else if (NPC.ai[0] == 3f) { - float num1065 = 7f; - float num1066 = 0.075f; - if (flag113) + float stingerAttackSpeed = 7f; + float stingerAttackAccel = 0.075f; + if (outsideJungle) { - num1066 = 0.09f; - num1065 = 8f; + stingerAttackAccel = 0.09f; + stingerAttackSpeed = 8f; } - Vector2 vector121 = new Vector2(NPC.position.X + (float)(NPC.width / 2) + (float)(40 * NPC.direction), NPC.position.Y + (float)NPC.height * 0.8f); - Vector2 vector122 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num1067 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - vector122.X; - float num1068 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - 300f - vector122.Y; - float num1069 = (float)Math.Sqrt((double)(num1067 * num1067 + num1068 * num1068)); + Vector2 stingerSpawnPos = new Vector2(NPC.position.X + (float)(NPC.width / 2) + (float)(40 * NPC.direction), NPC.position.Y + (float)NPC.height * 0.8f); + Vector2 stingerAttackPos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float stingerAttackTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - stingerAttackPos.X; + float stingerAttackTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - 300f - stingerAttackPos.Y; + float stingerAttackTargetDist = (float)Math.Sqrt((double)(stingerAttackTargetX * stingerAttackTargetX + stingerAttackTargetY * stingerAttackTargetY)); NPC.ai[1] += 1f; - bool flag104 = false; + bool canFireStinger = false; if (NPC.ai[1] % 35f == 34f) { - flag104 = true; + canFireStinger = true; } - if (flag104 && NPC.position.Y + (float)NPC.height < Main.player[NPC.target].position.Y && Collision.CanHit(vector121, 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + if (canFireStinger && NPC.position.Y + (float)NPC.height < Main.player[NPC.target].position.Y && Collision.CanHit(stingerSpawnPos, 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { SoundEngine.PlaySound(SoundID.Item42, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - float num1070 = 6f; - if (flag113) + float stingerSpeed = 6f; + if (outsideJungle) { - num1070 += 2f; + stingerSpeed += 2f; } - float num1071 = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - vector121.X; - float num1072 = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - vector121.Y; - float num1073 = (float)Math.Sqrt((double)(num1071 * num1071 + num1072 * num1072)); - num1073 = num1070 / num1073; - num1071 *= num1073; - num1072 *= num1073; + float stingerTargetX = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - stingerSpawnPos.X; + float stingerTargetY = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - stingerSpawnPos.Y; + float stingerTargetDist = (float)Math.Sqrt((double)(stingerTargetX * stingerTargetX + stingerTargetY * stingerTargetY)); + stingerTargetDist = stingerSpeed / stingerTargetDist; + stingerTargetX *= stingerTargetDist; + stingerTargetY *= stingerTargetDist; bool fireRocket = Main.rand.NextBool(15); int type = fireRocket ? ModContent.ProjectileType() : ModContent.ProjectileType(); int damage = fireRocket ? 72 : 52; if (Main.expertMode) damage = fireRocket ? 50 : 35; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector121.X, vector121.Y, num1071, num1072, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), stingerSpawnPos.X, stingerSpawnPos.Y, stingerTargetX, stingerTargetY, type, damage, 0f, Main.myPlayer, 0f, 0f); } } - if (!Collision.CanHit(new Vector2(vector121.X, vector121.Y - 30f), 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + if (!Collision.CanHit(new Vector2(stingerSpawnPos.X, stingerSpawnPos.Y - 30f), 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { - num1066 = 0.105f; - vector122 = vector121; - num1067 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - vector122.X; - num1068 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - vector122.Y; - if (NPC.velocity.X < num1067) + stingerAttackAccel = 0.105f; + stingerAttackPos = stingerSpawnPos; + stingerAttackTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - stingerAttackPos.X; + stingerAttackTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - stingerAttackPos.Y; + if (NPC.velocity.X < stingerAttackTargetX) { - NPC.velocity.X = NPC.velocity.X + num1066; - if (NPC.velocity.X < 0f && num1067 > 0f) + NPC.velocity.X = NPC.velocity.X + stingerAttackAccel; + if (NPC.velocity.X < 0f && stingerAttackTargetX > 0f) { - NPC.velocity.X = NPC.velocity.X + num1066; + NPC.velocity.X = NPC.velocity.X + stingerAttackAccel; } } - else if (NPC.velocity.X > num1067) + else if (NPC.velocity.X > stingerAttackTargetX) { - NPC.velocity.X = NPC.velocity.X - num1066; - if (NPC.velocity.X > 0f && num1067 < 0f) + NPC.velocity.X = NPC.velocity.X - stingerAttackAccel; + if (NPC.velocity.X > 0f && stingerAttackTargetX < 0f) { - NPC.velocity.X = NPC.velocity.X - num1066; + NPC.velocity.X = NPC.velocity.X - stingerAttackAccel; } } - if (NPC.velocity.Y < num1068) + if (NPC.velocity.Y < stingerAttackTargetY) { - NPC.velocity.Y = NPC.velocity.Y + num1066; - if (NPC.velocity.Y < 0f && num1068 > 0f) + NPC.velocity.Y = NPC.velocity.Y + stingerAttackAccel; + if (NPC.velocity.Y < 0f && stingerAttackTargetY > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num1066; + NPC.velocity.Y = NPC.velocity.Y + stingerAttackAccel; } } - else if (NPC.velocity.Y > num1068) + else if (NPC.velocity.Y > stingerAttackTargetY) { - NPC.velocity.Y = NPC.velocity.Y - num1066; - if (NPC.velocity.Y > 0f && num1068 < 0f) + NPC.velocity.Y = NPC.velocity.Y - stingerAttackAccel; + if (NPC.velocity.Y > 0f && stingerAttackTargetY < 0f) { - NPC.velocity.Y = NPC.velocity.Y - num1066; + NPC.velocity.Y = NPC.velocity.Y - stingerAttackAccel; } } } - else if (num1069 > 100f) + else if (stingerAttackTargetDist > 100f) { NPC.TargetClosest(true); NPC.spriteDirection = NPC.direction; - num1069 = num1065 / num1069; - if (NPC.velocity.X < num1067) + stingerAttackTargetDist = stingerAttackSpeed / stingerAttackTargetDist; + if (NPC.velocity.X < stingerAttackTargetX) { - NPC.velocity.X = NPC.velocity.X + num1066; - if (NPC.velocity.X < 0f && num1067 > 0f) + NPC.velocity.X = NPC.velocity.X + stingerAttackAccel; + if (NPC.velocity.X < 0f && stingerAttackTargetX > 0f) { - NPC.velocity.X = NPC.velocity.X + num1066 * 2f; + NPC.velocity.X = NPC.velocity.X + stingerAttackAccel * 2f; } } - else if (NPC.velocity.X > num1067) + else if (NPC.velocity.X > stingerAttackTargetX) { - NPC.velocity.X = NPC.velocity.X - num1066; - if (NPC.velocity.X > 0f && num1067 < 0f) + NPC.velocity.X = NPC.velocity.X - stingerAttackAccel; + if (NPC.velocity.X > 0f && stingerAttackTargetX < 0f) { - NPC.velocity.X = NPC.velocity.X - num1066 * 2f; + NPC.velocity.X = NPC.velocity.X - stingerAttackAccel * 2f; } } - if (NPC.velocity.Y < num1068) + if (NPC.velocity.Y < stingerAttackTargetY) { - NPC.velocity.Y = NPC.velocity.Y + num1066; - if (NPC.velocity.Y < 0f && num1068 > 0f) + NPC.velocity.Y = NPC.velocity.Y + stingerAttackAccel; + if (NPC.velocity.Y < 0f && stingerAttackTargetY > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num1066 * 2f; + NPC.velocity.Y = NPC.velocity.Y + stingerAttackAccel * 2f; } } - else if (NPC.velocity.Y > num1068) + else if (NPC.velocity.Y > stingerAttackTargetY) { - NPC.velocity.Y = NPC.velocity.Y - num1066; - if (NPC.velocity.Y > 0f && num1068 < 0f) + NPC.velocity.Y = NPC.velocity.Y - stingerAttackAccel; + if (NPC.velocity.Y > 0f && stingerAttackTargetY < 0f) { - NPC.velocity.Y = NPC.velocity.Y - num1066 * 2f; + NPC.velocity.Y = NPC.velocity.Y - stingerAttackAccel * 2f; } } } @@ -572,32 +571,30 @@ namespace CalamityMod.NPCs.PlagueEnemies spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 7; + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + int afterimageAmt = 7; if (NPC.ai[0] != 0f) - num153 = 5; + afterimageAmt = 5; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -628,23 +625,23 @@ namespace CalamityMod.NPCs.PlagueEnemies NPC.height = 100; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Plague, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int plagueDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Plague, 0f, 0f, 100, default, 2f); + Main.dust[plagueDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[plagueDust].scale = 0.5f; + Main.dust[plagueDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Plague, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Plague, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int plagueDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Plague, 0f, 0f, 100, default, 3f); + Main.dust[plagueDust2].noGravity = true; + Main.dust[plagueDust2].velocity *= 5f; + plagueDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Plague, 0f, 0f, 100, default, 2f); + Main.dust[plagueDust2].velocity *= 2f; } } } diff --git a/NPCs/PlagueEnemies/Plagueshell.cs b/NPCs/PlagueEnemies/Plagueshell.cs index 0679a55213..7ae1392e4e 100644 --- a/NPCs/PlagueEnemies/Plagueshell.cs +++ b/NPCs/PlagueEnemies/Plagueshell.cs @@ -17,7 +17,6 @@ namespace CalamityMod.NPCs.PlagueEnemies public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 8; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); } public override void SetDefaults() diff --git a/NPCs/PlagueEnemies/Viruling.cs b/NPCs/PlagueEnemies/Viruling.cs index 92a8e7fd8d..a78dd17c7f 100644 --- a/NPCs/PlagueEnemies/Viruling.cs +++ b/NPCs/PlagueEnemies/Viruling.cs @@ -20,7 +20,6 @@ namespace CalamityMod.NPCs.PlagueEnemies public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 5; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); } public override void SetDefaults() @@ -67,75 +66,75 @@ namespace CalamityMod.NPCs.PlagueEnemies { NPC.TargetClosest(true); } - float num = 6f; - float num2 = 0.05f; + float maxSpeed = 6f; + float acceleration = 0.05f; if (CalamityWorld.revenge) { - num *= 1.25f; - num2 *= 1.25f; + maxSpeed *= 1.25f; + acceleration *= 1.25f; } if (CalamityWorld.death) { - num *= 1.25f; - num2 *= 1.25f; + maxSpeed *= 1.25f; + acceleration *= 1.25f; } Vector2 vector = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num4 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num5 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num4 = (float)((int)(num4 / 8f) * 8); - num5 = (float)((int)(num5 / 8f) * 8); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDist = (float)((int)(targetXDist / 8f) * 8); + targetYDist = (float)((int)(targetYDist / 8f) * 8); vector.X = (float)((int)(vector.X / 8f) * 8); vector.Y = (float)((int)(vector.Y / 8f) * 8); - num4 -= vector.X; - num5 -= vector.Y; - float num6 = (float)Math.Sqrt((double)(num4 * num4 + num5 * num5)); - if (num6 == 0f) + targetXDist -= vector.X; + targetYDist -= vector.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + if (targetDistance == 0f) { - num4 = NPC.velocity.X; - num5 = NPC.velocity.Y; + targetXDist = NPC.velocity.X; + targetYDist = NPC.velocity.Y; } else { - num6 = num / num6; - num4 *= num6; - num5 *= num6; + targetDistance = maxSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; } if (Main.player[NPC.target].dead) { - num4 = (float)NPC.direction * num / 2f; - num5 = -num / 2f; + targetXDist = (float)NPC.direction * maxSpeed / 2f; + targetYDist = -maxSpeed / 2f; } - if (NPC.velocity.X < num4) + if (NPC.velocity.X < targetXDist) { - NPC.velocity.X = NPC.velocity.X + num2; + NPC.velocity.X = NPC.velocity.X + acceleration; } - else if (NPC.velocity.X > num4) + else if (NPC.velocity.X > targetXDist) { - NPC.velocity.X = NPC.velocity.X - num2; + NPC.velocity.X = NPC.velocity.X - acceleration; } - if (NPC.velocity.Y < num5) + if (NPC.velocity.Y < targetYDist) { - NPC.velocity.Y = NPC.velocity.Y + num2; + NPC.velocity.Y = NPC.velocity.Y + acceleration; } - else if (NPC.velocity.Y > num5) + else if (NPC.velocity.Y > targetYDist) { - NPC.velocity.Y = NPC.velocity.Y - num2; + NPC.velocity.Y = NPC.velocity.Y - acceleration; } - if (num4 > 0f) + if (targetXDist > 0f) { NPC.spriteDirection = 1; - NPC.rotation = (float)Math.Atan2((double)num5, (double)num4); + NPC.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist); } - else if (num4 < 0f) + else if (targetXDist < 0f) { NPC.spriteDirection = -1; - NPC.rotation = (float)Math.Atan2((double)num5, (double)num4) + 3.14f; + NPC.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist) + 3.14f; } - float num12 = 0.7f; + float recoilSpeed = 0.7f; if (NPC.collideX) { NPC.netUpdate = true; - NPC.velocity.X = NPC.oldVelocity.X * -num12; + NPC.velocity.X = NPC.oldVelocity.X * -recoilSpeed; if (NPC.direction == -1 && NPC.velocity.X > 0f && NPC.velocity.X < 2f) { NPC.velocity.X = 2f; @@ -148,7 +147,7 @@ namespace CalamityMod.NPCs.PlagueEnemies if (NPC.collideY) { NPC.netUpdate = true; - NPC.velocity.Y = NPC.oldVelocity.Y * -num12; + NPC.velocity.Y = NPC.oldVelocity.Y * -recoilSpeed; if (NPC.velocity.Y > 0f && (double)NPC.velocity.Y < 1.5) { NPC.velocity.Y = 2f; @@ -162,8 +161,8 @@ namespace CalamityMod.NPCs.PlagueEnemies { NPC.netUpdate = true; } - int num13 = Dust.NewDust(new Vector2(NPC.position.X - NPC.velocity.X, NPC.position.Y - NPC.velocity.Y), NPC.width, NPC.height, 46, NPC.velocity.X * 0.2f, NPC.velocity.Y * 0.2f, 100, default, 2f); - Dust dust = Main.dust[num13]; + int idleDust = Dust.NewDust(new Vector2(NPC.position.X - NPC.velocity.X, NPC.position.Y - NPC.velocity.Y), NPC.width, NPC.height, 46, NPC.velocity.X * 0.2f, NPC.velocity.Y * 0.2f, 100, default, 2f); + Dust dust = Main.dust[idleDust]; dust.noGravity = true; dust.velocity.X *= 0.3f; dust.velocity.Y *= 0.3f; diff --git a/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs b/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs index 7895b13f7c..f60f882457 100644 --- a/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs +++ b/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs @@ -56,32 +56,32 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath if (Math.Abs(NPC.velocity.X) >= 3f || Math.Abs(NPC.velocity.Y) >= 3f) { - float num247 = 0f; - float num248 = 0f; + float dustXOffset = 0f; + float dustYOffset = 0f; if (Main.rand.NextBool()) { - num247 = NPC.velocity.X * 0.5f; - num248 = NPC.velocity.Y * 0.5f; + dustXOffset = NPC.velocity.X * 0.5f; + dustYOffset = NPC.velocity.Y * 0.5f; } - int num249 = Dust.NewDust(new Vector2(NPC.position.X + 3f + num247, NPC.position.Y + 3f + num248) - NPC.velocity * 0.5f, NPC.width - 8, NPC.height - 8, 6, 0f, 0f, 100, default, 0.5f); - Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - num249 = Dust.NewDust(new Vector2(NPC.position.X + 3f + num247, NPC.position.Y + 3f + num248) - NPC.velocity * 0.5f, NPC.width - 8, NPC.height - 8, 31, 0f, 0f, 100, default, 0.25f); - Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num249].velocity *= 0.05f; + int smokyFire = Dust.NewDust(new Vector2(NPC.position.X + 3f + dustXOffset, NPC.position.Y + 3f + dustYOffset) - NPC.velocity * 0.5f, NPC.width - 8, NPC.height - 8, 6, 0f, 0f, 100, default, 0.5f); + Main.dust[smokyFire].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[smokyFire].velocity *= 0.2f; + Main.dust[smokyFire].noGravity = true; + smokyFire = Dust.NewDust(new Vector2(NPC.position.X + 3f + dustXOffset, NPC.position.Y + 3f + dustYOffset) - NPC.velocity * 0.5f, NPC.width - 8, NPC.height - 8, 31, 0f, 0f, 100, default, 0.25f); + Main.dust[smokyFire].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[smokyFire].velocity *= 0.05f; } else if (Main.rand.NextBool(4)) { - int num252 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 31, 0f, 0f, 100, default, 0.5f); - Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = NPC.Center + new Vector2(0f, (float)(-(float)NPC.height / 2)).RotatedBy((double)NPC.rotation, default) * 1.1f; - num252 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 6, 0f, 0f, 100, default, 1f); - Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = NPC.Center + new Vector2(0f, (float)(-(float)NPC.height / 2 - 6)).RotatedBy((double)NPC.rotation, default) * 1.1f; + int smokyFire2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 31, 0f, 0f, 100, default, 0.5f); + Main.dust[smokyFire2].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[smokyFire2].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[smokyFire2].noGravity = true; + Main.dust[smokyFire2].position = NPC.Center + new Vector2(0f, (float)(-(float)NPC.height / 2)).RotatedBy((double)NPC.rotation, default) * 1.1f; + smokyFire2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 6, 0f, 0f, 100, default, 1f); + Main.dust[smokyFire2].scale = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[smokyFire2].noGravity = true; + Main.dust[smokyFire2].position = NPC.Center + new Vector2(0f, (float)(-(float)NPC.height / 2 - 6)).RotatedBy((double)NPC.rotation, default) * 1.1f; } NPC.rotation = NPC.velocity.ToRotation() + MathHelper.PiOver2; @@ -98,8 +98,8 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath NPC.ai[0] = 1f; NPC.ai[1] = (float)Player.FindClosest(NPC.position, NPC.width, NPC.height); NPC.netUpdate = true; - float num754 = NPC.velocity.Length(); - NPC.velocity = Vector2.Normalize(NPC.velocity) * (num754 + 1f); + float npcSpeed = NPC.velocity.Length(); + NPC.velocity = Vector2.Normalize(NPC.velocity) * (npcSpeed + 1f); } else if (NPC.ai[0] == 1f) { @@ -117,9 +117,9 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { NPC.noTileCollide = true; Vector2 v3 = Main.player[(int)NPC.ai[1]].Center - NPC.Center; - float num760 = NPC.velocity.ToRotation(); - float num761 = v3.ToRotation(); - float angle = num761 - num760; + float facingDirection = NPC.velocity.ToRotation(); + float playerDirection = v3.ToRotation(); + float angle = playerDirection - facingDirection; angle = MathHelper.WrapAngle(angle); NPC.velocity = NPC.velocity.RotatedBy(angle * 0.2); } @@ -159,49 +159,47 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + int afterimageAmt = 5; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/PlaguebringerGoliath/PlagueHomingMissileGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + Color redLerpColor = Color.Lerp(Color.White, Color.Red, 0.5f); if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color secondAfterimageColor = redLerpColor; + secondAfterimageColor = Color.Lerp(secondAfterimageColor, Color.White, 0.5f); + secondAfterimageColor *= (float)(afterimageAmt - j) / 15f; + Vector2 secondAfterimagePos = NPC.oldPos[j] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + secondAfterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + secondAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, secondAfterimagePos, NPC.frame, secondAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, redLerpColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -222,25 +220,25 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath NPC.width = NPC.height = Main.zenithWorld ? 300 : 216; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 15; num621++) + for (int i = 0; i < 15; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 89, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int greenPlague = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 89, 0f, 0f, 100, default, 2f); + Main.dust[greenPlague].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[greenPlague].scale = 0.5f; + Main.dust[greenPlague].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } - Main.dust[num622].noGravity = true; + Main.dust[greenPlague].noGravity = true; } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 89, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 89, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - Main.dust[num624].noGravity = true; + int greenPlague2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 89, 0f, 0f, 100, default, 3f); + Main.dust[greenPlague2].noGravity = true; + Main.dust[greenPlague2].velocity *= 5f; + greenPlague2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 89, 0f, 0f, 100, default, 2f); + Main.dust[greenPlague2].velocity *= 2f; + Main.dust[greenPlague2].noGravity = true; } return true; } diff --git a/NPCs/PlaguebringerGoliath/PlagueMine.cs b/NPCs/PlaguebringerGoliath/PlagueMine.cs index 7bf16570f0..4b5d876202 100644 --- a/NPCs/PlaguebringerGoliath/PlagueMine.cs +++ b/NPCs/PlaguebringerGoliath/PlagueMine.cs @@ -86,16 +86,16 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath NPC.TargetClosest(true); float velocity = (bossRush ? 14f : death ? 12f : revenge ? 10f : 8f) + NPC.ai[3] * 0.04f; - Vector2 vector167 = new Vector2(NPC.Center.X + (float)(NPC.direction * 20), NPC.Center.Y + 6f); - float num1373 = player.position.X + (float)player.width * 0.5f - vector167.X; - float num1374 = player.Center.Y - vector167.Y; - float num1375 = (float)Math.Sqrt((double)(num1373 * num1373 + num1374 * num1374)); - float num1376 = velocity / num1375; - num1373 *= num1376; - num1374 *= num1376; + Vector2 npcDirection = new Vector2(NPC.Center.X + (float)(NPC.direction * 20), NPC.Center.Y + 6f); + float targetX = player.position.X + (float)player.width * 0.5f - npcDirection.X; + float targetY = player.Center.Y - npcDirection.Y; + float targetDistance = (float)Math.Sqrt((double)(targetX * targetX + targetY * targetY)); + float npcSpeed = velocity / targetDistance; + targetX *= npcSpeed; + targetY *= npcSpeed; float inertia = (bossRush ? 35f : death ? 40f : revenge ? 45f : 50f) - NPC.ai[3] * 0.25f; - NPC.velocity.X = (NPC.velocity.X * inertia + num1373) / (inertia + 1f); - NPC.velocity.Y = (NPC.velocity.Y * inertia + num1374) / (inertia + 1f); + NPC.velocity.X = (NPC.velocity.X * inertia + targetX) / (inertia + 1f); + NPC.velocity.Y = (NPC.velocity.Y * inertia + targetY) / (inertia + 1f); } public override void FindFrame(int frameHeight) @@ -115,17 +115,17 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/PlaguebringerGoliath/PlagueMineGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + Color redLerpColor = Color.Lerp(Color.White, Color.Red, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, redLerpColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -152,25 +152,25 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath NPC.width = NPC.height = Main.zenithWorld ? 300 : 216; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 15; num621++) + for (int i = 0; i < 15; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 89, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int greenPlague = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 89, 0f, 0f, 100, default, 2f); + Main.dust[greenPlague].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[greenPlague].scale = 0.5f; + Main.dust[greenPlague].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } - Main.dust[num622].noGravity = true; + Main.dust[greenPlague].noGravity = true; } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 89, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 89, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - Main.dust[num624].noGravity = true; + int greenPlague2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 89, 0f, 0f, 100, default, 3f); + Main.dust[greenPlague2].noGravity = true; + Main.dust[greenPlague2].velocity *= 5f; + greenPlague2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 89, 0f, 0f, 100, default, 2f); + Main.dust[greenPlague2].velocity *= 2f; + Main.dust[greenPlague2].noGravity = true; } return true; } diff --git a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs index cce3e746dd..6b7f5bfe78 100644 --- a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs +++ b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs @@ -57,7 +57,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath Main.npcFrameCount[NPC.type] = 6; NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.4f, PortraitScale = 0.5f, @@ -202,11 +202,11 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath Vector2 vectorCenter = NPC.Center; // Count nearby players - int num1038 = 0; - for (int num1039 = 0; num1039 < Main.maxPlayers; num1039++) + int activePlayers = 0; + for (int i = 0; i < Main.maxPlayers; i++) { - if (Main.player[num1039].active && !Main.player[num1039].dead && (vectorCenter - Main.player[num1039].Center).Length() < 1000f) - num1038++; + if (Main.player[i].active && !Main.player[i].dead && (vectorCenter - Main.player[i].Center).Length() < 1000f) + activePlayers++; } // Get a target @@ -305,11 +305,11 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { if (Main.netMode != NetmodeID.MultiplayerClient) { - int num596; - do num596 = MissileCountdown == 1 ? 4 : Main.rand.Next(4); - while (num596 == NPC.ai[1] || num596 == 1); + int attackSwitch; + do attackSwitch = MissileCountdown == 1 ? 4 : Main.rand.Next(4); + while (attackSwitch == NPC.ai[1] || attackSwitch == 1); - if (num596 == 0 && diagonalDash && distFromPlayer.Length() < 1800f) + if (attackSwitch == 0 && diagonalDash && distFromPlayer.Length() < 1800f) { do { @@ -330,7 +330,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath NPC.ai[3] = -chargeDistance; } - NPC.ai[0] = num596; + NPC.ai[0] = attackSwitch; NPC.ai[1] = 0f; NPC.ai[2] = 0f; NPC.TargetClosest(); @@ -348,20 +348,20 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath // Charge phase else if (NPC.ai[0] == 0f) { - float num1044 = revenge ? 28f : 26f; + float chargeSpeed = revenge ? 28f : 26f; if (phase2) - num1044 += 1f; + chargeSpeed += 1f; if (phase3) - num1044 += 1f; + chargeSpeed += 1f; if (phase4) - num1044 += 1f; + chargeSpeed += 1f; if (phase5) - num1044 += 1f; + chargeSpeed += 1f; - num1044 += 2f * enrageScale; + chargeSpeed += 2f * enrageScale; - int num1043 = (int)Math.Ceiling(2f + enrageScale); - if ((NPC.ai[1] > (2 * num1043) && NPC.ai[1] % 2f == 0f) || distFromPlayer.Length() > 1800f) + int phaseSwitchTimer = (int)Math.Ceiling(2f + enrageScale); + if ((NPC.ai[1] > (2 * phaseSwitchTimer) && NPC.ai[1] % 2f == 0f) || distFromPlayer.Length() > 1800f) { NPC.ai[0] = -1f; NPC.ai[1] = 0f; @@ -383,10 +383,10 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { float playerLocation = vectorCenter.X - player.Center.X; - float num620 = 20f; - num620 += 20f * enrageScale; + float chargeThresholdY = 20f; + chargeThresholdY += 20f * enrageScale; - if (Math.Abs(NPC.Center.Y - (player.Center.Y - chargeDistance)) < num620) + if (Math.Abs(NPC.Center.Y - (player.Center.Y - chargeDistance)) < chargeThresholdY) { if (diagonalDash) { @@ -410,13 +410,13 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath NPC.ai[1] += 1f; NPC.ai[2] = 0f; - float num1045 = player.position.X + (player.width / 2) - vectorCenter.X; - float num1046 = player.position.Y + (player.height / 2) - vectorCenter.Y; - float num1047 = (float)Math.Sqrt(num1045 * num1045 + num1046 * num1046); + float targetX = player.position.X + (player.width / 2) - vectorCenter.X; + float targetY = player.position.Y + (player.height / 2) - vectorCenter.Y; + float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); - num1047 = num1044 / num1047; - NPC.velocity.X = num1045 * num1047; - NPC.velocity.Y = num1046 * num1047; + targetDistance = chargeSpeed / targetDistance; + NPC.velocity.X = targetX * targetDistance; + NPC.velocity.Y = targetY * targetDistance; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); calamityGlobalNPC.newAI[1] = NPC.velocity.X; @@ -437,42 +437,42 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath NPC.rotation = NPC.velocity.X * 0.02f; charging = false; - float num1048 = revenge ? 14f : 12f; - float num1049 = revenge ? 0.25f : 0.22f; + float maxLineUpSpeedY = revenge ? 14f : 12f; + float lineUpAccelY = revenge ? 0.25f : 0.22f; if (phase2) { - num1048 += 1f; - num1049 += 0.05f; + maxLineUpSpeedY += 1f; + lineUpAccelY += 0.05f; } if (phase4) { - num1048 += 1f; - num1049 += 0.05f; + maxLineUpSpeedY += 1f; + lineUpAccelY += 0.05f; } - num1048 += 1.5f * enrageScale; - num1049 += 0.25f * enrageScale; + maxLineUpSpeedY += 1.5f * enrageScale; + lineUpAccelY += 0.25f * enrageScale; if (vectorCenter.Y < (player.Center.Y - chargeDistance)) - NPC.velocity.Y += num1049; + NPC.velocity.Y += lineUpAccelY; else - NPC.velocity.Y -= num1049; + NPC.velocity.Y -= lineUpAccelY; - if (NPC.velocity.Y < -num1048) - NPC.velocity.Y = -num1048; - if (NPC.velocity.Y > num1048) - NPC.velocity.Y = num1048; + if (NPC.velocity.Y < -maxLineUpSpeedY) + NPC.velocity.Y = -maxLineUpSpeedY; + if (NPC.velocity.Y > maxLineUpSpeedY) + NPC.velocity.Y = maxLineUpSpeedY; if (Math.Abs(vectorCenter.X - player.Center.X) > 650f) - NPC.velocity.X += num1049 * NPC.direction; + NPC.velocity.X += lineUpAccelY * NPC.direction; else if (Math.Abs(vectorCenter.X - player.Center.X) < 500f) - NPC.velocity.X -= num1049 * NPC.direction; + NPC.velocity.X -= lineUpAccelY * NPC.direction; else NPC.velocity.X *= 0.8f; - if (NPC.velocity.X < -num1048) - NPC.velocity.X = -num1048; - if (NPC.velocity.X > num1048) - NPC.velocity.X = num1048; + if (NPC.velocity.X < -maxLineUpSpeedY) + NPC.velocity.X = -maxLineUpSpeedY; + if (NPC.velocity.X > maxLineUpSpeedY) + NPC.velocity.X = maxLineUpSpeedY; NPC.direction = playerLocation < 0 ? 1 : -1; NPC.spriteDirection = NPC.direction; @@ -491,20 +491,20 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath NPC.spriteDirection = NPC.direction; - int num1050 = revenge ? 525 : 550; + int stopChargeXDist = revenge ? 525 : 550; if (phase4) - num1050 = revenge ? 450 : 475; + stopChargeXDist = revenge ? 450 : 475; else if (phase3) - num1050 = revenge ? 475 : 500; + stopChargeXDist = revenge ? 475 : 500; else if (phase2) - num1050 = revenge ? 500 : 525; - num1050 -= (int)(25f * enrageScale); + stopChargeXDist = revenge ? 500 : 525; + stopChargeXDist -= (int)(25f * enrageScale); - int num1051 = 1; + int chargeDirectionXSign = 1; if (vectorCenter.X < player.Center.X) - num1051 = -1; + chargeDirectionXSign = -1; - if (NPC.direction == num1051 && (Math.Abs(vectorCenter.X - player.Center.X) > num1050 || Math.Abs(vectorCenter.Y - player.Center.Y) > num1050)) + if (NPC.direction == chargeDirectionXSign && (Math.Abs(vectorCenter.X - player.Center.X) > stopChargeXDist || Math.Abs(vectorCenter.Y - player.Center.Y) > stopChargeXDist)) NPC.ai[2] = 1f; if (enrageScale > 0 && NPC.ai[2] == 1f) @@ -516,7 +516,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath NPC.frameCounter = 4; // Velocity fix if PBG slowed - if (NPC.velocity.Length() < num1044) + if (NPC.velocity.Length() < chargeSpeed) NPC.velocity = new Vector2(calamityGlobalNPC.newAI[1], calamityGlobalNPC.newAI[2]); calamityGlobalNPC.newAI[0] += 1f; @@ -530,13 +530,13 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { try { - int num430 = (int)(NPC.Center.X / 16f); - int num431 = (int)(NPC.Center.Y / 16f); - if (!WorldGen.SolidTile(num430, num431) && Main.tile[num430, num431].LiquidAmount == 0) + int tilePositionX = (int)(NPC.Center.X / 16f); + int tilePositionY = (int)(NPC.Center.Y / 16f); + if (!WorldGen.SolidTile(tilePositionX, tilePositionY) && Main.tile[tilePositionX, tilePositionY].LiquidAmount == 0) { - Main.tile[num430, num431].LiquidAmount = (byte)Main.rand.Next(50, 150); - Main.tile[num430, num431].Get().LiquidType = LiquidID.Honey; - WorldGen.SquareTileFrame(num430, num431); + Main.tile[tilePositionX, tilePositionY].LiquidAmount = (byte)Main.rand.Next(50, 150); + Main.tile[tilePositionX, tilePositionY].Get().LiquidType = LiquidID.Honey; + WorldGen.SquareTileFrame(tilePositionX, tilePositionY); } } catch @@ -557,26 +557,26 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath charging = false; NPC.velocity *= 0.9f; - float num1052 = revenge ? 0.12f : 0.1f; + float slowedVelocityThreshold = revenge ? 0.12f : 0.1f; if (phase2) { NPC.velocity *= 0.98f; - num1052 += 0.05f; + slowedVelocityThreshold += 0.05f; } if (phase3) { NPC.velocity *= 0.98f; - num1052 += 0.05f; + slowedVelocityThreshold += 0.05f; } if (phase4) { NPC.velocity *= 0.98f; - num1052 += 0.05f; + slowedVelocityThreshold += 0.05f; } if (enrageScale > 0) NPC.velocity *= 0.95f; - if (Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) < num1052) + if (Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) < slowedVelocityThreshold) { NPC.ai[2] = 0f; NPC.ai[1] += 1f; @@ -592,12 +592,12 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath NPC.direction = playerLocation < 0 ? 1 : -1; NPC.spriteDirection = NPC.direction; - float num1055 = player.position.X + (player.width / 2) - vectorCenter.X; - float num1056 = player.position.Y + (player.height / 2) - 200f - vectorCenter.Y; - float num1057 = (float)Math.Sqrt(num1055 * num1055 + num1056 * num1056); + float playerXDist = player.position.X + (player.width / 2) - vectorCenter.X; + float playerYDist = player.position.Y + (player.height / 2) - 200f - vectorCenter.Y; + float playerTotalDist = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); calamityGlobalNPC.newAI[0] += 1f; - if (num1057 < 600f || calamityGlobalNPC.newAI[0] >= 180f) + if (playerTotalDist < 600f || calamityGlobalNPC.newAI[0] >= 180f) { NPC.ai[0] = (phase3 || bossRush) ? 5f : 1f; NPC.ai[1] = 0f; @@ -622,53 +622,53 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath else if (NPC.ai[0] == 1f) { charging = false; - Vector2 vector119 = new Vector2(NPC.direction == 1 ? NPC.getRect().BottomLeft().X : NPC.getRect().BottomRight().X, NPC.getRect().Bottom().Y + 20f); - vector119.X += NPC.direction * 120; - float num1058 = player.position.X + (player.width / 2) - vectorCenter.X; - float num1059 = player.position.Y + (player.height / 2) - vectorCenter.Y; - float num1060 = (float)Math.Sqrt(num1058 * num1058 + num1059 * num1059); + Vector2 missileSpawnPos = new Vector2(NPC.direction == 1 ? NPC.getRect().BottomLeft().X : NPC.getRect().BottomRight().X, NPC.getRect().Bottom().Y + 20f); + missileSpawnPos.X += NPC.direction * 120; + float playerMissileX = player.position.X + (player.width / 2) - vectorCenter.X; + float playerMissileY = player.position.Y + (player.height / 2) - vectorCenter.Y; + float playerMissileDist = (float)Math.Sqrt(playerMissileX * playerMissileX + playerMissileY * playerMissileY); NPC.ai[1] += 1f; - NPC.ai[1] += num1038 / 2; + NPC.ai[1] += activePlayers / 2; if (phase2) NPC.ai[1] += 0.5f; - bool flag103 = false; + bool shouldSpawnMissiles = false; if (NPC.ai[1] > 40f - 12f * enrageScale) { NPC.ai[1] = 0f; NPC.ai[2] += 1f; - flag103 = true; + shouldSpawnMissiles = true; } - if (flag103) + if (shouldSpawnMissiles) { SoundEngine.PlaySound(SoundID.NPCHit8, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { if (expertMode && NPC.CountNPCS(ModContent.NPCType()) < 2) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)vector119.X, (int)vector119.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, challengeAmt); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)missileSpawnPos.X, (int)missileSpawnPos.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, challengeAmt); float npcSpeed = (revenge ? 9f : 7f) + enrageScale * 2f; - float num1071 = player.position.X + player.width * 0.5f - vector119.X; - float num1072 = player.position.Y + player.height * 0.5f - vector119.Y; - float num1073 = (float)Math.Sqrt(num1071 * num1071 + num1072 * num1072); + float projXDist = player.position.X + player.width * 0.5f - missileSpawnPos.X; + float projYDist = player.position.Y + player.height * 0.5f - missileSpawnPos.Y; + float projDistance = (float)Math.Sqrt(projXDist * projXDist + projYDist * projYDist); - num1073 = npcSpeed / num1073; - num1071 *= num1073; - num1072 *= num1073; + projDistance = npcSpeed / projDistance; + projXDist *= projDistance; + projYDist *= projDistance; - int num1062 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)vector119.X, (int)vector119.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, challengeAmt); - Main.npc[num1062].velocity.X = num1071; - Main.npc[num1062].velocity.Y = num1072; - Main.npc[num1062].netUpdate = true; + int plagueMissile = NPC.NewNPC(NPC.GetSource_FromAI(), (int)missileSpawnPos.X, (int)missileSpawnPos.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, challengeAmt); + Main.npc[plagueMissile].velocity.X = projXDist; + Main.npc[plagueMissile].velocity.Y = projYDist; + Main.npc[plagueMissile].netUpdate = true; } } // Move closer if too far away - if (num1060 > 600f) + if (playerMissileDist > 600f) Movement(100f, 350f, 450f, player, enrageScale); else NPC.velocity *= 0.9f; @@ -697,15 +697,15 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath else if (NPC.ai[0] == 5f) { charging = false; - Vector2 vector119 = new Vector2(NPC.direction == 1 ? NPC.getRect().BottomLeft().X : NPC.getRect().BottomRight().X, NPC.getRect().Bottom().Y + 20f); - vector119.X += NPC.direction * 120; - float num1058 = player.position.X + (player.width / 2) - vectorCenter.X; - float num1059 = player.position.Y + (player.height / 2) - vectorCenter.Y; - float num1060 = (float)Math.Sqrt(num1058 * num1058 + num1059 * num1059); + Vector2 missileSpawnPos = new Vector2(NPC.direction == 1 ? NPC.getRect().BottomLeft().X : NPC.getRect().BottomRight().X, NPC.getRect().Bottom().Y + 20f); + missileSpawnPos.X += NPC.direction * 120; + float playerMissileX = player.position.X + (player.width / 2) - vectorCenter.X; + float playerMissileY = player.position.Y + (player.height / 2) - vectorCenter.Y; + float playerMissileDist = (float)Math.Sqrt(playerMissileX * playerMissileX + playerMissileY * playerMissileY); NPC.ai[1] += 1f; - NPC.ai[1] += num1038 / 2; - bool flag103 = false; + NPC.ai[1] += activePlayers / 2; + bool shouldSpawnMissiles = false; if (phase4) NPC.ai[1] += 0.5f; if (phase5) @@ -718,39 +718,39 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { NPC.ai[1] = 0f; NPC.ai[2] += 1f; - flag103 = true; + shouldSpawnMissiles = true; } - if (flag103) + if (shouldSpawnMissiles) { SoundEngine.PlaySound(SoundID.Item88,NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { if (expertMode && NPC.CountNPCS(ModContent.NPCType()) < 3) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)vector119.X, (int)vector119.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, challengeAmt); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)missileSpawnPos.X, (int)missileSpawnPos.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, challengeAmt); float npcSpeed = (revenge ? 11f : 9f) + enrageScale * 2f; - float num1071 = player.position.X + player.width * 0.5f - vector119.X; - float num1072 = player.position.Y + player.height * 0.5f - vector119.Y; - float num1073 = (float)Math.Sqrt(num1071 * num1071 + num1072 * num1072); + float projXDist = player.position.X + player.width * 0.5f - missileSpawnPos.X; + float projYDist = player.position.Y + player.height * 0.5f - missileSpawnPos.Y; + float projDistance = (float)Math.Sqrt(projXDist * projXDist + projYDist * projYDist); - num1073 = npcSpeed / num1073; - num1071 *= num1073; - num1072 *= num1073; - num1071 += Main.rand.Next(-20, 21) * 0.05f; - num1072 += Main.rand.Next(-20, 21) * 0.05f; + projDistance = npcSpeed / projDistance; + projXDist *= projDistance; + projYDist *= projDistance; + projXDist += Main.rand.Next(-20, 21) * 0.05f; + projYDist += Main.rand.Next(-20, 21) * 0.05f; - int num1062 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)vector119.X, (int)vector119.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, challengeAmt); - Main.npc[num1062].velocity.X = num1071; - Main.npc[num1062].velocity.Y = num1072; - Main.npc[num1062].netUpdate = true; + int plagueMissile = NPC.NewNPC(NPC.GetSource_FromAI(), (int)missileSpawnPos.X, (int)missileSpawnPos.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, challengeAmt); + Main.npc[plagueMissile].velocity.X = projXDist; + Main.npc[plagueMissile].velocity.Y = projYDist; + Main.npc[plagueMissile].netUpdate = true; } } // Move closer if too far away - if (num1060 > 600f) + if (playerMissileDist > 600f) Movement(100f, 350f, 450f, player, enrageScale); else NPC.velocity *= 0.9f; @@ -778,14 +778,14 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath // Stinger phase else if (NPC.ai[0] == 3f) { - Vector2 vector121 = new Vector2(NPC.direction == 1 ? NPC.getRect().BottomLeft().X : NPC.getRect().BottomRight().X, NPC.getRect().Bottom().Y + 20f); - vector121.X += NPC.direction * 120; + Vector2 stingerSpawnPos = new Vector2(NPC.direction == 1 ? NPC.getRect().BottomLeft().X : NPC.getRect().BottomRight().X, NPC.getRect().Bottom().Y + 20f); + stingerSpawnPos.X += NPC.direction * 120; NPC.ai[1] += 1f; - int num650 = phase5 ? 20 : (phase3 ? 25 : 30); - num650 -= (int)Math.Ceiling(5f * enrageScale); + int stingerFireDelay = phase5 ? 20 : (phase3 ? 25 : 30); + stingerFireDelay -= (int)Math.Ceiling(5f * enrageScale); - if (NPC.ai[1] % num650 == (num650 - 1) && vectorCenter.Y < player.position.Y) + if (NPC.ai[1] % stingerFireDelay == (stingerFireDelay - 1) && vectorCenter.Y < player.position.Y) { SoundEngine.PlaySound(SoundID.Item42, NPC.Center); @@ -794,12 +794,12 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath float projectileSpeed = revenge ? 6f : 5f; projectileSpeed += 2f * enrageScale; - float num1071 = player.position.X + player.width * 0.5f - vector121.X; - float num1072 = player.position.Y + player.height * 0.5f - vector121.Y; - float num1073 = (float)Math.Sqrt(num1071 * num1071 + num1072 * num1072); - num1073 = projectileSpeed / num1073; - num1071 *= num1073; - num1072 *= num1073; + float projXDist = player.position.X + player.width * 0.5f - stingerSpawnPos.X; + float projYDist = player.position.Y + player.height * 0.5f - stingerSpawnPos.Y; + float projDistance = (float)Math.Sqrt(projXDist * projXDist + projYDist * projYDist); + projDistance = projectileSpeed / projDistance; + projXDist *= projDistance; + projYDist *= projDistance; int type = ModContent.ProjectileType(); switch ((int)NPC.ai[2]) @@ -823,7 +823,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath } int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector121.X, vector121.Y, num1071, num1072, type, damage, 0f, Main.myPlayer, challengeAmt, player.position.Y); + Projectile.NewProjectile(NPC.GetSource_FromAI(), stingerSpawnPos.X, stingerSpawnPos.Y, projXDist, projYDist, type, damage, 0f, Main.myPlayer, challengeAmt, player.position.Y); NPC.netUpdate = true; } @@ -838,7 +838,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath NPC.direction = playerLocation < 0 ? 1 : -1; NPC.spriteDirection = NPC.direction; - if (NPC.ai[1] > num650 * 10f) + if (NPC.ai[1] > stingerFireDelay * 10f) { NPC.ai[0] = -1f; NPC.ai[1] = 3f; @@ -857,12 +857,12 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath // Missile charge else if (NPC.ai[0] == 4f) { - float num1044 = revenge ? 28f : 26f; + float chargeSpeed = revenge ? 28f : 26f; - num1044 += 3f * enrageScale; + chargeSpeed += 3f * enrageScale; - int num1043 = (int)Math.Ceiling(2f + enrageScale); - if (NPC.ai[1] > (2 * num1043) && NPC.ai[1] % 2f == 0f) + int phaseSwitchTimer = (int)Math.Ceiling(2f + enrageScale); + if (NPC.ai[1] > (2 * phaseSwitchTimer) && NPC.ai[1] % 2f == 0f) { MissileCountdown = 0; NPC.ai[0] = -1f; @@ -883,10 +883,10 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { float playerLocation = vectorCenter.X - player.Center.X; - float num620 = 20f; - num620 += 20 * enrageScale; + float chargeThresholdY = 20f; + chargeThresholdY += 20 * enrageScale; - if (Math.Abs(vectorCenter.Y - (player.Center.Y - 500f)) < num620) + if (Math.Abs(vectorCenter.Y - (player.Center.Y - 500f)) < chargeThresholdY) { if (MissileCountdown == 1) { @@ -942,13 +942,13 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath NPC.ai[1] += 1f; NPC.ai[2] = 0f; - float num1045 = player.position.X + (player.width / 2) - vectorCenter.X; - float num1046 = player.position.Y - 500f + (player.height / 2) - vectorCenter.Y; - float num1047 = (float)Math.Sqrt(num1045 * num1045 + num1046 * num1046); + float targetX = player.position.X + (player.width / 2) - vectorCenter.X; + float targetY = player.position.Y - 500f + (player.height / 2) - vectorCenter.Y; + float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); - num1047 = num1044 / num1047; - NPC.velocity.X = num1045 * num1047; - NPC.velocity.Y = num1046 * num1047; + targetDistance = chargeSpeed / targetDistance; + NPC.velocity.X = targetX * targetDistance; + NPC.velocity.Y = targetY * targetDistance; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); NPC.direction = playerLocation < 0 ? 1 : -1; @@ -964,32 +964,32 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath NPC.rotation = NPC.velocity.X * 0.02f; charging = false; - float num1048 = revenge ? 16f : 14f; - float num1049 = revenge ? 0.2f : 0.18f; - num1048 += 1.5f * enrageScale; - num1049 += 0.25f * enrageScale; + float maxLineUpSpeedY = revenge ? 16f : 14f; + float lineUpAccelY = revenge ? 0.2f : 0.18f; + maxLineUpSpeedY += 1.5f * enrageScale; + lineUpAccelY += 0.25f * enrageScale; if (vectorCenter.Y < player.Center.Y - 500f) - NPC.velocity.Y += num1049; + NPC.velocity.Y += lineUpAccelY; else - NPC.velocity.Y -= num1049; + NPC.velocity.Y -= lineUpAccelY; - if (NPC.velocity.Y < -num1048) - NPC.velocity.Y = -num1048; - if (NPC.velocity.Y > num1048) - NPC.velocity.Y = num1048; + if (NPC.velocity.Y < -maxLineUpSpeedY) + NPC.velocity.Y = -maxLineUpSpeedY; + if (NPC.velocity.Y > maxLineUpSpeedY) + NPC.velocity.Y = maxLineUpSpeedY; if (Math.Abs(vectorCenter.X - player.Center.X) > 600f) - NPC.velocity.X += num1049 * NPC.direction; + NPC.velocity.X += lineUpAccelY * NPC.direction; else if (Math.Abs(vectorCenter.X - player.Center.X) < 300f) - NPC.velocity.X -= num1049 * NPC.direction; + NPC.velocity.X -= lineUpAccelY * NPC.direction; else NPC.velocity.X *= 0.8f; - if (NPC.velocity.X < -num1048) - NPC.velocity.X = -num1048; - if (NPC.velocity.X > num1048) - NPC.velocity.X = num1048; + if (NPC.velocity.X < -maxLineUpSpeedY) + NPC.velocity.X = -maxLineUpSpeedY; + if (NPC.velocity.X > maxLineUpSpeedY) + NPC.velocity.X = maxLineUpSpeedY; NPC.direction = playerLocation < 0 ? 1 : -1; NPC.spriteDirection = NPC.direction; @@ -1005,12 +1005,12 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath NPC.spriteDirection = NPC.direction; - int num1050 = 600; - int num1051 = 1; + int stopChargeXDist = 600; + int chargeDirectionXSign = 1; if (vectorCenter.X < player.Center.X) - num1051 = -1; - if (NPC.direction == num1051 && Math.Abs(vectorCenter.X - player.Center.X) > num1050) + chargeDirectionXSign = -1; + if (NPC.direction == chargeDirectionXSign && Math.Abs(vectorCenter.X - player.Center.X) > stopChargeXDist) NPC.ai[2] = 1f; if (enrageScale > 0 && NPC.ai[2] == 1f) NPC.velocity *= 0.95f; @@ -1020,8 +1020,8 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath charging = true; // Velocity fix if PBG slowed - if (NPC.velocity.Length() < num1044) - NPC.velocity.X = num1044 * NPC.direction; + if (NPC.velocity.Length() < chargeSpeed) + NPC.velocity.X = chargeSpeed * NPC.direction; calamityGlobalNPC.newAI[0] += 1f; if (calamityGlobalNPC.newAI[0] > 90f) @@ -1034,26 +1034,26 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath charging = false; NPC.velocity *= 0.9f; - float num1052 = revenge ? 0.12f : 0.1f; + float slowedVelocityThreshold = revenge ? 0.12f : 0.1f; if (phase3) { NPC.velocity *= 0.9f; - num1052 += 0.05f; + slowedVelocityThreshold += 0.05f; } if (phase4) { NPC.velocity *= 0.9f; - num1052 += 0.05f; + slowedVelocityThreshold += 0.05f; } if (phase5) { NPC.velocity *= 0.9f; - num1052 += 0.05f; + slowedVelocityThreshold += 0.05f; } if (enrageScale > 0) NPC.velocity *= 0.95f; - if (Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) < num1052) + if (Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) < slowedVelocityThreshold) { NPC.ai[2] = 0f; NPC.ai[1] += 1f; @@ -1117,18 +1117,18 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= 100f * NPC.scale; } @@ -1152,23 +1152,23 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath NPC.height = 200; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Plague, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int plagueDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Plague, 0f, 0f, 100, default, 2f); + Main.dust[plagueDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[plagueDust].scale = 0.5f; + Main.dust[plagueDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Plague, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Plague, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int plagueDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Plague, 0f, 0f, 100, default, 3f); + Main.dust[plagueDust2].noGravity = true; + Main.dust[plagueDust2].velocity *= 5f; + plagueDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Plague, 0f, 0f, 100, default, 2f); + Main.dust[plagueDust2].velocity *= 2f; } } } @@ -1199,51 +1199,49 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath int frameCount = 3; Rectangle rectangle = new Rectangle(NPC.frame.X, NPC.frame.Y, texture.Width / 2, texture.Height / frameCount); - Vector2 vector11 = rectangle.Size() / 2f; + Vector2 halfSizeTexture = rectangle.Size() / 2f; Vector2 posOffset = new Vector2(charging ? 175 : 125, 0); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 10; + int afterimageAmt = 10; if (NPC.ai[0] != 0f && NPC.ai[0] != 4f) - num153 = 7; + afterimageAmt = 7; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int j = 1; j < afterimageAmt; j += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture.Width, texture.Height / frameCount) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + posOffset; - spriteBatch.Draw(texture, vector41, new Rectangle?(rectangle), color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - j) / 15f; + Vector2 afterimagePos = NPC.oldPos[j] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(texture.Width, texture.Height / frameCount) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + posOffset; + spriteBatch.Draw(texture, afterimagePos, new Rectangle?(rectangle), afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture.Width, texture.Height / frameCount) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + posOffset; - spriteBatch.Draw(texture, vector43, new Rectangle?(rectangle), NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture.Width, texture.Height / frameCount) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + posOffset; + spriteBatch.Draw(texture, drawLocation, new Rectangle?(rectangle), NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + Color redLerpColor = Color.Lerp(Color.White, Color.Red, 0.5f); if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int k = 1; k < afterimageAmt; k++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector44 -= new Vector2(glowTexture.Width, glowTexture.Height / frameCount) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + posOffset; - spriteBatch.Draw(glowTexture, vector44, new Rectangle?(rectangle), color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color otherAfterimageColor = redLerpColor; + otherAfterimageColor = Color.Lerp(otherAfterimageColor, Color.White, 0.5f); + otherAfterimageColor *= (afterimageAmt - k) / 15f; + Vector2 otherAfterimagePos = NPC.oldPos[k] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + otherAfterimagePos -= new Vector2(glowTexture.Width, glowTexture.Height / frameCount) * NPC.scale / 2f; + otherAfterimagePos += halfSizeTexture * NPC.scale + posOffset; + spriteBatch.Draw(glowTexture, otherAfterimagePos, new Rectangle?(rectangle), otherAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(glowTexture, vector43, new Rectangle?(rectangle), color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(glowTexture, drawLocation, new Rectangle?(rectangle), redLerpColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -1329,7 +1327,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB Honey Bucket drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ItemID.BottomlessHoneyBucket); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ItemID.BottomlessHoneyBucket, hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedPlaguebringer, ModContent.ItemType(), desc: DropHelper.FirstKillText); diff --git a/NPCs/Polterghast/PhantomFuckYou.cs b/NPCs/Polterghast/PhantomFuckYou.cs index bc79c19f80..a6361ff55d 100644 --- a/NPCs/Polterghast/PhantomFuckYou.cs +++ b/NPCs/Polterghast/PhantomFuckYou.cs @@ -151,30 +151,28 @@ namespace CalamityMod.NPCs.Polterghast spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); + int afterimageAmt = 5; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -190,23 +188,23 @@ namespace CalamityMod.NPCs.Polterghast NPC.height = 45; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 2; num621++) + for (int i = 0; i < 2; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int ghostDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 100, default, 2f); + Main.dust[ghostDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[ghostDust].scale = 0.5f; + Main.dust[ghostDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 180, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 180, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int ghostDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 180, 0f, 0f, 100, default, 3f); + Main.dust[ghostDust2].noGravity = true; + Main.dust[ghostDust2].velocity *= 5f; + ghostDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 180, 0f, 0f, 100, default, 2f); + Main.dust[ghostDust2].velocity *= 2f; } } } diff --git a/NPCs/Polterghast/PolterPhantom.cs b/NPCs/Polterghast/PolterPhantom.cs index 6bb35746ee..d6f60702e6 100644 --- a/NPCs/Polterghast/PolterPhantom.cs +++ b/NPCs/Polterghast/PolterPhantom.cs @@ -23,7 +23,7 @@ namespace CalamityMod.NPCs.Polterghast { Main.npcFrameCount[NPC.type] = 4; NPCID.Sets.TrailingMode[NPC.type] = 1; - NPCID.Sets.NPCBestiaryDrawModifiers bestiaryData = new NPCID.Sets.NPCBestiaryDrawModifiers() { Hide = true }; + NPCID.Sets.NPCBestiaryDrawModifiers bestiaryData = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Hide = true }; NPCID.Sets.NPCBestiaryDrawOffset.Add(Type, bestiaryData); } @@ -176,9 +176,9 @@ namespace CalamityMod.NPCs.Polterghast // Rotation if (NPC.Calamity().newAI[3] == 0f) { - float num740 = player.Center.X + predictionVector.X - vector.X; - float num741 = player.Center.Y + predictionVector.Y - vector.Y; - NPC.rotation = (float)Math.Atan2(num741, num740) + MathHelper.PiOver2; + float playerXDestination = player.Center.X + predictionVector.X - vector.X; + float playerYDestination = player.Center.Y + predictionVector.Y - vector.Y; + NPC.rotation = (float)Math.Atan2(playerYDestination, playerXDestination) + MathHelper.PiOver2; } else NPC.rotation = NPC.velocity.ToRotation() + MathHelper.PiOver2; @@ -210,18 +210,18 @@ namespace CalamityMod.NPCs.Polterghast movementLimitX /= numHooks; movementLimitY /= numHooks; - Vector2 vector91 = new Vector2(movementLimitX, movementLimitY); - float num736 = player.Center.X - vector91.X; - float num737 = player.Center.Y - vector91.Y; + Vector2 movementLimitVector = new Vector2(movementLimitX, movementLimitY); + float movementLimitedXDist = player.Center.X - movementLimitVector.X; + float movementLimitedYDist = player.Center.Y - movementLimitVector.Y; if (despawnBoost) { - num737 *= -1f; - num736 *= -1f; + movementLimitedYDist *= -1f; + movementLimitedXDist *= -1f; velocity += 8f; } - float num738 = (float)Math.Sqrt(num736 * num736 + num737 * num737); + float movementLimitedDistance = (float)Math.Sqrt(movementLimitedXDist * movementLimitedXDist + movementLimitedYDist * movementLimitedYDist); float maxDistanceFromHooks = expertMode ? 650f : 500f; if (speedBoost || bossRush) maxDistanceFromHooks += 250f; @@ -238,54 +238,54 @@ namespace CalamityMod.NPCs.Polterghast acceleration += acceleration * 0.15f * (1f - lifeRatio); } - if (num738 >= maxDistanceFromHooks) + if (movementLimitedDistance >= maxDistanceFromHooks) { - num738 = maxDistanceFromHooks / num738; - num736 *= num738; - num737 *= num738; + movementLimitedDistance = maxDistanceFromHooks / movementLimitedDistance; + movementLimitedXDist *= movementLimitedDistance; + movementLimitedYDist *= movementLimitedDistance; } - movementLimitX += num736; - movementLimitY += num737; - vector91 = vector; - num736 = movementLimitX - vector91.X; - num737 = movementLimitY - vector91.Y; - num738 = (float)Math.Sqrt(num736 * num736 + num737 * num737); + movementLimitX += movementLimitedXDist; + movementLimitY += movementLimitedYDist; + movementLimitVector = vector; + movementLimitedXDist = movementLimitX - movementLimitVector.X; + movementLimitedYDist = movementLimitY - movementLimitVector.Y; + movementLimitedDistance = (float)Math.Sqrt(movementLimitedXDist * movementLimitedXDist + movementLimitedYDist * movementLimitedYDist); - if (num738 < velocity) + if (movementLimitedDistance < velocity) { - num736 = NPC.velocity.X; - num737 = NPC.velocity.Y; + movementLimitedXDist = NPC.velocity.X; + movementLimitedYDist = NPC.velocity.Y; } else { - num738 = velocity / num738; - num736 *= num738; - num737 *= num738; + movementLimitedDistance = velocity / movementLimitedDistance; + movementLimitedXDist *= movementLimitedDistance; + movementLimitedYDist *= movementLimitedDistance; } - if (NPC.velocity.X < num736) + if (NPC.velocity.X < movementLimitedXDist) { NPC.velocity.X += acceleration; - if (NPC.velocity.X < 0f && num736 > 0f) + if (NPC.velocity.X < 0f && movementLimitedXDist > 0f) NPC.velocity.X += acceleration * 2f; } - else if (NPC.velocity.X > num736) + else if (NPC.velocity.X > movementLimitedXDist) { NPC.velocity.X -= acceleration; - if (NPC.velocity.X > 0f && num736 < 0f) + if (NPC.velocity.X > 0f && movementLimitedXDist < 0f) NPC.velocity.X -= acceleration * 2f; } - if (NPC.velocity.Y < num737) + if (NPC.velocity.Y < movementLimitedYDist) { NPC.velocity.Y += acceleration; - if (NPC.velocity.Y < 0f && num737 > 0f) + if (NPC.velocity.Y < 0f && movementLimitedYDist > 0f) NPC.velocity.Y += acceleration * 2f; } - else if (NPC.velocity.Y > num737) + else if (NPC.velocity.Y > movementLimitedYDist) { NPC.velocity.Y -= acceleration; - if (NPC.velocity.Y > 0f && num737 < 0f) + if (NPC.velocity.Y > 0f && movementLimitedYDist < 0f) NPC.velocity.Y -= acceleration * 2f; } } @@ -434,28 +434,26 @@ namespace CalamityMod.NPCs.Polterghast float changeColorGateValue = chargePhaseGateValue - colorChangeTime; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); - Color color36 = Color.White; + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); Color lightRed = new Color(255, 100, 100, 255) * NPC.Opacity; - float amount9 = 0.5f; - int num153 = 7; + int afterimageAmt = 7; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; + Color afterimageColor = drawColor; if (!NPC.IsABestiaryIconDummy && Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] > changeColorGateValue) - color38 = Color.Lerp(color38, lightRed, MathHelper.Clamp((Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] - changeColorGateValue) / timeToReachFullColor, 0f, 1f)); + afterimageColor = Color.Lerp(afterimageColor, lightRed, MathHelper.Clamp((Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] - changeColorGateValue) / timeToReachFullColor, 0f, 1f)); - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } @@ -464,34 +462,34 @@ namespace CalamityMod.NPCs.Polterghast if (!NPC.IsABestiaryIconDummy && Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] > changeColorGateValue) color = Color.Lerp(color, lightRed, MathHelper.Clamp((Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] - changeColorGateValue) / timeToReachFullColor, 0f, 1f)); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, color, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); Texture2D texture2D16 = ModContent.Request("CalamityMod/NPCs/Polterghast/PolterPhantomGlow").Value; Color c = Color.Red; if (!NPC.IsABestiaryIconDummy && (Main.npc[CalamityGlobalNPC.ghostBoss].ai[2] < changeColorGateValue || Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] > changeColorGateValue)) c = Color.Black; - Color color42 = Color.Lerp(Color.White, c, 0.5f); + Color blackWhiteLerp = Color.Lerp(Color.White, c, 0.5f); if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Vector2 vector44 = NPC.oldPos[num163] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - Color color43 = color42; - color43 = Color.Lerp(color43, color36, amount9); - color43 = NPC.GetAlpha(color43); - color43 *= (num153 - num163) / 15f; - spriteBatch.Draw(texture2D16, vector44, NPC.frame, color43, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 otherAfterimagePos = NPC.oldPos[j] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + otherAfterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + otherAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + Color otherAfterimageColor = blackWhiteLerp; + otherAfterimageColor = Color.Lerp(otherAfterimageColor, Color.White, 0.5f); + otherAfterimageColor = NPC.GetAlpha(otherAfterimageColor); + otherAfterimageColor *= (afterimageAmt - j) / 15f; + spriteBatch.Draw(texture2D16, otherAfterimagePos, NPC.frame, otherAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D16, vector43, NPC.frame, color42, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D16, drawLocation, NPC.frame, blackWhiteLerp, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -547,23 +545,23 @@ namespace CalamityMod.NPCs.Polterghast NPC.height = 90; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int ghostDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 100, default, 2f); + Main.dust[ghostDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[ghostDust].scale = 0.5f; + Main.dust[ghostDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 60; num623++) + for (int j = 0; j < 60; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 180, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 180, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int ghostDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 180, 0f, 0f, 100, default, 3f); + Main.dust[ghostDust2].noGravity = true; + Main.dust[ghostDust2].velocity *= 5f; + ghostDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 180, 0f, 0f, 100, default, 2f); + Main.dust[ghostDust2].velocity *= 2f; } } } diff --git a/NPCs/Polterghast/Polterghast.cs b/NPCs/Polterghast/Polterghast.cs index c23fe9e9a5..05f9fa0d76 100644 --- a/NPCs/Polterghast/Polterghast.cs +++ b/NPCs/Polterghast/Polterghast.cs @@ -427,9 +427,9 @@ namespace CalamityMod.NPCs.Polterghast // Rotation if (calamityGlobalNPC.newAI[3] == 0f) { - float num740 = player.Center.X + predictionVector.X - vector.X; - float num741 = player.Center.Y + predictionVector.Y - vector.Y; - NPC.rotation = (float)Math.Atan2(num741, num740) + MathHelper.PiOver2; + float playerXDestination = player.Center.X + predictionVector.X - vector.X; + float playerYDestination = player.Center.Y + predictionVector.Y - vector.Y; + NPC.rotation = (float)Math.Atan2(playerYDestination, playerXDestination) + MathHelper.PiOver2; } else NPC.rotation = NPC.velocity.ToRotation() + MathHelper.PiOver2; @@ -457,18 +457,18 @@ namespace CalamityMod.NPCs.Polterghast movementLimitX /= numHooks; movementLimitY /= numHooks; - Vector2 vector91 = new Vector2(movementLimitX, movementLimitY); - float num736 = player.Center.X - vector91.X; - float num737 = player.Center.Y - vector91.Y; + Vector2 movementLimitVector = new Vector2(movementLimitX, movementLimitY); + float movementLimitedXDist = player.Center.X - movementLimitVector.X; + float movementLimitedYDist = player.Center.Y - movementLimitVector.Y; if (despawnBoost) { - num737 *= -1f; - num736 *= -1f; + movementLimitedYDist *= -1f; + movementLimitedXDist *= -1f; velocity += 10f; } - float num738 = (float)Math.Sqrt(num736 * num736 + num737 * num737); + float movementLimitedDistance = (float)Math.Sqrt(movementLimitedXDist * movementLimitedXDist + movementLimitedYDist * movementLimitedYDist); float maxDistanceFromHooks = expertMode ? 650f : 500f; if (speedBoost || bossRush) maxDistanceFromHooks += 250f; @@ -481,53 +481,53 @@ namespace CalamityMod.NPCs.Polterghast acceleration += acceleration * 0.15f * (1f - lifeRatio); } - if (num738 >= maxDistanceFromHooks) + if (movementLimitedDistance >= maxDistanceFromHooks) { - num738 = maxDistanceFromHooks / num738; - num736 *= num738; - num737 *= num738; + movementLimitedDistance = maxDistanceFromHooks / movementLimitedDistance; + movementLimitedXDist *= movementLimitedDistance; + movementLimitedYDist *= movementLimitedDistance; } - movementLimitX += num736; - movementLimitY += num737; - num736 = movementLimitX - vector.X; - num737 = movementLimitY - vector.Y; - num738 = (float)Math.Sqrt(num736 * num736 + num737 * num737); + movementLimitX += movementLimitedXDist; + movementLimitY += movementLimitedYDist; + movementLimitedXDist = movementLimitX - vector.X; + movementLimitedYDist = movementLimitY - vector.Y; + movementLimitedDistance = (float)Math.Sqrt(movementLimitedXDist * movementLimitedXDist + movementLimitedYDist * movementLimitedYDist); - if (num738 < velocity) + if (movementLimitedDistance < velocity) { - num736 = NPC.velocity.X; - num737 = NPC.velocity.Y; + movementLimitedXDist = NPC.velocity.X; + movementLimitedYDist = NPC.velocity.Y; } else { - num738 = velocity / num738; - num736 *= num738; - num737 *= num738; + movementLimitedDistance = velocity / movementLimitedDistance; + movementLimitedXDist *= movementLimitedDistance; + movementLimitedYDist *= movementLimitedDistance; } - if (NPC.velocity.X < num736) + if (NPC.velocity.X < movementLimitedXDist) { NPC.velocity.X += acceleration; - if (NPC.velocity.X < 0f && num736 > 0f) + if (NPC.velocity.X < 0f && movementLimitedXDist > 0f) NPC.velocity.X += acceleration * 2f; } - else if (NPC.velocity.X > num736) + else if (NPC.velocity.X > movementLimitedXDist) { NPC.velocity.X -= acceleration; - if (NPC.velocity.X > 0f && num736 < 0f) + if (NPC.velocity.X > 0f && movementLimitedXDist < 0f) NPC.velocity.X -= acceleration * 2f; } - if (NPC.velocity.Y < num737) + if (NPC.velocity.Y < movementLimitedYDist) { NPC.velocity.Y += acceleration; - if (NPC.velocity.Y < 0f && num737 > 0f) + if (NPC.velocity.Y < 0f && movementLimitedYDist > 0f) NPC.velocity.Y += acceleration * 2f; } - else if (NPC.velocity.Y > num737) + else if (NPC.velocity.Y > movementLimitedYDist) { NPC.velocity.Y -= acceleration; - if (NPC.velocity.Y > 0f && num737 < 0f) + if (NPC.velocity.Y > 0f && movementLimitedYDist < 0f) NPC.velocity.Y -= acceleration * 2f; } } @@ -670,14 +670,14 @@ namespace CalamityMod.NPCs.Polterghast { NPC.localAI[1] = 0f; - bool flag47 = Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); + bool notLiningUpCharge = Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); if (NPC.localAI[3] > 0f) { - flag47 = true; + notLiningUpCharge = true; NPC.localAI[3] = 0f; } - if (flag47) + if (notLiningUpCharge) { int type = ModContent.ProjectileType(); if (Main.rand.NextBool(3)) @@ -688,26 +688,26 @@ namespace CalamityMod.NPCs.Polterghast int damage = NPC.GetProjectileDamage(type); - Vector2 vector93 = vector; - float num743 = player.Center.X - vector93.X; - float num744 = player.Center.Y - vector93.Y; - float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); + Vector2 firingPosition = vector; + float playerXDist = player.Center.X - firingPosition.X; + float playerYDist = player.Center.Y - firingPosition.Y; + float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); - num745 = baseProjectileVelocity / num745; - num743 *= num745; - num744 *= num745; - vector93.X += num743 * 3f; - vector93.Y += num744 * 3f; + playerDistance = baseProjectileVelocity / playerDistance; + playerXDist *= playerDistance; + playerYDist *= playerDistance; + firingPosition.X += playerXDist * 3f; + firingPosition.Y += playerYDist * 3f; float rotation = MathHelper.ToRadians(65); - float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); - double startAngle = Math.Atan2(num743, num744) - rotation / 2; + float baseSpeed = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); + double startAngle = Math.Atan2(playerXDist, playerYDist) - rotation / 2; double deltaAngle = rotation / 6; double offsetAngle; for (int i = 0; i < 6; i++) { offsetAngle = startAngle + deltaAngle * i; - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), vector93.X, vector93.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), firingPosition.X, firingPosition.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); Main.projectile[proj].timeLeft = type == ModContent.ProjectileType() ? 450 : 1800; } } @@ -716,26 +716,26 @@ namespace CalamityMod.NPCs.Polterghast int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - Vector2 vector93 = vector; - float num743 = player.Center.X - vector93.X; - float num744 = player.Center.Y - vector93.Y; - float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); + Vector2 firingPosition = vector; + float playerXDist = player.Center.X - firingPosition.X; + float playerYDist = player.Center.Y - firingPosition.Y; + float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); - num745 = (baseProjectileVelocity + 5f) / num745; - num743 *= num745; - num744 *= num745; - vector93.X += num743 * 3f; - vector93.Y += num744 * 3f; + playerDistance = (baseProjectileVelocity + 5f) / playerDistance; + playerXDist *= playerDistance; + playerYDist *= playerDistance; + firingPosition.X += playerXDist * 3f; + firingPosition.Y += playerYDist * 3f; float rotation = MathHelper.ToRadians(80); - float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); - double startAngle = Math.Atan2(num743, num744) - rotation / 2; + float baseSpeed = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); + double startAngle = Math.Atan2(playerXDist, playerYDist) - rotation / 2; double deltaAngle = rotation / 6; double offsetAngle; for (int i = 0; i < 6; i++) { offsetAngle = startAngle + deltaAngle * i; - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), vector93.X, vector93.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), firingPosition.X, firingPosition.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); Main.projectile[proj].timeLeft = 450; } } @@ -768,24 +768,24 @@ namespace CalamityMod.NPCs.Polterghast Gore.NewGore(NPC.GetSource_FromAI(), NPC.position, NPC.velocity, Mod.Find("Polt5").Type, 1f); } - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - Main.dust[num622].noGravity = true; + int ghostDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 100, default, 2f); + Main.dust[ghostDust].velocity *= 3f; + Main.dust[ghostDust].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[ghostDust].scale = 0.5f; + Main.dust[ghostDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int ghostDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 3f); + Main.dust[ghostDust2].noGravity = true; + Main.dust[ghostDust2].velocity *= 5f; + ghostDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 2f); + Main.dust[ghostDust2].velocity *= 2f; } } @@ -805,14 +805,14 @@ namespace CalamityMod.NPCs.Polterghast { NPC.localAI[1] = 0f; - bool flag47 = Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); + bool notLiningUpCharge = Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); if (NPC.localAI[3] > 0f) { - flag47 = true; + notLiningUpCharge = true; NPC.localAI[3] = 0f; } - if (flag47) + if (notLiningUpCharge) { int type = ModContent.ProjectileType(); if (Main.rand.NextBool(3)) @@ -823,27 +823,27 @@ namespace CalamityMod.NPCs.Polterghast int damage = NPC.GetProjectileDamage(type); - Vector2 vector93 = vector; - float num743 = player.Center.X - vector93.X; - float num744 = player.Center.Y - vector93.Y; - float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); + Vector2 firingPosition = vector; + float playerXDist = player.Center.X - firingPosition.X; + float playerYDist = player.Center.Y - firingPosition.Y; + float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); - num745 = (baseProjectileVelocity + 1f) / num745; - num743 *= num745; - num744 *= num745; - vector93.X += num743 * 3f; - vector93.Y += num744 * 3f; + playerDistance = (baseProjectileVelocity + 1f) / playerDistance; + playerXDist *= playerDistance; + playerYDist *= playerDistance; + firingPosition.X += playerXDist * 3f; + firingPosition.Y += playerYDist * 3f; int numProj = 7; float rotation = MathHelper.ToRadians(80); - float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); - double startAngle = Math.Atan2(num743, num744) - rotation / 2; + float baseSpeed = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); + double startAngle = Math.Atan2(playerXDist, playerYDist) - rotation / 2; double deltaAngle = rotation / numProj; double offsetAngle; for (int i = 0; i < numProj; i++) { offsetAngle = startAngle + deltaAngle * i; - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), vector93.X, vector93.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), firingPosition.X, firingPosition.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); Main.projectile[proj].timeLeft = type == ModContent.ProjectileType() ? 450 : 1800; } } @@ -852,27 +852,27 @@ namespace CalamityMod.NPCs.Polterghast int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - Vector2 vector93 = vector; - float num743 = player.Center.X - vector93.X; - float num744 = player.Center.Y - vector93.Y; - float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); + Vector2 firingPosition = vector; + float playerXDist = player.Center.X - firingPosition.X; + float playerYDist = player.Center.Y - firingPosition.Y; + float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); - num745 = (baseProjectileVelocity + 5f) / num745; - num743 *= num745; - num744 *= num745; - vector93.X += num743 * 3f; - vector93.Y += num744 * 3f; + playerDistance = (baseProjectileVelocity + 5f) / playerDistance; + playerXDist *= playerDistance; + playerYDist *= playerDistance; + firingPosition.X += playerXDist * 3f; + firingPosition.Y += playerYDist * 3f; int numProj = 7; float rotation = MathHelper.ToRadians(100); - float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); - double startAngle = Math.Atan2(num743, num744) - rotation / 2; + float baseSpeed = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); + double startAngle = Math.Atan2(playerXDist, playerYDist) - rotation / 2; double deltaAngle = rotation / numProj; double offsetAngle; for (int i = 0; i < numProj; i++) { offsetAngle = startAngle + deltaAngle * i; - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), vector93.X, vector93.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), firingPosition.X, firingPosition.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); Main.projectile[proj].timeLeft = 450; } } @@ -922,24 +922,24 @@ namespace CalamityMod.NPCs.Polterghast Gore.NewGore(NPC.GetSource_FromAI(), NPC.position, NPC.velocity, Mod.Find("Polt5").Type, 1f); } - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - Main.dust[num622].noGravity = true; + int ghostDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 100, default, 2f); + Main.dust[ghostDust].velocity *= 3f; + Main.dust[ghostDust].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[ghostDust].scale = 0.5f; + Main.dust[ghostDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int ghostDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 3f); + Main.dust[ghostDust2].noGravity = true; + Main.dust[ghostDust2].velocity *= 5f; + ghostDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 2f); + Main.dust[ghostDust2].velocity *= 2f; } } @@ -955,21 +955,21 @@ namespace CalamityMod.NPCs.Polterghast NPC.localAI[1] = 0f; if (Main.netMode != NetmodeID.MultiplayerClient && !charging && !chargePhase) { - Vector2 vector93 = vector; - float num743 = player.Center.X - vector93.X; - float num744 = player.Center.Y - vector93.Y; - float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); + Vector2 firingPosition = vector; + float playerXDist = player.Center.X - firingPosition.X; + float playerYDist = player.Center.Y - firingPosition.Y; + float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); - num745 = baseProjectileVelocity / num745; - num743 *= num745; - num744 *= num745; - vector93.X += num743 * 3f; - vector93.Y += num744 * 3f; + playerDistance = baseProjectileVelocity / playerDistance; + playerXDist *= playerDistance; + playerYDist *= playerDistance; + firingPosition.X += playerXDist * 3f; + firingPosition.Y += playerYDist * 3f; int numProj = 6 + (getPissed ? 4 : 2); float rotation = MathHelper.ToRadians(110 + (getPissed ? 15 : 0)); - float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); - double startAngle = Math.Atan2(num743, num744) - rotation / 2; + float baseSpeed = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); + double startAngle = Math.Atan2(playerXDist, playerYDist) - rotation / 2; double deltaAngle = rotation / numProj; double offsetAngle; @@ -979,7 +979,7 @@ namespace CalamityMod.NPCs.Polterghast for (int i = 0; i < numProj; i++) { offsetAngle = startAngle + deltaAngle * i; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector93.X, vector93.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), firingPosition.X, firingPosition.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); } } } @@ -991,24 +991,23 @@ namespace CalamityMod.NPCs.Polterghast { NPC.localAI[2] = 0f; - float num757 = 6f; - Vector2 vector94 = vector; - float num758 = player.Center.X - vector94.X; - float num760 = player.Center.Y - vector94.Y; - float num761 = (float)Math.Sqrt(num758 * num758 + num760 * num760); - num761 = num757 / num761; - num758 *= num761; - num760 *= num761; - vector94.X += num758 * 3f; - vector94.Y += num760 * 3f; + Vector2 spiritSpawn = vector; + float spiritXDist = player.Center.X - spiritSpawn.X; + float spiritYDist = player.Center.Y - spiritSpawn.Y; + float spiritDistance = (float)Math.Sqrt(spiritXDist * spiritXDist + spiritYDist * spiritYDist); + spiritDistance = 6f / spiritDistance; + spiritXDist *= spiritDistance; + spiritYDist *= spiritDistance; + spiritSpawn.X += spiritXDist * 3f; + spiritSpawn.Y += spiritYDist * 3f; if (NPC.CountNPCS(ModContent.NPCType()) < 2 && Main.netMode != NetmodeID.MultiplayerClient && !charging && !chargePhase) { SoundEngine.PlaySound(PhantomSound, NPC.Center); - int num762 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); - Main.npc[num762].velocity.X = num758; - Main.npc[num762].velocity.Y = num760; - Main.npc[num762].netUpdate = true; + int phantomSpirit = NPC.NewNPC(NPC.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); + Main.npc[phantomSpirit].velocity.X = spiritXDist; + Main.npc[phantomSpirit].velocity.Y = spiritYDist; + Main.npc[phantomSpirit].netUpdate = true; } } @@ -1096,7 +1095,7 @@ namespace CalamityMod.NPCs.Polterghast // GFB Cell Phone drop var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ItemID.CellPhone); + GFBOnly.Add(ItemID.CellPhone, hideLootReport: true); } // Lore @@ -1151,40 +1150,38 @@ namespace CalamityMod.NPCs.Polterghast Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; Texture2D texture2D16 = ModContent.Request("CalamityMod/NPCs/Polterghast/PolterghastGlow2").Value; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 7; + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); + int afterimageAmt = 7; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } Vector2 vector43 = NPC.Center - screenPos; vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); + vector43 += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); Color c = NPC.IsABestiaryIconDummy ? Color.White : NPC.GetAlpha(drawColor); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, c, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, NPC.frame, c, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/Polterghast/PolterghastGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + Color secondColorLerp = Color.Lerp(Color.White, Color.Cyan, 0.5f); Color lightRed = new Color(255, 100, 100, 255); if (threeAM) { - color37 = Color.Red; + secondColorLerp = Color.Red; lightRed = Color.DarkRed; } @@ -1196,34 +1193,34 @@ namespace CalamityMod.NPCs.Polterghast float colorChangeTime = 180f; float changeColorGateValue = chargePhaseGateValue - colorChangeTime; if (NPC.Calamity().newAI[0] > changeColorGateValue) - color37 = Color.Lerp(color37, lightRed, MathHelper.Clamp((NPC.Calamity().newAI[0] - changeColorGateValue) / timeToReachFullColor, 0f, 1f)); + secondColorLerp = Color.Lerp(secondColorLerp, lightRed, MathHelper.Clamp((NPC.Calamity().newAI[0] - changeColorGateValue) / timeToReachFullColor, 0f, 1f)); - Color color42 = Color.Lerp(Color.White, (NPC.ai[2] >= changeColorGateValue || NPC.Calamity().newAI[0] > changeColorGateValue) ? Color.Red : Color.Black, 0.5f); + Color veinColor = Color.Lerp(Color.White, (NPC.ai[2] >= changeColorGateValue || NPC.Calamity().newAI[0] > changeColorGateValue) ? Color.Red : Color.Black, 0.5f); if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = NPC.GetAlpha(color41); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color otherAfterimageColor = secondColorLerp; + otherAfterimageColor = Color.Lerp(otherAfterimageColor, Color.White, 0.5f); + otherAfterimageColor = NPC.GetAlpha(otherAfterimageColor); + otherAfterimageColor *= (afterimageAmt - j) / 15f; + Vector2 otherAfterimagePos = NPC.oldPos[j] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + otherAfterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + otherAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, otherAfterimagePos, NPC.frame, otherAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - Color color43 = color42; - color43 = Color.Lerp(color43, color36, amount9); - color43 = NPC.GetAlpha(color43); - color43 *= (num153 - num163) / 15f; - spriteBatch.Draw(texture2D16, vector44, NPC.frame, color43, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color veinAfterimageColor = veinColor; + veinAfterimageColor = Color.Lerp(veinAfterimageColor, Color.White, 0.5f); + veinAfterimageColor = NPC.GetAlpha(veinAfterimageColor); + veinAfterimageColor *= (afterimageAmt - j) / 15f; + spriteBatch.Draw(texture2D16, otherAfterimagePos, NPC.frame, veinAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, NPC.frame, secondColorLerp, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - spriteBatch.Draw(texture2D16, vector43, NPC.frame, color42, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D16, vector43, NPC.frame, veinColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -1309,23 +1306,23 @@ namespace CalamityMod.NPCs.Polterghast NPC.height = 90; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int ghostDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 100, default, 2f); + Main.dust[ghostDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[ghostDust].scale = 0.5f; + Main.dust[ghostDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 60; num623++) + for (int j = 0; j < 60; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int ghostDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 3f); + Main.dust[ghostDust2].noGravity = true; + Main.dust[ghostDust2].velocity *= 5f; + ghostDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 2f); + Main.dust[ghostDust2].velocity *= 2f; } } } diff --git a/NPCs/Polterghast/PolterghastHook.cs b/NPCs/Polterghast/PolterghastHook.cs index 8b8e865ecd..3966ad294b 100644 --- a/NPCs/Polterghast/PolterghastHook.cs +++ b/NPCs/Polterghast/PolterghastHook.cs @@ -126,10 +126,10 @@ namespace CalamityMod.NPCs.Polterghast Movement(phase2, expertMode, revenge, death, speedBoost, despawnBoost, lifeRatio, tileEnrageMult, player); // Fire projectiles - Vector2 vector17 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num147 = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2) - vector17.X; - float num148 = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2) - vector17.Y; - float num149 = (float)Math.Sqrt(num147 * num147 + num148 * num148); + Vector2 hookPosition = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2) - hookPosition.X; + float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2) - hookPosition.Y; + float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); if (chargePhase) { @@ -155,13 +155,13 @@ namespace CalamityMod.NPCs.Polterghast if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[2] == 20f) { - float num151 = 10f * tileEnrageMult; + float shotSpeed = 10f * tileEnrageMult; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - num149 = num151 / num149; - num147 *= num149; - num148 *= num149; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector17.X, vector17.Y, num147, num148, type, damage, 0f, Main.myPlayer, 0f, 0f); + targetDistance = shotSpeed / targetDistance; + targetX *= targetDistance; + targetY *= targetDistance; + Projectile.NewProjectile(NPC.GetSource_FromAI(), hookPosition.X, hookPosition.Y, targetX, targetY, type, damage, 0f, Main.myPlayer, 0f, 0f); } } return; @@ -184,9 +184,9 @@ namespace CalamityMod.NPCs.Polterghast if (phase2) { - float num740 = Main.player[NPC.target].Center.X - NPC.Center.X; - float num741 = Main.player[NPC.target].Center.Y - NPC.Center.Y; - NPC.rotation = (float)Math.Atan2(num741, num740) + MathHelper.PiOver2; + float playerXDirection = Main.player[NPC.target].Center.X - NPC.Center.X; + float playerYDirection = Main.player[NPC.target].Center.Y - NPC.Center.Y; + NPC.rotation = (float)Math.Atan2(playerYDirection, playerXDirection) + MathHelper.PiOver2; } if (Main.netMode == NetmodeID.MultiplayerClient) @@ -220,9 +220,9 @@ namespace CalamityMod.NPCs.Polterghast if (!despawnBoost && NPC.localAI[0] <= 0f && NPC.ai[0] != 0f) { - for (int num763 = 0; num763 < Main.maxNPCs; num763++) + for (int i = 0; i < Main.maxNPCs; i++) { - if (num763 != NPC.whoAmI && Main.npc[num763].active && Main.npc[num763].type == NPC.type && (Main.npc[num763].velocity.X != 0f || Main.npc[num763].velocity.Y != 0f)) + if (i != NPC.whoAmI && Main.npc[i].active && Main.npc[i].type == NPC.type && (Main.npc[i].velocity.X != 0f || Main.npc[i].velocity.Y != 0f)) NPC.localAI[0] = 180f; } } @@ -230,34 +230,34 @@ namespace CalamityMod.NPCs.Polterghast if (NPC.localAI[0] <= 0f) { NPC.localAI[0] = 450f; - bool flag50 = false; - int num764 = 0; - while (!flag50 && num764 <= 1000) + bool canMoveToTile = false; + int increment = 0; + while (!canMoveToTile && increment <= 1000) { - num764++; - int num765 = (int)(player.Center.X / 16f); - int num766 = (int)(player.Center.Y / 16f); + increment++; + int playerTileX = (int)(player.Center.X / 16f); + int playerTileY = (int)(player.Center.Y / 16f); if (NPC.ai[0] == 0f) { - num765 = (int)((player.Center.X + Main.npc[CalamityGlobalNPC.ghostBoss].Center.X) / 32f); - num766 = (int)((player.Center.Y + Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y) / 32f); + playerTileX = (int)((player.Center.X + Main.npc[CalamityGlobalNPC.ghostBoss].Center.X) / 32f); + playerTileY = (int)((player.Center.Y + Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y) / 32f); } if (despawnBoost) { - num765 = (int)Main.npc[CalamityGlobalNPC.ghostBoss].position.X / 16; - num766 = (int)(Main.npc[CalamityGlobalNPC.ghostBoss].position.Y + 400f) / 16; + playerTileX = (int)Main.npc[CalamityGlobalNPC.ghostBoss].position.X / 16; + playerTileY = (int)(Main.npc[CalamityGlobalNPC.ghostBoss].position.Y + 400f) / 16; } - int num767 = 20; - num767 += (int)(100f * (num764 / 1000f)); - int num768 = num765 + Main.rand.Next(-num767, num767 + 1); - int num769 = num766 + Main.rand.Next(-num767, num767 + 1); + int randPlayerRadius = 20; + randPlayerRadius += (int)(100f * (increment / 1000f)); + int randTileX = playerTileX + Main.rand.Next(-randPlayerRadius, randPlayerRadius + 1); + int randTileY = playerTileY + Main.rand.Next(-randPlayerRadius, randPlayerRadius + 1); try { - if (WorldGen.SolidTile(num768, num769) || Main.tile[num768, num769].WallType > 0 || chargePhase) + if (WorldGen.SolidTile(randTileX, randTileY) || Main.tile[randTileX, randTileY].WallType > 0 || chargePhase) { - flag50 = true; - NPC.ai[0] = num768; - NPC.ai[1] = num769; + canMoveToTile = true; + NPC.ai[0] = randTileX; + NPC.ai[1] = randTileY; NPC.localAI[1] = Vector2.Distance(NPC.Center, player.Center) * 0.01f; NPC.netUpdate = true; } @@ -281,28 +281,28 @@ namespace CalamityMod.NPCs.Polterghast if (despawnBoost) velocity *= 2f; - Vector2 vector95 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num773 = NPC.ai[0] * 16f - 8f - vector95.X; - float num774 = NPC.ai[1] * 16f - 8f - vector95.Y; - float num775 = (float)Math.Sqrt(num773 * num773 + num774 * num774); - if (num775 < 12f + velocity) + Vector2 hookCenter = new Vector2(NPC.Center.X, NPC.Center.Y); + float hookXDest = NPC.ai[0] * 16f - 8f - hookCenter.X; + float hookYDest = NPC.ai[1] * 16f - 8f - hookCenter.Y; + float hookDestination = (float)Math.Sqrt(hookXDest * hookXDest + hookYDest * hookYDest); + if (hookDestination < 12f + velocity) { - NPC.velocity.X = num773; - NPC.velocity.Y = num774; + NPC.velocity.X = hookXDest; + NPC.velocity.Y = hookYDest; } else { - num775 = velocity / num775; - NPC.velocity.X = num773 * num775; - NPC.velocity.Y = num774 * num775; + hookDestination = velocity / hookDestination; + NPC.velocity.X = hookXDest * hookDestination; + NPC.velocity.Y = hookYDest * hookDestination; } if (!phase2) { - Vector2 vector96 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num776 = Main.npc[CalamityGlobalNPC.ghostBoss].Center.X - vector96.X; - float num777 = Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y - vector96.Y; - NPC.rotation = (float)Math.Atan2(num777, num776) - 1.57f; + Vector2 hookCenterPassive = new Vector2(NPC.Center.X, NPC.Center.Y); + float polterDirectionX = Main.npc[CalamityGlobalNPC.ghostBoss].Center.X - hookCenterPassive.X; + float polterDirectionY = Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y - hookCenterPassive.Y; + NPC.rotation = (float)Math.Atan2(polterDirectionY, polterDirectionX) - 1.57f; } } } @@ -327,32 +327,32 @@ namespace CalamityMod.NPCs.Polterghast Vector2 center = NPC.Center; float bossCenterX = Main.npc[CalamityGlobalNPC.ghostBoss].Center.X - center.X; float bossCenterY = Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y - center.Y; - float rotation2 = (float)Math.Atan2(bossCenterY, bossCenterX) - 1.57f; + float chainRotation = (float)Math.Atan2(bossCenterY, bossCenterX) - 1.57f; bool draw = true; while (draw) { int chainWidth = 20; int chainHeight = 52; - float num10 = (float)Math.Sqrt(bossCenterX * bossCenterX + bossCenterY * bossCenterY); - if (num10 < chainHeight) + float polterDistance = (float)Math.Sqrt(bossCenterX * bossCenterX + bossCenterY * bossCenterY); + if (polterDistance < chainHeight) { - chainWidth = (int)num10 - chainHeight + chainWidth; + chainWidth = (int)polterDistance - chainHeight + chainWidth; draw = false; } - num10 = chainWidth / num10; - bossCenterX *= num10; - bossCenterY *= num10; + polterDistance = chainWidth / polterDistance; + bossCenterX *= polterDistance; + bossCenterY *= polterDistance; center.X += bossCenterX; center.Y += bossCenterY; bossCenterX = Main.npc[CalamityGlobalNPC.ghostBoss].Center.X - center.X; bossCenterY = Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y - center.Y; - Color color2 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + Color cyanLerpColor = Color.Lerp(Color.White, Color.Cyan, 0.5f); if (Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] > changeColorGateValue) - color2 = Color.Lerp(color2, lightRed, MathHelper.Clamp((Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] - changeColorGateValue) / timeToReachFullColor, 0f, 1f)); + cyanLerpColor = Color.Lerp(cyanLerpColor, lightRed, MathHelper.Clamp((Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] - changeColorGateValue) / timeToReachFullColor, 0f, 1f)); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Polterghast/PolterghastChain").Value, new Vector2(center.X - screenPos.X, center.Y - screenPos.Y), - new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, 0, ModContent.Request("CalamityMod/NPCs/Polterghast/PolterghastChain").Value.Width, chainWidth)), color2, rotation2, + new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, 0, ModContent.Request("CalamityMod/NPCs/Polterghast/PolterghastChain").Value.Width, chainWidth)), cyanLerpColor, chainRotation, new Vector2(ModContent.Request("CalamityMod/NPCs/Polterghast/PolterghastChain").Value.Width * 0.5f, ModContent.Request("CalamityMod/NPCs/Polterghast/PolterghastChain").Value.Height * 0.5f), 1f, SpriteEffects.None, 0f); } } @@ -362,53 +362,51 @@ namespace CalamityMod.NPCs.Polterghast spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); + int afterimageAmt = 5; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/Polterghast/PolterghastHookGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + Color cyanLerp2 = Color.Lerp(Color.White, Color.Cyan, 0.5f); if (Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] > changeColorGateValue) - color37 = Color.Lerp(color37, lightRed, MathHelper.Clamp((Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] - changeColorGateValue) / timeToReachFullColor, 0f, 1f)); + cyanLerp2 = Color.Lerp(cyanLerp2, lightRed, MathHelper.Clamp((Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] - changeColorGateValue) / timeToReachFullColor, 0f, 1f)); if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = NPC.GetAlpha(color41); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color otherAfterimageColor = cyanLerp2; + otherAfterimageColor = Color.Lerp(otherAfterimageColor, Color.White, 0.5f); + otherAfterimageColor = NPC.GetAlpha(otherAfterimageColor); + otherAfterimageColor *= (afterimageAmt - j) / 15f; + Vector2 otherAfterimagePos = NPC.oldPos[j] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + otherAfterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + otherAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, otherAfterimagePos, NPC.frame, otherAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, cyanLerp2, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs b/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs index 249176e716..896e52d12c 100644 --- a/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs +++ b/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs @@ -83,7 +83,7 @@ namespace CalamityMod.NPCs.PrimordialWyrm public override void SetStaticDefaults() { NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.50f, PortraitScale = 0.6f, @@ -1366,14 +1366,14 @@ namespace CalamityMod.NPCs.PrimordialWyrm { for (int num1474 = 0; num1474 < dustAmt; num1474++) { - Vector2 vector171 = Vector2.Normalize(NPC.velocity) * new Vector2((NPC.width + 50) / 2f, NPC.height) * 0.75f; - vector171 = vector171.RotatedBy((num1474 - (dustAmt / 2 - 1)) * (double)pie / (float)dustAmt) + NPC.Center; - Vector2 value18 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 172, value18.X * 2f, value18.Y * 2f, 100, default, 1.4f); - Main.dust[num1475].noGravity = true; - Main.dust[num1475].noLight = true; - Main.dust[num1475].velocity /= 4f; - Main.dust[num1475].velocity -= NPC.velocity; + Vector2 dustRotation = Vector2.Normalize(NPC.velocity) * new Vector2((NPC.width + 50) / 2f, NPC.height) * 0.75f; + dustRotation = dustRotation.RotatedBy((num1474 - (dustAmt / 2 - 1)) * (double)pie / (float)dustAmt) + NPC.Center; + Vector2 dustVelocity = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); + int chargeDust = Dust.NewDust(dustRotation + dustVelocity, 0, 0, 172, dustVelocity.X * 2f, dustVelocity.Y * 2f, 100, default, 1.4f); + Main.dust[chargeDust].noGravity = true; + Main.dust[chargeDust].noLight = true; + Main.dust[chargeDust].velocity /= 4f; + Main.dust[chargeDust].velocity -= NPC.velocity; } } @@ -1394,18 +1394,18 @@ namespace CalamityMod.NPCs.PrimordialWyrm Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= 70f && NPC.Opacity == 1f; } diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs index bffb31da49..d608835485 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs @@ -43,7 +43,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians Main.npcFrameCount[NPC.type] = 10; NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { PortraitPositionXOverride = 0, PortraitScale = 0.75f, @@ -226,7 +226,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians Vector2 dustLineEnd = shootFrom; Vector2 currentDustPos = default; Vector2 spinningpoint = new Vector2(0f, -3f).RotatedByRandom(MathHelper.Pi); - Vector2 value5 = new Vector2(2.1f, 2f); + Vector2 dustVelocityMult = new Vector2(2.1f, 2f); int dustSpawned = 0; for (int i = 0; i < maxHealDustIterations; i++) { @@ -237,7 +237,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians dustColor.A = 255; int dust = Dust.NewDust(currentDustPos, 0, 0, 267, 0f, 0f, 0, dustColor, 1f); Main.dust[dust].position = currentDustPos; - Main.dust[dust].velocity = spinningpoint.RotatedBy(MathHelper.TwoPi * i / maxHealDustIterations) * value5 * (0.8f + Main.rand.NextFloat() * 0.4f) + NPC.velocity; + Main.dust[dust].velocity = spinningpoint.RotatedBy(MathHelper.TwoPi * i / maxHealDustIterations) * dustVelocityMult * (0.8f + Main.rand.NextFloat() * 0.4f) + NPC.velocity; Main.dust[dust].noGravity = true; Main.dust[dust].scale = 1f; Main.dust[dust].fadeIn = Main.rand.NextFloat() * 2f; @@ -388,8 +388,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians bool speedUp = Vector2.Distance(NPC.Center, player.Center) > 960f; - float num1006 = 0.111111117f * inertia; - int totalDustPerProjectile = 15; if (NPC.ai[0] == 0f) @@ -698,7 +696,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians else { inertia *= 1.5f; - NPC.velocity = (NPC.velocity * (inertia - 1f) + targetVector * (NPC.velocity.Length() + num1006)) / inertia; + NPC.velocity = (NPC.velocity * (inertia - 1f) + targetVector * (NPC.velocity.Length() + (0.111111117f * inertia))) / inertia; } // Throw down holy fire while charging @@ -993,65 +991,63 @@ namespace CalamityMod.NPCs.ProfanedGuardians Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; Vector2 drawPos = NPC.Center - screenPos; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); + int afterimageAmt = 5; if (NPC.ai[0] == 2f) - num153 = 10; + afterimageAmt = 10; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; if (colorOverride != null) - color38 = colorOverride.Value; + afterimageColor = colorOverride.Value; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = drawPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; - spriteBatch.Draw(texture2D15, vector43, NPC.frame, colorOverride ?? NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = drawPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, colorOverride ?? NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianCommanderGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + Color timeBasedColorLerp = Color.Lerp(Color.White, Color.Yellow, 0.5f); if (Main.remixWorld) { texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianCommanderGlowNight").Value; - color37 = Color.Cyan; + timeBasedColorLerp = Color.Cyan; } if (colorOverride != null) - color37 = colorOverride.Value; + timeBasedColorLerp = colorOverride.Value; if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = NPC.GetAlpha(color41); - color41 *= (num153 - num163) / 15f; + Color timeBasedAfterimageColor = timeBasedColorLerp; + timeBasedAfterimageColor = Color.Lerp(timeBasedAfterimageColor, Color.White, 0.5f); + timeBasedAfterimageColor = NPC.GetAlpha(timeBasedAfterimageColor); + timeBasedAfterimageColor *= (afterimageAmt - j) / 15f; if (colorOverride != null) - color41 = colorOverride.Value; + timeBasedAfterimageColor = colorOverride.Value; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 timeBasedAfterimagePos = NPC.oldPos[j] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + timeBasedAfterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + timeBasedAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; + spriteBatch.Draw(texture2D15, timeBasedAfterimagePos, NPC.frame, timeBasedAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, timeBasedColorLerp, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } // Draw laser effects @@ -1189,6 +1185,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians npcLoot.Add(ModContent.ItemType(), 10); npcLoot.Add(ModContent.ItemType(), 10); npcLoot.Add(ModContent.ItemType()); + npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 10, 15, 15, 20)); // Furniture npcLoot.Add(ModContent.ItemType(), ThankYouPainting.DropInt); @@ -1199,8 +1196,8 @@ namespace CalamityMod.NPCs.ProfanedGuardians // GFB Chicken Nugget and Divine Geode drops var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ItemID.ChickenNugget, 1, 1, 9999); - GFBOnly.Add(ModContent.ItemType(), 1, 25, 30); + GFBOnly.Add(ItemID.ChickenNugget, 1, 1, 9999, true); + GFBOnly.Add(ModContent.ItemType(), 1, 25, 30, true); } // Lore @@ -1223,18 +1220,18 @@ namespace CalamityMod.NPCs.ProfanedGuardians Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= 80f; } diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs b/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs index 1b776ed35a..eaedaa3fc6 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs @@ -35,7 +35,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians Main.npcFrameCount[NPC.type] = 10; NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { PortraitPositionXOverride = 0, PortraitScale = 0.75f, @@ -638,8 +638,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians { // Charge towards target float inertia = (bossRush || biomeEnraged) ? 57f : death ? 63f : revenge ? 66f : expertMode ? 69f : 75f; - float num1006 = 0.111111117f * inertia; - NPC.velocity = (NPC.velocity * (inertia - 1f) + targetVector * (NPC.velocity.Length() + num1006)) / inertia; + NPC.velocity = (NPC.velocity * (inertia - 1f) + targetVector * (NPC.velocity.Length() + (0.111111117f * inertia))) / inertia; } // Lay holy bombs while charging @@ -718,65 +717,63 @@ namespace CalamityMod.NPCs.ProfanedGuardians Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; Vector2 drawPos = NPC.Center - screenPos; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); + int afterimageAmt = 5; if (NPC.ai[0] == 2f) - num153 = 10; + afterimageAmt = 10; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; if (colorOverride != null) - color38 = colorOverride.Value; + afterimageColor = colorOverride.Value; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = drawPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; - spriteBatch.Draw(texture2D15, vector43, NPC.frame, colorOverride ?? NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = drawPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, colorOverride ?? NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianDefenderGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + Color timeBasedGlowColor = Color.Lerp(Color.White, Color.Yellow, 0.5f); if (Main.remixWorld) { texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianDefenderGlowNight").Value; - color37 = Color.Cyan; + timeBasedGlowColor = Color.Cyan; } if (colorOverride != null) - color37 = colorOverride.Value; + timeBasedGlowColor = colorOverride.Value; if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = NPC.GetAlpha(color41); - color41 *= (num153 - num163) / 15f; + Color timeBasedAfterimageColor = timeBasedGlowColor; + timeBasedAfterimageColor = Color.Lerp(timeBasedAfterimageColor, Color.White, 0.5f); + timeBasedAfterimageColor = NPC.GetAlpha(timeBasedAfterimageColor); + timeBasedAfterimageColor *= (afterimageAmt - j) / 15f; if (colorOverride != null) - color41 = colorOverride.Value; + timeBasedAfterimageColor = colorOverride.Value; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 timeBasedAfterimagePos = NPC.oldPos[j] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + timeBasedAfterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + timeBasedAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; + spriteBatch.Draw(texture2D15, timeBasedAfterimagePos, NPC.frame, timeBasedAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, timeBasedGlowColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } // Draw laser effects @@ -905,18 +902,18 @@ namespace CalamityMod.NPCs.ProfanedGuardians Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= 80f; } diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs b/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs index 221e5adac1..3a6d9a2e38 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs @@ -45,7 +45,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians Main.npcFrameCount[NPC.type] = 10; NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { PortraitPositionXOverride = 0, PortraitScale = 0.75f, @@ -433,78 +433,76 @@ namespace CalamityMod.NPCs.ProfanedGuardians Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; Texture2D texture2D16 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianHealerGlow2").Value; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); + int afterimageAmt = 5; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; if (colorOverride != null) - color38 = colorOverride.Value; + afterimageColor = colorOverride.Value; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; - spriteBatch.Draw(texture2D15, vector43, NPC.frame, colorOverride ?? NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, colorOverride ?? NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianHealerGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + Color timeBasedDrawColor = Color.Lerp(Color.White, Color.Yellow, 0.5f); if (Main.remixWorld) { texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianHealerGlowNight").Value; - color37 = Color.Cyan; + timeBasedDrawColor = Color.Cyan; } - Color color42 = Color.Lerp(Color.White, Color.Violet, 0.5f); + Color overrideColor = Color.Lerp(Color.White, Color.Violet, 0.5f); if (colorOverride != null) { - color37 = colorOverride.Value; - color42 = colorOverride.Value; + timeBasedDrawColor = colorOverride.Value; + overrideColor = colorOverride.Value; } if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = NPC.GetAlpha(color41); - color41 *= (num153 - num163) / 15f; + Color timeBasedAfterimageColor = timeBasedDrawColor; + timeBasedAfterimageColor = Color.Lerp(timeBasedAfterimageColor, Color.White, 0.5f); + timeBasedAfterimageColor = NPC.GetAlpha(timeBasedAfterimageColor); + timeBasedAfterimageColor *= (afterimageAmt - j) / 15f; if (colorOverride != null) - color41 = colorOverride.Value; + timeBasedAfterimageColor = colorOverride.Value; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 timeBasedAfterimagePos = NPC.oldPos[j] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + timeBasedAfterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + timeBasedAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; + spriteBatch.Draw(texture2D15, timeBasedAfterimagePos, NPC.frame, timeBasedAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - Color color43 = color42; - color43 = Color.Lerp(color43, color36, amount9); - color43 = NPC.GetAlpha(color43); - color43 *= (num153 - num163) / 15f; + Color alphaOverrideColor = overrideColor; + alphaOverrideColor = Color.Lerp(alphaOverrideColor, Color.White, 0.5f); + alphaOverrideColor = NPC.GetAlpha(alphaOverrideColor); + alphaOverrideColor *= (afterimageAmt - j) / 15f; if (colorOverride != null) - color43 = colorOverride.Value; + alphaOverrideColor = colorOverride.Value; - spriteBatch.Draw(texture2D16, vector44, NPC.frame, color43, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D16, timeBasedAfterimagePos, NPC.frame, alphaOverrideColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, timeBasedDrawColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - spriteBatch.Draw(texture2D16, vector43, NPC.frame, color42, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D16, drawLocation, NPC.frame, overrideColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } // Draw laser effects @@ -554,18 +552,18 @@ namespace CalamityMod.NPCs.ProfanedGuardians Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= 80f; } diff --git a/NPCs/ProfanedGuardians/ProfanedRocks.cs b/NPCs/ProfanedGuardians/ProfanedRocks.cs index 2f39c24a43..4919b3fdf2 100644 --- a/NPCs/ProfanedGuardians/ProfanedRocks.cs +++ b/NPCs/ProfanedGuardians/ProfanedRocks.cs @@ -340,18 +340,18 @@ namespace CalamityMod.NPCs.ProfanedGuardians { Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= (NPC.ai[2] == 6f ? 16f : 22f); } diff --git a/NPCs/Providence/ProvScreenShaderData.cs b/NPCs/Providence/ProvScreenShaderData.cs deleted file mode 100644 index 2f5e5c98bf..0000000000 --- a/NPCs/Providence/ProvScreenShaderData.cs +++ /dev/null @@ -1,56 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Graphics.Effects; -using Terraria.Graphics.Shaders; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.Providence -{ - public class ProvScreenShaderData : ScreenShaderData - { - private int ProvIndex; - - public ProvScreenShaderData(string passName) - : base(passName) - { - } - - private void UpdatePIndex() - { - int ProvType = ModContent.NPCType(); - if (ProvIndex >= 0 && Main.npc[ProvIndex].active && Main.npc[ProvIndex].type == ProvType) - { - return; - } - ProvIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ProvType) - { - ProvIndex = i; - break; - } - } - } - - public override void Update(GameTime gameTime) - { - if (ProvIndex == -1) - { - UpdatePIndex(); - if (ProvIndex == -1) - Filters.Scene["CalamityMod:Providence"].Deactivate(); - } - } - - public override void Apply() - { - UpdatePIndex(); - if (ProvIndex != -1) - { - UseTargetPosition(Main.npc[ProvIndex].Center); - } - base.Apply(); - } - } -} diff --git a/NPCs/Providence/ProvSky.cs b/NPCs/Providence/ProvSky.cs deleted file mode 100644 index a7c400cafd..0000000000 --- a/NPCs/Providence/ProvSky.cs +++ /dev/null @@ -1,115 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.GameContent; -using Terraria.Graphics.Effects; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.Providence -{ - public class ProvSky : CustomSky - { - private bool isActive = false; - private float intensity = 0f; - private int ProvIndex = -1; - - public override void Update(GameTime gameTime) - { - if (ProvIndex == -1) - { - UpdatePIndex(); - if (ProvIndex == -1) - isActive = false; - } - - if (isActive && intensity < 1f) - { - intensity += 0.01f; - } - else if (!isActive && intensity > 0f) - { - intensity -= 0.01f; - } - } - - private float GetIntensity() - { - if (UpdatePIndex()) - { - float x = 0f; - if (ProvIndex != -1) - x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[ProvIndex].Center); - - float spawnAnimationTimer = 180f; - float intensityScalar = 0.25f; - if (Main.npc[ProvIndex].Calamity().newAI[3] < spawnAnimationTimer) - intensityScalar = MathHelper.Lerp(0f, intensityScalar, Main.npc[ProvIndex].Calamity().newAI[3] / spawnAnimationTimer); - - return (Main.player[Main.myPlayer].HasBuff(ModContent.BuffType()) ? 0.75f : (1f - Utils.SmoothStep(3000f, 6000f, x)) * intensityScalar); - } - return 0f; - } - - public override Color OnTileColor(Color inColor) - { - float intensity = GetIntensity(); - return new Color(Vector4.Lerp(new Vector4(0.5f, 0.8f, 1f, 1f), inColor.ToVector4(), 1f - intensity)); - } - - private bool UpdatePIndex() - { - int ProvType = ModContent.NPCType(); - if (ProvIndex >= 0 && Main.npc[ProvIndex].active && Main.npc[ProvIndex].type == ProvType) - { - return true; - } - ProvIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ProvType) - { - ProvIndex = i; - break; - } - } - return ProvIndex != -1; - } - - public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) - { - if (maxDepth >= 0 && minDepth < 0) - { - float intensity = GetIntensity(); - Color color = Main.zenithWorld ? new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB) : Main.dayTime ? new Color(255, 200, 100) : new Color(100, 150, 255); - spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), color * intensity); - } - } - - public override float GetCloudAlpha() - { - return 0f; - } - - public override void Activate(Vector2 position, params object[] args) - { - isActive = true; - } - - public override void Deactivate(params object[] args) - { - isActive = false; - } - - public override void Reset() - { - isActive = false; - } - - public override bool IsActive() - { - return isActive || intensity > 0f; - } - } -} diff --git a/NPCs/Providence/ProvSpawnDefense.cs b/NPCs/Providence/ProvSpawnDefense.cs index 7b2755d913..2744eb6250 100644 --- a/NPCs/Providence/ProvSpawnDefense.cs +++ b/NPCs/Providence/ProvSpawnDefense.cs @@ -114,50 +114,48 @@ namespace CalamityMod.NPCs.Providence spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + int afterimageAmt = 5; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } Vector2 vector43 = NPC.Center - screenPos; vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + vector43 += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianDefenderGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + Color yellowLerp = Color.Lerp(Color.White, Color.Yellow, 0.5f); if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = NPC.GetAlpha(color41); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color yellowAfterimageColor = yellowLerp; + yellowAfterimageColor = Color.Lerp(yellowAfterimageColor, Color.White, 0.5f); + yellowAfterimageColor = NPC.GetAlpha(yellowAfterimageColor); + yellowAfterimageColor *= (float)(afterimageAmt - j) / 15f; + Vector2 yellowAfterimagePos = NPC.oldPos[j] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + yellowAfterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + yellowAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, yellowAfterimagePos, NPC.frame, yellowAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, NPC.frame, yellowLerp, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/Providence/ProvSpawnHealer.cs b/NPCs/Providence/ProvSpawnHealer.cs index c32dff5cf3..9644b52742 100644 --- a/NPCs/Providence/ProvSpawnHealer.cs +++ b/NPCs/Providence/ProvSpawnHealer.cs @@ -114,59 +114,57 @@ namespace CalamityMod.NPCs.Providence Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; Texture2D texture2D16 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianHealerGlow2").Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + int afterimageAmt = 5; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianHealerGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - Color color42 = Color.Lerp(Color.White, Color.Violet, 0.5f); + Color yellowLerp = Color.Lerp(Color.White, Color.Yellow, 0.5f); + Color violetLerp = Color.Lerp(Color.White, Color.Violet, 0.5f); if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = NPC.GetAlpha(color41); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color yellowAfterimageColor = yellowLerp; + yellowAfterimageColor = Color.Lerp(yellowAfterimageColor, Color.White, 0.5f); + yellowAfterimageColor = NPC.GetAlpha(yellowAfterimageColor); + yellowAfterimageColor *= (float)(afterimageAmt - j) / 15f; + Vector2 yellowAfterimagePos = NPC.oldPos[j] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + yellowAfterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + yellowAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, yellowAfterimagePos, NPC.frame, yellowAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - Color color43 = color42; - color43 = Color.Lerp(color43, color36, amount9); - color43 = NPC.GetAlpha(color43); - color43 *= (float)(num153 - num163) / 15f; - spriteBatch.Draw(texture2D16, vector44, NPC.frame, color43, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color violetAfterimageColor = violetLerp; + violetAfterimageColor = Color.Lerp(violetAfterimageColor, Color.White, 0.5f); + violetAfterimageColor = NPC.GetAlpha(violetAfterimageColor); + violetAfterimageColor *= (float)(afterimageAmt - j) / 15f; + spriteBatch.Draw(texture2D16, yellowAfterimagePos, NPC.frame, violetAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, yellowLerp, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - spriteBatch.Draw(texture2D16, vector43, NPC.frame, color42, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D16, drawLocation, NPC.frame, violetLerp, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/Providence/ProvSpawnOffense.cs b/NPCs/Providence/ProvSpawnOffense.cs index e80c1bb8c7..45fbb115f9 100644 --- a/NPCs/Providence/ProvSpawnOffense.cs +++ b/NPCs/Providence/ProvSpawnOffense.cs @@ -114,52 +114,50 @@ namespace CalamityMod.NPCs.Providence spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + int afterimageAmt = 5; if (NPC.ai[0] == 2f) - num153 = 10; + afterimageAmt = 10; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianCommanderGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + Color yellowLerpColor = Color.Lerp(Color.White, Color.Yellow, 0.5f); if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = NPC.GetAlpha(color41); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color yellowAfterimageColor = yellowLerpColor; + yellowAfterimageColor = Color.Lerp(yellowAfterimageColor, Color.White, 0.5f); + yellowAfterimageColor = NPC.GetAlpha(yellowAfterimageColor); + yellowAfterimageColor *= (float)(afterimageAmt - j) / 15f; + Vector2 yellowAfterimagePos = NPC.oldPos[j] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + yellowAfterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + yellowAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, yellowAfterimagePos, NPC.frame, yellowAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, yellowLerpColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index cbfbac5a39..1b0547687b 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -37,7 +37,6 @@ using Terraria.DataStructures; using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.GameContent.ItemDropRules; -using Terraria.Graphics.Effects; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -88,10 +87,12 @@ namespace CalamityMod.NPCs.Providence private int phaseChange = 0; private int frameUsed = 0; private int healTimer = 0; - internal bool challenge = Main.expertMode/* && Main.netMode == NetmodeID.SinglePlayer*/; //Used to determine if Profaned Soul Crystal should drop, couldn't figure out mp mems always dropping it so challenge is singleplayer only. + internal bool challenge = Main.expertMode; //Used to determine if Profaned Soul Crystal should drop, couldn't figure out mp mems always dropping it so challenge is singleplayer only. internal bool hasTakenDaytimeDamage = false; + public static bool shouldDrawInfernoBorder = true; //This is only here for other mods to disable it if they don't want it drawing. public bool Dying = false; public int DeathAnimationTimer; + public static float borderRadius = 3000f; //Sounds public static readonly SoundStyle SpawnSound = new("CalamityMod/Sounds/Custom/Providence/ProvidenceSpawn") { Volume = 1.2f }; @@ -118,7 +119,7 @@ namespace CalamityMod.NPCs.Providence Main.npcFrameCount[NPC.type] = 3; NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.2f, PortraitScale = 0.32f, @@ -189,6 +190,8 @@ namespace CalamityMod.NPCs.Providence writer.Write(SoundWarningLevel); writer.Write(Dying); writer.Write(DeathAnimationTimer); + writer.Write(borderRadius); + writer.Write(shouldDrawInfernoBorder); for (int i = 0; i < 4; i++) writer.Write(NPC.Calamity().newAI[i]); } @@ -214,6 +217,9 @@ namespace CalamityMod.NPCs.Providence SoundWarningLevel = reader.ReadSingle(); Dying = reader.ReadBoolean(); DeathAnimationTimer = reader.ReadInt32(); + borderRadius = reader.ReadSingle(); + shouldDrawInfernoBorder = reader.ReadBoolean(); + for (int i = 0; i < 4; i++) NPC.Calamity().newAI[i] = reader.ReadSingle(); @@ -227,6 +233,10 @@ namespace CalamityMod.NPCs.Providence public override void AI() { + // Set the border drawing to true if it isn't set to true + // Can happen when another mod sets to false for a difficulty and that difficulty is then toggled off. + shouldDrawInfernoBorder = true; + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); // whoAmI variable for Guardians and other things @@ -369,7 +379,7 @@ namespace CalamityMod.NPCs.Providence float distanceX = Math.Abs(NPC.Center.X - player.Center.X); // Inflict Holy Inferno if target is too far away - float burnIntensity = CalculateBurnIntensity(); + float burnIntensity = CalculateBurnIntensity(attackDelayAfterCocoon); if (!player.dead && player.active && !player.creativeGodMode && !Dying) { @@ -597,7 +607,7 @@ namespace CalamityMod.NPCs.Providence Vector2 dustLineEnd = NPC.Center; Vector2 currentDustPos = default; Vector2 spinningpoint = new Vector2(0f, -3f).RotatedByRandom(MathHelper.Pi); - Vector2 value5 = new Vector2(2.1f, 2f); + Vector2 dustVelocityMult = new Vector2(2.1f, 2f); Color dustColor = Main.hslToRgb(Main.rgbToHsl(new Color(255, 200, Main.DiscoB)).X, 1f, 0.5f); dustColor.A = 255; for (int i = 0; i < maxHealDustIterations; i++) @@ -607,7 +617,7 @@ namespace CalamityMod.NPCs.Providence currentDustPos = Vector2.Lerp(dustLineStart, dustLineEnd, i / (float)maxHealDustIterations); int dust = Dust.NewDust(currentDustPos, 0, 0, 267, 0f, 0f, 0, dustColor, 1f); Main.dust[dust].position = currentDustPos; - Main.dust[dust].velocity = spinningpoint.RotatedBy(MathHelper.TwoPi * i / maxHealDustIterations) * value5 * (0.8f + Main.rand.NextFloat() * 0.4f) + NPC.velocity; + Main.dust[dust].velocity = spinningpoint.RotatedBy(MathHelper.TwoPi * i / maxHealDustIterations) * dustVelocityMult * (0.8f + Main.rand.NextFloat() * 0.4f) + NPC.velocity; Main.dust[dust].noGravity = true; Main.dust[dust].scale = 1f; Main.dust[dust].fadeIn = Main.rand.NextFloat() * 2f; @@ -678,8 +688,8 @@ namespace CalamityMod.NPCs.Providence if (NPC.life > 0) { - int num660 = (int)(NPC.lifeMax * 0.66); - if ((NPC.life + num660) < bossLife) + int guardianHealthThreshold = (int)(NPC.lifeMax * 0.66); + if ((NPC.life + guardianHealthThreshold) < bossLife) { bossLife = NPC.life; SoundEngine.PlaySound(SoundID.Item74, NPC.Center); @@ -743,17 +753,17 @@ namespace CalamityMod.NPCs.Providence calamityGlobalNPC.newAI[0] += 1f; // Distance needed from target to change direction - float num851 = 800f; + float changeDirectionThreshold = 800f; // Increase distance from target when firing molten blasts or holy bombs bool stayAwayFromTarget = AIState == (int)Phase.MoltenBlobs || AIState == (int)Phase.HolyBomb; if (stayAwayFromTarget) - num851 += death ? 240f : revenge ? 180f : 120f; + changeDirectionThreshold += death ? 240f : revenge ? 180f : 120f; // Change X movement path if far enough away from target - if (NPC.Center.X < player.Center.X && flightPath < 0 && distanceX > num851) + if (NPC.Center.X < player.Center.X && flightPath < 0 && distanceX > changeDirectionThreshold) flightPath = 0; - if (NPC.Center.X > player.Center.X && flightPath > 0 && distanceX > num851) + if (NPC.Center.X > player.Center.X && flightPath > 0 && distanceX > changeDirectionThreshold) flightPath = 0; // Velocity and acceleration @@ -796,10 +806,10 @@ namespace CalamityMod.NPCs.Providence if (NPC.velocity.X < -velocity) NPC.velocity.X = -velocity; - float num855 = player.position.Y - (NPC.position.Y + NPC.height); - if (num855 < (laserPhaseSlow ? 150f : 200f)) // 150 + float moveUpThreshold = player.position.Y - (NPC.position.Y + NPC.height); + if (moveUpThreshold < (laserPhaseSlow ? 150f : 200f)) // 150 NPC.velocity.Y -= Main.getGoodWorld ? 0.4f : 0.2f; - if (num855 > (laserPhaseSlow ? 200f : 250f)) // 200 + if (moveUpThreshold > (laserPhaseSlow ? 200f : 250f)) // 200 NPC.velocity.Y += Main.getGoodWorld ? 0.4f : 0.2f; float speedCap = laserPhaseSlow ? 2f : 6f; @@ -1045,21 +1055,21 @@ namespace CalamityMod.NPCs.Providence { Vector2 npcCenter = NPC.Center; npcCenter.X += NPC.velocity.X * 7f; - float num857 = player.position.X + player.width * 0.5f - npcCenter.X; - float num858 = player.Center.Y - npcCenter.Y; - float num859 = (float)Math.Sqrt(num857 * num857 + num858 * num858); + float playerXDist = player.position.X + player.width * 0.5f - npcCenter.X; + float playerYDist = player.Center.Y - npcCenter.Y; + float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); float velocityBoost = death ? 4f * (1f - lifeRatio) : 2.5f * (1f - lifeRatio); - float num860 = (expertMode ? 10.25f : 9f) + velocityBoost; + float projSpeed = (expertMode ? 10.25f : 9f) + velocityBoost; if (revenge) - num860 *= 1.15f; + projSpeed *= 1.15f; - num859 = num860 / num859; - num857 *= num859; - num858 *= num859; + playerDistance = projSpeed / playerDistance; + playerXDist *= playerDistance; + playerYDist *= playerDistance; - Projectile.NewProjectile(NPC.GetSource_FromAI(), npcCenter.X, npcCenter.Y, num857, num858, ModContent.ProjectileType(), holyBlastDamage, 0f, Main.myPlayer, player.position.X, player.position.Y); + Projectile.NewProjectile(NPC.GetSource_FromAI(), npcCenter.X, npcCenter.Y, playerXDist, playerYDist, ModContent.ProjectileType(), holyBlastDamage, 0f, Main.myPlayer, player.position.X, player.position.Y); } } else if (NPC.ai[3] < 0f) @@ -1319,29 +1329,29 @@ namespace CalamityMod.NPCs.Providence SoundEngine.PlaySound(SoundID.DD2_BetsyFireballImpact, player2.Center); player2.AddBuff(ModContent.BuffType(), 3000, true); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(player2.position.X, player2.position.Y), + int icarusFollyDust = Dust.NewDust(new Vector2(player2.position.X, player2.position.Y), player2.width, player2.height, dustType, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - Main.dust[num622].noGravity = true; + Main.dust[icarusFollyDust].velocity *= 3f; + Main.dust[icarusFollyDust].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[icarusFollyDust].scale = 0.5f; + Main.dust[icarusFollyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 60; num623++) + for (int j = 0; j < 60; j++) { - int num624 = Dust.NewDust(new Vector2(player2.position.X, player2.position.Y), + int icarusFollyDust2 = Dust.NewDust(new Vector2(player2.position.X, player2.position.Y), player2.width, player2.height, dustType, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(player2.position.X, player2.position.Y), + Main.dust[icarusFollyDust2].noGravity = true; + Main.dust[icarusFollyDust2].velocity *= 5f; + icarusFollyDust2 = Dust.NewDust(new Vector2(player2.position.X, player2.position.Y), player2.width, player2.height, dustType, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - Main.dust[num624].noGravity = true; + Main.dust[icarusFollyDust2].velocity *= 2f; + Main.dust[icarusFollyDust2].noGravity = true; } } } @@ -1381,23 +1391,23 @@ namespace CalamityMod.NPCs.Providence { Vector2 npcCenter = NPC.Center; npcCenter.X += NPC.velocity.X * 7f; - float num857 = player.position.X + player.width * 0.5f - npcCenter.X; - float num858 = player.Center.Y - npcCenter.Y; - float num859 = (float)Math.Sqrt(num857 * num857 + num858 * num858); + float playerXDist = player.position.X + player.width * 0.5f - npcCenter.X; + float playerYDist = player.Center.Y - npcCenter.Y; + float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); float shootBoost2 = death ? 4f * (1f - lifeRatio) : 2.5f * (1f - lifeRatio); - float num860 = (expertMode ? 10.25f : 9f) + shootBoost2; + float projSpeed = (expertMode ? 10.25f : 9f) + shootBoost2; if (bossRush) - num860 = 12.75f; + projSpeed = 12.75f; if (revenge) - num860 *= 1.15f; + projSpeed *= 1.15f; - num859 = num860 / num859; - num857 *= num859; - num858 *= num859; + playerDistance = projSpeed / playerDistance; + playerXDist *= playerDistance; + playerYDist *= playerDistance; - Projectile.NewProjectile(NPC.GetSource_FromAI(), npcCenter.X, npcCenter.Y, num857 * 0.1f, num858, ModContent.ProjectileType(), moltenBlastDamage, 0f, Main.myPlayer, player.position.X, player.position.Y); + Projectile.NewProjectile(NPC.GetSource_FromAI(), npcCenter.X, npcCenter.Y, playerXDist * 0.1f, playerYDist, ModContent.ProjectileType(), moltenBlastDamage, 0f, Main.myPlayer, player.position.X, player.position.Y); } } else if (NPC.ai[3] < 0f) @@ -1568,7 +1578,7 @@ namespace CalamityMod.NPCs.Providence Vector2 dustLineEnd = crystalSpawnPos; Vector2 currentDustPos = default; Vector2 spinningpoint = new Vector2(0f, -3f).RotatedByRandom(MathHelper.Pi); - Vector2 value5 = new Vector2(2.1f, 2f); + Vector2 dustVelocityMult = new Vector2(2.1f, 2f); int dustSpawned = 0; int maxDustLines = 3; int blue = Main.DiscoB; @@ -1583,7 +1593,7 @@ namespace CalamityMod.NPCs.Providence dustColor.A = 255; int dust = Dust.NewDust(currentDustPos, 0, 0, 267, 0f, 0f, 0, dustColor, 1f); Main.dust[dust].position = currentDustPos + new Vector2(32f, 32f).RotatedByRandom(MathHelper.TwoPi) * i; - Main.dust[dust].velocity = spinningpoint.RotatedBy(MathHelper.TwoPi * j / maxHealDustIterations) * value5 * (0.8f + Main.rand.NextFloat() * 0.4f); + Main.dust[dust].velocity = spinningpoint.RotatedBy(MathHelper.TwoPi * j / maxHealDustIterations) * dustVelocityMult * (0.8f + Main.rand.NextFloat() * 0.4f); Main.dust[dust].noGravity = true; Main.dust[dust].scale = 1f + i; Main.dust[dust].fadeIn = Main.rand.NextFloat() * 2f; @@ -1808,7 +1818,7 @@ namespace CalamityMod.NPCs.Providence } } - public float CalculateBurnIntensity() + public float CalculateBurnIntensity(float attackDelayAfterCocoon = 1f) { float distanceToTarget = Vector2.Distance(Main.player[NPC.target].Center, NPC.Center); float aiTimer = NPC.ai[3]; @@ -1825,6 +1835,7 @@ namespace CalamityMod.NPCs.Providence if (CalamityGlobalNPC.holyBossAttacker != -1 && Main.npc[CalamityGlobalNPC.holyBossAttacker].active) guardianAlive = true; + if (CalamityGlobalNPC.holyBossDefender != -1 && Main.npc[CalamityGlobalNPC.holyBossDefender].active) guardianAlive = true; @@ -1837,16 +1848,23 @@ namespace CalamityMod.NPCs.Providence // It is determined based on how much time has elapsed during the attack thus far, specifically for the two cocoon attacks. // This shave-off does not happen when guardians are present. float shorterDistanceFade = Utils.GetLerpValue(0f, 120f, aiTimer, true); + //Distance does not get shorter if in GFB / Guardians are alive if (!guardianAlive && NPC.localAI[1] < (float)BossMode.Red) { maxDistance = baseDistance; if (AIState == (int)Phase.FlameCocoon || AIState == (int)Phase.SpearCocoon) maxDistance -= shorterDistance * shorterDistanceFade; + else if (attackDelayAfterCocoon > 1f) + maxDistance -= shorterDistance * (NPC.localAI[2] / attackDelayAfterCocoon); } float drawFireDistanceStart = maxDistance - 800f; - return Utils.GetLerpValue(drawFireDistanceStart, maxDistance, distanceToTarget, true); + float previousBorderEnd = borderRadius; + float clampedDistance = MathHelper.Clamp(maxDistance, previousBorderEnd - 10, previousBorderEnd + 10); + // Only set the border distance if it's not called from playermisceffects, that way it has mod compatability + borderRadius = clampedDistance; + return Utils.GetLerpValue(drawFireDistanceStart, clampedDistance, distanceToTarget, true); } private void DespawnSpecificProjectiles(bool dying = false) @@ -1955,6 +1973,11 @@ namespace CalamityMod.NPCs.Providence Providence prov = info.npc.ModNPC(); return !prov.hasTakenDaytimeDamage; }, ModContent.ItemType(), 1, 4, 4, desc: DropHelper.ProvidenceNightText); + npcLoot.AddIf(info => + { + Providence prov = info.npc.ModNPC(); + return !prov.hasTakenDaytimeDamage; + }, ModContent.ItemType(), 1, 30, 40); // Normal drops: Everything that would otherwise be in the bag var normalOnly = npcLoot.DefineNormalOnlyDropSet(); @@ -1993,8 +2016,8 @@ namespace CalamityMod.NPCs.Providence // GFB ASE and Blasphemous Donut drops var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ModContent.ItemType(), 1, 1, 99); - GFBOnly.Add(ModContent.ItemType(), 1, 1117, 2201); // reference to the versions the guards were added and got their latest resprites + GFBOnly.Add(ModContent.ItemType(), 1, 1, 99, true); + GFBOnly.Add(ModContent.ItemType(), 1, 1117, 2201, true); // reference to the versions the guards were added and got their latest resprites } // Lore @@ -2116,16 +2139,16 @@ namespace CalamityMod.NPCs.Providence if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < maxAfterimages; num155 += 2) + for (int i = 1; i < maxAfterimages; i += 2) { Color AfterimageColor = drawColor; AfterimageColor = Color.Lerp(AfterimageColor, BaseColor, Brightness); AfterimageColor = NPC.GetAlpha(AfterimageColor); - AfterimageColor *= (maxAfterimages - num155) / 15f; + AfterimageColor *= (maxAfterimages - i) / 15f; if (colorOverride != null) AfterimageColor = colorOverride.Value; - Vector2 AfterimageBodyPosition = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + Vector2 AfterimageBodyPosition = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; AfterimageBodyPosition -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; AfterimageBodyPosition += RotationCenter * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; spriteBatch.Draw(texture, AfterimageBodyPosition, NPC.frame, AfterimageColor, NPC.rotation, RotationCenter, NPC.scale, spriteEffects, 0f); @@ -2180,16 +2203,16 @@ namespace CalamityMod.NPCs.Providence if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < maxAfterimages; num163++) + for (int j = 1; j < maxAfterimages; j++) { Color AfterimageWingColor = BaseWingColor; AfterimageWingColor = Color.Lerp(AfterimageWingColor, BaseColor, Brightness); AfterimageWingColor = NPC.GetAlpha(AfterimageWingColor); - AfterimageWingColor *= (maxAfterimages - num163) / 15f; + AfterimageWingColor *= (maxAfterimages - j) / 15f; if (colorOverride != null) AfterimageWingColor = colorOverride.Value; - Vector2 AfterimageGlowPosition = NPC.oldPos[num163] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + Vector2 AfterimageGlowPosition = NPC.oldPos[j] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; AfterimageGlowPosition -= new Vector2(textureGlow.Width, textureGlow.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; AfterimageGlowPosition += RotationCenter * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; spriteBatch.Draw(textureGlow, AfterimageGlowPosition, NPC.frame, AfterimageWingColor, NPC.rotation, RotationCenter, NPC.scale, spriteEffects, 0f); @@ -2197,7 +2220,7 @@ namespace CalamityMod.NPCs.Providence Color AfterimageCrystalColor = BaseCrystalColor; AfterimageCrystalColor = Color.Lerp(AfterimageCrystalColor, BaseColor, Brightness); AfterimageCrystalColor = NPC.GetAlpha(AfterimageCrystalColor); - AfterimageCrystalColor *= (maxAfterimages - num163) / 15f; + AfterimageCrystalColor *= (maxAfterimages - j) / 15f; if (colorOverride != null) AfterimageCrystalColor = colorOverride.Value; spriteBatch.Draw(textureGlow2, AfterimageGlowPosition, NPC.frame, AfterimageCrystalColor, NPC.rotation, RotationCenter, NPC.scale, spriteEffects, 0f); @@ -2335,7 +2358,6 @@ namespace CalamityMod.NPCs.Providence Vector2 pos = NPC.Center + NPC.gfxOffY * Vector2.UnitY - Main.screenPosition; Main.spriteBatch.Draw(heatTex, shieldDrawPos, null, Color.White, 0, heatTex.Size() / 2f, shieldScale * scaleMult * 0.5f, 0, 0); } - return false; } diff --git a/NPCs/Ravager/FlamePillar.cs b/NPCs/Ravager/FlamePillar.cs index e6ed4e136f..4b61c255ff 100644 --- a/NPCs/Ravager/FlamePillar.cs +++ b/NPCs/Ravager/FlamePillar.cs @@ -123,9 +123,15 @@ namespace CalamityMod.NPCs.Ravager int damage = NPC.GetProjectileDamage(type); Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 0f, 0f); } + NPC.ai[2] += 1f; NPC.localAI[0] = 0f; + NPC.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (NPC.netSpam >= 10) + NPC.netSpam = 9; } } else @@ -143,17 +149,17 @@ namespace CalamityMod.NPCs.Ravager spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/Ravager/FlamePillarGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + Color flameBlue = Color.Lerp(Color.White, Color.Cyan, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, flameBlue, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -170,44 +176,44 @@ namespace CalamityMod.NPCs.Ravager NPC.height = 180; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 30; num621++) + for (int i = 0; i < 30; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 135, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int iceFlame = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 135, 0f, 0f, 100, default, 2f); + Main.dust[iceFlame].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[iceFlame].scale = 0.5f; + Main.dust[iceFlame].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Stone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int rockDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Stone, 0f, 0f, 100, default, 3f); + Main.dust[rockDust].noGravity = true; + Main.dust[rockDust].velocity *= 5f; + rockDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[rockDust].velocity *= 2f; } } else { - for (int num621 = 0; num621 < 2; num621++) + for (int i = 0; i < 2; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int iceFlame = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[iceFlame].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[iceFlame].scale = 0.5f; + Main.dust[iceFlame].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 2; num623++) + for (int j = 0; j < 2; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Stone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int rockDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Stone, 0f, 0f, 100, default, 3f); + Main.dust[rockDust].noGravity = true; + Main.dust[rockDust].velocity *= 5f; + rockDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[rockDust].velocity *= 2f; } } } diff --git a/NPCs/Ravager/RavagerBody.cs b/NPCs/Ravager/RavagerBody.cs index d2650a1b17..49b2079dd2 100644 --- a/NPCs/Ravager/RavagerBody.cs +++ b/NPCs/Ravager/RavagerBody.cs @@ -49,7 +49,7 @@ namespace CalamityMod.NPCs.Ravager { Main.npcFrameCount[NPC.type] = 7; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.5f, PortraitPositionYOverride = -40f, @@ -825,7 +825,12 @@ namespace CalamityMod.NPCs.Ravager if (Vector2.Distance(NPC.Center, player.Center) > distanceFromTarget) { NPC.active = false; + NPC.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + if (NPC.netSpam >= 10) + NPC.netSpam = 9; } } } @@ -853,35 +858,35 @@ namespace CalamityMod.NPCs.Ravager spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); - Vector2 vector = center - screenPos; - vector -= new Vector2(ModContent.Request("CalamityMod/NPCs/Ravager/RavagerBodyGlow").Value.Width, ModContent.Request("CalamityMod/NPCs/Ravager/RavagerBodyGlow").Value.Height / Main.npcFrameCount[NPC.type]) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); - Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Color.Blue); - spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Ravager/RavagerBodyGlow").Value, vector, - NPC.frame, color, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); + Vector2 glowmaskPosition = center - screenPos; + glowmaskPosition -= new Vector2(ModContent.Request("CalamityMod/NPCs/Ravager/RavagerBodyGlow").Value.Width, ModContent.Request("CalamityMod/NPCs/Ravager/RavagerBodyGlow").Value.Height / Main.npcFrameCount[NPC.type]) * 1f / 2f; + glowmaskPosition += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + Color glowmaskColor = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Color.Blue); + spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Ravager/RavagerBodyGlow").Value, glowmaskPosition, + NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); float legOffset = 20f; float headOffset = 75f; - Color color2 = Lighting.GetColor((int)center.X / 16, (int)(center.Y / 16f)); + Color drawLighting = Lighting.GetColor((int)center.X / 16, (int)(center.Y / 16f)); if (NPC.IsABestiaryIconDummy) { - color2 = Color.White; + drawLighting = Color.White; legOffset = 60f; headOffset = 0f; } spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Ravager/RavagerLegRight").Value, new Vector2(center.X - screenPos.X + NPC.scale * 28f, center.Y - screenPos.Y + legOffset), //72 new Rectangle?(new Rectangle(0, 0, ModContent.Request("CalamityMod/NPCs/Ravager/RavagerLegRight").Value.Width, ModContent.Request("CalamityMod/NPCs/Ravager/RavagerLegRight").Value.Height)), - color2, 0f, default, NPC.scale, SpriteEffects.None, 0f); + drawLighting, 0f, default, NPC.scale, SpriteEffects.None, 0f); spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Ravager/RavagerLegLeft").Value, new Vector2(center.X - screenPos.X - NPC.scale * 112f, center.Y - screenPos.Y + legOffset), //72 new Rectangle?(new Rectangle(0, 0, ModContent.Request("CalamityMod/NPCs/Ravager/RavagerLegLeft").Value.Width, ModContent.Request("CalamityMod/NPCs/Ravager/RavagerLegLeft").Value.Height)), - color2, 0f, default, NPC.scale, SpriteEffects.None, 0f); + drawLighting, 0f, default, NPC.scale, SpriteEffects.None, 0f); if (NPC.AnyNPCs(ModContent.NPCType()) || NPC.IsABestiaryIconDummy) { spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Ravager/RavagerHead").Value, new Vector2(center.X - screenPos.X - NPC.scale * 70f, center.Y - screenPos.Y - NPC.scale * headOffset), new Rectangle?(new Rectangle(0, 0, ModContent.Request("CalamityMod/NPCs/Ravager/RavagerHead").Value.Width, ModContent.Request("CalamityMod/NPCs/Ravager/RavagerHead").Value.Height)), - color2, 0f, default, NPC.scale, SpriteEffects.None, 0f); + drawLighting, 0f, default, NPC.scale, SpriteEffects.None, 0f); } } @@ -1042,10 +1047,10 @@ namespace CalamityMod.NPCs.Ravager // GFB Sans drops var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ItemID.Skull); - GFBOnly.Add(ItemID.Bone, 1, 1, 9999); - GFBOnly.Add(ItemID.Hotdog, 1, 1, 9999); - GFBOnly.Add(ModContent.ItemType(), 1, 1, 9999); + GFBOnly.Add(ItemID.Skull, hideLootReport: true); + GFBOnly.Add(ItemID.Bone, 1, 1, 9999, true); + GFBOnly.Add(ItemID.Hotdog, 1, 1, 9999, true); + GFBOnly.Add(ModContent.ItemType(), 1, 1, 9999, true); } // Lore diff --git a/NPCs/Ravager/RavagerClawLeft.cs b/NPCs/Ravager/RavagerClawLeft.cs index 7fe4eb3640..202654ffa7 100644 --- a/NPCs/Ravager/RavagerClawLeft.cs +++ b/NPCs/Ravager/RavagerClawLeft.cs @@ -81,14 +81,13 @@ namespace CalamityMod.NPCs.Ravager if (NPC.ai[0] == 0f) { NPC.noTileCollide = true; - float num659 = 36f; - Vector2 vector79 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num660 = Main.npc[CalamityGlobalNPC.scavenger].Center.X - vector79.X; - float num661 = Main.npc[CalamityGlobalNPC.scavenger].Center.Y - vector79.Y; - num660 -= 120f; - num661 += 50f; - float num662 = (float)Math.Sqrt(num660 * num660 + num661 * num661); - if (num662 < 12f + num659) + Vector2 npcCenter = new Vector2(NPC.Center.X, NPC.Center.Y); + float ravBodyXDist = Main.npc[CalamityGlobalNPC.scavenger].Center.X - npcCenter.X; + float ravBodyYDist = Main.npc[CalamityGlobalNPC.scavenger].Center.Y - npcCenter.Y; + ravBodyXDist -= 120f; + ravBodyYDist += 50f; + float ravBodyDistance = (float)Math.Sqrt(ravBodyXDist * ravBodyXDist + ravBodyYDist * ravBodyYDist); + if (ravBodyDistance < 48f) { NPC.rotation = 0f; NPC.Center = Main.npc[CalamityGlobalNPC.scavenger].Center + new Vector2(-120f, 50f); @@ -127,9 +126,9 @@ namespace CalamityMod.NPCs.Ravager } else { - num662 = num659 / num662; - NPC.velocity.X = num660 * num662; - NPC.velocity.Y = num661 * num662; + ravBodyDistance = 36f / ravBodyDistance; + NPC.velocity.X = ravBodyXDist * ravBodyDistance; + NPC.velocity.Y = ravBodyYDist * ravBodyDistance; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); } } @@ -139,26 +138,26 @@ namespace CalamityMod.NPCs.Ravager NPC.noTileCollide = true; NPC.collideX = false; NPC.collideY = false; - float num663 = 12f; + float clawSpeed = 12f; if (NPC.life < NPC.lifeMax / 2 || death) { - num663 += 2f; + clawSpeed += 2f; } if (NPC.life < NPC.lifeMax / 3 || death) { - num663 += 2f; + clawSpeed += 2f; } if (NPC.life < NPC.lifeMax / 5 || death) { - num663 += 5f; + clawSpeed += 5f; } - Vector2 vector80 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num664 = Main.player[NPC.target].Center.X - vector80.X; - float num665 = Main.player[NPC.target].Center.Y - vector80.Y; - float num666 = (float)Math.Sqrt(num664 * num664 + num665 * num665); - num666 = num663 / num666; - NPC.velocity.X = num664 * num666; - NPC.velocity.Y = num665 * num666; + Vector2 npcCenterAttack = new Vector2(NPC.Center.X, NPC.Center.Y); + float targetX = Main.player[NPC.target].Center.X - npcCenterAttack.X; + float targetY = Main.player[NPC.target].Center.Y - npcCenterAttack.Y; + float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); + targetDistance = clawSpeed / targetDistance; + NPC.velocity.X = targetX * targetDistance; + NPC.velocity.Y = targetY * targetDistance; NPC.ai[0] = 2f; NPC.rotation = (float)Math.Atan2(-NPC.velocity.Y, -NPC.velocity.X); } @@ -186,15 +185,15 @@ namespace CalamityMod.NPCs.Ravager NPC.noTileCollide = false; } } - Vector2 vector81 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num667 = Main.npc[CalamityGlobalNPC.scavenger].Center.X - vector81.X; - float num668 = Main.npc[CalamityGlobalNPC.scavenger].Center.Y - vector81.Y; - num667 += Main.npc[CalamityGlobalNPC.scavenger].velocity.X; - num668 += Main.npc[CalamityGlobalNPC.scavenger].velocity.Y; - num668 += 40f; - num667 -= 110f; - float num669 = (float)Math.Sqrt(num667 * num667 + num668 * num668); - if ((num669 > (death ? 900f : 700f) || NPC.collideX || NPC.collideY) | NPC.justHit) + Vector2 npcCenterRetract = new Vector2(NPC.Center.X, NPC.Center.Y); + float bodyReturnXDist = Main.npc[CalamityGlobalNPC.scavenger].Center.X - npcCenterRetract.X; + float bodyReturnYDist = Main.npc[CalamityGlobalNPC.scavenger].Center.Y - npcCenterRetract.Y; + bodyReturnXDist += Main.npc[CalamityGlobalNPC.scavenger].velocity.X; + bodyReturnYDist += Main.npc[CalamityGlobalNPC.scavenger].velocity.Y; + bodyReturnYDist += 40f; + bodyReturnXDist -= 110f; + float bodyReturnDistance = (float)Math.Sqrt(bodyReturnXDist * bodyReturnXDist + bodyReturnYDist * bodyReturnYDist); + if ((bodyReturnDistance > (death ? 900f : 700f) || NPC.collideX || NPC.collideY) | NPC.justHit) { NPC.noTileCollide = true; NPC.ai[0] = 0f; @@ -203,45 +202,44 @@ namespace CalamityMod.NPCs.Ravager else if (NPC.ai[0] == 3f) { NPC.noTileCollide = true; - float num671 = 12f; - float num672 = 0.4f; - Vector2 vector82 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num673 = Main.player[NPC.target].Center.X - vector82.X; - float num674 = Main.player[NPC.target].Center.Y - vector82.Y; - float num675 = (float)Math.Sqrt(num673 * num673 + num674 * num674); - num675 = num671 / num675; - num673 *= num675; - num674 *= num675; - if (NPC.velocity.X < num673) + float velocityMult = 0.4f; + Vector2 clawCenter = new Vector2(NPC.Center.X, NPC.Center.Y); + float playerX = Main.player[NPC.target].Center.X - clawCenter.X; + float playerY = Main.player[NPC.target].Center.Y - clawCenter.Y; + float playerDist = (float)Math.Sqrt(playerX * playerX + playerY * playerY); + playerDist = 12f / playerDist; + playerX *= playerDist; + playerY *= playerDist; + if (NPC.velocity.X < playerX) { - NPC.velocity.X += num672; - if (NPC.velocity.X < 0f && num673 > 0f) + NPC.velocity.X += velocityMult; + if (NPC.velocity.X < 0f && playerX > 0f) { - NPC.velocity.X += num672 * 2f; + NPC.velocity.X += velocityMult * 2f; } } - else if (NPC.velocity.X > num673) + else if (NPC.velocity.X > playerX) { - NPC.velocity.X -= num672; - if (NPC.velocity.X > 0f && num673 < 0f) + NPC.velocity.X -= velocityMult; + if (NPC.velocity.X > 0f && playerX < 0f) { - NPC.velocity.X -= num672 * 2f; + NPC.velocity.X -= velocityMult * 2f; } } - if (NPC.velocity.Y < num674) + if (NPC.velocity.Y < playerY) { - NPC.velocity.Y += num672; - if (NPC.velocity.Y < 0f && num674 > 0f) + NPC.velocity.Y += velocityMult; + if (NPC.velocity.Y < 0f && playerY > 0f) { - NPC.velocity.Y += num672 * 2f; + NPC.velocity.Y += velocityMult * 2f; } } - else if (NPC.velocity.Y > num674) + else if (NPC.velocity.Y > playerY) { - NPC.velocity.Y -= num672; - if (NPC.velocity.Y > 0f && num674 < 0f) + NPC.velocity.Y -= velocityMult; + if (NPC.velocity.Y > 0f && playerY < 0f) { - NPC.velocity.Y -= num672 * 2f; + NPC.velocity.Y -= velocityMult * 2f; } } NPC.rotation = (float)Math.Atan2(-NPC.velocity.Y, -NPC.velocity.X); @@ -302,11 +300,11 @@ namespace CalamityMod.NPCs.Ravager { if (NPC.life > 0) { - int num285 = 0; - while (num285 < hit.Damage / NPC.lifeMax * 100.0) + int dustCounter = 0; + while (dustCounter < hit.Damage / NPC.lifeMax * 100.0) { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f, 0, default, 1f); - num285++; + dustCounter++; } } else diff --git a/NPCs/Ravager/RavagerClawRight.cs b/NPCs/Ravager/RavagerClawRight.cs index 91518ff377..205e010f02 100644 --- a/NPCs/Ravager/RavagerClawRight.cs +++ b/NPCs/Ravager/RavagerClawRight.cs @@ -82,14 +82,13 @@ namespace CalamityMod.NPCs.Ravager if (NPC.ai[0] == 0f) { NPC.noTileCollide = true; - float num659 = 36f; - Vector2 vector79 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num660 = Main.npc[CalamityGlobalNPC.scavenger].Center.X - vector79.X; - float num661 = Main.npc[CalamityGlobalNPC.scavenger].Center.Y - vector79.Y; - num660 += 120f; - num661 += 50f; - float num662 = (float)Math.Sqrt(num660 * num660 + num661 * num661); - if (num662 < 12f + num659) + Vector2 npcCenter = new Vector2(NPC.Center.X, NPC.Center.Y); + float ravBodyXDist = Main.npc[CalamityGlobalNPC.scavenger].Center.X - npcCenter.X; + float ravBodyYDist = Main.npc[CalamityGlobalNPC.scavenger].Center.Y - npcCenter.Y; + ravBodyXDist += 120f; + ravBodyYDist += 50f; + float ravBodyDistance = (float)Math.Sqrt(ravBodyXDist * ravBodyXDist + ravBodyYDist * ravBodyYDist); + if (ravBodyDistance < 48f) { NPC.rotation = 0f; NPC.Center = Main.npc[CalamityGlobalNPC.scavenger].Center + new Vector2(120f, 50f); @@ -128,9 +127,9 @@ namespace CalamityMod.NPCs.Ravager } else { - num662 = num659 / num662; - NPC.velocity.X = num660 * num662; - NPC.velocity.Y = num661 * num662; + ravBodyDistance = 36f / ravBodyDistance; + NPC.velocity.X = ravBodyXDist * ravBodyDistance; + NPC.velocity.Y = ravBodyYDist * ravBodyDistance; NPC.rotation = (float)Math.Atan2(-NPC.velocity.Y, -NPC.velocity.X); } } @@ -140,26 +139,26 @@ namespace CalamityMod.NPCs.Ravager NPC.noTileCollide = true; NPC.collideX = false; NPC.collideY = false; - float num663 = 12f; + float clawSpeed = 12f; if (NPC.life < NPC.lifeMax / 2 || death) { - num663 += 2f; + clawSpeed += 2f; } if (NPC.life < NPC.lifeMax / 3 || death) { - num663 += 2f; + clawSpeed += 2f; } if (NPC.life < NPC.lifeMax / 5 || death) { - num663 += 5f; + clawSpeed += 5f; } - Vector2 vector80 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num664 = Main.player[NPC.target].Center.X - vector80.X; - float num665 = Main.player[NPC.target].Center.Y - vector80.Y; - float num666 = (float)Math.Sqrt(num664 * num664 + num665 * num665); - num666 = num663 / num666; - NPC.velocity.X = num664 * num666; - NPC.velocity.Y = num665 * num666; + Vector2 npcCenterAttack = new Vector2(NPC.Center.X, NPC.Center.Y); + float targetX = Main.player[NPC.target].Center.X - npcCenterAttack.X; + float targetY = Main.player[NPC.target].Center.Y - npcCenterAttack.Y; + float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); + targetDistance = clawSpeed / targetDistance; + NPC.velocity.X = targetX * targetDistance; + NPC.velocity.Y = targetY * targetDistance; NPC.ai[0] = 2f; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); } @@ -187,15 +186,15 @@ namespace CalamityMod.NPCs.Ravager NPC.noTileCollide = false; } } - Vector2 vector81 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num667 = Main.npc[CalamityGlobalNPC.scavenger].Center.X - vector81.X; - float num668 = Main.npc[CalamityGlobalNPC.scavenger].Center.Y - vector81.Y; - num667 += Main.npc[CalamityGlobalNPC.scavenger].velocity.X; - num668 += Main.npc[CalamityGlobalNPC.scavenger].velocity.Y; - num668 += 40f; - num667 += 110f; - float num669 = (float)Math.Sqrt(num667 * num667 + num668 * num668); - if ((num669 > (death ? 900f : 700f) || NPC.collideX || NPC.collideY) | NPC.justHit) + Vector2 npcCenterRetract = new Vector2(NPC.Center.X, NPC.Center.Y); + float bodyReturnXDist = Main.npc[CalamityGlobalNPC.scavenger].Center.X - npcCenterRetract.X; + float bodyReturnYDist = Main.npc[CalamityGlobalNPC.scavenger].Center.Y - npcCenterRetract.Y; + bodyReturnXDist += Main.npc[CalamityGlobalNPC.scavenger].velocity.X; + bodyReturnYDist += Main.npc[CalamityGlobalNPC.scavenger].velocity.Y; + bodyReturnYDist += 40f; + bodyReturnXDist += 110f; + float bodyReturnDistance = (float)Math.Sqrt(bodyReturnXDist * bodyReturnXDist + bodyReturnYDist * bodyReturnYDist); + if ((bodyReturnDistance > (death ? 900f : 700f) || NPC.collideX || NPC.collideY) | NPC.justHit) { NPC.noTileCollide = true; NPC.ai[0] = 0f; @@ -204,45 +203,44 @@ namespace CalamityMod.NPCs.Ravager else if (NPC.ai[0] == 3f) { NPC.noTileCollide = true; - float num671 = 12f; - float num672 = 0.4f; - Vector2 vector82 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num673 = Main.player[NPC.target].Center.X - vector82.X; - float num674 = Main.player[NPC.target].Center.Y - vector82.Y; - float num675 = (float)Math.Sqrt(num673 * num673 + num674 * num674); - num675 = num671 / num675; - num673 *= num675; - num674 *= num675; - if (NPC.velocity.X < num673) + float velocityMult = 0.4f; + Vector2 clawCenter = new Vector2(NPC.Center.X, NPC.Center.Y); + float playerX = Main.player[NPC.target].Center.X - clawCenter.X; + float playerY = Main.player[NPC.target].Center.Y - clawCenter.Y; + float playerDist = (float)Math.Sqrt(playerX * playerX + playerY * playerY); + playerDist = 12f / playerDist; + playerX *= playerDist; + playerY *= playerDist; + if (NPC.velocity.X < playerX) { - NPC.velocity.X += num672; - if (NPC.velocity.X < 0f && num673 > 0f) + NPC.velocity.X += velocityMult; + if (NPC.velocity.X < 0f && playerX > 0f) { - NPC.velocity.X += num672 * 2f; + NPC.velocity.X += velocityMult * 2f; } } - else if (NPC.velocity.X > num673) + else if (NPC.velocity.X > playerX) { - NPC.velocity.X -= num672; - if (NPC.velocity.X > 0f && num673 < 0f) + NPC.velocity.X -= velocityMult; + if (NPC.velocity.X > 0f && playerX < 0f) { - NPC.velocity.X -= num672 * 2f; + NPC.velocity.X -= velocityMult * 2f; } } - if (NPC.velocity.Y < num674) + if (NPC.velocity.Y < playerY) { - NPC.velocity.Y += num672; - if (NPC.velocity.Y < 0f && num674 > 0f) + NPC.velocity.Y += velocityMult; + if (NPC.velocity.Y < 0f && playerY > 0f) { - NPC.velocity.Y += num672 * 2f; + NPC.velocity.Y += velocityMult * 2f; } } - else if (NPC.velocity.Y > num674) + else if (NPC.velocity.Y > playerY) { - NPC.velocity.Y -= num672; - if (NPC.velocity.Y > 0f && num674 < 0f) + NPC.velocity.Y -= velocityMult; + if (NPC.velocity.Y > 0f && playerY < 0f) { - NPC.velocity.Y -= num672 * 2f; + NPC.velocity.Y -= velocityMult * 2f; } } NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); @@ -303,11 +301,11 @@ namespace CalamityMod.NPCs.Ravager { if (NPC.life > 0) { - int num285 = 0; - while (num285 < hit.Damage / NPC.lifeMax * 100.0) + int dustCounter = 0; + while (dustCounter < hit.Damage / NPC.lifeMax * 100.0) { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f, 0, default, 1f); - num285++; + dustCounter++; } } else diff --git a/NPCs/Ravager/RavagerHead.cs b/NPCs/Ravager/RavagerHead.cs index 5779b396d6..803f524d53 100644 --- a/NPCs/Ravager/RavagerHead.cs +++ b/NPCs/Ravager/RavagerHead.cs @@ -112,11 +112,11 @@ namespace CalamityMod.NPCs.Ravager { if (NPC.life > 0) { - int num285 = 0; - while ((double)num285 < hit.Damage / (double)NPC.lifeMax * 100.0) + int dustCounter = 0; + while ((double)dustCounter < hit.Damage / (double)NPC.lifeMax * 100.0) { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, (float)hit.HitDirection, -1f, 0, default, 1f); - num285++; + dustCounter++; } } else if (Main.netMode != NetmodeID.MultiplayerClient && !Main.zenithWorld) //GFB does something else diff --git a/NPCs/Ravager/RavagerHead2.cs b/NPCs/Ravager/RavagerHead2.cs index 4a2cffaa40..543f15d387 100644 --- a/NPCs/Ravager/RavagerHead2.cs +++ b/NPCs/Ravager/RavagerHead2.cs @@ -74,38 +74,38 @@ namespace CalamityMod.NPCs.Ravager NPC.timeLeft = 1800; // Rotation - float num801 = NPC.position.X + (NPC.width / 2) - player.position.X - (player.width / 2); - float num802 = NPC.position.Y + NPC.height - 59f - player.position.Y - (player.height / 2); - float num803 = (float)Math.Atan2(num802, num801) + MathHelper.PiOver2; - if (num803 < 0f) - num803 += MathHelper.TwoPi; - else if (num803 > MathHelper.TwoPi) - num803 -= MathHelper.TwoPi; + float playerXDist = NPC.position.X + (NPC.width / 2) - player.position.X - (player.width / 2); + float playerYDist = NPC.position.Y + NPC.height - 59f - player.position.Y - (player.height / 2); + float headRotation = (float)Math.Atan2(playerYDist, playerXDist) + MathHelper.PiOver2; + if (headRotation < 0f) + headRotation += MathHelper.TwoPi; + else if (headRotation > MathHelper.TwoPi) + headRotation -= MathHelper.TwoPi; - float num804 = 0.1f; - if (NPC.rotation < num803) + float headRotateIncrement = 0.1f; + if (NPC.rotation < headRotation) { - if ((num803 - NPC.rotation) > MathHelper.Pi) - NPC.rotation -= num804; + if ((headRotation - NPC.rotation) > MathHelper.Pi) + NPC.rotation -= headRotateIncrement; else - NPC.rotation += num804; + NPC.rotation += headRotateIncrement; } - else if (NPC.rotation > num803) + else if (NPC.rotation > headRotation) { - if ((NPC.rotation - num803) > MathHelper.Pi) - NPC.rotation += num804; + if ((NPC.rotation - headRotation) > MathHelper.Pi) + NPC.rotation += headRotateIncrement; else - NPC.rotation -= num804; + NPC.rotation -= headRotateIncrement; } - if (NPC.rotation > num803 - num804 && NPC.rotation < num803 + num804) - NPC.rotation = num803; + if (NPC.rotation > headRotation - headRotateIncrement && NPC.rotation < headRotation + headRotateIncrement) + NPC.rotation = headRotation; if (NPC.rotation < 0f) NPC.rotation += MathHelper.TwoPi; else if (NPC.rotation > MathHelper.TwoPi) NPC.rotation -= MathHelper.TwoPi; - if (NPC.rotation > num803 - num804 && NPC.rotation < num803 + num804) - NPC.rotation = num803; + if (NPC.rotation > headRotation - headRotateIncrement && NPC.rotation < headRotation + headRotateIncrement) + NPC.rotation = headRotation; NPC.ai[1] += 1f; bool fireProjectiles = NPC.ai[1] >= (bossRush ? 240f : 480f); @@ -141,52 +141,52 @@ namespace CalamityMod.NPCs.Ravager } } - float num823 = 22f; - float num824 = 0.3f; + float attackMovementVel = 22f; + float attackMovementAccel = 0.3f; if (death) { - num823 += 4f; - num824 += 0.05f; + attackMovementVel += 4f; + attackMovementAccel += 0.05f; } if (provy) { - num823 *= 1.25f; - num824 *= 1.25f; + attackMovementVel *= 1.25f; + attackMovementAccel *= 1.25f; } - Vector2 vector82 = NPC.Center; + Vector2 npcCenter = NPC.Center; float distanceX = NPC.ai[0] % 2f == 0f ? 480f : -480f; float distanceY = fireProjectiles ? -320f : 320f; - float num825 = player.Center.X + (fireProjectiles ? distanceX : 0f) - vector82.X; - float num826 = player.Center.Y + distanceY - vector82.Y; - float num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); - num827 = num823 / num827; - num825 *= num827; - num826 *= num827; + float playerXDistAttack = player.Center.X + (fireProjectiles ? distanceX : 0f) - npcCenter.X; + float playerYDistAttack = player.Center.Y + distanceY - npcCenter.Y; + float playerDistanceAttack = (float)Math.Sqrt(playerXDistAttack * playerXDistAttack + playerYDistAttack * playerYDistAttack); + playerDistanceAttack = attackMovementVel / playerDistanceAttack; + playerXDistAttack *= playerDistanceAttack; + playerYDistAttack *= playerDistanceAttack; - if (NPC.velocity.X < num825) + if (NPC.velocity.X < playerXDistAttack) { - NPC.velocity.X += num824; - if (NPC.velocity.X < 0f && num825 > 0f) - NPC.velocity.X += num824; + NPC.velocity.X += attackMovementAccel; + if (NPC.velocity.X < 0f && playerXDistAttack > 0f) + NPC.velocity.X += attackMovementAccel; } - else if (NPC.velocity.X > num825) + else if (NPC.velocity.X > playerXDistAttack) { - NPC.velocity.X -= num824; - if (NPC.velocity.X > 0f && num825 < 0f) - NPC.velocity.X -= num824; + NPC.velocity.X -= attackMovementAccel; + if (NPC.velocity.X > 0f && playerXDistAttack < 0f) + NPC.velocity.X -= attackMovementAccel; } - if (NPC.velocity.Y < num826) + if (NPC.velocity.Y < playerYDistAttack) { - NPC.velocity.Y += num824; - if (NPC.velocity.Y < 0f && num826 > 0f) - NPC.velocity.Y += num824; + NPC.velocity.Y += attackMovementAccel; + if (NPC.velocity.Y < 0f && playerYDistAttack > 0f) + NPC.velocity.Y += attackMovementAccel; } - else if (NPC.velocity.Y > num826) + else if (NPC.velocity.Y > playerYDistAttack) { - NPC.velocity.Y -= num824; - if (NPC.velocity.Y > 0f && num826 < 0f) - NPC.velocity.Y -= num824; + NPC.velocity.Y -= attackMovementAccel; + if (NPC.velocity.Y > 0f && playerYDistAttack < 0f) + NPC.velocity.Y -= attackMovementAccel; } } diff --git a/NPCs/Ravager/RockPillar.cs b/NPCs/Ravager/RockPillar.cs index 50a59b8c75..953f224ad4 100644 --- a/NPCs/Ravager/RockPillar.cs +++ b/NPCs/Ravager/RockPillar.cs @@ -77,23 +77,23 @@ namespace CalamityMod.NPCs.Ravager { SoundEngine.PlaySound(SoundID.Item62, NPC.Center); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int rockDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[rockDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[rockDust].scale = 0.5f; + Main.dust[rockDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Stone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int rockDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Stone, 0f, 0f, 100, default, 3f); + Main.dust[rockDust2].noGravity = true; + Main.dust[rockDust2].velocity *= 5f; + rockDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[rockDust2].velocity *= 2f; } NPC.noTileCollide = true; @@ -151,23 +151,23 @@ namespace CalamityMod.NPCs.Ravager NPC.height = 360; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 30; num621++) + for (int i = 0; i < 30; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int rockDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[rockDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[rockDust].scale = 0.5f; + Main.dust[rockDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Stone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int rockDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Stone, 0f, 0f, 100, default, 3f); + Main.dust[rockDust2].noGravity = true; + Main.dust[rockDust2].velocity *= 5f; + rockDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[rockDust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) @@ -188,23 +188,23 @@ namespace CalamityMod.NPCs.Ravager } else { - for (int num621 = 0; num621 < 2; num621++) + for (int i = 0; i < 2; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int rockDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[rockDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[rockDust].scale = 0.5f; + Main.dust[rockDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 2; num623++) + for (int j = 0; j < 2; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Stone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int rockDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Stone, 0f, 0f, 100, default, 3f); + Main.dust[rockDust2].noGravity = true; + Main.dust[rockDust2].velocity *= 5f; + rockDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[rockDust2].velocity *= 2f; } } } diff --git a/NPCs/Signus/CosmicLantern.cs b/NPCs/Signus/CosmicLantern.cs index 7ae8f2477d..fddafbc722 100644 --- a/NPCs/Signus/CosmicLantern.cs +++ b/NPCs/Signus/CosmicLantern.cs @@ -92,9 +92,9 @@ namespace CalamityMod.NPCs.Signus if (NPC.alpha < 0) { NPC.alpha = 0; - int num1262 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 204, 0f, 0f, 0, default, 0.25f); - Main.dust[num1262].velocity *= 0.1f; - Main.dust[num1262].noGravity = true; + int lightDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 204, 0f, 0f, 0, default, 0.25f); + Main.dust[lightDust].velocity *= 0.1f; + Main.dust[lightDust].noGravity = true; } bool revenge = CalamityWorld.revenge; @@ -111,50 +111,48 @@ namespace CalamityMod.NPCs.Signus spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + int afterimageAmt = 5; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/Signus/CosmicLanternGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + Color cyanLerp = Color.Lerp(Color.White, Color.Cyan, 0.5f); if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = NPC.GetAlpha(color41); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color flameAfterimageColor = cyanLerp; + flameAfterimageColor = Color.Lerp(flameAfterimageColor, Color.White, 0.5f); + flameAfterimageColor = NPC.GetAlpha(flameAfterimageColor); + flameAfterimageColor *= (float)(afterimageAmt - j) / 15f; + Vector2 flameAfterimagePos = NPC.oldPos[j] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + flameAfterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + flameAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, flameAfterimagePos, NPC.frame, flameAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, cyanLerp, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/Signus/CosmicMine.cs b/NPCs/Signus/CosmicMine.cs index da2bb1d95d..39bbd0604b 100644 --- a/NPCs/Signus/CosmicMine.cs +++ b/NPCs/Signus/CosmicMine.cs @@ -119,18 +119,18 @@ namespace CalamityMod.NPCs.Signus } } - float num1372 = death ? 16f : 14f; + float mineSpeed = death ? 16f : 14f; Vector2 vector167 = new Vector2(NPC.Center.X + (NPC.direction * 20), NPC.Center.Y + 6f); - float num1373 = player.position.X + player.width * 0.5f - vector167.X; - float num1374 = player.Center.Y - vector167.Y; - float num1375 = (float)Math.Sqrt(num1373 * num1373 + num1374 * num1374); - float num1376 = num1372 / num1375; - num1373 *= num1376; - num1374 *= num1376; + float playerXDist = player.position.X + player.width * 0.5f - vector167.X; + float playerYDist = player.Center.Y - vector167.Y; + float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); + float velocityMult = mineSpeed / playerDistance; + playerXDist *= velocityMult; + playerYDist *= velocityMult; NPC.ai[0] -= 1f; - if (num1375 < 200f || NPC.ai[0] > 0f) + if (playerDistance < 200f || NPC.ai[0] > 0f) { - if (num1375 < 200f) + if (playerDistance < 200f) { NPC.ai[0] = 20f; } @@ -145,17 +145,17 @@ namespace CalamityMod.NPCs.Signus return; } - NPC.velocity.X = (NPC.velocity.X * 50f + num1373) / 51f; - NPC.velocity.Y = (NPC.velocity.Y * 50f + num1374) / 51f; - if (num1375 < 350f) + NPC.velocity.X = (NPC.velocity.X * 50f + playerXDist) / 51f; + NPC.velocity.Y = (NPC.velocity.Y * 50f + playerYDist) / 51f; + if (playerDistance < 350f) { - NPC.velocity.X = (NPC.velocity.X * 10f + num1373) / 11f; - NPC.velocity.Y = (NPC.velocity.Y * 10f + num1374) / 11f; + NPC.velocity.X = (NPC.velocity.X * 10f + playerXDist) / 11f; + NPC.velocity.Y = (NPC.velocity.Y * 10f + playerYDist) / 11f; } - if (num1375 < 300f) + if (playerDistance < 300f) { - NPC.velocity.X = (NPC.velocity.X * 7f + num1373) / 8f; - NPC.velocity.Y = (NPC.velocity.Y * 7f + num1374) / 8f; + NPC.velocity.X = (NPC.velocity.X * 7f + playerXDist) / 8f; + NPC.velocity.Y = (NPC.velocity.Y * 7f + playerYDist) / 8f; } } @@ -171,30 +171,28 @@ namespace CalamityMod.NPCs.Signus spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); + int afterimageAmt = 5; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -208,25 +206,25 @@ namespace CalamityMod.NPCs.Signus NPC.width = NPC.height = 256; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int cosmiliteDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[cosmiliteDust].scale = 0.5f; + Main.dust[cosmiliteDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } - Main.dust[num622].noGravity = true; + Main.dust[cosmiliteDust].noGravity = true; } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - Main.dust[num624].noGravity = true; + int cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[cosmiliteDust2].noGravity = true; + Main.dust[cosmiliteDust2].velocity *= 5f; + cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust2].velocity *= 2f; + Main.dust[cosmiliteDust2].noGravity = true; } return true; } diff --git a/NPCs/Signus/Signus.cs b/NPCs/Signus/Signus.cs index f8058466f0..9f2f65c90f 100644 --- a/NPCs/Signus/Signus.cs +++ b/NPCs/Signus/Signus.cs @@ -42,7 +42,7 @@ namespace CalamityMod.NPCs.Signus Main.npcFrameCount[NPC.type] = 6; NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { PortraitPositionYOverride = 10f, Scale = 0.4f, @@ -185,14 +185,14 @@ namespace CalamityMod.NPCs.Signus if (lifeToAlpha < (Main.getGoodWorld ? 100 : 50) && NPC.ai[0] != 1f) { - for (int num1011 = 0; num1011 < 2; num1011++) + for (int i = 0; i < 2; i++) { if (Main.rand.Next(3) < 1) { - int num1012 = Dust.NewDust(vectorCenter - new Vector2(70f), 70 * 2, 70 * 2, (int)CalamityDusts.PurpleCosmilite, NPC.velocity.X * 0.5f, NPC.velocity.Y * 0.5f, 90, default, 1.5f); - Main.dust[num1012].noGravity = true; - Main.dust[num1012].velocity *= 0.2f; - Main.dust[num1012].fadeIn = 1f; + int cosmiliteDust = Dust.NewDust(vectorCenter - new Vector2(70f), 70 * 2, 70 * 2, (int)CalamityDusts.PurpleCosmilite, NPC.velocity.X * 0.5f, NPC.velocity.Y * 0.5f, 90, default, 1.5f); + Main.dust[cosmiliteDust].noGravity = true; + Main.dust[cosmiliteDust].velocity *= 0.2f; + Main.dust[cosmiliteDust].fadeIn = 1f; } } } @@ -238,19 +238,19 @@ namespace CalamityMod.NPCs.Signus if (expertMode) speed += death ? 6f * (float)(1D - lifeRatio) : 4f * (float)(1D - lifeRatio); - float num795 = player.Center.X - vectorCenter.X; - float num796 = player.Center.Y - vectorCenter.Y; - float num797 = (float)Math.Sqrt(num795 * num795 + num796 * num796); - num797 = speed / num797; - num795 *= num797; - num796 *= num797; + float playerXDist = player.Center.X - vectorCenter.X; + float playerYDist = player.Center.Y - vectorCenter.Y; + float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); + playerDistance = speed / playerDistance; + playerXDist *= playerDistance; + playerYDist *= playerDistance; float inertia2 = 50f; if (Main.getGoodWorld) inertia2 *= 0.5f; - NPC.velocity.X = (NPC.velocity.X * inertia2 + num795) / (inertia2 + 1f); - NPC.velocity.Y = (NPC.velocity.Y * inertia2 + num796) / (inertia2 + 1f); + NPC.velocity.X = (NPC.velocity.X * inertia2 + playerXDist) / (inertia2 + 1f); + NPC.velocity.Y = (NPC.velocity.Y * inertia2 + playerYDist) / (inertia2 + 1f); } else NPC.knockBackResist = 0f; @@ -284,38 +284,38 @@ namespace CalamityMod.NPCs.Signus NPC.TargetClosest(); - int num1249 = 0; - int num1250; - int num1251; + int maxTeleportTries = 0; + int playerTileX; + int playerTileY; while (true) { - num1249++; - num1250 = (int)player.Center.X / 16; - num1251 = (int)player.Center.Y / 16; + maxTeleportTries++; + playerTileX = (int)player.Center.X / 16; + playerTileY = (int)player.Center.Y / 16; int min = 14; int max = 18; if (Main.rand.NextBool()) - num1250 += Main.rand.Next(min, max); + playerTileX += Main.rand.Next(min, max); else - num1250 -= Main.rand.Next(min, max); + playerTileX -= Main.rand.Next(min, max); if (Main.rand.NextBool()) - num1251 += Main.rand.Next(min, max); + playerTileY += Main.rand.Next(min, max); else - num1251 -= Main.rand.Next(min, max); + playerTileY -= Main.rand.Next(min, max); - if (!WorldGen.SolidTile(num1250, num1251)) + if (!WorldGen.SolidTile(playerTileX, playerTileY)) break; - if (num1249 > 100) + if (maxTeleportTries > 100) return; } NPC.ai[0] = 1f; - NPC.ai[1] = num1250; - NPC.ai[2] = num1251; + NPC.ai[1] = playerTileX; + NPC.ai[2] = playerTileY; NPC.netUpdate = true; @@ -350,8 +350,8 @@ namespace CalamityMod.NPCs.Signus for (int n = 0; n < 15; n++) { - int num39 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 90, default, 3f); - Main.dust[num39].noGravity = true; + int cosmiliteDusty = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 90, default, 3f); + Main.dust[cosmiliteDusty].noGravity = true; } NPC.ai[0] = 2f; @@ -371,60 +371,60 @@ namespace CalamityMod.NPCs.Signus { SoundEngine.PlaySound(SoundID.Item122, NPC.Center); - int num660 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X + 750f), (int)player.position.Y, ModContent.NPCType()); + int cosmicMineSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X + 750f), (int)player.position.Y, ModContent.NPCType()); if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num660, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, cosmicMineSpawn, 0f, 0f, 0f, 0, 0, 0); - int num661 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X - 750f), (int)player.position.Y, ModContent.NPCType()); + int cosmicMineSpawn2 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X - 750f), (int)player.position.Y, ModContent.NPCType()); if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num661, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, cosmicMineSpawn2, 0f, 0f, 0f, 0, 0, 0); if (stealthTimer >= maxStealth) { - int num662 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X + 950f), (int)player.position.Y, ModContent.NPCType()); + int stealthCosmicMine = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X + 950f), (int)player.position.Y, ModContent.NPCType()); if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num662, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, stealthCosmicMine, 0f, 0f, 0f, 0, 0, 0); - int num663 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X - 950f), (int)player.position.Y, ModContent.NPCType()); + int stealthCosmicMine2 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X - 950f), (int)player.position.Y, ModContent.NPCType()); if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num663, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, stealthCosmicMine2, 0f, 0f, 0f, 0, 0, 0); SoundEngine.PlaySound(RaidersTalisman.StealthHitSound, NPC.Center); stealthTimer = 0; } - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(player.position.X + 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - Main.dust[num622].noGravity = true; + int teleportDust = Dust.NewDust(new Vector2(player.position.X + 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[teleportDust].velocity *= 3f; + Main.dust[teleportDust].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[teleportDust].scale = 0.5f; + Main.dust[teleportDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } - int num623 = Dust.NewDust(new Vector2(player.position.X - 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num623].velocity *= 3f; - Main.dust[num623].noGravity = true; + int j = Dust.NewDust(new Vector2(player.position.X - 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[j].velocity *= 3f; + Main.dust[j].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num623].scale = 0.5f; - Main.dust[num623].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[j].scale = 0.5f; + Main.dust[j].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(new Vector2(player.position.X + 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(player.position.X + 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - int num625 = Dust.NewDust(new Vector2(player.position.X - 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num625].noGravity = true; - Main.dust[num625].velocity *= 5f; - num625 = Dust.NewDust(new Vector2(player.position.X - 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num625].velocity *= 2f; + int teleportDust2 = Dust.NewDust(new Vector2(player.position.X + 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[teleportDust2].noGravity = true; + Main.dust[teleportDust2].velocity *= 5f; + teleportDust2 = Dust.NewDust(new Vector2(player.position.X + 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[teleportDust2].velocity *= 2f; + int teleportDusty = Dust.NewDust(new Vector2(player.position.X - 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[teleportDusty].noGravity = true; + Main.dust[teleportDusty].velocity *= 5f; + teleportDusty = Dust.NewDust(new Vector2(player.position.X - 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[teleportDusty].velocity *= 2f; } } @@ -466,16 +466,15 @@ namespace CalamityMod.NPCs.Signus { if (Main.netMode != NetmodeID.MultiplayerClient) { - float num1070 = 15f; - float num1071 = player.Center.X - vectorCenter.X; - float num1072 = player.Center.Y - vectorCenter.Y; - float num1073 = (float)Math.Sqrt(num1071 * num1071 + num1072 * num1072); - num1073 = num1070 / num1073; - num1071 *= num1073; - num1072 *= num1073; + float scytheXDist = player.Center.X - vectorCenter.X; + float scytheYDist = player.Center.Y - vectorCenter.Y; + float scytheDistance = (float)Math.Sqrt(scytheXDist * scytheXDist + scytheYDist * scytheYDist); + scytheDistance = 15f / scytheDistance; + scytheXDist *= scytheDistance; + scytheYDist *= scytheDistance; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter.X, vectorCenter.Y, num1071, num1072, type, damage, 0f, Main.myPlayer, 0f, NPC.target + 1); + Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter.X, vectorCenter.Y, scytheXDist, scytheYDist, type, damage, 0f, Main.myPlayer, 0f, NPC.target + 1); if (stealthTimer >= maxStealth) { damage *= 2; @@ -483,7 +482,7 @@ namespace CalamityMod.NPCs.Signus for (int i = 0; i < 4; i++) { Vector2 offset = new Vector2(Main.rand.Next(-5, 6), Main.rand.Next(-5, 6)); - Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter.X, vectorCenter.Y, num1071 + offset.X, num1072 + offset.Y, type, damage, 0f, Main.myPlayer, 0f, NPC.target + 1); + Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter.X, vectorCenter.Y, scytheXDist + offset.X, scytheYDist + offset.Y, type, damage, 0f, Main.myPlayer, 0f, NPC.target + 1); } stealthTimer = 0; } @@ -567,23 +566,23 @@ namespace CalamityMod.NPCs.Signus { type = ModContent.NPCType(); } - int num660 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X + spawnX), (int)(player.position.Y + spawnY), type); + int cosmicMineSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X + spawnX), (int)(player.position.Y + spawnY), type); if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num660, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, cosmicMineSpawn, 0f, 0f, 0f, 0, 0, 0); - int num661 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X - spawnX), (int)(player.position.Y + spawnY), type); + int cosmicMineSpawn2 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X - spawnX), (int)(player.position.Y + spawnY), type); if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num661, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, cosmicMineSpawn2, 0f, 0f, 0f, 0, 0, 0); if (buffed) { - int num662 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X + spawnX + spawnX / 2), (int)(player.position.Y + spawnY), ModContent.NPCType()); + int stealthCosmicMine = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X + spawnX + spawnX / 2), (int)(player.position.Y + spawnY), ModContent.NPCType()); if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num662, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, stealthCosmicMine, 0f, 0f, 0f, 0, 0, 0); - int num663 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X - spawnX - spawnX / 2), (int)(player.position.Y + spawnY), ModContent.NPCType()); + int stealthCosmicMine2 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X - spawnX - spawnX / 2), (int)(player.position.Y + spawnY), ModContent.NPCType()); if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num663, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, stealthCosmicMine2, 0f, 0f, 0f, 0, 0, 0); } spawnY -= 60; @@ -614,22 +613,19 @@ namespace CalamityMod.NPCs.Signus if (expertMode) velocity += death ? 6f * (float)(1D - lifeRatio) : 4f * (float)(1D - lifeRatio); - Vector2 vector126 = player.Center - vectorCenter; - Vector2 vector127 = vector126 - Vector2.UnitY * 300f; + Vector2 playerCenterDist = player.Center - vectorCenter; + Vector2 playerHoverAboveDist = playerCenterDist - Vector2.UnitY * 300f; - float num1013 = vector126.Length(); + playerCenterDist = Vector2.Normalize(playerCenterDist) * velocity; + playerHoverAboveDist = Vector2.Normalize(playerHoverAboveDist) * velocity; - vector126 = Vector2.Normalize(vector126) * velocity; - vector127 = Vector2.Normalize(vector127) * velocity; - - bool flag64 = Collision.CanHit(vectorCenter, 1, 1, player.Center, 1, 1) || NPC.ai[3] >= 120f; - float num1014 = 8f; - flag64 = flag64 && vector126.ToRotation() > MathHelper.Pi / num1014 && vector126.ToRotation() < MathHelper.Pi - MathHelper.Pi / num1014; - if (num1013 > 1400f || !flag64) + bool canLineUpCharge = Collision.CanHit(vectorCenter, 1, 1, player.Center, 1, 1) || NPC.ai[3] >= 120f; + canLineUpCharge = canLineUpCharge && playerCenterDist.ToRotation() > MathHelper.Pi / 8f && playerCenterDist.ToRotation() < MathHelper.Pi - MathHelper.Pi / 8f; + if (playerCenterDist.Length() > 1400f || !canLineUpCharge) { - NPC.velocity = (NPC.velocity * (inertia - 1f) + vector127) / inertia; + NPC.velocity = (NPC.velocity * (inertia - 1f) + playerHoverAboveDist) / inertia; - if (!flag64) + if (!canLineUpCharge) { NPC.ai[3] += 1f; if (NPC.ai[3] == 120f) @@ -641,8 +637,8 @@ namespace CalamityMod.NPCs.Signus else { calamityGlobalNPC.newAI[0] = 1f; - NPC.ai[2] = vector126.X; - NPC.ai[3] = vector126.Y; + NPC.ai[2] = playerCenterDist.X; + NPC.ai[3] = playerCenterDist.Y; NPC.netUpdate = true; } } @@ -694,8 +690,8 @@ namespace CalamityMod.NPCs.Signus } NPC.ai[1] += 1f; - bool flag65 = vectorCenter.Y + 50f > player.Center.Y; - if ((NPC.ai[1] >= 90f && flag65) || NPC.velocity.Length() < 8f) + bool shouldEndCharge = vectorCenter.Y + 50f > player.Center.Y; + if ((NPC.ai[1] >= 90f && shouldEndCharge) || NPC.velocity.Length() < 8f) { calamityGlobalNPC.newAI[0] = 3f; NPC.ai[1] = 30f; @@ -709,12 +705,12 @@ namespace CalamityMod.NPCs.Signus } else { - Vector2 vec2 = player.Center - vectorCenter; - vec2.Normalize(); - if (vec2.HasNaNs()) - vec2 = new Vector2(NPC.direction, 0f); + Vector2 distFromPlayerCenter = player.Center - vectorCenter; + distFromPlayerCenter.Normalize(); + if (distFromPlayerCenter.HasNaNs()) + distFromPlayerCenter = new Vector2(NPC.direction, 0f); - NPC.velocity = (NPC.velocity * (inertia - 1f) + vec2 * (NPC.velocity.Length() + 0.111111117f * inertia)) / inertia; + NPC.velocity = (NPC.velocity * (inertia - 1f) + distFromPlayerCenter * (NPC.velocity.Length() + 0.111111117f * inertia)) / inertia; } } else if (calamityGlobalNPC.newAI[0] == 3f) // Slow down after charging and reset @@ -782,7 +778,7 @@ namespace CalamityMod.NPCs.Signus if (NPC.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; - int num153 = 5; + int afterimageAmt = 5; Rectangle frame = NPC.frame; int frameCount = Main.npcFrameCount[NPC.type]; @@ -790,7 +786,7 @@ namespace CalamityMod.NPCs.Signus { NPCTexture = ModContent.Request("CalamityMod/NPCs/Signus/SignusAlt2").Value; glowMaskTexture = ModContent.Request("CalamityMod/NPCs/Signus/SignusAlt2Glow").Value; - num153 = 10; + afterimageAmt = 10; int frameY = 94 * (int)(NPC.frameCounter / 12.0); if (frameY >= 94 * 6) frameY = 0; @@ -800,7 +796,7 @@ namespace CalamityMod.NPCs.Signus { NPCTexture = ModContent.Request("CalamityMod/NPCs/Signus/SignusAlt").Value; glowMaskTexture = ModContent.Request("CalamityMod/NPCs/Signus/SignusAltGlow").Value; - num153 = 7; + afterimageAmt = 7; } else { @@ -808,9 +804,7 @@ namespace CalamityMod.NPCs.Signus glowMaskTexture = ModContent.Request("CalamityMod/NPCs/Signus/SignusGlow").Value; } - Vector2 vector11 = new Vector2(NPCTexture.Width / 2, NPCTexture.Height / frameCount / 2); - Color color36 = Color.White; - float amount9 = 0.5f; + Vector2 halfSizeTexture = new Vector2(NPCTexture.Width / 2, NPCTexture.Height / frameCount / 2); float scale = NPC.scale; float rotation = NPC.rotation; float offsetY = NPC.gfxOffY; @@ -822,42 +816,42 @@ namespace CalamityMod.NPCs.Signus if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(NPCTexture.Width, NPCTexture.Height / frameCount) * scale / 2f; - vector41 += vector11 * scale + new Vector2(0f, 4f + offsetY); - spriteBatch.Draw(NPCTexture, vector41, new Rectangle?(frame), color38 * transparency, rotation, vector11, scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(NPCTexture.Width, NPCTexture.Height / frameCount) * scale / 2f; + afterimagePos += halfSizeTexture * scale + new Vector2(0f, 4f + offsetY); + spriteBatch.Draw(NPCTexture, afterimagePos, new Rectangle?(frame), afterimageColor * transparency, rotation, halfSizeTexture, scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(NPCTexture.Width, NPCTexture.Height / frameCount) * scale / 2f; - vector43 += vector11 * scale + new Vector2(0f, 4f + offsetY); - spriteBatch.Draw(NPCTexture, vector43, new Rectangle?(frame), NPC.GetAlpha(drawColor) * transparency, rotation, vector11, scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(NPCTexture.Width, NPCTexture.Height / frameCount) * scale / 2f; + drawLocation += halfSizeTexture * scale + new Vector2(0f, 4f + offsetY); + spriteBatch.Draw(NPCTexture, drawLocation, new Rectangle?(frame), NPC.GetAlpha(drawColor) * transparency, rotation, halfSizeTexture, scale, spriteEffects, 0f); - Color color40 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + Color eyeGlowColor = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); if (Main.zenithWorld) { - color40 = Color.MediumBlue; + eyeGlowColor = Color.MediumBlue; } if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color40; - color41 = Color.Lerp(color41, color36, amount9); - color41 = NPC.GetAlpha(color41); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector44 -= new Vector2(glowMaskTexture.Width, glowMaskTexture.Height / frameCount) * scale / 2f; - vector44 += vector11 * scale + new Vector2(0f, 4f + offsetY); - spriteBatch.Draw(glowMaskTexture, vector44, new Rectangle?(frame), color41, rotation, vector11, scale, spriteEffects, 0f); + Color eyeAfterimageColor = eyeGlowColor; + eyeAfterimageColor = Color.Lerp(eyeAfterimageColor, Color.White, 0.5f); + eyeAfterimageColor = NPC.GetAlpha(eyeAfterimageColor); + eyeAfterimageColor *= (afterimageAmt - j) / 15f; + Vector2 eyeAfterimagePos = NPC.oldPos[j] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + eyeAfterimagePos -= new Vector2(glowMaskTexture.Width, glowMaskTexture.Height / frameCount) * scale / 2f; + eyeAfterimagePos += halfSizeTexture * scale + new Vector2(0f, 4f + offsetY); + spriteBatch.Draw(glowMaskTexture, eyeAfterimagePos, new Rectangle?(frame), eyeAfterimageColor, rotation, halfSizeTexture, scale, spriteEffects, 0f); } } @@ -874,12 +868,12 @@ namespace CalamityMod.NPCs.Signus for (float i = 0; i < 1; i += 0.125f) { - spriteBatch.Draw(glowMaskTexture, vector43 + (i * MathHelper.TwoPi).ToRotationVector2() * outlineThickness, new Rectangle?(frame), outlineColor, rotation, vector11, scale, spriteEffects, 0f); + spriteBatch.Draw(glowMaskTexture, drawLocation + (i * MathHelper.TwoPi).ToRotationVector2() * outlineThickness, new Rectangle?(frame), outlineColor, rotation, halfSizeTexture, scale, spriteEffects, 0f); } CalamityUtils.ExitShaderRegion(spriteBatch); } - spriteBatch.Draw(glowMaskTexture, vector43, new Rectangle?(frame), color40, rotation, vector11, scale, spriteEffects, 0f); + spriteBatch.Draw(glowMaskTexture, drawLocation, new Rectangle?(frame), eyeGlowColor, rotation, halfSizeTexture, scale, spriteEffects, 0f); return false; } @@ -937,8 +931,8 @@ namespace CalamityMod.NPCs.Signus // GFB Nanotech and Ethereal Talisman drops var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ModContent.ItemType()); - GFBOnly.Add(ModContent.ItemType()); + GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); + GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); } // Lore @@ -965,23 +959,23 @@ namespace CalamityMod.NPCs.Signus NPC.height = 150; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int teleportDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[teleportDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[teleportDust].scale = 0.5f; + Main.dust[teleportDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 60; num623++) + for (int j = 0; j < 60; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int teleportDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[teleportDust2].noGravity = true; + Main.dust[teleportDust2].velocity *= 5f; + teleportDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[teleportDust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) { @@ -1000,18 +994,18 @@ namespace CalamityMod.NPCs.Signus { Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= 60f; } diff --git a/NPCs/SlimeGod/CorruptSlimeSpawn.cs b/NPCs/SlimeGod/CorruptSlimeSpawn.cs index 1b6a787b3d..e6d980573f 100644 --- a/NPCs/SlimeGod/CorruptSlimeSpawn.cs +++ b/NPCs/SlimeGod/CorruptSlimeSpawn.cs @@ -15,7 +15,7 @@ namespace CalamityMod.NPCs.SlimeGod { Main.npcFrameCount[NPC.type] = 4; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0); value.PortraitPositionYOverride = -32f; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; } diff --git a/NPCs/SlimeGod/CrimsonSlimeSpawn2.cs b/NPCs/SlimeGod/CrimsonSlimeSpawn2.cs index 5542aebf97..4f189ae655 100644 --- a/NPCs/SlimeGod/CrimsonSlimeSpawn2.cs +++ b/NPCs/SlimeGod/CrimsonSlimeSpawn2.cs @@ -103,11 +103,11 @@ namespace CalamityMod.NPCs.SlimeGod } if (!NPC.wet) { - Vector2 vector3 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num14 = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - vector3.X; - float num15 = Main.player[NPC.target].position.Y - vector3.Y; - float num16 = (float)Math.Sqrt((double)(num14 * num14 + num15 * num15)); - if (Main.expertMode && num16 < 120f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && NPC.velocity.Y == 0f) + Vector2 faceDirection = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetX = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - faceDirection.X; + float targetY = Main.player[NPC.target].position.Y - faceDirection.Y; + float targetDistance = (float)Math.Sqrt((double)(targetX * targetX + targetY * targetY)); + if (Main.expertMode && targetDistance < 120f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && NPC.velocity.Y == 0f) { NPC.ai[0] = -40f; if (NPC.velocity.Y == 0f) @@ -119,17 +119,17 @@ namespace CalamityMod.NPCs.SlimeGod int projcount = Main.zenithWorld ? 12 : 5; for (int n = 0; n < projcount; n++) { - Vector2 vector4 = new Vector2((float)(n - 2), -4f); - vector4.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; - vector4.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; - vector4.Normalize(); - vector4 *= 4f + (float)Main.rand.Next(-50, 51) * 0.01f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector3.X, vector3.Y, vector4.X, vector4.Y, type, damage, 0f, Main.myPlayer, 0f, 0f); + Vector2 spikeDirection = new Vector2((float)(n - 2), -4f); + spikeDirection.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; + spikeDirection.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; + spikeDirection.Normalize(); + spikeDirection *= 4f + (float)Main.rand.Next(-50, 51) * 0.01f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), faceDirection.X, faceDirection.Y, spikeDirection.X, spikeDirection.Y, type, damage, 0f, Main.myPlayer, 0f, 0f); spikeTimer = 30f; } } } - else if (num16 < 360f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && NPC.velocity.Y == 0f) + else if (targetDistance < 360f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && NPC.velocity.Y == 0f) { NPC.ai[0] = -40f; if (NPC.velocity.Y == 0f) @@ -138,13 +138,13 @@ namespace CalamityMod.NPCs.SlimeGod } if (Main.netMode != NetmodeID.MultiplayerClient && spikeTimer == 0f) { - num15 = Main.player[NPC.target].position.Y - vector3.Y - (float)Main.rand.Next(0, 200); - num16 = (float)Math.Sqrt((double)(num14 * num14 + num15 * num15)); - num16 = 6.5f / num16; - num14 *= num16; - num15 *= num16; + targetY = Main.player[NPC.target].position.Y - faceDirection.Y - (float)Main.rand.Next(0, 200); + targetDistance = (float)Math.Sqrt((double)(targetX * targetX + targetY * targetY)); + targetDistance = 6.5f / targetDistance; + targetX *= targetDistance; + targetY *= targetDistance; spikeTimer = 50f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector3.X, vector3.Y, num14, num15, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), faceDirection.X, faceDirection.Y, targetX, targetY, type, damage, 0f, Main.myPlayer, 0f, 0f); } } } diff --git a/NPCs/SlimeGod/CrimulanPaladin.cs b/NPCs/SlimeGod/CrimulanPaladin.cs index fd8b9e4c4d..23bfbfd72c 100644 --- a/NPCs/SlimeGod/CrimulanPaladin.cs +++ b/NPCs/SlimeGod/CrimulanPaladin.cs @@ -184,34 +184,33 @@ namespace CalamityMod.NPCs.SlimeGod NPC.TargetClosest(false); player = Main.player[NPC.target]; Vector2 vectorAimedAheadOfTarget = player.Center + new Vector2((float)Math.Round(player.velocity.X), 0f).SafeNormalize(Vector2.Zero) * 960f; - Point point2 = vectorAimedAheadOfTarget.ToTileCoordinates(); - int num5 = 5; - int num8 = 0; - while (num8 < 100) + Point teleportAheadPos = vectorAimedAheadOfTarget.ToTileCoordinates(); + int maxTeleportTries = 0; + while (maxTeleportTries < 100) { - num8++; - int num9 = Main.rand.Next(point2.X - num5, point2.X + num5 + 1); - int num10 = Main.rand.Next(point2.Y - num5, point2.Y); - if (Main.tile[num9, num10].HasUnactuatedTile) + maxTeleportTries++; + int teleportPosX = Main.rand.Next(teleportAheadPos.X - 5, teleportAheadPos.X + 6); + int teleportPosY = Main.rand.Next(teleportAheadPos.Y - 5, teleportAheadPos.Y); + if (Main.tile[teleportPosX, teleportPosY].HasUnactuatedTile) continue; - bool flag4 = true; - if (flag4 && Main.tile[num9, num10].LiquidType == LiquidID.Lava) - flag4 = false; - if (flag4 && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) - flag4 = false; + bool canTeleport = true; + if (canTeleport && Main.tile[teleportPosX, teleportPosY].LiquidType == LiquidID.Lava) + canTeleport = false; + if (canTeleport && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) + canTeleport = false; - if (flag4) + if (canTeleport) { - NPC.localAI[0] = num9 * 16 + 8; - NPC.localAI[3] = num10 * 16 + 16; + NPC.localAI[0] = teleportPosX * 16 + 8; + NPC.localAI[3] = teleportPosY * 16 + 16; calamityGlobalNPC.newAI[0] = 0f; break; } } // Default teleport if the above conditions aren't met in 100 iterations - if (num8 >= 100) + if (maxTeleportTries >= 100) { Vector2 bottom = Main.player[Player.FindClosest(NPC.position, NPC.width, NPC.height)].Bottom; NPC.localAI[0] = bottom.X; @@ -362,24 +361,24 @@ namespace CalamityMod.NPCs.SlimeGod NPC.spriteDirection = NPC.direction; NPC.TargetClosest(); - Vector2 center40 = player.Center; - center40.Y -= 350f; - Vector2 vector272 = center40 - NPC.Center; + Vector2 targetCenter = player.Center; + targetCenter.Y -= 350f; + Vector2 targetDist = targetCenter - NPC.Center; if (NPC.ai[2] == 1f) { NPC.ai[1] += 1f; - vector272 = player.Center - NPC.Center; - vector272.Normalize(); - vector272 *= death ? 10f : revenge ? 9f : expertMode ? 8f : 7f; - NPC.velocity = (NPC.velocity * 4f + vector272) / 5f; + targetDist = player.Center - NPC.Center; + targetDist.Normalize(); + targetDist *= death ? 10f : revenge ? 9f : expertMode ? 8f : 7f; + NPC.velocity = (NPC.velocity * 4f + targetDist) / 5f; if (NPC.ai[1] > 12f) { NPC.ai[1] = 0f; NPC.ai[0] = 1.1f; NPC.ai[2] = 0f; - NPC.velocity = vector272; + NPC.velocity = targetDist; } } else @@ -391,9 +390,9 @@ namespace CalamityMod.NPCs.SlimeGod return; } - vector272.Normalize(); - vector272 *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; - NPC.velocity = (NPC.velocity * 5f + vector272) / 6f; + targetDist.Normalize(); + targetDist *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; + NPC.velocity = (NPC.velocity * 5f + targetDist) / 6f; } } else if (NPC.ai[0] == 1.1f) @@ -442,8 +441,8 @@ namespace CalamityMod.NPCs.SlimeGod } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(velocity2) * 30f * NPC.scale, velocity2, type, damage, 0f, Main.myPlayer); + Vector2 projFireDirection = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projFireDirection) * 30f * NPC.scale, projFireDirection, type, damage, 0f, Main.myPlayer); } } } @@ -591,11 +590,11 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Crimson; dustColor.A = 150; - for (int num245 = 0; num245 < 10; num245++) + for (int i = 0; i < 10; i++) { - int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); - Main.dust[num246].noGravity = true; - Main.dust[num246].velocity *= 0.5f; + int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + Main.dust[crimsonDust].noGravity = true; + Main.dust[crimsonDust].velocity *= 0.5f; } } else if (NPC.ai[0] == 6f) @@ -625,11 +624,11 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Crimson; dustColor.A = 150; - for (int num245 = 0; num245 < 10; num245++) + for (int i = 0; i < 10; i++) { - int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); - Main.dust[num246].noGravity = true; - Main.dust[num246].velocity *= 0.5f; + int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + Main.dust[crimsonDust].noGravity = true; + Main.dust[crimsonDust].velocity *= 0.5f; } } @@ -638,15 +637,15 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.life > 0) { - float num659 = lifeRatio; - num659 = num659 * 0.5f + 0.75f; - num659 *= scale; + float scaleRatio = lifeRatio; + scaleRatio = scaleRatio * 0.5f + 0.75f; + scaleRatio *= scale; - if (num659 != NPC.scale) + if (scaleRatio != NPC.scale) { NPC.position.X = NPC.position.X + (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y + (float)NPC.height; - NPC.scale = num659; + NPC.scale = scaleRatio; NPC.width = (int)(150f * NPC.scale); NPC.height = (int)(92f * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); @@ -655,25 +654,25 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.netMode != NetmodeID.MultiplayerClient) { - int num660 = (int)((double)NPC.lifeMax * 0.15); - if ((float)(NPC.life + num660) < bossLife) + int slimeSpawnThreshold = (int)((double)NPC.lifeMax * 0.15); + if ((float)(NPC.life + slimeSpawnThreshold) < bossLife) { bossLife = (float)NPC.life; int x = (int)(NPC.position.X + (float)Main.rand.Next(NPC.width - 32)); int y = (int)(NPC.position.Y + (float)Main.rand.Next(NPC.height - 32)); - int num663 = ModContent.NPCType(); + int slimeType = ModContent.NPCType(); if (Main.rand.NextBool(3)) { - num663 = ModContent.NPCType(); + slimeType = ModContent.NPCType(); } - int num664 = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, num663, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[num664].SetDefaults(num663); - Main.npc[num664].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; - Main.npc[num664].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; - Main.npc[num664].ai[0] = (float)(-1000 * Main.rand.Next(3)); - Main.npc[num664].ai[1] = 0f; - if (Main.netMode == NetmodeID.Server && num664 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0); + int slimeSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, slimeType, 0, 0f, 0f, 0f, 0f, 255); + Main.npc[slimeSpawn].SetDefaults(slimeType); + Main.npc[slimeSpawn].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; + Main.npc[slimeSpawn].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; + Main.npc[slimeSpawn].ai[0] = (float)(-1000 * Main.rand.Next(3)); + Main.npc[slimeSpawn].ai[1] = 0f; + if (Main.netMode == NetmodeID.Server && slimeSpawn < Main.maxNPCs) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn, 0f, 0f, 0f, 0, 0, 0); } } } diff --git a/NPCs/SlimeGod/EbonianPaladin.cs b/NPCs/SlimeGod/EbonianPaladin.cs index ba6c41d255..09a2661ab7 100644 --- a/NPCs/SlimeGod/EbonianPaladin.cs +++ b/NPCs/SlimeGod/EbonianPaladin.cs @@ -177,34 +177,33 @@ namespace CalamityMod.NPCs.SlimeGod NPC.TargetClosest(false); player = Main.player[NPC.target]; Vector2 vectorAimedAheadOfTarget = player.Center + new Vector2((float)Math.Round(player.velocity.X), 0f).SafeNormalize(Vector2.Zero) * 960f; - Point point2 = vectorAimedAheadOfTarget.ToTileCoordinates(); - int num5 = 5; - int num8 = 0; - while (num8 < 100) + Point teleportAheadPos = vectorAimedAheadOfTarget.ToTileCoordinates(); + int maxTeleportTries = 0; + while (maxTeleportTries < 100) { - num8++; - int num9 = Main.rand.Next(point2.X - num5, point2.X + num5 + 1); - int num10 = Main.rand.Next(point2.Y - num5, point2.Y); - if (Main.tile[num9, num10].HasUnactuatedTile) + maxTeleportTries++; + int teleportPosX = Main.rand.Next(teleportAheadPos.X - 5, teleportAheadPos.X + 6); + int teleportPosY = Main.rand.Next(teleportAheadPos.Y - 5, teleportAheadPos.Y); + if (Main.tile[teleportPosX, teleportPosY].HasUnactuatedTile) continue; - bool flag4 = true; - if (flag4 && Main.tile[num9, num10].LiquidType == LiquidID.Lava) - flag4 = false; - if (flag4 && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) - flag4 = false; + bool canTeleport = true; + if (canTeleport && Main.tile[teleportPosX, teleportPosY].LiquidType == LiquidID.Lava) + canTeleport = false; + if (canTeleport && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) + canTeleport = false; - if (flag4) + if (canTeleport) { - NPC.localAI[0] = num9 * 16 + 8; - NPC.localAI[3] = num10 * 16 + 16; + NPC.localAI[0] = teleportPosX * 16 + 8; + NPC.localAI[3] = teleportPosY * 16 + 16; calamityGlobalNPC.newAI[0] = 0f; break; } } // Default teleport if the above conditions aren't met in 100 iterations - if (num8 >= 100) + if (maxTeleportTries >= 100) { Vector2 bottom = Main.player[Player.FindClosest(NPC.position, NPC.width, NPC.height)].Bottom; NPC.localAI[0] = bottom.X; @@ -371,24 +370,24 @@ namespace CalamityMod.NPCs.SlimeGod NPC.spriteDirection = NPC.direction; NPC.TargetClosest(); - Vector2 center40 = player.Center; - center40.Y -= 350f; - Vector2 vector272 = center40 - NPC.Center; + Vector2 targetCenter = player.Center; + targetCenter.Y -= 350f; + Vector2 targetDist = targetCenter - NPC.Center; if (NPC.ai[2] == 1f) { NPC.ai[1] += 1f; - vector272 = player.Center - NPC.Center; - vector272.Normalize(); - vector272 *= death ? 9f : revenge ? 8f : expertMode ? 7f : 6f; - NPC.velocity = (NPC.velocity * 4f + vector272) / 5f; + targetDist = player.Center - NPC.Center; + targetDist.Normalize(); + targetDist *= death ? 9f : revenge ? 8f : expertMode ? 7f : 6f; + NPC.velocity = (NPC.velocity * 4f + targetDist) / 5f; if (NPC.ai[1] > 12f) { NPC.ai[1] = 0f; NPC.ai[0] = 2.1f; NPC.ai[2] = 0f; - NPC.velocity = vector272; + NPC.velocity = targetDist; } } else @@ -400,9 +399,9 @@ namespace CalamityMod.NPCs.SlimeGod return; } - vector272.Normalize(); - vector272 *= (death ? 11f : revenge ? 10f : expertMode ? 9f : 8f) + distanceSpeedBoost; - NPC.velocity = (NPC.velocity * 5f + vector272) / 6f; + targetDist.Normalize(); + targetDist *= (death ? 11f : revenge ? 10f : expertMode ? 9f : 8f) + distanceSpeedBoost; + NPC.velocity = (NPC.velocity * 5f + targetDist) / 6f; } } else if (NPC.ai[0] == 2.1f) @@ -455,8 +454,8 @@ namespace CalamityMod.NPCs.SlimeGod } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(velocity2) * 30f * NPC.scale, velocity2, type, damage, 0f, Main.myPlayer); + Vector2 projFireDirection = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projFireDirection) * 30f * NPC.scale, projFireDirection, type, damage, 0f, Main.myPlayer); } } } @@ -604,11 +603,11 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Lavender; dustColor.A = 150; - for (int num245 = 0; num245 < 10; num245++) + for (int i = 0; i < 10; i++) { - int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); - Main.dust[num246].noGravity = true; - Main.dust[num246].velocity *= 0.5f; + int corruptDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + Main.dust[corruptDust].noGravity = true; + Main.dust[corruptDust].velocity *= 0.5f; } } else if (NPC.ai[0] == 7f) @@ -638,11 +637,11 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Lavender; dustColor.A = 150; - for (int num245 = 0; num245 < 10; num245++) + for (int i = 0; i < 10; i++) { - int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); - Main.dust[num246].noGravity = true; - Main.dust[num246].velocity *= 0.5f; + int corruptDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + Main.dust[corruptDust].noGravity = true; + Main.dust[corruptDust].velocity *= 0.5f; } } @@ -651,15 +650,15 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.life > 0) { - float num659 = lifeRatio; - num659 = num659 * 0.5f + 0.75f; - num659 *= scale; + float scaleRatio = lifeRatio; + scaleRatio = scaleRatio * 0.5f + 0.75f; + scaleRatio *= scale; - if (num659 != NPC.scale) + if (scaleRatio != NPC.scale) { NPC.position.X = NPC.position.X + (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y + (float)NPC.height; - NPC.scale = num659; + NPC.scale = scaleRatio; NPC.width = (int)(150f * NPC.scale); NPC.height = (int)(92f * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); @@ -668,24 +667,24 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.netMode != NetmodeID.MultiplayerClient) { - int num660 = (int)((double)NPC.lifeMax * 0.2); - if ((float)(NPC.life + num660) < bossLife) + int slimeSpawnThreshold = (int)((double)NPC.lifeMax * 0.2); + if ((float)(NPC.life + slimeSpawnThreshold) < bossLife) { bossLife = (float)NPC.life; - int num661 = Main.rand.Next(1, 3); - for (int num662 = 0; num662 < num661; num662++) + int randSlimeAmt = Main.rand.Next(1, 3); + for (int j = 0; j < randSlimeAmt; j++) { int x = (int)(NPC.position.X + (float)Main.rand.Next(NPC.width - 32)); int y = (int)(NPC.position.Y + (float)Main.rand.Next(NPC.height - 32)); - int num663 = ModContent.NPCType(); - int num664 = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, num663, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[num664].SetDefaults(num663); - Main.npc[num664].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; - Main.npc[num664].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; - Main.npc[num664].ai[0] = (float)(-1000 * Main.rand.Next(3)); - Main.npc[num664].ai[1] = 0f; - if (Main.netMode == NetmodeID.Server && num664 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0); + int slimeType = ModContent.NPCType(); + int slimeSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, slimeType, 0, 0f, 0f, 0f, 0f, 255); + Main.npc[slimeSpawn].SetDefaults(slimeType); + Main.npc[slimeSpawn].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; + Main.npc[slimeSpawn].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; + Main.npc[slimeSpawn].ai[0] = (float)(-1000 * Main.rand.Next(3)); + Main.npc[slimeSpawn].ai[1] = 0f; + if (Main.netMode == NetmodeID.Server && slimeSpawn < Main.maxNPCs) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn, 0f, 0f, 0f, 0, 0, 0); } } } diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index ac07830de4..ca478c3440 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -221,27 +221,27 @@ namespace CalamityMod.NPCs.SlimeGod NPC.height = 40; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { Color color = Main.rand.NextBool() ? Color.Lavender : Color.Crimson; color.A = 150; - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, color, 2f); - Main.dust[num622].velocity *= 3f; + int slimyDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, color, 2f); + Main.dust[slimyDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[slimyDust].scale = 0.5f; + Main.dust[slimyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { Color color = Main.rand.NextBool() ? Color.Lavender : Color.Crimson; color.A = 150; - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, color, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, color, 2f); - Main.dust[num624].velocity *= 2f; + int slimyDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, color, 3f); + Main.dust[slimyDust2].noGravity = true; + Main.dust[slimyDust2].velocity *= 5f; + slimyDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, color, 2f); + Main.dust[slimyDust2].velocity *= 2f; } // Let the player know that the Slime God isn't dead fr @@ -432,9 +432,9 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.getGoodWorld) flySpeed *= 1.25f; - Vector2 vector167 = new Vector2(NPC.Center.X + (NPC.direction * 20), NPC.Center.Y + 6f); + Vector2 flyDirection = new Vector2(NPC.Center.X + (NPC.direction * 20), NPC.Center.Y + 6f); Vector2 flyDestination = GetFlyDestination(player); - Vector2 idealVelocity = (flyDestination - vector167).SafeNormalize(Vector2.UnitY) * flySpeed; + Vector2 idealVelocity = (flyDestination - flyDirection).SafeNormalize(Vector2.UnitY) * flySpeed; float distanceFromFlyDestination = NPC.Distance(flyDestination); @@ -475,11 +475,11 @@ namespace CalamityMod.NPCs.SlimeGod // If multiple slimes are present, and they are all relatively close together, try to stay in their general area. // If they are far apart, try to stay towards the closest slime. // If no slimes exist, or they are all extremely far away, try to stay near the target player instead. - // TODO -- Consider renaming the big slime god's internal names to be more intuitive? - int crimulanSlimeID = ModContent.NPCType(); - int crimulanSlimeSplitID = ModContent.NPCType(); - int ebonianSlimeID = ModContent.NPCType(); - int ebonianSlimeSplitID = ModContent.NPCType(); + + int largeCrimulanPaladin = ModContent.NPCType(); + int splitCrimulanPaladin = ModContent.NPCType(); + int largeEbonianPaladin = ModContent.NPCType(); + int splitEbonianPaladin = ModContent.NPCType(); List largeSlimes = new(); float ignoreGeneralAreaDistanceThreshold = 750f; @@ -489,7 +489,7 @@ namespace CalamityMod.NPCs.SlimeGod for (int i = 0; i < Main.maxNPCs; i++) { int npcType = Main.npc[i].type; - if (npcType != crimulanSlimeID && npcType != crimulanSlimeSplitID && npcType != ebonianSlimeID && npcType != ebonianSlimeSplitID) + if (npcType != largeCrimulanPaladin && npcType != splitCrimulanPaladin && npcType != largeEbonianPaladin && npcType != splitEbonianPaladin) continue; if (!Main.npc[i].active) @@ -539,44 +539,41 @@ namespace CalamityMod.NPCs.SlimeGod { spriteEffects = SpriteEffects.FlipHorizontally; } - Color color24 = NPC.GetAlpha(drawColor); - Color color25 = Lighting.GetColor((int)((double)NPC.position.X + (double)NPC.width * 0.5) / 16, (int)(((double)NPC.position.Y + (double)NPC.height * 0.5) / 16.0)); + Color drawColorAlpha = NPC.GetAlpha(drawColor); + Color colorLightingArea = Lighting.GetColor((int)((double)NPC.position.X + (double)NPC.width * 0.5) / 16, (int)(((double)NPC.position.Y + (double)NPC.height * 0.5) / 16.0)); Texture2D texture2D3 = TextureAssets.Npc[NPC.type].Value; Texture2D pog = ModContent.Request("CalamityMod/NPCs/SlimeGod/SlimeGodEyes").Value; - int num156 = TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type]; - int y3 = num156 * (int)NPC.frameCounter; - Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, num156); - Vector2 origin2 = rectangle.Size() / 2f; - int num157 = 8; - int num158 = 2; - int num159 = 1; - float num160 = 0f; - int num161 = num159; - spriteBatch.Draw(texture2D3, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY), NPC.frame, color24, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, spriteEffects, 0); + int frameTexture = TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type]; + int y3 = frameTexture * (int)NPC.frameCounter; + Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, frameTexture); + Vector2 halfRect = rectangle.Size() / 2f; + int twoConst = 2; + int coreID = 1; + spriteBatch.Draw(texture2D3, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY), NPC.frame, drawColorAlpha, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, spriteEffects, 0); if (Main.zenithWorld) { - spriteBatch.Draw(pog, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY), NPC.frame, color24, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, spriteEffects, 0); + spriteBatch.Draw(pog, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY), NPC.frame, drawColorAlpha, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, spriteEffects, 0); } if (!Main.zenithWorld) - while (((num158 > 0 && num161 < num157) || (num158 < 0 && num161 > num157)) && CalamityConfig.Instance.Afterimages) + while (((twoConst > 0 && coreID < 8) || (twoConst < 0 && coreID > 8)) && CalamityConfig.Instance.Afterimages) { - Color color26 = NPC.GetAlpha(color25); + Color colorLightingAlpha = NPC.GetAlpha(colorLightingArea); { goto IL_6899; } IL_6881: - num161 += num158; + coreID += twoConst; continue; IL_6899: - float num164 = (float)(num157 - num161); - if (num158 < 0) + float trailLengthMult = (float)(8 - coreID); + if (twoConst < 0) { - num164 = (float)(num159 - num161); + trailLengthMult = (float)(1 - coreID); } - color26 *= num164 / ((float)NPCID.Sets.TrailCacheLength[NPC.type] * 1.5f); - Vector2 value4 = NPC.oldPos[num161]; - float num165 = NPC.rotation; - Main.spriteBatch.Draw(texture2D3, value4 + NPC.Size / 2f - screenPos + new Vector2(0, NPC.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, num165 + NPC.rotation * num160 * (float)(num161 - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, NPC.scale, spriteEffects, 0f); + colorLightingAlpha *= trailLengthMult / ((float)NPCID.Sets.TrailCacheLength[NPC.type] * 1.5f); + Vector2 drawPosition = NPC.oldPos[coreID]; + float coreRotate = NPC.rotation; + Main.spriteBatch.Draw(texture2D3, drawPosition + NPC.Size / 2f - screenPos + new Vector2(0, NPC.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), colorLightingAlpha, coreRotate + NPC.rotation * 0f * (float)(coreID - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), halfRect, NPC.scale, spriteEffects, 0f); goto IL_6881; } return false; @@ -638,7 +635,7 @@ namespace CalamityMod.NPCs.SlimeGod npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB Gelatin Crystal drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ItemID.QueenSlimeCrystal); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ItemID.QueenSlimeCrystal, hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedSlimeGod, ModContent.ItemType(), desc: DropHelper.FirstKillText); diff --git a/NPCs/SlimeGod/SplitCrimulanPaladin.cs b/NPCs/SlimeGod/SplitCrimulanPaladin.cs index c8182af5fe..344477b686 100644 --- a/NPCs/SlimeGod/SplitCrimulanPaladin.cs +++ b/NPCs/SlimeGod/SplitCrimulanPaladin.cs @@ -22,7 +22,7 @@ namespace CalamityMod.NPCs.SlimeGod { Main.npcFrameCount[NPC.type] = 6; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.6f, PortraitScale = 1f, @@ -174,34 +174,33 @@ namespace CalamityMod.NPCs.SlimeGod NPC.TargetClosest(false); player = Main.player[NPC.target]; Vector2 vectorAimedAheadOfTarget = player.Center + new Vector2((float)Math.Round(player.velocity.X), 0f).SafeNormalize(Vector2.Zero) * 1120f; - Point point2 = vectorAimedAheadOfTarget.ToTileCoordinates(); - int num5 = 5; - int num8 = 0; - while (num8 < 100) + Point teleportAheadPos = vectorAimedAheadOfTarget.ToTileCoordinates(); + int maxTeleportTries = 0; + while (maxTeleportTries < 100) { - num8++; - int num9 = Main.rand.Next(point2.X - num5, point2.X + num5 + 1); - int num10 = Main.rand.Next(point2.Y - num5, point2.Y); - if (Main.tile[num9, num10].HasUnactuatedTile) + maxTeleportTries++; + int teleportPosX = Main.rand.Next(teleportAheadPos.X - 5, teleportAheadPos.X + 6); + int teleportPosY = Main.rand.Next(teleportAheadPos.Y - 5, teleportAheadPos.Y); + if (Main.tile[teleportPosX, teleportPosY].HasUnactuatedTile) continue; - bool flag4 = true; - if (flag4 && Main.tile[num9, num10].LiquidType == LiquidID.Lava) - flag4 = false; - if (flag4 && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) - flag4 = false; + bool canTeleport = true; + if (canTeleport && Main.tile[teleportPosX, teleportPosY].LiquidType == LiquidID.Lava) + canTeleport = false; + if (canTeleport && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) + canTeleport = false; - if (flag4) + if (canTeleport) { - NPC.localAI[0] = num9 * 16 + 8; - NPC.localAI[3] = num10 * 16 + 16; + NPC.localAI[0] = teleportPosX * 16 + 8; + NPC.localAI[3] = teleportPosY * 16 + 16; NPC.ai[3] = 0f; break; } } // Default teleport if the above conditions aren't met in 100 iterations - if (num8 >= 100) + if (maxTeleportTries >= 100) { Vector2 bottom = Main.player[Player.FindClosest(NPC.position, NPC.width, NPC.height)].Bottom; NPC.localAI[0] = bottom.X; @@ -344,24 +343,24 @@ namespace CalamityMod.NPCs.SlimeGod NPC.spriteDirection = NPC.direction; NPC.TargetClosest(); - Vector2 center40 = player.Center; - center40.Y -= 350f; - Vector2 vector272 = center40 - NPC.Center; + Vector2 targetCenter = player.Center; + targetCenter.Y -= 350f; + Vector2 targetDist = targetCenter - NPC.Center; if (NPC.ai[2] == 1f) { NPC.ai[1] += 1f; - vector272 = player.Center - NPC.Center; - vector272.Normalize(); - vector272 *= death ? 11f : revenge ? 10f : expertMode ? 9f : 8f; - NPC.velocity = (NPC.velocity * 4f + vector272) / 5f; + targetDist = player.Center - NPC.Center; + targetDist.Normalize(); + targetDist *= death ? 11f : revenge ? 10f : expertMode ? 9f : 8f; + NPC.velocity = (NPC.velocity * 4f + targetDist) / 5f; if (NPC.ai[1] > 12f) { NPC.ai[1] = 0f; NPC.ai[0] = 1.1f; NPC.ai[2] = 0f; - NPC.velocity = vector272; + NPC.velocity = targetDist; } } else @@ -373,9 +372,9 @@ namespace CalamityMod.NPCs.SlimeGod return; } - vector272.Normalize(); - vector272 *= (death ? 13f : revenge ? 12f : expertMode ? 11f : 10f) + distanceSpeedBoost; - NPC.velocity = (NPC.velocity * 5f + vector272) / 6f; + targetDist.Normalize(); + targetDist *= (death ? 13f : revenge ? 12f : expertMode ? 11f : 10f) + distanceSpeedBoost; + NPC.velocity = (NPC.velocity * 5f + targetDist) / 6f; } } else if (NPC.ai[0] == 1.1f) @@ -424,8 +423,8 @@ namespace CalamityMod.NPCs.SlimeGod } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(velocity2) * 30f * NPC.scale, velocity2, type, damage, 0f, Main.myPlayer); + Vector2 projFireDirection = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projFireDirection) * 30f * NPC.scale, projFireDirection, type, damage, 0f, Main.myPlayer); } } } @@ -570,11 +569,11 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Crimson; dustColor.A = 150; - for (int num245 = 0; num245 < 10; num245++) + for (int i = 0; i < 10; i++) { - int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); - Main.dust[num246].noGravity = true; - Main.dust[num246].velocity *= 0.5f; + int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + Main.dust[crimsonDust].noGravity = true; + Main.dust[crimsonDust].velocity *= 0.5f; } } else if (NPC.ai[0] == 6f) @@ -604,11 +603,11 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Crimson; dustColor.A = 150; - for (int num245 = 0; num245 < 10; num245++) + for (int i = 0; i < 10; i++) { - int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); - Main.dust[num246].noGravity = true; - Main.dust[num246].velocity *= 0.5f; + int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + Main.dust[crimsonDust].noGravity = true; + Main.dust[crimsonDust].velocity *= 0.5f; } } @@ -617,15 +616,15 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.life > 0) { - float num659 = lifeRatio; - num659 = num659 * 0.5f + 0.75f; - num659 *= scale; + float scaleRatio = lifeRatio; + scaleRatio = scaleRatio * 0.5f + 0.75f; + scaleRatio *= scale; - if (num659 != NPC.scale) + if (scaleRatio != NPC.scale) { NPC.position.X = NPC.position.X + (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y + (float)NPC.height; - NPC.scale = num659 * 0.75f; + NPC.scale = scaleRatio * 0.75f; NPC.width = (int)(150f * NPC.scale); NPC.height = (int)(92f * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); @@ -634,25 +633,25 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.netMode != NetmodeID.MultiplayerClient) { - int num660 = (int)((double)NPC.lifeMax * 0.15); - if ((float)(NPC.life + num660) < bossLife) + int slimeSpawnThreshold = (int)((double)NPC.lifeMax * 0.15); + if ((float)(NPC.life + slimeSpawnThreshold) < bossLife) { bossLife = (float)NPC.life; int x = (int)(NPC.position.X + (float)Main.rand.Next(NPC.width - 32)); int y = (int)(NPC.position.Y + (float)Main.rand.Next(NPC.height - 32)); - int num663 = ModContent.NPCType(); + int slimeType = ModContent.NPCType(); if (Main.rand.NextBool(3)) { - num663 = ModContent.NPCType(); + slimeType = ModContent.NPCType(); } - int num664 = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, num663, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[num664].SetDefaults(num663); - Main.npc[num664].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; - Main.npc[num664].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; - Main.npc[num664].ai[0] = (float)(-1000 * Main.rand.Next(3)); - Main.npc[num664].ai[1] = 0f; - if (Main.netMode == NetmodeID.Server && num664 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0); + int slimeSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, slimeType, 0, 0f, 0f, 0f, 0f, 255); + Main.npc[slimeSpawn].SetDefaults(slimeType); + Main.npc[slimeSpawn].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; + Main.npc[slimeSpawn].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; + Main.npc[slimeSpawn].ai[0] = (float)(-1000 * Main.rand.Next(3)); + Main.npc[slimeSpawn].ai[1] = 0f; + if (Main.netMode == NetmodeID.Server && slimeSpawn < Main.maxNPCs) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn, 0f, 0f, 0f, 0, 0, 0); } } } @@ -696,23 +695,23 @@ namespace CalamityMod.NPCs.SlimeGod NPC.height = 50; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 2f); - Main.dust[num622].velocity *= 3f; + int crimDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 2f); + Main.dust[crimDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[crimDust].scale = 0.5f; + Main.dust[crimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 2f); - Main.dust[num624].velocity *= 2f; + int crimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 3f); + Main.dust[crimDust2].noGravity = true; + Main.dust[crimDust2].velocity *= 5f; + crimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 2f); + Main.dust[crimDust2].velocity *= 2f; } } } diff --git a/NPCs/SlimeGod/SplitEbonianPaladin.cs b/NPCs/SlimeGod/SplitEbonianPaladin.cs index 5e0fb58f7b..80772fbe31 100644 --- a/NPCs/SlimeGod/SplitEbonianPaladin.cs +++ b/NPCs/SlimeGod/SplitEbonianPaladin.cs @@ -22,7 +22,7 @@ namespace CalamityMod.NPCs.SlimeGod { Main.npcFrameCount[NPC.type] = 6; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.6f, PortraitScale = 1f, @@ -170,34 +170,33 @@ namespace CalamityMod.NPCs.SlimeGod NPC.TargetClosest(false); player = Main.player[NPC.target]; Vector2 vectorAimedAheadOfTarget = player.Center + new Vector2((float)Math.Round(player.velocity.X), 0f).SafeNormalize(Vector2.Zero) * 1120f; - Point point2 = vectorAimedAheadOfTarget.ToTileCoordinates(); - int num5 = 5; - int num8 = 0; - while (num8 < 100) + Point teleportAheadPos = vectorAimedAheadOfTarget.ToTileCoordinates(); + int maxTeleportTries = 0; + while (maxTeleportTries < 100) { - num8++; - int num9 = Main.rand.Next(point2.X - num5, point2.X + num5 + 1); - int num10 = Main.rand.Next(point2.Y - num5, point2.Y); - if (Main.tile[num9, num10].HasUnactuatedTile) + maxTeleportTries++; + int teleportPosX = Main.rand.Next(teleportAheadPos.X - 5, teleportAheadPos.X + 6); + int teleportPosY = Main.rand.Next(teleportAheadPos.Y - 5, teleportAheadPos.Y); + if (Main.tile[teleportPosX, teleportPosY].HasUnactuatedTile) continue; - bool flag4 = true; - if (flag4 && Main.tile[num9, num10].LiquidType == LiquidID.Lava) - flag4 = false; - if (flag4 && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) - flag4 = false; + bool canTeleport = true; + if (canTeleport && Main.tile[teleportPosX, teleportPosY].LiquidType == LiquidID.Lava) + canTeleport = false; + if (canTeleport && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) + canTeleport = false; - if (flag4) + if (canTeleport) { - NPC.localAI[0] = num9 * 16 + 8; - NPC.localAI[3] = num10 * 16 + 16; + NPC.localAI[0] = teleportPosX * 16 + 8; + NPC.localAI[3] = teleportPosY * 16 + 16; NPC.ai[3] = 0f; break; } } // Default teleport if the above conditions aren't met in 100 iterations - if (num8 >= 100) + if (maxTeleportTries >= 100) { Vector2 bottom = Main.player[Player.FindClosest(NPC.position, NPC.width, NPC.height)].Bottom; NPC.localAI[0] = bottom.X; @@ -357,24 +356,24 @@ namespace CalamityMod.NPCs.SlimeGod NPC.spriteDirection = NPC.direction; NPC.TargetClosest(); - Vector2 center40 = player.Center; - center40.Y -= 350f; - Vector2 vector272 = center40 - NPC.Center; + Vector2 targetCenter = player.Center; + targetCenter.Y -= 350f; + Vector2 targetDist = targetCenter - NPC.Center; if (NPC.ai[2] == 1f) { NPC.ai[1] += 1f; - vector272 = player.Center - NPC.Center; - vector272.Normalize(); - vector272 *= death ? 10f : revenge ? 9f : expertMode ? 8f : 7f; - NPC.velocity = (NPC.velocity * 4f + vector272) / 5f; + targetDist = player.Center - NPC.Center; + targetDist.Normalize(); + targetDist *= death ? 10f : revenge ? 9f : expertMode ? 8f : 7f; + NPC.velocity = (NPC.velocity * 4f + targetDist) / 5f; if (NPC.ai[1] > 12f) { NPC.ai[1] = 0f; NPC.ai[0] = 2.1f; NPC.ai[2] = 0f; - NPC.velocity = vector272; + NPC.velocity = targetDist; } } else @@ -386,9 +385,9 @@ namespace CalamityMod.NPCs.SlimeGod return; } - vector272.Normalize(); - vector272 *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; - NPC.velocity = (NPC.velocity * 5f + vector272) / 6f; + targetDist.Normalize(); + targetDist *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; + NPC.velocity = (NPC.velocity * 5f + targetDist) / 6f; } } else if (NPC.ai[0] == 2.1f) @@ -441,8 +440,8 @@ namespace CalamityMod.NPCs.SlimeGod } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(velocity2) * 30f * NPC.scale, velocity2, type, damage, 0f, Main.myPlayer); + Vector2 projFireDirection = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projFireDirection) * 30f * NPC.scale, projFireDirection, type, damage, 0f, Main.myPlayer); } } } @@ -587,11 +586,11 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Lavender; dustColor.A = 150; - for (int num245 = 0; num245 < 10; num245++) + for (int i = 0; i < 10; i++) { - int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); - Main.dust[num246].noGravity = true; - Main.dust[num246].velocity *= 0.5f; + int corruptDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + Main.dust[corruptDust].noGravity = true; + Main.dust[corruptDust].velocity *= 0.5f; } } else if (NPC.ai[0] == 7f) @@ -621,11 +620,11 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Lavender; dustColor.A = 150; - for (int num245 = 0; num245 < 10; num245++) + for (int i = 0; i < 10; i++) { - int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); - Main.dust[num246].noGravity = true; - Main.dust[num246].velocity *= 0.5f; + int corruptDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + Main.dust[corruptDust].noGravity = true; + Main.dust[corruptDust].velocity *= 0.5f; } } @@ -634,15 +633,15 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.life > 0) { - float num659 = lifeRatio; - num659 = num659 * 0.5f + 0.75f; - num659 *= scale; + float scaleRatio = lifeRatio; + scaleRatio = scaleRatio * 0.5f + 0.75f; + scaleRatio *= scale; - if (num659 != NPC.scale) + if (scaleRatio != NPC.scale) { NPC.position.X = NPC.position.X + (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y + (float)NPC.height; - NPC.scale = num659 * 0.75f; + NPC.scale = scaleRatio * 0.75f; NPC.width = (int)(150f * NPC.scale); NPC.height = (int)(92f * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); @@ -651,21 +650,21 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.netMode != NetmodeID.MultiplayerClient) { - int num660 = (int)((double)NPC.lifeMax * 0.2); - if ((float)(NPC.life + num660) < bossLife) + int slimeSpawnThreshold = (int)((double)NPC.lifeMax * 0.2); + if ((float)(NPC.life + slimeSpawnThreshold) < bossLife) { bossLife = (float)NPC.life; int x = (int)(NPC.position.X + (float)Main.rand.Next(NPC.width - 32)); int y = (int)(NPC.position.Y + (float)Main.rand.Next(NPC.height - 32)); - int num663 = ModContent.NPCType(); - int num664 = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, num663, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[num664].SetDefaults(num663); - Main.npc[num664].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; - Main.npc[num664].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; - Main.npc[num664].ai[0] = (float)(-1000 * Main.rand.Next(3)); - Main.npc[num664].ai[1] = 0f; - if (Main.netMode == NetmodeID.Server && num664 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0); + int slimeType = ModContent.NPCType(); + int slimeSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, slimeType, 0, 0f, 0f, 0f, 0f, 255); + Main.npc[slimeSpawn].SetDefaults(slimeType); + Main.npc[slimeSpawn].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; + Main.npc[slimeSpawn].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; + Main.npc[slimeSpawn].ai[0] = (float)(-1000 * Main.rand.Next(3)); + Main.npc[slimeSpawn].ai[1] = 0f; + if (Main.netMode == NetmodeID.Server && slimeSpawn < Main.maxNPCs) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn, 0f, 0f, 0f, 0, 0, 0); } } } @@ -709,23 +708,23 @@ namespace CalamityMod.NPCs.SlimeGod NPC.height = 50; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 2f); - Main.dust[num622].velocity *= 3f; + int corruptionDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 2f); + Main.dust[corruptionDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[corruptionDust].scale = 0.5f; + Main.dust[corruptionDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 2f); - Main.dust[num624].velocity *= 2f; + int corruptionDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 3f); + Main.dust[corruptionDust2].noGravity = true; + Main.dust[corruptionDust2].velocity *= 5f; + corruptionDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 2f); + Main.dust[corruptionDust2].velocity *= 2f; } } } diff --git a/NPCs/StormWeaver/StormWeaverBody.cs b/NPCs/StormWeaver/StormWeaverBody.cs index ff92fcd7c0..db749693ef 100644 --- a/NPCs/StormWeaver/StormWeaverBody.cs +++ b/NPCs/StormWeaver/StormWeaverBody.cs @@ -186,11 +186,11 @@ namespace CalamityMod.NPCs.StormWeaver { if (NPC.alpha != 0) { - for (int num934 = 0; num934 < 2; num934++) + for (int i = 0; i < 2; i++) { - int num935 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; + int redDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 182, 0f, 0f, 100, default, 2f); + Main.dust[redDust].noGravity = true; + Main.dust[redDust].noLight = true; } } @@ -199,41 +199,41 @@ namespace CalamityMod.NPCs.StormWeaver NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; + Vector2 segmentLocation = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); + float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); + targetX = (int)(targetX / 16f) * 16; + targetY = (int)(targetY / 16f) * 16; + segmentLocation.X = (int)(segmentLocation.X / 16f) * 16; + segmentLocation.Y = (int)(segmentLocation.Y / 16f) * 16; + targetX -= segmentLocation.X; + targetY -= segmentLocation.Y; - float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); + float targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentLocation = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + targetX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - segmentLocation.X; + targetY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - segmentLocation.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2(num192, num191) + MathHelper.PiOver2; - num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = NPC.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2(targetY, targetX) + MathHelper.PiOver2; + targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); + int npcWidth = NPC.width; + targetDistance = (targetDistance - npcWidth) / targetDistance; + targetX *= targetDistance; + targetY *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetX; + NPC.position.Y = NPC.position.Y + targetY; - if (num191 < 0f) + if (targetX < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetX > 0f) NPC.spriteDirection = 1; } } @@ -263,21 +263,21 @@ namespace CalamityMod.NPCs.StormWeaver chargePhaseGateValue *= 0.5f; Texture2D texture = phase2 ? ModContent.Request("CalamityMod/NPCs/StormWeaver/StormWeaverBodyNaked").Value : TextureAssets.Npc[NPC.type].Value; - Vector2 vector = new Vector2(texture.Width / 2, texture.Height / 2); + Vector2 halfSizeTexture = new Vector2(texture.Width / 2, texture.Height / 2); float chargeTelegraphTime = 120f; float chargeTelegraphGateValue = chargePhaseGateValue - chargeTelegraphTime; - Vector2 vector2 = NPC.Center - screenPos; - vector2 -= new Vector2(texture.Width, texture.Height) * NPC.scale / 2f; - vector2 += vector * NPC.scale + new Vector2(0f, NPC.gfxOffY); - Color color = NPC.GetAlpha(drawColor); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture.Width, texture.Height) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + Color drawColorAlpha = NPC.GetAlpha(drawColor); if (Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] > chargeTelegraphGateValue) - color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp((Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] - chargeTelegraphGateValue) / chargeTelegraphTime, 0f, 1f)); + drawColorAlpha = Color.Lerp(drawColorAlpha, Color.Cyan, MathHelper.Clamp((Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] - chargeTelegraphGateValue) / chargeTelegraphTime, 0f, 1f)); else if (Main.npc[(int)NPC.ai[2]].localAI[3] > 0f) - color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp(Main.npc[(int)NPC.ai[2]].localAI[3] / 60f, 0f, 1f)); + drawColorAlpha = Color.Lerp(drawColorAlpha, Color.Cyan, MathHelper.Clamp(Main.npc[(int)NPC.ai[2]].localAI[3] / 60f, 0f, 1f)); - spriteBatch.Draw(texture, vector2, NPC.frame, color, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, drawLocation, NPC.frame, drawColorAlpha, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -329,24 +329,24 @@ namespace CalamityMod.NPCs.StormWeaver NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 20; num621++) + for (int i = 0; i < 20; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int cosmiliteDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[cosmiliteDust].scale = 0.5f; + Main.dust[cosmiliteDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 40; num623++) + for (int j = 0; j < 40; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[cosmiliteDust2].noGravity = true; + Main.dust[cosmiliteDust2].velocity *= 5f; + cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust2].velocity *= 2f; } } } diff --git a/NPCs/StormWeaver/StormWeaverHead.cs b/NPCs/StormWeaver/StormWeaverHead.cs index 2b4d2b5ed6..14a4949b6a 100644 --- a/NPCs/StormWeaver/StormWeaverHead.cs +++ b/NPCs/StormWeaver/StormWeaverHead.cs @@ -59,7 +59,7 @@ namespace CalamityMod.NPCs.StormWeaver { NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.85f, PortraitScale = 0.75f, @@ -221,11 +221,11 @@ namespace CalamityMod.NPCs.StormWeaver if (NPC.alpha != 0) { - for (int num934 = 0; num934 < 2; num934++) + for (int i = 0; i < 2; i++) { - int num935 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; + int redDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 182, 0f, 0f, 100, default, 2f); + Main.dust[redDust].noGravity = true; + Main.dust[redDust].noLight = true; } } @@ -252,10 +252,10 @@ namespace CalamityMod.NPCs.StormWeaver totalLength = npcCounts - 20; } - for (int num36 = 0; num36 < totalLength; num36++) + for (int segments = 0; segments < totalLength; segments++) { int lol; - if (num36 >= 0 && num36 < totalLength - 1) + if (segments >= 0 && segments < totalLength - 1) 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); @@ -292,13 +292,13 @@ namespace CalamityMod.NPCs.StormWeaver if ((double)NPC.position.Y < Main.topWorld + 16f) { - for (int num957 = 0; num957 < Main.maxNPCs; num957++) + for (int j = 0; j < Main.maxNPCs; j++) { - if (Main.npc[num957].active && (Main.npc[num957].type == ModContent.NPCType() - || Main.npc[num957].type == ModContent.NPCType() - || Main.npc[num957].type == ModContent.NPCType())) + if (Main.npc[j].active && (Main.npc[j].type == ModContent.NPCType() + || Main.npc[j].type == ModContent.NPCType() + || Main.npc[j].type == ModContent.NPCType())) { - Main.npc[num957].active = false; + Main.npc[j].active = false; } } } @@ -306,13 +306,13 @@ namespace CalamityMod.NPCs.StormWeaver if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 10000f && NPC.life > 0) { - for (int num957 = 0; num957 < Main.maxNPCs; num957++) + for (int j = 0; j < Main.maxNPCs; j++) { - if (Main.npc[num957].type == ModContent.NPCType() - || Main.npc[num957].type == ModContent.NPCType() - || Main.npc[num957].type == ModContent.NPCType()) + if (Main.npc[j].type == ModContent.NPCType() + || Main.npc[j].type == ModContent.NPCType() + || Main.npc[j].type == ModContent.NPCType()) { - Main.npc[num957].active = false; + Main.npc[j].active = false; } } } @@ -588,16 +588,16 @@ namespace CalamityMod.NPCs.StormWeaver } int dustAmt = 5; - for (int num1474 = 0; num1474 < dustAmt; num1474++) + for (int k = 0; k < dustAmt; k++) { - Vector2 vector171 = Vector2.Normalize(NPC.velocity) * new Vector2((NPC.width + 50) / 2f, NPC.height) * 0.75f; - vector171 = vector171.RotatedBy((num1474 - (dustAmt / 2 - 1)) * (double)MathHelper.Pi / (float)dustAmt) + NPC.Center; - Vector2 value18 = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 206, value18.X, value18.Y, 100, default, 3f); - Main.dust[num1475].noGravity = true; - Main.dust[num1475].noLight = true; - Main.dust[num1475].velocity /= 4f; - Main.dust[num1475].velocity -= NPC.velocity; + Vector2 dustRotation = Vector2.Normalize(NPC.velocity) * new Vector2((NPC.width + 50) / 2f, NPC.height) * 0.75f; + dustRotation = dustRotation.RotatedBy((k - (dustAmt / 2 - 1)) * (double)MathHelper.Pi / (float)dustAmt) + NPC.Center; + Vector2 randDustMovement = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); + int bluishDust = Dust.NewDust(dustRotation + randDustMovement, 0, 0, 206, randDustMovement.X, randDustMovement.Y, 100, default, 3f); + Main.dust[bluishDust].noGravity = true; + Main.dust[bluishDust].noLight = true; + Main.dust[bluishDust].velocity /= 4f; + Main.dust[bluishDust].velocity -= NPC.velocity; } } else @@ -614,20 +614,20 @@ namespace CalamityMod.NPCs.StormWeaver acceleration *= 1.4f; } - float num48 = velocity * 1.3f; - float num49 = velocity * 0.7f; - float num50 = NPC.velocity.Length(); - if (num50 > 0f) + float fasterVelMult = velocity * 1.3f; + float slowerVelMult = velocity * 0.7f; + float weaverSpeed = NPC.velocity.Length(); + if (weaverSpeed > 0f) { - if (num50 > num48) + if (weaverSpeed > fasterVelMult) { NPC.velocity.Normalize(); - NPC.velocity *= num48; + NPC.velocity *= fasterVelMult; } - else if (num50 < num49) + else if (weaverSpeed < slowerVelMult) { NPC.velocity.Normalize(); - NPC.velocity *= num49; + NPC.velocity *= slowerVelMult; } } @@ -660,11 +660,11 @@ namespace CalamityMod.NPCs.StormWeaver source.X += i * 30f - (boltProjectiles * 15f); Vector2 boltVelocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-BoltAngleSpread / 2 + (BoltAngleSpread * i / boltProjectiles))); boltVelocity.X = boltVelocity.X + 3f * Main.rand.NextFloat() - 1.5f; - Vector2 vector94 = Main.player[NPC.target].Center - source; + Vector2 aimDirection = Main.player[NPC.target].Center - source; float ai = Main.rand.Next(100); int type = ProjectileID.CultistBossLightningOrbArc; int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), source, boltVelocity, type, damage, 0f, Main.myPlayer, vector94.ToRotation(), ai); + Projectile.NewProjectile(NPC.GetSource_FromAI(), source, boltVelocity, type, damage, 0f, Main.myPlayer, aimDirection.ToRotation(), ai); } } } @@ -688,12 +688,12 @@ namespace CalamityMod.NPCs.StormWeaver npcCenter.Y = (int)(npcCenter.Y / 16f) * 16; targetCenterX -= npcCenter.X; targetCenterY -= npcCenter.Y; - float num193 = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY); - float num196 = Math.Abs(targetCenterX); - float num197 = Math.Abs(targetCenterY); - float num198 = velocity / num193; - targetCenterX *= num198; - targetCenterY *= num198; + float targetDistance = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY); + float absoluteTargetX = Math.Abs(targetCenterX); + float absoluteTargetY = Math.Abs(targetCenterY); + float timeToReachTarget = velocity / targetDistance; + targetCenterX *= timeToReachTarget; + targetCenterY *= timeToReachTarget; if ((NPC.velocity.X > 0f && targetCenterX > 0f) || (NPC.velocity.X < 0f && targetCenterX < 0f) || (NPC.velocity.Y > 0f && targetCenterY > 0f) || (NPC.velocity.Y < 0f && targetCenterY < 0f)) { @@ -735,7 +735,7 @@ namespace CalamityMod.NPCs.StormWeaver } else { - if (num196 > num197) + if (absoluteTargetX > absoluteTargetY) { if (NPC.velocity.X < targetCenterX) NPC.velocity.X = NPC.velocity.X + acceleration * 1.1f; @@ -827,21 +827,21 @@ namespace CalamityMod.NPCs.StormWeaver chargePhaseGateValue *= 0.5f; Texture2D texture = phase2 ? ModContent.Request("CalamityMod/NPCs/StormWeaver/StormWeaverHeadNaked").Value : TextureAssets.Npc[NPC.type].Value; - Vector2 vector = new Vector2(texture.Width / 2, texture.Height / 2); + Vector2 halfSizeTexture = new Vector2(texture.Width / 2, texture.Height / 2); float chargeTelegraphTime = 120f; float chargeTelegraphGateValue = chargePhaseGateValue - chargeTelegraphTime; - Vector2 vector2 = NPC.Center - screenPos; - vector2 -= new Vector2(texture.Width, texture.Height) * NPC.scale / 2f; - vector2 += vector * NPC.scale + new Vector2(0f, NPC.gfxOffY); - Color color = NPC.GetAlpha(drawColor); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture.Width, texture.Height) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + Color drawColorAlpha = NPC.GetAlpha(drawColor); if (calamityGlobalNPC.newAI[0] > chargeTelegraphGateValue) - color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp((calamityGlobalNPC.newAI[0] - chargeTelegraphGateValue) / chargeTelegraphTime, 0f, 1f)); + drawColorAlpha = Color.Lerp(drawColorAlpha, Color.Cyan, MathHelper.Clamp((calamityGlobalNPC.newAI[0] - chargeTelegraphGateValue) / chargeTelegraphTime, 0f, 1f)); else if (NPC.localAI[3] > 0f) - color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp(NPC.localAI[3] / 60f, 0f, 1f)); + drawColorAlpha = Color.Lerp(drawColorAlpha, Color.Cyan, MathHelper.Clamp(NPC.localAI[3] / 60f, 0f, 1f)); - spriteBatch.Draw(texture, vector2, NPC.frame, color, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, drawLocation, NPC.frame, drawColorAlpha, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -892,34 +892,34 @@ namespace CalamityMod.NPCs.StormWeaver NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 20; num621++) + for (int i = 0; i < 20; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int cosmiliteDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[cosmiliteDust].scale = 0.5f; + Main.dust[cosmiliteDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 40; num623++) + for (int j = 0; j < 40; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[cosmiliteDust2].noGravity = true; + Main.dust[cosmiliteDust2].velocity *= 5f; + cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust2].velocity *= 2f; } } } public override bool CheckDead() { - for (int num569 = 0; num569 < Main.maxNPCs; num569++) + for (int k = 0; k < Main.maxNPCs; k++) { - if (Main.npc[num569].active && (Main.npc[num569].type == ModContent.NPCType() || Main.npc[num569].type == ModContent.NPCType())) - Main.npc[num569].life = 0; + if (Main.npc[k].active && (Main.npc[k].type == ModContent.NPCType() || Main.npc[k].type == ModContent.NPCType())) + Main.npc[k].life = 0; } return true; @@ -987,8 +987,8 @@ namespace CalamityMod.NPCs.StormWeaver // GFB Elemental Gauntlet and Quiver drops var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ModContent.ItemType()); - GFBOnly.Add(ModContent.ItemType()); + GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); + GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); } // Lore diff --git a/NPCs/StormWeaver/StormWeaverTail.cs b/NPCs/StormWeaver/StormWeaverTail.cs index e50b446d82..3ff0f7a02e 100644 --- a/NPCs/StormWeaver/StormWeaverTail.cs +++ b/NPCs/StormWeaver/StormWeaverTail.cs @@ -178,11 +178,11 @@ namespace CalamityMod.NPCs.StormWeaver { if (NPC.alpha != 0) { - for (int num934 = 0; num934 < 2; num934++) + for (int i = 0; i < 2; i++) { - int num935 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; + int redDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 182, 0f, 0f, 100, default, 2f); + Main.dust[redDust].noGravity = true; + Main.dust[redDust].noLight = true; } } @@ -191,41 +191,41 @@ namespace CalamityMod.NPCs.StormWeaver NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; + Vector2 segmentLocation = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); + float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); + targetX = (int)(targetX / 16f) * 16; + targetY = (int)(targetY / 16f) * 16; + segmentLocation.X = (int)(segmentLocation.X / 16f) * 16; + segmentLocation.Y = (int)(segmentLocation.Y / 16f) * 16; + targetX -= segmentLocation.X; + targetY -= segmentLocation.Y; - float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); + float targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentLocation = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + targetX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - segmentLocation.X; + targetY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - segmentLocation.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2(num192, num191) + MathHelper.PiOver2; - num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = NPC.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2(targetY, targetX) + MathHelper.PiOver2; + targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); + int npcWidth = NPC.width; + targetDistance = (targetDistance - npcWidth) / targetDistance; + targetX *= targetDistance; + targetY *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetX; + NPC.position.Y = NPC.position.Y + targetY; - if (num191 < 0f) + if (targetX < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetX > 0f) NPC.spriteDirection = 1; } } @@ -255,28 +255,28 @@ namespace CalamityMod.NPCs.StormWeaver chargePhaseGateValue *= 0.5f; Texture2D texture = phase2 ? ModContent.Request("CalamityMod/NPCs/StormWeaver/StormWeaverTailNaked").Value : TextureAssets.Npc[NPC.type].Value; - Vector2 vector = new Vector2(texture.Width / 2, texture.Height / 2); + Vector2 halfSizeTexture = new Vector2(texture.Width / 2, texture.Height / 2); float chargeTelegraphTime = 120f; float chargeTelegraphGateValue = chargePhaseGateValue - chargeTelegraphTime; - Vector2 vector2 = NPC.Center - screenPos; - vector2 -= new Vector2(texture.Width, texture.Height) * NPC.scale / 2f; - vector2 += vector * NPC.scale + new Vector2(0f, NPC.gfxOffY); - Color color = NPC.GetAlpha(drawColor); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture.Width, texture.Height) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + Color drawColorAlpha = NPC.GetAlpha(drawColor); if (Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] > chargeTelegraphGateValue) - color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp((Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] - chargeTelegraphGateValue) / chargeTelegraphTime, 0f, 1f)); + drawColorAlpha = Color.Lerp(drawColorAlpha, Color.Cyan, MathHelper.Clamp((Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] - chargeTelegraphGateValue) / chargeTelegraphTime, 0f, 1f)); else if (Main.npc[(int)NPC.ai[2]].localAI[3] > 0f) - color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp(Main.npc[(int)NPC.ai[2]].localAI[3] / 60f, 0f, 1f)); + drawColorAlpha = Color.Lerp(drawColorAlpha, Color.Cyan, MathHelper.Clamp(Main.npc[(int)NPC.ai[2]].localAI[3] / 60f, 0f, 1f)); - spriteBatch.Draw(texture, vector2, NPC.frame, color, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, drawLocation, NPC.frame, drawColorAlpha, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); if (!phase2) { texture = ModContent.Request("CalamityMod/NPCs/StormWeaver/StormWeaverTailGlow").Value; Color rainbowBecauseWhyTheFuckNot = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); - Color color37 = Color.Lerp(Color.White, rainbowBecauseWhyTheFuckNot, 0.5f); - spriteBatch.Draw(texture, vector2, NPC.frame, color37, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + Color drawColorAlpha37 = Color.Lerp(Color.White, rainbowBecauseWhyTheFuckNot, 0.5f); + spriteBatch.Draw(texture, drawLocation, NPC.frame, drawColorAlpha37, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } return false; @@ -323,24 +323,24 @@ namespace CalamityMod.NPCs.StormWeaver NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 20; num621++) + for (int i = 0; i < 20; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int cosmiliteDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[cosmiliteDust].scale = 0.5f; + Main.dust[cosmiliteDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 40; num623++) + for (int j = 0; j < 40; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[cosmiliteDust2].noGravity = true; + Main.dust[cosmiliteDust2].velocity *= 5f; + cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust2].velocity *= 2f; } } } diff --git a/NPCs/SulphurousSea/AnthozoanCrab.cs b/NPCs/SulphurousSea/AnthozoanCrab.cs index 1fb22965ea..9d2cc53e40 100644 --- a/NPCs/SulphurousSea/AnthozoanCrab.cs +++ b/NPCs/SulphurousSea/AnthozoanCrab.cs @@ -20,7 +20,7 @@ namespace CalamityMod.NPCs.SulphurousSea public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 16; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { SpriteDirection = 1 }; diff --git a/NPCs/SulphurousSea/AquaticUrchin.cs b/NPCs/SulphurousSea/AquaticUrchin.cs index 57da22c833..a90d2d0b56 100644 --- a/NPCs/SulphurousSea/AquaticUrchin.cs +++ b/NPCs/SulphurousSea/AquaticUrchin.cs @@ -15,7 +15,7 @@ namespace CalamityMod.NPCs.SulphurousSea { public override void SetStaticDefaults() { - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0); value.Position.Y += 12; value.PortraitPositionYOverride = 32f; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; diff --git a/NPCs/SulphurousSea/BelchingCoral.cs b/NPCs/SulphurousSea/BelchingCoral.cs index dc3cf80d16..16b7ee7f24 100644 --- a/NPCs/SulphurousSea/BelchingCoral.cs +++ b/NPCs/SulphurousSea/BelchingCoral.cs @@ -19,7 +19,7 @@ namespace CalamityMod.NPCs.SulphurousSea public const float CheckDistance = 480f; public override void SetStaticDefaults() { - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0); value.Position.Y += 4; value.PortraitPositionYOverride = 24f; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; diff --git a/NPCs/SulphurousSea/Gnasher.cs b/NPCs/SulphurousSea/Gnasher.cs index cc32836c3f..c84311fc14 100644 --- a/NPCs/SulphurousSea/Gnasher.cs +++ b/NPCs/SulphurousSea/Gnasher.cs @@ -14,7 +14,7 @@ namespace CalamityMod.NPCs.SulphurousSea public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 5; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { SpriteDirection = 1 }; @@ -56,43 +56,43 @@ namespace CalamityMod.NPCs.SulphurousSea public override void AI() { NPC.spriteDirection = (NPC.direction > 0) ? -1 : 1; - float num79 = (Main.player[NPC.target].Center - NPC.Center).Length(); - num79 *= 0.0025f; - if ((double)num79 > 1.5) + float targetDist = (Main.player[NPC.target].Center - NPC.Center).Length(); + targetDist *= 0.0025f; + if ((double)targetDist > 1.5) { - num79 = 1.5f; + targetDist = 1.5f; } - float num78; + float maxVelocity; if (Main.expertMode) { - num78 = 2.5f - num79; + maxVelocity = 2.5f - targetDist; } else { - num78 = 2.25f - num79; + maxVelocity = 2.25f - targetDist; } - num78 *= (CalamityWorld.death ? 1.2f : CalamityWorld.revenge ? 1f : 0.8f); - if (NPC.velocity.X < -num78 || NPC.velocity.X > num78) + maxVelocity *= (CalamityWorld.death ? 1.2f : CalamityWorld.revenge ? 1f : 0.8f); + if (NPC.velocity.X < -maxVelocity || NPC.velocity.X > maxVelocity) { if (NPC.velocity.Y == 0f) { NPC.velocity *= 0.8f; } } - else if (NPC.velocity.X < num78 && NPC.direction == 1) + else if (NPC.velocity.X < maxVelocity && NPC.direction == 1) { NPC.velocity.X = NPC.velocity.X + 1f; - if (NPC.velocity.X > num78) + if (NPC.velocity.X > maxVelocity) { - NPC.velocity.X = num78; + NPC.velocity.X = maxVelocity; } } - else if (NPC.velocity.X > -num78 && NPC.direction == -1) + else if (NPC.velocity.X > -maxVelocity && NPC.direction == -1) { NPC.velocity.X = NPC.velocity.X - 1f; - if (NPC.velocity.X < -num78) + if (NPC.velocity.X < -maxVelocity) { - NPC.velocity.X = -num78; + NPC.velocity.X = -maxVelocity; } } } diff --git a/NPCs/SulphurousSea/Sulflounder.cs b/NPCs/SulphurousSea/Sulflounder.cs index 41784e4fd8..d91dcee45e 100644 --- a/NPCs/SulphurousSea/Sulflounder.cs +++ b/NPCs/SulphurousSea/Sulflounder.cs @@ -15,7 +15,7 @@ namespace CalamityMod.NPCs.SulphurousSea public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 4; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0); value.Position.Y -= 10f; value.PortraitPositionYOverride = -36f; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; @@ -56,10 +56,10 @@ namespace CalamityMod.NPCs.SulphurousSea public override void AI() { NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; - int num = 200; + int alphaControl = 200; if (NPC.ai[2] == 0f) { - NPC.alpha = num; + NPC.alpha = alphaControl; NPC.TargetClosest(true); if (!Main.player[NPC.target].dead && (Main.player[NPC.target].Center - NPC.Center).Length() < 170f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) @@ -76,7 +76,7 @@ namespace CalamityMod.NPCs.SulphurousSea { if (NPC.alpha > 0) { - NPC.alpha -= num / 16; + NPC.alpha -= alphaControl / 16; if (NPC.alpha < 0) { NPC.alpha = 0; diff --git a/NPCs/SulphurousSea/Toxicatfish.cs b/NPCs/SulphurousSea/Toxicatfish.cs index b0b427a1fa..b08d54b05e 100644 --- a/NPCs/SulphurousSea/Toxicatfish.cs +++ b/NPCs/SulphurousSea/Toxicatfish.cs @@ -15,7 +15,7 @@ namespace CalamityMod.NPCs.SulphurousSea public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 4; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0); value.Position.X += 10f; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; } diff --git a/NPCs/SulphurousSea/Trasher.cs b/NPCs/SulphurousSea/Trasher.cs index cdfac804e1..6dbff3f85d 100644 --- a/NPCs/SulphurousSea/Trasher.cs +++ b/NPCs/SulphurousSea/Trasher.cs @@ -20,7 +20,7 @@ namespace CalamityMod.NPCs.SulphurousSea public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 8; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { SpriteDirection = 1, Scale = 0.65f, @@ -89,19 +89,19 @@ namespace CalamityMod.NPCs.SulphurousSea NPC.TargetClosest(true); } NPC.noTileCollide = false; - bool flag14 = hasBeenHit; + bool canAttack = hasBeenHit; NPC.TargetClosest(false); if (Main.player[NPC.target].wet && !Main.player[NPC.target].dead && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && (Main.player[NPC.target].Center - NPC.Center).Length() < 200f) { - flag14 = true; + canAttack = true; } - if (Main.player[NPC.target].dead && flag14) + if (Main.player[NPC.target].dead && canAttack) { - flag14 = false; + canAttack = false; } - if (!flag14) + if (!canAttack) { if (NPC.collideX) { @@ -126,7 +126,7 @@ namespace CalamityMod.NPCs.SulphurousSea } } } - if (flag14) + if (canAttack) { NPC.TargetClosest(true); NPC.velocity.X = NPC.velocity.X + (float)NPC.direction * (CalamityWorld.death ? 0.6f : CalamityWorld.revenge ? 0.45f : 0.3f); @@ -174,15 +174,15 @@ namespace CalamityMod.NPCs.SulphurousSea } } } - int num258 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num259 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } @@ -201,22 +201,22 @@ namespace CalamityMod.NPCs.SulphurousSea return; } NPC.noTileCollide = true; - float num823 = 1f; + float velocityBoost = 1f; NPC.TargetClosest(true); - bool flag51 = false; + bool closeToTargetX = false; if ((double)NPC.life < (double)NPC.lifeMax * 0.5 || CalamityWorld.death) { - num823 = 1.5f; + velocityBoost = 1.5f; } if ((double)NPC.life < (double)NPC.lifeMax * 0.25 || CalamityWorld.death) { - num823 = 2.5f; + velocityBoost = 2.5f; } if (Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) < 20f) { - flag51 = true; + closeToTargetX = true; } - if (flag51) + if (closeToTargetX) { NPC.velocity.X = NPC.velocity.X * 0.9f; if ((double)NPC.velocity.X > -0.1 && (double)NPC.velocity.X < 0.1) @@ -228,26 +228,26 @@ namespace CalamityMod.NPCs.SulphurousSea { if (NPC.direction > 0) { - NPC.velocity.X = (NPC.velocity.X * 20f + num823) / 21f; + NPC.velocity.X = (NPC.velocity.X * 20f + velocityBoost) / 21f; } if (NPC.direction < 0) { - NPC.velocity.X = (NPC.velocity.X * 20f - num823) / 21f; + NPC.velocity.X = (NPC.velocity.X * 20f - velocityBoost) / 21f; } } - int num854 = 80; - int num855 = 20; - Vector2 position2 = new Vector2(NPC.Center.X - (float)(num854 / 2), NPC.position.Y + (float)NPC.height - (float)num855); - bool flag52 = false; + int collisionWidth = 80; + int collisionHeight = 20; + Vector2 collisionSize = new Vector2(NPC.Center.X - (float)(collisionWidth / 2), NPC.position.Y + (float)NPC.height - (float)collisionHeight); + bool shouldFallThroughTiles = false; 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.position.Y + (float)NPC.height < Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height - 16f) { - flag52 = true; + shouldFallThroughTiles = true; } - if (flag52) + if (shouldFallThroughTiles) { NPC.velocity.Y = NPC.velocity.Y + 0.5f; } - else if (Collision.SolidCollision(position2, num854, num855)) + else if (Collision.SolidCollision(collisionSize, collisionWidth, collisionHeight)) { if (NPC.velocity.Y > 0f) { diff --git a/NPCs/SunkenSea/BabyGhostBell.cs b/NPCs/SunkenSea/BabyGhostBell.cs index 73816facfa..187eec59a4 100644 --- a/NPCs/SunkenSea/BabyGhostBell.cs +++ b/NPCs/SunkenSea/BabyGhostBell.cs @@ -142,13 +142,13 @@ namespace CalamityMod.NPCs.SunkenSea spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/SunkenSea/BabyGhostBellGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/SunkenSea/BabyGhostBellGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightBlue); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/SunkenSea/BabyGhostBellGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/SunkenSea/BlindedAngler.cs b/NPCs/SunkenSea/BlindedAngler.cs index 804650ce5b..ccba52a02b 100644 --- a/NPCs/SunkenSea/BlindedAngler.cs +++ b/NPCs/SunkenSea/BlindedAngler.cs @@ -85,13 +85,13 @@ namespace CalamityMod.NPCs.SunkenSea spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/SunkenSea/BlindedAnglerGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/SunkenSea/BlindedAnglerGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightBlue); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/SunkenSea/BlindedAnglerGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override bool? CanBeHitByProjectile(Projectile projectile) diff --git a/NPCs/SunkenSea/Clam.cs b/NPCs/SunkenSea/Clam.cs index 79e6e83989..101764fe4a 100644 --- a/NPCs/SunkenSea/Clam.cs +++ b/NPCs/SunkenSea/Clam.cs @@ -19,7 +19,7 @@ namespace CalamityMod.NPCs.SunkenSea public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 5; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { SpriteDirection = 1 }; @@ -121,12 +121,12 @@ namespace CalamityMod.NPCs.SunkenSea else if (NPC.velocity.Y == 0f) { NPC.ai[2] += 1f; - int num321 = 20; + int decelerationTimer = 20; if (NPC.ai[1] == 0f) { - num321 = 12; + decelerationTimer = 12; } - if (NPC.ai[2] < (float)num321) + if (NPC.ai[2] < (float)decelerationTimer) { NPC.velocity.X *= 0.9f; return; diff --git a/NPCs/SunkenSea/EutrophicRay.cs b/NPCs/SunkenSea/EutrophicRay.cs index f21cb523a9..2cee708a99 100644 --- a/NPCs/SunkenSea/EutrophicRay.cs +++ b/NPCs/SunkenSea/EutrophicRay.cs @@ -19,7 +19,7 @@ namespace CalamityMod.NPCs.SunkenSea public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 5; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0); value.Position.X += 24f; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; } @@ -184,13 +184,13 @@ namespace CalamityMod.NPCs.SunkenSea spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/SunkenSea/EutrophicRayGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/SunkenSea/EutrophicRayGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightBlue); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/SunkenSea/EutrophicRayGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override bool? CanBeHitByProjectile(Projectile projectile) diff --git a/NPCs/SunkenSea/GhostBell.cs b/NPCs/SunkenSea/GhostBell.cs index 857c2720b1..d01e9196ec 100644 --- a/NPCs/SunkenSea/GhostBell.cs +++ b/NPCs/SunkenSea/GhostBell.cs @@ -139,13 +139,13 @@ namespace CalamityMod.NPCs.SunkenSea spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/SunkenSea/GhostBellGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/SunkenSea/GhostBellGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightBlue); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/SunkenSea/GhostBellGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) diff --git a/NPCs/SunkenSea/GiantClam.cs b/NPCs/SunkenSea/GiantClam.cs index 2e3edf2b02..782165556a 100644 --- a/NPCs/SunkenSea/GiantClam.cs +++ b/NPCs/SunkenSea/GiantClam.cs @@ -42,7 +42,7 @@ namespace CalamityMod.NPCs.SunkenSea { Main.npcFrameCount[NPC.type] = 12; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.4f, }; @@ -212,17 +212,17 @@ namespace CalamityMod.NPCs.SunkenSea { if (Main.rand.NextBool()) { - int num5 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 226, 0f, 0f, 200, default, 1.5f); - Main.dust[num5].noGravity = true; - Main.dust[num5].velocity *= 0.75f; - Main.dust[num5].fadeIn = 1.3f; + int attackDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 226, 0f, 0f, 200, default, 1.5f); + Main.dust[attackDust].noGravity = true; + Main.dust[attackDust].velocity *= 0.75f; + Main.dust[attackDust].fadeIn = 1.3f; Vector2 vector = new Vector2((float)Main.rand.Next(-200, 201), (float)Main.rand.Next(-200, 201)); vector.Normalize(); vector *= (float)Main.rand.Next(100, 200) * 0.04f; - Main.dust[num5].velocity = vector; + Main.dust[attackDust].velocity = vector; vector.Normalize(); vector *= 34f; - Main.dust[num5].position = NPC.Center - vector; + Main.dust[attackDust].position = NPC.Center - vector; } NPC.alpha -= Main.hardMode ? 7 : 4; if (NPC.alpha <= 0) @@ -356,7 +356,7 @@ namespace CalamityMod.NPCs.SunkenSea else if (attack == 2) { SoundEngine.PlaySound(SoundID.Item67, NPC.position); - Vector2 value9 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + Vector2 clamPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); float spread = 45f * 0.0174f; double startAngle = Math.Atan2(NPC.velocity.X, NPC.velocity.Y) - spread / 2; double deltaAngle = spread / 8f; @@ -365,18 +365,18 @@ namespace CalamityMod.NPCs.SunkenSea int damage = Main.expertMode ? 28 : 35; float speed = 5f; Vector2 vector = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)(NPC.height / 2)); - float num6 = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - vector.X + (float)Main.rand.Next(-20, 21); - float num7 = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - vector.Y + (float)Main.rand.Next(-20, 21); - float num8 = (float)Math.Sqrt((double)(num6 * num6 + num7 * num7)); - num8 = speed / num8; - num6 *= num8; - num7 *= num8; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, num6, num7, projectileShot, damage, 0f, Main.myPlayer, 0f, 0f); + float targetXDist = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - vector.X + (float)Main.rand.Next(-20, 21); + float targetYDist = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - vector.Y + (float)Main.rand.Next(-20, 21); + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + targetDistance = speed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, targetXDist, targetYDist, projectileShot, damage, 0f, Main.myPlayer, 0f, 0f); for (int i = 0; i < 4; i++) { offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - Projectile.NewProjectile(NPC.GetSource_FromAI(), value9.X, value9.Y, (float)(Math.Sin(offsetAngle) * 3f), (float)(Math.Cos(offsetAngle) * 3f), projectileShot, damage, 0f, Main.myPlayer, 0f, 0f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), value9.X, value9.Y, (float)(-Math.Sin(offsetAngle) * 3f), (float)(-Math.Cos(offsetAngle) * 3f), projectileShot, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), clamPosition.X, clamPosition.Y, (float)(Math.Sin(offsetAngle) * 3f), (float)(Math.Cos(offsetAngle) * 3f), projectileShot, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), clamPosition.X, clamPosition.Y, (float)(-Math.Sin(offsetAngle) * 3f), (float)(-Math.Cos(offsetAngle) * 3f), projectileShot, damage, 0f, Main.myPlayer, 0f, 0f); } attack = -1; NPC.ai[3] = 0f; @@ -507,12 +507,12 @@ namespace CalamityMod.NPCs.SunkenSea Texture2D glowmask = ModContent.Request("CalamityMod/NPCs/SunkenSea/GiantClamGlow").Value; SpriteEffects spriteEffects = SpriteEffects.None; Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(texture.Width / 2), (float)(texture.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(texture.Width / 2), (float)(texture.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)glowmask.Width, (float)(glowmask.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightBlue); - Main.EntitySpriteDraw(glowmask, vector, NPC.frame, color, NPC.rotation, vector11, NPC.scale, spriteEffects, 0); + Main.EntitySpriteDraw(glowmask, vector, NPC.frame, color, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0); } public override void OnKill() diff --git a/NPCs/SunkenSea/PrismBack.cs b/NPCs/SunkenSea/PrismBack.cs index 124831a026..32cd648cf8 100644 --- a/NPCs/SunkenSea/PrismBack.cs +++ b/NPCs/SunkenSea/PrismBack.cs @@ -19,7 +19,7 @@ namespace CalamityMod.NPCs.SunkenSea public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 5; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { PortraitPositionXOverride = 0 }; @@ -130,13 +130,13 @@ namespace CalamityMod.NPCs.SunkenSea spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/SunkenSea/PrismBackGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/SunkenSea/PrismBackGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.Blue); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/SunkenSea/PrismBackGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override bool? CanBeHitByProjectile(Projectile projectile) diff --git a/NPCs/SunkenSea/SeaFloaty.cs b/NPCs/SunkenSea/SeaFloaty.cs index 22235e0dda..6f38094dd5 100644 --- a/NPCs/SunkenSea/SeaFloaty.cs +++ b/NPCs/SunkenSea/SeaFloaty.cs @@ -15,7 +15,7 @@ namespace CalamityMod.NPCs.SunkenSea public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 6; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { SpriteDirection = 1 }; diff --git a/NPCs/SunkenSea/SeaMinnow.cs b/NPCs/SunkenSea/SeaMinnow.cs index af2f8ea345..0b4a2fa887 100644 --- a/NPCs/SunkenSea/SeaMinnow.cs +++ b/NPCs/SunkenSea/SeaMinnow.cs @@ -51,7 +51,7 @@ namespace CalamityMod.NPCs.SunkenSea CalamityAI.PassiveSwimmingAI(NPC, Mod, 3, 150f, 0.25f, 0.15f, 6f, 6f, 0.05f); NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; NPC.noGravity = true; - bool flag14 = false; + bool shouldSwimAway = false; if (NPC.direction == 0) { NPC.TargetClosest(true); @@ -62,13 +62,13 @@ namespace CalamityMod.NPCs.SunkenSea if (Main.player[NPC.target].wet && !Main.player[NPC.target].dead && (Main.player[NPC.target].Center - NPC.Center).Length() < 150f) { - flag14 = true; + shouldSwimAway = true; } - if ((!Main.player[NPC.target].wet || Main.player[NPC.target].dead) && flag14) + if ((!Main.player[NPC.target].wet || Main.player[NPC.target].dead) && shouldSwimAway) { - flag14 = false; + shouldSwimAway = false; } - if (!flag14) + if (!shouldSwimAway) { if (NPC.collideX || NPC.velocity.X == 0f) { @@ -93,7 +93,7 @@ namespace CalamityMod.NPCs.SunkenSea } } } - if (flag14) + if (shouldSwimAway) { NPC.TargetClosest(true); NPC.velocity.X = NPC.velocity.X - (float)NPC.direction * 0.25f; @@ -140,15 +140,15 @@ namespace CalamityMod.NPCs.SunkenSea } } } - int num258 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num259 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/SunkenSea/SeaSerpent1.cs b/NPCs/SunkenSea/SeaSerpent1.cs index 8f213a375e..8a332e4ec3 100644 --- a/NPCs/SunkenSea/SeaSerpent1.cs +++ b/NPCs/SunkenSea/SeaSerpent1.cs @@ -19,7 +19,7 @@ namespace CalamityMod.NPCs.SunkenSea public override void SetStaticDefaults() { - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { CustomTexturePath = "CalamityMod/ExtraTextures/Bestiary/SeaSerpent_Bestiary", PortraitPositionXOverride = 40, @@ -144,149 +144,149 @@ namespace CalamityMod.NPCs.SunkenSea { NPC.active = false; } - float num188 = speed; - float num189 = turnSpeed; - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + 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); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); if (NPC.life > NPC.lifeMax * 0.99) { - num192 += 300; + targetYDist += 300; if (Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) < 250f) { if (NPC.velocity.X > 0f) { - num191 = Main.player[NPC.target].Center.X + 300f; + targetXDist = Main.player[NPC.target].Center.X + 300f; } else { - num191 = Main.player[NPC.target].Center.X - 300f; + targetXDist = Main.player[NPC.target].Center.X - 300f; } } } else { - num188 *= 1.5f; - num189 *= 1.5f; + currentSpeed *= 1.5f; + currentTurnSpeed *= 1.5f; } - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = NPC.velocity.Length(); - if (num50 > 0f) + float maxCurrentSpeed = currentSpeed * 1.3f; + float minCurrentSpeed = currentSpeed * 0.7f; + float speedCompare = NPC.velocity.Length(); + if (speedCompare > 0f) { - if (num50 > num48) + if (speedCompare > maxCurrentSpeed) { NPC.velocity.Normalize(); - NPC.velocity *= num48; + NPC.velocity *= maxCurrentSpeed; } - else if (num50 < num49) + else if (speedCompare < minCurrentSpeed) { NPC.velocity.Normalize(); - NPC.velocity *= num49; + NPC.velocity *= minCurrentSpeed; } } - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - float num196 = System.Math.Abs(num191); - float num197 = System.Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; - if ((NPC.velocity.X > 0f && num191 > 0f) || (NPC.velocity.X < 0f && num191 < 0f) || (NPC.velocity.Y > 0f && num192 > 0f) || (NPC.velocity.Y < 0f && num192 < 0f)) + targetXDist = (float)((int)(targetXDist / 16f) * 16); + targetYDist = (float)((int)(targetYDist / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDist -= segmentPosition.X; + targetYDist -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + float absoluteTargetX = System.Math.Abs(targetXDist); + float absoluteTargetY = System.Math.Abs(targetYDist); + float timeToReachTarget = currentSpeed / targetDistance; + targetXDist *= timeToReachTarget; + targetYDist *= timeToReachTarget; + if ((NPC.velocity.X > 0f && targetXDist > 0f) || (NPC.velocity.X < 0f && targetXDist < 0f) || (NPC.velocity.Y > 0f && targetYDist > 0f) || (NPC.velocity.Y < 0f && targetYDist < 0f)) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetXDist) { - NPC.velocity.X = NPC.velocity.X + num189; + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed; } else { - if (NPC.velocity.X > num191) + if (NPC.velocity.X > targetXDist) { - NPC.velocity.X = NPC.velocity.X - num189; + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed; } } - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetYDist) { - NPC.velocity.Y = NPC.velocity.Y + num189; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed; } else { - if (NPC.velocity.Y > num192) + if (NPC.velocity.Y > targetYDist) { - NPC.velocity.Y = NPC.velocity.Y - num189; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed; } } - if ((double)System.Math.Abs(num192) < (double)num188 * 0.2 && ((NPC.velocity.X > 0f && num191 < 0f) || (NPC.velocity.X < 0f && num191 > 0f))) + if ((double)System.Math.Abs(targetYDist) < (double)currentSpeed * 0.2 && ((NPC.velocity.X > 0f && targetXDist < 0f) || (NPC.velocity.X < 0f && targetXDist > 0f))) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num189 * 2f; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed * 2f; } else { - NPC.velocity.Y = NPC.velocity.Y - num189 * 2f; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed * 2f; } } - if ((double)System.Math.Abs(num191) < (double)num188 * 0.2 && ((NPC.velocity.Y > 0f && num192 < 0f) || (NPC.velocity.Y < 0f && num192 > 0f))) + if ((double)System.Math.Abs(targetXDist) < (double)currentSpeed * 0.2 && ((NPC.velocity.Y > 0f && targetYDist < 0f) || (NPC.velocity.Y < 0f && targetYDist > 0f))) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num189 * 2f; //changed from 2 + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed * 2f; //changed from 2 } else { - NPC.velocity.X = NPC.velocity.X - num189 * 2f; //changed from 2 + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed * 2f; //changed from 2 } } } else { - if (num196 > num197) + if (absoluteTargetX > absoluteTargetY) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetXDist) { - NPC.velocity.X = NPC.velocity.X + num189 * 1.1f; //changed from 1.1 + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed * 1.1f; //changed from 1.1 } - else if (NPC.velocity.X > num191) + else if (NPC.velocity.X > targetXDist) { - NPC.velocity.X = NPC.velocity.X - num189 * 1.1f; //changed from 1.1 + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed * 1.1f; //changed from 1.1 } - if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)num188 * 0.5) + if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)currentSpeed * 0.5) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num189; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed; } else { - NPC.velocity.Y = NPC.velocity.Y - num189; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed; } } } else { - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetYDist) { - NPC.velocity.Y = NPC.velocity.Y + num189 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed * 1.1f; } - else if (NPC.velocity.Y > num192) + else if (NPC.velocity.Y > targetYDist) { - NPC.velocity.Y = NPC.velocity.Y - num189 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed * 1.1f; } - if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)num188 * 0.5) + if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)currentSpeed * 0.5) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num189; + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed; } else { - NPC.velocity.X = NPC.velocity.X - num189; + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed; } } } diff --git a/NPCs/SunkenSea/SeaSerpent2.cs b/NPCs/SunkenSea/SeaSerpent2.cs index e631ce019d..fc7e14a9cb 100644 --- a/NPCs/SunkenSea/SeaSerpent2.cs +++ b/NPCs/SunkenSea/SeaSerpent2.cs @@ -87,39 +87,39 @@ namespace CalamityMod.NPCs.SunkenSea NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDist = (float)((int)(targetXDist / 16f) * 16); + targetYDist = (float)((int)(targetYDist / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDist -= segmentPosition.X; + targetYDist -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDist = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDist = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDist, (double)targetXDist) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDist; + NPC.position.Y = NPC.position.Y + targetYDist; - if (num191 < 0f) + if (targetXDist < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetXDist > 0f) NPC.spriteDirection = 1; } } diff --git a/NPCs/SunkenSea/SeaSerpent3.cs b/NPCs/SunkenSea/SeaSerpent3.cs index b1c257e61c..7c8873f0fa 100644 --- a/NPCs/SunkenSea/SeaSerpent3.cs +++ b/NPCs/SunkenSea/SeaSerpent3.cs @@ -85,39 +85,39 @@ namespace CalamityMod.NPCs.SunkenSea NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDist = (float)((int)(targetXDist / 16f) * 16); + targetYDist = (float)((int)(targetYDist / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDist -= segmentPosition.X; + targetYDist -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDist = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDist = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDist, (double)targetXDist) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDist; + NPC.position.Y = NPC.position.Y + targetYDist; - if (num191 < 0f) + if (targetXDist < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetXDist > 0f) NPC.spriteDirection = 1; } } diff --git a/NPCs/SunkenSea/SeaSerpent4.cs b/NPCs/SunkenSea/SeaSerpent4.cs index 884f30e531..9442d632d8 100644 --- a/NPCs/SunkenSea/SeaSerpent4.cs +++ b/NPCs/SunkenSea/SeaSerpent4.cs @@ -85,39 +85,39 @@ namespace CalamityMod.NPCs.SunkenSea NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDist = (float)((int)(targetXDist / 16f) * 16); + targetYDist = (float)((int)(targetYDist / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDist -= segmentPosition.X; + targetYDist -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDist = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDist = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDist, (double)targetXDist) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDist; + NPC.position.Y = NPC.position.Y + targetYDist; - if (num191 < 0f) + if (targetXDist < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetXDist > 0f) NPC.spriteDirection = 1; } } diff --git a/NPCs/SunkenSea/SeaSerpent5.cs b/NPCs/SunkenSea/SeaSerpent5.cs index f5b91b77e3..6728bd8461 100644 --- a/NPCs/SunkenSea/SeaSerpent5.cs +++ b/NPCs/SunkenSea/SeaSerpent5.cs @@ -85,39 +85,39 @@ namespace CalamityMod.NPCs.SunkenSea NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDist = (float)((int)(targetXDist / 16f) * 16); + targetYDist = (float)((int)(targetYDist / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDist -= segmentPosition.X; + targetYDist -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDist = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDist = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDist, (double)targetXDist) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDist; + NPC.position.Y = NPC.position.Y + targetYDist; - if (num191 < 0f) + if (targetXDist < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetXDist > 0f) NPC.spriteDirection = 1; } } diff --git a/NPCs/SupremeCalamitas/SepulcherBody.cs b/NPCs/SupremeCalamitas/SepulcherBody.cs index 34c639e08e..499ffeb018 100644 --- a/NPCs/SupremeCalamitas/SepulcherBody.cs +++ b/NPCs/SupremeCalamitas/SepulcherBody.cs @@ -122,12 +122,12 @@ namespace CalamityMod.NPCs.SupremeCalamitas spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = NPC.localAI[3] / 2f % 2f == 0f ? ModContent.Request("CalamityMod/NPCs/SupremeCalamitas/SepulcherBodyAlt").Value : TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/SupremeCalamitas/SepulcherHead.cs b/NPCs/SupremeCalamitas/SepulcherHead.cs index 6b2b3f59ab..3b33ce86eb 100644 --- a/NPCs/SupremeCalamitas/SepulcherHead.cs +++ b/NPCs/SupremeCalamitas/SepulcherHead.cs @@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void SetStaticDefaults() { NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { PortraitPositionXOverride = 30, PortraitPositionYOverride = 0, @@ -191,131 +191,131 @@ namespace CalamityMod.NPCs.SupremeCalamitas else NPC.Opacity = MathHelper.Clamp(NPC.Opacity + 0.165f, 0f, 1f); - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); - float num188 = BossRushEvent.BossRushActive ? 12.5f : 10f; - float num189 = BossRushEvent.BossRushActive ? 0.125f : 0.1f; + Vector2 segmentLocation = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); + float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); + float sepMaxSpeed = BossRushEvent.BossRushActive ? 12.5f : 10f; + float sepAcceleration = BossRushEvent.BossRushActive ? 0.125f : 0.1f; - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = NPC.velocity.Length(); - if (num50 > 0f) + float fasterMaxSpeed = sepMaxSpeed * 1.3f; + float slowerMaxSpeed = sepMaxSpeed * 0.7f; + float currentSpeed = NPC.velocity.Length(); + if (currentSpeed > 0f) { - if (num50 > num48) + if (currentSpeed > fasterMaxSpeed) { NPC.velocity.Normalize(); - NPC.velocity *= num48; + NPC.velocity *= fasterMaxSpeed; } - else if (num50 < num49) + else if (currentSpeed < slowerMaxSpeed) { NPC.velocity.Normalize(); - NPC.velocity *= num49; + NPC.velocity *= slowerMaxSpeed; } } - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); - float num196 = Math.Abs(num191); - float num197 = Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; - if ((NPC.velocity.X > 0f && num191 > 0f) || (NPC.velocity.X < 0f && num191 < 0f) || (NPC.velocity.Y > 0f && num192 > 0f) || (NPC.velocity.Y < 0f && num192 < 0f)) + targetX = (int)(targetX / 16f) * 16; + targetY = (int)(targetY / 16f) * 16; + segmentLocation.X = (int)(segmentLocation.X / 16f) * 16; + segmentLocation.Y = (int)(segmentLocation.Y / 16f) * 16; + targetX -= segmentLocation.X; + targetY -= segmentLocation.Y; + float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); + float absoluteTargetX = Math.Abs(targetX); + float absoluteTargetY = Math.Abs(targetY); + float timeToReachTarget = sepMaxSpeed / targetDistance; + targetX *= timeToReachTarget; + targetY *= timeToReachTarget; + if ((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f) || (NPC.velocity.Y > 0f && targetY > 0f) || (NPC.velocity.Y < 0f && targetY < 0f)) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetX) { - NPC.velocity.X = NPC.velocity.X + num189; + NPC.velocity.X = NPC.velocity.X + sepAcceleration; } else { - if (NPC.velocity.X > num191) + if (NPC.velocity.X > targetX) { - NPC.velocity.X = NPC.velocity.X - num189; + NPC.velocity.X = NPC.velocity.X - sepAcceleration; } } - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetY) { - NPC.velocity.Y = NPC.velocity.Y + num189; + NPC.velocity.Y = NPC.velocity.Y + sepAcceleration; } else { - if (NPC.velocity.Y > num192) + if (NPC.velocity.Y > targetY) { - NPC.velocity.Y = NPC.velocity.Y - num189; + NPC.velocity.Y = NPC.velocity.Y - sepAcceleration; } } - if (Math.Abs(num192) < num188 * 0.2 && ((NPC.velocity.X > 0f && num191 < 0f) || (NPC.velocity.X < 0f && num191 > 0f))) + if (Math.Abs(targetY) < sepMaxSpeed * 0.2 && ((NPC.velocity.X > 0f && targetX < 0f) || (NPC.velocity.X < 0f && targetX > 0f))) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num189 * 2f; + NPC.velocity.Y = NPC.velocity.Y + sepAcceleration * 2f; } else { - NPC.velocity.Y = NPC.velocity.Y - num189 * 2f; + NPC.velocity.Y = NPC.velocity.Y - sepAcceleration * 2f; } } - if (Math.Abs(num191) < num188 * 0.2 && ((NPC.velocity.Y > 0f && num192 < 0f) || (NPC.velocity.Y < 0f && num192 > 0f))) + if (Math.Abs(targetX) < sepMaxSpeed * 0.2 && ((NPC.velocity.Y > 0f && targetY < 0f) || (NPC.velocity.Y < 0f && targetY > 0f))) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num189 * 2f; //changed from 2 + NPC.velocity.X = NPC.velocity.X + sepAcceleration * 2f; //changed from 2 } else { - NPC.velocity.X = NPC.velocity.X - num189 * 2f; //changed from 2 + NPC.velocity.X = NPC.velocity.X - sepAcceleration * 2f; //changed from 2 } } } else { - if (num196 > num197) + if (absoluteTargetX > absoluteTargetY) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetX) { - NPC.velocity.X = NPC.velocity.X + num189 * 1.1f; //changed from 1.1 + NPC.velocity.X = NPC.velocity.X + sepAcceleration * 1.1f; //changed from 1.1 } - else if (NPC.velocity.X > num191) + else if (NPC.velocity.X > targetX) { - NPC.velocity.X = NPC.velocity.X - num189 * 1.1f; //changed from 1.1 + NPC.velocity.X = NPC.velocity.X - sepAcceleration * 1.1f; //changed from 1.1 } - if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < num188 * 0.5) + if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < sepMaxSpeed * 0.5) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num189; + NPC.velocity.Y = NPC.velocity.Y + sepAcceleration; } else { - NPC.velocity.Y = NPC.velocity.Y - num189; + NPC.velocity.Y = NPC.velocity.Y - sepAcceleration; } } } else { - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetY) { - NPC.velocity.Y = NPC.velocity.Y + num189 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y + sepAcceleration * 1.1f; } - else if (NPC.velocity.Y > num192) + else if (NPC.velocity.Y > targetY) { - NPC.velocity.Y = NPC.velocity.Y - num189 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y - sepAcceleration * 1.1f; } - if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < num188 * 0.5) + if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < sepMaxSpeed * 0.5) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num189; + NPC.velocity.X = NPC.velocity.X + sepAcceleration; } else { - NPC.velocity.X = NPC.velocity.X - num189; + NPC.velocity.X = NPC.velocity.X - sepAcceleration; } } } @@ -333,12 +333,12 @@ namespace CalamityMod.NPCs.SupremeCalamitas spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/SupremeCalamitas/SepulcherTail.cs b/NPCs/SupremeCalamitas/SepulcherTail.cs index f6f30ac093..4f11f7283b 100644 --- a/NPCs/SupremeCalamitas/SepulcherTail.cs +++ b/NPCs/SupremeCalamitas/SepulcherTail.cs @@ -69,16 +69,16 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.realLife = (int)NPC.ai[2]; } - bool flag = false; + bool shouldDie = false; if (NPC.ai[1] <= 0f) { - flag = true; + shouldDie = true; } else if (Main.npc[(int)NPC.ai[1]].life <= 0 || NPC.life <= 0) { - flag = true; + shouldDie = true; } - if (flag) + if (shouldDie) { NPC.life = 0; NPC.HitEffect(0, 10.0); @@ -89,11 +89,11 @@ namespace CalamityMod.NPCs.SupremeCalamitas { if (NPC.alpha != 0) { - for (int num934 = 0; num934 < 2; num934++) + for (int i = 0; i < 2; i++) { - int num935 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; + int redDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 182, 0f, 0f, 100, default, 2f); + Main.dust[redDust].noGravity = true; + Main.dust[redDust].noLight = true; } } NPC.alpha -= 42; @@ -108,41 +108,41 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.alpha = Main.npc[(int)NPC.ai[2]].alpha; } - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); + Vector2 segmentLocation = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); + float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); + targetX = (int)(targetX / 16f) * 16; + targetY = (int)(targetY / 16f) * 16; + segmentLocation.X = (int)(segmentLocation.X / 16f) * 16; + segmentLocation.Y = (int)(segmentLocation.Y / 16f) * 16; + targetX -= segmentLocation.X; + targetY -= segmentLocation.Y; + float targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentLocation = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + targetX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - segmentLocation.X; + targetY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - segmentLocation.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2(num192, num191) + 1.57f; - num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = NPC.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2(targetY, targetX) + 1.57f; + targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); + int npcWidth = NPC.width; + targetDistance = (targetDistance - npcWidth) / targetDistance; + targetX *= targetDistance; + targetY *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; - if (num191 < 0f) + NPC.position.X = NPC.position.X + targetX; + NPC.position.Y = NPC.position.Y + targetY; + if (targetX < 0f) { NPC.spriteDirection = -1; } - else if (num191 > 0f) + else if (targetX > 0f) { NPC.spriteDirection = 1; } @@ -164,12 +164,12 @@ namespace CalamityMod.NPCs.SupremeCalamitas spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs b/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs index d38d262676..9455c06678 100644 --- a/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs +++ b/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs @@ -34,7 +34,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas Main.npcFrameCount[NPC.type] = 6; NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.6f, PortraitPositionXOverride = -5f, @@ -187,23 +187,23 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.height = 50; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int brimDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[brimDust].scale = 0.5f; + Main.dust[brimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int brimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); + Main.dust[brimDust2].noGravity = true; + Main.dust[brimDust2].velocity *= 5f; + brimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimDust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) @@ -223,49 +223,47 @@ namespace CalamityMod.NPCs.SupremeCalamitas spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 2; + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + int afterimageAmt = 2; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/SupremeCalamitas/SoulSeekerSupremeGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + Color redLerp = Color.Lerp(Color.White, Color.Red, 0.5f); if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color redAfterimageColor = redLerp; + redAfterimageColor = Color.Lerp(redAfterimageColor, Color.White, 0.5f); + redAfterimageColor *= (float)(afterimageAmt - j) / 15f; + Vector2 redAfterimagePos = NPC.oldPos[j] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + redAfterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + redAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, redAfterimagePos, NPC.frame, redAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, redLerp, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index cfe38c1788..d0ada4a1cd 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -593,14 +593,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas spawnYAdd = 125; } - int num52 = (int)(safeBox.X + (float)(safeBox.Width / 2)) / 16; - int num53 = (int)(safeBox.Y + (float)(safeBox.Height / 2)) / 16; - int num54 = safeBox.Width / 2 / 16 + 1; - for (int num55 = num52 - num54; num55 <= num52 + num54; num55++) + int safeBoxTilesX = (int)(safeBox.X + (float)(safeBox.Width / 2)) / 16; + int safeBoxTilesY = (int)(safeBox.Y + (float)(safeBox.Height / 2)) / 16; + int safeBoxTileWidth = safeBox.Width / 2 / 16 + 1; + for (int i = safeBoxTilesX - safeBoxTileWidth; i <= safeBoxTilesX + safeBoxTileWidth; i++) { - for (int num56 = num53 - num54; num56 <= num53 + num54; num56++) + for (int j = safeBoxTilesY - safeBoxTileWidth; j <= safeBoxTilesY + safeBoxTileWidth; j++) { - if (!WorldGen.InWorld(num55, num56, 2)) + if (!WorldGen.InWorld(i, j, 2)) continue; int xoffset = 0; @@ -612,18 +612,18 @@ namespace CalamityMod.NPCs.SupremeCalamitas yoffset += Main.rand.Next(-maxoffset, maxoffset + 1); } - if ((num55 == num52 - num54 || num55 == num52 + num54 || num56 == num53 - num54 || num56 == num53 + num54) && !Main.tile[num55 + xoffset, num56 + yoffset].HasTile) + if ((i == safeBoxTilesX - safeBoxTileWidth || i == safeBoxTilesX + safeBoxTileWidth || j == safeBoxTilesY - safeBoxTileWidth || j == safeBoxTilesY + safeBoxTileWidth) && !Main.tile[i + xoffset, j + yoffset].HasTile) { - Main.tile[num55 + xoffset, num56 + yoffset].TileType = (ushort)ModContent.TileType(); - Main.tile[num55 + xoffset, num56 + yoffset].Get().HasTile = true; + Main.tile[i + xoffset, j + yoffset].TileType = (ushort)ModContent.TileType(); + Main.tile[i + xoffset, j + yoffset].Get().HasTile = true; } if (Main.netMode == NetmodeID.Server) { - NetMessage.SendTileSquare(-1, num55 + xoffset, num56 + yoffset, 1, TileChangeType.None); + NetMessage.SendTileSquare(-1, i + xoffset, j + yoffset, 1, TileChangeType.None); } else { - WorldGen.SquareTileFrame(num55 + xoffset, num56 + yoffset, true); + WorldGen.SquareTileFrame(i + xoffset, j + yoffset, true); } } } @@ -872,7 +872,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (bulletHellCounter2 % 90 == 0) { float bottleSpeed = 12f; - Vector2 bottleVelocity = Vector2.Normalize(player.Center + player.velocity * 20f - NPC.Center) * bottleSpeed; + Vector2 bottleVelocity = (player.Center + player.velocity * 20f - NPC.Center).SafeNormalize(Vector2.UnitY) * bottleSpeed; Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, bottleVelocity * uDieLul, ModContent.ProjectileType(), 350, 0f, Main.myPlayer); } } @@ -967,7 +967,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas { Vector2 destination = player.Center; Vector2 distanceFromDestination = destination - NPC.Center; - Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination - NPC.velocity) * CirrusPhotonRipperDashVelocity; + Vector2 desiredVelocity = (distanceFromDestination - NPC.velocity).SafeNormalize(Vector2.UnitY) * CirrusPhotonRipperDashVelocity; if (Vector2.Distance(NPC.Center, destination) > CirrusPhotonRipperMinDistanceFromTarget) NPC.SimpleFlyMovement(desiredVelocity * uDieLul, CirrusPhotonRipperDashAcceleration * uDieLul); @@ -1070,7 +1070,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (bulletHellCounter2 % 90 == 0) { float bottleSpeed = 12f; - Vector2 bottleVelocity = Vector2.Normalize(player.Center + player.velocity * 20f - NPC.Center) * bottleSpeed; + Vector2 bottleVelocity = (player.Center + player.velocity * 20f - NPC.Center).SafeNormalize(Vector2.UnitY) * bottleSpeed; Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, bottleVelocity * uDieLul, ModContent.ProjectileType(), 125, 0f, Main.myPlayer); } } @@ -1164,7 +1164,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas { Vector2 destination = player.Center; Vector2 distanceFromDestination = destination - NPC.Center; - Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination - NPC.velocity) * CirrusPhotonRipperDashVelocity; + Vector2 desiredVelocity = (distanceFromDestination - NPC.velocity).SafeNormalize(Vector2.UnitY) * CirrusPhotonRipperDashVelocity; if (Vector2.Distance(NPC.Center, destination) > CirrusPhotonRipperMinDistanceFromTarget) NPC.SimpleFlyMovement(desiredVelocity * uDieLul, CirrusPhotonRipperDashAcceleration * uDieLul); @@ -1186,7 +1186,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (bulletHellCounter2 % 90 == 0) { float bottleSpeed = 12f; - Vector2 bottleVelocity = Vector2.Normalize(player.Center + player.velocity * 20f - NPC.Center) * bottleSpeed; + Vector2 bottleVelocity = (player.Center + player.velocity * 20f - NPC.Center).SafeNormalize(Vector2.UnitY) * bottleSpeed; Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, bottleVelocity * uDieLul, ModContent.ProjectileType(), 125, 0f, Main.myPlayer); } } @@ -1303,7 +1303,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas for (int k = 0; k < totalProjectiles; k++) { Vector2 rayVelocity = spinningPoint.RotatedBy(radians * k); - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(rayVelocity) * 16f, rayVelocity, ModContent.ProjectileType(), 250, 0f, Main.myPlayer); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + (rayVelocity).SafeNormalize(Vector2.UnitY) * 16f, rayVelocity, ModContent.ProjectileType(), 250, 0f, Main.myPlayer); if (proj.WithinBounds(Main.maxProjectiles)) { Main.projectile[proj].DamageType = DamageClass.Default; @@ -1829,8 +1829,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.netUpdate = true; } - Vector2 projectileVelocity = player.Center - NPC.Center; - projectileVelocity.Normalize(); + Vector2 projectileVelocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY); Vector2 projectileSpawn = NPC.Center + projectileVelocity * 8f; projectileVelocity *= 10f * uDieLul; @@ -1930,7 +1929,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!canDespawn) { - Vector2 vector = Vector2.Normalize(player.Center - NPC.Center); + Vector2 vector = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY); NPC.velocity = vector * chargeVelocity; shieldRotation = NPC.velocity.ToRotation(); @@ -1945,13 +1944,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas float velocity = 8; int type = ModContent.ProjectileType(); int damage = (int)(NPC.damage / 3); - Vector2 projectileVelocity = Vector2.Normalize(player.Center - NPC.Center) * velocity; + Vector2 projectileVelocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * velocity; float rotation = MathHelper.ToRadians(22); for (int i = 0; i < 3; i++) { Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(2))); - int p = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(perturbedSpeed) * 3f, perturbedSpeed, type, damage, 0f, Main.myPlayer); + int p = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + (perturbedSpeed).SafeNormalize(Vector2.UnitY) * 3f, perturbedSpeed, type, damage, 0f, Main.myPlayer); if (p.WithinBounds(Main.maxProjectiles)) { Main.projectile[p].DamageType = DamageClass.Default; @@ -2074,8 +2073,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 projectileVelocity = player.Center - NPC.Center; - projectileVelocity.Normalize(); + Vector2 projectileVelocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY); Vector2 projectileSpawn = NPC.Center + projectileVelocity * 4f; projectileVelocity *= 10f * uDieLul; int projectileType = hellblast; @@ -2153,8 +2151,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (Main.netMode != NetmodeID.MultiplayerClient) { SoundEngine.PlaySound(BrimstoneBigShotSound, NPC.Center); - Vector2 projectileVelocity = player.Center - NPC.Center; - projectileVelocity.Normalize(); + Vector2 projectileVelocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY); Vector2 projectileSpawn = NPC.Center + projectileVelocity * 8f; projectileVelocity *= 5f * uDieLul; int projectileType = gigablast; @@ -2213,7 +2210,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.ai[2] = 0f; else { - for (int num388 = 0; num388 < 50; num388++) + for (int i = 0; i < 50; i++) Dust.NewDust(NPC.position, NPC.width, NPC.height, cirrus ? (int)CalamityDusts.PurpleCosmilite : (int)CalamityDusts.Brimstone, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); SoundEngine.PlaySound(SpawnSound, NPC.Center); @@ -2395,8 +2392,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.netUpdate = true; } - Vector2 projectileVelocity = player.Center - NPC.Center; - projectileVelocity.Normalize(); + Vector2 projectileVelocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY); Vector2 projectileSpawn = NPC.Center + projectileVelocity * 8f; projectileVelocity *= 10f * uDieLul; @@ -2494,7 +2490,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!canDespawn) { - Vector2 vector = Vector2.Normalize(player.Center - NPC.Center); + Vector2 vector = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY); NPC.velocity = vector * chargeVelocity; shieldRotation = NPC.velocity.ToRotation(); @@ -2611,8 +2607,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 projectileVelocity = player.Center - NPC.Center; - projectileVelocity.Normalize(); + Vector2 projectileVelocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY); Vector2 projectileSpawn = NPC.Center + projectileVelocity * 4f; projectileVelocity *= 10f * uDieLul; int projectileType = hellblast; @@ -2694,8 +2689,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (Main.netMode != NetmodeID.MultiplayerClient) { SoundEngine.PlaySound(BrimstoneBigShotSound, NPC.Center); - Vector2 projectileVelocity = player.Center - NPC.Center; - projectileVelocity.Normalize(); + Vector2 projectileVelocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY); Vector2 projectileSpawn = NPC.Center + projectileVelocity * 8f; projectileVelocity *= 5f * uDieLul; int projectileType = gigablast; @@ -3067,7 +3061,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas // GFB Slurper Pole drops var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ModContent.ItemType()); + GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); } // Legendary seed pony on a stick upgrade @@ -3181,11 +3175,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (cirrus) texture2D15 = inPhase2 ? ModContent.Request("CalamityMod/NPCs/SupremeCalamitas/SupremeCirrus_Shimmered").Value : ModContent.Request("CalamityMod/NPCs/SupremeCalamitas/SupremeCirrus").Value; - Vector2 vector11 = new Vector2(texture2D15.Width / 2f, texture2D15.Height / Main.npcFrameCount[NPC.type] / 2f); + Vector2 halfSizeTexture = new Vector2(texture2D15.Width / 2f, texture2D15.Height / Main.npcFrameCount[NPC.type] / 2f); Vector2 ponyOrigin = new Vector2(pony.Width / 2f, pony.Height / 30f); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 7; + int afterimageAmt = 7; Rectangle frame = texture2D15.Frame(2, Main.npcFrameCount[NPC.type], NPC.frame.Y / Main.npcFrameCount[NPC.type], NPC.frame.Y % Main.npcFrameCount[NPC.type]); Rectangle ponyFrame = pony.Frame(1, 15, 0, alicornFrame); @@ -3195,22 +3187,22 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (CalamityConfig.Instance.Afterimages && !(cirrus && NPC.ai[1] == 2f)) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture2D15.Width / 2f, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(texture2D15.Width / 2f, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width / 2f, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width / 2f, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); if (!(cirrus && NPC.ai[1] == 2f)) { @@ -3218,7 +3210,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas { // Make the sprite jitter with rage in phase 2. This does not happen in rematches since it would make little sense logically. if (!DownedBossSystem.downedCalamitas) - vector43 += Main.rand.NextVector2Circular(0.25f, 0.7f); + drawLocation += Main.rand.NextVector2Circular(0.25f, 0.7f); // And gain a flaming aura. Color auraColor = NPC.GetAlpha(cirrus ? Color.Pink : Color.Red) * 0.4f; @@ -3226,10 +3218,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas { Vector2 rotationalDrawOffset = (MathHelper.TwoPi * i / 7f + Main.GlobalTimeWrappedHourly * 4f).ToRotationVector2(); rotationalDrawOffset *= MathHelper.Lerp(3f, 4.25f, (float)Math.Cos(Main.GlobalTimeWrappedHourly * 4f) * 0.5f + 0.5f); - spriteBatch.Draw(texture2D15, vector43 + rotationalDrawOffset, frame, auraColor, NPC.rotation, vector11, NPC.scale * 1.1f, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation + rotationalDrawOffset, frame, auraColor, NPC.rotation, halfSizeTexture, NPC.scale * 1.1f, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } if (!NPC.IsABestiaryIconDummy) @@ -3369,23 +3361,23 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.height = 100; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(NPC.position, NPC.width, NPC.height, cirrus ? (int)CalamityDusts.PurpleCosmilite : (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int onHitDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, cirrus ? (int)CalamityDusts.PurpleCosmilite : (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[onHitDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[onHitDust].scale = 0.5f; + Main.dust[onHitDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(NPC.position, NPC.width, NPC.height, cirrus ? (int)CalamityDusts.PurpleCosmilite : (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(NPC.position, NPC.width, NPC.height, cirrus ? (int)CalamityDusts.PurpleCosmilite : (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int onHitDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, cirrus ? (int)CalamityDusts.PurpleCosmilite : (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); + Main.dust[onHitDust2].noGravity = true; + Main.dust[onHitDust2].velocity *= 5f; + onHitDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, cirrus ? (int)CalamityDusts.PurpleCosmilite : (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[onHitDust2].velocity *= 2f; } } } @@ -3471,6 +3463,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas case 19: target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); break; + case 20: + target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); + break; } } } diff --git a/NPCs/SupremeCalamitas/SupremeCataclysm.cs b/NPCs/SupremeCalamitas/SupremeCataclysm.cs index f9fdb46159..e79e7fa71e 100644 --- a/NPCs/SupremeCalamitas/SupremeCataclysm.cs +++ b/NPCs/SupremeCalamitas/SupremeCataclysm.cs @@ -45,7 +45,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas Main.npcFrameCount[NPC.type] = 9; NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.3f, PortraitPositionYOverride = 36f, @@ -322,23 +322,23 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.height = 100; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int brimDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[brimDust].scale = 0.5f; + Main.dust[brimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int brimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); + Main.dust[brimDust2].noGravity = true; + Main.dust[brimDust2].velocity *= 5f; + brimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimDust2].velocity *= 2f; } // Turn into dust on death. diff --git a/NPCs/SupremeCalamitas/SupremeCatastrophe.cs b/NPCs/SupremeCalamitas/SupremeCatastrophe.cs index 2363e09ff4..bd4b87d7e7 100644 --- a/NPCs/SupremeCalamitas/SupremeCatastrophe.cs +++ b/NPCs/SupremeCalamitas/SupremeCatastrophe.cs @@ -37,7 +37,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas Main.npcFrameCount[NPC.type] = 8; NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.3f, PortraitPositionYOverride = 56f, @@ -316,23 +316,23 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.height = 100; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int brimDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[brimDust].scale = 0.5f; + Main.dust[brimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int brimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); + Main.dust[brimDust2].noGravity = true; + Main.dust[brimDust2].velocity *= 5f; + brimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimDust2].velocity *= 2f; } // Turn into dust on death. diff --git a/NPCs/TownNPCs/AndroombaFriendly.cs b/NPCs/TownNPCs/AndroombaFriendly.cs index a79572ba9a..386817f6b0 100644 --- a/NPCs/TownNPCs/AndroombaFriendly.cs +++ b/NPCs/TownNPCs/AndroombaFriendly.cs @@ -21,7 +21,7 @@ namespace CalamityMod.NPCs.TownNPCs Main.npcFrameCount[NPC.type] = 9; Main.npcCatchable[NPC.type] = true; NPCID.Sets.NoTownNPCHappiness[Type] = true; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0); value.Position.Y += 16; value.PortraitPositionYOverride = 36f; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; diff --git a/NPCs/TownNPCs/DILF.cs b/NPCs/TownNPCs/DILF.cs index f1b7d475c9..d692fdbc60 100644 --- a/NPCs/TownNPCs/DILF.cs +++ b/NPCs/TownNPCs/DILF.cs @@ -39,7 +39,7 @@ namespace CalamityMod.NPCs.TownNPCs .SetBiomeAffection(AffectionLevel.Dislike) .SetNPCAffection(NPCID.Wizard, AffectionLevel.Like) .SetNPCAffection(NPCID.Cyborg, AffectionLevel.Dislike); - NPCID.Sets.NPCBestiaryDrawModifiers drawModifiers = new NPCID.Sets.NPCBestiaryDrawModifiers() { + NPCID.Sets.NPCBestiaryDrawModifiers drawModifiers = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Velocity = 1f // Draws the NPC in the bestiary as if its walking +1 tiles in the x direction }; NPCID.Sets.NPCBestiaryDrawOffset.Add(NPC.type, drawModifiers); @@ -132,7 +132,6 @@ namespace CalamityMod.NPCs.TownNPCs { if (firstButton) { - Main.LocalPlayer.Calamity().newPermafrostInventory = false; shopName = "Shop"; } } diff --git a/NPCs/TownNPCs/FAP.cs b/NPCs/TownNPCs/FAP.cs index 2f8095a4c1..2aa452a208 100644 --- a/NPCs/TownNPCs/FAP.cs +++ b/NPCs/TownNPCs/FAP.cs @@ -47,7 +47,7 @@ namespace CalamityMod.NPCs.TownNPCs .SetNPCAffection(NPCID.TaxCollector, AffectionLevel.Dislike) .SetNPCAffection(NPCID.GoblinTinkerer, AffectionLevel.Hate) .SetNPCAffection(NPCID.Angler, AffectionLevel.Hate); - NPCID.Sets.NPCBestiaryDrawModifiers drawModifiers = new NPCID.Sets.NPCBestiaryDrawModifiers() { + NPCID.Sets.NPCBestiaryDrawModifiers drawModifiers = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Velocity = 1f // Draws the NPC in the bestiary as if its walking +1 tiles in the x direction }; NPCID.Sets.NPCBestiaryDrawOffset.Add(NPC.type, drawModifiers); @@ -290,7 +290,6 @@ namespace CalamityMod.NPCs.TownNPCs { if (firstButton) { - Main.LocalPlayer.Calamity().newCirrusInventory = false; shopName = "Shop"; } else @@ -319,6 +318,7 @@ namespace CalamityMod.NPCs.TownNPCs .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 8), Condition.DownedPlantera) .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 8), Condition.DownedPlantera) .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 8), Condition.DownedPlantera) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 8), Condition.DownedPlantera) .AddWithCustomValue(ItemID.EmpressButterfly, Item.buyPrice(gold: 10), Condition.DownedPlantera) .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 3), downedAureus) .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 4), downedAureus, Condition.BloodMoon) diff --git a/NPCs/TownNPCs/SEAHOE.cs b/NPCs/TownNPCs/SEAHOE.cs index 12a0425361..8f4b9f19ec 100644 --- a/NPCs/TownNPCs/SEAHOE.cs +++ b/NPCs/TownNPCs/SEAHOE.cs @@ -39,7 +39,7 @@ namespace CalamityMod.NPCs.TownNPCs .SetNPCAffection(NPCID.Pirate, AffectionLevel.Like) .SetNPCAffection(NPCID.Demolitionist, AffectionLevel.Dislike) .SetNPCAffection(NPCID.Angler, AffectionLevel.Hate); - NPCID.Sets.NPCBestiaryDrawModifiers drawModifiers = new NPCID.Sets.NPCBestiaryDrawModifiers() { + NPCID.Sets.NPCBestiaryDrawModifiers drawModifiers = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Velocity = 1f // Draws the NPC in the bestiary as if its walking +1 tiles in the x direction }; NPCID.Sets.NPCBestiaryDrawOffset.Add(NPC.type, drawModifiers); @@ -185,7 +185,6 @@ namespace CalamityMod.NPCs.TownNPCs { if (firstButton) { - Main.LocalPlayer.Calamity().newAmidiasInventory = false; shopName = "Shop"; } else diff --git a/NPCs/TownNPCs/THIEF.cs b/NPCs/TownNPCs/THIEF.cs index ebf707b8c0..04b229ba2c 100644 --- a/NPCs/TownNPCs/THIEF.cs +++ b/NPCs/TownNPCs/THIEF.cs @@ -37,7 +37,7 @@ namespace CalamityMod.NPCs.TownNPCs .SetBiomeAffection(AffectionLevel.Dislike) .SetNPCAffection(NPCID.GoblinTinkerer, AffectionLevel.Like) .SetNPCAffection(NPCID.Dryad, AffectionLevel.Dislike); - NPCID.Sets.NPCBestiaryDrawModifiers drawModifiers = new NPCID.Sets.NPCBestiaryDrawModifiers() { + NPCID.Sets.NPCBestiaryDrawModifiers drawModifiers = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Velocity = 1f // Draws the NPC in the bestiary as if its walking +1 tiles in the x direction }; NPCID.Sets.NPCBestiaryDrawOffset.Add(NPC.type, drawModifiers); @@ -249,7 +249,6 @@ namespace CalamityMod.NPCs.TownNPCs { if (firstButton) { - Main.LocalPlayer.Calamity().newBanditInventory = false; shopName = "Shop"; } else diff --git a/NPCs/TownNPCs/WITCH.cs b/NPCs/TownNPCs/WITCH.cs index 3b5aec0b0e..aadde1c96d 100644 --- a/NPCs/TownNPCs/WITCH.cs +++ b/NPCs/TownNPCs/WITCH.cs @@ -36,7 +36,7 @@ namespace CalamityMod.NPCs.TownNPCs .SetBiomeAffection(AffectionLevel.Dislike) .SetNPCAffection(NPCID.Clothier, AffectionLevel.Like) .SetNPCAffection(NPCID.PartyGirl, AffectionLevel.Dislike); - NPCID.Sets.NPCBestiaryDrawModifiers drawModifiers = new NPCID.Sets.NPCBestiaryDrawModifiers() { + NPCID.Sets.NPCBestiaryDrawModifiers drawModifiers = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Velocity = 1f // Draws the NPC in the bestiary as if its walking +1 tiles in the x direction }; NPCID.Sets.NPCBestiaryDrawOffset.Add(NPC.type, drawModifiers); @@ -135,7 +135,6 @@ namespace CalamityMod.NPCs.TownNPCs if (firstButton) { Main.playerInventory = true; - Main.LocalPlayer.Calamity().newCalamitasInventory = false; CalamitasEnchantUI.NPCIndex = NPC.whoAmI; CalamitasEnchantUI.CurrentlyViewing = true; diff --git a/NPCs/VanillaNPCOverrides/Bosses/BrainOfCthulhuAI.cs b/NPCs/VanillaNPCOverrides/Bosses/BrainOfCthulhuAI.cs index 00af992ebc..c0cd590fb0 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/BrainOfCthulhuAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/BrainOfCthulhuAI.cs @@ -47,16 +47,16 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { npc.localAI[0] = 1f; int brainOfCthuluCreepersCount = GetBrainOfCthuluCreepersCountRevDeath(); - for (int num789 = 0; num789 < brainOfCthuluCreepersCount; num789++) + for (int i = 0; i < brainOfCthuluCreepersCount; i++) { - float num790 = npc.Center.X; - float num791 = npc.Center.Y; - num790 += Main.rand.Next(-npc.width, npc.width); - num791 += Main.rand.Next(-npc.height, npc.height); + float brainX = npc.Center.X; + float brainY = npc.Center.Y; + brainX += Main.rand.Next(-npc.width, npc.width); + brainY += Main.rand.Next(-npc.height, npc.height); - int num792 = NPC.NewNPC(npc.GetSource_FromAI(), (int)num790, (int)num791, NPCID.Creeper, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[num792].velocity = new Vector2(Main.rand.Next(-30, 31) * 0.1f, Main.rand.Next(-30, 31) * 0.1f); - Main.npc[num792].netUpdate = true; + int creeperSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)brainX, (int)brainY, NPCID.Creeper, 0, 0f, 0f, 0f, 0f, 255); + Main.npc[creeperSpawn].velocity = new Vector2(Main.rand.Next(-30, 31) * 0.1f, Main.rand.Next(-30, 31) * 0.1f); + Main.npc[creeperSpawn].netUpdate = true; } } @@ -94,7 +94,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 395, 1f); } - for (int num794 = 0; num794 < 20; num794++) + for (int j = 0; j < 20; j++) Dust.NewDust(npc.position, npc.width, npc.height, 5, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); SoundEngine.PlaySound(SoundID.Roar, npc.position); @@ -129,21 +129,21 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[0] != -6f) { // Rubber band movement - Vector2 vector98 = new Vector2(npc.Center.X, npc.Center.Y); - float num795 = Main.player[npc.target].Center.X - vector98.X; - float num796 = Main.player[npc.target].Center.Y - vector98.Y; - float num797 = (float)Math.Sqrt(num795 * num795 + num796 * num796); + Vector2 brainCenter = new Vector2(npc.Center.X, npc.Center.Y); + float targetXDist = Main.player[npc.target].Center.X - brainCenter.X; + float targetYDist = Main.player[npc.target].Center.Y - brainCenter.Y; + float targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); float velocityScale = death ? 4f : 2f; float velocityBoost = velocityScale * (1f - lifeRatio); - float num798 = 8f + velocityBoost + 3f * enrageScale; + float nonChargeSpeed = 8f + velocityBoost + 3f * enrageScale; if (Main.getGoodWorld) - num798 *= 1.15f; + nonChargeSpeed *= 1.15f; - num797 = num798 / num797; - num795 *= num797; - num796 *= num797; - npc.velocity.X = (npc.velocity.X * 50f + num795) / 51f; - npc.velocity.Y = (npc.velocity.Y * 50f + num796) / 51f; + targetDistance = nonChargeSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + npc.velocity.X = (npc.velocity.X * 50f + targetXDist) / 51f; + npc.velocity.Y = (npc.velocity.Y * 50f + targetYDist) / 51f; } // Charge, -6 @@ -216,8 +216,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Velocity - int var = 120; - float velocity = MathHelper.TwoPi / (var * 0.75f); + float velocity = MathHelper.TwoPi / (120 * 0.75f); npc.velocity = npc.velocity.RotatedBy(-(double)velocity * npc.ai[1]); npc.ai[2] += 1f; @@ -284,19 +283,18 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.justHit) npc.localAI[1] -= Main.rand.Next(random); - float num799 = 60f; - if (npc.localAI[1] >= num799) + if (npc.localAI[1] >= 60f) { npc.localAI[1] = 0f; npc.TargetClosest(); - int num800 = 0; - int num801; - int num802; + int numTeleportTries = 0; + int teleportTileX; + int teleportTileY; while (true) { - num800++; - num801 = (int)Main.player[npc.target].Center.X / 16; - num802 = (int)Main.player[npc.target].Center.Y / 16; + numTeleportTries++; + teleportTileX = (int)Main.player[npc.target].Center.X / 16; + teleportTileY = (int)Main.player[npc.target].Center.Y / 16; int min = 14; int max = 17; @@ -305,25 +303,25 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses max += teleportDistanceIncrease; if (Main.rand.NextBool()) - num801 += Main.rand.Next(min, max); + teleportTileX += Main.rand.Next(min, max); else - num801 -= Main.rand.Next(min, max); + teleportTileX -= Main.rand.Next(min, max); if (Main.rand.NextBool()) - num802 += Main.rand.Next(min, max); + teleportTileY += Main.rand.Next(min, max); else - num802 -= Main.rand.Next(min, max); + teleportTileY -= Main.rand.Next(min, max); - if (!WorldGen.SolidTile(num801, num802)) + if (!WorldGen.SolidTile(teleportTileX, teleportTileY)) break; - if (num800 > 100) + if (numTeleportTries > 100) goto Block_2784; } npc.ai[3] = 0f; npc.ai[0] = npc.ai[0] == -7f ? -8f : -2f; - npc.ai[1] = num801; - npc.ai[2] = num802; + npc.ai[1] = teleportTileX; + npc.ai[2] = teleportTileY; npc.netUpdate = true; npc.netSpam = 0; Block_2784: @@ -423,24 +421,24 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Move towards target - Vector2 vector99 = new Vector2(npc.Center.X, npc.Center.Y); - float num803 = Main.player[npc.target].Center.X - vector99.X; - float num804 = Main.player[npc.target].Center.Y - vector99.Y; - float num805 = (float)Math.Sqrt(num803 * num803 + num804 * num804); - float num806 = (death ? 2f : 1f) + (creeperScale * 0.1f); + Vector2 brainCenterPhase1 = new Vector2(npc.Center.X, npc.Center.Y); + float targetXDistPhase1 = Main.player[npc.target].Center.X - brainCenterPhase1.X; + float targetYDistPhase1 = Main.player[npc.target].Center.Y - brainCenterPhase1.Y; + float targetDistancePhase1 = (float)Math.Sqrt(targetXDistPhase1 * targetXDistPhase1 + targetYDistPhase1 * targetYDistPhase1); + float maxMoveVelocity = (death ? 2f : 1f) + (creeperScale * 0.1f); if (Main.getGoodWorld) - num806 *= 2f; + maxMoveVelocity *= 2f; - if (num805 < num806) + if (targetDistancePhase1 < maxMoveVelocity) { - npc.velocity.X = num803; - npc.velocity.Y = num804; + npc.velocity.X = targetXDistPhase1; + npc.velocity.Y = targetYDistPhase1; } else { - num805 = num806 / num805; - npc.velocity.X = num803 * num805; - npc.velocity.Y = num804 * num805; + targetDistancePhase1 = maxMoveVelocity / targetDistancePhase1; + npc.velocity.X = targetXDistPhase1 * targetDistancePhase1; + npc.velocity.Y = targetYDistPhase1 * targetDistancePhase1; } // Pick a teleport location @@ -454,40 +452,40 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { npc.localAI[1] = 0f; npc.TargetClosest(); - int num809 = 0; - int num810; - int num811; + int phase1TeleportTries = 0; + int phase1TeleportTileX; + int phase1TeleportTileY; while (true) { - num809++; - num810 = (int)Main.player[npc.target].Center.X / 16; - num811 = (int)Main.player[npc.target].Center.Y / 16; + phase1TeleportTries++; + phase1TeleportTileX = (int)Main.player[npc.target].Center.X / 16; + phase1TeleportTileY = (int)Main.player[npc.target].Center.Y / 16; int min = 18 + teleportDistanceIncrease; int max = 26 + teleportDistanceIncrease; if (Main.rand.NextBool()) - num810 += Main.rand.Next(min, max); + phase1TeleportTileX += Main.rand.Next(min, max); else - num810 -= Main.rand.Next(min, max); + phase1TeleportTileX -= Main.rand.Next(min, max); if (Main.rand.NextBool()) - num811 += Main.rand.Next(min, max); + phase1TeleportTileY += Main.rand.Next(min, max); else - num811 -= Main.rand.Next(min, max); + phase1TeleportTileY -= Main.rand.Next(min, max); - if (!WorldGen.SolidTile(num810, num811) && Collision.CanHit(new Vector2(num810 * 16, num811 * 16), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + if (!WorldGen.SolidTile(phase1TeleportTileX, phase1TeleportTileY) && Collision.CanHit(new Vector2(phase1TeleportTileX * 16, phase1TeleportTileY * 16), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { break; } - if (num809 > 100) + if (phase1TeleportTries > 100) { goto Block_2801; } } npc.ai[0] = 1f; - npc.ai[1] = num810; - npc.ai[2] = num811; + npc.ai[1] = phase1TeleportTileX; + npc.ai[2] = phase1TeleportTileY; npc.netUpdate = true; Block_2801: ; @@ -575,21 +573,21 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Stay near Brain if (npc.ai[0] == 0f) { - Vector2 vector100 = new Vector2(npc.Center.X, npc.Center.Y); - float num812 = Main.npc[NPC.crimsonBoss].Center.X - vector100.X; - float num813 = Main.npc[NPC.crimsonBoss].Center.Y - vector100.Y; - float num814 = (float)Math.Sqrt(num812 * num812 + num813 * num813); + Vector2 creeperCenter = new Vector2(npc.Center.X, npc.Center.Y); + float brainXDist = Main.npc[NPC.crimsonBoss].Center.X - creeperCenter.X; + float brainYDist = Main.npc[NPC.crimsonBoss].Center.Y - creeperCenter.Y; + float brainDistance = (float)Math.Sqrt(brainXDist * brainXDist + brainYDist * brainYDist); float velocity = death ? 10f : 7f; velocity += 4f * enrageScale; // Max distance from Brain - if (num814 > 90f) + if (brainDistance > 90f) { - num814 = velocity / num814; - num812 *= num814; - num813 *= num814; - npc.velocity.X = (npc.velocity.X * 15f + num812) / 16f; - npc.velocity.Y = (npc.velocity.Y * 15f + num813) / 16f; + brainDistance = velocity / brainDistance; + brainXDist *= brainDistance; + brainYDist *= brainDistance; + npc.velocity.X = (npc.velocity.X * 15f + brainXDist) / 16f; + npc.velocity.Y = (npc.velocity.Y * 15f + brainYDist) / 16f; return false; } @@ -607,13 +605,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { npc.ai[1] = 0f; npc.TargetClosest(); - vector100 = new Vector2(npc.Center.X, npc.Center.Y); - num812 = Main.player[npc.target].Center.X - vector100.X; - num813 = Main.player[npc.target].Center.Y - vector100.Y; - num814 = (float)Math.Sqrt(num812 * num812 + num813 * num813); - num814 = velocity / num814; - npc.velocity.X = num812 * num814; - npc.velocity.Y = num813 * num814; + creeperCenter = new Vector2(npc.Center.X, npc.Center.Y); + brainXDist = Main.player[npc.target].Center.X - creeperCenter.X; + brainYDist = Main.player[npc.target].Center.Y - creeperCenter.Y; + brainDistance = (float)Math.Sqrt(brainXDist * brainXDist + brainYDist * brainYDist); + brainDistance = velocity / brainDistance; + npc.velocity.X = brainXDist * brainDistance; + npc.velocity.Y = brainYDist * brainDistance; npc.ai[0] = 1f; npc.netUpdate = true; } @@ -624,26 +622,26 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { float chargeVelocity = death ? 10f : 7f; chargeVelocity += 4f * enrageScale; - Vector2 value2 = Main.player[npc.target].Center - npc.Center; - value2.Normalize(); + Vector2 targetDirection = Main.player[npc.target].Center - npc.Center; + targetDirection.Normalize(); if (Main.getGoodWorld) { - value2 *= 12f; - npc.velocity = (npc.velocity * 49f + value2) / 50f; + targetDirection *= 12f; + npc.velocity = (npc.velocity * 49f + targetDirection) / 50f; } else { - value2 *= chargeVelocity; - npc.velocity = (npc.velocity * 99f + value2) / 100f; + targetDirection *= chargeVelocity; + npc.velocity = (npc.velocity * 99f + targetDirection) / 100f; } - Vector2 vector101 = new Vector2(npc.Center.X, npc.Center.Y); - float num815 = Main.npc[NPC.crimsonBoss].Center.X - vector101.X; - float num816 = Main.npc[NPC.crimsonBoss].Center.Y - vector101.Y; - float num817 = (float)Math.Sqrt(num815 * num815 + num816 * num816); + Vector2 creeperCenterCharge = new Vector2(npc.Center.X, npc.Center.Y); + float brainXDistCharge = Main.npc[NPC.crimsonBoss].Center.X - creeperCenterCharge.X; + float brainYDistCharge = Main.npc[NPC.crimsonBoss].Center.Y - creeperCenterCharge.Y; + float brainDistanceCharge = (float)Math.Sqrt(brainXDistCharge * brainXDistCharge + brainYDistCharge * brainYDistCharge); // Return to Brain - if (num817 > 700f || npc.justHit) + if (brainDistanceCharge > 700f || npc.justHit) npc.ai[0] = 0f; } diff --git a/NPCs/VanillaNPCOverrides/Bosses/CultistAI.cs b/NPCs/VanillaNPCOverrides/Bosses/CultistAI.cs index b58ab7914f..c174ecf722 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/CultistAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/CultistAI.cs @@ -240,9 +240,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.localAI[2] = 10f; - int num14 = Math.Sign(player.Center.X - npc.Center.X); - if (num14 != 0) - npc.direction = npc.spriteDirection = num14; + int facePlayerDirection = Math.Sign(player.Center.X - npc.Center.X); + if (facePlayerDirection != 0) + npc.direction = npc.spriteDirection = facePlayerDirection; npc.ai[1] += 1f; if (npc.ai[1] >= idleTime & isCultist) @@ -315,13 +315,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Movement case 0: // Set a location to move to - float num16 = (float)Math.Ceiling((player.Center + new Vector2(0f, -100f) - npc.Center).Length() / 50f); - if (num16 == 0f) - num16 = 1f; + float teleportLocation = (float)Math.Ceiling((player.Center + new Vector2(0f, -100f) - npc.Center).Length() / 50f); + if (teleportLocation == 0f) + teleportLocation = 1f; // Add self and clones to list List list2 = new List(); - int num17 = 0; + int cloneAmt = 0; list2.Add(npc.whoAmI); for (int k = 0; k < Main.maxNPCs; k++) { @@ -330,31 +330,31 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Move self and clones to location - bool flag5 = list2.Count % 2 == 0; + bool cloneAmtIsEven = list2.Count % 2 == 0; foreach (int current2 in list2) { NPC nPC2 = Main.npc[current2]; Vector2 center2 = nPC2.Center; - float num18 = (num17 + flag5.ToInt() + 1) / 2 * MathHelper.TwoPi * 0.4f / list2.Count; - if (num17 % 2 == 1) + float cloneOffset = (cloneAmt + cloneAmtIsEven.ToInt() + 1) / 2 * MathHelper.TwoPi * 0.4f / list2.Count; + if (cloneAmt % 2 == 1) { - num18 *= -1f; + cloneOffset *= -1f; } if (list2.Count == 1) { - num18 = 0f; + cloneOffset = 0f; } - Vector2 value = new Vector2(0f, -1f).RotatedBy(num18) * new Vector2(150f, 200f); - Vector2 value2 = player.Center + value - center2; + Vector2 cloneRotation = new Vector2(0f, -1f).RotatedBy(cloneOffset) * new Vector2(150f, 200f); + Vector2 finalClonePos = player.Center + cloneRotation - center2; nPC2.ai[0] = 1f; - nPC2.ai[1] = num16; - nPC2.velocity = value2 / num16 * 2f; + nPC2.ai[1] = teleportLocation; + nPC2.velocity = finalClonePos / teleportLocation * 2f; if (npc.whoAmI >= nPC2.whoAmI) { nPC2.position -= nPC2.velocity; } nPC2.netUpdate = true; - num17++; + cloneAmt++; } break; @@ -448,18 +448,18 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses NPC nPC3 = Main.npc[current3]; Vector2 center3 = nPC3.Center; - int num19 = Math.Sign(player.Center.X - center3.X); - if (num19 != 0) - nPC3.direction = nPC3.spriteDirection = num19; + int cloneFacePlayerDirection = Math.Sign(player.Center.X - center3.X); + if (cloneFacePlayerDirection != 0) + nPC3.direction = nPC3.spriteDirection = cloneFacePlayerDirection; vec = Vector2.Normalize(player.Center - center3); if (vec.HasNaNs()) vec = new Vector2(npc.direction, 0f); - Vector2 vector = center3 + new Vector2(npc.direction * 30, 12f); - Vector2 vector2 = vec * (fireballSpeed + (float)Main.rand.NextDouble() * 2f); - vector2 = vector2.RotatedByRandom(0.52359879016876221); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector, vector2, ProjectileID.CultistBossFireBallClone, fireballDamage, 0f, Main.myPlayer); + Vector2 shadowFireballDirection = center3 + new Vector2(npc.direction * 30, 12f); + Vector2 shadowFireballVelocity = vec * (fireballSpeed + (float)Main.rand.NextDouble() * 2f); + shadowFireballVelocity = shadowFireballVelocity.RotatedByRandom(0.52359879016876221); + Projectile.NewProjectile(npc.GetSource_FromAI(), shadowFireballDirection, shadowFireballVelocity, ProjectileID.CultistBossFireBallClone, fireballDamage, 0f, Main.myPlayer); } } @@ -469,9 +469,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (vec.HasNaNs()) vec = new Vector2(npc.direction, 0f); - Vector2 vector3 = npc.Center + new Vector2(npc.direction * 30, 12f); - Vector2 vector4 = vec * iceMistSpeed; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector3, vector4, ProjectileID.CultistBossIceMist, iceMistDamage, 0f, Main.myPlayer, 0f, 1f); + Vector2 iceMistDirection = npc.Center + new Vector2(npc.direction * 30, 12f); + Vector2 iceMistVelocity = vec * iceMistSpeed; + Projectile.NewProjectile(npc.GetSource_FromAI(), iceMistDirection, iceMistVelocity, ProjectileID.CultistBossIceMist, iceMistDamage, 0f, Main.myPlayer, 0f, 1f); } } @@ -491,19 +491,19 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { npc.localAI[2] = 11f; - Vector2 vec2 = Vector2.Normalize(player.Center - npc.Center); - if (vec2.HasNaNs()) - vec2 = new Vector2(npc.direction, 0f); + Vector2 playerDirection = Vector2.Normalize(player.Center - npc.Center); + if (playerDirection.HasNaNs()) + playerDirection = new Vector2(npc.direction, 0f); if ((npc.ai[1] >= 4f & isCultist) && (int)(npc.ai[1] - 4f) % fireballFireRate == 0) { if ((int)(npc.ai[1] - 4f) / fireballFireRate == 2) { List list4 = new List(); - for (int num20 = 0; num20 < Main.maxNPCs; num20++) + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num20].active && Main.npc[num20].type == NPCID.CultistBossClone && Main.npc[num20].ai[3] == npc.whoAmI) - list4.Add(num20); + if (Main.npc[i].active && Main.npc[i].type == NPCID.CultistBossClone && Main.npc[i].ai[3] == npc.whoAmI) + list4.Add(i); } if (Main.netMode != NetmodeID.MultiplayerClient) @@ -513,36 +513,36 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses NPC nPC4 = Main.npc[current4]; Vector2 center4 = nPC4.Center; - int num21 = Math.Sign(player.Center.X - center4.X); - if (num21 != 0) - nPC4.direction = nPC4.spriteDirection = num21; + int cloneFireballFaceDirection = Math.Sign(player.Center.X - center4.X); + if (cloneFireballFaceDirection != 0) + nPC4.direction = nPC4.spriteDirection = cloneFireballFaceDirection; - vec2 = Vector2.Normalize(player.Center - center4); - if (vec2.HasNaNs()) - vec2 = new Vector2(npc.direction, 0f); + playerDirection = Vector2.Normalize(player.Center - center4); + if (playerDirection.HasNaNs()) + playerDirection = new Vector2(npc.direction, 0f); - Vector2 vector5 = center4 + new Vector2(npc.direction * 30, 12f); - Vector2 vector6 = vec2 * (fireballSpeed + (float)Main.rand.NextDouble() * 2f); - vector6 = vector6.RotatedByRandom(0.52359879016876221); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector5, vector6, ProjectileID.CultistBossFireBallClone, fireballDamage, 0f, Main.myPlayer); + Vector2 shadowFireballDirection = center4 + new Vector2(npc.direction * 30, 12f); + Vector2 shadowFireballVelocity = playerDirection * (fireballSpeed + (float)Main.rand.NextDouble() * 2f); + shadowFireballVelocity = shadowFireballVelocity.RotatedByRandom(0.52359879016876221); + Projectile.NewProjectile(npc.GetSource_FromAI(), shadowFireballDirection, shadowFireballVelocity, ProjectileID.CultistBossFireBallClone, fireballDamage, 0f, Main.myPlayer); } } } - int num23 = Math.Sign(player.Center.X - npc.Center.X); - if (num23 != 0) - npc.direction = npc.spriteDirection = num23; + int cultistFireballFaceDirection = Math.Sign(player.Center.X - npc.Center.X); + if (cultistFireballFaceDirection != 0) + npc.direction = npc.spriteDirection = cultistFireballFaceDirection; if (Main.netMode != NetmodeID.MultiplayerClient) { - vec2 = Vector2.Normalize(player.Center - npc.Center); - if (vec2.HasNaNs()) - vec2 = new Vector2(npc.direction, 0f); + playerDirection = Vector2.Normalize(player.Center - npc.Center); + if (playerDirection.HasNaNs()) + playerDirection = new Vector2(npc.direction, 0f); - Vector2 vector7 = npc.Center + new Vector2(npc.direction * 30, 12f); - Vector2 vector8 = vec2 * (fireballSpeed + (float)Main.rand.NextDouble() * 4f); - vector8 = vector8.RotatedByRandom(0.52359879016876221); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector7, vector8, ProjectileID.CultistBossFireBall, fireballDamage, 0f, Main.myPlayer); + Vector2 fireballDirection = npc.Center + new Vector2(npc.direction * 30, 12f); + Vector2 fireballVelocity = playerDirection * (fireballSpeed + (float)Main.rand.NextDouble() * 4f); + fireballVelocity = fireballVelocity.RotatedByRandom(0.52359879016876221); + Projectile.NewProjectile(npc.GetSource_FromAI(), fireballDirection, fireballVelocity, ProjectileID.CultistBossFireBall, fireballDamage, 0f, Main.myPlayer); } } @@ -568,10 +568,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if ((npc.ai[1] == 20f & isCultist) && Main.netMode != NetmodeID.MultiplayerClient) { List list5 = new List(); - for (int num25 = 0; num25 < Main.maxNPCs; num25++) + for (int j = 0; j < Main.maxNPCs; j++) { - if (Main.npc[num25].active && Main.npc[num25].type == NPCID.CultistBossClone && Main.npc[num25].ai[3] == npc.whoAmI) - list5.Add(num25); + if (Main.npc[j].active && Main.npc[j].type == NPCID.CultistBossClone && Main.npc[j].ai[3] == npc.whoAmI) + list5.Add(j); } foreach (int current5 in list5) @@ -579,18 +579,18 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses NPC nPC5 = Main.npc[current5]; Vector2 center5 = nPC5.Center; - int num26 = Math.Sign(player.Center.X - center5.X); - if (num26 != 0) - nPC5.direction = nPC5.spriteDirection = num26; + int clonePlayerFaceDirection = Math.Sign(player.Center.X - center5.X); + if (clonePlayerFaceDirection != 0) + nPC5.direction = nPC5.spriteDirection = clonePlayerFaceDirection; - Vector2 vec3 = Vector2.Normalize(player.Center - center5); - if (vec3.HasNaNs()) - vec3 = new Vector2(npc.direction, 0f); + Vector2 playerDirection = Vector2.Normalize(player.Center - center5); + if (playerDirection.HasNaNs()) + playerDirection = new Vector2(npc.direction, 0f); - Vector2 vector9 = center5 + new Vector2(npc.direction * 30, 12f); - Vector2 vector10 = vec3 * (fireballSpeed + (float)Main.rand.NextDouble() * 2f); - vector10 = vector10.RotatedByRandom(0.52359879016876221); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector9.X, vector9.Y, vector10.X, vector10.Y, ProjectileID.CultistBossFireBallClone, fireballDamage, 0f, Main.myPlayer); + Vector2 shadowFireballDirection = center5 + new Vector2(npc.direction * 30, 12f); + Vector2 shadowFireballVelocity = playerDirection * (fireballSpeed + (float)Main.rand.NextDouble() * 2f); + shadowFireballVelocity = shadowFireballVelocity.RotatedByRandom(0.52359879016876221); + Projectile.NewProjectile(npc.GetSource_FromAI(), shadowFireballDirection.X, shadowFireballDirection.Y, shadowFireballVelocity.X, shadowFireballVelocity.Y, ProjectileID.CultistBossFireBallClone, fireballDamage, 0f, Main.myPlayer); } Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y - 100f, 0f, 0f, ProjectileID.CultistBossLightningOrb, lightningDamage, 0f, Main.myPlayer); @@ -618,8 +618,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[1] >= 0f && npc.ai[1] < 30f) { dontTakeDamage = true; - float num28 = (npc.ai[1] - 0f) / 30f; - npc.alpha = (int)(num28 * 255f); + float cultistAlphaControl = (npc.ai[1] - 0f) / 30f; + npc.alpha = (int)(cultistAlphaControl * 255f); } else if (npc.ai[1] >= 30f && npc.ai[1] < 90f) { @@ -630,57 +630,57 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses Vector2 spinningpoint = new Vector2(180f, 0f); List list6 = new List(); - for (int num29 = 0; num29 < Main.maxNPCs; num29++) + for (int k = 0; k < Main.maxNPCs; k++) { - if (Main.npc[num29].active && Main.npc[num29].type == NPCID.CultistBossClone && Main.npc[num29].ai[3] == npc.whoAmI) - list6.Add(num29); + if (Main.npc[k].active && Main.npc[k].type == NPCID.CultistBossClone && Main.npc[k].ai[3] == npc.whoAmI) + list6.Add(k); } - int num30 = 6 - list6.Count; - if (num30 > 2) - num30 = 2; + int potentialExtraClones = 6 - list6.Count; + if (potentialExtraClones > 2) + potentialExtraClones = 2; - int num31 = list6.Count + num30 + 1; - float[] array = new float[num31]; - for (int num32 = 0; num32 < array.Length; num32++) - array[num32] = Vector2.Distance(npc.Center + spinningpoint.RotatedBy(num32 * MathHelper.TwoPi / num31 - MathHelper.PiOver2), player.Center); + int newCloneAmt = list6.Count + potentialExtraClones + 1; + float[] array = new float[newCloneAmt]; + for (int cloneInc = 0; cloneInc < array.Length; cloneInc++) + array[cloneInc] = Vector2.Distance(npc.Center + spinningpoint.RotatedBy(cloneInc * MathHelper.TwoPi / newCloneAmt - MathHelper.PiOver2), player.Center); - int num33 = 0; - for (int num34 = 1; num34 < array.Length; num34++) + int rotateDistance = 0; + for (int j = 1; j < array.Length; j++) { - if (array[num33] > array[num34]) - num33 = num34; + if (array[rotateDistance] > array[j]) + rotateDistance = j; } - if (num33 < num31 / 2) - num33 += num31 / 2; + if (rotateDistance < newCloneAmt / 2) + rotateDistance += newCloneAmt / 2; else - num33 -= num31 / 2; + rotateDistance -= newCloneAmt / 2; - int num35 = num30; - for (int num36 = 0; num36 < array.Length; num36++) + int clonesToSpawn = potentialExtraClones; + for (int k = 0; k < array.Length; k++) { - if (num33 != num36) + if (rotateDistance != k) { - Vector2 vector11 = npc.Center + spinningpoint.RotatedBy(num36 * MathHelper.TwoPi / num31 - MathHelper.PiOver2); - if (num35-- > 0) + Vector2 cloneRotation = npc.Center + spinningpoint.RotatedBy(k * MathHelper.TwoPi / newCloneAmt - MathHelper.PiOver2); + if (clonesToSpawn-- > 0) { - int num37 = NPC.NewNPC(npc.GetSource_FromAI(), (int)vector11.X, (int)vector11.Y + npc.height / 2, NPCID.CultistBossClone, npc.whoAmI); - Main.npc[num37].ai[3] = npc.whoAmI; - Main.npc[num37].netUpdate = true; - Main.npc[num37].localAI[1] = npc.localAI[1]; + int cloneSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)cloneRotation.X, (int)cloneRotation.Y + npc.height / 2, NPCID.CultistBossClone, npc.whoAmI); + Main.npc[cloneSpawn].ai[3] = npc.whoAmI; + Main.npc[cloneSpawn].netUpdate = true; + Main.npc[cloneSpawn].localAI[1] = npc.localAI[1]; } else { - int num38 = list6[-num35 - 1]; - Main.npc[num38].Center = vector11; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num38, 0f, 0f, 0f, 0, 0, 0); + int currentClone = list6[-clonesToSpawn - 1]; + Main.npc[currentClone].Center = cloneRotation; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, currentClone, 0f, 0f, 0f, 0, 0, 0); } } } npc.ai[2] = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, Vector2.Zero, ProjectileID.CultistRitual, 0, 0f, Main.myPlayer, 0f, npc.whoAmI); - npc.Center += spinningpoint.RotatedBy(num33 * MathHelper.TwoPi / num31 - MathHelper.PiOver2); + npc.Center += spinningpoint.RotatedBy(rotateDistance * MathHelper.TwoPi / newCloneAmt - MathHelper.PiOver2); npc.netUpdate = true; list6.Clear(); } @@ -690,50 +690,50 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (isCultist) { - Vector2 vector12 = Main.projectile[(int)npc.ai[2]].Center; - vector12 -= npc.Center; - if (vector12 == Vector2.Zero) - vector12 = -Vector2.UnitY; + Vector2 ritualCenterDirection = Main.projectile[(int)npc.ai[2]].Center; + ritualCenterDirection -= npc.Center; + if (ritualCenterDirection == Vector2.Zero) + ritualCenterDirection = -Vector2.UnitY; - vector12.Normalize(); + ritualCenterDirection.Normalize(); - if (Math.Abs(vector12.Y) < 0.77f) + if (Math.Abs(ritualCenterDirection.Y) < 0.77f) npc.localAI[2] = 11f; - else if (vector12.Y < 0f) + else if (ritualCenterDirection.Y < 0f) npc.localAI[2] = 12f; else npc.localAI[2] = 10f; - int num39 = Math.Sign(vector12.X); - if (num39 != 0) - npc.direction = npc.spriteDirection = num39; + int ritualFaceDirection = Math.Sign(ritualCenterDirection.X); + if (ritualFaceDirection != 0) + npc.direction = npc.spriteDirection = ritualFaceDirection; } else { - Vector2 vector13 = Main.projectile[(int)Main.npc[(int)npc.ai[3]].ai[2]].Center; - vector13 -= npc.Center; - if (vector13 == Vector2.Zero) - vector13 = -Vector2.UnitY; + Vector2 ritualCenterFailDirection = Main.projectile[(int)Main.npc[(int)npc.ai[3]].ai[2]].Center; + ritualCenterFailDirection -= npc.Center; + if (ritualCenterFailDirection == Vector2.Zero) + ritualCenterFailDirection = -Vector2.UnitY; - vector13.Normalize(); + ritualCenterFailDirection.Normalize(); - if (Math.Abs(vector13.Y) < 0.77f) + if (Math.Abs(ritualCenterFailDirection.Y) < 0.77f) npc.localAI[2] = 11f; - else if (vector13.Y < 0f) + else if (ritualCenterFailDirection.Y < 0f) npc.localAI[2] = 12f; else npc.localAI[2] = 10f; - int num40 = Math.Sign(vector13.X); - if (num40 != 0) - npc.direction = npc.spriteDirection = num40; + int ritualFailFaceDirection = Math.Sign(ritualCenterFailDirection.X); + if (ritualFailFaceDirection != 0) + npc.direction = npc.spriteDirection = ritualFailFaceDirection; } } else if (npc.ai[1] >= 90f && npc.ai[1] < 120f) { dontTakeDamage = true; - float num41 = (npc.ai[1] - 90f) / 30f; - npc.alpha = 255 - (int)(num41 * 255f); + float ritualAlphaControl = (npc.ai[1] - 90f) / 30f; + npc.alpha = 255 - (int)(ritualAlphaControl * 255f); } else if (npc.ai[1] >= 120f && npc.ai[1] < timeToFinishRitual) { @@ -741,43 +741,43 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (isCultist) { - Vector2 vector14 = Main.projectile[(int)npc.ai[2]].Center; - vector14 -= npc.Center; - if (vector14 == Vector2.Zero) - vector14 = -Vector2.UnitY; + Vector2 ritualTimeAlmostUpCenterDirection = Main.projectile[(int)npc.ai[2]].Center; + ritualTimeAlmostUpCenterDirection -= npc.Center; + if (ritualTimeAlmostUpCenterDirection == Vector2.Zero) + ritualTimeAlmostUpCenterDirection = -Vector2.UnitY; - vector14.Normalize(); + ritualTimeAlmostUpCenterDirection.Normalize(); - if (Math.Abs(vector14.Y) < 0.77f) + if (Math.Abs(ritualTimeAlmostUpCenterDirection.Y) < 0.77f) npc.localAI[2] = 11f; - else if (vector14.Y < 0f) + else if (ritualTimeAlmostUpCenterDirection.Y < 0f) npc.localAI[2] = 12f; else npc.localAI[2] = 10f; - int num42 = Math.Sign(vector14.X); - if (num42 != 0) - npc.direction = npc.spriteDirection = num42; + int ritualTimeAlmostUpFaceDirection = Math.Sign(ritualTimeAlmostUpCenterDirection.X); + if (ritualTimeAlmostUpFaceDirection != 0) + npc.direction = npc.spriteDirection = ritualTimeAlmostUpFaceDirection; } else { - Vector2 vector15 = Main.projectile[(int)Main.npc[(int)npc.ai[3]].ai[2]].Center; - vector15 -= npc.Center; - if (vector15 == Vector2.Zero) - vector15 = -Vector2.UnitY; + Vector2 ritualTimeUpCenterDirection = Main.projectile[(int)Main.npc[(int)npc.ai[3]].ai[2]].Center; + ritualTimeUpCenterDirection -= npc.Center; + if (ritualTimeUpCenterDirection == Vector2.Zero) + ritualTimeUpCenterDirection = -Vector2.UnitY; - vector15.Normalize(); + ritualTimeUpCenterDirection.Normalize(); - if (Math.Abs(vector15.Y) < 0.77f) + if (Math.Abs(ritualTimeUpCenterDirection.Y) < 0.77f) npc.localAI[2] = 11f; - else if (vector15.Y < 0f) + else if (ritualTimeUpCenterDirection.Y < 0f) npc.localAI[2] = 12f; else npc.localAI[2] = 10f; - int num43 = Math.Sign(vector15.X); - if (num43 != 0) - npc.direction = npc.spriteDirection = num43; + int ritualTimeUpFaceDirection = Math.Sign(ritualTimeUpCenterDirection.X); + if (ritualTimeUpFaceDirection != 0) + npc.direction = npc.spriteDirection = ritualTimeUpFaceDirection; } } @@ -813,19 +813,19 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { npc.localAI[2] = 11f; - Vector2 vec4 = Vector2.Normalize(player.Center - npc.Center); - if (vec4.HasNaNs()) - vec4 = new Vector2(npc.direction, 0f); + Vector2 playerDirection = Vector2.Normalize(player.Center - npc.Center); + if (playerDirection.HasNaNs()) + playerDirection = new Vector2(npc.direction, 0f); if ((npc.ai[1] >= 4f & isCultist) && (int)(npc.ai[1] - 4f) % ancientLightSpawnRate == 0) { if ((int)(npc.ai[1] - 4f) / ancientLightSpawnRate == 2) { List list7 = new List(); - for (int num44 = 0; num44 < Main.maxNPCs; num44++) + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num44].active && Main.npc[num44].type == NPCID.CultistBossClone && Main.npc[num44].ai[3] == npc.whoAmI) - list7.Add(num44); + if (Main.npc[i].active && Main.npc[i].type == NPCID.CultistBossClone && Main.npc[i].ai[3] == npc.whoAmI) + list7.Add(i); } foreach (int current6 in list7) @@ -833,36 +833,36 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses NPC nPC6 = Main.npc[current6]; Vector2 center6 = nPC6.Center; - int num45 = Math.Sign(player.Center.X - center6.X); - if (num45 != 0) - nPC6.direction = nPC6.spriteDirection = num45; + int cloneFaceDirection = Math.Sign(player.Center.X - center6.X); + if (cloneFaceDirection != 0) + nPC6.direction = nPC6.spriteDirection = cloneFaceDirection; } } - int num47 = Math.Sign(player.Center.X - npc.Center.X); - if (num47 != 0) - npc.direction = npc.spriteDirection = num47; + int cultistFaceDirection = Math.Sign(player.Center.X - npc.Center.X); + if (cultistFaceDirection != 0) + npc.direction = npc.spriteDirection = cultistFaceDirection; if (Main.netMode != NetmodeID.MultiplayerClient) { - vec4 = Vector2.Normalize(player.Center - npc.Center); - if (vec4.HasNaNs()) - vec4 = new Vector2(npc.direction, 0f); + playerDirection = Vector2.Normalize(player.Center - npc.Center); + if (playerDirection.HasNaNs()) + playerDirection = new Vector2(npc.direction, 0f); - Vector2 vector18 = npc.Center + new Vector2(npc.direction * 30, 12f); + Vector2 ancientLightShootDirection = npc.Center + new Vector2(npc.direction * 30, 12f); float scaleFactor = death ? 6f : 4f; - float num48 = MathHelper.ToRadians(15f); - int num49 = 0; + float ancientLightSpread = MathHelper.ToRadians(15f); + int ancientLightInc = 0; float totalAncientLights = 5f; - while (num49 < totalAncientLights) + while (ancientLightInc < totalAncientLights) { - Vector2 vector19 = vec4 * scaleFactor; - vector19 = vector19.RotatedBy(num48 * num49 - (MathHelper.Pi / totalAncientLights * 2f - num48) / 2f); + Vector2 ancientLightSpeed = playerDirection * scaleFactor; + ancientLightSpeed = ancientLightSpeed.RotatedBy(ancientLightSpread * ancientLightInc - (MathHelper.Pi / totalAncientLights * 2f - ancientLightSpread) / 2f); float ai = (Main.rand.NextFloat() - 0.5f) * 0.3f * MathHelper.TwoPi / 60f; - int num50 = NPC.NewNPC(npc.GetSource_FromAI(), (int)vector18.X, (int)vector18.Y + 7, NPCID.AncientLight, 0, 0f, ai, vector19.X, vector19.Y, 255); - Main.npc[num50].velocity = vector19; - num49++; + int ancientLightProj = NPC.NewNPC(npc.GetSource_FromAI(), (int)ancientLightShootDirection.X, (int)ancientLightShootDirection.Y + 7, NPCID.AncientLight, 0, 0f, ai, ancientLightSpeed.X, ancientLightSpeed.Y, 255); + Main.npc[ancientLightProj].velocity = ancientLightSpeed; + ancientLightInc++; } } } @@ -886,19 +886,19 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if ((npc.ai[1] >= 4f & isCultist) && (int)(npc.ai[1] - 4f) % 20f == 0f) { List list8 = new List(); - for (int num51 = 0; num51 < Main.maxNPCs; num51++) + for (int k = 0; k < Main.maxNPCs; k++) { - if (Main.npc[num51].active && Main.npc[num51].type == NPCID.CultistBossClone && Main.npc[num51].ai[3] == npc.whoAmI) - list8.Add(num51); + if (Main.npc[k].active && Main.npc[k].type == NPCID.CultistBossClone && Main.npc[k].ai[3] == npc.whoAmI) + list8.Add(k); } - int num52 = list8.Count + 1; - if (num52 > 2) - num52 = 2; + int ancientDoomAmt = list8.Count + 1; + if (ancientDoomAmt > 2) + ancientDoomAmt = 2; - int num53 = Math.Sign(player.Center.X - npc.Center.X); - if (num53 != 0) - npc.direction = npc.spriteDirection = num53; + int ancientDoomFaceDirection = Math.Sign(player.Center.X - npc.Center.X); + if (ancientDoomFaceDirection != 0) + npc.direction = npc.spriteDirection = ancientDoomFaceDirection; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -915,32 +915,32 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses else { // Spawn Ancient Dooms randomly around the target - for (int num54 = 0; num54 < num52; num54++) + for (int i = 0; i < ancientDoomAmt; i++) { - Point point = npc.Center.ToTileCoordinates(); - Point point2 = Main.player[npc.target].Center.ToTileCoordinates(); - Vector2 vector20 = Main.player[npc.target].Center - npc.Center; + Point cultistCenterTileCoords = npc.Center.ToTileCoordinates(); + Point targetCenterTileCoords = Main.player[npc.target].Center.ToTileCoordinates(); + Vector2 targetDistanceDoom = Main.player[npc.target].Center - npc.Center; - int num55 = 20; - int num56 = 3; - int num57 = 7; - int num58 = 2; - int num59 = 0; - bool flag6 = vector20.Length() > 2800f; - while (!flag6 && num59 < 100) + int randSpawnOffset = 20; + int cultistCenterSpawnOffset = 3; + int targetCenterSpawnOffset = 7; + int tileCollisionRange = 2; + int spawnAttempts = 0; + bool doomSufficientlyFar = targetDistanceDoom.Length() > 2800f; + while (!doomSufficientlyFar && spawnAttempts < 100) { - num59++; - int num60 = Main.rand.Next(point2.X - num55, point2.X + num55 + 1); - int num61 = Main.rand.Next(point2.Y - num55, point2.Y + num55 + 1); - if ((num61 < point2.Y - num57 || num61 > point2.Y + num57 || num60 < point2.X - num57 || num60 > point2.X + num57) && (num61 < point.Y - num56 || num61 > point.Y + num56 || num60 < point.X - num56 || num60 > point.X + num56) && !Main.tile[num60, num61].HasUnactuatedTile) + spawnAttempts++; + int ancientDoomSpawnX = Main.rand.Next(targetCenterTileCoords.X - randSpawnOffset, targetCenterTileCoords.X + randSpawnOffset + 1); + int ancientDoomSpawnY = Main.rand.Next(targetCenterTileCoords.Y - randSpawnOffset, targetCenterTileCoords.Y + randSpawnOffset + 1); + if ((ancientDoomSpawnY < targetCenterTileCoords.Y - targetCenterSpawnOffset || ancientDoomSpawnY > targetCenterTileCoords.Y + targetCenterSpawnOffset || ancientDoomSpawnX < targetCenterTileCoords.X - targetCenterSpawnOffset || ancientDoomSpawnX > targetCenterTileCoords.X + targetCenterSpawnOffset) && (ancientDoomSpawnY < cultistCenterTileCoords.Y - cultistCenterSpawnOffset || ancientDoomSpawnY > cultistCenterTileCoords.Y + cultistCenterSpawnOffset || ancientDoomSpawnX < cultistCenterTileCoords.X - cultistCenterSpawnOffset || ancientDoomSpawnX > cultistCenterTileCoords.X + cultistCenterSpawnOffset) && !Main.tile[ancientDoomSpawnX, ancientDoomSpawnY].HasUnactuatedTile) { - bool flag7 = true; - if (flag7 && Collision.SolidTiles(num60 - num58, num60 + num58, num61 - num58, num61 + num58)) - flag7 = false; + bool notInsideTiles = true; + if (notInsideTiles && Collision.SolidTiles(ancientDoomSpawnX - tileCollisionRange, ancientDoomSpawnX + tileCollisionRange, ancientDoomSpawnY - tileCollisionRange, ancientDoomSpawnY + tileCollisionRange)) + notInsideTiles = false; - if (flag7) + if (notInsideTiles) { - NPC.NewNPC(npc.GetSource_FromAI(), num60 * 16 + 8, num61 * 16 + 8, NPCID.AncientDoom, 0, npc.whoAmI); + NPC.NewNPC(npc.GetSource_FromAI(), ancientDoomSpawnX * 16 + 8, ancientDoomSpawnY * 16 + 8, NPCID.AncientDoom, 0, npc.whoAmI); break; } } @@ -1009,35 +1009,35 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.localAI[0] = 1f; npc.velocity.X = npc.ai[2]; npc.velocity.Y = npc.ai[3]; - for (int num1492 = 0; num1492 < 13; num1492++) + for (int i = 0; i < 13; i++) { - int num1493 = Dust.NewDust(npc.position, npc.width, npc.height, 261, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default, 2.5f); - Main.dust[num1493].noGravity = true; - Main.dust[num1493].fadeIn = 1f; - Dust dust = Main.dust[num1493]; + int ancientLight = Dust.NewDust(npc.position, npc.width, npc.height, 261, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default, 2.5f); + Main.dust[ancientLight].noGravity = true; + Main.dust[ancientLight].fadeIn = 1f; + Dust dust = Main.dust[ancientLight]; dust.velocity *= 4f; - Main.dust[num1493].noLight = true; + Main.dust[ancientLight].noLight = true; } } // Spawn dust - for (int num1494 = 0; num1494 < 2; num1494++) + for (int j = 0; j < 2; j++) { if (Main.rand.Next(10 - (int)Math.Min(7f, npc.velocity.Length())) < 1) { - int num1495 = Dust.NewDust(npc.position, npc.width, npc.height, 261, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default, 2.5f); - Main.dust[num1495].noGravity = true; - Dust dust = Main.dust[num1495]; + int ancientLight2 = Dust.NewDust(npc.position, npc.width, npc.height, 261, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default, 2.5f); + Main.dust[ancientLight2].noGravity = true; + Dust dust = Main.dust[ancientLight2]; dust.velocity *= 0.2f; - Main.dust[num1495].fadeIn = 0.4f; + Main.dust[ancientLight2].fadeIn = 0.4f; if (Main.rand.NextBool(6)) { - dust = Main.dust[num1495]; + dust = Main.dust[ancientLight2]; dust.velocity *= 5f; - Main.dust[num1495].noLight = true; + Main.dust[ancientLight2].noLight = true; } else - Main.dust[num1495].velocity = npc.DirectionFrom(Main.dust[num1495].position) * Main.dust[num1495].velocity.Length(); + Main.dust[ancientLight2].velocity = npc.DirectionFrom(Main.dust[ancientLight2].position) * Main.dust[ancientLight2].velocity.Length(); } } @@ -1142,33 +1142,33 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.rand.NextBool(6)) { - Vector2 spinningpoint4 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - Dust dust17 = Main.dust[Dust.NewDust(npc.Center - spinningpoint4 * 20f, 0, 0, 27, 0f, 0f, 0, default, 1f)]; - dust17.noGravity = true; - dust17.position = npc.Center - spinningpoint4 * Main.rand.Next(10, 21) * npc.scale; - dust17.velocity = spinningpoint4.RotatedBy(MathHelper.PiOver2) * 4f; - dust17.scale = 0.5f + Main.rand.NextFloat(); - dust17.fadeIn = 0.5f; + Vector2 shadowflameDustRotate = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + Dust shadowflameDust = Main.dust[Dust.NewDust(npc.Center - shadowflameDustRotate * 20f, 0, 0, 27, 0f, 0f, 0, default, 1f)]; + shadowflameDust.noGravity = true; + shadowflameDust.position = npc.Center - shadowflameDustRotate * Main.rand.Next(10, 21) * npc.scale; + shadowflameDust.velocity = shadowflameDustRotate.RotatedBy(MathHelper.PiOver2) * 4f; + shadowflameDust.scale = 0.5f + Main.rand.NextFloat(); + shadowflameDust.fadeIn = 0.5f; } if (Main.rand.NextBool(6)) { - Vector2 spinningpoint5 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - Dust dust18 = Main.dust[Dust.NewDust(npc.Center - spinningpoint5 * 30f, 0, 0, 240, 0f, 0f, 0, default, 1f)]; - dust18.noGravity = true; - dust18.position = npc.Center - spinningpoint5 * 20f * npc.scale; - dust18.velocity = spinningpoint5.RotatedBy(-MathHelper.PiOver2) * 2f; - dust18.scale = 0.5f + Main.rand.NextFloat(); - dust18.fadeIn = 0.5f; + Vector2 darkDustRotate = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + Dust darkDust = Main.dust[Dust.NewDust(npc.Center - darkDustRotate * 30f, 0, 0, 240, 0f, 0f, 0, default, 1f)]; + darkDust.noGravity = true; + darkDust.position = npc.Center - darkDustRotate * 20f * npc.scale; + darkDust.velocity = darkDustRotate.RotatedBy(-MathHelper.PiOver2) * 2f; + darkDust.scale = 0.5f + Main.rand.NextFloat(); + darkDust.fadeIn = 0.5f; } if (Main.rand.NextBool(6)) { - Vector2 vector254 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - Dust dust19 = Main.dust[Dust.NewDust(npc.Center - vector254 * 30f, 0, 0, 240, 0f, 0f, 0, default, 1f)]; - dust19.position = npc.Center - vector254 * 20f * npc.scale; - dust19.velocity = Vector2.Zero; - dust19.scale = 0.5f + Main.rand.NextFloat(); - dust19.fadeIn = 0.5f; - dust19.noLight = true; + Vector2 darkDustRotate2 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + Dust darkDust2 = Main.dust[Dust.NewDust(npc.Center - darkDustRotate2 * 30f, 0, 0, 240, 0f, 0f, 0, default, 1f)]; + darkDust2.position = npc.Center - darkDustRotate2 * 20f * npc.scale; + darkDust2.velocity = Vector2.Zero; + darkDust2.scale = 0.5f + Main.rand.NextFloat(); + darkDust2.fadeIn = 0.5f; + darkDust2.noLight = true; } npc.localAI[0] += 0.05235988f; @@ -1192,8 +1192,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses Vector2 spinningPoint = new Vector2(0f, -splitProjVelocity); for (int k = 0; k < totalProjectiles; k++) { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, vector255, type, damage, 0f, Main.myPlayer); + Vector2 doomProjRotate = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, doomProjRotate, type, damage, 0f, Main.myPlayer); } } } diff --git a/NPCs/VanillaNPCOverrides/Bosses/DeerclopsAI.cs b/NPCs/VanillaNPCOverrides/Bosses/DeerclopsAI.cs new file mode 100644 index 0000000000..ff1a2d133f --- /dev/null +++ b/NPCs/VanillaNPCOverrides/Bosses/DeerclopsAI.cs @@ -0,0 +1,852 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.Graphics.CameraModifiers; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Audio; +using CalamityMod.World; + +namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses +{ + public static class DeerclopsAI + { + public static bool shouldDrawEnrageBorder = true; + public static bool hasTargetBeenInRange = true; + public const float increaseDRTriggerDistance = 450f; + public const float maxDRIncreaseDistance = 900f; + public static float borderDelay = 10f * 60f; + public static float innerBorder = 450f; + public static float outerBorder = 900f; + public static float borderScalar = 0f; + public static Vector2 lastDeerclopsPosition; + + + public static bool BuffedDeerclopsAI(NPC npc, Mod mod) + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + NPC.deerclopsBoss = npc.whoAmI; + + // Percent life remaining + float lifeRatio = (float)npc.life / (float)npc.lifeMax; + + // Difficulty bools + bool expertMode = Main.expertMode; + + // Projectile types and damage + int rubble = ProjectileID.DeerclopsRangedProjectile; + int rubbleDamage = npc.GetProjectileDamage(rubble); + int iceSpike = ProjectileID.DeerclopsIceSpike; + int iceSpikeDamage = npc.GetProjectileDamage(iceSpike); + int shadowHand = ProjectileID.InsanityShadowHostile; + int shadowHandDamage = npc.GetProjectileDamage(shadowHand); + + // Target data + NPCAimedTarget targetData = npc.GetTargetData(); + + // Movement variables + bool haltMovement = false; + bool goHome = false; + + // Damage resistance based on distance from target + float distanceFromTarget = npc.Distance(targetData.Center); + bool triggerDRIncrease = distanceFromTarget >= increaseDRTriggerDistance; + float resistDamageAmount = MathHelper.Clamp((distanceFromTarget - increaseDRTriggerDistance) / (maxDRIncreaseDistance - increaseDRTriggerDistance), 0f, 1f); + npc.localAI[3] = MathHelper.Lerp(0f, 30f, resistDamageAmount); + float dustAndDRScalar = Utils.Remap(npc.localAI[3], 0f, 30f, 0f, 1f); + calamityGlobalNPC.DR = MathHelper.Lerp(0.05f, 0.9f, dustAndDRScalar); + + if (borderDelay > 0f) + borderDelay -= 1f; + + if (dustAndDRScalar > 0f) + { + float invincibleDustAmount = Main.rand.NextFloat() * dustAndDRScalar * 3f; + while (invincibleDustAmount > 0f) + { + invincibleDustAmount -= 1f; + Dust.NewDustDirect(npc.position, npc.width, npc.height, 109, 0f, -3f, 0, default(Color), 1.4f).noGravity = true; + } + } + else if (!hasTargetBeenInRange) + { + //Target entered the border for the first time + hasTargetBeenInRange = true; + if (borderDelay > 120f) + borderDelay = 120f; + } + if (innerBorder != increaseDRTriggerDistance || maxDRIncreaseDistance != outerBorder) + { + //Adjust the border IF the new value is lower (helps prevent jumping if you enter the border early while it's on screen but not finished zooming in) + var LerpValue = Utils.GetLerpValue(hasTargetBeenInRange ? 120f : 180f, 0f, borderDelay, true); + var newInner = MathHelper.Lerp(maxDRIncreaseDistance * 5f, increaseDRTriggerDistance, LerpValue); + if (newInner < innerBorder) + innerBorder = newInner; + var newOuter = MathHelper.Lerp(maxDRIncreaseDistance * 5f, maxDRIncreaseDistance, LerpValue); + if (newOuter < outerBorder) + outerBorder = newOuter; + } + if ((hasTargetBeenInRange && borderScalar < 1f) || borderDelay > 0f) + { + //fade in, with full opacity only available after being inside the border for the first time + borderScalar = MathHelper.Clamp(borderScalar + 0.015f, 0f, hasTargetBeenInRange ? 1f : 0.9f); + } + shouldDrawEnrageBorder = CalamityWorld.revenge || CalamityWorld.death; + + //Set the last deerclops position (used only for post-death border shenanigans) + lastDeerclopsPosition = npc.Center; + + // Spawn settings + if (npc.homeTileX == -1 && npc.homeTileY == -1) + { + Point point = npc.Bottom.ToTileCoordinates(); + npc.homeTileX = point.X; + npc.homeTileY = point.Y; + npc.ai[2] = npc.homeTileX; + npc.ai[3] = npc.homeTileY; + npc.netUpdate = true; + npc.timeLeft = 86400; + } + + // Decrease time left based on actual world updates + npc.timeLeft -= Main.worldEventUpdates; + if (npc.timeLeft < 0) + npc.timeLeft = 0; + + // Set home tile so Deerclops knows where to return to + npc.homeTileX = (int)npc.ai[2]; + npc.homeTileY = (int)npc.ai[3]; + + // Spawn Shadow Hands + if (Main.netMode != NetmodeID.MultiplayerClient) + SpawnPassiveShadowHands(npc, lifeRatio, shadowHand, shadowHandDamage); + + // AI states + switch ((int)npc.ai[0]) + { + // This case is never used + case -1: + + npc.localAI[3] = -10f; + + break; + + // Choose an attack to use + case 0: + + npc.TargetClosest(); + targetData = npc.GetTargetData(); + if (ShouldRunAway(npc, ref targetData, isChasing: true)) + { + npc.ai[0] = 6f; + npc.ai[1] = 0f; + npc.localAI[1] = 0f; + npc.netUpdate = true; + break; + } + + npc.ai[1] += 1f; + Vector2 relativeCenter = npc.Bottom + new Vector2(0f, -32f); + Vector2 closestTargetPoint = targetData.Hitbox.ClosestPointInRect(relativeCenter); + Vector2 distanceFromTarget2 = closestTargetPoint - relativeCenter; + (closestTargetPoint - npc.Center).Length(); + float distanceCheckMultiplier = 0.6f; + bool useFrontIceSpikeAttack = Math.Abs(distanceFromTarget2.X) >= Math.Abs(distanceFromTarget2.Y) * distanceCheckMultiplier || distanceFromTarget2.Length() < 48f; + bool useEitherIceSpikeAttack = distanceFromTarget2.Y <= (float)(100 + targetData.Height) && distanceFromTarget2.Y >= -200f; + if (Math.Abs(distanceFromTarget2.X) < 120f && useEitherIceSpikeAttack && npc.velocity.Y == 0f && npc.localAI[1] >= 2f) + { + npc.velocity.X = 0f; + npc.ai[0] = 4f; + npc.ai[1] = 0f; + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] -= 1f; + npc.SyncExtraAI(); + npc.netUpdate = true; + break; + } + + if (Math.Abs(distanceFromTarget2.X) < 120f && useEitherIceSpikeAttack && npc.velocity.Y == 0f && useFrontIceSpikeAttack) + { + npc.velocity.X = 0f; + npc.ai[0] = 1f; + npc.ai[1] = 0f; + npc.localAI[1] += 1f; + calamityGlobalNPC.newAI[0] -= 1f; + npc.SyncExtraAI(); + npc.netUpdate = true; + break; + } + + bool useRubbleAttack = npc.ai[1] >= 240f; + if (npc.velocity.Y == 0f && npc.velocity.X != 0f && useRubbleAttack) + { + npc.velocity.X = 0f; + npc.ai[0] = 2f; + npc.ai[1] = 0f; + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] -= 1f; + npc.SyncExtraAI(); + npc.netUpdate = true; + break; + } + + bool useShadowHandAttack = npc.ai[1] >= 90f; + if (npc.velocity.Y == 0f && npc.velocity.X == 0f && useShadowHandAttack) + { + npc.velocity.X = 0f; + npc.ai[0] = 5f; + npc.ai[1] = 0f; + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] -= 1f; + npc.SyncExtraAI(); + npc.netUpdate = true; + break; + } + + // This replaced the slow debuff infliction + bool useSecondShadowHandAttack = npc.ai[1] >= 120f; + if (npc.velocity.Y == 0f && useSecondShadowHandAttack && Math.Abs(distanceFromTarget2.X) > 100f && calamityGlobalNPC.newAI[0] <= 0f) + { + npc.velocity.X = 0f; + npc.ai[0] = 3f; + npc.ai[1] = 0f; + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] = 5f; + npc.SyncExtraAI(); + npc.netUpdate = true; + } + + break; + + // Create spikes in front of Deerclops + case 1: + + npc.ai[1] += 1f; + haltMovement = true; + MakeSpikesForward(npc, 1, targetData, iceSpike, iceSpikeDamage); + + if (npc.ai[1] >= 80f) + { + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.netUpdate = true; + } + + break; + + // Scoop up rubble + case 2: + + int scoopRubbleGateValue = 32; + npc.ai[1] += 1f; + if (npc.ai[1] == (float)(scoopRubbleGateValue - 20)) + SoundEngine.PlaySound(SoundID.DeerclopsScream, npc.Center); + + if (npc.ai[1] == (float)scoopRubbleGateValue) + SoundEngine.PlaySound(SoundID.DeerclopsRubbleAttack, npc.Center); + + haltMovement = true; + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] >= (float)scoopRubbleGateValue) + { + Point sourceTileCoords = npc.Top.ToTileCoordinates(); + int numRubble = 20; + int distancedByThisManyTiles = 5; + sourceTileCoords.X += npc.direction * 3; + sourceTileCoords.Y -= 10; + int screenShakeGateValue = (int)npc.ai[1] - scoopRubbleGateValue; + if (screenShakeGateValue == 0) + { + PunchCameraModifier modifier4 = new PunchCameraModifier(npc.Center, new Vector2(0f, -1f), 20f, 6f, 30, 1000f, "Deerclops"); + Main.instance.CameraModifiers.Add(modifier4); + } + + int rubbleStart = screenShakeGateValue; + int rubbleLimit = rubbleStart + 1; + if (screenShakeGateValue % 1 != 0) + rubbleLimit = rubbleStart; + + for (int rubbleIndex = rubbleStart; rubbleIndex < rubbleLimit && rubbleIndex < numRubble; rubbleIndex++) + ShootRubbleUp(npc, ref sourceTileCoords, numRubble, distancedByThisManyTiles, rubbleIndex, rubble, rubbleDamage); + } + + if (npc.ai[1] >= 60f) + { + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.netUpdate = true; + } + + break; + + // Spawn shadow hands around the target with differing velocities + case 3: + + if (npc.ai[1] == 30f) + SoundEngine.PlaySound(SoundID.DeerclopsScream, npc.Center); + + npc.ai[1] += 1f; + haltMovement = true; + if ((int)npc.ai[1] % 4 == 0 && npc.ai[1] >= 28f) + { + PunchCameraModifier modifier5 = new PunchCameraModifier(npc.Center, (Main.rand.NextFloat() * ((float)Math.PI * 2f)).ToRotationVector2(), 20f, 6f, 20, 1000f, "Deerclops"); + Main.instance.CameraModifiers.Add(modifier5); + } + + if (npc.ai[1] == 30f) + { + npc.TargetClosest(); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int totalProjectiles = 9; + float radians = MathHelper.TwoPi / totalProjectiles; + float velocity = 9f; + Vector2 spinningPoint = new Vector2(0f, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 actualVelocity = spinningPoint.RotatedBy(radians * k); + float velocityMultiplier = 1f - k * 0.1f; + Projectile.NewProjectile(npc.GetSource_FromAI(), Main.player[npc.target].Center + Vector2.Normalize(actualVelocity) * 450f, actualVelocity * velocityMultiplier * -1f, shadowHand, shadowHandDamage, 0f, Main.myPlayer); + } + } + } + + if (npc.ai[1] >= 60f) + { + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.netUpdate = true; + } + + break; + + // Spawn ice spikes on both sides + case 4: + + npc.ai[1] += 1f; + haltMovement = true; + npc.TargetClosest(); + MakeSpikesBothSides(npc, 1, targetData, iceSpike, iceSpikeDamage); + + if (npc.ai[1] >= 90f) + { + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.netUpdate = true; + } + + break; + + // Spawn shadow hands around the target with randomized AI + case 5: + + if (npc.ai[1] == 30f) + SoundEngine.PlaySound(SoundID.DeerclopsScream, npc.Center); + + npc.ai[1] += 1f; + haltMovement = true; + if ((int)npc.ai[1] % 4 == 0 && npc.ai[1] >= 28f) + { + PunchCameraModifier modifier = new PunchCameraModifier(npc.Center, (Main.rand.NextFloat() * ((float)Math.PI * 2f)).ToRotationVector2(), 20f, 6f, 20, 1000f, "Deerclops"); + Main.instance.CameraModifiers.Add(modifier); + } + + if (npc.ai[1] == 30f) + { + npc.TargetClosest(); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + for (int i = 0; i < 6; i++) + { + RandomizeInsanityShadowFor(Main.player[npc.target], isHostile: true, out var spawnposition, out var spawnvelocity, out var ai, out var ai2); + Projectile.NewProjectile(npc.GetSource_FromAI(), spawnposition, spawnvelocity, shadowHand, shadowHandDamage, 0f, Main.myPlayer, ai, ai2); + } + } + } + + if (npc.ai[1] >= 60f) + { + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.netUpdate = true; + } + + break; + + // Try to go home + case 6: + + npc.TargetClosest(faceTarget: false); + targetData = npc.GetTargetData(); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (!ShouldRunAway(npc, ref targetData, isChasing: false)) + { + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.localAI[1] = 0f; + npc.netUpdate = true; + break; + } + + if (npc.timeLeft <= 0) + { + npc.ai[0] = 8f; + npc.ai[1] = 0f; + npc.localAI[1] = 0f; + npc.netUpdate = true; + break; + } + } + + if (npc.direction != npc.oldDirection) + npc.netUpdate = true; + + goHome = true; + npc.ai[1] += 1f; + Vector2 homeVector = new Vector2(npc.homeTileX * 16, npc.homeTileY * 16); + bool farBelowHome = npc.Top.Y > homeVector.Y + 1600f; + bool closeToHome = npc.Distance(homeVector) < 1020f; + npc.Distance(targetData.Center); + float stopMovingGateValue = npc.ai[1] % 600f; + if (closeToHome && stopMovingGateValue < 420f) + haltMovement = true; + + bool returnHome = false; + int returnHomeDueToBelowHomeGateValue = 300; + if (farBelowHome && npc.ai[1] >= (float)returnHomeDueToBelowHomeGateValue) + returnHome = true; + + int returnHomeDueToFarFromHomeGateValue = 1500; + if (!closeToHome && npc.ai[1] >= (float)returnHomeDueToFarFromHomeGateValue) + returnHome = true; + + if (returnHome) + { + npc.ai[0] = 7f; + npc.ai[1] = 0f; + npc.localAI[1] = 0f; + npc.netUpdate = true; + } + + break; + + // Return home + case 7: + + if (npc.ai[1] == 30f) + SoundEngine.PlaySound(SoundID.DeerclopsScream, npc.Center); + + npc.ai[1] += 1f; + haltMovement = true; + if ((int)npc.ai[1] % 4 == 0 && npc.ai[1] >= 28f) + { + PunchCameraModifier modifier3 = new PunchCameraModifier(npc.Center, (Main.rand.NextFloat() * ((float)Math.PI * 2f)).ToRotationVector2(), 20f, 6f, 20, 1000f, "Deerclops"); + Main.instance.CameraModifiers.Add(modifier3); + } + + if (npc.ai[1] == 40f) + { + npc.TargetClosest(); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.netUpdate = true; + npc.Bottom = new Vector2(npc.homeTileX * 16, npc.homeTileY * 16); + } + } + + if (npc.ai[1] >= 60f) + { + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.netUpdate = true; + } + + break; + + // Despawn + case 8: + + if (npc.ai[1] == 30f) + SoundEngine.PlaySound(SoundID.DeerclopsScream, npc.Center); + + npc.ai[1] += 1f; + haltMovement = true; + if ((int)npc.ai[1] % 4 == 0 && npc.ai[1] >= 28f) + { + PunchCameraModifier modifier2 = new PunchCameraModifier(npc.Center, (Main.rand.NextFloat() * ((float)Math.PI * 2f)).ToRotationVector2(), 20f, 6f, 20, 1000f, "Deerclops"); + Main.instance.CameraModifiers.Add(modifier2); + } + + if (npc.ai[1] >= 40f) + { + npc.life = -1; + npc.HitEffect(); + npc.active = false; + if (Main.netMode != NetmodeID.MultiplayerClient) + NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f); + + return false; + } + + break; + } + + // Movement + Movement(npc, lifeRatio, haltMovement, goHome); + + return false; + } + + private static bool ShouldRunAway(NPC npc, ref NPCAimedTarget targetData, bool isChasing) + { + // Run away if the target is far enough away from Deerclops' spawn point and not in the snow biome, or if the target is dead, or if the target is 2400 or more units away + if (targetData.Type == NPCTargetType.Player) + { + Player player = Main.player[npc.target]; + bool zoneSnow = player.ZoneSnow; + Vector2 other = new Vector2(npc.homeTileX * 16, npc.homeTileY * 16); + float distanceToTriggerRunAway = 480f; + zoneSnow |= player.Distance(other) <= distanceToTriggerRunAway; + return (player.dead || (!isChasing && !zoneSnow)) | (npc.Distance(player.Center) >= 2400f); + } + + if (targetData.Type == NPCTargetType.None) + return true; + + return false; + } + + private static void SpawnPassiveShadowHands(NPC npc, float lifeRatio, int shadowHand, int shadowHandDamage) + { + int shadowHandSpawnRate = (int)Utils.Remap(lifeRatio, 1f, 0f, 80f, 40f); + npc.localAI[2] += 1f; + int shadowHandTimer = (int)npc.localAI[2]; + if (shadowHandTimer % shadowHandSpawnRate != 0) + return; + + int rotation = shadowHandTimer / shadowHandSpawnRate; + if (shadowHandTimer / shadowHandSpawnRate >= 3) + npc.localAI[2] = 0f; + + for (int i = 0; i < Main.maxPlayers; i++) + { + if (npc.Boss_CanShootExtraAt(i, rotation % 3, 3, 1200f, alwaysSkipMainTarget: false)) + { + // Normal shadow hand spawn behavior + // Modified to make the shadow hand spawns fair + RandomizeInsanityShadowFor(Main.player[i], isHostile: true, out var spawnPosition, out var spawnVelocity, out var ai, out var ai2); + + // Spawn hands to cut the player off and force them back towards Deerclops + // This only happens if the player is triggering Deerclops' increased DR + float minShadowHandSpawnDistanceFromPlayer = 450f; + float playerDistanceFromDeerclops = Vector2.Distance(npc.Center, Main.player[i].Center); + if (playerDistanceFromDeerclops >= 450f) + { + spawnPosition = (Main.player[i].Center - npc.Center).SafeNormalize(Vector2.UnitY) * (playerDistanceFromDeerclops + minShadowHandSpawnDistanceFromPlayer); + spawnVelocity = (Main.player[i].Center - spawnPosition).SafeNormalize(Vector2.UnitY) * spawnVelocity.Length(); + } + + Projectile.NewProjectile(npc.GetSource_FromAI(), spawnPosition, spawnVelocity, shadowHand, shadowHandDamage, 0f, Main.myPlayer, ai, ai2); + } + } + } + + private static void RandomizeInsanityShadowFor(Entity targetEntity, bool isHostile, out Vector2 spawnPosition, out Vector2 spawnVelocity, out float ai0, out float ai1) + { + int spawnDirection = Main.rand.Next(2) * 2 - 1; + int shadowHandType = Main.rand.Next(4); + float spawnDistance = (isHostile ? 450f : 225f); + float velocityDivisor = (isHostile ? 30 : 20); + float velocityOffset = (isHostile ? 30 : 0); + float randomRotation = Main.rand.NextFloatDirection() * (float)Math.PI * 0.125f; + if (isHostile && targetEntity.velocity.X * (float)spawnDirection > 0f) + spawnDirection *= -1; + + if (shadowHandType == 0 && isHostile) + velocityDivisor += 10f; + + spawnPosition = targetEntity.Center + targetEntity.velocity * velocityOffset + new Vector2((float)spawnDirection * (0f - spawnDistance), 0f).RotatedBy(randomRotation); + spawnVelocity = new Vector2((float)spawnDirection * spawnDistance / velocityDivisor, 0f).RotatedBy(randomRotation); + ai0 = 0f; + ai1 = 0f; + + if (shadowHandType == 1) + { + float rotation = (float)Math.PI * 2f * Main.rand.NextFloat(); + spawnPosition = targetEntity.Center - rotation.ToRotationVector2() * spawnDistance; + ai0 = 180f; + ai1 = rotation - (float)Math.PI / 2f; + spawnVelocity = rotation.ToRotationVector2() * (isHostile ? 4 : 2); + } + else if (shadowHandType == 2) + { + float rotation = (float)Math.PI * 2f * Main.rand.NextFloat(); + spawnPosition = targetEntity.Center - rotation.ToRotationVector2() * spawnDistance; + ai0 = 300f; + ai1 = rotation; + spawnVelocity = rotation.ToRotationVector2() * (isHostile ? 4 : 2); + } + else if (shadowHandType == 3) + { + float rotation = (float)Math.PI * 2f * Main.rand.NextFloat(); + float distance = (isHostile ? 150 : 75); + float spawnVelocityRotation = (float)Math.PI / 2f / distance * Main.rand.NextFloatDirection(); + spawnPosition = targetEntity.Center + targetEntity.velocity * distance; + if (Vector2.Distance(spawnPosition, targetEntity.Center) < spawnDistance) + spawnPosition = (spawnPosition - targetEntity.Center).SafeNormalize(Vector2.UnitY) * spawnDistance; + + Vector2 vector = rotation.ToRotationVector2() * (isHostile ? 8 : 3); + for (int i = 0; (float)i < distance; i++) + { + spawnPosition -= vector; + vector = vector.RotatedBy(0f - spawnVelocityRotation); + } + + spawnVelocity = vector; + ai0 = 390f; + ai1 = spawnVelocityRotation; + } + } + + private static void ShootRubbleUp(NPC npc, ref Point sourceTileCoords, int howMany, int distancedByThisManyTiles, int whichOne, int rubble, int rubbleDamage) + { + // Loop to spawn rubble + // The rubble attempts are used to offset the Y coordinates of the rubble spawns to make sure they can spawn in non-solid tiles + int rubbleSpawnLocation = whichOne * distancedByThisManyTiles; + int maxRubbleSpawnAttempts = 35; + for (int rubbleSpawnAttempts = 0; rubbleSpawnAttempts < maxRubbleSpawnAttempts; rubbleSpawnAttempts++) + { + int posX = sourceTileCoords.X + rubbleSpawnLocation * npc.direction; + int posY = sourceTileCoords.Y + rubbleSpawnAttempts; + if (WorldGen.ActiveAndWalkableTile(posX, posY)) + { + SpawnRubble(npc, posX, posY, howMany, whichOne, rubble, rubbleDamage); + break; + } + } + } + + private static void SpawnRubble(NPC npc, int posX, int posY, int howMany, int whichOne, int rubble, int rubbleDamage) + { + Vector2 rubbleVelocity = new Vector2(0f, -1f).RotatedBy((float)(whichOne * npc.direction) * 0.7f * ((float)Math.PI / 4f / (float)howMany)); + int ai1_FrameToUse = Main.rand.Next(Main.projFrames[rubble] * 4); + ai1_FrameToUse = 6 + Main.rand.Next(6); + float ai2_DelayBeforeGoingUp = whichOne * 20f; + Projectile.NewProjectile(npc.GetSource_FromAI(), new Vector2(posX * 16 + 8, posY * 16 - 8), rubbleVelocity * 0.01f, rubble, rubbleDamage, 0f, Main.myPlayer, 0f, ai1_FrameToUse, ai2_DelayBeforeGoingUp); + } + + private static void MakeSpikesForward(NPC npc, int AISLOT_PhaseCounter, NPCAimedTarget targetData, int iceSpike, int iceSpikeDamage) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + return; + + int iceSpikeGateValue = 36; + if (!(npc.ai[AISLOT_PhaseCounter] < (float)iceSpikeGateValue)) + { + Point sourceTileCoords = npc.Bottom.ToTileCoordinates(); + int numIceSpikes = 20; + int xOffsetMult = 1; + sourceTileCoords.X += npc.direction * 3; + int screenShakeGateValue = (int)npc.ai[AISLOT_PhaseCounter] - iceSpikeGateValue; + if (screenShakeGateValue == 0) + { + PunchCameraModifier modifier = new PunchCameraModifier(npc.Center, new Vector2(0f, 1f), 20f, 6f, 30, 1000f, "Deerclops"); + Main.instance.CameraModifiers.Add(modifier); + } + + int iceSpikeStart = screenShakeGateValue / 4 * 4; + int iceSpikeLimit = iceSpikeStart + 4; + if (screenShakeGateValue % 4 != 0) + iceSpikeLimit = iceSpikeStart; + + for (int i = iceSpikeStart; i < iceSpikeLimit && i < numIceSpikes; i++) + { + int xOffset = i * xOffsetMult; + TryMakingSpike(npc, ref sourceTileCoords, npc.direction, numIceSpikes, i, xOffset, iceSpike, iceSpikeDamage); + } + } + } + + private static void MakeSpikesBothSides(NPC npc, int AISLOT_PhaseCounter, NPCAimedTarget targetData, int iceSpike, int iceSpikeDamage) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + return; + + int iceSpikeGateValue = 56; + if (!(npc.ai[AISLOT_PhaseCounter] < (float)iceSpikeGateValue)) + { + Point sourceTileCoords = npc.Bottom.ToTileCoordinates(); + int numIceSpikes = 15; + int xOffsetMult = 1; + int screenShakeGateValue = (int)npc.ai[AISLOT_PhaseCounter] - iceSpikeGateValue; + if (screenShakeGateValue == 0) + { + PunchCameraModifier modifier = new PunchCameraModifier(npc.Center, new Vector2(0f, 1f), 20f, 6f, 30, 1000f, "Deerclops"); + Main.instance.CameraModifiers.Add(modifier); + } + + int iceSpikeStart = screenShakeGateValue / 2 * 2; + int iceSpikeLimit = iceSpikeStart + 2; + if (screenShakeGateValue % 2 != 0) + iceSpikeLimit = iceSpikeStart; + + for (int iceSpikeIndex = iceSpikeStart; iceSpikeIndex >= 0 && iceSpikeIndex < iceSpikeLimit && iceSpikeIndex < numIceSpikes; iceSpikeIndex++) + { + int xOffset = iceSpikeIndex * xOffsetMult; + TryMakingSpike(npc, ref sourceTileCoords, npc.direction, numIceSpikes, -iceSpikeIndex, xOffset, iceSpike, iceSpikeDamage); + TryMakingSpike(npc, ref sourceTileCoords, -npc.direction, numIceSpikes, -iceSpikeIndex, xOffset, iceSpike, iceSpikeDamage); + } + } + } + + private static void TryMakingSpike(NPC npc, ref Point sourceTileCoords, int dir, int howMany, int whichOne, int xOffset, int iceSpike, int iceSpikeDamage) + { + int posX = sourceTileCoords.X + xOffset * dir; + int posY = FindBestY(npc, ref sourceTileCoords, posX); + if (WorldGen.ActiveAndWalkableTile(posX, posY)) + { + Vector2 iceSpikeSpawnPos = new Vector2(posX * 16 + 8, posY * 16 - 8); + Vector2 iceSpikeVelocity = new Vector2(0f, -1f).RotatedBy((float)(whichOne * dir) * 0.7f * ((float)Math.PI / 4f / (float)howMany)); + Projectile.NewProjectile(npc.GetSource_FromAI(), iceSpikeSpawnPos, iceSpikeVelocity, iceSpike, iceSpikeDamage, 0f, Main.myPlayer, 0f, 0.1f + Main.rand.NextFloat() * 0.1f + (float)xOffset * 1.1f / (float)howMany); + } + } + + private static int FindBestY(NPC npc, ref Point sourceTileCoords, int x) + { + int bestY = sourceTileCoords.Y; + NPCAimedTarget targetData = npc.GetTargetData(); + if (!targetData.Invalid) + { + Rectangle hitbox = targetData.Hitbox; + Vector2 vector = new Vector2(hitbox.Center.X, hitbox.Bottom); + int y = (int)(vector.Y / 16f); + int sign = Math.Sign(y - bestY); + int y2 = y + sign * 15; + int? potentialBestY = null; + float yLimit = float.PositiveInfinity; + for (int i = bestY; i != y2; i += sign) + { + if (WorldGen.ActiveAndWalkableTile(x, i)) + { + float newYLimit = new Point(x, i).ToWorldCoordinates().Distance(vector); + if (!potentialBestY.HasValue || !(newYLimit >= yLimit)) + { + potentialBestY = i; + yLimit = newYLimit; + } + } + } + + if (potentialBestY.HasValue) + bestY = potentialBestY.Value; + } + + for (int j = 0; j < 20; j++) + { + if (bestY < 10) + break; + + if (!WorldGen.SolidTile(x, bestY)) + break; + + bestY--; + } + + for (int k = 0; k < 20; k++) + { + if (bestY > Main.maxTilesY - 10) + break; + + if (WorldGen.ActiveAndWalkableTile(x, bestY)) + break; + + bestY++; + } + + return bestY; + } + + private static void Movement(NPC npc, float lifeRatio, bool haltMovement, bool goHome) + { + float moveSpeedMultiplier = 1f - lifeRatio; + float moveSpeed = 3.5f + 1f * moveSpeedMultiplier; + float moveSpeedDivisor = 4f; + float yVelocityIncrease = -0.4f; + float yVelocityMin = -8f; + float yVelocityIncrease2 = 0.4f; + Rectangle targetHitbox = npc.GetTargetData().Hitbox; + + if (goHome) + { + targetHitbox = new Rectangle(npc.homeTileX * 16, npc.homeTileY * 16, 16, 16); + if (npc.Distance(targetHitbox.Center.ToVector2()) < 240f) + targetHitbox.X = (int)(npc.Center.X + (float)(160 * npc.direction)); + } + + float distanceFromTargetX = (float)targetHitbox.Center.X - npc.Center.X; + float absoluteDistanceFromTargetX = Math.Abs(distanceFromTargetX); + if (goHome && distanceFromTargetX != 0f) + npc.direction = (npc.spriteDirection = Math.Sign(distanceFromTargetX)); + + bool closeToTarget = absoluteDistanceFromTargetX < 80f; + bool stopMoving = closeToTarget || haltMovement; + if (npc.ai[0] == -1f) + { + distanceFromTargetX = 5f; + moveSpeed = 5.35f; + stopMoving = false; + } + + if (stopMoving) + { + npc.velocity.X *= 0.9f; + if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + npc.velocity.X = 0f; + } + else + { + int moveDirection = Math.Sign(distanceFromTargetX); + npc.velocity.X = MathHelper.Lerp(npc.velocity.X, (float)moveDirection * moveSpeed, 1f / moveSpeedDivisor); + } + + int npcCenterXOffset = 40; + int npcCenterYOffset = 20; + int gfxOffsetY = 0; + Vector2 npcCenter = new Vector2(npc.Center.X - (float)(npcCenterXOffset / 2), npc.position.Y + (float)npc.height - (float)npcCenterYOffset + (float)gfxOffsetY); + bool moveDown = npcCenter.X < (float)targetHitbox.X && npcCenter.X + (float)npc.width > (float)(targetHitbox.X + targetHitbox.Width); + bool aboveTarget = npcCenter.Y + (float)npcCenterYOffset < (float)(targetHitbox.Y + targetHitbox.Height - 16); + bool acceptTopSurfaces = npc.Bottom.Y >= (float)targetHitbox.Top; + bool insideTiles = Collision.SolidCollision(npcCenter, npcCenterXOffset, npcCenterYOffset, acceptTopSurfaces); + bool insideTiles2 = Collision.SolidCollision(npcCenter, npcCenterXOffset, npcCenterYOffset - 4, acceptTopSurfaces); + bool moveUp = !Collision.SolidCollision(npcCenter + new Vector2(npcCenterXOffset * npc.direction, 0f), 16, 80, acceptTopSurfaces); + float yVelocity = -8f; + + if (insideTiles || insideTiles2) + npc.localAI[0] = 0f; + + if ((moveDown || closeToTarget) && aboveTarget) + { + npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y + yVelocityIncrease2 * 2f, 0.001f, 16f); + } + else if (insideTiles && !insideTiles2) + { + npc.velocity.Y = 0f; + } + else if (insideTiles) + { + npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y + yVelocityIncrease, yVelocityMin, 0f); + } + else if (npc.velocity.Y == 0f && moveUp) + { + npc.velocity.Y = yVelocity; + npc.localAI[0] = 1f; + } + else + npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y + yVelocityIncrease2, yVelocity, 16f); + } + } +} diff --git a/NPCs/VanillaNPCOverrides/Bosses/DestroyerAI.cs b/NPCs/VanillaNPCOverrides/Bosses/DestroyerAI.cs index 6e49fad655..abbaa9444e 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/DestroyerAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/DestroyerAI.cs @@ -203,7 +203,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses float velocity = bossRush ? 6f : death ? 5.333f : 5f; int type = ProjectileID.DeathLaser; int damage = npc.GetProjectileDamage(type); - Vector2 projectileVelocity = Vector2.Normalize(player.Center - npc.Center) * velocity; + Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity; int numProj = calamityGlobalNPC.newAI[0] % 60f == 0f ? 7 : 4; int spread = 54; float rotation = MathHelper.ToRadians(spread); @@ -267,22 +267,22 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses laserSpawnDistance = 20f; } - bool scrap = false; + bool weakLaser = false; if (probeLaunched) { - scrap = true; - projectileType = ProjectileID.SaucerScrap; + weakLaser = true; + projectileType = ProjectileID.EyeLaser; laserSpawnDistance = 0f; } // Get target vector - Vector2 projectileVelocity = Vector2.Normalize(player.Center - npc.Center) * projectileSpeed; + Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * projectileSpeed; Vector2 projectileSpawn = npc.Center + projectileVelocity * laserSpawnDistance; - // Shoot projectile and set timeLeft if not a homing laser/metal scrap so lasers don't last for too long - int damage = scrap ? 0 : npc.GetProjectileDamage(projectileType); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, damage, 0f, Main.myPlayer, scrap ? 0f : 1f, 0f); - Main.projectile[proj].timeLeft = scrap ? 150 : 900; + // Shoot projectile + int damage = npc.GetProjectileDamage(projectileType); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, damage, 0f, Main.myPlayer, weakLaser ? 0f : 1f, 0f); + Main.projectile[proj].timeLeft = weakLaser ? 600 : 900; npc.netUpdate = true; } @@ -290,36 +290,36 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } } - int num12 = (int)(npc.position.X / 16f) - 1; - int num13 = (int)((npc.position.X + npc.width) / 16f) + 2; - int num14 = (int)(npc.position.Y / 16f) - 1; - int num15 = (int)((npc.position.Y + npc.height) / 16f) + 2; + int tilePosX = (int)(npc.position.X / 16f) - 1; + int tileWidthPosX = (int)((npc.position.X + npc.width) / 16f) + 2; + int tilePosY = (int)(npc.position.Y / 16f) - 1; + int tileWidthPosY = (int)((npc.position.Y + npc.height) / 16f) + 2; - if (num12 < 0) - num12 = 0; - if (num13 > Main.maxTilesX) - num13 = Main.maxTilesX; - if (num14 < 0) - num14 = 0; - if (num15 > Main.maxTilesY) - num15 = Main.maxTilesY; + if (tilePosX < 0) + tilePosX = 0; + if (tileWidthPosX > Main.maxTilesX) + tileWidthPosX = Main.maxTilesX; + if (tilePosY < 0) + tilePosY = 0; + if (tileWidthPosY > Main.maxTilesY) + tileWidthPosY = Main.maxTilesY; // Fly or not - bool flag2 = flyAtTarget; - if (!flag2) + bool shouldFly = flyAtTarget; + if (!shouldFly) { - for (int k = num12; k < num13; k++) + for (int k = tilePosX; k < tileWidthPosX; k++) { - for (int l = num14; l < num15; l++) + for (int l = tilePosY; l < tileWidthPosY; l++) { if (Main.tile[k, l] != null && ((Main.tile[k, l].HasUnactuatedTile && (Main.tileSolid[Main.tile[k, l].TileType] || (Main.tileSolidTop[Main.tile[k, l].TileType] && Main.tile[k, l].TileFrameY == 0))) || Main.tile[k, l].LiquidAmount > 64)) { - Vector2 vector2; - vector2.X = k * 16; - vector2.Y = l * 16; - if (npc.position.X + npc.width > vector2.X && npc.position.X < vector2.X + 16f && npc.position.Y + npc.height > vector2.Y && npc.position.Y < vector2.Y + 16f) + Vector2 tileConvertedPosition; + tileConvertedPosition.X = k * 16; + tileConvertedPosition.Y = l * 16; + if (npc.position.X + npc.width > tileConvertedPosition.X && npc.position.X < tileConvertedPosition.X + 16f && npc.position.Y + npc.height > tileConvertedPosition.Y && npc.position.Y < tileConvertedPosition.Y + 16f) { - flag2 = true; + shouldFly = true; break; } } @@ -328,17 +328,17 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Start flying if target is not within a certain distance - if (!flag2) + if (!shouldFly) { npc.localAI[1] = 1f; if (npc.type == NPCID.TheDestroyer) { Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - int num16 = 1000; + int noFlyZone = 1000; int heightReduction = death ? 400 : (int)(400f * (1f - lifeRatio)); int height = 1800 - heightReduction; - bool flag3 = true; + bool outsideNoFlyZone = true; if (npc.position.Y > player.position.Y) { @@ -346,16 +346,16 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { if (Main.player[m].active) { - Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - num16, (int)Main.player[m].position.Y - num16, num16 * 2, height); - if (rectangle.Intersects(rectangle2)) + Rectangle noFlyRectangle = new Rectangle((int)Main.player[m].position.X - noFlyZone, (int)Main.player[m].position.Y - noFlyZone, noFlyZone * 2, height); + if (rectangle.Intersects(noFlyRectangle)) { - flag3 = false; + outsideNoFlyZone = false; break; } } } - if (flag3) - flag2 = true; + if (outsideNoFlyZone) + shouldFly = true; } } } @@ -366,7 +366,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses float fallSpeed = 16f; if (player.dead) { - flag2 = false; + shouldFly = false; npc.velocity.Y += 2f; if (npc.position.Y > Main.worldSurface * 16.0) @@ -412,25 +412,25 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses turnSpeed *= 1.2f; } - Vector2 vector3 = npc.Center; - float num20 = player.position.X + (player.width / 2); - float num21 = player.position.Y + (player.height / 2); - num20 = (int)(num20 / 16f) * 16; - num21 = (int)(num21 / 16f) * 16; - vector3.X = (int)(vector3.X / 16f) * 16; - vector3.Y = (int)(vector3.Y / 16f) * 16; - num20 -= vector3.X; - num21 -= vector3.Y; - float num22 = (float)Math.Sqrt(num20 * num20 + num21 * num21); + Vector2 npcCenter = npc.Center; + float targetTilePosX = player.position.X + (player.width / 2); + float targetTilePosY = player.position.Y + (player.height / 2); + targetTilePosX = (int)(targetTilePosX / 16f) * 16; + targetTilePosY = (int)(targetTilePosY / 16f) * 16; + npcCenter.X = (int)(npcCenter.X / 16f) * 16; + npcCenter.Y = (int)(npcCenter.Y / 16f) * 16; + targetTilePosX -= npcCenter.X; + targetTilePosY -= npcCenter.Y; + float targetTileDist = (float)Math.Sqrt(targetTilePosX * targetTilePosX + targetTilePosY * targetTilePosY); if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) { - int num23 = (int)(44f * npc.scale); + int mechdusaSegmentScale = (int)(44f * npc.scale); try { - vector3 = npc.Center; - num20 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector3.X; - num21 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector3.Y; + npcCenter = npc.Center; + targetTilePosX = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - npcCenter.X; + targetTilePosY = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - npcCenter.Y; } catch { @@ -438,31 +438,31 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (mechdusaCurvedSpineSegmentIndex > 0) { - float num25 = (float)num23 - (float)num23 * (((float)mechdusaCurvedSpineSegmentIndex - 1f) * 0.1f); - if (num25 < 0f) - num25 = 0f; + float absoluteTilePosX = (float)mechdusaSegmentScale - (float)mechdusaSegmentScale * (((float)mechdusaCurvedSpineSegmentIndex - 1f) * 0.1f); + if (absoluteTilePosX < 0f) + absoluteTilePosX = 0f; - if (num25 > (float)num23) - num25 = num23; + if (absoluteTilePosX > (float)mechdusaSegmentScale) + absoluteTilePosX = mechdusaSegmentScale; - num21 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) + num25 - vector3.Y; + targetTilePosY = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) + absoluteTilePosX - npcCenter.Y; } - npc.rotation = (float)Math.Atan2(num21, num20) + MathHelper.PiOver2; - num22 = (float)Math.Sqrt(num20 * num20 + num21 * num21); + npc.rotation = (float)Math.Atan2(targetTilePosY, targetTilePosX) + MathHelper.PiOver2; + targetTileDist = (float)Math.Sqrt(targetTilePosX * targetTilePosX + targetTilePosY * targetTilePosY); if (mechdusaCurvedSpineSegmentIndex > 0) - num23 = num23 / mechdusaCurvedSpineSegments * mechdusaCurvedSpineSegmentIndex; + mechdusaSegmentScale = mechdusaSegmentScale / mechdusaCurvedSpineSegments * mechdusaCurvedSpineSegmentIndex; - num22 = (num22 - num23) / num22; - num20 *= num22; - num21 *= num22; + targetTileDist = (targetTileDist - mechdusaSegmentScale) / targetTileDist; + targetTilePosX *= targetTileDist; + targetTilePosY *= targetTileDist; npc.velocity = Vector2.Zero; - npc.position.X += num20; - npc.position.Y += num21; + npc.position.X += targetTilePosX; + npc.position.Y += targetTilePosY; } else { - if (!flag2) + if (!shouldFly) { npc.velocity.Y += 0.15f; if (npc.velocity.Y > fallSpeed) @@ -477,9 +477,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } else if (npc.velocity.Y == fallSpeed) { - if (npc.velocity.X < num20) + if (npc.velocity.X < targetTilePosX) npc.velocity.X += speed; - else if (npc.velocity.X > num20) + else if (npc.velocity.X > targetTilePosX) npc.velocity.X -= speed; } else if (npc.velocity.Y > 4f) @@ -494,29 +494,29 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { if (npc.soundDelay == 0) { - float num24 = num22 / 40f; - if (num24 < 10f) - num24 = 10f; - if (num24 > 20f) - num24 = 20f; + float soundDelay = targetTileDist / 40f; + if (soundDelay < 10f) + soundDelay = 10f; + if (soundDelay > 20f) + soundDelay = 20f; - npc.soundDelay = (int)num24; + npc.soundDelay = (int)soundDelay; SoundEngine.PlaySound(SoundID.WormDig, npc.position); } - num22 = (float)Math.Sqrt(num20 * num20 + num21 * num21); - float num25 = Math.Abs(num20); - float num26 = Math.Abs(num21); - float num27 = fallSpeed / num22; - num20 *= num27; - num21 *= num27; + targetTileDist = (float)Math.Sqrt(targetTilePosX * targetTilePosX + targetTilePosY * targetTilePosY); + float absoluteTilePosX = Math.Abs(targetTilePosX); + float absoluteTilePosY = Math.Abs(targetTilePosY); + float tileToReachTarget = fallSpeed / targetTileDist; + targetTilePosX *= tileToReachTarget; + targetTilePosY *= tileToReachTarget; - bool flag6 = false; + bool flyWyvernMovement = false; if (flyAtTarget) { - if (((npc.velocity.X > 0f && num20 < 0f) || (npc.velocity.X < 0f && num20 > 0f) || (npc.velocity.Y > 0f && num21 < 0f) || (npc.velocity.Y < 0f && num21 > 0f)) && Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) > speed / 2f && num22 < 400f) + if (((npc.velocity.X > 0f && targetTilePosX < 0f) || (npc.velocity.X < 0f && targetTilePosX > 0f) || (npc.velocity.Y > 0f && targetTilePosY < 0f) || (npc.velocity.Y < 0f && targetTilePosY > 0f)) && Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) > speed / 2f && targetTileDist < 400f) { - flag6 = true; + flyWyvernMovement = true; if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < fallSpeed) npc.velocity *= 1.1f; @@ -524,7 +524,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.position.Y > player.position.Y) { - flag6 = true; + flyWyvernMovement = true; if (Math.Abs(npc.velocity.X) < fallSpeed / 2f) { @@ -538,42 +538,42 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } } - if (!flag6) + if (!flyWyvernMovement) { if (!flyAtTarget) { - if (((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f)) && ((npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f))) + if (((npc.velocity.X > 0f && targetTilePosX > 0f) || (npc.velocity.X < 0f && targetTilePosX < 0f)) && ((npc.velocity.Y > 0f && targetTilePosY > 0f) || (npc.velocity.Y < 0f && targetTilePosY < 0f))) { - if (npc.velocity.X < num20) + if (npc.velocity.X < targetTilePosX) npc.velocity.X += turnSpeed; - else if (npc.velocity.X > num20) + else if (npc.velocity.X > targetTilePosX) npc.velocity.X -= turnSpeed; - if (npc.velocity.Y < num21) + if (npc.velocity.Y < targetTilePosY) npc.velocity.Y += turnSpeed; - else if (npc.velocity.Y > num21) + else if (npc.velocity.Y > targetTilePosY) npc.velocity.Y -= turnSpeed; } } - if ((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f) || (npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f)) + if ((npc.velocity.X > 0f && targetTilePosX > 0f) || (npc.velocity.X < 0f && targetTilePosX < 0f) || (npc.velocity.Y > 0f && targetTilePosY > 0f) || (npc.velocity.Y < 0f && targetTilePosY < 0f)) { - if (npc.velocity.X < num20) + if (npc.velocity.X < targetTilePosX) npc.velocity.X += speed; - else if (npc.velocity.X > num20) + else if (npc.velocity.X > targetTilePosX) npc.velocity.X -= speed; - if (npc.velocity.Y < num21) + if (npc.velocity.Y < targetTilePosY) npc.velocity.Y += speed; - else if (npc.velocity.Y > num21) + else if (npc.velocity.Y > targetTilePosY) npc.velocity.Y -= speed; - if (Math.Abs(num21) < fallSpeed * 0.2 && ((npc.velocity.X > 0f && num20 < 0f) || (npc.velocity.X < 0f && num20 > 0f))) + if (Math.Abs(targetTilePosY) < fallSpeed * 0.2 && ((npc.velocity.X > 0f && targetTilePosX < 0f) || (npc.velocity.X < 0f && targetTilePosX > 0f))) { if (npc.velocity.Y > 0f) npc.velocity.Y += speed * 2f; else npc.velocity.Y -= speed * 2f; } - if (Math.Abs(num20) < fallSpeed * 0.2 && ((npc.velocity.Y > 0f && num21 < 0f) || (npc.velocity.Y < 0f && num21 > 0f))) + if (Math.Abs(targetTilePosX) < fallSpeed * 0.2 && ((npc.velocity.Y > 0f && targetTilePosY < 0f) || (npc.velocity.Y < 0f && targetTilePosY > 0f))) { if (npc.velocity.X > 0f) npc.velocity.X += speed * 2f; @@ -581,11 +581,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.velocity.X -= speed * 2f; } } - else if (num25 > num26) + else if (absoluteTilePosX > absoluteTilePosY) { - if (npc.velocity.X < num20) + if (npc.velocity.X < targetTilePosX) npc.velocity.X += speed * 1.1f; - else if (npc.velocity.X > num20) + else if (npc.velocity.X > targetTilePosX) npc.velocity.X -= speed * 1.1f; if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.5) @@ -598,9 +598,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } else { - if (npc.velocity.Y < num21) + if (npc.velocity.Y < targetTilePosY) npc.velocity.Y += speed * 1.1f; - else if (npc.velocity.Y > num21) + else if (npc.velocity.Y > targetTilePosY) npc.velocity.Y -= speed * 1.1f; if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.5) @@ -618,7 +618,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.type == NPCID.TheDestroyer) { - if (flag2) + if (shouldFly) { if (npc.localAI[0] != 1f) npc.netUpdate = true; @@ -642,14 +642,14 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { NPC nPC = Main.npc[NPC.mechQueen]; Vector2 mechQueenCenter = nPC.GetMechQueenCenter(); - Vector2 vector4 = new Vector2(0f, 100f); - Vector2 spinningpoint = mechQueenCenter + vector4; - float num30 = nPC.velocity.X * 0.025f; - spinningpoint = spinningpoint.RotatedBy(num30, mechQueenCenter); + Vector2 mechdusaSpinningVector = new Vector2(0f, 100f); + Vector2 spinningpoint = mechQueenCenter + mechdusaSpinningVector; + float mechdusaRotation = nPC.velocity.X * 0.025f; + spinningpoint = spinningpoint.RotatedBy(mechdusaRotation, mechQueenCenter); npc.position = spinningpoint - npc.Size / 2f + nPC.velocity; npc.velocity.X = 0f; npc.velocity.Y = 0f; - npc.rotation = num30 * 0.75f + (float)Math.PI; + npc.rotation = mechdusaRotation * 0.75f + (float)Math.PI; } return false; @@ -671,16 +671,16 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses float velocity = bossRush ? 8f : 6f; float acceleration = bossRush ? 0.1f : 0.05f; - Vector2 vector = npc.Center; - float num4 = targetData.Center.X; - float num5 = targetData.Center.Y; - num4 = (int)(num4 / 8f) * 8; - num5 = (int)(num5 / 8f) * 8; - vector.X = (int)(vector.X / 8f) * 8; - vector.Y = (int)(vector.Y / 8f) * 8; - num4 -= vector.X; - num5 -= vector.Y; - float distanceFromTarget = (float)Math.Sqrt(num4 * num4 + num5 * num5); + Vector2 probeCenter = npc.Center; + float probeTargetX = targetData.Center.X; + float probeTargetY = targetData.Center.Y; + probeTargetX = (int)(probeTargetX / 8f) * 8; + probeTargetY = (int)(probeTargetY / 8f) * 8; + probeCenter.X = (int)(probeCenter.X / 8f) * 8; + probeCenter.Y = (int)(probeCenter.Y / 8f) * 8; + probeTargetX -= probeCenter.X; + probeTargetY -= probeCenter.Y; + float distanceFromTarget = (float)Math.Sqrt(probeTargetX * probeTargetX + probeTargetY * probeTargetY); float distance2 = distanceFromTarget; bool farAwayFromTarget = false; @@ -689,27 +689,27 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (distanceFromTarget == 0f) { - num4 = npc.velocity.X; - num5 = npc.velocity.Y; + probeTargetX = npc.velocity.X; + probeTargetY = npc.velocity.Y; } else { distanceFromTarget = velocity / distanceFromTarget; - num4 *= distanceFromTarget; - num5 *= distanceFromTarget; + probeTargetX *= distanceFromTarget; + probeTargetY *= distanceFromTarget; } for (int i = 0; i < Main.maxNPCs; i++) { if (i != npc.whoAmI && Main.npc[i].active && Main.npc[i].type == npc.type) { - Vector2 value42 = Main.npc[i].Center - npc.Center; - if (value42.Length() < (npc.width + npc.height)) + Vector2 otherProbeDist = Main.npc[i].Center - npc.Center; + if (otherProbeDist.Length() < (npc.width + npc.height)) { - value42.Normalize(); - value42 *= -0.1f; - npc.velocity += value42; - Main.npc[i].velocity -= value42; + otherProbeDist = otherProbeDist.SafeNormalize(Vector2.UnitY); + otherProbeDist *= -0.1f; + npc.velocity += otherProbeDist; + Main.npc[i].velocity -= otherProbeDist; } } } @@ -733,8 +733,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (targetDead) { - num4 = npc.direction * velocity / 2f; - num5 = -velocity / 2f; + probeTargetX = npc.direction * velocity / 2f; + probeTargetY = -velocity / 2f; } if (npc.ai[3] != 0f) @@ -742,18 +742,18 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (NPC.IsMechQueenUp) { NPC nPC = Main.npc[NPC.mechQueen]; - Vector2 vector2 = new Vector2(26f * npc.ai[3], 0f); - int num9 = (int)npc.ai[2]; - if (num9 < 0 || num9 >= Main.maxNPCs) + Vector2 tileConvertedPosition = new Vector2(26f * npc.ai[3], 0f); + int mechdusaProbe = (int)npc.ai[2]; + if (mechdusaProbe < 0 || mechdusaProbe >= Main.maxNPCs) { - num9 = NPC.FindFirstNPC(NPCID.TheDestroyer); - npc.ai[2] = num9; + mechdusaProbe = NPC.FindFirstNPC(NPCID.TheDestroyer); + npc.ai[2] = mechdusaProbe; npc.netUpdate = true; } - if (num9 > -1) + if (mechdusaProbe > -1) { - NPC nPC2 = Main.npc[num9]; + NPC nPC2 = Main.npc[mechdusaProbe]; if (!nPC2.active || nPC2.type != NPCID.TheDestroyer) { npc.dontTakeDamage = false; @@ -764,7 +764,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } else { - Vector2 spinningpoint = nPC2.Center + vector2; + Vector2 spinningpoint = nPC2.Center + tileConvertedPosition; spinningpoint = spinningpoint.RotatedBy(nPC2.rotation, nPC2.Center); npc.Center = spinningpoint; npc.velocity = nPC.velocity; @@ -793,14 +793,14 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { npc.dontTakeDamage = false; - if (npc.velocity.X < num4) + if (npc.velocity.X < probeTargetX) npc.velocity.X += acceleration; - else if (npc.velocity.X > num4) + else if (npc.velocity.X > probeTargetX) npc.velocity.X -= acceleration; - if (npc.velocity.Y < num5) + if (npc.velocity.Y < probeTargetY) npc.velocity.Y += acceleration; - else if (npc.velocity.Y > num5) + else if (npc.velocity.Y > probeTargetY) npc.velocity.Y -= acceleration; } @@ -817,12 +817,12 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses int type = ProjectileID.PinkLaser; int damage = npc.GetProjectileDamage(type); int totalProjectiles = (CalamityWorld.death || bossRush) ? 3 : 1; - Vector2 vector3 = new Vector2(num4, num5); + Vector2 npcCenter = new Vector2(probeTargetX, probeTargetY); if (NPC.IsMechQueenUp) { Vector2 v = targetData.Center - npc.Center - targetData.Velocity * 20f; float projectileVelocity = 8f; - vector3 = v.SafeNormalize(Vector2.UnitY) * projectileVelocity; + npcCenter = v.SafeNormalize(Vector2.UnitY) * projectileVelocity; } for (int i = 0; i < totalProjectiles; i++) { @@ -838,29 +838,29 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses velocityMultiplier = 0.8f; break; } - Projectile.NewProjectile(npc.GetSource_FromAI(), vector, vector3 * velocityMultiplier, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(npc.GetSource_FromAI(), probeCenter, npcCenter * velocityMultiplier, type, damage, 0f, Main.myPlayer); } npc.netUpdate = true; } } - if (num4 > 0f) + if (probeTargetX > 0f) { npc.spriteDirection = 1; - npc.rotation = (float)Math.Atan2(num5, num4); + npc.rotation = (float)Math.Atan2(probeTargetY, probeTargetX); } - if (num4 < 0f) + if (probeTargetX < 0f) { npc.spriteDirection = -1; - npc.rotation = (float)Math.Atan2(num5, num4) + MathHelper.Pi; + npc.rotation = (float)Math.Atan2(probeTargetY, probeTargetX) + MathHelper.Pi; } - float num12 = -0.7f; + float tilePosX = -0.7f; if (npc.collideX) { npc.netUpdate = true; - npc.velocity.X = npc.oldVelocity.X * num12; + npc.velocity.X = npc.oldVelocity.X * tilePosX; if (npc.direction == -1 && npc.velocity.X > 0f && npc.velocity.X < 2f) npc.velocity.X = 2f; if (npc.direction == 1 && npc.velocity.X < 0f && npc.velocity.X > -2f) @@ -870,7 +870,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.collideY) { npc.netUpdate = true; - npc.velocity.Y = npc.oldVelocity.Y * num12; + npc.velocity.Y = npc.oldVelocity.Y * tilePosX; if (npc.velocity.Y > 0f && npc.velocity.Y < 1.5) npc.velocity.Y = 2f; if (npc.velocity.Y < 0f && npc.velocity.Y > -1.5) @@ -879,7 +879,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (farAwayFromTarget) { - if ((npc.velocity.X > 0f && num4 > 0f) || (npc.velocity.X < 0f && num4 < 0f)) + if ((npc.velocity.X > 0f && probeTargetX > 0f) || (npc.velocity.X < 0f && probeTargetX < 0f)) { if (Math.Abs(npc.velocity.X) < (NPC.IsMechQueenUp ? 5f : 12f)) npc.velocity.X *= 1.05f; @@ -892,9 +892,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { Vector2 center = npc.GetTargetData().Center; Vector2 v2 = center - npc.Center; - int num28 = 120; - if (v2.Length() < (float)num28) - npc.Center = center - v2.SafeNormalize(Vector2.UnitY) * num28; + if (v2.Length() < 120f) + npc.Center = center - v2.SafeNormalize(Vector2.UnitY) * 120; } if (targetDead) diff --git a/NPCs/VanillaNPCOverrides/Bosses/DreadnautilusAI.cs b/NPCs/VanillaNPCOverrides/Bosses/DreadnautilusAI.cs index 902e3d8937..e7b1f039f3 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/DreadnautilusAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/DreadnautilusAI.cs @@ -79,25 +79,25 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses case -1: { npc.velocity *= 0.98f; - int num15 = Math.Sign(nPCAimedTarget.Center.X - npc.Center.X); - if (num15 != 0) + int spawnFaceDirection = Math.Sign(nPCAimedTarget.Center.X - npc.Center.X); + if (spawnFaceDirection != 0) { - npc.direction = num15; + npc.direction = spawnFaceDirection; npc.spriteDirection = -npc.direction; } if (npc.localAI[1] == 0f && npc.alpha < 100) { npc.localAI[1] = 1f; - int num16 = 36; - for (int l = 0; l < num16; l++) + int dustAmt = 36; + for (int l = 0; l < dustAmt; l++) { npc.position += npc.netOffset; - Vector2 value3 = (Vector2.Normalize(npc.velocity) * new Vector2(npc.width / 2f, npc.height) * 0.75f * 0.5f).RotatedBy((l - (num16 / 2 - 1)) * ((float)Math.PI * 2f) / num16) + npc.Center; - Vector2 value4 = value3 - npc.Center; - int num17 = Dust.NewDust(value3 + value4, 0, 0, 5, value4.X * 2f, value4.Y * 2f, 100, default, 1.4f); - Main.dust[num17].noGravity = true; - Main.dust[num17].velocity = Vector2.Normalize(value4) * 3f; + Vector2 dustRotation = (Vector2.Normalize(npc.velocity) * new Vector2(npc.width / 2f, npc.height) * 0.75f * 0.5f).RotatedBy((l - (dustAmt / 2 - 1)) * ((float)Math.PI * 2f) / dustAmt) + npc.Center; + Vector2 dustVelocity = dustRotation - npc.Center; + int spawnDustBlood = Dust.NewDust(dustRotation + dustVelocity, 0, 0, 5, dustVelocity.X * 2f, dustVelocity.Y * 2f, 100, default, 1.4f); + Main.dust[spawnDustBlood].noGravity = true; + Main.dust[spawnDustBlood].velocity = Vector2.Normalize(dustVelocity) * 3f; npc.position -= npc.netOffset; } } @@ -141,27 +141,27 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } npc.direction = (npc.Center.X < nPCAimedTarget.Center.X) ? 1 : (-1); - float num13 = npc.Center.DirectionTo(nPCAimedTarget.Center).ToRotation() - 213f / 452f * npc.spriteDirection; + float faceTargetDirection = npc.Center.DirectionTo(nPCAimedTarget.Center).ToRotation() - 213f / 452f * npc.spriteDirection; if (npc.spriteDirection == -1) - num13 += (float)Math.PI; + faceTargetDirection += (float)Math.PI; if (npc.spriteDirection != npc.direction) { npc.spriteDirection = npc.direction; npc.rotation = 0f - npc.rotation; - num13 = 0f - num13; + faceTargetDirection = 0f - faceTargetDirection; } - npc.rotation = npc.rotation.AngleTowards(num13, 0.02f); + npc.rotation = npc.rotation.AngleTowards(faceTargetDirection, 0.02f); npc.ai[1] += 1f; if (npc.ai[1] > phaseSwitchPhaseTime) { - int num14 = (int)npc.ai[3]; - if (num14 % 7 == 3 && NPC.CountNPCS(NPCID.BloodSquid) < maxBloodSquids) + int attackPicker = (int)npc.ai[3]; + if (attackPicker % 7 == 3 && NPC.CountNPCS(NPCID.BloodSquid) < maxBloodSquids) { attackType = 3; } - else if (num14 % 2 == 0) + else if (attackPicker % 2 == 0) { SoundEngine.PlaySound(SoundID.Item170, npc.Center); attackType = 2; @@ -180,16 +180,16 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses case 1: { npc.direction = (!(npc.Center.X < nPCAimedTarget.Center.X)) ? 1 : (-1); - float num18 = npc.Center.DirectionFrom(nPCAimedTarget.Center).ToRotation() - 213f / 452f * npc.spriteDirection; + float chargeFaceDirection = npc.Center.DirectionFrom(nPCAimedTarget.Center).ToRotation() - 213f / 452f * npc.spriteDirection; if (npc.spriteDirection == -1) - num18 += (float)Math.PI; + chargeFaceDirection += (float)Math.PI; - bool flag2 = npc.ai[1] < dashChargeUpPhaseTime; - if (npc.spriteDirection != npc.direction && flag2) + bool shouldStartCharge = npc.ai[1] < dashChargeUpPhaseTime; + if (npc.spriteDirection != npc.direction && shouldStartCharge) { npc.spriteDirection = npc.direction; npc.rotation = 0f - npc.rotation; - num18 = 0f - num18; + chargeFaceDirection = 0f - chargeFaceDirection; } if (npc.ai[1] < dashChargeUpPhaseTime) @@ -198,23 +198,23 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses SoundEngine.PlaySound(SoundID.Item172, npc.Center); npc.velocity *= 0.95f; - npc.rotation = npc.rotation.AngleLerp(num18, 0.02f); + npc.rotation = npc.rotation.AngleLerp(chargeFaceDirection, 0.02f); npc.position += npc.netOffset; npc.BloodNautilus_GetMouthPositionAndRotation(out Vector2 mouthPosition4, out Vector2 mouthDirection4); - Dust dust6 = Dust.NewDustDirect(mouthPosition4 + mouthDirection4 * 60f - new Vector2(40f), 80, 80, 16, 0f, 0f, 150, Color.Transparent, 0.6f); - dust6.fadeIn = 1f; - dust6.velocity = dust6.position.DirectionTo(mouthPosition4 + Main.rand.NextVector2Circular(15f, 15f)) * dust6.velocity.Length(); - dust6.noGravity = true; - dust6 = Dust.NewDustDirect(mouthPosition4 + mouthDirection4 * 100f - new Vector2(30f), 60, 60, 16, 0f, 0f, 100, Color.Transparent, 0.9f); - dust6.fadeIn = 1.5f; - dust6.velocity = dust6.position.DirectionTo(mouthPosition4 + Main.rand.NextVector2Circular(15f, 15f)) * (dust6.velocity.Length() + 5f); - dust6.noGravity = true; + Dust chargeUpDust = Dust.NewDustDirect(mouthPosition4 + mouthDirection4 * 60f - new Vector2(40f), 80, 80, 16, 0f, 0f, 150, Color.Transparent, 0.6f); + chargeUpDust.fadeIn = 1f; + chargeUpDust.velocity = chargeUpDust.position.DirectionTo(mouthPosition4 + Main.rand.NextVector2Circular(15f, 15f)) * chargeUpDust.velocity.Length(); + chargeUpDust.noGravity = true; + chargeUpDust = Dust.NewDustDirect(mouthPosition4 + mouthDirection4 * 100f - new Vector2(30f), 60, 60, 16, 0f, 0f, 100, Color.Transparent, 0.9f); + chargeUpDust.fadeIn = 1.5f; + chargeUpDust.velocity = chargeUpDust.position.DirectionTo(mouthPosition4 + Main.rand.NextVector2Circular(15f, 15f)) * (chargeUpDust.velocity.Length() + 5f); + chargeUpDust.noGravity = true; npc.position -= npc.netOffset; } else if (npc.ai[1] < dashChargeUpPhaseTime + dashPhaseTime) { npc.position += npc.netOffset; - npc.rotation = npc.rotation.AngleLerp(num18, 0.07f); + npc.rotation = npc.rotation.AngleLerp(chargeFaceDirection, 0.07f); npc.BloodNautilus_GetMouthPositionAndRotation(out Vector2 mouthPosition5, out Vector2 mouthDirection5); // Dash directly towards the target until within 15 tiles of the target, and then continue in the same direction for 18 frames (15 frames in Death Mode) @@ -228,12 +228,12 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses for (int m = 0; m < 4; m++) { - Dust dust7 = Dust.NewDustDirect(mouthPosition5 + mouthDirection5 * 60f - new Vector2(15f), 30, 30, 5, 0f, 0f, 0, Color.Transparent, 1.5f); - dust7.velocity = dust7.position.DirectionFrom(mouthPosition5 + Main.rand.NextVector2Circular(5f, 5f)) * dust7.velocity.Length(); - dust7.position -= mouthDirection5 * 60f; - dust7 = Dust.NewDustDirect(mouthPosition5 + mouthDirection5 * 100f - new Vector2(20f), 40, 40, 5, 0f, 0f, 100, Color.Transparent, 1.5f); - dust7.velocity = dust7.position.DirectionFrom(mouthPosition5 + Main.rand.NextVector2Circular(10f, 10f)) * (dust7.velocity.Length() + 5f); - dust7.position -= mouthDirection5 * 100f; + Dust chargeBloodDust = Dust.NewDustDirect(mouthPosition5 + mouthDirection5 * 60f - new Vector2(15f), 30, 30, 5, 0f, 0f, 0, Color.Transparent, 1.5f); + chargeBloodDust.velocity = chargeBloodDust.position.DirectionFrom(mouthPosition5 + Main.rand.NextVector2Circular(5f, 5f)) * chargeBloodDust.velocity.Length(); + chargeBloodDust.position -= mouthDirection5 * 60f; + chargeBloodDust = Dust.NewDustDirect(mouthPosition5 + mouthDirection5 * 100f - new Vector2(20f), 40, 40, 5, 0f, 0f, 100, Color.Transparent, 1.5f); + chargeBloodDust.velocity = chargeBloodDust.position.DirectionFrom(mouthPosition5 + Main.rand.NextVector2Circular(10f, 10f)) * (chargeBloodDust.velocity.Length() + 5f); + chargeBloodDust.position -= mouthDirection5 * 100f; } npc.position -= npc.netOffset; @@ -250,18 +250,18 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses case 2: { npc.direction = (npc.Center.X < nPCAimedTarget.Center.X) ? 1 : (-1); - float num10 = npc.Center.DirectionTo(nPCAimedTarget.Center).ToRotation() - 213f / 452f * npc.spriteDirection; + float bloodProjFaceDirection = npc.Center.DirectionTo(nPCAimedTarget.Center).ToRotation() - 213f / 452f * npc.spriteDirection; if (npc.spriteDirection == -1) - num10 += (float)Math.PI; + bloodProjFaceDirection += (float)Math.PI; if (npc.spriteDirection != npc.direction) { npc.spriteDirection = npc.direction; npc.rotation = 0f - npc.rotation; - num10 = 0f - num10; + bloodProjFaceDirection = 0f - bloodProjFaceDirection; } - npc.rotation = npc.rotation.AngleLerp(num10, 0.2f); + npc.rotation = npc.rotation.AngleLerp(bloodProjFaceDirection, 0.2f); if (npc.ai[1] < bloodSpitChargeUpPhaseTime) { npc.position += npc.netOffset; @@ -269,14 +269,14 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.BloodNautilus_GetMouthPositionAndRotation(out Vector2 mouthPosition2, out Vector2 mouthDirection2); if (Main.rand.Next(4) != 0) { - Dust dust3 = Dust.NewDustDirect(mouthPosition2 + mouthDirection2 * 60f - new Vector2(60f), 120, 120, 16, 0f, 0f, 150, Color.Transparent, 0.6f); - dust3.fadeIn = 1f; - dust3.velocity = dust3.position.DirectionTo(mouthPosition2 + Main.rand.NextVector2Circular(15f, 15f)) * (dust3.velocity.Length() + 3f); - dust3.noGravity = true; - dust3 = Dust.NewDustDirect(mouthPosition2 + mouthDirection2 * 100f - new Vector2(80f), 160, 160, 16, 0f, 0f, 100, Color.Transparent, 0.9f); - dust3.fadeIn = 1.5f; - dust3.velocity = dust3.position.DirectionTo(mouthPosition2 + Main.rand.NextVector2Circular(15f, 15f)) * (dust3.velocity.Length() + 5f); - dust3.noGravity = true; + Dust bloodProjChargeUpDust = Dust.NewDustDirect(mouthPosition2 + mouthDirection2 * 60f - new Vector2(60f), 120, 120, 16, 0f, 0f, 150, Color.Transparent, 0.6f); + bloodProjChargeUpDust.fadeIn = 1f; + bloodProjChargeUpDust.velocity = bloodProjChargeUpDust.position.DirectionTo(mouthPosition2 + Main.rand.NextVector2Circular(15f, 15f)) * (bloodProjChargeUpDust.velocity.Length() + 3f); + bloodProjChargeUpDust.noGravity = true; + bloodProjChargeUpDust = Dust.NewDustDirect(mouthPosition2 + mouthDirection2 * 100f - new Vector2(80f), 160, 160, 16, 0f, 0f, 100, Color.Transparent, 0.9f); + bloodProjChargeUpDust.fadeIn = 1.5f; + bloodProjChargeUpDust.velocity = bloodProjChargeUpDust.position.DirectionTo(mouthPosition2 + Main.rand.NextVector2Circular(15f, 15f)) * (bloodProjChargeUpDust.velocity.Length() + 5f); + bloodProjChargeUpDust.noGravity = true; } npc.position -= npc.netOffset; @@ -285,23 +285,23 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { npc.position += npc.netOffset; npc.velocity *= 0.9f; - float num11 = (npc.ai[1] - bloodSpitChargeUpPhaseTime) % (bloodSpitPhaseTime / numBloodSpitVolleys); + float bloodProjShootTimer = (npc.ai[1] - bloodSpitChargeUpPhaseTime) % (bloodSpitPhaseTime / numBloodSpitVolleys); npc.BloodNautilus_GetMouthPositionAndRotation(out Vector2 mouthPosition3, out Vector2 mouthDirection3); - if (num11 < bloodSpitPhaseTime / numBloodSpitVolleys * 0.8f) + if (bloodProjShootTimer < bloodSpitPhaseTime / numBloodSpitVolleys * 0.8f) { for (int i = 0; i < 5; i++) { - Dust dust4 = Dust.NewDustDirect(mouthPosition3 + mouthDirection3 * 50f - new Vector2(15f), 30, 30, 5, 0f, 0f, 0, Color.Transparent, 1.5f); - dust4.velocity = dust4.position.DirectionFrom(mouthPosition3 + Main.rand.NextVector2Circular(5f, 5f)) * dust4.velocity.Length(); - dust4.position -= mouthDirection3 * 60f; - dust4 = Dust.NewDustDirect(mouthPosition3 + mouthDirection3 * 90f - new Vector2(20f), 40, 40, 5, 0f, 0f, 100, Color.Transparent, 1.5f); - dust4.velocity = dust4.position.DirectionFrom(mouthPosition3 + Main.rand.NextVector2Circular(10f, 10f)) * (dust4.velocity.Length() + 5f); - dust4.position -= mouthDirection3 * 100f; + Dust bloodProjShootDust = Dust.NewDustDirect(mouthPosition3 + mouthDirection3 * 50f - new Vector2(15f), 30, 30, 5, 0f, 0f, 0, Color.Transparent, 1.5f); + bloodProjShootDust.velocity = bloodProjShootDust.position.DirectionFrom(mouthPosition3 + Main.rand.NextVector2Circular(5f, 5f)) * bloodProjShootDust.velocity.Length(); + bloodProjShootDust.position -= mouthDirection3 * 60f; + bloodProjShootDust = Dust.NewDustDirect(mouthPosition3 + mouthDirection3 * 90f - new Vector2(20f), 40, 40, 5, 0f, 0f, 100, Color.Transparent, 1.5f); + bloodProjShootDust.velocity = bloodProjShootDust.position.DirectionFrom(mouthPosition3 + Main.rand.NextVector2Circular(10f, 10f)) * (bloodProjShootDust.velocity.Length() + 5f); + bloodProjShootDust.position -= mouthDirection3 * 100f; } } // Spit blood spread - if ((int)num11 == 0) + if ((int)bloodProjShootTimer == 0) { // Recoil away with each spit npc.velocity += mouthDirection3 * -8f; @@ -309,12 +309,12 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Spawn dust with each spit for (int j = 0; j < 20; j++) { - Dust dust5 = Dust.NewDustDirect(mouthPosition3 + mouthDirection3 * 60f - new Vector2(15f), 30, 30, 5, 0f, 0f, 0, Color.Transparent, 1.5f); - dust5.velocity = dust5.position.DirectionFrom(mouthPosition3 + Main.rand.NextVector2Circular(5f, 5f)) * dust5.velocity.Length(); - dust5.position -= mouthDirection3 * 60f; - dust5 = Dust.NewDustDirect(mouthPosition3 + mouthDirection3 * 100f - new Vector2(20f), 40, 40, 5, 0f, 0f, 100, Color.Transparent, 1.5f); - dust5.velocity = dust5.position.DirectionFrom(mouthPosition3 + Main.rand.NextVector2Circular(10f, 10f)) * (dust5.velocity.Length() + 5f); - dust5.position -= mouthDirection3 * 100f; + Dust bloodProjShootDust2 = Dust.NewDustDirect(mouthPosition3 + mouthDirection3 * 60f - new Vector2(15f), 30, 30, 5, 0f, 0f, 0, Color.Transparent, 1.5f); + bloodProjShootDust2.velocity = bloodProjShootDust2.position.DirectionFrom(mouthPosition3 + Main.rand.NextVector2Circular(5f, 5f)) * bloodProjShootDust2.velocity.Length(); + bloodProjShootDust2.position -= mouthDirection3 * 60f; + bloodProjShootDust2 = Dust.NewDustDirect(mouthPosition3 + mouthDirection3 * 100f - new Vector2(20f), 40, 40, 5, 0f, 0f, 100, Color.Transparent, 1.5f); + bloodProjShootDust2.velocity = bloodProjShootDust2.position.DirectionFrom(mouthPosition3 + Main.rand.NextVector2Circular(10f, 10f)) * (bloodProjShootDust2.velocity.Length() + 5f); + bloodProjShootDust2.position -= mouthDirection3 * 100f; } // Spawn projectiles @@ -352,8 +352,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[1] < bloodSquidPhaseTime) { npc.position += npc.netOffset; - float num9 = MathHelper.Clamp(1f - npc.ai[1] / bloodSquidPhaseTime * 1.5f, 0f, 1f); - npc.velocity = Vector2.Lerp(value2: new Vector2(0f, num9 * -1.5f), value1: npc.velocity, amount: 0.03f); + float bloodSquidVelClamp = MathHelper.Clamp(1f - npc.ai[1] / bloodSquidPhaseTime * 1.5f, 0f, 1f); + npc.velocity = Vector2.Lerp(value2: new Vector2(0f, bloodSquidVelClamp * -1.5f), value1: npc.velocity, amount: 0.03f); npc.velocity = Vector2.Zero; npc.rotation = npc.rotation.AngleLerp(targetAngle, 0.02f); npc.BloodNautilus_GetMouthPositionAndRotation(out Vector2 _, out Vector2 _); @@ -362,9 +362,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses Lighting.AddLight(npc.Center, new Vector3(1f, 0.5f, 0.5f) * scaleFactor2); if (Main.rand.Next(3) != 0) { - Dust dust2 = Dust.NewDustDirect(npc.Center - new Vector2(6f), 12, 12, 5, 0f, 0f, 60, Color.Transparent, 1.4f); - dust2.position += new Vector2(npc.spriteDirection * 12, 12f); - dust2.velocity *= 0.1f; + Dust bloodSquidSpawnDust = Dust.NewDustDirect(npc.Center - new Vector2(6f), 12, 12, 5, 0f, 0f, 60, Color.Transparent, 1.4f); + bloodSquidSpawnDust.position += new Vector2(npc.spriteDirection * 12, 12f); + bloodSquidSpawnDust.velocity *= 0.1f; } npc.position -= npc.netOffset; @@ -406,30 +406,30 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.netMode == NetmodeID.MultiplayerClient || !Main.player[npc.target].active || Main.player[npc.target].dead || npc.Distance(Main.player[npc.target].Center) > 2000f) return; - Point point = npc.Center.ToTileCoordinates(); - Point point2 = point; - int num = 20; - int num2 = 3; - int num3 = 8; - int num4 = 2; + Point npcCenterTileCoords = npc.Center.ToTileCoordinates(); + Point npcCenterTileCoordsCopy = npcCenterTileCoords; + int bloodTearRandSpawnOffset = 20; + int npcCenterTileRadius = 3; + int npcCenterCopyTileRadius = 8; + int bloodTearSpawnTileRadius = 2; int attempts = 0; - int num6; - int num7; + int bloodTearTileX; + int bloodTearTileY; while (true) { if (attempts >= 100) return; attempts++; - num6 = Main.rand.Next(point2.X - num, point2.X + num + 1); - num7 = Main.rand.Next(point2.Y - num, point2.Y + num + 1); - if ((num7 < point2.Y - num3 || num7 > point2.Y + num3 || num6 < point2.X - num3 || num6 > point2.X + num3) && (num7 < point.Y - num2 || num7 > point.Y + num2 || num6 < point.X - num2 || num6 > point.X + num2) && !Main.tile[num6, num7].HasUnactuatedTile) + bloodTearTileX = Main.rand.Next(npcCenterTileCoordsCopy.X - bloodTearRandSpawnOffset, npcCenterTileCoordsCopy.X + bloodTearRandSpawnOffset + 1); + bloodTearTileY = Main.rand.Next(npcCenterTileCoordsCopy.Y - bloodTearRandSpawnOffset, npcCenterTileCoordsCopy.Y + bloodTearRandSpawnOffset + 1); + if ((bloodTearTileY < npcCenterTileCoordsCopy.Y - npcCenterCopyTileRadius || bloodTearTileY > npcCenterTileCoordsCopy.Y + npcCenterCopyTileRadius || bloodTearTileX < npcCenterTileCoordsCopy.X - npcCenterCopyTileRadius || bloodTearTileX > npcCenterTileCoordsCopy.X + npcCenterCopyTileRadius) && (bloodTearTileY < npcCenterTileCoords.Y - npcCenterTileRadius || bloodTearTileY > npcCenterTileCoords.Y + npcCenterTileRadius || bloodTearTileX < npcCenterTileCoords.X - npcCenterTileRadius || bloodTearTileX > npcCenterTileCoords.X + npcCenterTileRadius) && !Main.tile[bloodTearTileX, bloodTearTileY].HasUnactuatedTile) { bool spawnBloodTear = true; - if (spawnBloodTear && Main.tile[num6, num7].LiquidType == LiquidID.Lava) + if (spawnBloodTear && Main.tile[bloodTearTileX, bloodTearTileY].LiquidType == LiquidID.Lava) spawnBloodTear = false; - if (spawnBloodTear && Collision.SolidTiles(num6 - num4, num6 + num4, num7 - num4, num7 + num4)) + if (spawnBloodTear && Collision.SolidTiles(bloodTearTileX - bloodTearSpawnTileRadius, bloodTearTileX + bloodTearSpawnTileRadius, bloodTearTileY - bloodTearSpawnTileRadius, bloodTearTileY + bloodTearSpawnTileRadius)) spawnBloodTear = false; if (spawnBloodTear && !Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) @@ -440,7 +440,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } } - Projectile.NewProjectile(npc.GetSource_FromAI(), num6 * 16 + 8, num7 * 16 + 8, 0f, 0f, ProjectileID.BloodNautilusTears, 0, 0f, Main.myPlayer); + Projectile.NewProjectile(npc.GetSource_FromAI(), bloodTearTileX * 16 + 8, bloodTearTileY * 16 + 8, 0f, 0f, ProjectileID.BloodNautilusTears, 0, 0f, Main.myPlayer); } } } diff --git a/NPCs/VanillaNPCOverrides/Bosses/DukeFishronAI.cs b/NPCs/VanillaNPCOverrides/Bosses/DukeFishronAI.cs index 31c08e97cb..338ce7f742 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/DukeFishronAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/DukeFishronAI.cs @@ -236,18 +236,18 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } } - float num17 = (float)Math.Atan2(rotationVector.Y, rotationVector.X); + float rotationSpeed = (float)Math.Atan2(rotationVector.Y, rotationVector.X); if (npc.spriteDirection == 1) - num17 += MathHelper.Pi; - if (num17 < 0f) - num17 += MathHelper.TwoPi; - if (num17 > MathHelper.TwoPi) - num17 -= MathHelper.TwoPi; + rotationSpeed += MathHelper.Pi; + if (rotationSpeed < 0f) + rotationSpeed += MathHelper.TwoPi; + if (rotationSpeed > MathHelper.TwoPi) + rotationSpeed -= MathHelper.TwoPi; if (npc.ai[0] == -1f || npc.ai[0] == 3f || npc.ai[0] == 4f || npc.ai[0] == 8f) - num17 = 0f; + rotationSpeed = 0f; if (rateOfRotation != 0f) - npc.rotation = npc.rotation.AngleTowards(num17, rateOfRotation); + npc.rotation = npc.rotation.AngleTowards(rotationSpeed, rateOfRotation); // Alpha adjustments if (npc.ai[0] != -1f && npc.ai[0] < 9f) @@ -270,10 +270,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.velocity *= 0.98f; // Direction - int num19 = Math.Sign(player.Center.X - npc.Center.X); - if (num19 != 0) + int faceDirection = Math.Sign(player.Center.X - npc.Center.X); + if (faceDirection != 0) { - npc.direction = num19; + npc.direction = faceDirection; npc.spriteDirection = -npc.direction; } @@ -294,15 +294,15 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Spawn dust and play sound if (npc.ai[2] == sharknadoPhaseTimer - 30) { - int num20 = 36; - for (int i = 0; i < num20; i++) + int dustAmt = 36; + for (int i = 0; i < dustAmt; i++) { - Vector2 dust = (Vector2.Normalize(npc.velocity) * new Vector2(npc.width / 2f, npc.height) * 0.75f * 0.5f).RotatedBy((i - (num20 / 2 - 1)) * MathHelper.TwoPi / num20) + npc.Center; - Vector2 vector2 = dust - npc.Center; - int num21 = Dust.NewDust(dust + vector2, 0, 0, 172, vector2.X * 2f, vector2.Y * 2f, 100, default, 1.4f); - Main.dust[num21].noGravity = true; - Main.dust[num21].noLight = true; - Main.dust[num21].velocity = Vector2.Normalize(vector2) * 3f; + Vector2 dust = (Vector2.Normalize(npc.velocity) * new Vector2(npc.width / 2f, npc.height) * 0.75f * 0.5f).RotatedBy((i - (dustAmt / 2 - 1)) * MathHelper.TwoPi / dustAmt) + npc.Center; + Vector2 sharknadoDustDirection = dust - npc.Center; + int sharknadoDust = Dust.NewDust(dust + sharknadoDustDirection, 0, 0, 172, sharknadoDustDirection.X * 2f, sharknadoDustDirection.Y * 2f, 100, default, 1.4f); + Main.dust[sharknadoDust].noGravity = true; + Main.dust[sharknadoDust].noLight = true; + Main.dust[sharknadoDust].velocity = Vector2.Normalize(sharknadoDustDirection) * 3f; } SoundEngine.PlaySound(SoundID.Zombie20,npc.Center); @@ -325,17 +325,17 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[1] == 0f) npc.ai[1] = 300 * Math.Sign((npc.Center - player.Center).X); - Vector2 vector3 = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -200f) - npc.Center - npc.velocity) * idlePhaseVelocity; - npc.SimpleFlyMovement(vector3, idlePhaseAcceleration); + Vector2 idlePhaseDirection = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -200f) - npc.Center - npc.velocity) * idlePhaseVelocity; + npc.SimpleFlyMovement(idlePhaseDirection, idlePhaseAcceleration); // Rotation and direction - int num22 = Math.Sign(player.Center.X - npc.Center.X); - if (num22 != 0) + int playerFaceDirection = Math.Sign(player.Center.X - npc.Center.X); + if (playerFaceDirection != 0) { - if (npc.ai[2] == 0f && num22 != npc.direction) + if (npc.ai[2] == 0f && playerFaceDirection != npc.direction) npc.rotation += MathHelper.Pi; - npc.direction = num22; + npc.direction = playerFaceDirection; if (npc.spriteDirection != -npc.direction) npc.rotation += MathHelper.Pi; @@ -347,7 +347,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.ai[2] += 1f; if (npc.ai[2] >= idlePhaseTimer || CalamityWorld.LegendaryMode) { - int num23 = 0; + int attackPicker = 0; switch ((int)npc.ai[3]) { case 0: @@ -360,23 +360,23 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses case 7: case 8: case 9: - num23 = 1; + attackPicker = 1; break; case 10: npc.ai[3] = 1f; - num23 = 2; + attackPicker = 2; break; case 11: npc.ai[3] = 0f; - num23 = 3; + attackPicker = 3; break; } if (phase2) - num23 = 4; + attackPicker = 4; // Set velocity for charge - if (num23 == 1) + if (attackPicker == 1) { npc.ai[0] = 1f; npc.ai[1] = 0f; @@ -387,9 +387,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); // Direction - if (num22 != 0) + if (playerFaceDirection != 0) { - npc.direction = num22; + npc.direction = playerFaceDirection; if (npc.spriteDirection == 1) npc.rotation += MathHelper.Pi; @@ -399,7 +399,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Bubbles - else if (num23 == 2) + else if (attackPicker == 2) { npc.ai[0] = 2f; npc.ai[1] = 0f; @@ -407,7 +407,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Spawn sharknadoes - else if (num23 == 3) + else if (attackPicker == 3) { npc.ai[0] = 3f; npc.ai[1] = 0f; @@ -415,7 +415,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Go to phase 2 - else if (num23 == 4) + else if (attackPicker == 4) { npc.ai[0] = 4f; npc.ai[1] = 0f; @@ -433,16 +433,16 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.velocity *= 1.01f; // Spawn dust - int num24 = 7; - for (int j = 0; j < num24; j++) + int chargeDustAmt = 7; + for (int j = 0; j < chargeDustAmt; j++) { - Vector2 arg_E1C_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((j - (num24 / 2 - 1)) * MathHelper.Pi / num24) + npc.Center; - Vector2 vector4 = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num25 = Dust.NewDust(arg_E1C_0 + vector4, 0, 0, 172, vector4.X * 2f, vector4.Y * 2f, 100, default, 1.4f); - Main.dust[num25].noGravity = true; - Main.dust[num25].noLight = true; - Main.dust[num25].velocity /= 4f; - Main.dust[num25].velocity -= npc.velocity; + Vector2 arg_E1C_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((j - (chargeDustAmt / 2 - 1)) * MathHelper.Pi / chargeDustAmt) + npc.Center; + Vector2 chargeDustDirection = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); + int chargeDust = Dust.NewDust(arg_E1C_0 + chargeDustDirection, 0, 0, 172, chargeDustDirection.X * 2f, chargeDustDirection.Y * 2f, 100, default, 1.4f); + Main.dust[chargeDust].noGravity = true; + Main.dust[chargeDust].noLight = true; + Main.dust[chargeDust].velocity /= 4f; + Main.dust[chargeDust].velocity -= npc.velocity; } npc.ai[2] += 1f; @@ -464,8 +464,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[1] == 0f) npc.ai[1] = 300 * Math.Sign((npc.Center - player.Center).X); - Vector2 vector5 = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -200f) - npc.Center - npc.velocity) * bubbleBelchPhaseVelocity; - npc.SimpleFlyMovement(vector5, bubbleBelchPhaseAcceleration); + Vector2 bubbleAttackDirection = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -200f) - npc.Center - npc.velocity) * bubbleBelchPhaseVelocity; + npc.SimpleFlyMovement(bubbleAttackDirection, bubbleBelchPhaseAcceleration); // Play sounds and spawn bubbles if (npc.ai[2] == 0f) @@ -477,16 +477,16 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector6 = Vector2.Normalize(player.Center - npc.Center) * (npc.width + 20) / 2f + npc.Center; - NPC.NewNPC(npc.GetSource_FromAI(), (int)vector6.X, (int)vector6.Y + 45, NPCID.DetonatingBubble); + Vector2 bubbleSpawnDirection = Vector2.Normalize(player.Center - npc.Center) * (npc.width + 20) / 2f + npc.Center; + NPC.NewNPC(npc.GetSource_FromAI(), (int)bubbleSpawnDirection.X, (int)bubbleSpawnDirection.Y + 45, NPCID.DetonatingBubble); } } // Direction - int num26 = Math.Sign(player.Center.X - npc.Center.X); - if (num26 != 0) + int bubbleSpriteFaceDirection = Math.Sign(player.Center.X - npc.Center.X); + if (bubbleSpriteFaceDirection != 0) { - npc.direction = num26; + npc.direction = bubbleSpriteFaceDirection; if (npc.spriteDirection != -npc.direction) npc.rotation += MathHelper.Pi; npc.spriteDirection = -npc.direction; @@ -516,17 +516,17 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == sharknadoPhaseTimer - 30) { - Vector2 vector7 = npc.rotation.ToRotationVector2() * (Vector2.UnitX * npc.direction) * (npc.width + 20) / 2f + npc.Center; + Vector2 sharknadoSpawnerDirection = npc.rotation.ToRotationVector2() * (Vector2.UnitX * npc.direction) * (npc.width + 20) / 2f + npc.Center; bool normal = Main.rand.NextBool(); float velocityY = normal ? 8f : -4f; float ai1 = normal ? 0f : -1f; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector7.X, vector7.Y, npc.direction * 3, velocityY, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 0f, ai1); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector7.X, vector7.Y, -(float)npc.direction * 3, velocityY, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 0f, ai1); + Projectile.NewProjectile(npc.GetSource_FromAI(), sharknadoSpawnerDirection.X, sharknadoSpawnerDirection.Y, npc.direction * 3, velocityY, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 0f, ai1); + Projectile.NewProjectile(npc.GetSource_FromAI(), sharknadoSpawnerDirection.X, sharknadoSpawnerDirection.Y, -(float)npc.direction * 3, velocityY, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 0f, ai1); velocityY = normal ? -4f : 8f; ai1 = normal ? -1f : 0f; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector7.X, vector7.Y, 0f, velocityY, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 0f, ai1); + Projectile.NewProjectile(npc.GetSource_FromAI(), sharknadoSpawnerDirection.X, sharknadoSpawnerDirection.Y, 0f, velocityY, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 0f, ai1); } npc.ai[2] += 1f; @@ -570,17 +570,17 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[1] == 0f) npc.ai[1] = 300 * Math.Sign((npc.Center - player.Center).X); - Vector2 vector8 = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -200f) - npc.Center - npc.velocity) * idlePhaseVelocity; - npc.SimpleFlyMovement(vector8, idlePhaseAcceleration); + Vector2 phase2IdleDirection = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -200f) - npc.Center - npc.velocity) * idlePhaseVelocity; + npc.SimpleFlyMovement(phase2IdleDirection, idlePhaseAcceleration); // Direction and rotation - int num27 = Math.Sign(player.Center.X - npc.Center.X); - if (num27 != 0) + int phase2SpriteFaceDirection = Math.Sign(player.Center.X - npc.Center.X); + if (phase2SpriteFaceDirection != 0) { - if (npc.ai[2] == 0f && num27 != npc.direction) + if (npc.ai[2] == 0f && phase2SpriteFaceDirection != npc.direction) npc.rotation += MathHelper.Pi; - npc.direction = num27; + npc.direction = phase2SpriteFaceDirection; if (npc.spriteDirection != -npc.direction) npc.rotation += MathHelper.Pi; @@ -592,7 +592,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.ai[2] += 1f; if (npc.ai[2] >= idlePhaseTimer || CalamityWorld.LegendaryMode) { - int num28 = 0; + int phase2AttackPicker = 0; switch ((int)npc.ai[3]) { case 0: @@ -601,23 +601,23 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses case 3: case 4: case 5: - num28 = 1; + phase2AttackPicker = 1; break; case 6: npc.ai[3] = 1f; - num28 = 2; + phase2AttackPicker = 2; break; case 7: npc.ai[3] = 0f; - num28 = 3; + phase2AttackPicker = 3; break; } if (phase3) - num28 = 4; + phase2AttackPicker = 4; // Set velocity for charge - if (num28 == 1) + if (phase2AttackPicker == 1) { npc.ai[0] = 6f; npc.ai[1] = 0f; @@ -628,9 +628,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); // Direction - if (num27 != 0) + if (phase2SpriteFaceDirection != 0) { - npc.direction = num27; + npc.direction = phase2SpriteFaceDirection; if (npc.spriteDirection == 1) npc.rotation += MathHelper.Pi; @@ -640,16 +640,16 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Set velocity for spin - else if (num28 == 2) + else if (phase2AttackPicker == 2) { // Velocity and rotation npc.velocity = Vector2.Normalize(player.Center - npc.Center) * bubbleSpinPhaseVelocity; npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); // Direction - if (num27 != 0) + if (phase2SpriteFaceDirection != 0) { - npc.direction = num27; + npc.direction = phase2SpriteFaceDirection; if (npc.spriteDirection == 1) npc.rotation += MathHelper.Pi; @@ -663,7 +663,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Spawn cthulhunado - else if (num28 == 3) + else if (phase2AttackPicker == 3) { npc.ai[0] = 8f; npc.ai[1] = 0f; @@ -671,7 +671,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Go to next phase - else if (num28 == 4) + else if (phase2AttackPicker == 4) { npc.ai[0] = 9f; npc.ai[1] = 0f; @@ -689,16 +689,16 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.velocity *= 1.01f; // Spawn dust - int num29 = 7; - for (int k = 0; k < num29; k++) + int phase2ChargeDustAmt = 7; + for (int k = 0; k < phase2ChargeDustAmt; k++) { - Vector2 arg_1A97_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((k - (num29 / 2 - 1)) * MathHelper.Pi / num29) + npc.Center; - Vector2 vector9 = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num30 = Dust.NewDust(arg_1A97_0 + vector9, 0, 0, 172, vector9.X * 2f, vector9.Y * 2f, 100, default, 1.4f); - Main.dust[num30].noGravity = true; - Main.dust[num30].noLight = true; - Main.dust[num30].velocity /= 4f; - Main.dust[num30].velocity -= npc.velocity; + Vector2 arg_1A97_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((k - (phase2ChargeDustAmt / 2 - 1)) * MathHelper.Pi / phase2ChargeDustAmt) + npc.Center; + Vector2 phase2ChargeDustDirection = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); + int phase2ChargeDust = Dust.NewDust(arg_1A97_0 + phase2ChargeDustDirection, 0, 0, 172, phase2ChargeDustDirection.X * 2f, phase2ChargeDustDirection.Y * 2f, 100, default, 1.4f); + Main.dust[phase2ChargeDust].noGravity = true; + Main.dust[phase2ChargeDust].noLight = true; + Main.dust[phase2ChargeDust].velocity /= 4f; + Main.dust[phase2ChargeDust].velocity -= npc.velocity; } npc.ai[2] += 1f; @@ -726,17 +726,17 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector10 = Vector2.Normalize(npc.velocity) * (npc.width + 20) / 2f + npc.Center; - int num31 = NPC.NewNPC(npc.GetSource_FromAI(), (int)vector10.X, (int)vector10.Y + 45, NPCID.DetonatingBubble); - Main.npc[num31].target = npc.target; - Main.npc[num31].velocity = Vector2.Normalize(npc.velocity).RotatedBy(MathHelper.PiOver2 * npc.direction) * bubbleSpinBubbleVelocity * (CalamityWorld.LegendaryMode ? (Main.rand.NextFloat() + 0.5f) : 1f); - Main.npc[num31].netUpdate = true; - Main.npc[num31].ai[3] = Main.rand.Next(80, 121) / 100f; + Vector2 phase2BubbleSharkronDirection = Vector2.Normalize(npc.velocity) * (npc.width + 20) / 2f + npc.Center; + int phase2Bubbles = NPC.NewNPC(npc.GetSource_FromAI(), (int)phase2BubbleSharkronDirection.X, (int)phase2BubbleSharkronDirection.Y + 45, NPCID.DetonatingBubble); + Main.npc[phase2Bubbles].target = npc.target; + Main.npc[phase2Bubbles].velocity = Vector2.Normalize(npc.velocity).RotatedBy(MathHelper.PiOver2 * npc.direction) * bubbleSpinBubbleVelocity * (CalamityWorld.LegendaryMode ? (Main.rand.NextFloat() + 0.5f) : 1f); + Main.npc[phase2Bubbles].netUpdate = true; + Main.npc[phase2Bubbles].ai[3] = Main.rand.Next(80, 121) / 100f; if (npc.ai[2] % (bubbleSpinPhaseDivisor * 5) == 0f) { - int npc2 = NPC.NewNPC(npc.GetSource_FromAI(), (int)vector10.X, (int)vector10.Y + 45, NPCID.Sharkron2); - Main.npc[npc2].ai[1] = 89f; + int phase2BubbleSharkrons = NPC.NewNPC(npc.GetSource_FromAI(), (int)phase2BubbleSharkronDirection.X, (int)phase2BubbleSharkronDirection.Y + 45, NPCID.Sharkron2); + Main.npc[phase2BubbleSharkrons].ai[1] = 89f; } } } @@ -846,17 +846,17 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.SimpleFlyMovement(desiredVelocity, idlePhaseAcceleration); // Rotation and direction - int num32 = Math.Sign(player.Center.X - npc.Center.X); - if (num32 != 0) + int phase3SpriteFaceDirection = Math.Sign(player.Center.X - npc.Center.X); + if (phase3SpriteFaceDirection != 0) { - if (npc.ai[2] == 0f && num32 != npc.direction) + if (npc.ai[2] == 0f && phase3SpriteFaceDirection != npc.direction) { npc.rotation += MathHelper.Pi; for (int l = 0; l < npc.oldPos.Length; l++) npc.oldPos[l] = Vector2.Zero; } - npc.direction = num32; + npc.direction = phase3SpriteFaceDirection; if (npc.spriteDirection != -npc.direction) npc.rotation += MathHelper.Pi; @@ -868,7 +868,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.ai[2] += 1f; if (npc.ai[2] >= idlePhaseTimer || CalamityWorld.LegendaryMode) { - int num33 = 0; + int phase3AttackPicker = 0; if (phase4) { switch ((int)npc.ai[3]) @@ -880,16 +880,16 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses case 5: case 6: case 7: - num33 = 1; + phase3AttackPicker = 1; break; case 3: case 8: - num33 = 2; + phase3AttackPicker = 2; break; } if (death) - num33 = 1; + phase3AttackPicker = 1; } else { @@ -901,18 +901,18 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses case 5: case 6: case 7: - num33 = 1; + phase3AttackPicker = 1; break; case 1: case 4: case 8: - num33 = 2; + phase3AttackPicker = 2; break; } } // Set velocity for charge - if (num33 == 1) + if (phase3AttackPicker == 1) { npc.ai[0] = 11f; npc.ai[1] = 0f; @@ -923,9 +923,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); // Direction - if (num32 != 0) + if (phase3SpriteFaceDirection != 0) { - npc.direction = num32; + npc.direction = phase3SpriteFaceDirection; if (npc.spriteDirection == 1) npc.rotation += MathHelper.Pi; @@ -935,7 +935,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Pause - else if (num33 == 2) + else if (phase3AttackPicker == 2) { npc.ai[0] = 12f; npc.ai[1] = 0f; @@ -958,16 +958,16 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.alpha = 0; // Spawn dust - int num34 = 7; - for (int m = 0; m < num34; m++) + int phase3ChargeDustAmt = 7; + for (int m = 0; m < phase3ChargeDustAmt; m++) { - Vector2 arg_2444_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((m - (num34 / 2 - 1)) * MathHelper.Pi / num34) + npc.Center; - Vector2 vector11 = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num35 = Dust.NewDust(arg_2444_0 + vector11, 0, 0, 172, vector11.X * 2f, vector11.Y * 2f, 100, default, 1.4f); - Main.dust[num35].noGravity = true; - Main.dust[num35].noLight = true; - Main.dust[num35].velocity /= 4f; - Main.dust[num35].velocity -= npc.velocity; + Vector2 arg_2444_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((m - (phase3ChargeDustAmt / 2 - 1)) * MathHelper.Pi / phase3ChargeDustAmt) + npc.Center; + Vector2 phase3ChargeDustDirection = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); + int phase3ChargeDust = Dust.NewDust(arg_2444_0 + phase3ChargeDustDirection, 0, 0, 172, phase3ChargeDustDirection.X * 2f, phase3ChargeDustDirection.Y * 2f, 100, default, 1.4f); + Main.dust[phase3ChargeDust].noGravity = true; + Main.dust[phase3ChargeDust].noLight = true; + Main.dust[phase3ChargeDust].velocity /= 4f; + Main.dust[phase3ChargeDust].velocity -= npc.velocity; } npc.ai[2] += 1f; @@ -1016,17 +1016,17 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Rotation and direction Vector2 center = player.Center + new Vector2(-npc.ai[1], -200f); npc.Center = center; - int num36 = Math.Sign(player.Center.X - npc.Center.X); - if (num36 != 0) + int phase3PlayerDirection = Math.Sign(player.Center.X - npc.Center.X); + if (phase3PlayerDirection != 0) { - if (npc.ai[2] == 0f && num36 != npc.direction) + if (npc.ai[2] == 0f && phase3PlayerDirection != npc.direction) { npc.rotation += MathHelper.Pi; for (int n = 0; n < npc.oldPos.Length; n++) npc.oldPos[n] = Vector2.Zero; } - npc.direction = num36; + npc.direction = phase3PlayerDirection; if (npc.spriteDirection != -npc.direction) npc.rotation += MathHelper.Pi; diff --git a/NPCs/VanillaNPCOverrides/Bosses/EaterOfWorldsAI.cs b/NPCs/VanillaNPCOverrides/Bosses/EaterOfWorldsAI.cs index cbfa4e9624..012513d062 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/EaterOfWorldsAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/EaterOfWorldsAI.cs @@ -103,21 +103,21 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses Vector2.Distance(npc.Center, Main.player[npc.target].Center) > 320f) { calamityGlobalNPC.newAI[0] = 0f; - Vector2 vector34 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num349 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector34.X; - float num350 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector34.Y; - float num418 = 7f + enrageScale * 2f; - float num351 = (float)Math.Sqrt(num349 * num349 + num350 * num350); - num351 = num418 / num351; - num349 *= num351; - num350 *= num351; - num350 += npc.velocity.Y * 0.5f; - num349 += npc.velocity.X * 0.5f; - vector34.X -= num349; - vector34.Y -= num350; + Vector2 cursedFlameDirection = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float targetXDirection = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - cursedFlameDirection.X; + float targetYDirection = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - cursedFlameDirection.Y; + float projSpeed = 7f + enrageScale * 2f; + float flameTargetDistance = (float)Math.Sqrt(targetXDirection * targetXDirection + targetYDirection * targetYDirection); + flameTargetDistance = projSpeed / flameTargetDistance; + targetXDirection *= flameTargetDistance; + targetYDirection *= flameTargetDistance; + targetYDirection += npc.velocity.Y * 0.5f; + targetXDirection += npc.velocity.X * 0.5f; + cursedFlameDirection.X -= targetXDirection; + cursedFlameDirection.Y -= targetYDirection; int type = ProjectileID.CursedFlameHostile; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector34.X, vector34.Y, num349, num350, type, npc.GetProjectileDamage(type), 0f, Main.myPlayer); + Projectile.NewProjectile(npc.GetSource_FromAI(), cursedFlameDirection.X, cursedFlameDirection.Y, targetXDirection, targetYDirection, type, npc.GetProjectileDamage(type), 0f, Main.myPlayer); } } } @@ -233,38 +233,38 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Movement - int num29 = (int)(npc.position.X / 16f) - 1; - int num30 = (int)((npc.position.X + npc.width) / 16f) + 2; - int num31 = (int)(npc.position.Y / 16f) - 1; - int num32 = (int)((npc.position.Y + npc.height) / 16f) + 2; - if (num29 < 0) - num29 = 0; - if (num30 > Main.maxTilesX) - num30 = Main.maxTilesX; - if (num31 < 0) - num31 = 0; - if (num32 > Main.maxTilesY) - num32 = Main.maxTilesY; + int tilePositionX = (int)(npc.position.X / 16f) - 1; + int tileWidthPosX = (int)((npc.position.X + npc.width) / 16f) + 2; + int tilePositionY = (int)(npc.position.Y / 16f) - 1; + int tileWidthPosY = (int)((npc.position.Y + npc.height) / 16f) + 2; + if (tilePositionX < 0) + tilePositionX = 0; + if (tileWidthPosX > Main.maxTilesX) + tileWidthPosX = Main.maxTilesX; + if (tilePositionY < 0) + tilePositionY = 0; + if (tileWidthPosY > Main.maxTilesY) + tileWidthPosY = Main.maxTilesY; // Fly or not bool inTiles = false; if (!inTiles) { - for (int num33 = num29; num33 < num30; num33++) + for (int i = tilePositionX; i < tileWidthPosX; i++) { - for (int num34 = num31; num34 < num32; num34++) + for (int j = tilePositionY; j < tileWidthPosY; j++) { - if (Main.tile[num33, num34] != null && ((Main.tile[num33, num34].HasUnactuatedTile && (Main.tileSolid[Main.tile[num33, num34].TileType] || (Main.tileSolidTop[Main.tile[num33, num34].TileType] && Main.tile[num33, num34].TileFrameY == 0))) || Main.tile[num33, num34].LiquidAmount > 64)) + if (Main.tile[i, j] != null && ((Main.tile[i, j].HasUnactuatedTile && (Main.tileSolid[Main.tile[i, j].TileType] || (Main.tileSolidTop[Main.tile[i, j].TileType] && Main.tile[i, j].TileFrameY == 0))) || Main.tile[i, j].LiquidAmount > 64)) { Vector2 vector; - vector.X = num33 * 16; - vector.Y = num34 * 16; + vector.X = i * 16; + vector.Y = j * 16; if (npc.position.X + npc.width > vector.X && npc.position.X < vector.X + 16f && npc.position.Y + npc.height > vector.Y && npc.position.Y < vector.Y + 16f) { inTiles = true; - if (Main.rand.NextBool(100) && Main.tile[num33, num34].HasUnactuatedTile) + if (Main.rand.NextBool(100) && Main.tile[i, j].HasUnactuatedTile) { - WorldGen.KillTile(num33, num34, true, true, false); + WorldGen.KillTile(i, j, true, true, false); } } } @@ -274,18 +274,18 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (!inTiles && npc.type == NPCID.EaterofWorldsHead) { Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - int num35 = death ? 700 : 850; - num35 -= (int)(enrageScale * 300f); + int noFlyZone = death ? 700 : 850; + noFlyZone -= (int)(enrageScale * 300f); - if (num35 < 100) - num35 = 100; + if (noFlyZone < 100) + noFlyZone = 100; bool freeMoveAnyway = true; - for (int num36 = 0; num36 < Main.maxPlayers; num36++) + for (int k = 0; k < Main.maxPlayers; k++) { - if (Main.player[num36].active) + if (Main.player[k].active) { - Rectangle rectangle2 = new Rectangle((int)Main.player[num36].position.X - num35, (int)Main.player[num36].position.Y - num35, num35 * 2, num35 * 2); + Rectangle rectangle2 = new Rectangle((int)Main.player[k].position.X - noFlyZone, (int)Main.player[k].position.Y - noFlyZone, noFlyZone * 2, noFlyZone * 2); if (rectangle.Intersects(rectangle2)) { freeMoveAnyway = false; @@ -302,65 +302,65 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses float velocityBoost = velocityScale * (1f - lifeRatio); float accelerationScale = (death ? 0.06f : 0.03f) * enrageScale; float accelerationBoost = accelerationScale * (1f - lifeRatio); - float num37 = 12f + velocityBoost; - float num38 = 0.15f + accelerationBoost; + float segmentVelocity = 12f + velocityBoost; + float segmentAcceleration = 0.15f + accelerationBoost; if (phase5) { - num37 += 2.4f * enrageScale; - num38 += 0.03f * enrageScale; + segmentVelocity += 2.4f * enrageScale; + segmentAcceleration += 0.03f * enrageScale; } else if (phase4) { - num37 += 1.2f * enrageScale; - num38 += 0.015f * enrageScale; + segmentVelocity += 1.2f * enrageScale; + segmentAcceleration += 0.015f * enrageScale; } if (Main.getGoodWorld) { - num37 += 4f; - num38 += 0.05f; + segmentVelocity += 4f; + segmentAcceleration += 0.05f; } - Vector2 vector2 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num39 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); - float num40 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); + Vector2 segmentDirection = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float targetPosX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); + float targetPosY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); - num39 = (int)(num39 / 16f) * 16; - num40 = (int)(num40 / 16f) * 16; - vector2.X = (int)(vector2.X / 16f) * 16; - vector2.Y = (int)(vector2.Y / 16f) * 16; - num39 -= vector2.X; - num40 -= vector2.Y; - float num52 = (float)Math.Sqrt(num39 * num39 + num40 * num40); + targetPosX = (int)(targetPosX / 16f) * 16; + targetPosY = (int)(targetPosY / 16f) * 16; + segmentDirection.X = (int)(segmentDirection.X / 16f) * 16; + segmentDirection.Y = (int)(segmentDirection.Y / 16f) * 16; + targetPosX -= segmentDirection.X; + targetPosY -= segmentDirection.Y; + float targetDistance = (float)Math.Sqrt(targetPosX * targetPosX + targetPosY * targetPosY); // Does this worm segment have a "previous segment" defined? if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) { try { - vector2 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num39 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector2.X; - num40 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector2.Y; + segmentDirection = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + targetPosX = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - segmentDirection.X; + targetPosY = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - segmentDirection.Y; } catch { } - npc.rotation = (float)Math.Atan2(num40, num39) + MathHelper.PiOver2; - num52 = (float)Math.Sqrt(num39 * num39 + num40 * num40); - int num53 = npc.width; - num53 = (int)(num53 * npc.scale); + npc.rotation = (float)Math.Atan2(targetPosY, targetPosX) + MathHelper.PiOver2; + targetDistance = (float)Math.Sqrt(targetPosX * targetPosX + targetPosY * targetPosY); + int npcWidth = npc.width; + npcWidth = (int)(npcWidth * npc.scale); if (Main.getGoodWorld) - num53 = 62; + npcWidth = 62; - num52 = (num52 - num53) / num52; - num39 *= num52; - num40 *= num52; + targetDistance = (targetDistance - npcWidth) / targetDistance; + targetPosX *= targetDistance; + targetPosY *= targetDistance; npc.velocity = Vector2.Zero; - npc.position.X += num39; - npc.position.Y += num40; + npc.position.X += targetPosX; + npc.position.Y += targetPosY; } // Otherwise this is a head. (Why does this not just check for head NPC type?) @@ -372,35 +372,35 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses calamityGlobalNPC.newAI[1] += 1f; // Set velocity for when a new head spawns - npc.velocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * (num37 * (death ? 0.5f : 0.4f)); + npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * (segmentVelocity * (death ? 0.5f : 0.4f)); } if (!inTiles) { npc.velocity.Y += death ? 0.15f : 0.11f; - if (npc.velocity.Y > num37) - npc.velocity.Y = num37; + if (npc.velocity.Y > segmentVelocity) + npc.velocity.Y = segmentVelocity; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num37 * 0.4) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.4) { if (npc.velocity.X < 0f) - npc.velocity.X -= num38 * 1.1f; + npc.velocity.X -= segmentAcceleration * 1.1f; else - npc.velocity.X += num38 * 1.1f; + npc.velocity.X += segmentAcceleration * 1.1f; } - else if (npc.velocity.Y == num37) + else if (npc.velocity.Y == segmentVelocity) { - if (npc.velocity.X < num39) - npc.velocity.X += num38; - else if (npc.velocity.X > num39) - npc.velocity.X -= num38; + if (npc.velocity.X < targetPosX) + npc.velocity.X += segmentAcceleration; + else if (npc.velocity.X > targetPosX) + npc.velocity.X -= segmentAcceleration; } else if (npc.velocity.Y > (death ? 6f : 4f)) { if (npc.velocity.X < 0f) - npc.velocity.X += num38 * 0.9f; + npc.velocity.X += segmentAcceleration * 0.9f; else - npc.velocity.X -= num38 * 0.9f; + npc.velocity.X -= segmentAcceleration * 0.9f; } } else @@ -408,31 +408,31 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Sound if (npc.soundDelay == 0) { - float num54 = num52 / 40f; - if (num54 < 10f) - num54 = 10f; - if (num54 > 20f) - num54 = 20f; + float soundDelay = targetDistance / 40f; + if (soundDelay < 10f) + soundDelay = 10f; + if (soundDelay > 20f) + soundDelay = 20f; - npc.soundDelay = (int)num54; + npc.soundDelay = (int)soundDelay; SoundEngine.PlaySound(SoundID.WormDig, npc.position); } - num52 = (float)Math.Sqrt(num39 * num39 + num40 * num40); - float num55 = Math.Abs(num39); - float num56 = Math.Abs(num40); - float num57 = num37 / num52; - num39 *= num57; - num40 *= num57; + targetDistance = (float)Math.Sqrt(targetPosX * targetPosX + targetPosY * targetPosY); + float absoluteTargetX = Math.Abs(targetPosX); + float absoluteTargetY = Math.Abs(targetPosY); + float timeToReachTarget = segmentVelocity / targetDistance; + targetPosX *= timeToReachTarget; + targetPosY *= timeToReachTarget; // Despawn bool shouldDespawn = npc.type == NPCID.EaterofWorldsHead && Main.player[npc.target].dead; if (shouldDespawn && !bossRush) { bool everyoneDead = true; - for (int num58 = 0; num58 < Main.maxPlayers; num58++) + for (int i = 0; i < Main.maxPlayers; i++) { - if (Main.player[num58].active && !Main.player[num58].dead) + if (Main.player[i].active && !Main.player[i].dead) { everyoneDead = false; break; @@ -444,83 +444,83 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient && (npc.position.Y / 16f) > (Main.rockLayer + Main.maxTilesY) / 2.0) { npc.active = false; - int num59 = (int)npc.ai[0]; + int segmentAmt = (int)npc.ai[0]; - while (num59 > 0 && num59 < Main.maxNPCs && Main.npc[num59].active && Main.npc[num59].aiStyle == npc.aiStyle) + while (segmentAmt > 0 && segmentAmt < Main.maxNPCs && Main.npc[segmentAmt].active && Main.npc[segmentAmt].aiStyle == npc.aiStyle) { - int arg_2853_0 = (int)Main.npc[num59].ai[0]; - Main.npc[num59].active = false; + int arg_2853_0 = (int)Main.npc[segmentAmt].ai[0]; + Main.npc[segmentAmt].active = false; npc.life = 0; if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num59, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, segmentAmt, 0f, 0f, 0f, 0, 0, 0); - num59 = arg_2853_0; + segmentAmt = arg_2853_0; } if (Main.netMode == NetmodeID.Server) NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI, 0f, 0f, 0f, 0, 0, 0); } - num39 = 0f; - num40 = num37; + targetPosX = 0f; + targetPosY = segmentVelocity; } } - if ((npc.velocity.X > 0f && num39 > 0f) || (npc.velocity.X < 0f && num39 < 0f) || (npc.velocity.Y > 0f && num40 > 0f) || (npc.velocity.Y < 0f && num40 < 0f)) + if ((npc.velocity.X > 0f && targetPosX > 0f) || (npc.velocity.X < 0f && targetPosX < 0f) || (npc.velocity.Y > 0f && targetPosY > 0f) || (npc.velocity.Y < 0f && targetPosY < 0f)) { - if (npc.velocity.X < num39) - npc.velocity.X += num38; - else if (npc.velocity.X > num39) - npc.velocity.X -= num38; - if (npc.velocity.Y < num40) - npc.velocity.Y += num38; - else if (npc.velocity.Y > num40) - npc.velocity.Y -= num38; + if (npc.velocity.X < targetPosX) + npc.velocity.X += segmentAcceleration; + else if (npc.velocity.X > targetPosX) + npc.velocity.X -= segmentAcceleration; + if (npc.velocity.Y < targetPosY) + npc.velocity.Y += segmentAcceleration; + else if (npc.velocity.Y > targetPosY) + npc.velocity.Y -= segmentAcceleration; - if (Math.Abs(num40) < num37 * 0.2 && ((npc.velocity.X > 0f && num39 < 0f) || (npc.velocity.X < 0f && num39 > 0f))) + if (Math.Abs(targetPosY) < segmentVelocity * 0.2 && ((npc.velocity.X > 0f && targetPosX < 0f) || (npc.velocity.X < 0f && targetPosX > 0f))) { if (npc.velocity.Y > 0f) - npc.velocity.Y += num38 * 2f; + npc.velocity.Y += segmentAcceleration * 2f; else - npc.velocity.Y -= num38 * 2f; + npc.velocity.Y -= segmentAcceleration * 2f; } - if (Math.Abs(num39) < num37 * 0.2 && ((npc.velocity.Y > 0f && num40 < 0f) || (npc.velocity.Y < 0f && num40 > 0f))) + if (Math.Abs(targetPosX) < segmentVelocity * 0.2 && ((npc.velocity.Y > 0f && targetPosY < 0f) || (npc.velocity.Y < 0f && targetPosY > 0f))) { if (npc.velocity.X > 0f) - npc.velocity.X += num38 * 2f; + npc.velocity.X += segmentAcceleration * 2f; else - npc.velocity.X -= num38 * 2f; + npc.velocity.X -= segmentAcceleration * 2f; } } - else if (num55 > num56) + else if (absoluteTargetX > absoluteTargetY) { - if (npc.velocity.X < num39) - npc.velocity.X += num38 * 1.1f; - else if (npc.velocity.X > num39) - npc.velocity.X -= num38 * 1.1f; + if (npc.velocity.X < targetPosX) + npc.velocity.X += segmentAcceleration * 1.1f; + else if (npc.velocity.X > targetPosX) + npc.velocity.X -= segmentAcceleration * 1.1f; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num37 * 0.5) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.5) { if (npc.velocity.Y > 0f) - npc.velocity.Y += num38; + npc.velocity.Y += segmentAcceleration; else - npc.velocity.Y -= num38; + npc.velocity.Y -= segmentAcceleration; } } else { - if (npc.velocity.Y < num40) - npc.velocity.Y += num38 * 1.1f; - else if (npc.velocity.Y > num40) - npc.velocity.Y -= num38 * 1.1f; + if (npc.velocity.Y < targetPosY) + npc.velocity.Y += segmentAcceleration * 1.1f; + else if (npc.velocity.Y > targetPosY) + npc.velocity.Y -= segmentAcceleration * 1.1f; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num37 * 0.5) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.5) { if (npc.velocity.X > 0f) - npc.velocity.X += num38; + npc.velocity.X += segmentAcceleration; else - npc.velocity.X -= num38; + npc.velocity.X -= segmentAcceleration; } } } diff --git a/NPCs/VanillaNPCOverrides/Bosses/EmpressofLightAI.cs b/NPCs/VanillaNPCOverrides/Bosses/EmpressofLightAI.cs index a347de39cb..eeebea7535 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/EmpressofLightAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/EmpressofLightAI.cs @@ -1,12 +1,12 @@ -using CalamityMod.Events; +using System; +using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; -using System; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { @@ -52,8 +52,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses Vector2 etherealLanceDistance = new Vector2(0f, -450f); Vector2 sunDanceDistance = new Vector2(-80f, -500f); - float acceleration = death ? 0.7f : 0.6f; - float velocity = death ? 18f : 15f; + float acceleration = death ? 0.55f : 0.48f; + float velocity = death ? 14f : 12f; float movementDistanceGateValue = 40f; float despawnDistanceGateValue = 6400f; @@ -100,24 +100,23 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[1] > 10f && npc.ai[1] < 150f) { - int num67 = 2; - for (int m = 0; m < num67; m++) + for (int m = 0; m < 2; m++) { - float num68 = MathHelper.Lerp(1.3f, 0.7f, npc.Opacity) * Utils.GetLerpValue(0f, 120f, npc.ai[1], clamped: true); + float dustOpacity = MathHelper.Lerp(1.3f, 0.7f, npc.Opacity) * Utils.GetLerpValue(0f, 120f, npc.ai[1], clamped: true); Color newColor2 = Main.hslToRgb(npc.ai[1] / 180f, 1f, 0.5f); - int num69 = Dust.NewDust(npc.position, npc.width, npc.height, 267, 0f, 0f, 0, newColor2); - Main.dust[num69].position = npc.Center + Main.rand.NextVector2Circular(npc.width * 3f, npc.height * 3f) + new Vector2(0f, -150f); - Main.dust[num69].velocity *= Main.rand.NextFloat() * 0.8f; - Main.dust[num69].noGravity = true; - Main.dust[num69].fadeIn = 0.6f + Main.rand.NextFloat() * 0.7f * num68; - Main.dust[num69].velocity += Vector2.UnitY * 3f; - Main.dust[num69].scale = 0.35f; - if (num69 != 6000) + int rainbow = Dust.NewDust(npc.position, npc.width, npc.height, 267, 0f, 0f, 0, newColor2); + Main.dust[rainbow].position = npc.Center + Main.rand.NextVector2Circular(npc.width * 3f, npc.height * 3f) + new Vector2(0f, -150f); + Main.dust[rainbow].velocity *= Main.rand.NextFloat() * 0.8f; + Main.dust[rainbow].noGravity = true; + Main.dust[rainbow].fadeIn = 0.6f + Main.rand.NextFloat() * 0.7f * dustOpacity; + Main.dust[rainbow].velocity += Vector2.UnitY * 3f; + Main.dust[rainbow].scale = 0.35f; + if (rainbow != 6000) { - Dust dust2 = Dust.CloneDust(num69); - dust2.scale /= 2f; - dust2.fadeIn *= 0.85f; - dust2.color = new Color(255, 255, 255, 255); + Dust rainbowClone = Dust.CloneDust(rainbow); + rainbowClone.scale /= 2f; + rainbowClone.fadeIn *= 0.85f; + rainbowClone.color = new Color(255, 255, 255, 255); } } } @@ -146,11 +145,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Avoid cheap bullshit. npc.damage = 0; - float num33 = phase2 ? (death ? 10f : 15f) : (death ? 20f : 30f); + float idleTimer = phase2 ? (death ? 10f : 15f) : (death ? 20f : 30f); if (Main.getGoodWorld) - num33 *= 0.5f; - if (num33 < 10f) - num33 = 10f; + idleTimer *= 0.5f; + if (idleTimer < 10f) + idleTimer = 10f; if (npc.ai[1] <= 10f) { @@ -174,52 +173,52 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.Distance(center) > 200f) center -= npc.DirectionTo(center) * 100f; - Vector2 vector2 = center - npc.Center; - float lerpValue = Utils.GetLerpValue(100f, 600f, vector2.Length()); - float num34 = vector2.Length(); + Vector2 targetDirection = center - npc.Center; + float lerpValue = Utils.GetLerpValue(100f, 600f, targetDirection.Length()); + float targetDistance = targetDirection.Length(); float maxVelocity = death ? 24f : 21f; - if (num34 > maxVelocity) - num34 = maxVelocity; + if (targetDistance > maxVelocity) + targetDistance = maxVelocity; - npc.velocity = Vector2.Lerp(vector2.SafeNormalize(Vector2.Zero) * num34, vector2 / 6f, lerpValue); + npc.velocity = Vector2.Lerp(targetDirection.SafeNormalize(Vector2.Zero) * targetDistance, targetDirection / 6f, lerpValue); npc.netUpdate = true; } npc.velocity *= 0.92f; npc.ai[1] += 1f; - if (!(npc.ai[1] >= num33)) + if (!(npc.ai[1] >= idleTimer)) break; - int num35 = (int)npc.ai[2]; - int num36 = 2; - int num37 = 0; + int attackPatternLength = (int)npc.ai[2]; + int attackType = 2; + int attackIncrement = 0; if (!phase2) { - int num38 = num37++; - int num39 = num37++; - int num40 = num37++; - int num41 = num37++; - int num42 = num37++; - int num43 = num37++; - int num44 = num37++; - int num45 = num37++; - int num46 = num37++; - int num47 = num37++; + int phase1Attack1 = attackIncrement++; + int phase1Attack2 = attackIncrement++; + int phase1Attack3 = attackIncrement++; + int phase1Attack4 = attackIncrement++; + int phase1Attack5 = attackIncrement++; + int phase1Attack6 = attackIncrement++; + int phase1Attack7 = attackIncrement++; + int phase1Attack8 = attackIncrement++; + int phase1Attack9 = attackIncrement++; + int phase1Attack10 = attackIncrement++; - if (num35 % num37 == num38) - num36 = 2; + if (attackPatternLength % attackIncrement == phase1Attack1) + attackType = 2; - if (num35 % num37 == num39) - num36 = 6; + if (attackPatternLength % attackIncrement == phase1Attack2) + attackType = 6; - if (num35 % num37 == num40) - num36 = 8; + if (attackPatternLength % attackIncrement == phase1Attack3) + attackType = 8; - if (num35 % num37 == num41) + if (attackPatternLength % attackIncrement == phase1Attack4) { - num36 = 4; + attackType = 4; // Adjust the upcoming Ethereal Lance attack depending on what random variable is chosen here. calamityGlobalNPC.newAI[0] = Main.rand.Next(2); @@ -228,18 +227,18 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.SyncExtraAI(); } - if (num35 % num37 == num42) - num36 = 5; + if (attackPatternLength % attackIncrement == phase1Attack5) + attackType = 5; - if (num35 % num37 == num43) - num36 = 8; + if (attackPatternLength % attackIncrement == phase1Attack6) + attackType = 8; - if (num35 % num37 == num44) - num36 = 2; + if (attackPatternLength % attackIncrement == phase1Attack7) + attackType = 2; - if (num35 % num37 == num45) + if (attackPatternLength % attackIncrement == phase1Attack8) { - num36 = 4; + attackType = 4; // Adjust the upcoming Ethereal Lance attack depending on what random variable is chosen here. calamityGlobalNPC.newAI[0] = Main.rand.Next(2); @@ -248,32 +247,32 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.SyncExtraAI(); } - if (num35 % num37 == num46) - num36 = 8; + if (attackPatternLength % attackIncrement == phase1Attack9) + attackType = 8; - if (num35 % num37 == num47) - num36 = 5; + if (attackPatternLength % attackIncrement == phase1Attack10) + attackType = 5; if (lifeRatio <= 0.5f) - num36 = 10; + attackType = 10; } if (phase2) { - int num48 = num37++; - int num49 = num37++; - int num50 = num37++; - int num51 = num37++; - int num52 = num37++; - int num53 = num37++; - int num54 = num37++; - int num55 = num37++; - int num56 = num37++; - int num57 = num37++; + int phase2Attack1 = attackIncrement++; + int phase2Attack2 = attackIncrement++; + int phase2Attack3 = attackIncrement++; + int phase2Attack4 = attackIncrement++; + int phase2Attack5 = attackIncrement++; + int phase2Attack6 = attackIncrement++; + int phase2Attack7 = attackIncrement++; + int phase2Attack8 = attackIncrement++; + int phase2Attack9 = attackIncrement++; + int phase2Attack10 = attackIncrement++; - if (num35 % num37 == num48) + if (attackPatternLength % attackIncrement == phase2Attack1) { - num36 = 7; + attackType = 7; // Adjust the upcoming Ethereal Lance attack depending on what random variable is chosen here. calamityGlobalNPC.newAI[2] = Main.rand.Next(2); @@ -282,27 +281,27 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.SyncExtraAI(); } - if (num35 % num37 == num49) - num36 = 2; + if (attackPatternLength % attackIncrement == phase2Attack2) + attackType = 2; - if (num35 % num37 == num50) - num36 = 8; + if (attackPatternLength % attackIncrement == phase2Attack3) + attackType = 8; - if (num35 % num37 == num52) - num36 = 5; + if (attackPatternLength % attackIncrement == phase2Attack5) + attackType = 5; - if (num35 % num37 == num53) - num36 = 2; + if (attackPatternLength % attackIncrement == phase2Attack6) + attackType = 2; - if (num35 % num37 == num54) - num36 = 6; + if (attackPatternLength % attackIncrement == phase2Attack7) + attackType = 6; - if (num35 % num37 == num54) - num36 = 6; + if (attackPatternLength % attackIncrement == phase2Attack7) + attackType = 6; - if (num35 % num37 == num55) + if (attackPatternLength % attackIncrement == phase2Attack8) { - num36 = 4; + attackType = 4; // Adjust the upcoming Ethereal Lance attack depending on what random variable is chosen here. calamityGlobalNPC.newAI[0] = Main.rand.Next(2); @@ -311,40 +310,40 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.SyncExtraAI(); } - if (num35 % num37 == num56) - num36 = 8; + if (attackPatternLength % attackIncrement == phase2Attack9) + attackType = 8; - if (num35 % num37 == num51) - num36 = 11; + if (attackPatternLength % attackIncrement == phase2Attack4) + attackType = 11; - if (num35 % num37 == num57) - num36 = 12; + if (attackPatternLength % attackIncrement == phase2Attack10) + attackType = 12; } npc.TargetClosest(); NPCAimedTarget targetData5 = npc.GetTargetData(); - bool flag12 = false; + bool despawnFlag = false; if (npc.AI_120_HallowBoss_IsGenuinelyEnraged() && !bossRush) { if (!Main.dayTime) - flag12 = true; + despawnFlag = true; if (Main.dayTime && Main.time >= 53400.0) - flag12 = true; + despawnFlag = true; } // Despawn. - if (targetData5.Invalid || npc.Distance(targetData5.Center) > despawnDistanceGateValue || flag12) - num36 = 13; + if (targetData5.Invalid || npc.Distance(targetData5.Center) > despawnDistanceGateValue || despawnFlag) + attackType = 13; // Set charge direction. - if (num36 == 8 && targetData5.Center.X > npc.Center.X) - num36 = 9; + if (attackType == 8 && targetData5.Center.X > npc.Center.X) + attackType = 9; - if (num36 != 5 && num36 != 12) + if (attackType != 5 && attackType != 12) npc.velocity = npc.DirectionFrom(targetData5.Center).SafeNormalize(Vector2.Zero).RotatedBy((float)Math.PI / 2f * (targetData5.Center.X > npc.Center.X).ToDirectionInt()) * 24f; - npc.ai[0] = num36; + npc.ai[0] = attackType; npc.ai[1] = 0f; npc.ai[2] += Main.rand.Next(2) + 1f; npc.netUpdate = true; @@ -360,17 +359,17 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[1] == 0f) SoundEngine.PlaySound(SoundID.Item164, npc.Center); - Vector2 value29 = new Vector2(-55f, -30f); + Vector2 randomStreakOffset = new Vector2(-55f, -30f); NPCAimedTarget targetData11 = npc.GetTargetData(); - Vector2 value30 = targetData11.Invalid ? npc.Center : targetData11.Center; - if (npc.Distance(value30 + rainbowStreakDistance) > movementDistanceGateValue) - npc.SimpleFlyMovement(npc.DirectionTo(value30 + rainbowStreakDistance).SafeNormalize(Vector2.Zero) * velocity, acceleration); + Vector2 targetCenter = targetData11.Invalid ? npc.Center : targetData11.Center; + if (npc.Distance(targetCenter + rainbowStreakDistance) > movementDistanceGateValue) + npc.SimpleFlyMovement(npc.DirectionTo(targetCenter + rainbowStreakDistance).SafeNormalize(Vector2.Zero) * velocity, acceleration); if (npc.ai[1] < 60f) - AI_120_HallowBoss_DoMagicEffect(npc.Center + value29, 1, Utils.GetLerpValue(0f, 60f, npc.ai[1], clamped: true), npc); + AI_120_HallowBoss_DoMagicEffect(npc.Center + randomStreakOffset, 1, Utils.GetLerpValue(0f, 60f, npc.ai[1], clamped: true), npc); - int num91 = CalamityWorld.LegendaryMode ? 1 : 2; - if ((int)npc.ai[1] % num91 == 0 && npc.ai[1] < 60f) + int streakSpawnFrequency = CalamityWorld.LegendaryMode ? 1 : 2; + if ((int)npc.ai[1] % streakSpawnFrequency == 0 && npc.ai[1] < 60f) { int projectileType = ProjectileID.HallowBossRainbowStreak; int projectileDamage = npc.GetProjectileDamage(projectileType) * projectileDamageMultiplier; @@ -385,7 +384,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + value29, rainbowStreakVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, npc.target, ai3); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + randomStreakOffset, rainbowStreakVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, npc.target, ai3); if (Main.rand.NextBool(60) && CalamityWorld.LegendaryMode) { Main.projectile[proj].extraUpdates += 1; @@ -396,17 +395,17 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Spawn extra homing Rainbow Streaks per player. if (Main.netMode != NetmodeID.MultiplayerClient) { - int num92 = (int)(npc.ai[1] / num91); - for (int num93 = 0; num93 < Main.maxPlayers; num93++) + int multiplayerStreakSpawnFrequency = (int)(npc.ai[1] / streakSpawnFrequency); + for (int i = 0; i < Main.maxPlayers; i++) { - if (npc.Boss_CanShootExtraAt(num93, num92 % 3, 3, 2400f)) - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + value29, rainbowStreakVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, num93, ai3); + if (npc.Boss_CanShootExtraAt(i, multiplayerStreakSpawnFrequency % 3, 3, 2400f)) + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + randomStreakOffset, rainbowStreakVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, i, ai3); } } } npc.ai[1] += 1f; - extraPhaseTime = (dayTimeEnrage ? 36f : 45f) + 30f * lessTimeSpentPerPhaseMultiplier; + extraPhaseTime = (dayTimeEnrage ? 36f : 72f) + 30f * lessTimeSpentPerPhaseMultiplier; if (npc.ai[1] >= 60f + extraPhaseTime) { npc.ai[0] = 1f; @@ -421,14 +420,14 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { npc.ai[1] += 1f; NPCAimedTarget targetData8 = npc.GetTargetData(); - Vector2 value19 = targetData8.Invalid ? npc.Center : targetData8.Center; - if (npc.Distance(value19 + phase2AnimationDistance) > num2) - npc.SimpleFlyMovement(npc.DirectionTo(value19 + phase2AnimationDistance).SafeNormalize(Vector2.Zero) * scaleFactor, num); + Vector2 targetCenter = targetData8.Invalid ? npc.Center : targetData8.Center; + if (npc.Distance(targetCenter + phase2AnimationDistance) > 0.5f) + npc.SimpleFlyMovement(npc.DirectionTo(targetCenter + phase2AnimationDistance).SafeNormalize(Vector2.Zero) * scaleFactor, 4f); if ((int)npc.ai[1] % 180 == 0) { - Vector2 value20 = new Vector2(0f, -100f); - Projectile.NewProjectile(npc.GetSource_FromAI(), targetData8.Center + value20, Vector2.Zero, ProjectileID.HallowBossDeathAurora, num4, 0f, Main.myPlayer); + Vector2 auroraVector = new Vector2(0f, -100f); + Projectile.NewProjectile(npc.GetSource_FromAI(), targetData8.Center + auroraVector, Vector2.Zero, ProjectileID.HallowBossDeathAurora, magicAmt, 0f, Main.myPlayer); } if (npc.ai[1] >= 120f) @@ -457,47 +456,45 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } NPCAimedTarget targetData10 = npc.GetTargetData(); - Vector2 value24 = targetData10.Invalid ? npc.Center : targetData10.Center; - if (npc.Distance(value24 + etherealLanceDistance) > movementDistanceGateValue) - npc.SimpleFlyMovement(npc.DirectionTo(value24 + etherealLanceDistance).SafeNormalize(Vector2.Zero) * velocity, acceleration); + targetCenter = targetData10.Invalid ? npc.Center : targetData10.Center; + if (npc.Distance(targetCenter + etherealLanceDistance) > movementDistanceGateValue) + npc.SimpleFlyMovement(npc.DirectionTo(targetCenter + etherealLanceDistance).SafeNormalize(Vector2.Zero) * velocity, acceleration); - int num82 = death ? 8 : 12; + int lanceRotation = death ? 8 : 12; if (npc.ai[1] % (dayTimeEnrage ? 2f : 3f) == 0f && npc.ai[1] < 100f) { - int num83 = 1; - for (int n = 0; n < num83; n++) + for (int n = 0; n < 1; n++) { - int num85 = (int)(npc.ai[1] / (dayTimeEnrage ? 2f : 3f)); - Vector2 vector8 = Vector2.UnitX.RotatedBy((float)Math.PI / (num82 * 2) + num85 * ((float)Math.PI / num82)); + int lanceFrequency = (int)(npc.ai[1] / (dayTimeEnrage ? 2f : 3f)); + Vector2 lanceDirection = Vector2.UnitX.RotatedBy((float)Math.PI / (lanceRotation * 2) + lanceFrequency * ((float)Math.PI / lanceRotation)); if (calamityGlobalNPC.newAI[0] == 0f) - vector8.X += (vector8.X > 0f) ? 0.5f : -0.5f; + lanceDirection.X += (lanceDirection.X > 0f) ? 0.5f : -0.5f; - vector8.Normalize(); + lanceDirection.Normalize(); float spawnDistance = 600f; - Vector2 center4 = targetData10.Center; - if (npc.Distance(center4) > 2400f) + Vector2 playerCenter = targetData10.Center; + if (npc.Distance(playerCenter) > 2400f) continue; - if (Vector2.Dot(targetData10.Velocity.SafeNormalize(Vector2.UnitY), vector8) > 0f) - vector8 *= -1f; + if (Vector2.Dot(targetData10.Velocity.SafeNormalize(Vector2.UnitY), lanceDirection) > 0f) + lanceDirection *= -1f; - int num87 = 90; - Vector2 value25 = center4 + targetData10.Velocity * num87; - Vector2 spawnLocation = center4 + vector8 * spawnDistance - targetData10.Velocity * 30f; - if (spawnLocation.Distance(center4) < spawnDistance) + Vector2 targetHoverPos = playerCenter + targetData10.Velocity * 90; + Vector2 spawnLocation = playerCenter + lanceDirection * spawnDistance - targetData10.Velocity * 30f; + if (spawnLocation.Distance(playerCenter) < spawnDistance) { - Vector2 value26 = center4 - spawnLocation; - if (value26 == Vector2.Zero) - value26 = vector8; + Vector2 lanceSpawnDirection = playerCenter - spawnLocation; + if (lanceSpawnDirection == Vector2.Zero) + lanceSpawnDirection = lanceDirection; - spawnLocation = center4 - Vector2.Normalize(value26) * spawnDistance; + spawnLocation = playerCenter - Vector2.Normalize(lanceSpawnDirection) * spawnDistance; } int projectileType = ProjectileID.FairyQueenLance; int projectileDamage = npc.GetProjectileDamage(projectileType) * projectileDamageMultiplier; - Vector2 v3 = value25 - spawnLocation; + Vector2 v3 = targetHoverPos - spawnLocation; if (Main.netMode != NetmodeID.MultiplayerClient) Projectile.NewProjectile(npc.GetSource_FromAI(), spawnLocation, Vector2.Zero, projectileType, projectileDamage, 0f, Main.myPlayer, v3.ToRotation(), npc.ai[1] / 100f); @@ -505,35 +502,35 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses continue; // Spawn extra Ethereal Lances per player. - for (int num89 = 0; num89 < Main.maxPlayers; num89++) + for (int j = 0; j < Main.maxPlayers; j++) { - if (!npc.Boss_CanShootExtraAt(num89, num85 % 3, 3, 2400f)) + if (!npc.Boss_CanShootExtraAt(j, lanceFrequency % 3, 3, 2400f)) continue; - Player player2 = Main.player[num89]; - center4 = player2.Center; - if (Vector2.Dot(player2.velocity.SafeNormalize(Vector2.UnitY), vector8) > 0f) - vector8 *= -1f; + Player extraPlayer = Main.player[j]; + playerCenter = extraPlayer.Center; + if (Vector2.Dot(extraPlayer.velocity.SafeNormalize(Vector2.UnitY), lanceDirection) > 0f) + lanceDirection *= -1f; - Vector2 value27 = center4 + player2.velocity * num87; - spawnLocation = center4 + vector8 * spawnDistance - player2.velocity * 30f; - if (spawnLocation.Distance(center4) < spawnDistance) + Vector2 extraPlayerSpawnLocation = playerCenter + extraPlayer.velocity * 90; + spawnLocation = playerCenter + lanceDirection * spawnDistance - extraPlayer.velocity * 30f; + if (spawnLocation.Distance(playerCenter) < spawnDistance) { - Vector2 value28 = center4 - spawnLocation; - if (value28 == Vector2.Zero) - value28 = vector8; + Vector2 extraPlayerSpawnDirection = playerCenter - spawnLocation; + if (extraPlayerSpawnDirection == Vector2.Zero) + extraPlayerSpawnDirection = lanceDirection; - spawnLocation = center4 - Vector2.Normalize(value28) * spawnDistance; + spawnLocation = playerCenter - Vector2.Normalize(extraPlayerSpawnDirection) * spawnDistance; } - v3 = value27 - spawnLocation; + v3 = extraPlayerSpawnLocation - spawnLocation; Projectile.NewProjectile(npc.GetSource_FromAI(), spawnLocation, Vector2.Zero, projectileType, projectileDamage, 0f, Main.myPlayer, v3.ToRotation(), npc.ai[1] / 100f); } } } npc.ai[1] += 1f; - extraPhaseTime = (dayTimeEnrage ? 24f : 30f) + 20f * lessTimeSpentPerPhaseMultiplier; + extraPhaseTime = (dayTimeEnrage ? 24f : 48f) + 20f * lessTimeSpentPerPhaseMultiplier; if (npc.ai[1] >= 100f + extraPhaseTime) { npc.ai[0] = 1f; @@ -556,19 +553,19 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[1] == 0f) SoundEngine.PlaySound(SoundID.Item163, npc.Center); - Vector2 value16 = new Vector2(55f, -30f); - Vector2 value17 = npc.Center + value16; + Vector2 magicSpawnOffset = new Vector2(55f, -30f); + Vector2 everlastingRainbowSpawn = npc.Center + magicSpawnOffset; if (npc.ai[1] < 42f) - AI_120_HallowBoss_DoMagicEffect(npc.Center + value16, 3, Utils.GetLerpValue(0f, 42f, npc.ai[1], clamped: true), npc); + AI_120_HallowBoss_DoMagicEffect(npc.Center + magicSpawnOffset, 3, Utils.GetLerpValue(0f, 42f, npc.ai[1], clamped: true), npc); NPCAimedTarget targetData7 = npc.GetTargetData(); - Vector2 value18 = targetData7.Invalid ? npc.Center : targetData7.Center; - if (npc.Distance(value18 + everlastingRainbowDistance) > movementDistanceGateValue) - npc.SimpleFlyMovement(npc.DirectionTo(value18 + everlastingRainbowDistance).SafeNormalize(Vector2.Zero) * velocity, acceleration); + targetCenter = targetData7.Invalid ? npc.Center : targetData7.Center; + if (npc.Distance(targetCenter + everlastingRainbowDistance) > movementDistanceGateValue) + npc.SimpleFlyMovement(npc.DirectionTo(targetCenter + everlastingRainbowDistance).SafeNormalize(Vector2.Zero) * velocity, acceleration); if (npc.ai[1] % 42f == 0f && npc.ai[1] < 42f) { - float num64 = (float)Math.PI * 2f * Main.rand.NextFloat(); + float projRotation = (float)Math.PI * 2f * Main.rand.NextFloat(); float totalProjectiles = CalamityWorld.LegendaryMode ? 30f : death ? (dayTimeEnrage ? 22f : 15f) : (dayTimeEnrage ? 18f : 13f); int projIndex = 0; bool inversePhase2SpreadPattern = Main.rand.NextBool(); @@ -577,8 +574,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses int projectileType = ProjectileID.HallowBossLastingRainbow; int projectileDamage = npc.GetProjectileDamage(projectileType) * projectileDamageMultiplier; - float num66 = i; - Vector2 spinningpoint = Vector2.UnitY.RotatedBy((float)Math.PI / 2f + (float)Math.PI * 2f * num66 + num64); + float projRotationMultiplier = i; + Vector2 spinningpoint = Vector2.UnitY.RotatedBy((float)Math.PI / 2f + (float)Math.PI * 2f * projRotationMultiplier + projRotation); float initialVelocity = death ? 2f : 1.75f; if (dayTimeEnrage && projIndex % 2 == 0) @@ -597,14 +594,14 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), value17 + spinningpoint.RotatedBy(-MathHelper.PiOver2) * 30f, spinningpoint * initialVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, 0f, num66); + Projectile.NewProjectile(npc.GetSource_FromAI(), everlastingRainbowSpawn + spinningpoint.RotatedBy(-MathHelper.PiOver2) * 30f, spinningpoint * initialVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, 0f, projRotationMultiplier); projIndex++; } } npc.ai[1] += 1f; - extraPhaseTime = (dayTimeEnrage ? 36f : 45f) + 30f * lessTimeSpentPerPhaseMultiplier; + extraPhaseTime = (dayTimeEnrage ? 36f : 72f) + 30f * lessTimeSpentPerPhaseMultiplier; if (npc.ai[1] >= 72f + extraPhaseTime) { npc.ai[0] = 1f; @@ -627,34 +624,34 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses float sunDanceGateValue = dayTimeEnrage ? 35f : death ? 40f : 50f; float totalSunDancePhaseTime = totalSunDances * sunDanceGateValue; - Vector2 value7 = new Vector2(0f, -100f); - Vector2 position = npc.Center + value7; + Vector2 sunDanceHoverOffset = new Vector2(0f, -100f); + Vector2 position = npc.Center + sunDanceHoverOffset; NPCAimedTarget targetData2 = npc.GetTargetData(); - Vector2 value8 = targetData2.Invalid ? npc.Center : targetData2.Center; - if (npc.Distance(value8 + sunDanceDistance) > movementDistanceGateValue) - npc.SimpleFlyMovement(npc.DirectionTo(value8 + sunDanceDistance).SafeNormalize(Vector2.Zero) * velocity * 0.3f, acceleration * 0.7f); + targetCenter = targetData2.Invalid ? npc.Center : targetData2.Center; + if (npc.Distance(targetCenter + sunDanceDistance) > movementDistanceGateValue) + npc.SimpleFlyMovement(npc.DirectionTo(targetCenter + sunDanceDistance).SafeNormalize(Vector2.Zero) * velocity * 0.3f, acceleration * 0.7f); if (npc.ai[1] % sunDanceGateValue == 0f && npc.ai[1] < totalSunDancePhaseTime) { int projectileType = ProjectileID.FairyQueenSunDance; int projectileDamage = npc.GetProjectileDamage(projectileType) * projectileDamageMultiplier; - int num25 = (int)(npc.ai[1] / sunDanceGateValue); - int num26 = (targetData2.Center.X > npc.Center.X) ? 1 : 0; - float num27 = phase2 ? 8f : 6f; - float num28 = 1f / num27; - for (float num29 = 0f; num29 < 1f; num29 += num28) + int sunDanceExtension = (int)(npc.ai[1] / sunDanceGateValue); + int targetFloatDirection = (targetData2.Center.X > npc.Center.X) ? 1 : 0; + float projAmount = phase2 ? 8f : 6f; + float projRotation = 1f / projAmount; + for (float j = 0f; j < 1f; j += projRotation) { - float num30 = (num29 + num28 * 0.5f + num25 * num28 * 0.5f) % 1f; - float ai = (float)Math.PI * 2f * (num30 + num26); + float projDirection = (j + projRotation * 0.5f + sunDanceExtension * projRotation * 0.5f) % 1f; + float ai = (float)Math.PI * 2f * (projDirection + targetFloatDirection); if (Main.netMode != NetmodeID.MultiplayerClient) Projectile.NewProjectile(npc.GetSource_FromAI(), position, Vector2.Zero, projectileType, projectileDamage, 0f, Main.myPlayer, ai, npc.whoAmI); } } npc.ai[1] += 1f; - extraPhaseTime = 110f + 30f * lessTimeSpentPerPhaseMultiplier; // 112.5 is too little + extraPhaseTime = (dayTimeEnrage ? 110f : 150f) + 30f * lessTimeSpentPerPhaseMultiplier; // 112.5 is too little if (npc.ai[1] >= totalSunDancePhaseTime + extraPhaseTime) { npc.ai[0] = 1f; @@ -697,9 +694,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.Distance(center3) <= 3200f) { Vector2 lanceWallStartingPosition = Vector2.Zero; - Vector2 vector6 = Vector2.UnitY; - float num77 = 0.4f; - float num78 = 1.4f; + Vector2 lanceWallDirection = Vector2.UnitY; + float lanceWallConvergence = 0.4f; + float lanceWallSizeMult = 1.4f; totalProjectiles += 5f; lanceSpacing += 50f; lanceWallSize *= 0.5f; @@ -722,37 +719,37 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses case 0: center3 += new Vector2((0f - lanceWallSize) / 2f, 0f); lanceWallStartingPosition = new Vector2(0f, lanceWallSize); - vector6 = Vector2.UnitX; + lanceWallDirection = Vector2.UnitX; break; case 1: center3 += new Vector2(lanceWallSize / 2f, lanceSpacing / 2f); lanceWallStartingPosition = new Vector2(0f, lanceWallSize); - vector6 = -Vector2.UnitX; + lanceWallDirection = -Vector2.UnitX; break; case 2: - center3 += new Vector2(0f - lanceWallSize, 0f - lanceWallSize) * num77; - lanceWallStartingPosition = new Vector2(lanceWallSize * num78, 0f); - vector6 = new Vector2(1f, 1f); + center3 += new Vector2(0f - lanceWallSize, 0f - lanceWallSize) * lanceWallConvergence; + lanceWallStartingPosition = new Vector2(lanceWallSize * lanceWallSizeMult, 0f); + lanceWallDirection = new Vector2(1f, 1f); break; case 3: - center3 += new Vector2(lanceWallSize * num77 + lanceSpacing / 2f, (0f - lanceWallSize) * num77); - lanceWallStartingPosition = new Vector2((0f - lanceWallSize) * num78, 0f); - vector6 = new Vector2(-1f, 1f); + center3 += new Vector2(lanceWallSize * lanceWallConvergence + lanceSpacing / 2f, (0f - lanceWallSize) * lanceWallConvergence); + lanceWallStartingPosition = new Vector2((0f - lanceWallSize) * lanceWallSizeMult, 0f); + lanceWallDirection = new Vector2(-1f, 1f); break; case 4: - center3 += new Vector2(0f - lanceWallSize, lanceWallSize) * num77; - lanceWallStartingPosition = new Vector2(lanceWallSize * num78, 0f); - vector6 = center3.DirectionTo(targetData9.Center); + center3 += new Vector2(0f - lanceWallSize, lanceWallSize) * lanceWallConvergence; + lanceWallStartingPosition = new Vector2(lanceWallSize * lanceWallSizeMult, 0f); + lanceWallDirection = center3.DirectionTo(targetData9.Center); break; case 5: - center3 += new Vector2(lanceWallSize * num77 + lanceSpacing / 2f, lanceWallSize * num77); - lanceWallStartingPosition = new Vector2((0f - lanceWallSize) * num78, 0f); - vector6 = center3.DirectionTo(targetData9.Center); + center3 += new Vector2(lanceWallSize * lanceWallConvergence + lanceSpacing / 2f, lanceWallSize * lanceWallConvergence); + lanceWallStartingPosition = new Vector2((0f - lanceWallSize) * lanceWallSizeMult, 0f); + lanceWallDirection = center3.DirectionTo(targetData9.Center); break; } @@ -762,12 +759,12 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses for (float i = 0f; i <= 1f; i += 1f / totalProjectiles) { Vector2 spawnLocation = center3 + lanceWallStartingPosition * (i - 0.5f) * (expertAttack ? 1f : 2f); - Vector2 v2 = vector6; + Vector2 v2 = lanceWallDirection; if (expertAttack) { - Vector2 value22 = targetData9.Velocity * 20f * i; - Vector2 value23 = spawnLocation.DirectionTo(targetData9.Center + value22); - v2 = Vector2.Lerp(vector6, value23, 0.75f).SafeNormalize(Vector2.UnitY); + Vector2 lanceWallSpawnPredictiveness = targetData9.Velocity * 20f * i; + Vector2 lanceWallSpawnLocation = spawnLocation.DirectionTo(targetData9.Center + lanceWallSpawnPredictiveness); + v2 = Vector2.Lerp(lanceWallDirection, lanceWallSpawnLocation, 0.75f).SafeNormalize(Vector2.UnitY); } if (Main.netMode != NetmodeID.MultiplayerClient) @@ -784,7 +781,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } npc.ai[1] += 1f; - extraPhaseTime = (dayTimeEnrage ? 24f : 30f) + 20f * lessTimeSpentPerPhaseMultiplier; + extraPhaseTime = (dayTimeEnrage ? 24f : 48f) + 20f * lessTimeSpentPerPhaseMultiplier; if (npc.ai[1] >= lanceWallPhaseTime + extraPhaseTime) { npc.ai[0] = 1f; @@ -804,7 +801,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses takeDamage = !(npc.ai[1] >= 6f) || !(npc.ai[1] <= 40f); - int num32 = (npc.ai[0] != 8f) ? 1 : (-1); + int chargeDirection = (npc.ai[0] != 8f) ? 1 : (-1); AI_120_HallowBoss_DoMagicEffect(npc.Center, 5, Utils.GetLerpValue(40f, 90f, npc.ai[1], clamped: true), npc); @@ -819,7 +816,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses SoundEngine.PlaySound(SoundID.Item160, npc.Center); NPCAimedTarget targetData3 = npc.GetTargetData(); - destination = (targetData3.Invalid ? npc.Center : targetData3.Center) + new Vector2(num32 * -800f, 0f); + destination = (targetData3.Invalid ? npc.Center : targetData3.Center) + new Vector2(chargeDirection * -800f, 0f); npc.SimpleFlyMovement(npc.DirectionTo(destination).SafeNormalize(Vector2.Zero) * velocity, acceleration * 2f); if (npc.ai[1] == chargeGateValue) @@ -862,16 +859,16 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Spawn extra homing Rainbow Streaks per player. if (Main.netMode != NetmodeID.MultiplayerClient) { - int num92 = (int)((npc.ai[1] - chargeGateValue - 1f) / rainbowStreakGateValue); - for (int num93 = 0; num93 < Main.maxPlayers; num93++) + int multiplayerStreakSpawnFrequency = (int)((npc.ai[1] - chargeGateValue - 1f) / rainbowStreakGateValue); + for (int i = 0; i < Main.maxPlayers; i++) { - if (npc.Boss_CanShootExtraAt(num93, num92 % 3, 3, 2400f)) - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, rainbowStreakVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, num93, ai3); + if (npc.Boss_CanShootExtraAt(i, multiplayerStreakSpawnFrequency % 3, 3, 2400f)) + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, rainbowStreakVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, i, ai3); } } } - npc.velocity = Vector2.Lerp(value2: new Vector2(num32 * 70f, 0f), value1: npc.velocity, amount: 0.05f); + npc.velocity = Vector2.Lerp(value2: new Vector2(chargeDirection * 70f, 0f), value1: npc.velocity, amount: 0.05f); if (npc.ai[1] == chargeGateValue + chargeDuration) npc.velocity *= 0.45f; @@ -887,7 +884,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } npc.ai[1] += 1f; - extraPhaseTime = (dayTimeEnrage ? 48f : 60f) * lessTimeSpentPerPhaseMultiplier; + extraPhaseTime = (dayTimeEnrage ? 48f : 96f) * lessTimeSpentPerPhaseMultiplier; if (npc.ai[1] >= 150f + extraPhaseTime) { npc.ai[0] = 1f; @@ -949,9 +946,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } NPCAimedTarget targetData6 = npc.GetTargetData(); - Vector2 value11 = targetData6.Invalid ? npc.Center : targetData6.Center; - if (npc.Distance(value11 + etherealLanceDistance) > movementDistanceGateValue) - npc.SimpleFlyMovement(npc.DirectionTo(value11 + etherealLanceDistance).SafeNormalize(Vector2.Zero) * velocity, acceleration); + targetCenter = targetData6.Invalid ? npc.Center : targetData6.Center; + if (npc.Distance(targetCenter + etherealLanceDistance) > movementDistanceGateValue) + npc.SimpleFlyMovement(npc.DirectionTo(targetCenter + etherealLanceDistance).SafeNormalize(Vector2.Zero) * velocity, acceleration); float etherealLanceGateValue = death ? 5f : 6f; if (dayTimeEnrage) @@ -959,69 +956,66 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[1] % etherealLanceGateValue == 0f && npc.ai[1] < 100f) { - int num59 = 3; - for (int k = 0; k < num59; k++) + for (int k = 0; k < 3; k++) { - Vector2 vector3 = -targetData6.Velocity; - vector3.SafeNormalize(-Vector2.UnitY); + Vector2 inverseTargetVel = -targetData6.Velocity; + inverseTargetVel.SafeNormalize(-Vector2.UnitY); float spawnDistance = 100f + (k * 100f); - Vector2 center2 = targetData6.Center; - if (npc.Distance(center2) > 2400f) + targetCenter = targetData6.Center; + if (npc.Distance(targetCenter) > 2400f) continue; - int num61 = 90; - Vector2 value12 = center2 + targetData6.Velocity * num61; - Vector2 vector4 = center2 + vector3 * spawnDistance; - if (vector4.Distance(center2) < spawnDistance) + Vector2 straightLanceSpawnPredict = targetCenter + targetData6.Velocity * 90; + Vector2 straightLanceSpawnDirection = targetCenter + inverseTargetVel * spawnDistance; + if (straightLanceSpawnDirection.Distance(targetCenter) < spawnDistance) { - Vector2 value13 = center2 - vector4; - if (value13 == Vector2.Zero) - value13 = vector3; + Vector2 straightLanceSpawnLocation = targetCenter - straightLanceSpawnDirection; + if (straightLanceSpawnLocation == Vector2.Zero) + straightLanceSpawnLocation = inverseTargetVel; - vector4 = center2 - Vector2.Normalize(value13) * spawnDistance; + straightLanceSpawnDirection = targetCenter - Vector2.Normalize(straightLanceSpawnLocation) * spawnDistance; } int projectileType = ProjectileID.FairyQueenLance; int projectileDamage = npc.GetProjectileDamage(projectileType) * projectileDamageMultiplier; - Vector2 v = value12 - vector4; + Vector2 v = straightLanceSpawnPredict - straightLanceSpawnDirection; if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), vector4, Vector2.Zero, projectileType, projectileDamage, 0f, Main.myPlayer, v.ToRotation(), npc.ai[1] / 100f); + Projectile.NewProjectile(npc.GetSource_FromAI(), straightLanceSpawnDirection, Vector2.Zero, projectileType, projectileDamage, 0f, Main.myPlayer, v.ToRotation(), npc.ai[1] / 100f); if (Main.netMode == NetmodeID.MultiplayerClient) continue; - int num62 = (int)(npc.ai[1] / etherealLanceGateValue); + int multiplayerExtraStraightLances = (int)(npc.ai[1] / etherealLanceGateValue); for (int l = 0; l < Main.maxPlayers; l++) { - if (!npc.Boss_CanShootExtraAt(l, num62 % 3, 3, 2400f)) + if (!npc.Boss_CanShootExtraAt(l, multiplayerExtraStraightLances % 3, 3, 2400f)) continue; Player player = Main.player[l]; - vector3 = -player.velocity; - vector3.SafeNormalize(-Vector2.UnitY); - center2 = player.Center; - num61 = 90; - Vector2 value14 = center2 + player.velocity * num61; - vector4 = center2 + vector3 * spawnDistance; - if (vector4.Distance(center2) < spawnDistance) + inverseTargetVel = -player.velocity; + inverseTargetVel.SafeNormalize(-Vector2.UnitY); + targetCenter = player.Center; + Vector2 extraPlayerLancePredict = targetCenter + player.velocity * 90; + straightLanceSpawnDirection = targetCenter + inverseTargetVel * spawnDistance; + if (straightLanceSpawnDirection.Distance(targetCenter) < spawnDistance) { - Vector2 value15 = center2 - vector4; - if (value15 == Vector2.Zero) - value15 = vector3; + Vector2 extraPlayerLanceSpawnLocation = targetCenter - straightLanceSpawnDirection; + if (extraPlayerLanceSpawnLocation == Vector2.Zero) + extraPlayerLanceSpawnLocation = inverseTargetVel; - vector4 = center2 - Vector2.Normalize(value15) * spawnDistance; + straightLanceSpawnDirection = targetCenter - Vector2.Normalize(extraPlayerLanceSpawnLocation) * spawnDistance; } - v = value14 - vector4; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector4, Vector2.Zero, projectileType, projectileDamage, 0f, Main.myPlayer, v.ToRotation(), npc.ai[1] / 100f); + v = extraPlayerLancePredict - straightLanceSpawnDirection; + Projectile.NewProjectile(npc.GetSource_FromAI(), straightLanceSpawnDirection, Vector2.Zero, projectileType, projectileDamage, 0f, Main.myPlayer, v.ToRotation(), npc.ai[1] / 100f); } } } npc.ai[1] += 1f; - extraPhaseTime = (dayTimeEnrage ? 24f : 30f) * lessTimeSpentPerPhaseMultiplier; + extraPhaseTime = (dayTimeEnrage ? 24f : 48f) * lessTimeSpentPerPhaseMultiplier; if (npc.ai[1] >= 100f + extraPhaseTime) { npc.ai[0] = 1f; @@ -1037,7 +1031,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Avoid cheap bullshit. npc.damage = 0; - Vector2 value6 = new Vector2(-55f, -30f); + Vector2 projRandomOffset = new Vector2(-55f, -30f); if (npc.ai[1] == 0f) { @@ -1047,24 +1041,24 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.velocity *= 0.95f; - bool flag11 = npc.ai[1] < 60f && npc.ai[1] >= 10f; - if (flag11) - AI_120_HallowBoss_DoMagicEffect(npc.Center + value6, 1, Utils.GetLerpValue(0f, 60f, npc.ai[1], clamped: true), npc); + bool shouldSpawnStreaks = npc.ai[1] < 60f && npc.ai[1] >= 10f; + if (shouldSpawnStreaks) + AI_120_HallowBoss_DoMagicEffect(npc.Center + projRandomOffset, 1, Utils.GetLerpValue(0f, 60f, npc.ai[1], clamped: true), npc); - int num21 = 4; + int stationaryStreakSpawnFrequency = 4; if (dayTimeEnrage) - num21 -= 1; + stationaryStreakSpawnFrequency -= 1; - float num22 = (npc.ai[1] - 10f) / 50f; - if ((int)npc.ai[1] % num21 == 0 && flag11) + float streakHomeTime = (npc.ai[1] - 10f) / 50f; + if ((int)npc.ai[1] % stationaryStreakSpawnFrequency == 0 && shouldSpawnStreaks) { int projectileType = ProjectileID.HallowBossRainbowStreak; int projectileDamage = npc.GetProjectileDamage(projectileType) * projectileDamageMultiplier; - Vector2 vector = new Vector2(0f, death ? -24f : -22f).RotatedBy((float)Math.PI * 2f * num22); + Vector2 vector = new Vector2(0f, death ? -24f : -22f).RotatedBy((float)Math.PI * 2f * streakHomeTime); if (Main.netMode != NetmodeID.MultiplayerClient) { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + value6, vector, projectileType, projectileDamage, 0f, Main.myPlayer, npc.target, num22); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + projRandomOffset, vector, projectileType, projectileDamage, 0f, Main.myPlayer, npc.target, streakHomeTime); if (Main.rand.NextBool(15) && CalamityWorld.LegendaryMode) { Main.projectile[proj].extraUpdates += 1; @@ -1075,17 +1069,17 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Spawn extra homing Rainbow Streaks per player. if (Main.netMode != NetmodeID.MultiplayerClient) { - int num23 = (int)(npc.ai[1] % num21); + int extraStationaryStreakSpawnFrequency = (int)(npc.ai[1] % stationaryStreakSpawnFrequency); for (int j = 0; j < Main.maxPlayers; j++) { - if (npc.Boss_CanShootExtraAt(j, num23 % 3, 3, 2400f)) - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + value6, vector, projectileType, projectileDamage, 0f, Main.myPlayer, j, num22); + if (npc.Boss_CanShootExtraAt(j, extraStationaryStreakSpawnFrequency % 3, 3, 2400f)) + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + projRandomOffset, vector, projectileType, projectileDamage, 0f, Main.myPlayer, j, streakHomeTime); } } } npc.ai[1] += 1f; - extraPhaseTime = (dayTimeEnrage ? 36f : 45f) + 30f * lessTimeSpentPerPhaseMultiplier; + extraPhaseTime = (dayTimeEnrage ? 36f : 72f) + 30f * lessTimeSpentPerPhaseMultiplier; if (npc.ai[1] >= 120f + extraPhaseTime) { npc.ai[0] = 1f; @@ -1114,47 +1108,47 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses visible = false; - bool flag7 = false; - bool flag8 = false; - if (!flag7) + bool trueDespawnFlag = false; + bool shouldDespawn = false; + if (!trueDespawnFlag) { if (npc.AI_120_HallowBoss_IsGenuinelyEnraged() && !bossRush) { if (!Main.dayTime) - flag8 = true; + shouldDespawn = true; if (Main.dayTime && Main.time >= 53400.0) - flag8 = true; + shouldDespawn = true; } - flag7 = flag7 || flag8; + trueDespawnFlag = trueDespawnFlag || shouldDespawn; } - if (!flag7) + if (!trueDespawnFlag) { - bool flag9 = targetData.Invalid || npc.Distance(targetData.Center) > despawnDistanceGateValue; - flag7 = flag7 || flag9; + bool hasNoTarget = targetData.Invalid || npc.Distance(targetData.Center) > despawnDistanceGateValue; + trueDespawnFlag = trueDespawnFlag || hasNoTarget; } - npc.alpha = Utils.Clamp(npc.alpha + flag7.ToDirectionInt() * 5, 0, 255); - bool flag10 = npc.alpha == 0 || npc.alpha == 255; + npc.alpha = Utils.Clamp(npc.alpha + trueDespawnFlag.ToDirectionInt() * 5, 0, 255); + bool alphaExtreme = npc.alpha == 0 || npc.alpha == 255; - int num17 = 5; - for (int i = 0; i < num17; i++) + int despawnDustAmt = 5; + for (int i = 0; i < despawnDustAmt; i++) { - float num18 = MathHelper.Lerp(1.3f, 0.7f, npc.Opacity); + float despawnDustOpacity = MathHelper.Lerp(1.3f, 0.7f, npc.Opacity); Color newColor = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.5f); - int num19 = Dust.NewDust(npc.position - npc.Size * 0.5f, npc.width * 2, npc.height * 2, 267, 0f, 0f, 0, newColor); - Main.dust[num19].position = npc.Center + Main.rand.NextVector2Circular(npc.width, npc.height); - Main.dust[num19].velocity *= Main.rand.NextFloat() * 0.8f; - Main.dust[num19].noGravity = true; - Main.dust[num19].scale = 0.9f + Main.rand.NextFloat() * 1.2f; - Main.dust[num19].fadeIn = 0.4f + Main.rand.NextFloat() * 1.2f * num18; - Main.dust[num19].velocity += Vector2.UnitY * -2f; - Main.dust[num19].scale = 0.35f; - if (num19 != 6000) + int despawnRainbowDust = Dust.NewDust(npc.position - npc.Size * 0.5f, npc.width * 2, npc.height * 2, 267, 0f, 0f, 0, newColor); + Main.dust[despawnRainbowDust].position = npc.Center + Main.rand.NextVector2Circular(npc.width, npc.height); + Main.dust[despawnRainbowDust].velocity *= Main.rand.NextFloat() * 0.8f; + Main.dust[despawnRainbowDust].noGravity = true; + Main.dust[despawnRainbowDust].scale = 0.9f + Main.rand.NextFloat() * 1.2f; + Main.dust[despawnRainbowDust].fadeIn = 0.4f + Main.rand.NextFloat() * 1.2f * despawnDustOpacity; + Main.dust[despawnRainbowDust].velocity += Vector2.UnitY * -2f; + Main.dust[despawnRainbowDust].scale = 0.35f; + if (despawnRainbowDust != 6000) { - Dust dust = Dust.CloneDust(num19); + Dust dust = Dust.CloneDust(despawnRainbowDust); dust.scale /= 2f; dust.fadeIn *= 0.85f; dust.color = new Color(255, 255, 255, 255); @@ -1162,7 +1156,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } npc.ai[1] += 1f; - if (!(npc.ai[1] >= 20f && flag10)) + if (!(npc.ai[1] >= 20f && alphaExtreme)) break; if (npc.alpha == 255) @@ -1200,51 +1194,51 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses private static void AI_120_HallowBoss_DoMagicEffect(Vector2 spot, int effectType, float progress, NPC npc) { - float num = 4f; - float num2 = 1f; + float magicDustSpawnArea = 4f; + float magicDustColorMult = 1f; float fadeIn = 0f; - float num3 = 0.5f; - int num4 = 2; - int num5 = 267; + float magicDustPosChange = 0.5f; + int magicAmt = 2; + int magicDustType = 267; switch (effectType) { case 1: - num2 = 0.5f; + magicDustColorMult = 0.5f; fadeIn = 2f; - num3 = 0f; + magicDustPosChange = 0f; break; case 2: case 4: - num = 50f; - num2 = 0.5f; + magicDustSpawnArea = 50f; + magicDustColorMult = 0.5f; fadeIn = 0f; - num3 = 0f; - num4 = 4; + magicDustPosChange = 0f; + magicAmt = 4; break; case 3: - num = 30f; - num2 = 0.1f; + magicDustSpawnArea = 30f; + magicDustColorMult = 0.1f; fadeIn = 2.5f; - num3 = 0f; + magicDustPosChange = 0f; break; case 5: if (progress == 0f) { - num4 = 0; + magicAmt = 0; } else { - num4 = 5; - num5 = Main.rand.Next(86, 92); + magicAmt = 5; + magicDustType = Main.rand.Next(86, 92); } if (progress >= 1f) - num4 = 0; + magicAmt = 0; break; } - for (int i = 0; i < num4; i++) + for (int i = 0; i < magicAmt; i++) { - Dust dust = Dust.NewDustPerfect(spot, num5, Main.rand.NextVector2CircularEdge(num, num) * (Main.rand.NextFloat() * (1f - num3) + num3), 0, Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.5f), (Main.rand.NextFloat() * 2f + 2f) * num2); + Dust dust = Dust.NewDustPerfect(spot, magicDustType, Main.rand.NextVector2CircularEdge(magicDustSpawnArea, magicDustSpawnArea) * (Main.rand.NextFloat() * (1f - magicDustPosChange) + magicDustPosChange), 0, Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.5f), (Main.rand.NextFloat() * 2f + 2f) * magicDustColorMult); dust.fadeIn = fadeIn; dust.noGravity = true; switch (effectType) @@ -1256,11 +1250,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses dust.scale = 3f * Utils.GetLerpValue(0.7f, 0f, progress, clamped: true) * Utils.GetLerpValue(0f, 0.3f, progress, clamped: true); dust.velocity = ((float)Math.PI * 2f * (i / 4f) + (float)Math.PI / 4f).ToRotationVector2() * 8f * Utils.GetLerpValue(1f, 0f, progress, clamped: true); dust.velocity += npc.velocity * 0.3f; - float num6 = 0f; + float magicDustColorChange = 0f; if (effectType == 4) - num6 = 0.5f; + magicDustColorChange = 0.5f; - dust.color = Main.hslToRgb((i / 5f + num6 + progress * 0.5f) % 1f, 1f, 0.5f); + dust.color = Main.hslToRgb((i / 5f + magicDustColorChange + progress * 0.5f) % 1f, 1f, 0.5f); dust.color.A /= 2; dust.alpha = 127; break; diff --git a/NPCs/VanillaNPCOverrides/Bosses/EyeOfCthulhuAI.cs b/NPCs/VanillaNPCOverrides/Bosses/EyeOfCthulhuAI.cs index 9ba225d43b..64d91c5d5d 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/EyeOfCthulhuAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/EyeOfCthulhuAI.cs @@ -24,7 +24,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses bool phase3 = lifeRatio < 0.65f; bool phase4 = lifeRatio < 0.55f; bool phase5 = lifeRatio < 0.4f; - float num5 = death ? 15f : 20f; + float lineUpDist = death ? 15f : 20f; float enrageScale = bossRush ? 1f : 0f; if (Main.dayTime || bossRush) @@ -44,58 +44,58 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.TargetClosest(); bool dead = Main.player[npc.target].dead; - float num6 = npc.position.X + (npc.width / 2) - Main.player[npc.target].position.X - (Main.player[npc.target].width / 2); - float num7 = npc.position.Y + npc.height - 59f - Main.player[npc.target].position.Y - (Main.player[npc.target].height / 2); - float num8 = (float)Math.Atan2(num7, num6) + MathHelper.PiOver2; + float targetXDistance = npc.position.X + (npc.width / 2) - 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); + float eyeRotation = (float)Math.Atan2(targetYDistance, targetXDistance) + MathHelper.PiOver2; - if (num8 < 0f) - num8 += MathHelper.TwoPi; - else if (num8 > MathHelper.TwoPi) - num8 -= MathHelper.TwoPi; + if (eyeRotation < 0f) + eyeRotation += MathHelper.TwoPi; + else if (eyeRotation > MathHelper.TwoPi) + eyeRotation -= MathHelper.TwoPi; - float num9 = 0f; + float eyeRotationAcceleration = 0f; if (npc.ai[0] == 0f && npc.ai[1] == 0f) - num9 = 0.02f; + eyeRotationAcceleration = 0.02f; if (npc.ai[0] == 0f && npc.ai[1] == 2f && npc.ai[2] > 40f) - num9 = 0.05f; + eyeRotationAcceleration = 0.05f; if (npc.ai[0] == 3f && npc.ai[1] == 0f) - num9 = 0.05f; + eyeRotationAcceleration = 0.05f; if (npc.ai[0] == 3f && npc.ai[1] == 2f && npc.ai[2] > 40f) - num9 = 0.08f; - if (npc.ai[0] == 3f && npc.ai[1] == 4f && npc.ai[2] > num5) - num9 = 0.15f; + eyeRotationAcceleration = 0.08f; + if (npc.ai[0] == 3f && npc.ai[1] == 4f && npc.ai[2] > lineUpDist) + eyeRotationAcceleration = 0.15f; if (npc.ai[0] == 3f && npc.ai[1] == 5f) - num9 = 0.05f; - num9 *= 1.5f; + eyeRotationAcceleration = 0.05f; + eyeRotationAcceleration *= 1.5f; - if (npc.rotation < num8) + if (npc.rotation < eyeRotation) { - if ((num8 - npc.rotation) > MathHelper.Pi) - npc.rotation -= num9; + if ((eyeRotation - npc.rotation) > MathHelper.Pi) + npc.rotation -= eyeRotationAcceleration; else - npc.rotation += num9; + npc.rotation += eyeRotationAcceleration; } - else if (npc.rotation > num8) + else if (npc.rotation > eyeRotation) { - if ((npc.rotation - num8) > MathHelper.Pi) - npc.rotation += num9; + if ((npc.rotation - eyeRotation) > MathHelper.Pi) + npc.rotation += eyeRotationAcceleration; else - npc.rotation -= num9; + npc.rotation -= eyeRotationAcceleration; } - if (npc.rotation > num8 - num9 && npc.rotation < num8 + num9) - npc.rotation = num8; + if (npc.rotation > eyeRotation - eyeRotationAcceleration && npc.rotation < eyeRotation + eyeRotationAcceleration) + npc.rotation = eyeRotation; if (npc.rotation < 0f) npc.rotation += MathHelper.TwoPi; else if (npc.rotation > MathHelper.TwoPi) npc.rotation -= MathHelper.TwoPi; - if (npc.rotation > num8 - num9 && npc.rotation < num8 + num9) - npc.rotation = num8; + if (npc.rotation > eyeRotation - eyeRotationAcceleration && npc.rotation < eyeRotation + eyeRotationAcceleration) + npc.rotation = eyeRotation; if (Main.rand.NextBool(5)) { - int num10 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + npc.height * 0.25f), npc.width, (int)(npc.height * 0.5f), 5, npc.velocity.X, 2f, 0, default, 1f); - Dust dust = Main.dust[num10]; + int randomBlood = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + npc.height * 0.25f), npc.width, (int)(npc.height * 0.5f), 5, npc.velocity.X, 2f, 0, default, 1f); + Dust dust = Main.dust[randomBlood]; dust.velocity.X *= 0.5f; dust.velocity.Y *= 0.1f; } @@ -134,8 +134,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.SimpleFlyMovement(idealVelocity, hoverAcceleration); npc.ai[2] += 1f; - float num17 = 180f - (death ? 200f * (1f - lifeRatio) : 0f); - if (npc.ai[2] >= num17) + float attackSwitchTimer = 180f - (death ? 200f * (1f - lifeRatio) : 0f); + if (npc.ai[2] >= attackSwitchTimer) { npc.ai[1] = 1f; npc.ai[2] = 0f; @@ -155,7 +155,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[3] >= servantSpawnGateValue) { npc.ai[3] = 0f; - npc.rotation = num8; + npc.rotation = eyeRotation; Vector2 servantSpawnVelocity = npc.SafeDirectionTo(Main.player[npc.target].Center) * 6f; Vector2 servantSpawnCenter = npc.Center + servantSpawnVelocity * 10f; @@ -170,18 +170,18 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses SoundEngine.PlaySound(SoundID.NPCHit1, servantSpawnCenter); - int num; - for (int m = 0; m < 10; m = num + 1) + int servantDust; + for (int m = 0; m < 10; m = servantDust + 1) { Dust.NewDust(servantSpawnCenter, 20, 20, 5, servantSpawnVelocity.X * 0.4f, servantSpawnVelocity.Y * 0.4f, 0, default, 1f); - num = m; + servantDust = m; } } } } else if (npc.ai[1] == 1f) { - npc.rotation = num8; + npc.rotation = eyeRotation; float chargeSpeed = 8f; chargeSpeed += 5f * enrageScale; if (death) @@ -214,18 +214,18 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses else npc.rotation = npc.velocity.ToRotation() - MathHelper.PiOver2; - int num28 = 90; + int chargeDelay = 90; if (death) - num28 -= (int)Math.Round(120f * (1f - lifeRatio)); + chargeDelay -= (int)Math.Round(120f * (1f - lifeRatio)); if (Main.getGoodWorld) - num28 -= 15; + chargeDelay -= 15; - if (npc.ai[2] >= num28) + if (npc.ai[2] >= chargeDelay) { npc.ai[3] += 1f; npc.ai[2] = 0f; npc.TargetClosest(); - npc.rotation = num8; + npc.rotation = eyeRotation; if (npc.ai[3] >= 3f) { @@ -280,12 +280,12 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses Vector2 servantSpawnCenter = npc.Center + servantSpawnVelocity * 10f; if (Main.netMode != NetmodeID.MultiplayerClient) { - int num34 = NPC.NewNPC(npc.GetSource_FromAI(), (int)servantSpawnCenter.X, (int)servantSpawnCenter.Y, NPCID.ServantofCthulhu, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[num34].velocity.X = servantSpawnVelocity.X; - Main.npc[num34].velocity.Y = servantSpawnVelocity.Y; + int servantSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)servantSpawnCenter.X, (int)servantSpawnCenter.Y, NPCID.ServantofCthulhu, 0, 0f, 0f, 0f, 0f, 255); + Main.npc[servantSpawn].velocity.X = servantSpawnVelocity.X; + Main.npc[servantSpawn].velocity.Y = servantSpawnVelocity.Y; - if (Main.netMode == NetmodeID.Server && num34 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num34, 0f, 0f, 0f, 0, 0, 0); + if (Main.netMode == NetmodeID.Server && servantSpawn < Main.maxNPCs) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, servantSpawn, 0f, 0f, 0f, 0, 0, 0); if (CalamityWorld.LegendaryMode) { @@ -323,7 +323,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.netMode != NetmodeID.Server) { - for (int num35 = 0; num35 < 2; num35++) + for (int phase2Gore = 0; phase2Gore < 2; phase2Gore++) { Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 8, 1f); Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 7, 1f); @@ -331,7 +331,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } } - for (int num36 = 0; num36 < 20; num36++) + for (int i = 0; i < 20; i++) { Dust.NewDust(npc.position, npc.width, npc.height, 5, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); } @@ -417,7 +417,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses else if (npc.ai[1] == 1f) { SoundEngine.PlaySound(SoundID.ForceRoar, npc.position); - npc.rotation = num8; + npc.rotation = eyeRotation; float chargeSpeed = 6.2f + 4f * (0.75f - lifeRatio); chargeSpeed += 4f * enrageScale; @@ -440,10 +440,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses else if (npc.ai[1] == 2f) { - float num46 = 60f; - npc.ai[2] += 1f; - if (npc.ai[2] >= num46) + if (npc.ai[2] >= 60f) { npc.velocity *= 0.96f; if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) @@ -454,16 +452,16 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses else npc.rotation = npc.velocity.ToRotation() - MathHelper.PiOver2; - int num47 = 80; + int phase2ChargeDelay = 80; if (death) - num47 -= (int)Math.Round(40f * (0.75f - lifeRatio)); + phase2ChargeDelay -= (int)Math.Round(40f * (0.75f - lifeRatio)); - if (npc.ai[2] >= num47) + if (npc.ai[2] >= phase2ChargeDelay) { npc.ai[3] += 1f; npc.ai[2] = 0f; npc.TargetClosest(); - npc.rotation = num8; + npc.rotation = eyeRotation; if (npc.ai[3] >= 3f) { @@ -500,68 +498,68 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses else if (Main.netMode != NetmodeID.MultiplayerClient) { float speedBoost = death ? 5f * (0.65f - lifeRatio) : 3.5f * (0.65f - lifeRatio); - float num48 = 18f + speedBoost; - num48 += 10f * enrageScale; + float finalChargeSpeed = 18f + speedBoost; + finalChargeSpeed += 10f * enrageScale; - Vector2 vector10 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num49 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector10.X; - float num50 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector10.Y; - float num51 = Math.Abs(Main.player[npc.target].velocity.X) + Math.Abs(Main.player[npc.target].velocity.Y) / 4f; - num51 += 10f - num51; + Vector2 eyeChargeDirection = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float targetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - eyeChargeDirection.X; + float targetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - eyeChargeDirection.Y; + float targetVelocity = Math.Abs(Main.player[npc.target].velocity.X) + Math.Abs(Main.player[npc.target].velocity.Y) / 4f; + targetVelocity += 10f - targetVelocity; - if (num51 < 5f) - num51 = 5f; - if (num51 > 15f) - num51 = 15f; + if (targetVelocity < 5f) + targetVelocity = 5f; + if (targetVelocity > 15f) + targetVelocity = 15f; if (npc.ai[2] == -1f) { - num51 *= 4f; - num48 *= 1.3f; + targetVelocity *= 4f; + finalChargeSpeed *= 1.3f; } - num49 -= Main.player[npc.target].velocity.X * num51; - num50 -= Main.player[npc.target].velocity.Y * num51 / 4f; - num49 *= 1f + Main.rand.Next(-10, 11) * 0.01f; - num50 *= 1f + Main.rand.Next(-10, 11) * 0.01f; + targetX -= Main.player[npc.target].velocity.X * targetVelocity; + targetY -= Main.player[npc.target].velocity.Y * targetVelocity / 4f; + targetX *= 1f + Main.rand.Next(-10, 11) * 0.01f; + targetY *= 1f + Main.rand.Next(-10, 11) * 0.01f; - float num52 = (float)Math.Sqrt(num49 * num49 + num50 * num50); - float num53 = num52; + float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); + float targetDistCopy = targetDistance; - num52 = num48 / num52; - npc.velocity.X = num49 * num52; - npc.velocity.Y = num50 * num52; + targetDistance = finalChargeSpeed / targetDistance; + npc.velocity.X = targetX * targetDistance; + npc.velocity.Y = targetY * targetDistance; npc.velocity.X += Main.rand.Next(-20, 21) * 0.1f; npc.velocity.Y += Main.rand.Next(-20, 21) * 0.1f; - if (num53 < 100f) + if (targetDistCopy < 100f) { if (Math.Abs(npc.velocity.X) > Math.Abs(npc.velocity.Y)) { - float num56 = Math.Abs(npc.velocity.X); - float num57 = Math.Abs(npc.velocity.Y); + float absoluteXVel = Math.Abs(npc.velocity.X); + float absoluteYVel = Math.Abs(npc.velocity.Y); if (npc.Center.X > Main.player[npc.target].Center.X) - num57 *= -1f; + absoluteYVel *= -1f; if (npc.Center.Y > Main.player[npc.target].Center.Y) - num56 *= -1f; + absoluteXVel *= -1f; - npc.velocity.X = num57; - npc.velocity.Y = num56; + npc.velocity.X = absoluteYVel; + npc.velocity.Y = absoluteXVel; } } else if (Math.Abs(npc.velocity.X) > Math.Abs(npc.velocity.Y)) { - float num58 = (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) / 2f; - float num59 = num58; + float absoluteEyeVel = (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) / 2f; + float absoluteEyeVelBackup = absoluteEyeVel; if (npc.Center.X > Main.player[npc.target].Center.X) - num59 *= -1f; + absoluteEyeVelBackup *= -1f; if (npc.Center.Y > Main.player[npc.target].Center.Y) - num58 *= -1f; + absoluteEyeVel *= -1f; - npc.velocity.X = num59; - npc.velocity.Y = num58; + npc.velocity.X = absoluteEyeVelBackup; + npc.velocity.Y = absoluteEyeVel; } npc.ai[1] = 4f; @@ -577,13 +575,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[2] == 0f) SoundEngine.PlaySound(SoundID.ForceRoar, npc.position); - float num60 = num5; + float lineUpDistControl = lineUpDist; npc.ai[2] += 1f; - if (npc.ai[2] == num60 && Vector2.Distance(npc.position, Main.player[npc.target].position) < 200f) + if (npc.ai[2] == lineUpDistControl && Vector2.Distance(npc.position, Main.player[npc.target].position) < 200f) npc.ai[2] -= 1f; - if (npc.ai[2] >= num60) + if (npc.ai[2] >= lineUpDistControl) { npc.velocity *= 0.95f; if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) @@ -594,8 +592,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses else npc.rotation = npc.velocity.ToRotation() - MathHelper.PiOver2; - float num61 = num60 + 13f; - if (npc.ai[2] >= num61) + float lineUpDistNetUpdate = lineUpDistControl + 13f; + if (npc.ai[2] >= lineUpDistNetUpdate) { npc.netUpdate = true; @@ -624,9 +622,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses float hoverSpeed = 8f + speedBoost; float hoverAcceleration = 0.25f + accelerationBoost; - Vector2 vector11 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num65 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector11.X; - float num66 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) + offset - vector11.Y; + Vector2 eyeLineUpChargeDirection = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float lineUpChargeTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - eyeLineUpChargeDirection.X; + float lineUpChargeTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) + offset - eyeLineUpChargeDirection.Y; Vector2 hoverDestination = Main.player[npc.target].Center + Vector2.UnitY * offset; bool horizontalCharge = calamityGlobalNPC.newAI[0] == 1f || calamityGlobalNPC.newAI[0] == 3f; @@ -739,13 +737,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[2] == 0f) SoundEngine.PlaySound(SoundID.Roar, npc.position); - float num60 = (float)Math.Round(num5 * 2.5f); + float lineUpDistControl = (float)Math.Round(lineUpDist * 2.5f); npc.ai[2] += 1f; - if (npc.ai[2] == num60 && Vector2.Distance(npc.position, Main.player[npc.target].position) < 200f) + if (npc.ai[2] == lineUpDistControl && Vector2.Distance(npc.position, Main.player[npc.target].position) < 200f) npc.ai[2] -= 1f; - if (npc.ai[2] >= num60) + if (npc.ai[2] >= lineUpDistControl) { npc.velocity *= 0.95f; if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) @@ -756,8 +754,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses else npc.rotation = npc.velocity.ToRotation() - MathHelper.PiOver2; - float num61 = num60 + 13f; - if (npc.ai[2] >= num61) + float lineUpDistNetUpdate = lineUpDistControl + 13f; + if (npc.ai[2] >= lineUpDistNetUpdate) { npc.netUpdate = true; diff --git a/NPCs/VanillaNPCOverrides/Bosses/GolemAI.cs b/NPCs/VanillaNPCOverrides/Bosses/GolemAI.cs index 9758dde5b4..22d960ce8d 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/GolemAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/GolemAI.cs @@ -59,10 +59,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses bool turboEnrage = false; if (Main.player[npc.target].Center.Y > Main.worldSurface * 16.0) { - int num = (int)Main.player[npc.target].Center.X / 16; - int num2 = (int)Main.player[npc.target].Center.Y / 16; + int targetTilePosX = (int)Main.player[npc.target].Center.X / 16; + int targetTilePosY = (int)Main.player[npc.target].Center.Y / 16; - Tile tile = Framing.GetTileSafely(num, num2); + Tile tile = Framing.GetTileSafely(targetTilePosX, targetTilePosY); if (tile.WallType == WallID.LihzahrdBrickUnsafe) enrage = false; else @@ -89,13 +89,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Check for body parts - bool flag40 = NPC.AnyNPCs(NPCID.GolemHead); - bool flag41 = NPC.AnyNPCs(NPCID.GolemFistLeft); - bool flag42 = NPC.AnyNPCs(NPCID.GolemFistRight); - npc.dontTakeDamage = (flag40 || flag41 || flag42) && !CalamityWorld.LegendaryMode; + bool headAlive = NPC.AnyNPCs(NPCID.GolemHead); + bool leftFistAlive = NPC.AnyNPCs(NPCID.GolemFistLeft); + bool rightFistAlive = NPC.AnyNPCs(NPCID.GolemFistRight); + npc.dontTakeDamage = (headAlive || leftFistAlive || rightFistAlive) && !CalamityWorld.LegendaryMode; // Phase 2, check for free head - bool flag43 = NPC.AnyNPCs(NPCID.GolemHeadFree); + bool freedHeadAlive = NPC.AnyNPCs(NPCID.GolemHeadFree); // Deactivate torches if (Main.netMode != NetmodeID.MultiplayerClient && Main.getGoodWorld && npc.velocity.Y > 0f) @@ -117,10 +117,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Spawn arm dust if (!Main.getGoodWorld) { - if (!flag41) + if (!leftFistAlive) { - int num642 = Dust.NewDust(new Vector2(npc.Center.X - 80f, npc.Center.Y - 9f), 8, 8, 31, 0f, 0f, 100, default, 1f); - Dust dust = Main.dust[num642]; + int lostLeftFistDust = Dust.NewDust(new Vector2(npc.Center.X - 80f, npc.Center.Y - 9f), 8, 8, 31, 0f, 0f, 100, default, 1f); + Dust dust = Main.dust[lostLeftFistDust]; dust.alpha += Main.rand.Next(100); dust.velocity *= 0.2f; dust.velocity.Y -= 0.5f + Main.rand.Next(10) * 0.1f; @@ -128,20 +128,20 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.rand.NextBool(10)) { - num642 = Dust.NewDust(new Vector2(npc.Center.X - 80f, npc.Center.Y - 9f), 8, 8, 6, 0f, 0f, 0, default, 1f); + lostLeftFistDust = Dust.NewDust(new Vector2(npc.Center.X - 80f, npc.Center.Y - 9f), 8, 8, 6, 0f, 0f, 0, default, 1f); if (Main.rand.Next(20) != 0) { - Main.dust[num642].noGravity = true; - dust = Main.dust[num642]; + Main.dust[lostLeftFistDust].noGravity = true; + dust = Main.dust[lostLeftFistDust]; dust.scale *= 1f + Main.rand.Next(10) * 0.1f; dust.velocity.Y -= 1f; } } } - if (!flag42) + if (!rightFistAlive) { - int num643 = Dust.NewDust(new Vector2(npc.Center.X + 62f, npc.Center.Y - 9f), 8, 8, 31, 0f, 0f, 100, default, 1f); - Dust dust = Main.dust[num643]; + int lostRightFistDust = Dust.NewDust(new Vector2(npc.Center.X + 62f, npc.Center.Y - 9f), 8, 8, 31, 0f, 0f, 100, default, 1f); + Dust dust = Main.dust[lostRightFistDust]; dust.alpha += Main.rand.Next(100); dust.velocity *= 0.2f; dust.velocity.Y -= 0.5f + Main.rand.Next(10) * 0.1f; @@ -149,11 +149,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.rand.NextBool(10)) { - num643 = Dust.NewDust(new Vector2(npc.Center.X + 62f, npc.Center.Y - 9f), 8, 8, 6, 0f, 0f, 0, default, 1f); + lostRightFistDust = Dust.NewDust(new Vector2(npc.Center.X + 62f, npc.Center.Y - 9f), 8, 8, 6, 0f, 0f, 0, default, 1f); if (Main.rand.Next(20) != 0) { - Main.dust[num643].noGravity = true; - dust = Main.dust[num643]; + Main.dust[lostRightFistDust].noGravity = true; + dust = Main.dust[lostRightFistDust]; dust.scale *= 1f + Main.rand.Next(10) * 0.1f; dust.velocity.Y -= 1f; } @@ -175,7 +175,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.velocity.Y == 0f) { // Laser fire when head is dead - if (Main.netMode != NetmodeID.MultiplayerClient && (!flag40 || turboEnrage || CalamityWorld.LegendaryMode)) + if (Main.netMode != NetmodeID.MultiplayerClient && (!headAlive || turboEnrage || CalamityWorld.LegendaryMode)) { npc.localAI[1] += 1f; @@ -190,28 +190,28 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (turboEnrage && Main.getGoodWorld) divisor = 2f; - Vector2 vector82 = new Vector2(npc.Center.X, npc.Center.Y - 60f); - if (npc.localAI[1] % divisor == 0f && (Vector2.Distance(Main.player[npc.target].Center, vector82) > 160f || !flag43)) + Vector2 projectileFirePos = new Vector2(npc.Center.X, npc.Center.Y - 60f); + if (npc.localAI[1] % divisor == 0f && (Vector2.Distance(Main.player[npc.target].Center, projectileFirePos) > 160f || !freedHeadAlive)) { - float num673 = turboEnrage ? 12f : enrage ? 9f : 6f; - float num674 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector82.X; - float num675 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector82.Y; - float num676 = (float)Math.Sqrt(num674 * num674 + num675 * num675); + float laserSpeed = turboEnrage ? 12f : enrage ? 9f : 6f; + float laserTargetXDist = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - projectileFirePos.X; + float laserTargetYDist = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - projectileFirePos.Y; + float laserTargetDistance = (float)Math.Sqrt(laserTargetXDist * laserTargetXDist + laserTargetYDist * laserTargetYDist); - num676 = num673 / num676; - num674 *= num676; - num675 *= num676; - vector82.X += num674 * 3f; - vector82.Y += num675 * 3f; + laserTargetDistance = laserSpeed / laserTargetDistance; + laserTargetXDist *= laserTargetDistance; + laserTargetYDist *= laserTargetDistance; + projectileFirePos.X += laserTargetXDist * 3f; + projectileFirePos.Y += laserTargetYDist * 3f; int type = ProjectileID.EyeBeam; int damage = npc.GetProjectileDamage(type); if (Main.netMode != NetmodeID.MultiplayerClient) { - int num677 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector82.X, vector82.Y, num674, num675, type, damage, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[num677].timeLeft = 480; + int bodyLaser = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileFirePos.X, projectileFirePos.Y, laserTargetXDist, laserTargetYDist, type, damage, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[bodyLaser].timeLeft = 480; if (turboEnrage && Main.getGoodWorld) - Main.projectile[num677].extraUpdates += 1; + Main.projectile[bodyLaser].extraUpdates += 1; } } @@ -233,11 +233,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.ai[1] += 18f; else { - if (!flag41) + if (!leftFistAlive) npc.ai[1] += 6f; - if (!flag42) + if (!rightFistAlive) npc.ai[1] += 6f; - if (!flag40) + if (!headAlive) npc.ai[1] += 6f; } } @@ -266,7 +266,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses float speedMult = 1f; float multiplier = turboEnrage ? 0.0025f : enrage ? 0.002f : 0.0015f; - if (distanceBelowTarget > 0f && ((!flag41 && !flag42) || turboEnrage || CalamityWorld.LegendaryMode)) + if (distanceBelowTarget > 0f && ((!leftFistAlive && !rightFistAlive) || turboEnrage || CalamityWorld.LegendaryMode)) speedMult += distanceBelowTarget * multiplier; float speedMultLimit = turboEnrage ? 3.5f : enrage ? 3f : 2.5f; @@ -274,7 +274,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses speedMult = speedMultLimit; if (Main.player[npc.target].position.Y < npc.Bottom.Y) - npc.velocity.Y = ((((!flag43 && !flag40) || turboEnrage || CalamityWorld.LegendaryMode) ? -15.1f : -12.1f) + (enrage ? -4f : 0f)) * speedMult; + npc.velocity.Y = ((((!freedHeadAlive && !headAlive) || turboEnrage || CalamityWorld.LegendaryMode) ? -15.1f : -12.1f) + (enrage ? -4f : 0f)) * speedMult; else npc.velocity.Y = 1f; @@ -308,43 +308,43 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.SyncExtraAI(); // Dust and gore - for (int num644 = (int)npc.position.X - 20; num644 < (int)npc.position.X + npc.width + 40; num644 += 20) + for (int i = (int)npc.position.X - 20; i < (int)npc.position.X + npc.width + 40; i += 20) { - for (int num645 = 0; num645 < 4; num645++) + for (int j = 0; j < 4; j++) { - int num646 = Dust.NewDust(new Vector2(npc.position.X - 20f, npc.position.Y + npc.height), npc.width + 20, 4, 31, 0f, 0f, 100, default, 1.5f); - Dust dust = Main.dust[num646]; + int fallDust = Dust.NewDust(new Vector2(npc.position.X - 20f, npc.position.Y + npc.height), npc.width + 20, 4, 31, 0f, 0f, 100, default, 1.5f); + Dust dust = Main.dust[fallDust]; dust.velocity *= 0.2f; } if (Main.netMode != NetmodeID.Server) { - int num647 = Gore.NewGore(npc.GetSource_FromAI(), new Vector2(num644 - 20, npc.position.Y + npc.height - 8f), default, Main.rand.Next(61, 64), 1f); - Gore gore = Main.gore[num647]; + int fallGore = Gore.NewGore(npc.GetSource_FromAI(), new Vector2(i - 20, npc.position.Y + npc.height - 8f), default, Main.rand.Next(61, 64), 1f); + Gore gore = Main.gore[fallGore]; gore.velocity *= 0.4f; } } // Fireball explosion when head is dead - if (Main.netMode != NetmodeID.MultiplayerClient && (!flag40 || turboEnrage || CalamityWorld.LegendaryMode)) + if (Main.netMode != NetmodeID.MultiplayerClient && (!headAlive || turboEnrage || CalamityWorld.LegendaryMode)) { - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Torch, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity.Y *= 6f; - Main.dust[num622].velocity.X *= 3f; + int fiery = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Torch, 0f, 0f, 100, default, 2f); + Main.dust[fiery].velocity.Y *= 6f; + Main.dust[fiery].velocity.X *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[fiery].scale = 0.5f; + Main.dust[fiery].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Torch, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity.Y *= 10f; - num624 = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Torch, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity.X *= 2f; + int fiery2 = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Torch, 0f, 0f, 100, default, 3f); + Main.dust[fiery2].noGravity = true; + Main.dust[fiery2].velocity.Y *= 10f; + fiery2 = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Torch, 0f, 0f, 100, default, 2f); + Main.dust[fiery2].velocity.X *= 2f; } int totalFireballs = 5; @@ -426,8 +426,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses void CustomGravity() { - float gravity = turboEnrage ? (Main.getGoodWorld ? 1.2f : 0.9f) : enrage ? 0.6f : (!flag41 && !flag42) ? 0.45f : 0.3f; - float maxFallSpeed = reduceFallSpeed ? 12f : turboEnrage ? (Main.getGoodWorld ? 40f : 30f) : enrage ? 20f : (!flag41 && !flag42) ? 15f : 10f; + float gravity = turboEnrage ? (Main.getGoodWorld ? 1.2f : 0.9f) : enrage ? 0.6f : (!leftFistAlive && !rightFistAlive) ? 0.45f : 0.3f; + float maxFallSpeed = reduceFallSpeed ? 12f : turboEnrage ? (Main.getGoodWorld ? 40f : 30f) : enrage ? 20f : (!leftFistAlive && !rightFistAlive) ? 15f : 10f; npc.velocity.Y += gravity; if (npc.velocity.Y > maxFallSpeed) @@ -435,12 +435,12 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Despawn - int num649 = turboEnrage ? 7500 : enrage ? 6000 : 4500; - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) + Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > num649) + int despawnDistance = turboEnrage ? 7500 : enrage ? 6000 : 4500; + if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) + Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > despawnDistance) { npc.TargetClosest(); - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) + Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > num649) + if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) + Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > despawnDistance) { npc.active = false; npc.netUpdate = true; @@ -461,10 +461,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses bool turboEnrage = false; if (Main.player[npc.target].Center.Y > Main.worldSurface * 16.0) { - int num = (int)Main.player[npc.target].Center.X / 16; - int num2 = (int)Main.player[npc.target].Center.Y / 16; + int targetTilePosX = (int)Main.player[npc.target].Center.X / 16; + int targetTilePosY = (int)Main.player[npc.target].Center.Y / 16; - Tile tile = Framing.GetTileSafely(num, num2); + Tile tile = Framing.GetTileSafely(targetTilePosX, targetTilePosY); if (tile.WallType == WallID.LihzahrdBrickUnsafe) enrage = false; else @@ -499,30 +499,30 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { npc.noTileCollide = true; - float num723 = 25f; - num723 *= (aggression + 3f) / 4f; + float fistSpeed = 25f; + fistSpeed *= (aggression + 3f) / 4f; - Vector2 vector80 = new Vector2(npc.Center.X, npc.Center.Y); - float num724 = Main.npc[NPC.golemBoss].Center.X - vector80.X; - float num725 = Main.npc[NPC.golemBoss].Center.Y - vector80.Y; - num725 -= 9f; - num724 = (npc.type != NPCID.GolemFistLeft) ? (num724 + 78f) : (num724 - 84f); + Vector2 fistCenter = new Vector2(npc.Center.X, npc.Center.Y); + float fistXPos = Main.npc[NPC.golemBoss].Center.X - fistCenter.X; + float fistYPos = Main.npc[NPC.golemBoss].Center.Y - fistCenter.Y; + fistYPos -= 9f; + fistXPos = (npc.type != NPCID.GolemFistLeft) ? (fistXPos + 78f) : (fistXPos - 84f); if (Main.getGoodWorld) - num724 = (npc.type != NPCID.GolemFistLeft) ? (num724 - 40f) : (num724 + 40f); + fistXPos = (npc.type != NPCID.GolemFistLeft) ? (fistXPos - 40f) : (fistXPos + 40f); - float num726 = (float)Math.Sqrt(num724 * num724 + num725 * num725); - if (num726 < 12f + num723) + float fistRestDistance = (float)Math.Sqrt(fistXPos * fistXPos + fistYPos * fistYPos); + if (fistRestDistance < 12f + fistSpeed) { npc.rotation = 0f; - npc.velocity.X = num724; - npc.velocity.Y = num725; + npc.velocity.X = fistXPos; + npc.velocity.Y = fistYPos; - float num727 = aggression; - npc.ai[1] += num727; + float fistShootSpeed = aggression; + npc.ai[1] += fistShootSpeed; if (npc.life < npc.lifeMax / 2) - npc.ai[1] += num727; + npc.ai[1] += fistShootSpeed; if (npc.life < npc.lifeMax / 4) - npc.ai[1] += num727; + npc.ai[1] += fistShootSpeed; if (npc.ai[1] >= 40f) { @@ -539,9 +539,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } else { - num726 = num723 / num726; - npc.velocity.X = num724 * num726; - npc.velocity.Y = num725 * num726; + fistRestDistance = fistSpeed / fistRestDistance; + npc.velocity.X = fistXPos * fistRestDistance; + npc.velocity.Y = fistYPos * fistRestDistance; npc.rotation = (float)Math.Atan2(0f - npc.velocity.Y, 0f - npc.velocity.X); if (npc.type == NPCID.GolemFistLeft) @@ -550,26 +550,26 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } else if (npc.ai[0] == 1f) { - Vector2 vector80 = new Vector2(npc.Center.X, npc.Center.Y); - float num724 = Main.npc[NPC.golemBoss].Center.X - vector80.X; - float num725 = Main.npc[NPC.golemBoss].Center.Y - vector80.Y; - num725 -= 9f; - num724 = (npc.type != NPCID.GolemFistLeft) ? (num724 + 78f) : (num724 - 84f); + Vector2 fistCenter = new Vector2(npc.Center.X, npc.Center.Y); + float fistXPos = Main.npc[NPC.golemBoss].Center.X - fistCenter.X; + float fistYPos = Main.npc[NPC.golemBoss].Center.Y - fistCenter.Y; + fistYPos -= 9f; + fistXPos = (npc.type != NPCID.GolemFistLeft) ? (fistXPos + 78f) : (fistXPos - 84f); if (Main.getGoodWorld) - num724 = (npc.type != NPCID.GolemFistLeft) ? (num724 - 40f) : (num724 + 40f); + fistXPos = (npc.type != NPCID.GolemFistLeft) ? (fistXPos - 40f) : (fistXPos + 40f); npc.ai[1] += 1f; - npc.Center = new Vector2(num724, num725); + npc.Center = new Vector2(fistXPos, fistYPos); npc.rotation = 0f; npc.velocity = Vector2.Zero; if (npc.ai[1] <= 15f) { for (int i = 0; i < 1; i++) { - Vector2 vector3 = Main.rand.NextVector2Circular(80f, 80f); - Vector2 vector4 = vector3 * -1f * 0.05f; - Vector2 vector5 = Main.rand.NextVector2Circular(20f, 20f); - Dust dust = Dust.NewDustPerfect(npc.Center + vector4 + vector3 + vector5, 228, vector4); + Vector2 largeRandDustRadius = Main.rand.NextVector2Circular(80f, 80f); + Vector2 largeRandDustRecoil = largeRandDustRadius * -1f * 0.05f; + Vector2 smallRandDustRadius = Main.rand.NextVector2Circular(20f, 20f); + Dust dust = Dust.NewDustPerfect(npc.Center + largeRandDustRecoil + largeRandDustRadius + smallRandDustRadius, 228, largeRandDustRecoil); dust.fadeIn = 1.5f; dust.scale = 0.5f; if (Main.getGoodWorld) @@ -585,18 +585,18 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.collideX = false; npc.collideY = false; - float num728 = 20f; - num728 *= (aggression + 3f) / 4f; - if (num728 > 48f) - num728 = 48f; + float fistReturnSpeed = 20f; + fistReturnSpeed *= (aggression + 3f) / 4f; + if (fistReturnSpeed > 48f) + fistReturnSpeed = 48f; - Vector2 vector81 = new Vector2(npc.Center.X, npc.Center.Y); - float num729 = Main.player[npc.target].Center.X - vector81.X; - float num730 = Main.player[npc.target].Center.Y - vector81.Y; - float num731 = (float)Math.Sqrt(num729 * num729 + num730 * num730); - num731 = num728 / num731; - npc.velocity.X = num729 * num731; - npc.velocity.Y = num730 * num731; + Vector2 fistCent = new Vector2(npc.Center.X, npc.Center.Y); + float fistTargetXDist = Main.player[npc.target].Center.X - fistCent.X; + float fistTargetYDist = Main.player[npc.target].Center.Y - fistCent.Y; + float fistTargetDistance = (float)Math.Sqrt(fistTargetXDist * fistTargetXDist + fistTargetYDist * fistTargetYDist); + fistTargetDistance = fistReturnSpeed / fistTargetDistance; + npc.velocity.X = fistTargetXDist * fistTargetDistance; + npc.velocity.Y = fistTargetYDist * fistTargetDistance; npc.ai[0] = 2f; npc.ai[1] = 0f; @@ -629,9 +629,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.rand.NextBool()) { - Vector2 vector7 = npc.velocity * 0.5f; - Vector2 vector8 = Main.rand.NextVector2Circular(20f, 20f); - Dust.NewDustPerfect(npc.Center + vector7 + vector8, 306, vector7, 0, Main.OurFavoriteColor).scale = 2f; + Vector2 halfVelocityDust = npc.velocity * 0.5f; + Vector2 randDustRadius = Main.rand.NextVector2Circular(20f, 20f); + Dust.NewDustPerfect(npc.Center + halfVelocityDust + randDustRadius, 306, halfVelocityDust, 0, Main.OurFavoriteColor).scale = 2f; } if (Math.Abs(npc.velocity.X) > Math.Abs(npc.velocity.Y)) @@ -651,20 +651,20 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.noTileCollide = false; } - Vector2 vector82 = new Vector2(npc.Center.X, npc.Center.Y); - float num732 = Main.npc[NPC.golemBoss].Center.X - vector82.X; - float num733 = Main.npc[NPC.golemBoss].Center.Y - vector82.Y; - num732 += Main.npc[NPC.golemBoss].velocity.X; - num733 += Main.npc[NPC.golemBoss].velocity.Y; - num733 -= 9f; - num732 = (npc.type != NPCID.GolemFistLeft) ? (num732 + 78f) : (num732 - 84f); - float num734 = (float)Math.Sqrt(num732 * num732 + num733 * num733); + Vector2 projectileFirePos = new Vector2(npc.Center.X, npc.Center.Y); + float fistGolemDistanceX = Main.npc[NPC.golemBoss].Center.X - projectileFirePos.X; + float fistGolemDistanceY = Main.npc[NPC.golemBoss].Center.Y - projectileFirePos.Y; + fistGolemDistanceX += Main.npc[NPC.golemBoss].velocity.X; + fistGolemDistanceY += Main.npc[NPC.golemBoss].velocity.Y; + fistGolemDistanceY -= 9f; + fistGolemDistanceX = (npc.type != NPCID.GolemFistLeft) ? (fistGolemDistanceX + 78f) : (fistGolemDistanceX - 84f); + float fistGolemDistance = (float)Math.Sqrt(fistGolemDistanceX * fistGolemDistanceX + fistGolemDistanceY * fistGolemDistanceY); if (npc.life < npc.lifeMax / 4) { npc.knockBackResist = 0f; - if (num734 > 700f || npc.collideX || npc.collideY) + if (fistGolemDistance > 700f || npc.collideX || npc.collideY) { npc.noTileCollide = true; npc.ai[0] = 0f; @@ -673,19 +673,19 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses return false; } - bool flag41 = npc.justHit; - if (flag41) + bool leftFistAlive = npc.justHit; + if (leftFistAlive) { if (npc.life < npc.lifeMax / 2) { if (npc.knockBackResist == 0f) - flag41 = false; + leftFistAlive = false; npc.knockBackResist = 0f; } } - if ((num734 > 600f || npc.collideX || npc.collideY) | flag41) + if ((fistGolemDistance > 600f || npc.collideX || npc.collideY) | leftFistAlive) { npc.noTileCollide = true; npc.ai[0] = 0f; @@ -697,40 +697,39 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses return false; npc.noTileCollide = true; - float num736 = 12f; - float num737 = 0.4f; - Vector2 vector83 = new Vector2(npc.Center.X, npc.Center.Y); - float num738 = Main.player[npc.target].Center.X - vector83.X; - float num739 = Main.player[npc.target].Center.Y - vector83.Y; - float num740 = (float)Math.Sqrt(num738 * num738 + num739 * num739); - num740 = num736 / num740; - num738 *= num740; - num739 *= num740; + float fistAcceleration = 0.4f; + Vector2 returningFistCenter = new Vector2(npc.Center.X, npc.Center.Y); + float returningTargetX = Main.player[npc.target].Center.X - returningFistCenter.X; + float returningTargetY = Main.player[npc.target].Center.Y - returningFistCenter.Y; + float returningTargetDist = (float)Math.Sqrt(returningTargetX * returningTargetX + returningTargetY * returningTargetY); + returningTargetDist = 12f / returningTargetDist; + returningTargetX *= returningTargetDist; + returningTargetY *= returningTargetDist; - if (npc.velocity.X < num738) + if (npc.velocity.X < returningTargetX) { - npc.velocity.X += num737; - if (npc.velocity.X < 0f && num738 > 0f) - npc.velocity.X += num737 * 2f; + npc.velocity.X += fistAcceleration; + if (npc.velocity.X < 0f && returningTargetX > 0f) + npc.velocity.X += fistAcceleration * 2f; } - else if (npc.velocity.X > num738) + else if (npc.velocity.X > returningTargetX) { - npc.velocity.X -= num737; - if (npc.velocity.X > 0f && num738 < 0f) - npc.velocity.X -= num737 * 2f; + npc.velocity.X -= fistAcceleration; + if (npc.velocity.X > 0f && returningTargetX < 0f) + npc.velocity.X -= fistAcceleration * 2f; } - if (npc.velocity.Y < num739) + if (npc.velocity.Y < returningTargetY) { - npc.velocity.Y += num737; - if (npc.velocity.Y < 0f && num739 > 0f) - npc.velocity.Y += num737 * 2f; + npc.velocity.Y += fistAcceleration; + if (npc.velocity.Y < 0f && returningTargetY > 0f) + npc.velocity.Y += fistAcceleration * 2f; } - else if (npc.velocity.Y > num739) + else if (npc.velocity.Y > returningTargetY) { - npc.velocity.Y -= num737; - if (npc.velocity.Y > 0f && num739 < 0f) - npc.velocity.Y -= num737 * 2f; + npc.velocity.Y -= fistAcceleration; + if (npc.velocity.Y > 0f && returningTargetY < 0f) + npc.velocity.Y -= fistAcceleration * 2f; } npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); @@ -771,9 +770,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses bool death = CalamityWorld.death || bossRush; // Count body parts - bool flag41 = NPC.AnyNPCs(NPCID.GolemFistLeft); - bool flag42 = NPC.AnyNPCs(NPCID.GolemFistRight); - npc.dontTakeDamage = (flag41 || flag42) && !CalamityWorld.LegendaryMode; + bool leftFistAlive = NPC.AnyNPCs(NPCID.GolemFistLeft); + bool rightFistAlive = NPC.AnyNPCs(NPCID.GolemFistRight); + npc.dontTakeDamage = (leftFistAlive || rightFistAlive) && !CalamityWorld.LegendaryMode; // Stay in position on top of body npc.Center = Main.npc[NPC.golemBoss].Center - new Vector2(Main.getGoodWorld ? 2f : 3f, Main.getGoodWorld ? 37f : 57f); @@ -783,10 +782,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses bool turboEnrage = false; if (Main.player[npc.target].Center.Y > Main.worldSurface * 16.0) { - int num = (int)Main.player[npc.target].Center.X / 16; - int num2 = (int)Main.player[npc.target].Center.Y / 16; + int targetTilePosX = (int)Main.player[npc.target].Center.X / 16; + int targetTilePosY = (int)Main.player[npc.target].Center.Y / 16; - Tile tile = Framing.GetTileSafely(num, num2); + Tile tile = Framing.GetTileSafely(targetTilePosX, targetTilePosY); if (tile.WallType == WallID.LihzahrdBrickUnsafe) enrage = false; else @@ -812,31 +811,30 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[0] == 0f) { npc.ai[1] += 1f; - int num654 = 150; - if (npc.ai[1] < 20f || npc.ai[1] > (num654 - 20)) + if (npc.ai[1] < 20f || npc.ai[1] > 130) npc.localAI[0] = 1f; else npc.localAI[0] = 0f; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] >= num654) + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] >= 150) { npc.TargetClosest(); npc.ai[1] = 0f; - Vector2 vector81 = new Vector2(npc.Center.X, npc.Center.Y + 10f); - float num655 = turboEnrage ? 12f : enrage ? 10f : 8f; - float num656 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector81.X; - float num657 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector81.Y; - float num658 = (float)Math.Sqrt(num656 * num656 + num657 * num657); + Vector2 headCent = new Vector2(npc.Center.X, npc.Center.Y + 10f); + float headFireballSpeed = turboEnrage ? 12f : enrage ? 10f : 8f; + float headFireballTargetX = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - headCent.X; + float headFireballTargetY = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - headCent.Y; + float headFireballTargetDist = (float)Math.Sqrt(headFireballTargetX * headFireballTargetX + headFireballTargetY * headFireballTargetY); - num658 = num655 / num658; - num656 *= num658; - num657 *= num658; + headFireballTargetDist = headFireballSpeed / headFireballTargetDist; + headFireballTargetX *= headFireballTargetDist; + headFireballTargetY *= headFireballTargetDist; int type = ProjectileID.Fireball; int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector81.X, vector81.Y, num656, num657, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), headCent.X, headCent.Y, headFireballTargetX, headFireballTargetY, type, damage, 0f, Main.myPlayer, 0f, 0f); npc.netUpdate = true; } @@ -846,16 +844,16 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses else if (npc.ai[0] == 1f) { // Fire projectiles from eye positions - Vector2 vector82 = new Vector2(npc.Center.X, npc.Center.Y + 10f); + Vector2 projectileFirePos = new Vector2(npc.Center.X, npc.Center.Y + 10f); if (Main.player[npc.target].Center.X < npc.Center.X - npc.width) { npc.localAI[1] = -1f; - vector82.X -= 40f; + projectileFirePos.X -= 40f; } else if (Main.player[npc.target].Center.X > npc.Center.X + npc.width) { npc.localAI[1] = 1f; - vector82.X += 40f; + projectileFirePos.X += 40f; } else npc.localAI[1] = 0f; @@ -864,30 +862,29 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses float shootBoost = death ? 3f * (1f - lifeRatio) : 2f * (1f - lifeRatio); npc.ai[1] += 1f + shootBoost; - int num662 = 240; - if (npc.ai[1] < 20f || npc.ai[1] > (num662 - 20)) + if (npc.ai[1] < 20f || npc.ai[1] > 220) npc.localAI[0] = 1f; else npc.localAI[0] = 0f; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] >= num662) + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] >= 240) { npc.TargetClosest(); npc.ai[1] = 0f; - float num663 = turboEnrage ? 16f : enrage ? 14f : 12f; - float num664 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector82.X; - float num665 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector82.Y; - float num666 = (float)Math.Sqrt(num664 * num664 + num665 * num665); + float fireballSpeedFistsDed = turboEnrage ? 16f : enrage ? 14f : 12f; + float fireballFistsDedTargetX = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - projectileFirePos.X; + float fireballFistsDedTargetY = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - projectileFirePos.Y; + float fireballFistsDedTargetDist = (float)Math.Sqrt(fireballFistsDedTargetX * fireballFistsDedTargetX + fireballFistsDedTargetY * fireballFistsDedTargetY); - num666 = num663 / num666; - num664 *= num666; - num665 *= num666; + fireballFistsDedTargetDist = fireballSpeedFistsDed / fireballFistsDedTargetDist; + fireballFistsDedTargetX *= fireballFistsDedTargetDist; + fireballFistsDedTargetY *= fireballFistsDedTargetDist; int type = ProjectileID.Fireball; int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector82.X, vector82.Y, num664, num665, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), projectileFirePos.X, projectileFirePos.Y, fireballFistsDedTargetX, fireballFistsDedTargetY, type, damage, 0f, Main.myPlayer, 0f, 0f); npc.netUpdate = true; } @@ -911,34 +908,34 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.localAI[1] == 0f) { - for (int num672 = 0; num672 < 2; num672++) + for (int i = 0; i < 2; i++) { - vector82 = new Vector2(npc.Center.X, npc.Center.Y - 22f); - if (num672 == 0) - vector82.X -= 18f; + projectileFirePos = new Vector2(npc.Center.X, npc.Center.Y - 22f); + if (i == 0) + projectileFirePos.X -= 18f; else - vector82.X += 18f; + projectileFirePos.X += 18f; - float num673 = 9f; + float laserSpeed = 9f; if (!Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - num673 = 14f; + laserSpeed = 14f; - float num674 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector82.X; - float num675 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector82.Y; - float num676 = (float)Math.Sqrt(num674 * num674 + num675 * num675); + float laserTargetXDist = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - projectileFirePos.X; + float laserTargetYDist = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - projectileFirePos.Y; + float laserTargetDistance = (float)Math.Sqrt(laserTargetXDist * laserTargetXDist + laserTargetYDist * laserTargetYDist); - num676 = num673 / num676; - num674 *= num676; - num675 *= num676; - vector82.X += num674 * 3f; - vector82.Y += num675 * 3f; + laserTargetDistance = laserSpeed / laserTargetDistance; + laserTargetXDist *= laserTargetDistance; + laserTargetYDist *= laserTargetDistance; + projectileFirePos.X += laserTargetXDist * 3f; + projectileFirePos.Y += laserTargetYDist * 3f; if (Main.netMode != NetmodeID.MultiplayerClient) { - int num677 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector82.X, vector82.Y, num674, num675, projType, dmg, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[num677].timeLeft = enrage ? 480 : 300; + int bodyLaser = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileFirePos.X, projectileFirePos.Y, laserTargetXDist, laserTargetYDist, projType, dmg, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[bodyLaser].timeLeft = enrage ? 480 : 300; if (turboEnrage && Main.getGoodWorld) - Main.projectile[num677].extraUpdates += 1; + Main.projectile[bodyLaser].extraUpdates += 1; npc.netUpdate = true; } @@ -946,32 +943,32 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } else if (npc.localAI[1] != 0f) { - vector82 = new Vector2(npc.Center.X, npc.Center.Y - 22f); + projectileFirePos = new Vector2(npc.Center.X, npc.Center.Y - 22f); if (npc.localAI[1] == -1f) - vector82.X -= 30f; + projectileFirePos.X -= 30f; else if (npc.localAI[1] == 1f) - vector82.X += 30f; + projectileFirePos.X += 30f; - float num678 = 9f; + float extraLaserSpeed = 9f; if (!Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - num678 = 14f; + extraLaserSpeed = 14f; - float num679 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector82.X; - float num680 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector82.Y; - float num681 = (float)Math.Sqrt(num679 * num679 + num680 * num680); + float extraLaserTargetX = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - projectileFirePos.X; + float extraLaserTargetY = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - projectileFirePos.Y; + float extraLaserTargetDist = (float)Math.Sqrt(extraLaserTargetX * extraLaserTargetX + extraLaserTargetY * extraLaserTargetY); - num681 = num678 / num681; - num679 *= num681; - num680 *= num681; - vector82.X += num679 * 3f; - vector82.Y += num680 * 3f; + extraLaserTargetDist = extraLaserSpeed / extraLaserTargetDist; + extraLaserTargetX *= extraLaserTargetDist; + extraLaserTargetY *= extraLaserTargetDist; + projectileFirePos.X += extraLaserTargetX * 3f; + projectileFirePos.Y += extraLaserTargetY * 3f; if (Main.netMode != NetmodeID.MultiplayerClient) { - int num682 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector82.X, vector82.Y, num679, num680, projType, dmg, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[num682].timeLeft = enrage ? 480 : 300; + int extraLasers = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileFirePos.X, projectileFirePos.Y, extraLaserTargetX, extraLaserTargetY, projType, dmg, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[extraLasers].timeLeft = enrage ? 480 : 300; if (turboEnrage && Main.getGoodWorld) - Main.projectile[num682].extraUpdates += 1; + Main.projectile[extraLasers].extraUpdates += 1; npc.netUpdate = true; } @@ -980,7 +977,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Laser fire if arms are dead - if ((!flag41 && !flag42) || death || CalamityWorld.LegendaryMode) + if ((!leftFistAlive && !rightFistAlive) || death || CalamityWorld.LegendaryMode) { npc.ai[0] = 1f; return false; @@ -1031,10 +1028,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses bool turboEnrage = false; if (Main.player[npc.target].Center.Y > Main.worldSurface * 16.0) { - int num = (int)Main.player[npc.target].Center.X / 16; - int num2 = (int)Main.player[npc.target].Center.Y / 16; + int targetTilePosX = (int)Main.player[npc.target].Center.X / 16; + int targetTilePosY = (int)Main.player[npc.target].Center.Y / 16; - Tile tile = Framing.GetTileSafely(num, num2); + Tile tile = Framing.GetTileSafely(targetTilePosX, targetTilePosY); if (tile.WallType == WallID.LihzahrdBrickUnsafe) enrage = false; else @@ -1054,11 +1051,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Float through tiles or not - bool flag44 = false; + bool canPassThroughTiles = false; if (!Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1) || phase3 || turboEnrage) { npc.noTileCollide = true; - flag44 = true; + canPassThroughTiles = true; } else npc.noTileCollide = false; @@ -1153,7 +1150,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses float acceleration = enrage ? 0.4f : phase3 ? 0.2f : phase2 ? 0.15f : 0.1f; - // How far Ceaseless Void is from where it's supposed to be + // How far is from where it's supposed to be Vector2 distanceFromDestination = destination - npc.Center; CalamityUtils.SmoothMovement(npc, 0f, distanceFromDestination, velocity, acceleration, true); @@ -1175,34 +1172,33 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses float shootBoost = death ? 3f * (2f - (lifeRatio + golemLifeRatio)) : 2f * (2f - (lifeRatio + golemLifeRatio)); npc.ai[1] += 1f + shootBoost; - int num705 = 360; - if (npc.ai[1] < 20f || npc.ai[1] > (num705 - 20)) + if (npc.ai[1] < 20f || npc.ai[1] > 340) npc.localAI[0] = 1f; else npc.localAI[0] = 0f; - if (flag44 && !phase3) + if (canPassThroughTiles && !phase3) npc.ai[1] = 20f; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] >= num705 && Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 160f) + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] >= 360 && Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 160f) { npc.TargetClosest(); npc.ai[1] = 0f; - Vector2 vector88 = new Vector2(npc.Center.X, npc.Center.Y - 10f); - float num706 = turboEnrage ? 8f : enrage ? 6.5f : 5f; - float num709 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector88.X; - float num710 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector88.Y; - float num711 = (float)Math.Sqrt(num709 * num709 + num710 * num710); + Vector2 freeHeadCenter = new Vector2(npc.Center.X, npc.Center.Y - 10f); + float freeHeadSpeed = turboEnrage ? 8f : enrage ? 6.5f : 5f; + float freeHeadTargetX = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - freeHeadCenter.X; + float freeHeadTargetY = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - freeHeadCenter.Y; + float freeHeadTargetDist = (float)Math.Sqrt(freeHeadTargetX * freeHeadTargetX + freeHeadTargetY * freeHeadTargetY); - num711 = num706 / num711; - num709 *= num711; - num710 *= num711; + freeHeadTargetDist = freeHeadSpeed / freeHeadTargetDist; + freeHeadTargetX *= freeHeadTargetDist; + freeHeadTargetY *= freeHeadTargetDist; int projectileType = phase3 ? ProjectileID.InfernoHostileBolt : ProjectileID.Fireball; int damage = npc.GetProjectileDamage(projectileType); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), vector88.X, vector88.Y, num709, num710, projectileType, damage, 0f, Main.myPlayer, 0f, 0f); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), freeHeadCenter.X, freeHeadCenter.Y, freeHeadTargetX, freeHeadTargetY, projectileType, damage, 0f, Main.myPlayer, 0f, 0f); if (projectileType == ProjectileID.InfernoHostileBolt) { Main.projectile[proj].timeLeft = 300; @@ -1225,50 +1221,50 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.ai[2] = 0f; - for (int num713 = 0; num713 < 2; num713++) + for (int i = 0; i < 2; i++) { - Vector2 vector89 = new Vector2(npc.Center.X, npc.Center.Y - 50f); + Vector2 freeHeadProjSpawn = new Vector2(npc.Center.X, npc.Center.Y - 50f); if (Main.getGoodWorld) - vector89.Y += 30f; - if (num713 == 0) - vector89.X -= 14f; - else if (num713 == 1) - vector89.X += 14f; + freeHeadProjSpawn.Y += 30f; + if (i == 0) + freeHeadProjSpawn.X -= 14f; + else if (i == 1) + freeHeadProjSpawn.X += 14f; - float num714 = 5f + shootBoost; - float num717 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector89.X; - float num718 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector89.Y; - float num719 = (float)Math.Sqrt(num717 * num717 + num718 * num718); + float freeHeadProjSpeed = 5f + shootBoost; + float freeHeadProjTargetX = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - freeHeadProjSpawn.X; + float freeHeadProjTargetY = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - freeHeadProjSpawn.Y; + float freeHeadProjTargetDist = (float)Math.Sqrt(freeHeadProjTargetX * freeHeadProjTargetX + freeHeadProjTargetY * freeHeadProjTargetY); - num719 = num714 / num719; - num717 *= num719; - num718 *= num719; - vector89.X += num717 * 3f; - vector89.Y += num718 * 3f; + freeHeadProjTargetDist = freeHeadProjSpeed / freeHeadProjTargetDist; + freeHeadProjTargetX *= freeHeadProjTargetDist; + freeHeadProjTargetY *= freeHeadProjTargetDist; + freeHeadProjSpawn.X += freeHeadProjTargetX * 3f; + freeHeadProjSpawn.Y += freeHeadProjTargetY * 3f; int type = ProjectileID.EyeBeam; int damage = npc.GetProjectileDamage(type); - int num720 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector89.X, vector89.Y, num717, num718, type, damage, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[num720].timeLeft = enrage ? 480 : 300; + int freeHeadLaser = Projectile.NewProjectile(npc.GetSource_FromAI(), freeHeadProjSpawn.X, freeHeadProjSpawn.Y, freeHeadProjTargetX, freeHeadProjTargetY, type, damage, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[freeHeadLaser].timeLeft = enrage ? 480 : 300; if (turboEnrage && Main.getGoodWorld) - Main.projectile[num720].extraUpdates += 1; + Main.projectile[freeHeadLaser].extraUpdates += 1; } } if (!Main.getGoodWorld) { npc.position += npc.netOffset; - int num765 = Main.rand.Next(2) * 2 - 1; - Vector2 vector95 = npc.Bottom + new Vector2((float)(num765 * 22) * npc.scale, -22f * npc.scale); - Dust dust5 = Dust.NewDustPerfect(vector95, 228, ((float)Math.PI / 2f + -(float)Math.PI / 2f * (float)num765 + Main.rand.NextFloatDirection() * ((float)Math.PI / 4f)).ToRotationVector2() * (2f + Main.rand.NextFloat())); - Dust dust = dust5; + int randDustOffset = Main.rand.Next(2) * 2 - 1; + Vector2 randDustPos = npc.Bottom + new Vector2((float)(randDustOffset * 22) * npc.scale, -22f * npc.scale); + Dust getGoodDust = Dust.NewDustPerfect(randDustPos, 228, ((float)Math.PI / 2f + -(float)Math.PI / 2f * (float)randDustOffset + Main.rand.NextFloatDirection() * ((float)Math.PI / 4f)).ToRotationVector2() * (2f + Main.rand.NextFloat())); + Dust dust = getGoodDust; dust.velocity += npc.velocity; - dust5.noGravity = true; - dust5 = Dust.NewDustPerfect(npc.Bottom + new Vector2(Main.rand.NextFloatDirection() * 6f * npc.scale, (Main.rand.NextFloat() * -4f - 8f) * npc.scale), 228, Vector2.UnitY * (2f + Main.rand.NextFloat())); - dust5.fadeIn = 0f; - dust5.scale = 0.7f + Main.rand.NextFloat() * 0.5f; - dust5.noGravity = true; - dust = dust5; + getGoodDust.noGravity = true; + getGoodDust = Dust.NewDustPerfect(npc.Bottom + new Vector2(Main.rand.NextFloatDirection() * 6f * npc.scale, (Main.rand.NextFloat() * -4f - 8f) * npc.scale), 228, Vector2.UnitY * (2f + Main.rand.NextFloat())); + getGoodDust.fadeIn = 0f; + getGoodDust.scale = 0.7f + Main.rand.NextFloat() * 0.5f; + getGoodDust.noGravity = true; + dust = getGoodDust; dust.velocity += npc.velocity; npc.position -= npc.netOffset; } diff --git a/NPCs/VanillaNPCOverrides/Bosses/KingSlimeAI.cs b/NPCs/VanillaNPCOverrides/Bosses/KingSlimeAI.cs index 9c90497a5c..9956468308 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/KingSlimeAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/KingSlimeAI.cs @@ -18,15 +18,15 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses float lifeRatio = npc.life / (float)npc.lifeMax; // Variables - float num234 = 1f; + float teleportScale = 1f; bool teleporting = false; - bool flag9 = false; + bool teleported = false; npc.aiAction = 0; - float num237 = 2f; + float teleportScaleSpeed = 2f; if (Main.getGoodWorld) { - num237 -= 1f - lifeRatio; - num234 *= num237; + teleportScaleSpeed -= 1f - lifeRatio; + teleportScale *= teleportScaleSpeed; } // Reset damage @@ -53,15 +53,15 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.Calamity().newAI[0] = 1f; npc.SyncExtraAI(); Vector2 vector = npc.Center + new Vector2(-40f, -(float)npc.height / 2); - for (int num621 = 0; num621 < 20; num621++) + for (int i = 0; i < 20; i++) { - int num622 = Dust.NewDust(vector, npc.width / 2, npc.height / 2, 90, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 2f; - Main.dust[num622].noGravity = true; + int rubyDust = Dust.NewDust(vector, npc.width / 2, npc.height / 2, 90, 0f, 0f, 100, default, 2f); + Main.dust[rubyDust].velocity *= 2f; + Main.dust[rubyDust].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].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, npc.position); @@ -160,13 +160,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses teleporting = true; npc.aiAction = 1; npc.ai[0] += 1f; - num234 = MathHelper.Clamp((60f - npc.ai[0]) / 60f, 0f, 1f); - num234 = 0.5f + num234 * 0.5f; + teleportScale = MathHelper.Clamp((60f - npc.ai[0]) / 60f, 0f, 1f); + teleportScale = 0.5f + teleportScale * 0.5f; if (Main.getGoodWorld) - num234 *= num237; + teleportScale *= teleportScaleSpeed; if (npc.ai[0] >= 60f) - flag9 = true; + teleported = true; if (npc.ai[0] == 60f && Main.netMode != NetmodeID.Server) Gore.NewGore(npc.GetSource_FromAI(), npc.Center + new Vector2(-40f, -(float)npc.height / 2), npc.velocity, 734, 1f); @@ -185,13 +185,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.ai[0] = 0f; } - if (!flag9) + if (!teleported) { - for (int num245 = 0; num245 < 10; num245++) + for (int i = 0; i < 10; i++) { - int num246 = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, 4, npc.velocity.X, npc.velocity.Y, 150, new Color(78, 136, 255, 80), 2f); - Main.dust[num246].noGravity = true; - dust = Main.dust[num246]; + int slimeDust = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, 4, npc.velocity.X, npc.velocity.Y, 150, new Color(78, 136, 255, 80), 2f); + Main.dust[slimeDust].noGravity = true; + dust = Main.dust[slimeDust]; dust.velocity *= 0.5f; } } @@ -206,10 +206,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses teleporting = true; npc.aiAction = 0; npc.ai[0] += 1f; - num234 = MathHelper.Clamp(npc.ai[0] / 30f, 0f, 1f); - num234 = 0.5f + num234 * 0.5f; + teleportScale = MathHelper.Clamp(npc.ai[0] / 30f, 0f, 1f); + teleportScale = 0.5f + teleportScale * 0.5f; if (Main.getGoodWorld) - num234 *= num237; + teleportScale *= teleportScaleSpeed; if (npc.ai[0] >= 30f && Main.netMode != NetmodeID.MultiplayerClient) { @@ -226,17 +226,17 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.TargetClosest(); } - for (int num247 = 0; num247 < 10; num247++) + for (int j = 0; j < 10; j++) { - int num248 = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, 4, npc.velocity.X, npc.velocity.Y, 150, new Color(78, 136, 255, 80), 2f); - Main.dust[num248].noGravity = true; - dust = Main.dust[num248]; + int slimyDust = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, 4, npc.velocity.X, npc.velocity.Y, 150, new Color(78, 136, 255, 80), 2f); + Main.dust[slimyDust].noGravity = true; + dust = Main.dust[slimyDust]; dust.velocity *= 2f; } } // Don't take damage while teleporting - npc.dontTakeDamage = npc.hide = flag9; + npc.dontTakeDamage = npc.hide = teleported; npc.noTileCollide = false; @@ -324,11 +324,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Change jump velocity else if (npc.target < Main.maxPlayers) { - float num252 = 3f; + float jumpVelocityMult = 3f; if (Main.getGoodWorld) - num252 = 6f; + jumpVelocityMult = 6f; - if ((npc.direction == 1 && npc.velocity.X < num252) || (npc.direction == -1 && npc.velocity.X > 0f - num252)) + if ((npc.direction == 1 && npc.velocity.X < jumpVelocityMult) || (npc.direction == -1 && npc.velocity.X > 0f - jumpVelocityMult)) { if ((npc.direction == -1 && npc.velocity.X < 0.1) || (npc.direction == 1 && npc.velocity.X > -0.1)) npc.velocity.X += (bossRush ? 0.4f : death ? 0.25f : 0.2f) * npc.direction; @@ -348,9 +348,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Spawn dust - int num249 = Dust.NewDust(npc.position, npc.width, npc.height, 4, npc.velocity.X, npc.velocity.Y, 255, new Color(0, 80, 255, 80), npc.scale * 1.2f); - Main.dust[num249].noGravity = true; - dust = Main.dust[num249]; + int idleSlimeDust = Dust.NewDust(npc.position, npc.width, npc.height, 4, npc.velocity.X, npc.velocity.Y, 255, new Color(0, 80, 255, 80), npc.scale * 1.2f); + Main.dust[idleSlimeDust].noGravity = true; + dust = Main.dust[idleSlimeDust]; dust.velocity *= 0.5f; if (npc.life <= 0) @@ -360,7 +360,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses float maxScale = death ? (Main.getGoodWorld ? 6f : 3f) : (Main.getGoodWorld ? 3f : 1.25f); float minScale = 0.75f; lifeRatio = lifeRatio * (maxScale - minScale) + minScale; - lifeRatio *= num234; + lifeRatio *= teleportScale; if (lifeRatio != npc.scale) { npc.position.X += npc.width / 2; @@ -375,12 +375,12 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Slime spawning if (Main.netMode != NetmodeID.MultiplayerClient) { - int num251 = (int)(npc.lifeMax * 0.05); - if (npc.life + num251 < npc.ai[3]) + int slimeSpawnThreshold = (int)(npc.lifeMax * 0.05); + if (npc.life + slimeSpawnThreshold < npc.ai[3]) { npc.ai[3] = npc.life; - int num252 = Main.rand.Next(2, 4); - for (int num253 = 0; num253 < num252; num253++) + int slimeAmt = Main.rand.Next(2, 4); + for (int i = 0; i < slimeAmt; i++) { int x = (int)(npc.position.X + Main.rand.Next(npc.width - 32)); int y = (int)(npc.position.Y + Main.rand.Next(npc.height - 32)); @@ -431,15 +431,15 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (CalamityWorld.LegendaryMode) npcType = NPCID.RainbowSlime; - int num255 = NPC.NewNPC(npc.GetSource_FromAI(), x, y, npcType); - Main.npc[num255].SetDefaults(npcType); - Main.npc[num255].velocity.X = Main.rand.Next(-15, 16) * 0.1f; - Main.npc[num255].velocity.Y = Main.rand.Next(-30, 1) * 0.1f; - Main.npc[num255].ai[0] = -1000 * Main.rand.Next(3); - Main.npc[num255].ai[1] = 0f; + int slimeSpawns = NPC.NewNPC(npc.GetSource_FromAI(), x, y, npcType); + Main.npc[slimeSpawns].SetDefaults(npcType); + Main.npc[slimeSpawns].velocity.X = Main.rand.Next(-15, 16) * 0.1f; + Main.npc[slimeSpawns].velocity.Y = Main.rand.Next(-30, 1) * 0.1f; + Main.npc[slimeSpawns].ai[0] = -1000 * Main.rand.Next(3); + Main.npc[slimeSpawns].ai[1] = 0f; - if (Main.netMode == NetmodeID.Server && num255 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num255, 0f, 0f, 0f, 0, 0, 0); + if (Main.netMode == NetmodeID.Server && slimeSpawns < Main.maxNPCs) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawns, 0f, 0f, 0f, 0, 0, 0); } } } @@ -450,34 +450,34 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { npc.TargetClosest(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 point4 = vectorAimedAheadOfTarget.ToTileCoordinates(); - int num235 = 5; - int num238 = 0; - while (num238 < 100) + Point predictiveTeleportPoint = vectorAimedAheadOfTarget.ToTileCoordinates(); + int randomPredictiveTeleportOffset = 5; + int teleportTries = 0; + while (teleportTries < 100) { - num238++; - int num239 = Main.rand.Next(point4.X - num235, point4.X + num235 + 1); - int num240 = Main.rand.Next(point4.Y - num235, point4.Y); + teleportTries++; + int teleportTileX = Main.rand.Next(predictiveTeleportPoint.X - randomPredictiveTeleportOffset, predictiveTeleportPoint.X + randomPredictiveTeleportOffset + 1); + int teleportTileY = Main.rand.Next(predictiveTeleportPoint.Y - randomPredictiveTeleportOffset, predictiveTeleportPoint.Y); - if (!Main.tile[num239, num240].HasUnactuatedTile) + if (!Main.tile[teleportTileX, teleportTileY].HasUnactuatedTile) { - bool flag13 = true; - if (flag13 && Main.tile[num239, num240].LiquidType == LiquidID.Lava) - flag13 = false; - if (flag13 && !Collision.CanHitLine(npc.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) - flag13 = false; + bool canTeleportToTile = true; + if (canTeleportToTile && Main.tile[teleportTileX, teleportTileY].LiquidType == LiquidID.Lava) + canTeleportToTile = false; + if (canTeleportToTile && !Collision.CanHitLine(npc.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) + canTeleportToTile = false; - if (flag13) + if (canTeleportToTile) { - npc.localAI[1] = num239 * 16 + 8; - npc.localAI[2] = num240 * 16 + 16; + npc.localAI[1] = teleportTileX * 16 + 8; + npc.localAI[2] = teleportTileY * 16 + 16; break; } } } // Default teleport if the above conditions aren't met in 100 iterations - if (num238 >= 100) + if (teleportTries >= 100) { Vector2 bottom = Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].Bottom; npc.localAI[1] = bottom.X; diff --git a/NPCs/VanillaNPCOverrides/Bosses/MoonLordAI.cs b/NPCs/VanillaNPCOverrides/Bosses/MoonLordAI.cs index a034bd0db0..8efb918101 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/MoonLordAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/MoonLordAI.cs @@ -1,15 +1,18 @@ -using CalamityMod.Events; +using System; +using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; -using System; using Terraria; +using Terraria.Audio; using Terraria.GameContent.Events; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { + // This is the most horrible abomination of code I have ever seen in my life, by a fucking landslide. + // This took hours of my time to attempt to clean up, and quite frankly I'd be surprised if even half of it is accurate. + // I do not want to look at this crime against humanity for a very long time. -CIT public static class MoonLordAI { public static readonly SoundStyle DeathrayChargeSound = new("CalamityMod/Sounds/Custom/MoonLordLaserCharge"); @@ -122,37 +125,37 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.netUpdate = true; int[] array5 = new int[3]; - int num1155 = 0; - int num; + int handsSpawned = 0; + int totalSpawns; - for (int num1156 = 0; num1156 < 2; num1156 = num + 1) + for (int i = 0; i < 2; i = totalSpawns + 1) { - int num1157 = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X + num1156 * 800 - 400, (int)npc.Center.Y - 100, NPCID.MoonLordHand, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num1157].ai[2] = num1156; - Main.npc[num1157].netUpdate = true; + int handSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X + i * 800 - 400, (int)npc.Center.Y - 100, NPCID.MoonLordHand, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[handSpawn].ai[2] = i; + Main.npc[handSpawn].netUpdate = true; int[] arg_381A6_0 = array5; - num = num1155; - num1155 = num + 1; - arg_381A6_0[num] = num1157; - num = num1156; + totalSpawns = handsSpawned; + handsSpawned = totalSpawns + 1; + arg_381A6_0[totalSpawns] = handSpawn; + totalSpawns = i; } - int num1158 = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y - 400, NPCID.MoonLordHead, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num1158].netUpdate = true; + int headSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y - 400, NPCID.MoonLordHead, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[headSpawn].netUpdate = true; int[] arg_3823F_0 = array5; - num = num1155; - num1155 = num + 1; - arg_3823F_0[num] = num1158; + totalSpawns = handsSpawned; + handsSpawned = totalSpawns + 1; + arg_3823F_0[totalSpawns] = headSpawn; - for (int num1159 = 0; num1159 < 3; num1159 = num + 1) + for (int j = 0; j < 3; j = totalSpawns + 1) { - Main.npc[array5[num1159]].ai[3] = npc.whoAmI; - num = num1159; + Main.npc[array5[j]].ai[3] = npc.whoAmI; + totalSpawns = j; } - for (int num1160 = 0; num1160 < 3; num1160 = num + 1) + for (int k = 0; k < 3; k = totalSpawns + 1) { - npc.localAI[num1160] = array5[num1160]; - num = num1160; + npc.localAI[k] = array5[k]; + totalSpawns = k; } } } @@ -170,9 +173,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { if (Main.netMode != NetmodeID.MultiplayerClient) { - int num = NPC.NewNPC(npc.GetSource_FromAI(), (int)Main.npc[(int)npc.localAI[2]].Center.X, (int)Main.npc[(int)npc.localAI[2]].Center.Y, NPCID.MoonLordFreeEye); - Main.npc[num].ai[3] = npc.whoAmI; - Main.npc[num].netUpdate = true; + int totalSpawns = NPC.NewNPC(npc.GetSource_FromAI(), (int)Main.npc[(int)npc.localAI[2]].Center.X, (int)Main.npc[(int)npc.localAI[2]].Center.Y, NPCID.MoonLordFreeEye); + Main.npc[totalSpawns].ai[3] = npc.whoAmI; + Main.npc[totalSpawns].netUpdate = true; } } @@ -182,8 +185,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.dontTakeDamage = true; npc.TargetClosest(false); - Vector2 value4 = Main.player[npc.target].Center - npc.Center + new Vector2(0f, 130f); - if (value4.Length() > 20f) + Vector2 targetDistance = Main.player[npc.target].Center - npc.Center + new Vector2(0f, 130f); + if (targetDistance.Length() > 20f) { float velocity = death ? 9.5f : 9.25f; switch (aggressionLevel) @@ -211,7 +214,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.npc[(int)npc.localAI[2]].ai[0] == 1f) velocity -= 2f; - Vector2 desiredVelocity = Vector2.Normalize(value4 - npc.velocity) * velocity; + Vector2 desiredVelocity = Vector2.Normalize(targetDistance - npc.velocity) * velocity; Vector2 velocity2 = npc.velocity; npc.SimpleFlyMovement(desiredVelocity, 0.5f); npc.velocity = Vector2.Lerp(npc.velocity, velocity2, 0.5f); @@ -220,17 +223,17 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { // Despawn if other parts aren't there - bool flag84 = false; + bool shouldDespawn = false; if (npc.localAI[0] < 0f || npc.localAI[1] < 0f || npc.localAI[2] < 0f) - flag84 = true; + shouldDespawn = true; else if (!Main.npc[(int)npc.localAI[0]].active || Main.npc[(int)npc.localAI[0]].type != NPCID.MoonLordHand) - flag84 = true; + shouldDespawn = true; else if (!Main.npc[(int)npc.localAI[1]].active || Main.npc[(int)npc.localAI[1]].type != NPCID.MoonLordHand) - flag84 = true; + shouldDespawn = true; else if (!Main.npc[(int)npc.localAI[2]].active || Main.npc[(int)npc.localAI[2]].type != NPCID.MoonLordHead) - flag84 = true; + shouldDespawn = true; - if (flag84) + if (shouldDespawn) { npc.life = 0; npc.HitEffect(0, 10.0); @@ -238,15 +241,15 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Take damage if other parts are down - bool flag85 = true; + bool coreIsOpen = true; if (Main.npc[(int)npc.localAI[0]].Calamity().newAI[0] != 1f) - flag85 = false; + coreIsOpen = false; if (Main.npc[(int)npc.localAI[1]].Calamity().newAI[0] != 1f) - flag85 = false; + coreIsOpen = false; if (Main.npc[(int)npc.localAI[2]].Calamity().newAI[0] != 1f) - flag85 = false; + coreIsOpen = false; - if (flag85) + if (coreIsOpen) { npc.ai[0] = 1f; npc.dontTakeDamage = false; @@ -261,8 +264,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.dontTakeDamage = false; npc.TargetClosest(false); - Vector2 value5 = Main.player[npc.target].Center - npc.Center + new Vector2(0f, 130f); - if (value5.Length() > 20f) + Vector2 targetDistanceVulnerable = Main.player[npc.target].Center - npc.Center + new Vector2(0f, 130f); + if (targetDistanceVulnerable.Length() > 20f) { float velocity = death ? 9.5f : 9.25f; switch (aggressionLevel) @@ -290,10 +293,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.npc[(int)npc.localAI[2]].ai[0] == 1f) velocity -= 2f; - Vector2 desiredVelocity2 = Vector2.Normalize(value5 - npc.velocity) * velocity; - Vector2 velocity3 = npc.velocity; + Vector2 desiredVelocity2 = Vector2.Normalize(targetDistanceVulnerable - npc.velocity) * velocity; + Vector2 currentVelocity = npc.velocity; npc.SimpleFlyMovement(desiredVelocity2, 0.5f); - npc.velocity = Vector2.Lerp(npc.velocity, velocity3, 0.5f); + npc.velocity = Vector2.Lerp(npc.velocity, currentVelocity, 0.5f); } } @@ -302,8 +305,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { npc.dontTakeDamage = true; npc.Calamity().ShouldCloseHPBar = true; - Vector2 value6 = new Vector2(npc.direction, -0.5f); - npc.velocity = Vector2.Lerp(npc.velocity, value6, 0.98f); + Vector2 dyingVelocity = new Vector2(npc.direction, -0.5f); + npc.velocity = Vector2.Lerp(npc.velocity, dyingVelocity, 0.98f); npc.ai[1] += 1f; float ai1 = npc.ai[1]; @@ -334,98 +337,97 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[1] % 3f == 0f && npc.ai[1] < 580f && npc.ai[1] > 60f) { - Vector2 vector158 = Utils.RandomVector2(Main.rand, -1f, 1f); - if (vector158 != Vector2.Zero) - vector158.Normalize(); + Vector2 randPositionOffset = Utils.RandomVector2(Main.rand, -1f, 1f); + if (randPositionOffset != Vector2.Zero) + randPositionOffset.Normalize(); - vector158 *= 20f + Main.rand.NextFloat() * 400f; - Vector2 vector159 = npc.Center + vector158; - Point point5 = vector159.ToTileCoordinates(); + randPositionOffset *= 20f + Main.rand.NextFloat() * 400f; + Vector2 npcPosition = npc.Center + randPositionOffset; + Point npcPositionTileCoords = npcPosition.ToTileCoordinates(); - bool flag86 = true; - if (!WorldGen.InWorld(point5.X, point5.Y, 0)) - flag86 = false; - if (flag86 && WorldGen.SolidTile(point5.X, point5.Y)) - flag86 = false; + bool inOpenSpace = true; + if (!WorldGen.InWorld(npcPositionTileCoords.X, npcPositionTileCoords.Y, 0)) + inOpenSpace = false; + if (inOpenSpace && WorldGen.SolidTile(npcPositionTileCoords.X, npcPositionTileCoords.Y)) + inOpenSpace = false; - float num1163 = Main.rand.Next(6, 19); - float num1164 = MathHelper.TwoPi / num1163; - float num1165 = MathHelper.TwoPi * Main.rand.NextFloat(); - float scaleFactor8 = 1f + Main.rand.NextFloat() * 2f; - float num1166 = 1f + Main.rand.NextFloat(); + float randDustAmt = Main.rand.Next(6, 19); + float twoPiOverRand = MathHelper.TwoPi * Main.rand.NextFloat(); + float dustVelocityMult = 1f + Main.rand.NextFloat() * 2f; + float dustScale = 1f + Main.rand.NextFloat(); float fadeIn = 0.4f + Main.rand.NextFloat(); - int num1167 = Utils.SelectRandom(Main.rand, new int[] + int dustType = Utils.SelectRandom(Main.rand, new int[] { 31, 229 }); - if (flag86) + if (inOpenSpace) { - //MoonlordDeathDrama.AddExplosion(vector159); - for (float num1168 = 0f; num1168 < num1163 * 2f; num1168 = ai1 + 1f) + //MoonlordDeathDrama.AddExplosion(npcPosition); + for (float j = 0f; j < randDustAmt * 2f; j = ai1 + 1f) { - Dust dust2 = Main.dust[Dust.NewDust(vector159, 0, 0, 229, 0f, 0f, 0, default, 1f)]; - dust2.noGravity = true; - dust2.position = vector159; - dust2.velocity = Vector2.UnitY.RotatedBy(num1165 + num1164 * num1168) * scaleFactor8 * (Main.rand.NextFloat() * 1.6f + 1.6f); - dust2.fadeIn = fadeIn; - dust2.scale = num1166; - ai1 = num1168; + Dust vortex = Main.dust[Dust.NewDust(npcPosition, 0, 0, 229, 0f, 0f, 0, default, 1f)]; + vortex.noGravity = true; + vortex.position = npcPosition; + vortex.velocity = Vector2.UnitY.RotatedBy(twoPiOverRand + (MathHelper.TwoPi / randDustAmt) * j) * dustVelocityMult * (Main.rand.NextFloat() * 1.6f + 1.6f); + vortex.fadeIn = fadeIn; + vortex.scale = dustScale; + ai1 = j; } } - for (float num1169 = 0f; num1169 < npc.ai[1] / 60f; num1169 = ai1 + 1f) + for (float k = 0f; k < npc.ai[1] / 60f; k = ai1 + 1f) { - Vector2 vector160 = Utils.RandomVector2(Main.rand, -1f, 1f); - if (vector160 != Vector2.Zero) - vector160.Normalize(); + Vector2 randPosOffset = Utils.RandomVector2(Main.rand, -1f, 1f); + if (randPosOffset != Vector2.Zero) + randPosOffset.Normalize(); - vector160 *= 20f + Main.rand.NextFloat() * 800f; - Vector2 vector161 = npc.Center + vector160; - Point point6 = vector161.ToTileCoordinates(); + randPosOffset *= 20f + Main.rand.NextFloat() * 800f; + Vector2 npcPositioning = npc.Center + randPosOffset; + Point npcPositioningTileCoords = npcPositioning.ToTileCoordinates(); - bool flag87 = true; - if (!WorldGen.InWorld(point6.X, point6.Y, 0)) - flag87 = false; - if (flag87 && WorldGen.SolidTile(point6.X, point6.Y)) - flag87 = false; + bool isInOpenness = true; + if (!WorldGen.InWorld(npcPositioningTileCoords.X, npcPositioningTileCoords.Y, 0)) + isInOpenness = false; + if (isInOpenness && WorldGen.SolidTile(npcPositioningTileCoords.X, npcPositioningTileCoords.Y)) + isInOpenness = false; - if (flag87) + if (isInOpenness) { - Dust dust3 = Main.dust[Dust.NewDust(vector161, 0, 0, num1167, 0f, 0f, 0, default, 1f)]; - dust3.noGravity = true; - dust3.position = vector161; - dust3.velocity = -Vector2.UnitY * scaleFactor8 * (Main.rand.NextFloat() * 0.9f + 1.6f); - dust3.fadeIn = fadeIn; - dust3.scale = num1166; + Dust openDust = Main.dust[Dust.NewDust(npcPositioning, 0, 0, dustType, 0f, 0f, 0, default, 1f)]; + openDust.noGravity = true; + openDust.position = npcPositioning; + openDust.velocity = -Vector2.UnitY * dustVelocityMult * (Main.rand.NextFloat() * 0.9f + 1.6f); + openDust.fadeIn = fadeIn; + openDust.scale = dustScale; } - ai1 = num1169; + ai1 = k; } } if (npc.ai[1] % 15f == 0f && npc.ai[1] < 480f && npc.ai[1] >= 90f && Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector162 = Utils.RandomVector2(Main.rand, -1f, 1f); - if (vector162 != Vector2.Zero) - vector162.Normalize(); + Vector2 randomOffset = Utils.RandomVector2(Main.rand, -1f, 1f); + if (randomOffset != Vector2.Zero) + randomOffset.Normalize(); - vector162 *= 20f + Main.rand.NextFloat() * 400f; - bool flag88 = true; - Vector2 vector163 = npc.Center + vector162; - Point point7 = vector163.ToTileCoordinates(); + randomOffset *= 20f + Main.rand.NextFloat() * 400f; + bool stillInTheOpen = true; + Vector2 npcOffsetPos = npc.Center + randomOffset; + Point npcOffsetPosTileCoords = npcOffsetPos.ToTileCoordinates(); - if (!WorldGen.InWorld(point7.X, point7.Y, 0)) - flag88 = false; - if (flag88 && WorldGen.SolidTile(point7.X, point7.Y)) - flag88 = false; + if (!WorldGen.InWorld(npcOffsetPosTileCoords.X, npcOffsetPosTileCoords.Y, 0)) + stillInTheOpen = false; + if (stillInTheOpen && WorldGen.SolidTile(npcOffsetPosTileCoords.X, npcOffsetPosTileCoords.Y)) + stillInTheOpen = false; - if (flag88) + if (stillInTheOpen) { - float num1170 = (Main.rand.Next(4) < 2).ToDirectionInt() * (0.3926991f + MathHelper.PiOver4 * Main.rand.NextFloat()); - Vector2 vector164 = new Vector2(0f, -Main.rand.NextFloat() * 0.5f - 0.5f).RotatedBy(num1170) * 6f; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector163.X, vector163.Y, vector164.X, vector164.Y, ProjectileID.BlowupSmokeMoonlord, 0, 0f, Main.myPlayer, 0f, 0f); + float smokeRotation = (Main.rand.Next(4) < 2).ToDirectionInt() * (0.3926991f + MathHelper.PiOver4 * Main.rand.NextFloat()); + Vector2 smokePosition = new Vector2(0f, -Main.rand.NextFloat() * 0.5f - 0.5f).RotatedBy(smokeRotation) * 6f; + Projectile.NewProjectile(npc.GetSource_FromAI(), npcOffsetPos.X, npcOffsetPos.Y, smokePosition.X, smokePosition.Y, ProjectileID.BlowupSmokeMoonlord, 0, 0f, Main.myPlayer, 0f, 0f); } } @@ -441,9 +443,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.HitEffect(0, 1337.0); npc.checkDead(); - for (int num1174 = 0; num1174 < Main.maxNPCs; num1174++) + for (int i = 0; i < Main.maxNPCs; i++) { - NPC nPC5 = Main.npc[num1174]; + NPC nPC5 = Main.npc[i]; if (nPC5.active && (nPC5.type == NPCID.MoonLordHand || nPC5.type == NPCID.MoonLordHead)) { nPC5.active = false; @@ -464,8 +466,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses else if (npc.ai[0] == 3f) { npc.dontTakeDamage = true; - Vector2 value7 = new Vector2(npc.direction, -0.5f); - npc.velocity = Vector2.Lerp(npc.velocity, value7, 0.98f); + Vector2 despawnVelocityLerp = new Vector2(npc.direction, -0.5f); + npc.velocity = Vector2.Lerp(npc.velocity, despawnVelocityLerp, 0.98f); npc.ai[1] += 1f; if (npc.ai[1] < 60f) @@ -473,22 +475,22 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[1] == 40f) { - for (int num1171 = 0; num1171 < Main.maxProjectiles; num1171++) + for (int j = 0; j < Main.maxProjectiles; j++) { - Projectile projectile2 = Main.projectile[num1171]; + Projectile projectile2 = Main.projectile[j]; if (projectile2.active && (projectile2.type == ProjectileID.MoonLeech || projectile2.type == ProjectileID.PhantasmalBolt || projectile2.type == ProjectileID.PhantasmalDeathray || projectile2.type == ProjectileID.PhantasmalEye || projectile2.type == ProjectileID.PhantasmalSphere)) { projectile2.active = false; if (Main.netMode != NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, num1171, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, j, 0f, 0f, 0f, 0, 0, 0); } } - for (int num1172 = 0; num1172 < Main.maxNPCs; num1172++) + for (int k = 0; k < Main.maxNPCs; k++) { - NPC nPC4 = Main.npc[num1172]; + NPC nPC4 = Main.npc[k]; if (nPC4.active && nPC4.type == NPCID.MoonLordFreeEye) { nPC4.active = false; @@ -497,9 +499,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } } - for (int num1173 = 0; num1173 < Main.maxGore; num1173++) + for (int l = 0; l < Main.maxGore; l++) { - Gore gore2 = Main.gore[num1173]; + Gore gore2 = Main.gore[l]; if (gore2.active && gore2.type >= GoreID.MoonLordHeart1 && gore2.type <= GoreID.MoonLordHeart4) gore2.active = false; } @@ -507,9 +509,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[1] >= 60f) { - for (int num1174 = 0; num1174 < Main.maxNPCs; num1174++) + for (int i = 0; i < Main.maxNPCs; i++) { - NPC nPC5 = Main.npc[num1174]; + NPC nPC5 = Main.npc[i]; if (nPC5.active && (nPC5.type == NPCID.MoonLordFreeEye || nPC5.type == NPCID.MoonLordHand || nPC5.type == NPCID.MoonLordHead)) { nPC5.active = false; @@ -531,24 +533,24 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Despawn - bool flag89 = false; + bool preventDespawn = false; if (npc.ai[0] == -2f || npc.ai[0] == -1f || npc.ai[0] == -2f || npc.ai[0] == 3f) - flag89 = true; + preventDespawn = true; if (Main.player[npc.target].active && !Main.player[npc.target].dead) - flag89 = true; + preventDespawn = true; - if (!flag89) + if (!preventDespawn) { - for (int num1175 = 0; num1175 < Main.maxPlayers; num1175++) + for (int p = 0; p < Main.maxPlayers; p++) { - if (Main.player[num1175].active && !Main.player[num1175].dead) + if (Main.player[p].active && !Main.player[p].dead) { - flag89 = true; + preventDespawn = true; break; } } } - if (!flag89) + if (!preventDespawn) { npc.ai[0] = 3f; npc.ai[1] = 0f; @@ -582,9 +584,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses Main.npc[(int)npc.localAI[2]].netUpdate = true; } - for (int num1176 = 0; num1176 < Main.maxNPCs; num1176++) + for (int i = 0; i < Main.maxNPCs; i++) { - NPC nPC7 = Main.npc[num1176]; + NPC nPC7 = Main.npc[i]; if (nPC7.active && nPC7.type == NPCID.MoonLordFreeEye) { NPC nPC6 = nPC7; @@ -611,11 +613,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.velocity = Vector2.Zero; npc.Center = Main.npc[(int)npc.ai[3]].Center + new Vector2(0f, -400f); - Vector2 value19 = new Vector2(27f, 59f); - float num1207 = 0f; - float num1208 = 0f; - int num1209 = 0; - int num1210 = 0; + Vector2 boltAndDeathrayVector = new Vector2(27f, 59f); + float attackTimer = 0f; + float attackTimerComparison = 0f; + int headVulnerability = 0; + int deathrayCheck = 0; // Invulnerable if (npc.ai[0] >= 0f || npc.ai[0] == -2f) @@ -638,36 +640,35 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Set up attacks - float num1211 = npc.ai[0]; + float ai0CrossCheck = npc.ai[0]; npc.ai[1] += 1f; - int num1212 = (int)Main.npc[(int)npc.ai[3]].ai[2]; - int num1213 = 2; - int num1214 = 0; - int num1215 = 0; + int attackType = (int)Main.npc[(int)npc.ai[3]].ai[2]; + int fiveFrameCounter = 0; + int attackTimerIncrement = 0; - while (num1214 < 5) + while (fiveFrameCounter < 5) { - num1208 = NPC.MoonLordAttacksArray[num1212, num1213, 1, num1214]; - if (num1208 + num1215 > npc.ai[1]) + attackTimerComparison = NPC.MoonLordAttacksArray[attackType, 2, 1, fiveFrameCounter]; + if (attackTimerComparison + attackTimerIncrement > npc.ai[1]) break; - num1215 += (int)num1208; - int num = num1214; - num1214 = num + 1; + attackTimerIncrement += (int)attackTimerComparison; + int totalSpawns = fiveFrameCounter; + fiveFrameCounter = totalSpawns + 1; } - if (num1214 == 5) + if (fiveFrameCounter == 5) { - num1214 = 0; + fiveFrameCounter = 0; npc.ai[1] = 0f; - num1208 = NPC.MoonLordAttacksArray[num1212, num1213, 1, num1214]; - num1215 = 0; + attackTimerComparison = NPC.MoonLordAttacksArray[attackType, 2, 1, fiveFrameCounter]; + attackTimerIncrement = 0; } - npc.ai[0] = NPC.MoonLordAttacksArray[num1212, num1213, 0, num1214]; - num1207 = (int)npc.ai[1] - num1215; + npc.ai[0] = NPC.MoonLordAttacksArray[attackType, 2, 0, fiveFrameCounter]; + attackTimer = (int)npc.ai[1] - attackTimerIncrement; - if (npc.ai[0] != num1211) + if (npc.ai[0] != ai0CrossCheck) npc.netUpdate = true; } @@ -690,65 +691,61 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Set variables for deathray else if (npc.ai[0] == 0f) { - num1210 = 3; + deathrayCheck = 3; npc.TargetClosest(false); Vector2 v3 = Main.player[npc.target].Center - npc.Center - new Vector2(0f, -22f); - float num1219 = v3.Length() / 500f; - if (num1219 > 1f) - num1219 = 1f; + float deathrayTravelDist = v3.Length() / 500f; + if (deathrayTravelDist > 1f) + deathrayTravelDist = 1f; - num1219 = 1f - num1219; - num1219 *= 2f; - if (num1219 > 1f) - num1219 = 1f; + deathrayTravelDist = 1f - deathrayTravelDist; + deathrayTravelDist *= 2f; + if (deathrayTravelDist > 1f) + deathrayTravelDist = 1f; npc.localAI[0] = v3.ToRotation(); - npc.localAI[1] = num1219; + npc.localAI[1] = deathrayTravelDist; npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], 1f, 0.2f); } // Deathray if (npc.ai[0] == 1f) { - if (num1207 < 180f) + if (attackTimer < 180f) { npc.localAI[1] -= 0.05f; if (npc.localAI[1] < 0f) npc.localAI[1] = 0f; - if (num1207 >= 60f) + if (attackTimer >= 60f) { Vector2 center20 = npc.Center; // Hopefully it plays - if (num1207 == 60f) + if (attackTimer == 60f) SoundEngine.PlaySound(DeathrayChargeSound, center20); - int num1220 = 0; - if (num1207 >= 120f) - num1220 = 1; + int deathrayAttackDustAmt = 0; + if (attackTimer >= 120f) + deathrayAttackDustAmt = 1; - for (int num1221 = 0; num1221 < 1 + num1220; num1221++) + for (int i = 0; i < 1 + deathrayAttackDustAmt; i++) { - int num1222 = 229; - float num1223 = 0.8f; - if (num1221 % 2 == 1) - { - num1222 = 229; - num1223 = 1.65f; - } + float deathrayAttackDustScale = 0.8f; + if (i % 2 == 1) + deathrayAttackDustScale = 1.65f; - Vector2 vector199 = center20 + ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * value19 / 2f; - int num1224 = Dust.NewDust(vector199 - Vector2.One * 8f, 16, 16, num1222, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, default, 1f); - Main.dust[num1224].velocity = Vector2.Normalize(center20 - vector199) * 3.5f * (10f - num1220 * 2f) / 10f; - Main.dust[num1224].noGravity = true; - Main.dust[num1224].scale = num1223; - Main.dust[num1224].customData = npc; + Vector2 deathrayAttackDustRotation = center20 + ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * boltAndDeathrayVector / 2f; + int deathrayAttackDust = Dust.NewDust(deathrayAttackDustRotation - Vector2.One * 8f, 16, 16, 229, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, default, 1f); + Main.dust[deathrayAttackDust].velocity = Vector2.Normalize(center20 - deathrayAttackDustRotation) * 3.5f * (10f - deathrayAttackDustAmt * 2f) / 10f; + Main.dust[deathrayAttackDust].noGravity = true; + Main.dust[deathrayAttackDust].scale = deathrayAttackDustScale; + Main.dust[deathrayAttackDust].customData = npc; } } } - else if (num1207 < num1208 - 15f) + else if (attackTimer < attackTimerComparison - 15f) { if (calamityGlobalNPC.newAI[1] == 0f) { @@ -780,22 +777,22 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } } - if (num1207 == 180f && Main.netMode != NetmodeID.MultiplayerClient) + if (attackTimer == 180f && Main.netMode != NetmodeID.MultiplayerClient) { int projectileType = ProjectileID.PhantasmalDeathray; int damage = npc.GetProjectileDamage(projectileType); npc.TargetClosest(false); - Vector2 vector200 = Main.player[npc.target].Center - npc.Center; - vector200.Normalize(); + Vector2 deathrayRotationSpeed = Main.player[npc.target].Center - npc.Center; + deathrayRotationSpeed.Normalize(); - float num1225 = -1f; - if (vector200.X < 0f) - num1225 = 1f; + float deathrayRotationDirection = -1f; + if (deathrayRotationSpeed.X < 0f) + deathrayRotationDirection = 1f; - vector200 = vector200.RotatedBy(-(double)num1225 * MathHelper.TwoPi / 6f); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, vector200.X, vector200.Y, projectileType, damage, 0f, Main.myPlayer, num1225 * MathHelper.TwoPi / calamityGlobalNPC.newAI[1], npc.whoAmI); - npc.ai[2] = (vector200.ToRotation() + MathHelper.Pi + MathHelper.TwoPi) * num1225; + deathrayRotationSpeed = deathrayRotationSpeed.RotatedBy(-(double)deathrayRotationDirection * MathHelper.TwoPi / 6f); + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, deathrayRotationSpeed.X, deathrayRotationSpeed.Y, projectileType, damage, 0f, Main.myPlayer, deathrayRotationDirection * MathHelper.TwoPi / calamityGlobalNPC.newAI[1], npc.whoAmI); + npc.ai[2] = (deathrayRotationSpeed.ToRotation() + MathHelper.Pi + MathHelper.TwoPi) * deathrayRotationDirection; npc.netUpdate = true; } @@ -803,15 +800,15 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.localAI[1] > 1f) npc.localAI[1] = 1f; - float num1226 = (npc.ai[2] >= 0f).ToDirectionInt(); - float num1227 = npc.ai[2]; - if (num1227 < 0f) - num1227 *= -1f; + float deathrayFaceDirection = (npc.ai[2] >= 0f).ToDirectionInt(); + float deathrayTimer = npc.ai[2]; + if (deathrayTimer < 0f) + deathrayTimer *= -1f; - num1227 += -(MathHelper.Pi + MathHelper.TwoPi); - num1227 += num1226 * MathHelper.TwoPi / calamityGlobalNPC.newAI[1]; - npc.localAI[0] = num1227; - npc.ai[2] = (num1227 + MathHelper.Pi + MathHelper.TwoPi) * num1226; + deathrayTimer += -(MathHelper.Pi + MathHelper.TwoPi); + deathrayTimer += deathrayFaceDirection * MathHelper.TwoPi / calamityGlobalNPC.newAI[1]; + npc.localAI[0] = deathrayTimer; + npc.ai[2] = (deathrayTimer + MathHelper.Pi + MathHelper.TwoPi) * deathrayFaceDirection; } else { @@ -823,7 +820,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.localAI[1] = 0f; if (Main.netMode != NetmodeID.MultiplayerClient && Main.getGoodWorld && Main.remixWorld) { - for (int num1268 = 0; num1268 < 30; num1268++) + for (int k = 0; k < 30; k++) { if (!WorldGen.SolidTile((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f))) Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, (float)Main.rand.Next(-1599, 1600) * 0.01f, (float)Main.rand.Next(-1599, 1) * 0.01f, ProjectileID.MoonBoulder, 70, 10f); @@ -831,46 +828,46 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } } - num1210 = 3; + deathrayCheck = 3; } } // Moon Leech thing else if (npc.ai[0] == 2f) { - num1209 = 2; - num1210 = 3; - Vector2 value21 = new Vector2(0f, 216f); + headVulnerability = 2; + deathrayCheck = 3; + Vector2 leechCenterOffset = new Vector2(0f, 216f); - if (num1207 == 0f && Main.netMode != NetmodeID.MultiplayerClient) + if (attackTimer == 0f && Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector201 = npc.Center + value21; - for (int num1228 = 0; num1228 < Main.maxPlayers; num1228++) + Vector2 leechNPCCenter = npc.Center + leechCenterOffset; + for (int i = 0; i < Main.maxPlayers; i++) { - Player player6 = Main.player[num1228]; - if (player6.active && !player6.dead && Vector2.Distance(player6.Center, vector201) <= 3000f) + Player player6 = Main.player[i]; + if (player6.active && !player6.dead && Vector2.Distance(player6.Center, leechNPCCenter) <= 3000f) { - Vector2 vector202 = Main.player[npc.target].Center - vector201; - if (vector202 != Vector2.Zero) - vector202.Normalize(); + Vector2 targetLeechDist = Main.player[npc.target].Center - leechNPCCenter; + if (targetLeechDist != Vector2.Zero) + targetLeechDist.Normalize(); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector201.X, vector201.Y, vector202.X, vector202.Y, ProjectileID.MoonLeech, 0, 0f, Main.myPlayer, npc.whoAmI + 1, num1228); + Projectile.NewProjectile(npc.GetSource_FromAI(), leechNPCCenter.X, leechNPCCenter.Y, targetLeechDist.X, targetLeechDist.Y, ProjectileID.MoonLeech, 0, 0f, Main.myPlayer, npc.whoAmI + 1, i); } } } - if ((num1207 == 120f || num1207 == 150f || num1207 == 180f || num1207 == 210f || num1207 == 240f) && Main.netMode != NetmodeID.MultiplayerClient) + if ((attackTimer == 120f || attackTimer == 150f || attackTimer == 180f || attackTimer == 210f || attackTimer == 240f) && Main.netMode != NetmodeID.MultiplayerClient) { - for (int num1229 = 0; num1229 < Main.maxProjectiles; num1229++) + for (int j = 0; j < Main.maxProjectiles; j++) { - Projectile projectile6 = Main.projectile[num1229]; + Projectile projectile6 = Main.projectile[j]; if (projectile6.active && projectile6.type == ProjectileID.MoonLeech && Main.player[(int)projectile6.ai[1]].FindBuffIndex(BuffID.MoonLeech) != -1) { - Vector2 center21 = Main.player[npc.target].Center; - int num1230 = NPC.NewNPC(npc.GetSource_FromAI(), (int)center21.X, (int)center21.Y, NPCID.MoonLordLeechBlob); - Main.npc[num1230].netUpdate = true; - Main.npc[num1230].ai[0] = npc.whoAmI + 1; - Main.npc[num1230].ai[1] = num1229; + Vector2 targetCenter = Main.player[npc.target].Center; + int moonLeech = NPC.NewNPC(npc.GetSource_FromAI(), (int)targetCenter.X, (int)targetCenter.Y, NPCID.MoonLordLeechBlob); + Main.npc[moonLeech].netUpdate = true; + Main.npc[moonLeech].ai[0] = npc.whoAmI + 1; + Main.npc[moonLeech].ai[1] = j; } } } @@ -879,16 +876,16 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Phantasmal Bolts else if (npc.ai[0] == 3f) { - if (num1207 == 0f) + if (attackTimer == 0f) { npc.TargetClosest(false); npc.netUpdate = true; } Vector2 v4 = Main.player[npc.target].Center - npc.Center; - bool shootFirstBolt = num1207 == num1208 - 14f; - bool shootSecondBolt = num1207 == num1208 - 7f; - bool shootThirdBolt = num1207 == num1208; + bool shootFirstBolt = attackTimer == attackTimerComparison - 14f; + bool shootSecondBolt = attackTimer == attackTimerComparison - 7f; + bool shootThirdBolt = attackTimer == attackTimerComparison; switch (aggressionLevel) { case 6: @@ -916,12 +913,12 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.localAI[1] > 1f) npc.localAI[1] = 1f; - if (num1207 == num1208 - 35f) + if (attackTimer == attackTimerComparison - 35f) SoundEngine.PlaySound(SoundID.NPCDeath6, npc.position); if ((shootFirstBolt || shootSecondBolt || shootThirdBolt) && Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector203 = Utils.Vector2FromElipse(npc.localAI[0].ToRotationVector2(), value19 * npc.localAI[1]); + Vector2 boltDirection = Utils.Vector2FromElipse(npc.localAI[0].ToRotationVector2(), boltAndDeathrayVector * npc.localAI[1]); float velocity = death ? 6.75f : 6.25f; switch (aggressionLevel) @@ -943,28 +940,28 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses break; } - Vector2 vector204 = Vector2.Normalize(v4) * velocity; + Vector2 boltVelocity = Vector2.Normalize(v4) * velocity; int type = ProjectileID.PhantasmalBolt; int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + vector203.X, npc.Center.Y + vector203.Y, vector204.X, vector204.Y, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + boltDirection.X, npc.Center.Y + boltDirection.Y, boltVelocity.X, boltVelocity.Y, type, damage, 0f, Main.myPlayer, 0f, 0f); } } // Dictates whether this npc is vulnerable or not - int num1231 = num1209 * 7; - if (num1231 > npc.localAI[2]) + int headEyeVulnerableCheck = headVulnerability * 7; + if (headEyeVulnerableCheck > npc.localAI[2]) npc.localAI[2] += 1f; - if (num1231 < npc.localAI[2]) + if (headEyeVulnerableCheck < npc.localAI[2]) npc.localAI[2] -= 1f; if (npc.localAI[2] < 0f) npc.localAI[2] = 0f; if (npc.localAI[2] > 14f) npc.localAI[2] = 14f; - int num1232 = num1210 * 5; - if (num1232 > npc.localAI[3]) + int headEyeDeathrayCheck = deathrayCheck * 5; + if (headEyeDeathrayCheck > npc.localAI[3]) npc.localAI[3] += 1f; - if (num1232 < npc.localAI[3]) + if (headEyeDeathrayCheck < npc.localAI[3]) npc.localAI[3] -= 1f; if (npc.localAI[3] < 0f) npc.localAI[2] = 0f; @@ -985,18 +982,18 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Variables - bool flag90 = npc.ai[2] == 0f; - float num1177 = -flag90.ToDirectionInt(); - npc.spriteDirection = (int)num1177; + bool isLeftHand = npc.ai[2] == 0f; + float handFaceDirection = -isLeftHand.ToDirectionInt(); + npc.spriteDirection = (int)handFaceDirection; npc.dontTakeDamage = npc.frameCounter >= 21.0; if (calamityGlobalNPC.newAI[0] == 1f) npc.dontTakeDamage = true; - Vector2 vector165 = new Vector2(30f, 66f); - float num1178 = 0f; - float num1179 = 0f; - int num1180 = 0; + Vector2 handBehaviorVector = new Vector2(30f, 66f); + float handAttackTimer = 0f; + float handAttackTimerComparison = 0f; + int handFrameCheck = 0; // Go to die if (Main.npc[(int)npc.ai[3]].ai[0] == 2f) @@ -1015,41 +1012,41 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.dontTakeDamage = true; } - float num1181 = npc.ai[0]; + float handAI0CrossCheck = npc.ai[0]; npc.ai[1] += 1f; - int num1182 = (int)Main.npc[(int)npc.ai[3]].ai[2]; - int num1183 = flag90 ? 0 : 1; - int num1184 = 0; - int num1185 = 0; + int handAttackType = (int)Main.npc[(int)npc.ai[3]].ai[2]; + int handType = isLeftHand ? 0 : 1; + int handFiveFrameTimer = 0; + int handAttackTimerIncrement = 0; - while (num1184 < 5) + while (handFiveFrameTimer < 5) { - num1179 = NPC.MoonLordAttacksArray[num1182, num1183, 1, num1184]; - if (num1179 + num1185 > npc.ai[1]) + handAttackTimerComparison = NPC.MoonLordAttacksArray[handAttackType, handType, 1, handFiveFrameTimer]; + if (handAttackTimerComparison + handAttackTimerIncrement > npc.ai[1]) break; - num1185 += (int)num1179; - int num = num1184; - num1184 = num + 1; + handAttackTimerIncrement += (int)handAttackTimerComparison; + int totalSpawns = handFiveFrameTimer; + handFiveFrameTimer = totalSpawns + 1; } - if (num1184 == 5) + if (handFiveFrameTimer == 5) { - num1184 = 0; + handFiveFrameTimer = 0; npc.ai[1] = 0f; - num1179 = NPC.MoonLordAttacksArray[num1182, num1183, 1, num1184]; - num1185 = 0; + handAttackTimerComparison = NPC.MoonLordAttacksArray[handAttackType, handType, 1, handFiveFrameTimer]; + handAttackTimerIncrement = 0; } - npc.ai[0] = NPC.MoonLordAttacksArray[num1182, num1183, 0, num1184]; - num1178 = (int)npc.ai[1] - num1185; - if (npc.ai[0] != num1181) + npc.ai[0] = NPC.MoonLordAttacksArray[handAttackType, handType, 0, handFiveFrameTimer]; + handAttackTimer = (int)npc.ai[1] - handAttackTimerIncrement; + if (npc.ai[0] != handAI0CrossCheck) npc.netUpdate = true; } if (npc.ai[0] == -2f) { - num1180 = 0; + handFrameCheck = 0; npc.dontTakeDamage = true; @@ -1059,18 +1056,18 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Move else if (npc.ai[0] == 0f) { - num1180 = 3; + handFrameCheck = 3; npc.localAI[1] -= 0.05f; if (npc.localAI[1] < 0f) npc.localAI[1] = 0f; - Vector2 center15 = Main.npc[(int)npc.ai[3]].Center; - Vector2 value10 = center15 + new Vector2(350f * num1177, -100f); - Vector2 vector167 = value10 - npc.Center; + Vector2 handCenter = Main.npc[(int)npc.ai[3]].Center; + Vector2 handMovementVector = handCenter + new Vector2(350f * handFaceDirection, -100f); + Vector2 handMovementDirection = handMovementVector - npc.Center; - if (vector167.Length() > 20f) + if (handMovementDirection.Length() > 20f) { - vector167.Normalize(); + handMovementDirection.Normalize(); float velocity = death ? 7.75f : 7.5f; switch (aggressionLevel) @@ -1096,23 +1093,20 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses break; } - vector167 *= velocity; - Vector2 velocity5 = npc.velocity; + handMovementDirection *= velocity; + Vector2 handVelocity = npc.velocity; - if (vector167 != Vector2.Zero) - npc.SimpleFlyMovement(vector167, 0.3f); + if (handMovementDirection != Vector2.Zero) + npc.SimpleFlyMovement(handMovementDirection, 0.3f); - npc.velocity = Vector2.Lerp(velocity5, npc.velocity, 0.5f); + npc.velocity = Vector2.Lerp(handVelocity, npc.velocity, 0.5f); } } // Phantasmal Eyes else if (npc.ai[0] == 1f) { - num1180 = 0; - int num1186 = 7; - int num1187 = 4; - + handFrameCheck = 0; float divisor = 6f; switch (aggressionLevel) { @@ -1137,26 +1131,26 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses break; } - if (num1178 >= (num1186 * num1187 * 2)) + if (handAttackTimer >= 56) { npc.localAI[1] -= 0.07f; if (npc.localAI[1] < 0f) npc.localAI[1] = 0f; } - else if (num1178 >= (num1186 * num1187)) + else if (handAttackTimer >= 28) { npc.localAI[1] += 0.05f; if (npc.localAI[1] > 0.75f) npc.localAI[1] = 0.75f; - float num1188 = MathHelper.TwoPi * (num1178 % (num1186 * num1187)) / (num1186 * num1187) - MathHelper.PiOver2; - npc.localAI[0] = new Vector2((float)Math.Cos(num1188) * vector165.X, (float)Math.Sin(num1188) * vector165.Y).ToRotation(); + float handLocalAI = MathHelper.TwoPi * (handAttackTimer % 28) / 28 - MathHelper.PiOver2; + npc.localAI[0] = new Vector2((float)Math.Cos(handLocalAI) * handBehaviorVector.X, (float)Math.Sin(handLocalAI) * handBehaviorVector.Y).ToRotation(); - if (num1178 % divisor == 0f) + if (handAttackTimer % divisor == 0f) { - Vector2 value11 = new Vector2(1f * -num1177, 3f); - Vector2 vector168 = Utils.Vector2FromElipse(npc.localAI[0].ToRotationVector2(), vector165 * npc.localAI[1]); - Vector2 vector169 = npc.Center + Vector2.Normalize(vector168) * vector165.Length() * 0.4f + value11; + Vector2 handAttackVector = new Vector2(1f * -handFaceDirection, 3f); + Vector2 handAttackRotation = Utils.Vector2FromElipse(npc.localAI[0].ToRotationVector2(), handBehaviorVector * npc.localAI[1]); + Vector2 handAttackMovement = npc.Center + Vector2.Normalize(handAttackRotation) * handBehaviorVector.Length() * 0.4f + handAttackVector; float velocity = death ? 3.5f : 3f; switch (aggressionLevel) @@ -1178,11 +1172,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses break; } - Vector2 vector170 = Vector2.Normalize(vector168) * velocity; - float ai = (MathHelper.TwoPi * (float)Main.rand.NextDouble() - MathHelper.Pi) / 30f + 0.0174532924f * num1177; + Vector2 handAttackDirection = Vector2.Normalize(handAttackRotation) * velocity; + float ai = (MathHelper.TwoPi * (float)Main.rand.NextDouble() - MathHelper.Pi) / 30f + 0.0174532924f * handFaceDirection; int type = ProjectileID.PhantasmalEye; int damage = npc.GetProjectileDamage(type); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), vector169, vector170, type, damage, 0f, Main.myPlayer, 0f, ai); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), handAttackMovement, handAttackDirection, type, damage, 0f, Main.myPlayer, 0f, ai); Main.projectile[proj].timeLeft = 1200; Main.projectile[proj].Calamity().lineColor = bossRush ? 1 : aggressionLevel; } @@ -1193,8 +1187,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.localAI[1] > 0.75f) npc.localAI[1] = 0.75f; - float num1189 = MathHelper.TwoPi * (num1178 % (num1186 * num1187)) / (num1186 * num1187) - MathHelper.PiOver2; - npc.localAI[0] = new Vector2((float)Math.Cos(num1189) * vector165.X, (float)Math.Sin(num1189) * vector165.Y).ToRotation(); + float handPauseDirection = MathHelper.TwoPi * (handAttackTimer % 28) / 28 - MathHelper.PiOver2; + npc.localAI[0] = new Vector2((float)Math.Cos(handPauseDirection) * handBehaviorVector.X, (float)Math.Sin(handPauseDirection) * handBehaviorVector.Y).ToRotation(); } } @@ -1205,10 +1199,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.localAI[1] < 0f) npc.localAI[1] = 0f; - Vector2 center16 = Main.npc[(int)npc.ai[3]].Center; - Vector2 value12 = new Vector2(220f * num1177, -60f) + center16; - value12 += new Vector2(num1177 * 100f, -50f); - Vector2 value13 = new Vector2(400f * num1177, -60f); + Vector2 handCenter = Main.npc[(int)npc.ai[3]].Center; + Vector2 sphereHandDirection = new Vector2(220f * handFaceDirection, -60f) + handCenter; + sphereHandDirection += new Vector2(handFaceDirection * 100f, -50f); + Vector2 sphereHandDirectionMaxBound = new Vector2(400f * handFaceDirection, -60f); float velocityMultiplier = death ? 0.88f : 0.885f; switch (aggressionLevel) @@ -1234,13 +1228,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses break; } - if (num1178 < 30f) + if (handAttackTimer < 30f) { - Vector2 vector171 = value12 - npc.Center; - if (vector171 != Vector2.Zero) + Vector2 sphereHandTravelVelocity = sphereHandDirection - npc.Center; + if (sphereHandTravelVelocity != Vector2.Zero) { - Vector2 vector172 = vector171; - vector172.Normalize(); + Vector2 sphereHandTravelDist = sphereHandTravelVelocity; + sphereHandTravelDist.Normalize(); float velocity = death ? 11f : 10f; switch (aggressionLevel) @@ -1266,13 +1260,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses break; } - npc.velocity = Vector2.SmoothStep(npc.velocity, vector172 * Math.Min(velocity, vector171.Length()), 0.2f); + npc.velocity = Vector2.SmoothStep(npc.velocity, sphereHandTravelDist * Math.Min(velocity, sphereHandTravelVelocity.Length()), 0.2f); } } - else if (num1178 < 210f) + else if (handAttackTimer < 210f) { - num1180 = 1; - int num1190 = (int)num1178 - 30; + handFrameCheck = 1; + int sphereHandSpeed = (int)handAttackTimer - 30; int divisor = 30; switch (aggressionLevel) @@ -1298,24 +1292,24 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses break; } - if (num1190 % divisor == 0 && Main.netMode != NetmodeID.MultiplayerClient) + if (sphereHandSpeed % divisor == 0 && Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector173 = new Vector2(5f * num1177, -8f); - int num1191 = num1190 / 30; - vector173.X += (num1191 - 3.5f) * num1177 * 3f; - vector173.Y += (num1191 - 4.5f) * 1f; - vector173 *= 1.2f; + Vector2 sphereFireDirection = new Vector2(5f * handFaceDirection, -8f); + int finalSphereHandSpeed = sphereHandSpeed / 30; + sphereFireDirection.X += (finalSphereHandSpeed - 3.5f) * handFaceDirection * 3f; + sphereFireDirection.Y += (finalSphereHandSpeed - 4.5f) * 1f; + sphereFireDirection *= 1.2f; int type = ProjectileID.PhantasmalSphere; int damage = npc.GetProjectileDamage(type); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, vector173.X, vector173.Y, type, damage, 1f, Main.myPlayer, 0f, npc.whoAmI); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, sphereFireDirection.X, sphereFireDirection.Y, type, damage, 1f, Main.myPlayer, 0f, npc.whoAmI); Main.projectile[proj].timeLeft = 1200; } - Vector2 vector174 = Vector2.SmoothStep(value12, value12 + value13, (num1178 - 30f) / 180f) - npc.Center; - if (vector174 != Vector2.Zero) + Vector2 handSmoothMovement = Vector2.SmoothStep(sphereHandDirection, sphereHandDirection + sphereHandDirectionMaxBound, (handAttackTimer - 30f) / 180f) - npc.Center; + if (handSmoothMovement != Vector2.Zero) { - Vector2 vector175 = vector174; - vector175.Normalize(); + Vector2 handSmoothMoveNormalize = handSmoothMovement; + handSmoothMoveNormalize.Normalize(); float velocity = death ? 26.5f : 24f; switch (aggressionLevel) @@ -1341,34 +1335,34 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses break; } - npc.velocity = Vector2.Lerp(npc.velocity, vector175 * Math.Min(velocity, vector174.Length()), 0.5f); + npc.velocity = Vector2.Lerp(npc.velocity, handSmoothMoveNormalize * Math.Min(velocity, handSmoothMovement.Length()), 0.5f); } } - else if (num1178 < 282f) + else if (handAttackTimer < 282f) { - num1180 = 0; + handFrameCheck = 0; npc.velocity *= velocityMultiplier; } - else if (num1178 < 287f) + else if (handAttackTimer < 287f) { - num1180 = 1; + handFrameCheck = 1; npc.velocity *= velocityMultiplier; } - else if (num1178 < 292f) + else if (handAttackTimer < 292f) { - num1180 = 2; + handFrameCheck = 2; npc.velocity *= velocityMultiplier; } - else if (num1178 < 300f) + else if (handAttackTimer < 300f) { - num1180 = 3; + handFrameCheck = 3; - if (num1178 == 292f && Main.netMode != NetmodeID.MultiplayerClient) + if (handAttackTimer == 292f && Main.netMode != NetmodeID.MultiplayerClient) { - int num1193 = Player.FindClosest(npc.position, npc.width, npc.height); - Vector2 vector176 = Vector2.Normalize(Main.player[num1193].Center - (npc.Center + Vector2.UnitY * -350f)); - if (float.IsNaN(vector176.X) || float.IsNaN(vector176.Y)) - vector176 = Vector2.UnitY; + int closestPlayer = Player.FindClosest(npc.position, npc.width, npc.height); + Vector2 sphereVelocity = Vector2.Normalize(Main.player[closestPlayer].Center - (npc.Center + Vector2.UnitY * -350f)); + if (float.IsNaN(sphereVelocity.X) || float.IsNaN(sphereVelocity.Y)) + sphereVelocity = Vector2.UnitY; float velocity = death ? 2.2f : 2f; switch (aggressionLevel) @@ -1394,24 +1388,24 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses break; } - vector176 *= velocity; - for (int num1194 = 0; num1194 < Main.maxProjectiles; num1194++) + sphereVelocity *= velocity; + for (int i = 0; i < Main.maxProjectiles; i++) { - Projectile projectile3 = Main.projectile[num1194]; - if (projectile3.active && projectile3.type == ProjectileID.PhantasmalSphere && projectile3.ai[1] == npc.whoAmI && projectile3.ai[0] != -1f) + Projectile currentProjectile = Main.projectile[i]; + if (currentProjectile.active && currentProjectile.type == ProjectileID.PhantasmalSphere && currentProjectile.ai[1] == npc.whoAmI && currentProjectile.ai[0] != -1f) { - projectile3.ai[0] = -1f; - projectile3.velocity = vector176; - projectile3.netUpdate = true; + currentProjectile.ai[0] = -1f; + currentProjectile.velocity = sphereVelocity; + currentProjectile.netUpdate = true; } } } - Vector2 vector177 = Vector2.SmoothStep(value12, value12 + value13, 1f - (num1178 - 270f) / 30f) - npc.Center; - if (vector177 != Vector2.Zero) + Vector2 handPauseSmoothSpeed = Vector2.SmoothStep(sphereHandDirection, sphereHandDirection + sphereHandDirectionMaxBound, 1f - (handAttackTimer - 270f) / 30f) - npc.Center; + if (handPauseSmoothSpeed != Vector2.Zero) { - Vector2 vector178 = vector177; - vector178.Normalize(); + Vector2 handPauseDirection = handPauseSmoothSpeed; + handPauseDirection.Normalize(); float velocity = death ? 19.75f : 17.5f; switch (aggressionLevel) @@ -1437,18 +1431,18 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses break; } - npc.velocity = Vector2.Lerp(npc.velocity, vector178 * Math.Min(velocity, vector177.Length()), 0.1f); + npc.velocity = Vector2.Lerp(npc.velocity, handPauseDirection * Math.Min(velocity, handPauseSmoothSpeed.Length()), 0.1f); } } else { - num1180 = 3; + handFrameCheck = 3; - Vector2 vector179 = value12 - npc.Center; - if (vector179 != Vector2.Zero) + Vector2 handReturnSmoothSpeed = sphereHandDirection - npc.Center; + if (handReturnSmoothSpeed != Vector2.Zero) { - Vector2 vector180 = vector179; - vector180.Normalize(); + Vector2 handReturnDirection = handReturnSmoothSpeed; + handReturnDirection.Normalize(); float velocity = death ? 11f : 10f; switch (aggressionLevel) @@ -1474,7 +1468,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses break; } - npc.velocity = Vector2.SmoothStep(npc.velocity, vector180 * Math.Min(velocity, vector179.Length()), 0.2f); + npc.velocity = Vector2.SmoothStep(npc.velocity, handReturnDirection * Math.Min(velocity, handReturnSmoothSpeed.Length()), 0.2f); } } } @@ -1482,16 +1476,16 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Phantasmal Bolts else if (npc.ai[0] == 3f) { - if (num1178 == 0f) + if (handAttackTimer == 0f) { npc.TargetClosest(false); npc.netUpdate = true; } Vector2 v = Main.player[npc.target].Center - npc.Center; - bool shootFirstBolt = num1178 == num1179 - 14f; - bool shootSecondBolt = num1178 == num1179 - 7f; - bool shootThirdBolt = num1178 == num1179; + bool shootFirstBolt = handAttackTimer == handAttackTimerComparison - 14f; + bool shootSecondBolt = handAttackTimer == handAttackTimerComparison - 7f; + bool shootThirdBolt = handAttackTimer == handAttackTimerComparison; switch (aggressionLevel) { case 6: @@ -1520,12 +1514,12 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.localAI[1] > 1f) npc.localAI[1] = 1f; - if (num1178 == num1179 - 35f) + if (handAttackTimer == handAttackTimerComparison - 35f) SoundEngine.PlaySound(SoundID.NPCDeath6, npc.position); if ((shootFirstBolt || shootSecondBolt || shootThirdBolt) && Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector181 = Utils.Vector2FromElipse(npc.localAI[0].ToRotationVector2(), vector165 * npc.localAI[1]); + Vector2 boltShootDirection = Utils.Vector2FromElipse(npc.localAI[0].ToRotationVector2(), handBehaviorVector * npc.localAI[1]); float velocity = death ? 6.75f : 6.25f; switch (aggressionLevel) @@ -1547,39 +1541,39 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses break; } - Vector2 vector182 = Vector2.Normalize(v) * velocity; + Vector2 boltShootSpeed = Vector2.Normalize(v) * velocity; int type = ProjectileID.PhantasmalBolt; int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + vector181.X, npc.Center.Y + vector181.Y, vector182.X, vector182.Y, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + boltShootDirection.X, npc.Center.Y + boltShootDirection.Y, boltShootSpeed.X, boltShootSpeed.Y, type, damage, 0f, Main.myPlayer, 0f, 0f); } } // Center - Vector2 center17 = Main.npc[(int)npc.ai[3]].Center; - Vector2 value14 = new Vector2(220f * num1177, -60f) + center17; - Vector2 vector183 = value14 + new Vector2(num1177 * 110f, -150f); - Vector2 vector184 = vector183 + new Vector2(num1177 * 370f, 150f); + Vector2 handCentering = Main.npc[(int)npc.ai[3]].Center; + Vector2 handDirection = new Vector2(220f * handFaceDirection, -60f) + handCentering; + Vector2 minHandFaceDirection = handDirection + new Vector2(handFaceDirection * 110f, -150f); + Vector2 maxHandFaceDirection = minHandFaceDirection + new Vector2(handFaceDirection * 370f, 150f); - if (vector183.X > vector184.X) - Utils.Swap(ref vector183.X, ref vector184.X); - if (vector183.Y > vector184.Y) - Utils.Swap(ref vector183.Y, ref vector184.Y); + if (minHandFaceDirection.X > maxHandFaceDirection.X) + Utils.Swap(ref minHandFaceDirection.X, ref maxHandFaceDirection.X); + if (minHandFaceDirection.Y > maxHandFaceDirection.Y) + Utils.Swap(ref minHandFaceDirection.Y, ref maxHandFaceDirection.Y); - Vector2 value15 = Vector2.Clamp(npc.Center + npc.velocity, vector183, vector184); - if (value15 != npc.Center + npc.velocity) - npc.Center = value15 - npc.velocity; + Vector2 handVelocity2 = Vector2.Clamp(npc.Center + npc.velocity, minHandFaceDirection, maxHandFaceDirection); + if (handVelocity2 != npc.Center + npc.velocity) + npc.Center = handVelocity2 - npc.velocity; // Frames - int num1195 = num1180 * 7; - if (num1195 > npc.frameCounter) + int handFrameTimer = handFrameCheck * 7; + if (handFrameTimer > npc.frameCounter) { - double num1196 = npc.frameCounter; - npc.frameCounter = num1196 + 1.0; + double handFrameControl = npc.frameCounter; + npc.frameCounter = handFrameControl + 1.0; } - if (num1195 < npc.frameCounter) + if (handFrameTimer < npc.frameCounter) { - double num1196 = npc.frameCounter; - npc.frameCounter = num1196 - 1.0; + double handFrameControl = npc.frameCounter; + npc.frameCounter = handFrameControl - 1.0; } if (npc.frameCounter < 0.0) @@ -1631,7 +1625,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.rand.NextBool(420)) SoundEngine.PlaySound(Main.rand.NextBool() ? SoundID.Zombie100 : SoundID.Zombie101, npc.Center); - Vector2 value22 = new Vector2(30f); + Vector2 thirtyVector = new Vector2(30f); if (!Main.npc[(int)npc.ai[3]].active || Main.npc[(int)npc.ai[3]].type != NPCID.MoonLordCore) { @@ -1640,35 +1634,35 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.active = false; } - float num1241 = 0f; - float num1242 = npc.ai[0]; + float secondAttackPicker = 0f; + float ai0Copy = npc.ai[0]; npc.ai[1] += 1f; - int num1243 = 0; - int num1244 = 0; - while (num1243 < 10) + int secondAttackArrayInc = 0; + int secondAttackPickerInc = 0; + while (secondAttackArrayInc < 10) { - num1241 = NPC.MoonLordAttacksArray2[1, num1243]; - if (num1241 + num1244 > npc.ai[1]) + secondAttackPicker = NPC.MoonLordAttacksArray2[1, secondAttackArrayInc]; + if (secondAttackPicker + secondAttackPickerInc > npc.ai[1]) break; - num1244 += (int)num1241; - num1243 += 1; + secondAttackPickerInc += (int)secondAttackPicker; + secondAttackArrayInc += 1; } - if (num1243 == 10) + if (secondAttackArrayInc == 10) { - num1243 = 0; + secondAttackArrayInc = 0; npc.ai[1] = 0f; - num1241 = NPC.MoonLordAttacksArray2[1, num1243]; - num1244 = 0; + secondAttackPicker = NPC.MoonLordAttacksArray2[1, secondAttackArrayInc]; + secondAttackPickerInc = 0; } - npc.ai[0] = NPC.MoonLordAttacksArray2[0, num1243]; - float num1245 = (int)npc.ai[1] - num1244; + npc.ai[0] = NPC.MoonLordAttacksArray2[0, secondAttackArrayInc]; + float secondAttackTimer = (int)npc.ai[1] - secondAttackPickerInc; - if (npc.ai[0] != num1242) + if (npc.ai[0] != ai0Copy) npc.netUpdate = true; if (npc.ai[0] == -1f) @@ -1677,10 +1671,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[1] > 180f) npc.ai[1] = 0f; - float value23; + float localAI2Lerp; if (npc.ai[1] < 60f) { - value23 = 0.75f; + localAI2Lerp = 0.75f; npc.localAI[0] = 0f; @@ -1690,7 +1684,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } else if (npc.ai[1] < 120f) { - value23 = 1f; + localAI2Lerp = 1f; if (npc.localAI[1] < 0.5f) npc.localAI[1] += 0.025f; @@ -1699,14 +1693,14 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } else { - value23 = 1.15f; + localAI2Lerp = 1.15f; npc.localAI[1] -= 0.05f; if (npc.localAI[1] < 0f) npc.localAI[1] = 0f; } - npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], value23, 0.3f); + npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], localAI2Lerp, 0.3f); } if (npc.ai[0] == 0f) @@ -1724,16 +1718,15 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], 1f, 0.2f); float velocity = death ? 38f : 36f; - Vector2 center23 = npc.Center; - Vector2 center24 = Main.player[npc.target].Center; - Vector2 value24 = center24 - center23; - value24 = Vector2.Normalize(value24) * velocity; + Vector2 freeEyeCenter = npc.Center; + Vector2 freeEyeTargetCenter = Main.player[npc.target].Center; + Vector2 freeEyeTargetDistance = freeEyeTargetCenter - freeEyeCenter; + freeEyeTargetDistance = Vector2.Normalize(freeEyeTargetDistance) * velocity; - if (Vector2.Distance(center23, center24) > 300f) + if (Vector2.Distance(freeEyeCenter, freeEyeTargetCenter) > 300f) { - int num1246 = 30; - npc.velocity.X = (npc.velocity.X * (num1246 - 1) + value24.X) / num1246; - npc.velocity.Y = (npc.velocity.Y * (num1246 - 1) + value24.Y) / num1246; + npc.velocity.X = (npc.velocity.X * 29 + freeEyeTargetDistance.X) / 30; + npc.velocity.Y = (npc.velocity.Y * 29 + freeEyeTargetDistance.Y) / 30; } else { @@ -1743,24 +1736,24 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Fly towards Moon Lord Head and stay away from other True Eyes - float num1247 = 0.5f; - for (int num1248 = 0; num1248 < Main.maxNPCs; num1248++) + float freeEyeAccel = 0.5f; + for (int j = 0; j < Main.maxNPCs; j++) { - if (Main.npc[num1248].active) + if (Main.npc[j].active) { - if (num1248 != npc.whoAmI && Main.npc[num1248].type == npc.type) + if (j != npc.whoAmI && Main.npc[j].type == npc.type) { - if (Vector2.Distance(npc.Center, Main.npc[num1248].Center) < 150f) + if (Vector2.Distance(npc.Center, Main.npc[j].Center) < 150f) { - if (npc.position.X < Main.npc[num1248].position.X) - npc.velocity.X = npc.velocity.X - num1247; + if (npc.position.X < Main.npc[j].position.X) + npc.velocity.X = npc.velocity.X - freeEyeAccel; else - npc.velocity.X = npc.velocity.X + num1247; + npc.velocity.X = npc.velocity.X + freeEyeAccel; - if (npc.position.Y < Main.npc[num1248].position.Y) - npc.velocity.Y = npc.velocity.Y - num1247; + if (npc.position.Y < Main.npc[j].position.Y) + npc.velocity.Y = npc.velocity.Y - freeEyeAccel; else - npc.velocity.Y = npc.velocity.Y + num1247; + npc.velocity.Y = npc.velocity.Y + freeEyeAccel; } } } @@ -1770,7 +1763,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[0] == 1f) { - if (num1245 == 0f) + if (secondAttackTimer == 0f) { npc.TargetClosest(false); npc.netUpdate = true; @@ -1788,22 +1781,22 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.localAI[1] > 1f) npc.localAI[1] = 1f; - if (num1245 < 20f) + if (secondAttackTimer < 20f) npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], 1.1f, 0.2f); else npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], 0.4f, 0.2f); - if (num1245 == num1241 - 35f) + if (secondAttackTimer == secondAttackPicker - 35f) SoundEngine.PlaySound(SoundID.NPCDeath6, npc.position); - if ((num1245 == num1241 - 14f || num1245 == num1241 - 7f || num1245 == num1241) && Main.netMode != NetmodeID.MultiplayerClient) + if ((secondAttackTimer == secondAttackPicker - 14f || secondAttackTimer == secondAttackPicker - 7f || secondAttackTimer == secondAttackPicker) && Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector214 = Utils.Vector2FromElipse(npc.localAI[0].ToRotationVector2(), value22 * npc.localAI[1]); + Vector2 freeEyeBoltDirection = Utils.Vector2FromElipse(npc.localAI[0].ToRotationVector2(), thirtyVector * npc.localAI[1]); float velocity = death ? 9f : 8f; - Vector2 vector215 = Vector2.Normalize(v8) * velocity; + Vector2 freeEyeBoltVel = Vector2.Normalize(v8) * velocity; int type = ProjectileID.PhantasmalBolt; int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + vector214.X, npc.Center.Y + vector214.Y, vector215.X, vector215.Y, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + freeEyeBoltDirection.X, npc.Center.Y + freeEyeBoltDirection.Y, freeEyeBoltVel.X, freeEyeBoltVel.Y, type, damage, 0f, Main.myPlayer, 0f, 0f); } } else if (npc.ai[0] == 2f || npc.ai[0] == 4f) @@ -1811,7 +1804,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses int type = ProjectileID.PhantasmalSphere; int damage = npc.GetProjectileDamage(type); - if (num1245 < 15f) + if (secondAttackTimer < 15f) { npc.localAI[1] -= 0.07f; if (npc.localAI[1] < 0f) @@ -1823,70 +1816,70 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.velocity.Length() < 1f) npc.velocity = Vector2.Zero; } - else if (num1245 < 75f) + else if (secondAttackTimer < 75f) { - float num1249 = (num1245 - 15f) / 10f; - int num1250 = 0; - int num1251 = 0; - switch ((int)num1249) + float freeEyeAttackPattern = (secondAttackTimer - 15f) / 10f; + int freeEyeRotateValue = 0; + int freeEyeRotateValue2 = 0; + switch ((int)freeEyeAttackPattern) { case 0: - num1250 = 0; - num1251 = 2; + freeEyeRotateValue = 0; + freeEyeRotateValue2 = 2; break; case 1: - num1250 = 2; - num1251 = 5; + freeEyeRotateValue = 2; + freeEyeRotateValue2 = 5; break; case 2: - num1250 = 5; - num1251 = 3; + freeEyeRotateValue = 5; + freeEyeRotateValue2 = 3; break; case 3: - num1250 = 3; - num1251 = 1; + freeEyeRotateValue = 3; + freeEyeRotateValue2 = 1; break; case 4: - num1250 = 1; - num1251 = 4; + freeEyeRotateValue = 1; + freeEyeRotateValue2 = 4; break; case 5: - num1250 = 4; - num1251 = 0; + freeEyeRotateValue = 4; + freeEyeRotateValue2 = 0; break; } Vector2 spinningpoint2 = Vector2.UnitY * -30f; - Vector2 value25 = spinningpoint2.RotatedBy(num1250 * MathHelper.TwoPi / 6f); - Vector2 value26 = spinningpoint2.RotatedBy(num1251 * MathHelper.TwoPi / 6f); - Vector2 vector216 = Vector2.Lerp(value25, value26, num1249 - (int)num1249); - float value27 = vector216.Length() / 30f; + Vector2 freeEyeRotateLerpValue = spinningpoint2.RotatedBy(freeEyeRotateValue * MathHelper.TwoPi / 6f); + Vector2 freeEyeRotateLerpValue2 = spinningpoint2.RotatedBy(freeEyeRotateValue2 * MathHelper.TwoPi / 6f); + Vector2 freeEyeRotation = Vector2.Lerp(freeEyeRotateLerpValue, freeEyeRotateLerpValue2, freeEyeAttackPattern - (int)freeEyeAttackPattern); + float freeEyeRotationDist = freeEyeRotation.Length() / 30f; - npc.localAI[0] = vector216.ToRotation(); - npc.localAI[1] = MathHelper.Lerp(npc.localAI[1], value27, 0.5f); + npc.localAI[0] = freeEyeRotation.ToRotation(); + npc.localAI[1] = MathHelper.Lerp(npc.localAI[1], freeEyeRotationDist, 0.5f); - for (int num1252 = 0; num1252 < 2; num1252++) + for (int k = 0; k < 2; k++) { - int num1253 = Dust.NewDust(npc.Center + vector216 - Vector2.One * 4f, 0, 0, 229, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num1253]; - dust.velocity += vector216 / 15f; - Main.dust[num1253].noGravity = true; + int trueEyeDust = Dust.NewDust(npc.Center + freeEyeRotation - Vector2.One * 4f, 0, 0, 229, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[trueEyeDust]; + dust.velocity += freeEyeRotation / 15f; + Main.dust[trueEyeDust].noGravity = true; } - if ((num1245 - 15f) % 10f == 0f && Main.netMode != NetmodeID.MultiplayerClient) + if ((secondAttackTimer - 15f) % 10f == 0f && Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector217 = Vector2.Normalize(vector216); - if (vector217.HasNaNs()) - vector217 = Vector2.UnitY * -1f; + Vector2 trueEyeSphereDirection = Vector2.Normalize(freeEyeRotation); + if (trueEyeSphereDirection.HasNaNs()) + trueEyeSphereDirection = Vector2.UnitY * -1f; float spreadVelocity = death ? 4.5f : 4f; - vector217 *= 4f; - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + vector216.X, npc.Center.Y + vector216.Y, vector217.X, vector217.Y, type, 0, 0f, Main.myPlayer, 30f, npc.whoAmI); + trueEyeSphereDirection *= 4f; + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + freeEyeRotation.X, npc.Center.Y + freeEyeRotation.Y, trueEyeSphereDirection.X, trueEyeSphereDirection.Y, type, 0, 0f, Main.myPlayer, 30f, npc.whoAmI); Main.projectile[proj].timeLeft = 1200; if (CalamityWorld.LegendaryMode) { - for (int num1268 = 0; num1268 < 3; num1268++) + for (int k = 0; k < 3; k++) { if (!WorldGen.SolidTile((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f))) Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, (float)Main.rand.Next(-1599, 1600) * 0.01f, (float)Main.rand.Next(-1599, 1) * 0.01f, ProjectileID.MoonBoulder, 70, 10f); @@ -1896,13 +1889,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } else { - if (num1245 < 105f) + if (secondAttackTimer < 105f) { npc.localAI[0] = npc.localAI[0].AngleLerp(npc.ai[2] - MathHelper.PiOver2, 0.2f); npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], 0.75f, 0.2f); - if (num1245 == 75f) + if (secondAttackTimer == 75f) { npc.TargetClosest(false); @@ -1910,14 +1903,14 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.velocity = Vector2.UnitY * -7f; - for (int num1255 = 0; num1255 < Main.maxProjectiles; num1255++) + for (int i = 0; i < Main.maxProjectiles; i++) { - Projectile projectile7 = Main.projectile[num1255]; - if (projectile7.active && projectile7.type == type && projectile7.ai[1] == npc.whoAmI && projectile7.ai[0] != -1f) + Projectile trueEyeSpheres = Main.projectile[i]; + if (trueEyeSpheres.active && trueEyeSpheres.type == type && trueEyeSpheres.ai[1] == npc.whoAmI && trueEyeSpheres.ai[0] != -1f) { - Projectile projectile8 = projectile7; - projectile8.velocity += npc.velocity; - projectile7.netUpdate = true; + Projectile trueEyeSphereVel = trueEyeSpheres; + trueEyeSphereVel.velocity += npc.velocity; + trueEyeSpheres.netUpdate = true; } } } @@ -1931,26 +1924,26 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses return false; } - if (num1245 < 120f) + if (secondAttackTimer < 120f) { SoundEngine.PlaySound(SoundID.Zombie102, npc.Center); - if (num1245 == 105f) + if (secondAttackTimer == 105f) npc.netUpdate = true; float velocity = death ? 13.25f : 12f; - Vector2 velocity6 = (npc.ai[2] - MathHelper.PiOver2).ToRotationVector2() * velocity; - npc.velocity = velocity6 * 2f; + Vector2 trueEyeSphereVelocity = (npc.ai[2] - MathHelper.PiOver2).ToRotationVector2() * velocity; + npc.velocity = trueEyeSphereVelocity * 2f; - for (int num1256 = 0; num1256 < Main.maxProjectiles; num1256++) + for (int i = 0; i < Main.maxProjectiles; i++) { - Projectile projectile9 = Main.projectile[num1256]; - if (projectile9.active && projectile9.type == type && projectile9.ai[1] == npc.whoAmI && projectile9.ai[0] != -1f) + Projectile trueEyeSphereProj = Main.projectile[i]; + if (trueEyeSphereProj.active && trueEyeSphereProj.type == type && trueEyeSphereProj.ai[1] == npc.whoAmI && trueEyeSphereProj.ai[0] != -1f) { - projectile9.ai[0] = -1f; - projectile9.damage = damage; - projectile9.velocity = velocity6; - projectile9.netUpdate = true; + trueEyeSphereProj.ai[0] = -1f; + trueEyeSphereProj.damage = damage; + trueEyeSphereProj.velocity = trueEyeSphereVelocity; + trueEyeSphereProj.netUpdate = true; } } @@ -1963,7 +1956,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } else if (npc.ai[0] == 3f) { - if (num1245 < 15f) + if (secondAttackTimer < 15f) { npc.localAI[1] -= 0.07f; if (npc.localAI[1] < 0f) @@ -1975,17 +1968,17 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.velocity.Length() < 1f) npc.velocity = Vector2.Zero; } - else if (num1245 < 45f) + else if (secondAttackTimer < 45f) { npc.localAI[0] = 0f; - npc.localAI[1] = (float)Math.Sin((num1245 - 15f) * MathHelper.TwoPi / 15f) * 0.5f; + npc.localAI[1] = (float)Math.Sin((secondAttackTimer - 15f) * MathHelper.TwoPi / 15f) * 0.5f; if (npc.localAI[1] < 0f) npc.localAI[0] = MathHelper.Pi; } else { - if (num1245 >= 185f) + if (secondAttackTimer >= 185f) { npc.velocity *= 0.88f; @@ -1999,13 +1992,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses return false; } - if (num1245 == 45f) + if (secondAttackTimer == 45f) { npc.ai[2] = Main.rand.NextBool().ToDirectionInt() * MathHelper.TwoPi / 40f; npc.netUpdate = true; } - if ((num1245 - 15f - 30f) % 40f == 0f) + if ((secondAttackTimer - 15f - 30f) % 40f == 0f) npc.ai[2] *= 0.95f; npc.localAI[0] += npc.ai[2]; @@ -2014,34 +2007,34 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.localAI[1] > 1f) npc.localAI[1] = 1f; - Vector2 vector218 = npc.localAI[0].ToRotationVector2() * value22 * npc.localAI[1]; - float scaleFactor10 = MathHelper.Lerp(8f, 20f, (num1245 - 15f - 30f) / 140f); + Vector2 trueEyeDirection = npc.localAI[0].ToRotationVector2() * thirtyVector * npc.localAI[1]; + float trueEyeVelScale = MathHelper.Lerp(8f, 20f, (secondAttackTimer - 15f - 30f) / 140f); - npc.velocity = Vector2.Normalize(vector218) * scaleFactor10; + npc.velocity = Vector2.Normalize(trueEyeDirection) * trueEyeVelScale; npc.rotation = npc.rotation.AngleLerp(npc.velocity.ToRotation() + MathHelper.PiOver2, 0.2f); - if ((num1245 - 15f - 30f) % 10f == 0f && Main.netMode != NetmodeID.MultiplayerClient) + if ((secondAttackTimer - 15f - 30f) % 10f == 0f && Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector219 = npc.Center + Vector2.Normalize(vector218) * value22.Length() * 0.4f; + Vector2 trueEyeEyeDirection = npc.Center + Vector2.Normalize(trueEyeDirection) * thirtyVector.Length() * 0.4f; float velocity = death ? 6f : 5f; - Vector2 vector220 = Vector2.Normalize(vector218) * velocity; + Vector2 trueEyeEyeSpeed = Vector2.Normalize(trueEyeDirection) * velocity; float ai3 = (MathHelper.TwoPi * (float)Main.rand.NextDouble() - MathHelper.Pi) / 30f + 0.0174532924f * npc.ai[2]; int type = ProjectileID.PhantasmalEye; int damage = npc.GetProjectileDamage(type); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), vector219, vector220, type, damage, 0f, Main.myPlayer, 0f, ai3); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), trueEyeEyeDirection, trueEyeEyeSpeed, type, damage, 0f, Main.myPlayer, 0f, ai3); Main.projectile[proj].timeLeft = 1200; } } } else if (npc.ai[0] == 4f) { - if (num1245 == 0f) + if (secondAttackTimer == 0f) { npc.TargetClosest(false); npc.netUpdate = true; } - if (num1245 < 180f) + if (secondAttackTimer < 180f) { npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], 1f, 0.2f); @@ -2053,41 +2046,37 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.velocity.Length() < 1f) npc.velocity = Vector2.Zero; - if (num1245 >= 60f) + if (secondAttackTimer >= 60f) { - Vector2 center25 = npc.Center; + Vector2 trueEyeCentering = npc.Center; - int num1257 = 0; - if (num1245 >= 120f) - num1257 = 1; + int dustAmt = 0; + if (secondAttackTimer >= 120f) + dustAmt = 1; - for (int num1258 = 0; num1258 < 1 + num1257; num1258++) + for (int j = 0; j < 1 + dustAmt; j++) { - int num1259 = 229; - float num1260 = 0.8f; - if (num1258 % 2 == 1) - { - num1259 = 229; - num1260 = 1.65f; - } + float dustScale = 0.8f; + if (j % 2 == 1) + dustScale = 1.65f; - Vector2 vector221 = center25 + ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * value22 / 2f; - int num1261 = Dust.NewDust(vector221 - Vector2.One * 8f, 16, 16, num1259, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, default, 1f); - Main.dust[num1261].velocity = Vector2.Normalize(center25 - vector221) * 3.5f * (10f - num1257 * 2f) / 10f; - Main.dust[num1261].noGravity = true; - Main.dust[num1261].scale = num1260; - Main.dust[num1261].customData = npc; + Vector2 trueEyeDustDirection = trueEyeCentering + ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * thirtyVector / 2f; + int trueEyeDust = Dust.NewDust(trueEyeDustDirection - Vector2.One * 8f, 16, 16, 229, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, default, 1f); + Main.dust[trueEyeDust].velocity = Vector2.Normalize(trueEyeCentering - trueEyeDustDirection) * 3.5f * (10f - dustAmt * 2f) / 10f; + Main.dust[trueEyeDust].noGravity = true; + Main.dust[trueEyeDust].scale = dustScale; + Main.dust[trueEyeDust].customData = npc; } } } else { - if (num1245 < num1241 - 15f) + if (secondAttackTimer < secondAttackPicker - 15f) { if (calamityGlobalNPC.newAI[1] == 0f) calamityGlobalNPC.newAI[1] = 600f; - if (num1245 == 180f && Main.netMode != NetmodeID.MultiplayerClient) + if (secondAttackTimer == 180f && Main.netMode != NetmodeID.MultiplayerClient) { // If head is in deathray phase if (Main.npc[(int)Main.npc[(int)npc.ai[3]].localAI[2]].ai[0] == 1f) @@ -2095,18 +2084,18 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.TargetClosest(false); - Vector2 vector222 = Main.player[npc.target].Center - npc.Center; - vector222.Normalize(); + Vector2 deathrayTargetDist = Main.player[npc.target].Center - npc.Center; + deathrayTargetDist.Normalize(); - float num1262 = -1f; - if (vector222.X < 0f) - num1262 = 1f; + float deathraySweepDirection = -1f; + if (deathrayTargetDist.X < 0f) + deathraySweepDirection = 1f; - vector222 = vector222.RotatedBy(-(double)num1262 * MathHelper.TwoPi / 6f); + deathrayTargetDist = deathrayTargetDist.RotatedBy(-(double)deathraySweepDirection * MathHelper.TwoPi / 6f); int type = ProjectileID.PhantasmalDeathray; int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, vector222.X, vector222.Y, type, damage, 0f, Main.myPlayer, num1262 * MathHelper.TwoPi / calamityGlobalNPC.newAI[1], npc.whoAmI); - npc.ai[2] = (vector222.ToRotation() + MathHelper.Pi + MathHelper.TwoPi) * num1262; + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, deathrayTargetDist.X, deathrayTargetDist.Y, type, damage, 0f, Main.myPlayer, deathraySweepDirection * MathHelper.TwoPi / calamityGlobalNPC.newAI[1], npc.whoAmI); + npc.ai[2] = (deathrayTargetDist.ToRotation() + MathHelper.Pi + MathHelper.TwoPi) * deathraySweepDirection; npc.netUpdate = true; } @@ -2114,16 +2103,16 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.localAI[1] > 1f) npc.localAI[1] = 1f; - float num1263 = (npc.ai[2] >= 0f).ToDirectionInt(); - float num1264 = npc.ai[2]; - if (num1264 < 0f) - num1264 *= -1f; + float deathrayRotationDirection = (npc.ai[2] >= 0f).ToDirectionInt(); + float deathrayRotation = npc.ai[2]; + if (deathrayRotation < 0f) + deathrayRotation *= -1f; - num1264 += -(MathHelper.Pi + MathHelper.TwoPi); - num1264 += num1263 * MathHelper.TwoPi / calamityGlobalNPC.newAI[1]; + deathrayRotation += -(MathHelper.Pi + MathHelper.TwoPi); + deathrayRotation += deathrayRotationDirection * MathHelper.TwoPi / calamityGlobalNPC.newAI[1]; - npc.localAI[0] = num1264; - npc.ai[2] = (num1264 + MathHelper.Pi + MathHelper.TwoPi) * num1263; + npc.localAI[0] = deathrayRotation; + npc.ai[2] = (deathrayRotation + MathHelper.Pi + MathHelper.TwoPi) * deathrayRotationDirection; return false; } @@ -2139,13 +2128,12 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses else if (npc.type == NPCID.MoonLordLeechBlob) { // Variables - float num1265 = 180f; - Vector2 value28 = new Vector2(0f, 216f); - int num1266 = (int)Math.Abs(npc.ai[0]) - 1; - int num1267 = (int)npc.ai[1]; + Vector2 mouthMovement = new Vector2(0f, 216f); + int headNPCType = (int)Math.Abs(npc.ai[0]) - 1; + int moonLordHead = (int)npc.ai[1]; // Despawn - if (!Main.npc[num1266].active || Main.npc[num1266].type != NPCID.MoonLordHead) + if (!Main.npc[headNPCType].active || Main.npc[headNPCType].type != NPCID.MoonLordHead) { npc.life = 0; npc.HitEffect(0, 10.0); @@ -2155,86 +2143,86 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Heal the Moon Lord npc.ai[2] += 1f; - if (npc.ai[2] >= num1265) + if (npc.ai[2] >= 180f) { if (Main.netMode != NetmodeID.MultiplayerClient) { - int num1268 = (int)Main.npc[num1266].ai[3]; - int num1269 = -1; - int num1270 = -1; - int num1271 = num1266; + int k = (int)Main.npc[headNPCType].ai[3]; + int leftHandHeal = -1; + int rightHandHeal = -1; + int headHeal = headNPCType; - for (int num1272 = 0; num1272 < Main.maxNPCs; num1272++) + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num1272].active && Main.npc[num1272].ai[3] == num1268) + if (Main.npc[i].active && Main.npc[i].ai[3] == k) { - if (num1269 == -1 && Main.npc[num1272].type == NPCID.MoonLordHand && Main.npc[num1272].ai[2] == 0f) - num1269 = num1272; - if (num1270 == -1 && Main.npc[num1272].type == NPCID.MoonLordHand && Main.npc[num1272].ai[2] == 1f) - num1270 = num1272; - if (num1269 != -1 && num1270 != -1 && num1271 != -1) + if (leftHandHeal == -1 && Main.npc[i].type == NPCID.MoonLordHand && Main.npc[i].ai[2] == 0f) + leftHandHeal = i; + if (rightHandHeal == -1 && Main.npc[i].type == NPCID.MoonLordHand && Main.npc[i].ai[2] == 1f) + rightHandHeal = i; + if (leftHandHeal != -1 && rightHandHeal != -1 && headHeal != -1) break; } } // Heal limits - int num1273 = death ? 1500 : 1250; - int num1274 = Main.npc[num1268].lifeMax - Main.npc[num1268].life; - int num1275 = Main.npc[num1269].lifeMax - Main.npc[num1269].life; - int num1276 = Main.npc[num1270].lifeMax - Main.npc[num1270].life; - int num1277 = Main.npc[num1271].lifeMax - Main.npc[num1271].life; + int maxHealAmt = death ? 1500 : 1250; + int totalHealth = Main.npc[k].lifeMax - Main.npc[k].life; + int leftHandHealth = Main.npc[leftHandHeal].lifeMax - Main.npc[leftHandHeal].life; + int rightHandHealth = Main.npc[rightHandHeal].lifeMax - Main.npc[rightHandHeal].life; + int headHealth = Main.npc[headHeal].lifeMax - Main.npc[headHeal].life; // Healing - if (num1277 > 0 && num1273 > 0) + if (headHealth > 0 && maxHealAmt > 0) { - int num1278 = num1277 - num1273; - if (num1278 > 0) + int maxHealthFailsafe = headHealth - maxHealAmt; + if (maxHealthFailsafe > 0) { - num1278 = 0; + maxHealthFailsafe = 0; } - int num1279 = num1273 + num1278; - num1273 -= num1279; - NPC nPC6 = Main.npc[num1271]; - nPC6.life += num1279; - NPC.HealEffect(Utils.CenteredRectangle(Main.npc[num1271].Center, new Vector2(50f)), num1279, true); + int headHealingAmt = maxHealAmt + maxHealthFailsafe; + maxHealAmt -= headHealingAmt; + NPC nPC6 = Main.npc[headHeal]; + nPC6.life += headHealingAmt; + NPC.HealEffect(Utils.CenteredRectangle(Main.npc[headHeal].Center, new Vector2(50f)), headHealingAmt, true); } - if (num1274 > 0 && num1273 > 0) + if (totalHealth > 0 && maxHealAmt > 0) { - int num1280 = num1274 - num1273; - if (num1280 > 0) + int totalHealthFailsafe = totalHealth - maxHealAmt; + if (totalHealthFailsafe > 0) { - num1280 = 0; + totalHealthFailsafe = 0; } - int num1281 = num1273 + num1280; - num1273 -= num1281; - NPC nPC6 = Main.npc[num1268]; - nPC6.life += num1281; - NPC.HealEffect(Utils.CenteredRectangle(Main.npc[num1268].Center, new Vector2(50f)), num1281, true); + int totalHealingAmt = maxHealAmt + totalHealthFailsafe; + maxHealAmt -= totalHealingAmt; + NPC nPC6 = Main.npc[k]; + nPC6.life += totalHealingAmt; + NPC.HealEffect(Utils.CenteredRectangle(Main.npc[k].Center, new Vector2(50f)), totalHealingAmt, true); } - if (num1275 > 0 && num1273 > 0) + if (leftHandHealth > 0 && maxHealAmt > 0) { - int num1282 = num1275 - num1273; - if (num1282 > 0) + int leftHandHealthFailsafe = leftHandHealth - maxHealAmt; + if (leftHandHealthFailsafe > 0) { - num1282 = 0; + leftHandHealthFailsafe = 0; } - int num1283 = num1273 + num1282; - num1273 -= num1283; - NPC nPC6 = Main.npc[num1269]; - nPC6.life += num1283; - NPC.HealEffect(Utils.CenteredRectangle(Main.npc[num1269].Center, new Vector2(50f)), num1283, true); + int leftHandHealingAmt = maxHealAmt + leftHandHealthFailsafe; + maxHealAmt -= leftHandHealingAmt; + NPC nPC6 = Main.npc[leftHandHeal]; + nPC6.life += leftHandHealingAmt; + NPC.HealEffect(Utils.CenteredRectangle(Main.npc[leftHandHeal].Center, new Vector2(50f)), leftHandHealingAmt, true); } - if (num1276 > 0 && num1273 > 0) + if (rightHandHealth > 0 && maxHealAmt > 0) { - int num1284 = num1276 - num1273; - if (num1284 > 0) + int rightHandHealthFailsafe = rightHandHealth - maxHealAmt; + if (rightHandHealthFailsafe > 0) { - num1284 = 0; + rightHandHealthFailsafe = 0; } - int num1285 = num1273 + num1284; - NPC nPC6 = Main.npc[num1270]; - nPC6.life += num1285; - NPC.HealEffect(Utils.CenteredRectangle(Main.npc[num1270].Center, new Vector2(50f)), num1285, true); + int rightHandHealingAmt = maxHealAmt + rightHandHealthFailsafe; + NPC nPC6 = Main.npc[rightHandHeal]; + nPC6.life += rightHandHealingAmt; + NPC.HealEffect(Utils.CenteredRectangle(Main.npc[rightHandHeal].Center, new Vector2(50f)), rightHandHealingAmt, true); } } @@ -2247,26 +2235,26 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Move towards the Moon Lord mouth npc.velocity = Vector2.Zero; - npc.Center = Vector2.Lerp(Main.projectile[num1267].Center, Main.npc[(int)Math.Abs(npc.ai[0]) - 1].Center + value28, npc.ai[2] / num1265); + npc.Center = Vector2.Lerp(Main.projectile[moonLordHead].Center, Main.npc[(int)Math.Abs(npc.ai[0]) - 1].Center + mouthMovement, npc.ai[2] / 180f); // Emit dust Vector2 spinningpoint3 = Vector2.UnitY * -npc.height / 2f; - for (int num1286 = 0; num1286 < 4; num1286++) + for (int i = 0; i < 4; i++) { - int num1287 = Dust.NewDust(npc.Center - Vector2.One * 4f + spinningpoint3.RotatedBy(num1286 * MathHelper.TwoPi / 6f), 0, 0, 229, 0f, 0f, 0, default, 1f); - Main.dust[num1287].velocity = -Vector2.UnitY; - Main.dust[num1287].noGravity = true; - Main.dust[num1287].scale = 0.7f; - Main.dust[num1287].customData = npc; + int leechDust = Dust.NewDust(npc.Center - Vector2.One * 4f + spinningpoint3.RotatedBy(i * MathHelper.TwoPi / 6f), 0, 0, 229, 0f, 0f, 0, default, 1f); + Main.dust[leechDust].velocity = -Vector2.UnitY; + Main.dust[leechDust].noGravity = true; + Main.dust[leechDust].scale = 0.7f; + Main.dust[leechDust].customData = npc; } spinningpoint3 = Vector2.UnitY * -npc.height / 6f; - for (int num1288 = 0; num1288 < 2; num1288++) + for (int j = 0; j < 2; j++) { - int num1289 = Dust.NewDust(npc.Center - Vector2.One * 4f + spinningpoint3.RotatedBy(num1288 * MathHelper.TwoPi / 6f), 0, 0, 229, 0f, -2f, 0, default, 1f); - Main.dust[num1289].noGravity = true; - Main.dust[num1289].scale = 1.5f; - Main.dust[num1289].customData = npc; + int leechDust2 = Dust.NewDust(npc.Center - Vector2.One * 4f + spinningpoint3.RotatedBy(j * MathHelper.TwoPi / 6f), 0, 0, 229, 0f, -2f, 0, default, 1f); + Main.dust[leechDust2].noGravity = true; + Main.dust[leechDust2].scale = 1.5f; + Main.dust[leechDust2].customData = npc; } } return false; diff --git a/NPCs/VanillaNPCOverrides/Bosses/PlanteraAI.cs b/NPCs/VanillaNPCOverrides/Bosses/PlanteraAI.cs index 5d9e8ebfd4..c4479e2103 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/PlanteraAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/PlanteraAI.cs @@ -846,9 +846,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Set timer to new amount if a different hook is currently moving if (!despawn && npc.localAI[0] <= 0f && npc.ai[0] != 0f) { - for (int num763 = 0; num763 < Main.maxNPCs; num763++) + for (int i = 0; i < Main.maxNPCs; i++) { - if (num763 != npc.whoAmI && Main.npc[num763].active && Main.npc[num763].type == npc.type && (Main.npc[num763].velocity.X != 0f || Main.npc[num763].velocity.Y != 0f)) + if (i != npc.whoAmI && Main.npc[i].active && Main.npc[i].type == npc.type && (Main.npc[i].velocity.X != 0f || Main.npc[i].velocity.Y != 0f)) npc.localAI[0] = Main.rand.Next(60, 301); } } @@ -860,39 +860,39 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.localAI[0] = Main.rand.Next(300, 601); // Pick location - bool flag50 = false; - int num764 = 0; - while (!flag50 && num764 <= 1000) + bool hookCanMove = false; + int hookMoveTries = 0; + while (!hookCanMove && hookMoveTries <= 1000) { - num764++; + hookMoveTries++; - int num765 = (int)(Main.player[Main.npc[NPC.plantBoss].target].Center.X / 16f); - int num766 = (int)(Main.player[Main.npc[NPC.plantBoss].target].Center.Y / 16f); + int targetTilePosX = (int)(Main.player[Main.npc[NPC.plantBoss].target].Center.X / 16f); + int targetTilePosY = (int)(Main.player[Main.npc[NPC.plantBoss].target].Center.Y / 16f); if (npc.ai[0] == 0f) { - num765 = (int)((Main.player[Main.npc[NPC.plantBoss].target].Center.X + Main.npc[NPC.plantBoss].Center.X) / 32f); - num766 = (int)((Main.player[Main.npc[NPC.plantBoss].target].Center.Y + Main.npc[NPC.plantBoss].Center.Y) / 32f); + targetTilePosX = (int)((Main.player[Main.npc[NPC.plantBoss].target].Center.X + Main.npc[NPC.plantBoss].Center.X) / 32f); + targetTilePosY = (int)((Main.player[Main.npc[NPC.plantBoss].target].Center.Y + Main.npc[NPC.plantBoss].Center.Y) / 32f); } if (despawn) { - num765 = (int)Main.npc[NPC.plantBoss].position.X / 16; - num766 = (int)(Main.npc[NPC.plantBoss].position.Y + 400f) / 16; + targetTilePosX = (int)Main.npc[NPC.plantBoss].position.X / 16; + targetTilePosY = (int)(Main.npc[NPC.plantBoss].position.Y + 400f) / 16; } - int num767 = 20; - num767 += (int)(100f * (num764 / 1000f)); - int num768 = num765 + Main.rand.Next(-num767, num767 + 1); - int num769 = num766 + Main.rand.Next(-num767, num767 + 1); + int hookTileOffset = 20; + hookTileOffset += (int)(100f * (hookMoveTries / 1000f)); + int hookTileX = targetTilePosX + Main.rand.Next(-hookTileOffset, hookTileOffset + 1); + int hookTileY = targetTilePosY + Main.rand.Next(-hookTileOffset, hookTileOffset + 1); try { - if (WorldGen.SolidTile(num768, num769) || (Main.tile[num768, num769].WallType > 0 && (num764 > 500 || lifeRatio < 0.5f))) + if (WorldGen.SolidTile(hookTileX, hookTileY) || (Main.tile[hookTileX, hookTileY].WallType > 0 && (hookMoveTries > 500 || lifeRatio < 0.5f))) { - flag50 = true; - npc.ai[0] = num768; - npc.ai[1] = num769; + hookCanMove = true; + npc.ai[0] = hookTileX; + npc.ai[1] = hookTileY; npc.netUpdate = true; } } @@ -915,11 +915,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses velocity *= 2f; // Moving to new location - Vector2 vector95 = new Vector2(npc.Center.X, npc.Center.Y); - float num773 = npc.ai[0] * 16f - 8f - vector95.X; - float num774 = npc.ai[1] * 16f - 8f - vector95.Y; - float num775 = (float)Math.Sqrt(num773 * num773 + num774 * num774); - if (num775 < 12f + velocity) + Vector2 hookCenter = new Vector2(npc.Center.X, npc.Center.Y); + float hookMoveX = npc.ai[0] * 16f - 8f - hookCenter.X; + float hookMoveY = npc.ai[1] * 16f - 8f - hookCenter.Y; + float hookMoveDistance = (float)Math.Sqrt(hookMoveX * hookMoveX + hookMoveY * hookMoveY); + if (hookMoveDistance < 12f + velocity) { if (Main.netMode != NetmodeID.MultiplayerClient && Main.getGoodWorld && npc.localAI[3] == 1f) { @@ -927,24 +927,24 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses WorldGen.SpawnPlanteraThorns(npc.Center); } - npc.velocity.X = num773; - npc.velocity.Y = num774; + npc.velocity.X = hookMoveX; + npc.velocity.Y = hookMoveY; } else { if (Main.netMode != NetmodeID.MultiplayerClient && Main.getGoodWorld) npc.localAI[3] = 1f; - num775 = velocity / num775; - npc.velocity.X = num773 * num775; - npc.velocity.Y = num774 * num775; + hookMoveDistance = velocity / hookMoveDistance; + npc.velocity.X = hookMoveX * hookMoveDistance; + npc.velocity.Y = hookMoveY * hookMoveDistance; } // Rotation - Vector2 vector96 = new Vector2(npc.Center.X, npc.Center.Y); - float num776 = Main.npc[NPC.plantBoss].Center.X - vector96.X; - float num777 = Main.npc[NPC.plantBoss].Center.Y - vector96.Y; - npc.rotation = (float)Math.Atan2(num777, num776) - MathHelper.PiOver2; + Vector2 hookCenterRotation = new Vector2(npc.Center.X, npc.Center.Y); + float plantXDirection = Main.npc[NPC.plantBoss].Center.X - hookCenterRotation.X; + float plantYDirection = Main.npc[NPC.plantBoss].Center.Y - hookCenterRotation.Y; + npc.rotation = (float)Math.Atan2(plantYDirection, plantXDirection) - MathHelper.PiOver2; } return false; @@ -1019,13 +1019,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Velocity and acceleration - float num779 = death ? 2.4f : 1.6f; + float tentacleAcceleration = death ? 2.4f : 1.6f; float extendedDistanceFromPlantera = (1f - lifeRatio) * 2f; - float num780 = 100f + (extendedDistanceFromPlantera * 300f); + float tentacleVelocity = 100f + (extendedDistanceFromPlantera * 300f); float deceleration = (death ? 0.5f : 0.8f) / (1f + extendedDistanceFromPlantera); if (Main.getGoodWorld) - num779 += 4f; + tentacleAcceleration += 4f; // Despawn if Plantera is gone if (!Main.npc[plantBoss].active) @@ -1036,37 +1036,37 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Movement Vector2 planteraCenter = Main.npc[plantBoss].Center; - float num784 = planteraCenter.X + npc.ai[0]; - float num785 = planteraCenter.Y + npc.ai[1]; - float num786 = num784 - planteraCenter.X; - float num787 = num785 - planteraCenter.Y; - float num788 = (float)Math.Sqrt(num786 * num786 + num787 * num787); - num788 = num780 / num788; - num786 *= num788; - num787 *= num788; + float plantXOffset = planteraCenter.X + npc.ai[0]; + float plantYOffset = planteraCenter.Y + npc.ai[1]; + float plantXDist = plantXOffset - planteraCenter.X; + float plantYDist = plantYOffset - planteraCenter.Y; + float plantTotalDist = (float)Math.Sqrt(plantXDist * plantXDist + plantYDist * plantYDist); + plantTotalDist = tentacleVelocity / plantTotalDist; + plantXDist *= plantTotalDist; + plantYDist *= plantTotalDist; - if (npc.position.X < planteraCenter.X + num786) + if (npc.position.X < planteraCenter.X + plantXDist) { - npc.velocity.X += num779; - if (npc.velocity.X < 0f && num786 > 0f) + npc.velocity.X += tentacleAcceleration; + if (npc.velocity.X < 0f && plantXDist > 0f) npc.velocity.X *= deceleration; } - else if (npc.position.X > planteraCenter.X + num786) + else if (npc.position.X > planteraCenter.X + plantXDist) { - npc.velocity.X -= num779; - if (npc.velocity.X > 0f && num786 < 0f) + npc.velocity.X -= tentacleAcceleration; + if (npc.velocity.X > 0f && plantXDist < 0f) npc.velocity.X *= deceleration; } - if (npc.position.Y < planteraCenter.Y + num787) + if (npc.position.Y < planteraCenter.Y + plantYDist) { - npc.velocity.Y += num779; - if (npc.velocity.Y < 0f && num787 > 0f) + npc.velocity.Y += tentacleAcceleration; + if (npc.velocity.Y < 0f && plantYDist > 0f) npc.velocity.Y *= deceleration; } - else if (npc.position.Y > planteraCenter.Y + num787) + else if (npc.position.Y > planteraCenter.Y + plantYDist) { - npc.velocity.Y -= num779; - if (npc.velocity.Y > 0f && num787 < 0f) + npc.velocity.Y -= tentacleAcceleration; + if (npc.velocity.Y > 0f && plantYDist < 0f) npc.velocity.Y *= deceleration; } @@ -1081,15 +1081,15 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.velocity.Y = -velocityLimit; // Direction and rotation - if (num786 > 0f) + if (plantXDist > 0f) { npc.spriteDirection = 1; - npc.rotation = (float)Math.Atan2(num787, num786); + npc.rotation = (float)Math.Atan2(plantYDist, plantXDist); } - if (num786 < 0f) + if (plantXDist < 0f) { npc.spriteDirection = -1; - npc.rotation = (float)Math.Atan2(num787, num786) + MathHelper.Pi; + npc.rotation = (float)Math.Atan2(plantYDist, plantXDist) + MathHelper.Pi; } return false; diff --git a/NPCs/VanillaNPCOverrides/Bosses/QueenBeeAI.cs b/NPCs/VanillaNPCOverrides/Bosses/QueenBeeAI.cs index 2f17fbc3cc..ef2300c683 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/QueenBeeAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/QueenBeeAI.cs @@ -31,10 +31,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses bool death = CalamityWorld.death || bossRush; bool enrage = true; - int num = (int)Main.player[npc.target].Center.X / 16; - int num2 = (int)Main.player[npc.target].Center.Y / 16; + int targetTileX = (int)Main.player[npc.target].Center.X / 16; + int targetTileY = (int)Main.player[npc.target].Center.Y / 16; - Tile tile = Framing.GetTileSafely(num, num2); + Tile tile = Framing.GetTileSafely(targetTileX, targetTileY); if (tile.WallType == WallID.HiveUnsafe) enrage = false; @@ -69,12 +69,12 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses bool phase5 = lifeRatio < 0.1f; // Despawn - float num616 = Vector2.Distance(npc.Center, Main.player[npc.target].Center); + float distanceFromTarget = Vector2.Distance(npc.Center, Main.player[npc.target].Center); if (npc.ai[0] != 5f) { if (npc.timeLeft < 60) npc.timeLeft = 60; - if (num616 > 3000f) + if (distanceFromTarget > 3000f) npc.ai[0] = 4f; } if (Main.player[npc.target].dead) @@ -186,9 +186,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[1] % 2f == 0f) { // Initiate charge - float num620 = 20f; - num620 += 20f * enrageScale; - if (Math.Abs(npc.position.Y + (npc.height / 2) - (Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2))) < num620) + float chargeDistance = 20f; + chargeDistance += 20f * enrageScale; + if (Math.Abs(npc.position.Y + (npc.height / 2) - (Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2))) < chargeDistance) { // Set AI variables and speed npc.localAI[0] = 1f; @@ -196,13 +196,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.ai[2] = 0f; // Get target location - Vector2 vector74 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num599 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector74.X; - float num600 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector74.Y; - float num601 = (float)Math.Sqrt(num599 * num599 + num600 * num600); - num601 = speed / num601; - npc.velocity.X = num599 * num601; - npc.velocity.Y = num600 * num601; + Vector2 beeLocation = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float targetXDist = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - beeLocation.X; + float targetYDist = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - beeLocation.Y; + float targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); + targetDistance = speed / targetDistance; + npc.velocity.X = targetXDist * targetDistance; + npc.velocity.Y = targetYDist * targetDistance; // Face the correct direction and play charge sound float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; @@ -215,54 +215,54 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Velocity variables npc.localAI[0] = 0f; - float num602 = 12f; - float num603 = 0.15f; + float chargeVelocity = 12f; + float chargeAcceleration = 0.15f; if (phase2) { - num602 += 1.5f; - num603 += 0.0625f; + chargeVelocity += 1.5f; + chargeAcceleration += 0.0625f; } if (phase3) { - num602 += 1.5f; - num603 += 0.0625f; + chargeVelocity += 1.5f; + chargeAcceleration += 0.0625f; } if (phase4) { - num602 += 1.5f; - num603 += 0.0625f; + chargeVelocity += 1.5f; + chargeAcceleration += 0.0625f; } if (phase5) { - num602 += 1.5f; - num603 += 0.0625f; + chargeVelocity += 1.5f; + chargeAcceleration += 0.0625f; } - num602 += 3f * enrageScale; - num603 += 0.5f * enrageScale; + chargeVelocity += 3f * enrageScale; + chargeAcceleration += 0.5f * enrageScale; // Velocity calculations if (npc.position.Y + (npc.height / 2) < Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2)) - npc.velocity.Y += num603; + npc.velocity.Y += chargeAcceleration; else - npc.velocity.Y -= num603; + npc.velocity.Y -= chargeAcceleration; - if (npc.velocity.Y < -num602) - npc.velocity.Y = -num602; - if (npc.velocity.Y > num602) - npc.velocity.Y = num602; + if (npc.velocity.Y < -chargeVelocity) + npc.velocity.Y = -chargeVelocity; + if (npc.velocity.Y > chargeVelocity) + npc.velocity.Y = chargeVelocity; if (Math.Abs(npc.position.X + (npc.width / 2) - (Main.player[npc.target].position.X + (Main.player[npc.target].width / 2))) > 500f) - npc.velocity.X += num603 * npc.direction; + npc.velocity.X += chargeAcceleration * npc.direction; else if (Math.Abs(npc.position.X + (npc.width / 2) - (Main.player[npc.target].position.X + (Main.player[npc.target].width / 2))) < 300f) - npc.velocity.X -= num603 * npc.direction; + npc.velocity.X -= chargeAcceleration * npc.direction; else npc.velocity.X *= 0.8f; // Limit velocity - if (npc.velocity.X < -num602) - npc.velocity.X = -num602; - if (npc.velocity.X > num602) - npc.velocity.X = num602; + if (npc.velocity.X < -chargeVelocity) + npc.velocity.X = -chargeVelocity; + if (npc.velocity.X > chargeVelocity) + npc.velocity.X = chargeVelocity; // Face the correct direction float playerLocation2 = npc.Center.X - Main.player[npc.target].Center.X; @@ -285,31 +285,31 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.spriteDirection = npc.direction; // Charging distance from player - int num604 = 450; + int chargingDistance = 450; if (phase4) - num604 = 350; + chargingDistance = 350; else if (phase2) - num604 = 400; - num604 -= (int)(100f * enrageScale); + chargingDistance = 400; + chargingDistance -= (int)(100f * enrageScale); // Get which side of the player the boss is on - int num605 = 1; + int chargeDirection = 1; if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + (Main.player[npc.target].width / 2)) - num605 = -1; + chargeDirection = -1; // If boss is in correct position, slow down, if not, reset - bool flag35 = false; - if (npc.direction == num605 && Math.Abs(npc.position.X + (npc.width / 2) - (Main.player[npc.target].position.X + (Main.player[npc.target].width / 2))) > num604) + bool shouldCharge = false; + if (npc.direction == chargeDirection && Math.Abs(npc.position.X + (npc.width / 2) - (Main.player[npc.target].position.X + (Main.player[npc.target].width / 2))) > chargingDistance) { npc.ai[2] = 1f; - flag35 = true; + shouldCharge = true; } - if (Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > num604 * 1.5f) + if (Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > chargingDistance * 1.5f) { npc.ai[2] = 1f; - flag35 = true; + shouldCharge = true; } - if (enrageScale > 0f && flag35) + if (enrageScale > 0f && shouldCharge) npc.velocity *= 0.5f; // Keep moving @@ -338,26 +338,26 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.localAI[0] = 0f; npc.velocity *= 0.9f; - float num606 = 0.1f; + float chargeDeceleration = 0.1f; if (phase3) { npc.velocity *= 0.9f; - num606 += 0.05f; + chargeDeceleration += 0.05f; } if (phase4) { npc.velocity *= 0.9f; - num606 += 0.05f; + chargeDeceleration += 0.05f; } if (phase5) { npc.velocity *= 0.9f; - num606 += 0.05f; + chargeDeceleration += 0.05f; } if (enrageScale > 0f) npc.velocity *= 0.7f; - if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < num606) + if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < chargeDeceleration) { npc.ai[2] = 0f; npc.ai[1] += 1f; @@ -380,15 +380,15 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.spriteDirection = npc.direction; // Get target location - float num608 = 0.1f; - Vector2 vector75 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num609 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector75.X; - float num610 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 200f - vector75.Y; - float num611 = (float)Math.Sqrt(num609 * num609 + num610 * num610); + float beeAttackAccel = 0.1f; + Vector2 beeAttackPosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float beeAttackTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - beeAttackPosition.X; + float beeAttackTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 200f - beeAttackPosition.Y; + float beeAttackTargetDist = (float)Math.Sqrt(beeAttackTargetX * beeAttackTargetX + beeAttackTargetY * beeAttackTargetY); // Go to bee spawn phase calamityGlobalNPC.newAI[0] += 1f; - if (num611 < (death ? 400f : 300f) || calamityGlobalNPC.newAI[0] >= 180f) + if (beeAttackTargetDist < (death ? 400f : 300f) || calamityGlobalNPC.newAI[0] >= 180f) { npc.ai[0] = 1f; npc.ai[1] = 0f; @@ -399,29 +399,29 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Velocity calculations - if (npc.velocity.X < num609) + if (npc.velocity.X < beeAttackTargetX) { - npc.velocity.X += num608; - if (npc.velocity.X < 0f && num609 > 0f) - npc.velocity.X += num608; + npc.velocity.X += beeAttackAccel; + if (npc.velocity.X < 0f && beeAttackTargetX > 0f) + npc.velocity.X += beeAttackAccel; } - else if (npc.velocity.X > num609) + else if (npc.velocity.X > beeAttackTargetX) { - npc.velocity.X -= num608; - if (npc.velocity.X > 0f && num609 < 0f) - npc.velocity.X -= num608; + npc.velocity.X -= beeAttackAccel; + if (npc.velocity.X > 0f && beeAttackTargetX < 0f) + npc.velocity.X -= beeAttackAccel; } - if (npc.velocity.Y < num610) + if (npc.velocity.Y < beeAttackTargetY) { - npc.velocity.Y += num608; - if (npc.velocity.Y < 0f && num610 > 0f) - npc.velocity.Y += num608; + npc.velocity.Y += beeAttackAccel; + if (npc.velocity.Y < 0f && beeAttackTargetY > 0f) + npc.velocity.Y += beeAttackAccel; } - else if (npc.velocity.Y > num610) + else if (npc.velocity.Y > beeAttackTargetY) { - npc.velocity.Y -= num608; - if (npc.velocity.Y > 0f && num610 < 0f) - npc.velocity.Y -= num608; + npc.velocity.Y -= beeAttackAccel; + if (npc.velocity.Y > 0f && beeAttackTargetY < 0f) + npc.velocity.Y -= beeAttackAccel; } } @@ -431,21 +431,21 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.localAI[0] = 0f; // Get target location and spawn bees from ass - Vector2 vector76 = new Vector2(npc.position.X + (npc.width / 2) + (Main.rand.Next(20) * npc.direction), npc.position.Y + npc.height * 0.8f); - Vector2 vector77 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num612 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector77.X; - float num613 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector77.Y; - float num614 = (float)Math.Sqrt(num612 * num612 + num613 * num613); + Vector2 beeSpawnLocation = new Vector2(npc.position.X + (npc.width / 2) + (Main.rand.Next(20) * npc.direction), npc.position.Y + npc.height * 0.8f); + Vector2 queenBeeLocation = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float beeSpawnTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - queenBeeLocation.X; + float beeSpawnTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - queenBeeLocation.Y; + float beeSpawnTargetDist = (float)Math.Sqrt(beeSpawnTargetX * beeSpawnTargetX + beeSpawnTargetY * beeSpawnTargetY); // Bee spawn timer npc.ai[1] += 1f; - int num638 = 0; - for (int num639 = 0; num639 < 255; num639++) + int beeSpawnTimer = 0; + for (int i = 0; i < 255; i++) { - if (Main.player[num639].active && !Main.player[num639].dead && (npc.Center - Main.player[num639].Center).Length() < 1000f) - num638++; + if (Main.player[i].active && !Main.player[i].dead && (npc.Center - Main.player[i].Center).Length() < 1000f) + beeSpawnTimer++; } - npc.ai[1] += num638 / 2; + npc.ai[1] += beeSpawnTimer / 2; if (phase2) npc.ai[1] += 0.25f; if (phase3) @@ -456,8 +456,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.ai[1] += 0.25f; bool spawnBee = false; - float num640 = 15f - 12f * enrageScale; - if (npc.ai[1] > num640) + float beeSpawnCheck = 15f - 12f * enrageScale; + if (npc.ai[1] > beeSpawnCheck) { npc.ai[1] = 0f; npc.ai[2] += 1f; @@ -465,7 +465,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Spawn bees or hornets - if (Collision.CanHit(vector76, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height) && spawnBee) + if (Collision.CanHit(beeSpawnLocation, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height) && spawnBee) { SoundEngine.PlaySound(SoundID.NPCHit1, npc.Center); if (Main.netMode != NetmodeID.MultiplayerClient) @@ -479,7 +479,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses spawnType = NPCID.Hellbat; } - int spawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)vector76.X, (int)vector76.Y, spawnType); + int spawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)beeSpawnLocation.X, (int)beeSpawnLocation.Y, spawnType); Main.npc[spawn].velocity = Main.player[npc.target].Center - npc.Center; Main.npc[spawn].velocity.Normalize(); Main.npc[spawn].velocity *= 5f; @@ -490,39 +490,39 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Velocity calculations if target is too far away - if (num614 > 400f || !Collision.CanHit(new Vector2(vector76.X, vector76.Y - 30f), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + if (beeSpawnTargetDist > 400f || !Collision.CanHit(new Vector2(beeSpawnLocation.X, beeSpawnLocation.Y - 30f), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { - float num617 = 14f; - float num618 = 0.1f; - vector77 = vector76; - num612 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector77.X; - num613 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector77.Y; - num614 = (float)Math.Sqrt(num612 * num612 + num613 * num613); - num614 = num617 / num614; + float beeAttackHoverSpeed = 14f; + float beeAttackHoverAccel = 0.1f; + queenBeeLocation = beeSpawnLocation; + beeSpawnTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - queenBeeLocation.X; + beeSpawnTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - queenBeeLocation.Y; + beeSpawnTargetDist = (float)Math.Sqrt(beeSpawnTargetX * beeSpawnTargetX + beeSpawnTargetY * beeSpawnTargetY); + beeSpawnTargetDist = beeAttackHoverSpeed / beeSpawnTargetDist; - if (npc.velocity.X < num612) + if (npc.velocity.X < beeSpawnTargetX) { - npc.velocity.X += num618; - if (npc.velocity.X < 0f && num612 > 0f) - npc.velocity.X += num618; + npc.velocity.X += beeAttackHoverAccel; + if (npc.velocity.X < 0f && beeSpawnTargetX > 0f) + npc.velocity.X += beeAttackHoverAccel; } - else if (npc.velocity.X > num612) + else if (npc.velocity.X > beeSpawnTargetX) { - npc.velocity.X -= num618; - if (npc.velocity.X > 0f && num612 < 0f) - npc.velocity.X -= num618; + npc.velocity.X -= beeAttackHoverAccel; + if (npc.velocity.X > 0f && beeSpawnTargetX < 0f) + npc.velocity.X -= beeAttackHoverAccel; } - if (npc.velocity.Y < num613) + if (npc.velocity.Y < beeSpawnTargetY) { - npc.velocity.Y += num618; - if (npc.velocity.Y < 0f && num613 > 0f) - npc.velocity.Y += num618; + npc.velocity.Y += beeAttackHoverAccel; + if (npc.velocity.Y < 0f && beeSpawnTargetY > 0f) + npc.velocity.Y += beeAttackHoverAccel; } - else if (npc.velocity.Y > num613) + else if (npc.velocity.Y > beeSpawnTargetY) { - npc.velocity.Y -= num618; - if (npc.velocity.Y > 0f && num613 < 0f) - npc.velocity.Y -= num618; + npc.velocity.Y -= beeAttackHoverAccel; + if (npc.velocity.Y > 0f && beeSpawnTargetY < 0f) + npc.velocity.Y -= beeAttackHoverAccel; } } else @@ -547,114 +547,114 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses else if (npc.ai[0] == 3f) { // Get target location and shoot from ass - Vector2 vector78 = new Vector2(npc.position.X + (npc.width / 2) + (Main.rand.Next(20) * npc.direction), npc.position.Y + npc.height * 0.8f); - Vector2 vector79 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num621 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector79.X; - float num622 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 300f - vector79.Y; - float num623 = (float)Math.Sqrt(num621 * num621 + num622 * num622); + Vector2 stingerSpawnLocation = new Vector2(npc.position.X + (npc.width / 2) + (Main.rand.Next(20) * npc.direction), npc.position.Y + npc.height * 0.8f); + Vector2 stingerQueenBeeLocation = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float stingerAttackTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - stingerQueenBeeLocation.X; + float stingerAttackTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 300f - stingerQueenBeeLocation.Y; + float stingerAttackTargetDist = (float)Math.Sqrt(stingerAttackTargetX * stingerAttackTargetX + stingerAttackTargetY * stingerAttackTargetY); npc.ai[1] += 1f; - int num650 = phase4 ? 15 : phase3 ? 20 : phase2 ? 25 : 30; - num650 -= (int)Math.Ceiling(5f * enrageScale); - if (num650 < 3) - num650 = 3; + int stingerAttackTimer = phase4 ? 15 : phase3 ? 20 : phase2 ? 25 : 30; + stingerAttackTimer -= (int)Math.Ceiling(5f * enrageScale); + if (stingerAttackTimer < 3) + stingerAttackTimer = 3; // Fire stingers - if (npc.ai[1] % num650 == (num650 - 1) && npc.position.Y + npc.height < Main.player[npc.target].position.Y && Collision.CanHit(vector78, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + if (npc.ai[1] % stingerAttackTimer == (stingerAttackTimer - 1) && npc.position.Y + npc.height < Main.player[npc.target].position.Y && Collision.CanHit(stingerSpawnLocation, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { SoundEngine.PlaySound(SoundID.Item17, npc.position); if (Main.netMode != NetmodeID.MultiplayerClient) { - float num624 = 5f; + float stingerSpeed = 5f; if (phase3) - num624 += 1f; - num624 += 2f * enrageScale; + stingerSpeed += 1f; + stingerSpeed += 2f * enrageScale; - float num625 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector78.X; - float num626 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector78.Y; - float num627 = (float)Math.Sqrt(num625 * num625 + num626 * num626); - num627 = num624 / num627; - num625 *= num627; - num626 *= num627; + float stingerTargetX = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - stingerSpawnLocation.X; + float stingerTargetY = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - stingerSpawnLocation.Y; + float stingerTargetDist = (float)Math.Sqrt(stingerTargetX * stingerTargetX + stingerTargetY * stingerTargetY); + stingerTargetDist = stingerSpeed / stingerTargetDist; + stingerTargetX *= stingerTargetDist; + stingerTargetY *= stingerTargetDist; int type = Main.zenithWorld ? (phase3 ? ModContent.ProjectileType() : ProjectileID.FlamingWood) : ProjectileID.QueenBeeStinger; - int projectile = Projectile.NewProjectile(npc.GetSource_FromAI(), vector78.X, vector78.Y, num625, num626, type, Main.zenithWorld ? 25 : npc.GetProjectileDamage(type), 0f, Main.myPlayer, 0f, (Main.zenithWorld && phase3) ? Main.player[npc.target].position.Y : 0f); + int projectile = Projectile.NewProjectile(npc.GetSource_FromAI(), stingerSpawnLocation.X, stingerSpawnLocation.Y, stingerTargetX, stingerTargetY, type, Main.zenithWorld ? 25 : npc.GetProjectileDamage(type), 0f, Main.myPlayer, 0f, (Main.zenithWorld && phase3) ? Main.player[npc.target].position.Y : 0f); Main.projectile[projectile].timeLeft = 600; Main.projectile[projectile].extraUpdates = 1; } } // Movement calculations - float num620 = 0.075f; - num620 += 0.2f * enrageScale; - if (!Collision.CanHit(new Vector2(vector78.X, vector78.Y - 30f), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + float stingerAttackAccel = 0.075f; + stingerAttackAccel += 0.2f * enrageScale; + if (!Collision.CanHit(new Vector2(stingerSpawnLocation.X, stingerSpawnLocation.Y - 30f), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { - num620 = 0.1f; + stingerAttackAccel = 0.1f; if (enrageScale > 0f) - num620 = 0.5f; + stingerAttackAccel = 0.5f; - vector79 = vector78; - num621 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector79.X; - num622 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector79.Y; + stingerQueenBeeLocation = stingerSpawnLocation; + stingerAttackTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - stingerQueenBeeLocation.X; + stingerAttackTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - stingerQueenBeeLocation.Y; - if (npc.velocity.X < num621) + if (npc.velocity.X < stingerAttackTargetX) { - npc.velocity.X += num620; - if (npc.velocity.X < 0f && num621 > 0f) - npc.velocity.X += num620; + npc.velocity.X += stingerAttackAccel; + if (npc.velocity.X < 0f && stingerAttackTargetX > 0f) + npc.velocity.X += stingerAttackAccel; } - else if (npc.velocity.X > num621) + else if (npc.velocity.X > stingerAttackTargetX) { - npc.velocity.X -= num620; - if (npc.velocity.X > 0f && num621 < 0f) - npc.velocity.X -= num620; + npc.velocity.X -= stingerAttackAccel; + if (npc.velocity.X > 0f && stingerAttackTargetX < 0f) + npc.velocity.X -= stingerAttackAccel; } - if (npc.velocity.Y < num622) + if (npc.velocity.Y < stingerAttackTargetY) { - npc.velocity.Y += num620; - if (npc.velocity.Y < 0f && num622 > 0f) - npc.velocity.Y += num620; + npc.velocity.Y += stingerAttackAccel; + if (npc.velocity.Y < 0f && stingerAttackTargetY > 0f) + npc.velocity.Y += stingerAttackAccel; } - else if (npc.velocity.Y > num622) + else if (npc.velocity.Y > stingerAttackTargetY) { - npc.velocity.Y -= num620; - if (npc.velocity.Y > 0f && num622 < 0f) - npc.velocity.Y -= num620; + npc.velocity.Y -= stingerAttackAccel; + if (npc.velocity.Y > 0f && stingerAttackTargetY < 0f) + npc.velocity.Y -= stingerAttackAccel; } } - else if (num623 > 100f) + else if (stingerAttackTargetDist > 100f) { float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; npc.direction = playerLocation < 0 ? 1 : -1; npc.spriteDirection = npc.direction; - if (npc.velocity.X < num621) + if (npc.velocity.X < stingerAttackTargetX) { - npc.velocity.X += num620; - if (npc.velocity.X < 0f && num621 > 0f) - npc.velocity.X += num620 * 2f; + npc.velocity.X += stingerAttackAccel; + if (npc.velocity.X < 0f && stingerAttackTargetX > 0f) + npc.velocity.X += stingerAttackAccel * 2f; } - else if (npc.velocity.X > num621) + else if (npc.velocity.X > stingerAttackTargetX) { - npc.velocity.X -= num620; - if (npc.velocity.X > 0f && num621 < 0f) - npc.velocity.X -= num620 * 2f; + npc.velocity.X -= stingerAttackAccel; + if (npc.velocity.X > 0f && stingerAttackTargetX < 0f) + npc.velocity.X -= stingerAttackAccel * 2f; } - if (npc.velocity.Y < num622) + if (npc.velocity.Y < stingerAttackTargetY) { - npc.velocity.Y += num620; - if (npc.velocity.Y < 0f && num622 > 0f) - npc.velocity.Y += num620 * 2f; + npc.velocity.Y += stingerAttackAccel; + if (npc.velocity.Y < 0f && stingerAttackTargetY > 0f) + npc.velocity.Y += stingerAttackAccel * 2f; } - else if (npc.velocity.Y > num622) + else if (npc.velocity.Y > stingerAttackTargetY) { - npc.velocity.Y -= num620; - if (npc.velocity.Y > 0f && num622 < 0f) - npc.velocity.Y -= num620 * 2f; + npc.velocity.Y -= stingerAttackAccel; + if (npc.velocity.Y > 0f && stingerAttackTargetY < 0f) + npc.velocity.Y -= stingerAttackAccel * 2f; } } // Go to a random phase - if (npc.ai[1] > num650 * 15f) + if (npc.ai[1] > stingerAttackTimer * 15f) { npc.ai[0] = -1f; npc.ai[1] = 3f; @@ -665,14 +665,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses else if (npc.ai[0] == 4f) { npc.localAI[0] = 1f; - float num661 = 14f; - float num662 = 14f; + float despawnVelMult = 14f; - Vector2 value2 = Main.player[npc.target].Center - npc.Center; - value2.Normalize(); - value2 *= num661; + Vector2 despawnTargetDist = Main.player[npc.target].Center - npc.Center; + despawnTargetDist.Normalize(); + despawnTargetDist *= 14f; - npc.velocity = (npc.velocity * num662 + value2) / (num662 + 1f); + npc.velocity = (npc.velocity * despawnVelMult + despawnTargetDist) / (despawnVelMult + 1f); if (npc.velocity.X < 0f) npc.direction = -1; else @@ -680,7 +679,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.spriteDirection = npc.direction; - if (num616 < 2000f) + if (distanceFromTarget < 2000f) { npc.ai[0] = -1f; npc.localAI[0] = 0f; diff --git a/NPCs/VanillaNPCOverrides/Bosses/QueenSlimeAI.cs b/NPCs/VanillaNPCOverrides/Bosses/QueenSlimeAI.cs index c6ab749eeb..8dbf151dbc 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/QueenSlimeAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/QueenSlimeAI.cs @@ -21,8 +21,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; - float num3 = 1f; - bool flag = false; + float slimeScale = 1f; + bool teleported = false; bool phase2 = lifeRatio <= 0.5f; bool phase3 = lifeRatio <= 0.4f; bool phase4 = lifeRatio <= 0.2f; @@ -71,34 +71,34 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses 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 point2 = vectorAimedAheadOfTarget.ToTileCoordinates(); - int num5 = 5; - int num8 = 0; - while (num8 < 100) + Point predictiveTeleportPoint = vectorAimedAheadOfTarget.ToTileCoordinates(); + int randomTeleportOffset = 5; + int teleportTries = 0; + while (teleportTries < 100) { - num8++; - int num9 = Main.rand.Next(point2.X - num5, point2.X + num5 + 1); - int num10 = Main.rand.Next(point2.Y - num5, point2.Y); - if (Main.tile[num9, num10].HasUnactuatedTile) + teleportTries++; + int teleportTileX = Main.rand.Next(predictiveTeleportPoint.X - randomTeleportOffset, predictiveTeleportPoint.X + randomTeleportOffset + 1); + int teleportTileY = Main.rand.Next(predictiveTeleportPoint.Y - randomTeleportOffset, predictiveTeleportPoint.Y); + if (Main.tile[teleportTileX, teleportTileY].HasUnactuatedTile) continue; - bool flag4 = true; - if (flag4 && Main.tile[num9, num10].LiquidType == LiquidID.Lava) - flag4 = false; - if (flag4 && !Collision.CanHitLine(npc.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) - flag4 = false; + bool canTeleportToTile = true; + if (canTeleportToTile && Main.tile[teleportTileX, teleportTileY].LiquidType == LiquidID.Lava) + canTeleportToTile = false; + if (canTeleportToTile && !Collision.CanHitLine(npc.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) + canTeleportToTile = false; - if (flag4) + if (canTeleportToTile) { - npc.localAI[1] = num9 * 16 + 8; - npc.localAI[2] = num10 * 16 + 16; + npc.localAI[1] = teleportTileX * 16 + 8; + npc.localAI[2] = teleportTileY * 16 + 16; npc.ai[3] = 0f; break; } } // Default teleport if the above conditions aren't met in 100 iterations - if (num8 >= 100) + if (teleportTries >= 100) { Vector2 bottom = Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].Bottom; npc.localAI[1] = bottom.X; @@ -121,11 +121,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } else { - float num13 = npc.ai[3]; + float teleportNetUpdate = npc.ai[3]; npc.ai[3] -= 1f; if (npc.ai[3] < 0f) { - if (Main.netMode != NetmodeID.MultiplayerClient && num13 > 0f) + if (Main.netMode != NetmodeID.MultiplayerClient && teleportNetUpdate > 0f) npc.netUpdate = true; npc.ai[3] = 0f; @@ -254,8 +254,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.rotation = 0f; npc.ai[1] += 1f; float teleportEndTime = bossRush ? 10f : death ? 15f : 20f; - num3 = MathHelper.Clamp(npc.ai[1] / teleportEndTime, 0f, 1f); - num3 = 0.5f + num3 * 0.5f; + slimeScale = MathHelper.Clamp(npc.ai[1] / teleportEndTime, 0f, 1f); + slimeScale = 0.5f + slimeScale * 0.5f; if (npc.ai[1] >= teleportEndTime && Main.netMode != NetmodeID.MultiplayerClient) { npc.ai[0] = 0f; @@ -274,11 +274,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Emit teleport dust Color newColor2 = NPC.AI_121_QueenSlime_GetDustColor(); newColor2.A = 150; - for (int num26 = 0; num26 < 10; num26++) + for (int i = 0; i < 10; i++) { - int num27 = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, 4, npc.velocity.X, npc.velocity.Y, 50, newColor2, 1.5f); - Main.dust[num27].noGravity = true; - Main.dust[num27].velocity *= 2f; + int queenSlimeDust = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, 4, npc.velocity.X, npc.velocity.Y, 50, newColor2, 1.5f); + Main.dust[queenSlimeDust].noGravity = true; + Main.dust[queenSlimeDust].velocity *= 2f; } break; @@ -292,11 +292,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.rotation = 0f; npc.ai[1] += 1f; float teleportTime = bossRush ? 20f : death ? 30f : 40f; - num3 = MathHelper.Clamp((teleportTime - npc.ai[1]) / teleportTime, 0f, 1f); - num3 = 0.5f + num3 * 0.5f; + slimeScale = MathHelper.Clamp((teleportTime - npc.ai[1]) / teleportTime, 0f, 1f); + slimeScale = 0.5f + slimeScale * 0.5f; if (npc.ai[1] >= teleportTime) - flag = true; + teleported = true; // Spawn crown gore if (npc.ai[1] == teleportTime) @@ -317,15 +317,15 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Emit teleport dust - if (!flag) + if (!teleported) { Color newColor = NPC.AI_121_QueenSlime_GetDustColor(); newColor.A = 150; for (int n = 0; n < 10; n++) { - int num25 = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, 4, npc.velocity.X, npc.velocity.Y, 50, newColor, 1.5f); - Main.dust[num25].noGravity = true; - Main.dust[num25].velocity *= 0.5f; + int queenSlimeDust2 = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, 4, npc.velocity.X, npc.velocity.Y, 50, newColor, 1.5f); + Main.dust[queenSlimeDust2].noGravity = true; + Main.dust[queenSlimeDust2].velocity *= 0.5f; } } @@ -402,11 +402,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.target >= Main.maxPlayers) break; - float num19 = bossRush ? 6.5f : death ? 5.5f : 4.5f; + float jumpVelocity = bossRush ? 6.5f : death ? 5.5f : 4.5f; if (Main.getGoodWorld) - num19 = 7f; + jumpVelocity = 7f; - if ((npc.direction == 1 && npc.velocity.X < num19) || (npc.direction == -1 && npc.velocity.X > 0f - num19)) + if ((npc.direction == 1 && npc.velocity.X < jumpVelocity) || (npc.direction == -1 && npc.velocity.X > 0f - jumpVelocity)) { if ((npc.direction == -1 && npc.velocity.X < 0.1) || (npc.direction == 1 && npc.velocity.X > -0.1)) npc.velocity.X += (bossRush ? 0.5f : death ? 0.35f : 0.3f) * npc.direction; @@ -442,12 +442,12 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.noTileCollide = false; npc.noGravity = false; - int num20 = 30; + int slamDelay = 30; if (phase2) - num20 = 10; + slamDelay = 10; if (Main.getGoodWorld) - num20 = 0; + slamDelay = 0; if (npc.velocity.Y == 0f) { @@ -479,10 +479,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses for (int l = 0; l < 20; l++) { - int num21 = Dust.NewDust(npc.Bottom - new Vector2(npc.width / 2, 30f), npc.width, 30, 31, npc.velocity.X, npc.velocity.Y, 40, NPC.AI_121_QueenSlime_GetDustColor()); - Main.dust[num21].noGravity = true; - Main.dust[num21].velocity.Y = -5f + Main.rand.NextFloat() * -3f; - Main.dust[num21].velocity.X *= 7f; + int slamDust = Dust.NewDust(npc.Bottom - new Vector2(npc.width / 2, 30f), npc.width, 30, 31, npc.velocity.X, npc.velocity.Y, 40, NPC.AI_121_QueenSlime_GetDustColor()); + Main.dust[slamDust].noGravity = true; + Main.dust[slamDust].velocity.Y = -5f + Main.rand.NextFloat() * -3f; + Main.dust[slamDust].velocity.X *= 7f; } npc.Calamity().newAI[0] = npc.ai[0]; @@ -492,28 +492,28 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.ai[2] = 0f; npc.netUpdate = true; } - else if (npc.ai[1] >= num20) + else if (npc.ai[1] >= slamDelay) { for (int m = 0; m < 4; m++) { Vector2 position = npc.Bottom - new Vector2(Main.rand.NextFloatDirection() * 16f, Main.rand.Next(8)); - int num22 = Dust.NewDust(position, 2, 2, 31, npc.velocity.X, npc.velocity.Y, 40, NPC.AI_121_QueenSlime_GetDustColor(), 1.4f); - Main.dust[num22].position = position; - Main.dust[num22].noGravity = true; - Main.dust[num22].velocity.Y = npc.velocity.Y * 0.9f; - Main.dust[num22].velocity.X = (Main.rand.NextBool() ? (-10f) : 10f) + Main.rand.NextFloatDirection() * 3f; + int slamDust2 = Dust.NewDust(position, 2, 2, 31, npc.velocity.X, npc.velocity.Y, 40, NPC.AI_121_QueenSlime_GetDustColor(), 1.4f); + Main.dust[slamDust2].position = position; + Main.dust[slamDust2].noGravity = true; + Main.dust[slamDust2].velocity.Y = npc.velocity.Y * 0.9f; + Main.dust[slamDust2].velocity.X = (Main.rand.NextBool() ? (-10f) : 10f) + Main.rand.NextFloatDirection() * 3f; } } npc.velocity.X *= 0.8f; - float num23 = npc.ai[1]; + float slamNetUpdate = npc.ai[1]; npc.ai[1] += 1f; - if (npc.ai[1] >= num20) + if (npc.ai[1] >= slamDelay) { - if (num23 < num20) + if (slamNetUpdate < slamDelay) npc.netUpdate = true; - if (phase2 && npc.ai[1] > (num20 + 120)) + if (phase2 && npc.ai[1] > (slamDelay + 120)) { npc.Calamity().newAI[0] = npc.ai[0]; npc.SyncExtraAI(); @@ -526,18 +526,18 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } npc.velocity.Y += bossRush ? 2f : death ? 1.75f : 1.5f; - float num24 = bossRush ? 15.99f : death ? 15.5f : 15f; + float slamVelocity = bossRush ? 15.99f : death ? 15.5f : 15f; if (Main.getGoodWorld) { npc.velocity.Y += 1f; - num24 = 15.99f; + slamVelocity = 15.99f; } if (npc.velocity.Y == 0f) npc.velocity.Y = 0.01f; - if (npc.velocity.Y >= num24) - npc.velocity.Y = num24; + if (npc.velocity.Y >= slamVelocity) + npc.velocity.Y = slamVelocity; // Cascade of crystals in phase 3 or 4 while falling down if (((npc.ai[0] == 4f && phase3) || phase4) && npc.ai[1] % 12f == 0f) @@ -709,21 +709,21 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } } - float num16 = 100f; + float slamDustRadius = 100f; for (int k = 0; k < 4; k++) { - Vector2 vector2 = npc.Center + Main.rand.NextVector2CircularEdge(num16, num16); + Vector2 slamDustArea = npc.Center + Main.rand.NextVector2CircularEdge(slamDustRadius, slamDustRadius); if (!phase2) - vector2 += new Vector2(0f, 20f); + slamDustArea += new Vector2(0f, 20f); - Vector2 v = vector2 - npc.Center; + Vector2 v = slamDustArea - npc.Center; v = v.SafeNormalize(Vector2.Zero) * -8f; - int num17 = Dust.NewDust(vector2, 2, 2, 31, v.X, v.Y, 40, NPC.AI_121_QueenSlime_GetDustColor(), 1.8f); - Main.dust[num17].position = vector2; - Main.dust[num17].noGravity = true; - Main.dust[num17].alpha = 250; - Main.dust[num17].velocity = v; - Main.dust[num17].customData = npc; + int superSlamDust = Dust.NewDust(slamDustArea, 2, 2, 31, v.X, v.Y, 40, NPC.AI_121_QueenSlime_GetDustColor(), 1.8f); + Main.dust[superSlamDust].position = slamDustArea; + Main.dust[superSlamDust].noGravity = true; + Main.dust[superSlamDust].alpha = 250; + Main.dust[superSlamDust].velocity = v; + Main.dust[superSlamDust].customData = npc; } if (phase2) @@ -733,14 +733,14 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Don't take damage while teleporting - npc.dontTakeDamage = npc.hide = flag; + npc.dontTakeDamage = npc.hide = teleported; // Adjust size with HP - if (num3 != npc.scale) + if (slimeScale != npc.scale) { npc.position.X += npc.width / 2; npc.position.Y += npc.height; - npc.scale = num3; + npc.scale = slimeScale; npc.width = (int)(114f * npc.scale); npc.height = (int)(100f * npc.scale); npc.position.X -= npc.width / 2; @@ -765,8 +765,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.netUpdate = true; } - int num28 = (int)(npc.lifeMax * (CalamityWorld.LegendaryMode ? 0.01f : phase3 ? 0.04f : phase2 ? 0.03f : 0.025f)); - if (!((npc.life + num28) < npc.localAI[0])) + int slimeSpawnThreshold = (int)(npc.lifeMax * (CalamityWorld.LegendaryMode ? 0.01f : phase3 ? 0.04f : phase2 ? 0.03f : 0.025f)); + if (!((npc.life + slimeSpawnThreshold) < npc.localAI[0])) return false; npc.localAI[0] = npc.life; @@ -793,14 +793,14 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses break; } - int num32 = NPC.NewNPC(npc.GetSource_FromAI(), x, y, typeToSpawn); - Main.npc[num32].SetDefaults(typeToSpawn); - Main.npc[num32].velocity.X = Main.rand.Next(-15, 16) * 0.1f; - Main.npc[num32].velocity.Y = Main.rand.Next(-30, 1) * 0.1f; - Main.npc[num32].ai[0] = -500 * Main.rand.Next(3); - Main.npc[num32].ai[1] = 0f; - if (Main.netMode == NetmodeID.Server && num32 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num32); + int slimeScale2 = NPC.NewNPC(npc.GetSource_FromAI(), x, y, typeToSpawn); + Main.npc[slimeScale2].SetDefaults(typeToSpawn); + Main.npc[slimeScale2].velocity.X = Main.rand.Next(-15, 16) * 0.1f; + Main.npc[slimeScale2].velocity.Y = Main.rand.Next(-30, 1) * 0.1f; + Main.npc[slimeScale2].ai[0] = -500 * Main.rand.Next(3); + Main.npc[slimeScale2].ai[1] = 0f; + if (Main.netMode == NetmodeID.Server && slimeScale2 < Main.maxNPCs) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeScale2); return false; } diff --git a/NPCs/VanillaNPCOverrides/Bosses/SkeletronAI.cs b/NPCs/VanillaNPCOverrides/Bosses/SkeletronAI.cs index 271967206e..c658223715 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/SkeletronAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/SkeletronAI.cs @@ -1,11 +1,11 @@ -using CalamityMod.Events; +using System; +using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; -using System; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { @@ -61,37 +61,37 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses void SpawnHands() { - int num155 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.SkeletronHand, npc.whoAmI); - Main.npc[num155].ai[0] = -1f; - Main.npc[num155].ai[1] = npc.whoAmI; - Main.npc[num155].target = npc.target; - Main.npc[num155].netUpdate = true; + int skeletronHand = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.SkeletronHand, npc.whoAmI); + Main.npc[skeletronHand].ai[0] = -1f; + Main.npc[skeletronHand].ai[1] = npc.whoAmI; + Main.npc[skeletronHand].target = npc.target; + Main.npc[skeletronHand].netUpdate = true; - num155 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.SkeletronHand, npc.whoAmI); - Main.npc[num155].ai[0] = 1f; - Main.npc[num155].ai[1] = npc.whoAmI; - Main.npc[num155].ai[3] = 150f; - Main.npc[num155].target = npc.target; - Main.npc[num155].netUpdate = true; + skeletronHand = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.SkeletronHand, npc.whoAmI); + Main.npc[skeletronHand].ai[0] = 1f; + Main.npc[skeletronHand].ai[1] = npc.whoAmI; + Main.npc[skeletronHand].ai[3] = 150f; + Main.npc[skeletronHand].target = npc.target; + Main.npc[skeletronHand].netUpdate = true; // Spawn two additional hands with different attack timings if (death) { - num155 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.SkeletronHand, npc.whoAmI); - Main.npc[num155].ai[0] = -1f; - Main.npc[num155].Calamity().newAI[0] = -1f; - Main.npc[num155].ai[1] = npc.whoAmI; - Main.npc[num155].ai[3] = respawnHands ? -75f : 0f; - Main.npc[num155].target = npc.target; - Main.npc[num155].netUpdate = true; + skeletronHand = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.SkeletronHand, npc.whoAmI); + Main.npc[skeletronHand].ai[0] = -1f; + Main.npc[skeletronHand].Calamity().newAI[0] = -1f; + Main.npc[skeletronHand].ai[1] = npc.whoAmI; + Main.npc[skeletronHand].ai[3] = respawnHands ? -75f : 0f; + Main.npc[skeletronHand].target = npc.target; + Main.npc[skeletronHand].netUpdate = true; - num155 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.SkeletronHand, npc.whoAmI); - Main.npc[num155].ai[0] = 1f; - Main.npc[num155].Calamity().newAI[0] = -1f; - Main.npc[num155].ai[1] = npc.whoAmI; - Main.npc[num155].ai[3] = respawnHands ? 75f : 150f; - Main.npc[num155].target = npc.target; - Main.npc[num155].netUpdate = true; + skeletronHand = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.SkeletronHand, npc.whoAmI); + Main.npc[skeletronHand].ai[0] = 1f; + Main.npc[skeletronHand].Calamity().newAI[0] = -1f; + Main.npc[skeletronHand].ai[1] = npc.whoAmI; + Main.npc[skeletronHand].ai[3] = respawnHands ? 75f : 150f; + Main.npc[skeletronHand].target = npc.target; + Main.npc[skeletronHand].netUpdate = true; } } } @@ -115,17 +115,17 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Hand immunity - int num156 = 0; - for (int num157 = 0; num157 < Main.maxNPCs; num157++) + int numHandsAlive = 0; + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num157].active && Main.npc[num157].type == NPCID.SkeletronHand) - num156++; + if (Main.npc[i].active && Main.npc[i].type == NPCID.SkeletronHand) + numHandsAlive++; } - bool handsDead = num156 == 0; + bool handsDead = numHandsAlive == 0; npc.chaseable = handsDead; - calamityGlobalNPC.DR = num156 > 0 ? 0.9999f : 0.05f; - calamityGlobalNPC.unbreakableDR = num156 > 0; - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = num156 > 0; + calamityGlobalNPC.DR = numHandsAlive > 0 ? 0.9999f : 0.05f; + calamityGlobalNPC.unbreakableDR = numHandsAlive > 0; + calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = numHandsAlive > 0; // Teleport if (handsDead || phase2) @@ -140,28 +140,28 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Fire magic bolt after teleport if (Main.netMode != NetmodeID.MultiplayerClient) { - float num151 = 2f + (distance * 0.005f); - if (num151 > 6f) - num151 = 6f; + float magicBoltSpeed = 2f + (distance * 0.005f); + if (magicBoltSpeed > 6f) + magicBoltSpeed = 6f; int type = ProjectileID.Skull; int damage = npc.GetProjectileDamage(type); int numProj = Main.getGoodWorld ? 22 : death ? 5 : 3; - float num743 = Main.player[npc.target].Center.X - npc.Center.X; - float num744 = Main.player[npc.target].Center.Y - npc.Center.Y; - float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); + float boltTargetXDist = Main.player[npc.target].Center.X - npc.Center.X; + float boltTargetYDist = Main.player[npc.target].Center.Y - npc.Center.Y; + float boltTargetDistance = (float)Math.Sqrt(boltTargetXDist * boltTargetXDist + boltTargetYDist * boltTargetYDist); - num745 = num151 / num745; - num743 *= num745; - num744 *= num745; + boltTargetDistance = magicBoltSpeed / boltTargetDistance; + boltTargetXDist *= boltTargetDistance; + boltTargetYDist *= boltTargetDistance; Vector2 center = npc.Center; - center.X += num743 * 5f; - center.Y += num744 * 5f; + center.X += boltTargetXDist * 5f; + center.Y += boltTargetYDist * 5f; float rotation = MathHelper.ToRadians(Main.getGoodWorld ? 180 : 60); - float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); - double startAngle = Math.Atan2(num743, num744) - rotation / 2; + float baseSpeed = (float)Math.Sqrt(boltTargetXDist * boltTargetXDist + boltTargetYDist * boltTargetYDist); + double startAngle = Math.Atan2(boltTargetXDist, boltTargetYDist) - rotation / 2; double deltaAngle = rotation / numProj; double offsetAngle; @@ -178,9 +178,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Teleport dust for (int m = 0; m < 30; m++) { - int num39 = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 200, default, 3f); - Main.dust[num39].noGravity = true; - Main.dust[num39].velocity.X = Main.dust[num39].velocity.X * 2f; + int teleportDust = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 200, default, 3f); + Main.dust[teleportDust].noGravity = true; + Main.dust[teleportDust].velocity.X = Main.dust[teleportDust].velocity.X * 2f; } } @@ -198,29 +198,29 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 value53 = npc.Center + new Vector2(npc.direction * 20, 6f); - Vector2 vector251 = Main.player[npc.target].Center - value53; - Point point12 = npc.Center.ToTileCoordinates(); - Point point13 = Main.player[npc.target].Center.ToTileCoordinates(); - int num1453 = 26; - int num1454 = 4; - int num1455 = 22; - int num1457 = 0; + Vector2 skullFaceDirection = npc.Center + new Vector2(npc.direction * 20, 6f); + Vector2 skullTargetDirection = Main.player[npc.target].Center - skullFaceDirection; + Point skullTileCoords = npc.Center.ToTileCoordinates(); + Point targetTileCoords = Main.player[npc.target].Center.ToTileCoordinates(); + int randomTeleportOffset = 26; + int skullPositionOffset = 4; + int targetPositionOffset = 22; + int teleportTries = 0; - bool flag106 = false; - if (vector251.Length() > 2000f) - flag106 = true; + bool targetTooFar = false; + if (skullTargetDirection.Length() > 2000f) + targetTooFar = true; - while (!flag106 && num1457 < 100) + while (!targetTooFar && teleportTries < 100) { - num1457++; - int num1458 = Main.rand.Next(point13.X - num1453, point13.X + num1453 + 1); - int num1459 = Main.rand.Next(point13.Y - num1453, point13.Y + num1453 + 1); - if ((num1459 < point13.Y - num1455 || num1459 > point13.Y + num1455 || num1458 < point13.X - num1455 || num1458 > point13.X + num1455) && (num1459 < point12.Y - num1454 || num1459 > point12.Y + num1454 || num1458 < point12.X - num1454 || num1458 > point12.X + num1454) && !Main.tile[num1458, num1459].HasUnactuatedTile) + teleportTries++; + int teleportTileX = Main.rand.Next(targetTileCoords.X - randomTeleportOffset, targetTileCoords.X + randomTeleportOffset + 1); + int teleportTileY = Main.rand.Next(targetTileCoords.Y - randomTeleportOffset, targetTileCoords.Y + randomTeleportOffset + 1); + if ((teleportTileY < targetTileCoords.Y - targetPositionOffset || teleportTileY > targetTileCoords.Y + targetPositionOffset || teleportTileX < targetTileCoords.X - targetPositionOffset || teleportTileX > targetTileCoords.X + targetPositionOffset) && (teleportTileY < skullTileCoords.Y - skullPositionOffset || teleportTileY > skullTileCoords.Y + skullPositionOffset || teleportTileX < skullTileCoords.X - skullPositionOffset || teleportTileX > skullTileCoords.X + skullPositionOffset) && !Main.tile[teleportTileX, teleportTileY].HasUnactuatedTile) { // New location params - calamityGlobalNPC.newAI[2] = num1458 * 16 - npc.width / 2; - calamityGlobalNPC.newAI[3] = num1459 * 16 - npc.height; + calamityGlobalNPC.newAI[2] = teleportTileX * 16 - npc.width / 2; + calamityGlobalNPC.newAI[3] = teleportTileY * 16 - npc.height; npc.SyncExtraAI(); break; } @@ -233,8 +233,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses for (int m = 0; m < 5; m++) { Vector2 position = new Vector2(calamityGlobalNPC.newAI[2], calamityGlobalNPC.newAI[3]); - int num39 = Dust.NewDust(position, npc.width, npc.height, 27, 0f, 0f, 200, default, 2f); - Main.dust[num39].noGravity = true; + int teleportDust = Dust.NewDust(position, npc.width, npc.height, 27, 0f, 0f, 200, default, 2f); + Main.dust[teleportDust].noGravity = true; } } @@ -257,9 +257,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Teleport dust for (int m = 0; m < 30; m++) { - int num39 = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 200, default, 3f); - Main.dust[num39].noGravity = true; - Main.dust[num39].velocity.X = Main.dust[num39].velocity.X * 2f; + int teleportDust = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 200, default, 3f); + Main.dust[teleportDust].noGravity = true; + Main.dust[teleportDust].velocity.X = Main.dust[teleportDust].velocity.X * 2f; } // New location @@ -278,38 +278,39 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Skull shooting if (handsDead && npc.ai[1] == 0f) { - float num158 = bossRush ? 10f : phase2 ? (60f - (death ? 30f * (1f - lifeRatio) : 0f)) : 75f; + float skullProjFrequency = bossRush ? 10f : phase2 ? (60f - (death ? 30f * (1f - lifeRatio) : 0f)) : 75f; if (Main.getGoodWorld) - num158 *= 0.8f; - num158 = (float)Math.Ceiling(num158); + skullProjFrequency *= 0.8f; + skullProjFrequency = (float)Math.Ceiling(skullProjFrequency); - if (Main.netMode != NetmodeID.MultiplayerClient && calamityGlobalNPC.newAI[1] % num158 == 0f && calamityGlobalNPC.newAI[1] > 45f) + if (Main.netMode != NetmodeID.MultiplayerClient && calamityGlobalNPC.newAI[1] % skullProjFrequency == 0f && calamityGlobalNPC.newAI[1] > 45f) { - Vector2 vector18 = npc.Center; - float num159 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector18.X; - float num160 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector18.Y; - float num161 = (float)Math.Sqrt(num159 * num159 + num160 * num160); - if (Collision.CanHit(vector18, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + Vector2 skullFiringPos = npc.Center; + float skullProjTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - skullFiringPos.X; + float skullProjTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - skullFiringPos.Y; + // Ozzatron: noticed this is unused. Leaving as-is for minimal touch. + float skullProjTargetDist = (float)Math.Sqrt(skullProjTargetX * skullProjTargetX + skullProjTargetY * skullProjTargetY); + if (Collision.CanHit(skullFiringPos, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { - float num162 = phase2 ? (5f + (death ? 3f * (1f - lifeRatio) : 0f)) : 4f; - float num163 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector18.X; - float num164 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector18.Y; - float num165 = (float)Math.Sqrt(num163 * num163 + num164 * num164); - num165 = num162 / num165; - num163 *= num165; - num164 *= num165; + float skullProjSpeed = phase2 ? (5f + (death ? 3f * (1f - lifeRatio) : 0f)) : 4f; + skullProjTargetX = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - skullFiringPos.X; + skullProjTargetY = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - skullFiringPos.Y; + skullProjTargetDist = (float)Math.Sqrt(skullProjTargetX * skullProjTargetX + skullProjTargetY * skullProjTargetY); + skullProjTargetDist = skullProjSpeed / skullProjTargetDist; + skullProjTargetX *= skullProjTargetDist; + skullProjTargetY *= skullProjTargetDist; int spread = bossRush ? 100 : 50; - Vector2 vector19 = new Vector2(num163 + Main.rand.Next(-spread, spread + 1) * 0.01f, num164 + Main.rand.Next(-spread, spread + 1) * 0.01f); - vector19.Normalize(); - vector19 *= num162; - vector19 += npc.velocity; - num163 = vector19.X; - num164 = vector19.Y; + Vector2 skullProjDirection = new Vector2(skullProjTargetX + Main.rand.Next(-spread, spread + 1) * 0.01f, skullProjTargetY + Main.rand.Next(-spread, spread + 1) * 0.01f); + skullProjDirection.Normalize(); + skullProjDirection *= skullProjSpeed; + skullProjDirection += npc.velocity; + skullProjTargetX = skullProjDirection.X; + skullProjTargetY = skullProjDirection.Y; int type = ProjectileID.Skull; int damage = npc.GetProjectileDamage(type); - vector18 += vector19 * 5f; - int num168 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector18.X, vector18.Y, num163, num164, type, damage, 0f, Main.myPlayer, -1f, 0f); - Main.projectile[num168].timeLeft = 300; + skullFiringPos += skullProjDirection * 5f; + int skullProjectile = Projectile.NewProjectile(npc.GetSource_FromAI(), skullFiringPos.X, skullFiringPos.Y, skullProjTargetX, skullProjTargetY, type, damage, 0f, Main.myPlayer, -1f, 0f); + Main.projectile[skullProjectile].timeLeft = 300; npc.netUpdate = true; } @@ -337,58 +338,58 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.rotation = npc.velocity.X / 15f; - float num169 = 0.04f + (death ? 0.04f * (1f - lifeRatio) : 0f); - float num170 = 3.5f - (death ? 1f - lifeRatio : 0f); - float num171 = 0.08f + (death ? 0.04f * (1f - lifeRatio) : 0f); - float num172 = 8.5f - (death ? 2f * (1f - lifeRatio) : 0f); + float headYAcceleration = 0.04f + (death ? 0.04f * (1f - lifeRatio) : 0f); + float headYTopSpeed = 3.5f - (death ? 1f - lifeRatio : 0f); + float headXAcceleration = 0.08f + (death ? 0.04f * (1f - lifeRatio) : 0f); + float headXTopSpeed = 8.5f - (death ? 2f * (1f - lifeRatio) : 0f); if (Main.getGoodWorld) { - num169 += 0.01f; - num170 += 1f; - num171 += 0.05f; - num172 += 2f; + headYAcceleration += 0.01f; + headYTopSpeed += 1f; + headXAcceleration += 0.05f; + headXTopSpeed += 2f; } if (bossRush) { - num169 *= 1.25f; - num170 *= 0.75f; - num171 *= 1.25f; - num172 *= 0.75f; + headYAcceleration *= 1.25f; + headYTopSpeed *= 0.75f; + headXAcceleration *= 1.25f; + headXTopSpeed *= 0.75f; } if (npc.position.Y > Main.player[npc.target].position.Y - 250f) { if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.98f; - npc.velocity.Y -= num169; - if (npc.velocity.Y > num170) - npc.velocity.Y = num170; + npc.velocity.Y -= headYAcceleration; + if (npc.velocity.Y > headYTopSpeed) + npc.velocity.Y = headYTopSpeed; } else if (npc.position.Y < Main.player[npc.target].position.Y - 250f) { if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.98f; - npc.velocity.Y += num169; - if (npc.velocity.Y < -num170) - npc.velocity.Y = -num170; + npc.velocity.Y += headYAcceleration; + if (npc.velocity.Y < -headYTopSpeed) + npc.velocity.Y = -headYTopSpeed; } if (npc.position.X + (npc.width / 2) > Main.player[npc.target].position.X + (Main.player[npc.target].width / 2)) { if (npc.velocity.X > 0f) npc.velocity.X *= 0.98f; - npc.velocity.X -= num171; - if (npc.velocity.X > num172) - npc.velocity.X = num172; + npc.velocity.X -= headXAcceleration; + if (npc.velocity.X > headXTopSpeed) + npc.velocity.X = headXTopSpeed; } if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + (Main.player[npc.target].width / 2)) { if (npc.velocity.X < 0f) npc.velocity.X *= 0.98f; - npc.velocity.X += num171; - if (npc.velocity.X < -num172) - npc.velocity.X = -num172; + npc.velocity.X += headXAcceleration; + if (npc.velocity.X < -headXTopSpeed) + npc.velocity.X = -headXTopSpeed; } } @@ -402,21 +403,20 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { if (NPC.CountNPCS(NPCID.DarkCaster) < 6) { - int num167 = 1000; - for (int num168 = 0; num168 < num167; num168++) + for (int i = 0; i < 1000; i++) { - int num169 = (int)(npc.Center.X / 16f) + Main.rand.Next(-50, 51); - int num170; - for (num170 = (int)(npc.Center.Y / 16f) + Main.rand.Next(-50, 51); num170 < Main.maxTilesY - 10 && !WorldGen.SolidTile(num169, num170); num170++) + int headYAcceleration = (int)(npc.Center.X / 16f) + Main.rand.Next(-50, 51); + int headYTopSpeed; + for (headYTopSpeed = (int)(npc.Center.Y / 16f) + Main.rand.Next(-50, 51); headYTopSpeed < Main.maxTilesY - 10 && !WorldGen.SolidTile(headYAcceleration, headYTopSpeed); headYTopSpeed++) { } - num170--; - if (!WorldGen.SolidTile(num169, num170)) + headYTopSpeed--; + if (!WorldGen.SolidTile(headYAcceleration, headYTopSpeed)) { - int num171 = NPC.NewNPC(npc.GetSource_FromAI(), num169 * 16 + 8, num170 * 16, NPCID.DarkCaster); - if (Main.netMode == NetmodeID.Server && num171 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num171); + int headXAcceleration = NPC.NewNPC(npc.GetSource_FromAI(), headYAcceleration * 16 + 8, headYTopSpeed * 16, NPCID.DarkCaster); + if (Main.netMode == NetmodeID.Server && headXAcceleration < Main.maxNPCs) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, headXAcceleration); break; } @@ -427,21 +427,20 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { if (!NPC.AnyNPCs(NPCID.DiabolistWhite)) { - int num167 = 1000; - for (int num168 = 0; num168 < num167; num168++) + for (int i = 0; i < 1000; i++) { - int num169 = (int)(npc.Center.X / 16f) + Main.rand.Next(-50, 51); - int num170; - for (num170 = (int)(npc.Center.Y / 16f) + Main.rand.Next(-50, 51); num170 < Main.maxTilesY - 10 && !WorldGen.SolidTile(num169, num170); num170++) + int headYAcceleration = (int)(npc.Center.X / 16f) + Main.rand.Next(-50, 51); + int headYTopSpeed; + for (headYTopSpeed = (int)(npc.Center.Y / 16f) + Main.rand.Next(-50, 51); headYTopSpeed < Main.maxTilesY - 10 && !WorldGen.SolidTile(headYAcceleration, headYTopSpeed); headYTopSpeed++) { } - num170--; - if (!WorldGen.SolidTile(num169, num170)) + headYTopSpeed--; + if (!WorldGen.SolidTile(headYAcceleration, headYTopSpeed)) { - int num171 = NPC.NewNPC(npc.GetSource_FromAI(), num169 * 16 + 8, num170 * 16, NPCID.DiabolistWhite); - if (Main.netMode == NetmodeID.Server && num171 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num171); + int headXAcceleration = NPC.NewNPC(npc.GetSource_FromAI(), headYAcceleration * 16 + 8, headYTopSpeed * 16, NPCID.DiabolistWhite); + if (Main.netMode == NetmodeID.Server && headXAcceleration < Main.maxNPCs) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, headXAcceleration); break; } @@ -466,21 +465,20 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { if (Main.netMode != NetmodeID.MultiplayerClient && NPC.CountNPCS(NPCID.DarkCaster) < 6) { - int num167 = 1000; - for (int num168 = 0; num168 < num167; num168++) + for (int j = 0; j < 1000; j++) { - int num169 = (int)(npc.Center.X / 16f) + Main.rand.Next(-50, 51); - int num170; - for (num170 = (int)(npc.Center.Y / 16f) + Main.rand.Next(-50, 51); num170 < Main.maxTilesY - 10 && !WorldGen.SolidTile(num169, num170); num170++) + int headYAcceleration = (int)(npc.Center.X / 16f) + Main.rand.Next(-50, 51); + int headYTopSpeed; + for (headYTopSpeed = (int)(npc.Center.Y / 16f) + Main.rand.Next(-50, 51); headYTopSpeed < Main.maxTilesY - 10 && !WorldGen.SolidTile(headYAcceleration, headYTopSpeed); headYTopSpeed++) { } - num170--; - if (!WorldGen.SolidTile(num169, num170)) + headYTopSpeed--; + if (!WorldGen.SolidTile(headYAcceleration, headYTopSpeed)) { - int num171 = NPC.NewNPC(npc.GetSource_FromAI(), num169 * 16 + 8, num170 * 16, NPCID.DarkCaster); - if (Main.netMode == NetmodeID.Server && num171 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num171); + int headXAcceleration = NPC.NewNPC(npc.GetSource_FromAI(), headYAcceleration * 16 + 8, headYTopSpeed * 16, NPCID.DarkCaster); + if (Main.netMode == NetmodeID.Server && headXAcceleration < Main.maxNPCs) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, headXAcceleration); break; } @@ -498,30 +496,30 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } npc.rotation += npc.direction * 0.3f; - Vector2 vector20 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num173 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector20.X; - float num174 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector20.Y; - float num175 = (float)Math.Sqrt(num173 * num173 + num174 * num174); + Vector2 headSpinPos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float headSpinTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - headSpinPos.X; + float headSpinTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - headSpinPos.Y; + float headSpinTargetDist = (float)Math.Sqrt(headSpinTargetX * headSpinTargetX + headSpinTargetY * headSpinTargetY); // Increase speed while charging npc.damage = (int)(npc.defDamage * 1.3); - float num176 = bossRush ? 9f : 4.5f; + float headSpinVelocityMult = bossRush ? 9f : 4.5f; float velocityBoost = death ? 1f : 1f - lifeRatio; if (handsDead || bossRush) - num176 += velocityBoost; + headSpinVelocityMult += velocityBoost; - if (num175 > 150f) + if (headSpinTargetDist > 150f) { - float baseDistanceVelocityMult = 1f + MathHelper.Clamp((num175 - 150f) * 0.0015f, 0.05f, 1.5f); - num176 *= baseDistanceVelocityMult; + float baseDistanceVelocityMult = 1f + MathHelper.Clamp((headSpinTargetDist - 150f) * 0.0015f, 0.05f, 1.5f); + headSpinVelocityMult *= baseDistanceVelocityMult; } if (Main.getGoodWorld) - num176 *= 1.3f; + headSpinVelocityMult *= 1.3f; - num175 = num176 / num175; - npc.velocity.X = num173 * num175; - npc.velocity.Y = num174 * num175; + headSpinTargetDist = headSpinVelocityMult / headSpinTargetDist; + npc.velocity.X = headSpinTargetX * headSpinTargetDist; + npc.velocity.Y = headSpinTargetY * headSpinTargetDist; } // Daytime enrage @@ -531,13 +529,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses calamityGlobalNPC.DR = 0.9999f; calamityGlobalNPC.unbreakableDR = true; npc.rotation += npc.direction * 0.3f; - Vector2 vector21 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num177 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector21.X; - float num178 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector21.Y; - float num179 = (float)Math.Sqrt(num177 * num177 + num178 * num178); - num179 = 8f / num179; - npc.velocity.X = num177 * num179; - npc.velocity.Y = num178 * num179; + Vector2 enrageSpinPos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float enrageSpinTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - enrageSpinPos.X; + float enrageSpinTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - enrageSpinPos.Y; + float enrageSpinTargetDist = (float)Math.Sqrt(enrageSpinTargetX * enrageSpinTargetX + enrageSpinTargetY * enrageSpinTargetY); + enrageSpinTargetDist = 8f / enrageSpinTargetDist; + npc.velocity.X = enrageSpinTargetX * enrageSpinTargetDist; + npc.velocity.Y = enrageSpinTargetY * enrageSpinTargetDist; } // Despawn @@ -552,19 +550,19 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Emit dust - if (npc.ai[1] != 2f && npc.ai[1] != 3f && num156 != 0) + if (npc.ai[1] != 2f && npc.ai[1] != 3f && numHandsAlive != 0) { - int num180 = Dust.NewDust(new Vector2(npc.position.X + (npc.width / 2) - 15f - npc.velocity.X * 5f, npc.position.Y + npc.height - 2f), 30, 10, 5, -npc.velocity.X * 0.2f, 3f, 0, default, 2f); - Main.dust[num180].noGravity = true; - Main.dust[num180].velocity.X = Main.dust[num180].velocity.X * 1.3f; - Main.dust[num180].velocity.X = Main.dust[num180].velocity.X + npc.velocity.X * 0.4f; - Main.dust[num180].velocity.Y = Main.dust[num180].velocity.Y + (2f + npc.velocity.Y); - for (int num181 = 0; num181 < 2; num181++) + int idleDust = Dust.NewDust(new Vector2(npc.position.X + (npc.width / 2) - 15f - npc.velocity.X * 5f, npc.position.Y + npc.height - 2f), 30, 10, 5, -npc.velocity.X * 0.2f, 3f, 0, default, 2f); + Main.dust[idleDust].noGravity = true; + Main.dust[idleDust].velocity.X = Main.dust[idleDust].velocity.X * 1.3f; + Main.dust[idleDust].velocity.X = Main.dust[idleDust].velocity.X + npc.velocity.X * 0.4f; + Main.dust[idleDust].velocity.Y = Main.dust[idleDust].velocity.Y + (2f + npc.velocity.Y); + for (int j = 0; j < 2; j++) { - num180 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 120f), npc.width, 60, 5, npc.velocity.X, npc.velocity.Y, 0, default, 2f); - Main.dust[num180].noGravity = true; - Main.dust[num180].velocity -= npc.velocity; - Main.dust[num180].velocity.Y = Main.dust[num180].velocity.Y + 5f; + idleDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 120f), npc.width, 60, 5, npc.velocity.X, npc.velocity.Y, 0, default, 2f); + Main.dust[idleDust].noGravity = true; + Main.dust[idleDust].velocity -= npc.velocity; + Main.dust[idleDust].velocity.Y = Main.dust[idleDust].velocity.Y + 5f; } } @@ -610,9 +608,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Teleport dust for (int m = 0; m < 10; m++) { - int num39 = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 200, default, 3f); - Main.dust[num39].noGravity = true; - Main.dust[num39].velocity.X = Main.dust[num39].velocity.X * 2f; + int teleportDust = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 200, default, 3f); + Main.dust[teleportDust].noGravity = true; + Main.dust[teleportDust].velocity.X = Main.dust[teleportDust].velocity.X * 2f; } // New location @@ -726,20 +724,20 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } } - Vector2 vector22 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num182 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector22.X; - float num183 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector22.Y; - float num184 = (float)Math.Sqrt(num182 * num182 + num183 * num183); - npc.rotation = (float)Math.Atan2(num183, num182) + MathHelper.PiOver2; + Vector2 handCurrentPos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float handIdleXPos = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - handCurrentPos.X; + float handIdleYPos = Main.npc[(int)npc.ai[1]].position.Y + 230f - handCurrentPos.Y; + float handIdleDist = (float)Math.Sqrt(handIdleXPos * handIdleXPos + handIdleYPos * handIdleYPos); + npc.rotation = (float)Math.Atan2(handIdleYPos, handIdleXPos) + MathHelper.PiOver2; return false; } if (npc.ai[2] == 1f) { - Vector2 vector23 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num185 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector23.X; - float num186 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector23.Y; - float num187 = (float)Math.Sqrt(num185 * num185 + num186 * num186); - npc.rotation = (float)Math.Atan2(num186, num185) + MathHelper.PiOver2; + Vector2 handCurrentPosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float handDrawbackXPos = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - handCurrentPosition.X; + float handDrawbackYPos = Main.npc[(int)npc.ai[1]].position.Y + 230f - handCurrentPosition.Y; + float handDrawbackDist = (float)Math.Sqrt(handDrawbackXPos * handDrawbackXPos + handDrawbackYPos * handDrawbackYPos); + npc.rotation = (float)Math.Atan2(handDrawbackYPos, handDrawbackXPos) + MathHelper.PiOver2; npc.velocity.X *= 0.95f; npc.velocity.Y -= 0.2f; @@ -750,13 +748,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { npc.TargetClosest(); npc.ai[2] = 2f; - vector23 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num185 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector23.X; - num186 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector23.Y; - num187 = (float)Math.Sqrt(num185 * num185 + num186 * num186); - num187 = 22f / num187; - npc.velocity.X = num185 * num187; - npc.velocity.Y = num186 * num187; + handCurrentPosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + handDrawbackXPos = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - handCurrentPosition.X; + handDrawbackYPos = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - handCurrentPosition.Y; + handDrawbackDist = (float)Math.Sqrt(handDrawbackXPos * handDrawbackXPos + handDrawbackYPos * handDrawbackYPos); + handDrawbackDist = 22f / handDrawbackDist; + npc.velocity.X = handDrawbackXPos * handDrawbackDist; + npc.velocity.Y = handDrawbackYPos * handDrawbackDist; npc.netUpdate = true; } } @@ -770,11 +768,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } else if (npc.ai[2] == 4f) { - Vector2 vector24 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num188 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector24.X; - float num189 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector24.Y; - float num190 = (float)Math.Sqrt(num188 * num188 + num189 * num189); - npc.rotation = (float)Math.Atan2(num189, num188) + MathHelper.PiOver2; + Vector2 handStrikeCurrentPos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float handStrikeXPos = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - handStrikeCurrentPos.X; + float handStrikeYPos = Main.npc[(int)npc.ai[1]].position.Y + 230f - handStrikeCurrentPos.Y; + float handStrikeDist = (float)Math.Sqrt(handStrikeXPos * handStrikeXPos + handStrikeYPos * handStrikeYPos); + npc.rotation = (float)Math.Atan2(handStrikeYPos, handStrikeXPos) + MathHelper.PiOver2; npc.velocity.Y *= 0.95f; npc.velocity.X += 0.2f * -npc.ai[0]; @@ -787,13 +785,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { npc.TargetClosest(); npc.ai[2] = 5f; - vector24 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num188 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector24.X; - num189 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector24.Y; - num190 = (float)Math.Sqrt(num188 * num188 + num189 * num189); - num190 = 23f / num190; - npc.velocity.X = num188 * num190; - npc.velocity.Y = num189 * num190; + handStrikeCurrentPos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + handStrikeXPos = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - handStrikeCurrentPos.X; + handStrikeYPos = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - handStrikeCurrentPos.Y; + handStrikeDist = (float)Math.Sqrt(handStrikeXPos * handStrikeXPos + handStrikeYPos * handStrikeYPos); + handStrikeDist = 23f / handStrikeDist; + npc.velocity.X = handStrikeXPos * handStrikeDist; + npc.velocity.Y = handStrikeYPos * handStrikeDist; npc.netUpdate = true; } } diff --git a/NPCs/VanillaNPCOverrides/Bosses/SkeletronPrimeAI.cs b/NPCs/VanillaNPCOverrides/Bosses/SkeletronPrimeAI.cs index 159a652c59..a7eb64e482 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/SkeletronPrimeAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/SkeletronPrimeAI.cs @@ -1,13 +1,13 @@ -using CalamityMod.Buffs.DamageOverTime; +using System; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; -using System; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { @@ -209,15 +209,15 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses float velocityX = 7f - (death ? 3.5f * (1f - lifeRatio) : 0f); float acceleration = 0.1f + (death ? 0.05f * (1f - lifeRatio) : 0f); - float num500 = 0f; - float num501 = 0f; - float num502 = 0f; - int num503 = ((!(Main.player[npc.target].Center.X < npc.Center.X)) ? 1 : (-1)); + float headDecelerationUpDist = 0f; + float headDecelerationDownDist = 0f; + float headDecelerationHorizontalDist = 0f; + int headHorizontalDirection = ((!(Main.player[npc.target].Center.X < npc.Center.X)) ? 1 : (-1)); if (NPC.IsMechQueenUp) { - num502 = -150f * (float)num503; - num500 = -100f; - num501 = -100f; + headDecelerationHorizontalDist = -150f * (float)headHorizontalDirection; + headDecelerationUpDist = -100f; + headDecelerationDownDist = -100f; } if (!cannonAlive) @@ -252,7 +252,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.player[npc.target].HoldingTrueMeleeWeapon()) acceleration *= 0.5f; - if (npc.position.Y > Main.player[npc.target].position.Y - (400f + num500)) + if (npc.position.Y > Main.player[npc.target].position.Y - (400f + headDecelerationUpDist)) { if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.9f; @@ -262,7 +262,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.velocity.Y > velocityY) npc.velocity.Y = velocityY; } - else if (npc.position.Y < Main.player[npc.target].position.Y - (450f + num501)) + else if (npc.position.Y < Main.player[npc.target].position.Y - (450f + headDecelerationDownDist)) { if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.9f; @@ -273,7 +273,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.velocity.Y = -velocityY; } - if (npc.position.X + (npc.width / 2) > Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (400f + num502)) + if (npc.position.X + (npc.width / 2) > Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (400f + headDecelerationHorizontalDist)) { if (npc.velocity.X > 0f) npc.velocity.X *= 0.9f; @@ -283,7 +283,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.velocity.X > velocityX) npc.velocity.X = velocityX; } - if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - (400f + num502)) + if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - (400f + headDecelerationHorizontalDist)) { if (npc.velocity.X < 0f) npc.velocity.X *= 0.9f; @@ -321,8 +321,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses Vector2 spinningPoint = normalLaserRotation ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); for (int k = 0; k < totalProjectiles; k++) { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + Vector2.Normalize(vector255) * 30f, vector255, type, damage, 0f, Main.myPlayer, 1f, 0f); + Vector2 laserFireDirection = spinningPoint.RotatedBy(radians * k); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + Vector2.Normalize(laserFireDirection) * 30f, laserFireDirection, type, damage, 0f, Main.myPlayer, 1f, 0f); Main.projectile[proj].timeLeft = 900; } calamityGlobalNPC.newAI[3] += 1f; @@ -351,10 +351,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses else npc.rotation += npc.direction * 0.3f; - Vector2 vector48 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num455 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector48.X; - float num456 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector48.Y; - float num457 = (float)Math.Sqrt(num455 * num455 + num456 * num456); + Vector2 headPosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float headTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - headPosition.X; + float headTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - headPosition.Y; + float headTargetDistance = (float)Math.Sqrt(headTargetX * headTargetX + headTargetY * headTargetY); float speed = bossRush ? 9f : 6f; if (phase2) @@ -362,30 +362,30 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (phase3) speed += 0.5f; - if (num457 > 150f) + if (headTargetDistance > 150f) { - float baseDistanceVelocityMult = 1f + MathHelper.Clamp((num457 - 150f) * 0.0015f, 0.05f, 1.5f); + float baseDistanceVelocityMult = 1f + MathHelper.Clamp((headTargetDistance - 150f) * 0.0015f, 0.05f, 1.5f); speed *= baseDistanceVelocityMult; } if (NPC.IsMechQueenUp) { - float num508 = (NPC.npcsFoundForCheckActive[NPCID.TheDestroyerBody] ? 0.6f : 0.75f); - speed *= num508; + float mechdusaSpeedMult = (NPC.npcsFoundForCheckActive[NPCID.TheDestroyerBody] ? 0.6f : 0.75f); + speed *= mechdusaSpeedMult; } - num457 = speed / num457; - npc.velocity.X = num455 * num457; - npc.velocity.Y = num456 * num457; + headTargetDistance = speed / headTargetDistance; + npc.velocity.X = headTargetX * headTargetDistance; + npc.velocity.Y = headTargetY * headTargetDistance; if (NPC.IsMechQueenUp) { - float num509 = Vector2.Distance(npc.Center, Main.player[npc.target].Center); - if (num509 < 0.1f) - num509 = 0f; + float mechdusaAccelMult = Vector2.Distance(npc.Center, Main.player[npc.target].Center); + if (mechdusaAccelMult < 0.1f) + mechdusaAccelMult = 0f; - if (num509 < speed) - npc.velocity = npc.velocity.SafeNormalize(Vector2.Zero) * num509; + if (mechdusaAccelMult < speed) + npc.velocity = npc.velocity.SafeNormalize(Vector2.Zero) * mechdusaAccelMult; } } @@ -401,21 +401,21 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses else npc.rotation += npc.direction * 0.3f; - Vector2 vector49 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num458 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector49.X; - float num459 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector49.Y; - float num460 = (float)Math.Sqrt(num458 * num458 + num459 * num459); + Vector2 enragedHeadPosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float enragedHeadTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - enragedHeadPosition.X; + float enragedHeadTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - enragedHeadPosition.Y; + float enragedHeadTargetDist = (float)Math.Sqrt(enragedHeadTargetX * enragedHeadTargetX + enragedHeadTargetY * enragedHeadTargetY); - float num461 = 10f; - num461 += num460 / 100f; - if (num461 < 8f) - num461 = 8f; - if (num461 > 32f) - num461 = 32f; + float enragedHeadSpeed = 10f; + enragedHeadSpeed += enragedHeadTargetDist / 100f; + if (enragedHeadSpeed < 8f) + enragedHeadSpeed = 8f; + if (enragedHeadSpeed > 32f) + enragedHeadSpeed = 32f; - num460 = num461 / num460; - npc.velocity.X = num458 * num460; - npc.velocity.Y = num459 * num460; + enragedHeadTargetDist = enragedHeadSpeed / enragedHeadTargetDist; + npc.velocity.X = enragedHeadTargetX * enragedHeadTargetDist; + npc.velocity.Y = enragedHeadTargetY * enragedHeadTargetDist; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -423,28 +423,28 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.localAI[0] >= 60f) { npc.localAI[0] = 0f; - Vector2 vector16 = npc.Center; - if (Collision.CanHit(vector16, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + Vector2 headCenter = npc.Center; + if (Collision.CanHit(headCenter, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { - float num159 = 7f; - float num160 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector16.X + Main.rand.Next(-20, 21); - float num161 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector16.Y + Main.rand.Next(-20, 21); - float num162 = (float)Math.Sqrt(num160 * num160 + num161 * num161); - num162 = num159 / num162; - num160 *= num162; - num161 *= num162; + enragedHeadSpeed = 7f; + float enragedHeadSkullTargetX = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - headCenter.X + Main.rand.Next(-20, 21); + float enragedHeadSkullTargetY = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - headCenter.Y + Main.rand.Next(-20, 21); + float enragedHeadSkullTargetDist = (float)Math.Sqrt(enragedHeadSkullTargetX * enragedHeadSkullTargetX + enragedHeadSkullTargetY * enragedHeadSkullTargetY); + enragedHeadSkullTargetDist = enragedHeadSpeed / enragedHeadSkullTargetDist; + enragedHeadSkullTargetX *= enragedHeadSkullTargetDist; + enragedHeadSkullTargetY *= enragedHeadSkullTargetDist; - Vector2 value = new Vector2(num160 * 1f + Main.rand.Next(-50, 51) * 0.01f, num161 * 1f + Main.rand.Next(-50, 51) * 0.01f); + Vector2 value = new Vector2(enragedHeadSkullTargetX * 1f + Main.rand.Next(-50, 51) * 0.01f, enragedHeadSkullTargetY * 1f + Main.rand.Next(-50, 51) * 0.01f); value.Normalize(); - value *= num159; + value *= enragedHeadSpeed; value += npc.velocity; - num160 = value.X; - num161 = value.Y; + enragedHeadSkullTargetX = value.X; + enragedHeadSkullTargetY = value.Y; int type = ProjectileID.Skull; - vector16 += value * 5f; - int num165 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector16.X, vector16.Y, num160, num161, type, 250, 0f, Main.myPlayer, -1f, 0f); - Main.projectile[num165].timeLeft = 300; + headCenter += value * 5f; + int enragedSkulls = Projectile.NewProjectile(npc.GetSource_FromAI(), headCenter.X, headCenter.Y, enragedHeadSkullTargetX, enragedHeadSkullTargetY, type, 250, 0f, Main.myPlayer, -1f, 0f); + Main.projectile[enragedSkulls].timeLeft = 300; } } } @@ -455,19 +455,19 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { if (NPC.IsMechQueenUp) { - int num514 = NPC.FindFirstNPC(NPCID.Retinazer); - if (num514 >= 0) - Main.npc[num514].EncourageDespawn(5); + int mechdusaBossDespawning = NPC.FindFirstNPC(NPCID.Retinazer); + if (mechdusaBossDespawning >= 0) + Main.npc[mechdusaBossDespawning].EncourageDespawn(5); - num514 = NPC.FindFirstNPC(NPCID.Spazmatism); - if (num514 >= 0) - Main.npc[num514].EncourageDespawn(5); + mechdusaBossDespawning = NPC.FindFirstNPC(NPCID.Spazmatism); + if (mechdusaBossDespawning >= 0) + Main.npc[mechdusaBossDespawning].EncourageDespawn(5); if (!NPC.AnyNPCs(NPCID.Retinazer) && !NPC.AnyNPCs(NPCID.Spazmatism)) { - num514 = NPC.FindFirstNPC(NPCID.TheDestroyer); - if (num514 >= 0) - Main.npc[num514].Transform(NPCID.TheDestroyerTail); + mechdusaBossDespawning = NPC.FindFirstNPC(NPCID.TheDestroyer); + if (mechdusaBossDespawning >= 0) + Main.npc[mechdusaBossDespawning].Transform(NPCID.TheDestroyerTail); npc.EncourageDespawn(5); } @@ -540,27 +540,27 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector16 = npc.Center; - float num159 = 4f + (death ? 2f * (1f - lifeRatio) : 0f); - float num160 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector16.X + Main.rand.Next(-20, 21); - float num161 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector16.Y + Main.rand.Next(-20, 21); - float num162 = (float)Math.Sqrt(num160 * num160 + num161 * num161); - num162 = num159 / num162; - num160 *= num162; - num161 *= num162; + Vector2 headCenter = npc.Center; + float enragedHeadSpeed = 4f + (death ? 2f * (1f - lifeRatio) : 0f); + float enragedHeadSkullTargetX = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - headCenter.X + Main.rand.Next(-20, 21); + float enragedHeadSkullTargetY = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - headCenter.Y + Main.rand.Next(-20, 21); + float enragedHeadSkullTargetDist = (float)Math.Sqrt(enragedHeadSkullTargetX * enragedHeadSkullTargetX + enragedHeadSkullTargetY * enragedHeadSkullTargetY); + enragedHeadSkullTargetDist = enragedHeadSpeed / enragedHeadSkullTargetDist; + enragedHeadSkullTargetX *= enragedHeadSkullTargetDist; + enragedHeadSkullTargetY *= enragedHeadSkullTargetDist; - Vector2 value = new Vector2(num160 + Main.rand.Next(-skullSpread, skullSpread + 1) * 0.01f, num161 + Main.rand.Next(-skullSpread, skullSpread + 1) * 0.01f); + Vector2 value = new Vector2(enragedHeadSkullTargetX + Main.rand.Next(-skullSpread, skullSpread + 1) * 0.01f, enragedHeadSkullTargetY + Main.rand.Next(-skullSpread, skullSpread + 1) * 0.01f); value.Normalize(); - value *= num159; - num160 = value.X; - num161 = value.Y; + value *= enragedHeadSpeed; + enragedHeadSkullTargetX = value.X; + enragedHeadSkullTargetY = value.Y; int type = ProjectileID.Skull; int damage = npc.GetProjectileDamage(type); - vector16 += value * 5f; - int num165 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector16.X, vector16.Y, num160, num161, type, damage, 0f, Main.myPlayer, -1f, 0f); - Main.projectile[num165].timeLeft = 480; - Main.projectile[num165].tileCollide = false; + headCenter += value * 5f; + int enragedSkulls = Projectile.NewProjectile(npc.GetSource_FromAI(), headCenter.X, headCenter.Y, enragedHeadSkullTargetX, enragedHeadSkullTargetY, type, damage, 0f, Main.myPlayer, -1f, 0f); + Main.projectile[enragedSkulls].timeLeft = 480; + Main.projectile[enragedSkulls].tileCollide = false; } } @@ -772,11 +772,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.netUpdate = true; } - Vector2 vector62 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num506 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector62.X; - float num507 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector62.Y; - float num508 = (float)Math.Sqrt(num506 * num506 + num507 * num507); - npc.rotation = (float)Math.Atan2(num507, num506) - MathHelper.PiOver2; + Vector2 laserArmPosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float laserArmTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - laserArmPosition.X; + float laserArmTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - laserArmPosition.Y; + float laserArmTargetDist = (float)Math.Sqrt(laserArmTargetX * laserArmTargetX + laserArmTargetY * laserArmTargetY); + npc.rotation = (float)Math.Atan2(laserArmTargetY, laserArmTargetX) - MathHelper.PiOver2; if (Main.netMode != NetmodeID.MultiplayerClient && !dontAttack) { @@ -793,15 +793,15 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { npc.localAI[0] = 0f; npc.TargetClosest(); - float num509 = bossRush ? 5f : 4f; + float laserSpeed = bossRush ? 5f : 4f; int type = ProjectileID.DeathLaser; int damage = npc.GetProjectileDamage(type); - num508 = num509 / num508; - num506 *= num508; - num507 *= num508; - vector62.X += num506 * 30f; - vector62.Y += num507 * 30f; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector62.X, vector62.Y, num506, num507, type, damage, 0f, Main.myPlayer, 1f, 0f); + laserArmTargetDist = laserSpeed / laserArmTargetDist; + laserArmTargetX *= laserArmTargetDist; + laserArmTargetY *= laserArmTargetDist; + laserArmPosition.X += laserArmTargetX * 30f; + laserArmPosition.Y += laserArmTargetY * 30f; + Projectile.NewProjectile(npc.GetSource_FromAI(), laserArmPosition.X, laserArmPosition.Y, laserArmTargetX, laserArmTargetY, type, damage, 0f, Main.myPlayer, 1f, 0f); } } } @@ -830,10 +830,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.netUpdate = true; } - Vector2 vector63 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num513 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector63.X; - float num514 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector63.Y; - npc.rotation = (float)Math.Atan2(num514, num513) - MathHelper.PiOver2; + Vector2 laserRingArmPosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float laserRingTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - laserRingArmPosition.X; + float laserRingTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - laserRingArmPosition.Y; + npc.rotation = (float)Math.Atan2(laserRingTargetY, laserRingTargetX) - MathHelper.PiOver2; if (Main.netMode != NetmodeID.MultiplayerClient && !dontAttack) { @@ -861,8 +861,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses Vector2 spinningPoint = normalLaserRotation ? new Vector2(0f, -velocity) : new Vector2(-laserVelocityX, -velocity); for (int k = 0; k < totalProjectiles; k++) { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + Vector2.Normalize(vector255) * 30f, vector255, type, damage, 0f, Main.myPlayer, 1f, 0f); + Vector2 laserFireDirection = spinningPoint.RotatedBy(radians * k); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + Vector2.Normalize(laserFireDirection) * 30f, laserFireDirection, type, damage, 0f, Main.myPlayer, 1f, 0f); Main.projectile[proj].timeLeft = 900; } npc.localAI[1] += 1f; @@ -1041,11 +1041,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.npc[(int)npc.ai[1]].ai[1] == 3f && npc.timeLeft > 10) npc.timeLeft = 10; - Vector2 vector60 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num492 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector60.X; - float num493 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector60.Y; - float num494 = (float)Math.Sqrt(num492 * num492 + num493 * num493); - npc.rotation = (float)Math.Atan2(num493, num492) - MathHelper.PiOver2; + Vector2 cannonArmPosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float cannonArmTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - cannonArmPosition.X; + float cannonArmTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - cannonArmPosition.Y; + float cannonArmTargetDist = (float)Math.Sqrt(cannonArmTargetX * cannonArmTargetX + cannonArmTargetY * cannonArmTargetY); + npc.rotation = (float)Math.Atan2(cannonArmTargetY, cannonArmTargetX) - MathHelper.PiOver2; if (Main.netMode != NetmodeID.MultiplayerClient && !dontAttack) { @@ -1063,25 +1063,24 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses SoundEngine.PlaySound(SoundID.Item62, npc.Center); npc.localAI[0] = 0f; npc.TargetClosest(); - float num495 = 0.5f; int type = ProjectileID.RocketSkeleton; int damage = npc.GetProjectileDamage(type); - num494 = num495 / num494; - num492 *= num494; - num493 *= num494; - vector60.X += num492 * 30f; - vector60.Y += num493 * 30f; - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), vector60.X, vector60.Y, num492, num493, type, damage, 0f, Main.myPlayer, npc.target, 1f); + cannonArmTargetDist = 0.5f / cannonArmTargetDist; + cannonArmTargetX *= cannonArmTargetDist; + cannonArmTargetY *= cannonArmTargetDist; + cannonArmPosition.X += cannonArmTargetX * 30f; + cannonArmPosition.Y += cannonArmTargetY * 30f; + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), cannonArmPosition.X, cannonArmPosition.Y, cannonArmTargetX, cannonArmTargetY, type, damage, 0f, Main.myPlayer, npc.target, 1f); Main.projectile[proj].timeLeft = 600; } } } else { - Vector2 vector61 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num499 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector61.X; - float num500 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector61.Y; - npc.rotation = (float)Math.Atan2(num500, num499) - MathHelper.PiOver2; + Vector2 cannonSpreadArmPosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float cannonSpreadArmTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - cannonSpreadArmPosition.X; + float cannonSpreadArmTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - cannonSpreadArmPosition.Y; + npc.rotation = (float)Math.Atan2(cannonSpreadArmTargetY, cannonSpreadArmTargetX) - MathHelper.PiOver2; if (Main.netMode != NetmodeID.MultiplayerClient && !dontAttack) { @@ -1099,17 +1098,16 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses SoundEngine.PlaySound(SoundID.Item62, npc.Center); npc.localAI[0] = 0f; npc.TargetClosest(); - float num502 = 0.5f; int type = ProjectileID.RocketSkeleton; int damage = npc.GetProjectileDamage(type); - Vector2 value19 = Main.player[npc.target].Center - npc.Center; - value19.Normalize(); - value19 *= num502; + Vector2 cannonSpreadTargetDist = Main.player[npc.target].Center - npc.Center; + cannonSpreadTargetDist.Normalize(); + cannonSpreadTargetDist *= 0.5f; int numProj = bossRush ? 5 : 3; float rotation = MathHelper.ToRadians(bossRush ? 8 : 5); for (int i = 0; i < numProj; i++) { - Vector2 perturbedSpeed = value19.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); + Vector2 perturbedSpeed = cannonSpreadTargetDist.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + Vector2.Normalize(perturbedSpeed) * 30f, perturbedSpeed, type, damage, 0f, Main.myPlayer, npc.target, 1f); Main.projectile[proj].timeLeft = 600; } @@ -1137,18 +1135,18 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.spriteDirection = -(int)npc.ai[0]; // Where the vice should be in relation to the head - Vector2 vector55 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num477 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector55.X; - float num478 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector55.Y; - float num479 = (float)Math.Sqrt(num477 * num477 + num478 * num478); + Vector2 viceArmPosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float viceArmIdleXPos = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - viceArmPosition.X; + float viceArmIdleYPos = Main.npc[(int)npc.ai[1]].position.Y + 230f - viceArmPosition.Y; + float viceArmIdleDistance = (float)Math.Sqrt(viceArmIdleXPos * viceArmIdleXPos + viceArmIdleYPos * viceArmIdleYPos); // Return the vice to its proper location in relation to the head if it's too far away if (npc.ai[2] != 99f) { - if (num479 > 800f) + if (viceArmIdleDistance > 800f) npc.ai[2] = 99f; } - else if (num479 < 400f) + else if (viceArmIdleDistance < 400f) npc.ai[2] = 0f; // Despawn if head is gone @@ -1318,10 +1316,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.velocity.X = -velocityX2; } - Vector2 vector57 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num483 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector57.X; - float num484 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector57.Y; - npc.rotation = (float)Math.Atan2(num484, num483) + MathHelper.PiOver2; + Vector2 viceArmReelbackCurrentPos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float viceArmReelbackXDest = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - viceArmReelbackCurrentPos.X; + float viceArmReelbackYDest = Main.npc[(int)npc.ai[1]].position.Y + 230f - viceArmReelbackCurrentPos.Y; + npc.rotation = (float)Math.Atan2(viceArmReelbackYDest, viceArmReelbackXDest) + MathHelper.PiOver2; return false; } @@ -1331,10 +1329,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.9f; - Vector2 vector58 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num486 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 280f * npc.ai[0] - vector58.X; - float num487 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector58.Y; - npc.rotation = (float)Math.Atan2(num487, num486) + MathHelper.PiOver2; + Vector2 viceArmChargePosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float viceArmChargeTargetX = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 280f * npc.ai[0] - viceArmChargePosition.X; + float viceArmChargeTargetY = Main.npc[(int)npc.ai[1]].position.Y + 230f - viceArmChargePosition.Y; + npc.rotation = (float)Math.Atan2(viceArmChargeTargetY, viceArmChargeTargetX) + MathHelper.PiOver2; npc.velocity.X = (npc.velocity.X * 5f + Main.npc[(int)npc.ai[1]].velocity.X) / 6f; npc.velocity.X += 0.5f; @@ -1355,13 +1353,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.ai[2] = 2f; npc.TargetClosest(); - vector58 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num486 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector58.X; - num487 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector58.Y; - float num488 = (float)Math.Sqrt(num486 * num486 + num487 * num487); - num488 = chargeVelocity / num488; - npc.velocity.X = num486 * num488; - npc.velocity.Y = num487 * num488; + viceArmChargePosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + viceArmChargeTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - viceArmChargePosition.X; + viceArmChargeTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - viceArmChargePosition.Y; + float viceArmChargeTargetDist = (float)Math.Sqrt(viceArmChargeTargetX * viceArmChargeTargetX + viceArmChargeTargetY * viceArmChargeTargetY); + viceArmChargeTargetDist = chargeVelocity / viceArmChargeTargetDist; + npc.velocity.X = viceArmChargeTargetX * viceArmChargeTargetDist; + npc.velocity.Y = viceArmChargeTargetY * viceArmChargeTargetDist; npc.netUpdate = true; } } @@ -1396,10 +1394,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Different type of charge else if (npc.ai[2] == 4f) { - Vector2 vector59 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num489 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector59.X; - float num490 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector59.Y; - npc.rotation = (float)Math.Atan2(num490, num489) + MathHelper.PiOver2; + Vector2 viceArmOtherChargePosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float viceArmOtherChargeTargetX = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - viceArmOtherChargePosition.X; + float viceArmOtherChargeTargetY = Main.npc[(int)npc.ai[1]].position.Y + 230f - viceArmOtherChargePosition.Y; + npc.rotation = (float)Math.Atan2(viceArmOtherChargeTargetY, viceArmOtherChargeTargetX) + MathHelper.PiOver2; npc.velocity.Y = (npc.velocity.Y * 5f + Main.npc[(int)npc.ai[1]].velocity.Y) / 6f; @@ -1419,13 +1417,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.ai[2] = 5f; npc.TargetClosest(); - vector59 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num489 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector59.X; - num490 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector59.Y; - float num491 = (float)Math.Sqrt(num489 * num489 + num490 * num490); - num491 = chargeVelocity / num491; - npc.velocity.X = num489 * num491; - npc.velocity.Y = num490 * num491; + viceArmOtherChargePosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + viceArmOtherChargeTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - viceArmOtherChargePosition.X; + viceArmOtherChargeTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - viceArmOtherChargePosition.Y; + float viceArmOtherChargeTargetDist = (float)Math.Sqrt(viceArmOtherChargeTargetX * viceArmOtherChargeTargetX + viceArmOtherChargeTargetY * viceArmOtherChargeTargetY); + viceArmOtherChargeTargetDist = chargeVelocity / viceArmOtherChargeTargetDist; + npc.velocity.X = viceArmOtherChargeTargetX * viceArmOtherChargeTargetDist; + npc.velocity.Y = viceArmOtherChargeTargetY * viceArmOtherChargeTargetDist; npc.netUpdate = true; } } @@ -1471,17 +1469,17 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) npc.TargetClosest(); - Vector2 vector50 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num462 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector50.X; - float num463 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector50.Y; - float num464 = (float)Math.Sqrt(num462 * num462 + num463 * num463); + Vector2 sawArmLocation = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float sawArmIdleXPos = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - sawArmLocation.X; + float sawArmIdleYPos = Main.npc[(int)npc.ai[1]].position.Y + 230f - sawArmLocation.Y; + float sawArmIdleDistance = (float)Math.Sqrt(sawArmIdleXPos * sawArmIdleXPos + sawArmIdleYPos * sawArmIdleYPos); if (npc.ai[2] != 99f) { - if (num464 > 800f) + if (sawArmIdleDistance > 800f) npc.ai[2] = 99f; } - else if (num464 < 400f) + else if (sawArmIdleDistance < 400f) npc.ai[2] = 0f; npc.spriteDirection = -(int)npc.ai[0]; @@ -1646,19 +1644,19 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.velocity.X = -velocityX; } - Vector2 vector52 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num468 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector52.X; - float num469 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector52.Y; - npc.rotation = (float)Math.Atan2(num469, num468) + MathHelper.PiOver2; + Vector2 sawArmReelbackCurrentPos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float sawArmReelbackXDest = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - sawArmReelbackCurrentPos.X; + float sawArmReelbackYDest = Main.npc[(int)npc.ai[1]].position.Y + 230f - sawArmReelbackCurrentPos.Y; + npc.rotation = (float)Math.Atan2(sawArmReelbackYDest, sawArmReelbackXDest) + MathHelper.PiOver2; return false; } if (npc.ai[2] == 1f) { - Vector2 vector53 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num471 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector53.X; - float num472 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector53.Y; - npc.rotation = (float)Math.Atan2(num472, num471) + MathHelper.PiOver2; + Vector2 sawArmChargePos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float sawArmChargeTargetX = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - sawArmChargePos.X; + float sawArmChargeTargetY = Main.npc[(int)npc.ai[1]].position.Y + 230f - sawArmChargePos.Y; + npc.rotation = (float)Math.Atan2(sawArmChargeTargetY, sawArmChargeTargetX) + MathHelper.PiOver2; npc.velocity.X *= 0.95f; npc.velocity.Y -= 0.5f; @@ -1677,13 +1675,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.ai[2] = 2f; npc.TargetClosest(); - vector53 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num471 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector53.X; - num472 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector53.Y; - float num473 = (float)Math.Sqrt(num471 * num471 + num472 * num472); - num473 = chargeVelocity / num473; - npc.velocity.X = num471 * num473; - npc.velocity.Y = num472 * num473; + sawArmChargePos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + sawArmChargeTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - sawArmChargePos.X; + sawArmChargeTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - sawArmChargePos.Y; + float sawArmChargeTargetDist = (float)Math.Sqrt(sawArmChargeTargetX * sawArmChargeTargetX + sawArmChargeTargetY * sawArmChargeTargetY); + sawArmChargeTargetDist = chargeVelocity / sawArmChargeTargetDist; + npc.velocity.X = sawArmChargeTargetX * sawArmChargeTargetDist; + npc.velocity.Y = sawArmChargeTargetY * sawArmChargeTargetDist; npc.netUpdate = true; } } @@ -1706,37 +1704,37 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (!viceAlive) chargeVelocity += 1.5f; - Vector2 vector54 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num474 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector54.X; - float num475 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector54.Y; - float num476 = (float)Math.Sqrt(num474 * num474 + num475 * num475); - num476 = chargeVelocity / num476; - num474 *= num476; - num475 *= num476; + Vector2 sawArmOtherChargePos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float sawArmOtherChargeTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - sawArmOtherChargePos.X; + float sawArmOtherChargeTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - sawArmOtherChargePos.Y; + float sawArmOtherChargeTargetDist = (float)Math.Sqrt(sawArmOtherChargeTargetX * sawArmOtherChargeTargetX + sawArmOtherChargeTargetY * sawArmOtherChargeTargetY); + sawArmOtherChargeTargetDist = chargeVelocity / sawArmOtherChargeTargetDist; + sawArmOtherChargeTargetX *= sawArmOtherChargeTargetDist; + sawArmOtherChargeTargetY *= sawArmOtherChargeTargetDist; float acceleration = bossRush ? 0.3f : death ? 0.1f : 0.08f; - if (npc.velocity.X > num474) + if (npc.velocity.X > sawArmOtherChargeTargetX) { if (npc.velocity.X > 0f) npc.velocity.X *= 0.9f; npc.velocity.X -= acceleration; } - if (npc.velocity.X < num474) + if (npc.velocity.X < sawArmOtherChargeTargetX) { if (npc.velocity.X < 0f) npc.velocity.X *= 0.9f; npc.velocity.X += acceleration; } - if (npc.velocity.Y > num475) + if (npc.velocity.Y > sawArmOtherChargeTargetY) { if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.9f; npc.velocity.Y -= acceleration; } - if (npc.velocity.Y < num475) + if (npc.velocity.Y < sawArmOtherChargeTargetY) { if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.9f; @@ -1756,10 +1754,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.netUpdate = true; } - vector54 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num474 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector54.X; - num475 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector54.Y; - npc.rotation = (float)Math.Atan2(num475, num474) + MathHelper.PiOver2; + sawArmOtherChargePos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + sawArmOtherChargeTargetX = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - sawArmOtherChargePos.X; + sawArmOtherChargeTargetY = Main.npc[(int)npc.ai[1]].position.Y + 230f - sawArmOtherChargePos.Y; + npc.rotation = (float)Math.Atan2(sawArmOtherChargeTargetY, sawArmOtherChargeTargetX) + MathHelper.PiOver2; return false; } diff --git a/NPCs/VanillaNPCOverrides/Bosses/TwinsAI.cs b/NPCs/VanillaNPCOverrides/Bosses/TwinsAI.cs index b7f95d1cdb..00c33bf5ac 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/TwinsAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/TwinsAI.cs @@ -21,43 +21,43 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.TargetClosest(); } bool dead2 = Main.player[npc.target].dead; - float num399 = npc.position.X + (npc.width / 2) - Main.player[npc.target].position.X - (Main.player[npc.target].width / 2); - float num400 = npc.position.Y + npc.height - 59f - Main.player[npc.target].position.Y - (Main.player[npc.target].height / 2); - float num401 = (float)Math.Atan2(num400, num399) + 1.57f; - if (num401 < 0f) + float trueMeleeRetiTargetXDist = npc.position.X + (npc.width / 2) - Main.player[npc.target].position.X - (Main.player[npc.target].width / 2); + float trueMeleeRetiTargetYDist = npc.position.Y + npc.height - 59f - Main.player[npc.target].position.Y - (Main.player[npc.target].height / 2); + float trueMeleeRetiTargetDistance = (float)Math.Atan2(trueMeleeRetiTargetYDist, trueMeleeRetiTargetXDist) + 1.57f; + if (trueMeleeRetiTargetDistance < 0f) { - num401 += MathHelper.TwoPi; + trueMeleeRetiTargetDistance += MathHelper.TwoPi; } - else if (num401 > MathHelper.TwoPi) + else if (trueMeleeRetiTargetDistance > MathHelper.TwoPi) { - num401 -= MathHelper.TwoPi; + trueMeleeRetiTargetDistance -= MathHelper.TwoPi; } - float num402 = 0.1f; - if (npc.rotation < num401) + float trueMeleeRetiReducedAccel = 0.1f; + if (npc.rotation < trueMeleeRetiTargetDistance) { - if ((double)(num401 - npc.rotation) > MathHelper.Pi) + if ((double)(trueMeleeRetiTargetDistance - npc.rotation) > MathHelper.Pi) { - npc.rotation -= num402; + npc.rotation -= trueMeleeRetiReducedAccel; } else { - npc.rotation += num402; + npc.rotation += trueMeleeRetiReducedAccel; } } - else if (npc.rotation > num401) + else if (npc.rotation > trueMeleeRetiTargetDistance) { - if ((double)(npc.rotation - num401) > MathHelper.Pi) + if ((double)(npc.rotation - trueMeleeRetiTargetDistance) > MathHelper.Pi) { - npc.rotation += num402; + npc.rotation += trueMeleeRetiReducedAccel; } else { - npc.rotation -= num402; + npc.rotation -= trueMeleeRetiReducedAccel; } } - if (npc.rotation > num401 - num402 && npc.rotation < num401 + num402) + if (npc.rotation > trueMeleeRetiTargetDistance - trueMeleeRetiReducedAccel && npc.rotation < trueMeleeRetiTargetDistance + trueMeleeRetiReducedAccel) { - npc.rotation = num401; + npc.rotation = trueMeleeRetiTargetDistance; } if (npc.rotation < 0f) { @@ -67,22 +67,22 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { npc.rotation -= MathHelper.TwoPi; } - if (npc.rotation > num401 - num402 && npc.rotation < num401 + num402) + if (npc.rotation > trueMeleeRetiTargetDistance - trueMeleeRetiReducedAccel && npc.rotation < trueMeleeRetiTargetDistance + trueMeleeRetiReducedAccel) { - npc.rotation = num401; + npc.rotation = trueMeleeRetiTargetDistance; } if (Main.rand.NextBool(5)) { - int num403 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + npc.height * 0.25f), npc.width, (int)(npc.height * 0.5f), 5, npc.velocity.X, 2f); - Main.dust[num403].velocity.X *= 0.5f; - Main.dust[num403].velocity.Y *= 0.1f; + int retinazerDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + npc.height * 0.25f), npc.width, (int)(npc.height * 0.5f), 5, npc.velocity.X, 2f); + Main.dust[retinazerDust].velocity.X *= 0.5f; + Main.dust[retinazerDust].velocity.Y *= 0.1f; } if (Main.netMode != NetmodeID.MultiplayerClient && !Main.dayTime && !Main.player[npc.target].dead && npc.timeLeft < 10) { - for (int num381 = 0; num381 < Main.maxNPCs; num381++) + for (int i = 0; i < Main.maxNPCs; i++) { - if (num381 != npc.whoAmI && Main.npc[num381].active && (Main.npc[num381].type == NPCID.Retinazer || Main.npc[num381].type == NPCID.Spazmatism) && Main.npc[num381].timeLeft - 1 > npc.timeLeft) - npc.timeLeft = Main.npc[num381].timeLeft - 1; + if (i != npc.whoAmI && Main.npc[i].active && (Main.npc[i].type == NPCID.Retinazer || Main.npc[i].type == NPCID.Spazmatism) && Main.npc[i].timeLeft - 1 > npc.timeLeft) + npc.timeLeft = Main.npc[i].timeLeft - 1; } } @@ -100,61 +100,61 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.HitSound = SoundID.NPCHit4; if (npc.ai[1] == 0f) { - float num421 = 8f; - float num422 = 0.15f; + float retinazerMaxSpeed = 8f; + float retinazerAccel = 0.15f; if (Main.expertMode) { - num421 = 9.5f; - num422 = 0.175f; + retinazerMaxSpeed = 9.5f; + retinazerAccel = 0.175f; } if (Main.getGoodWorld) { - num421 *= 1.15f; - num422 *= 1.15f; + retinazerMaxSpeed *= 1.15f; + retinazerAccel *= 1.15f; } // Reduce acceleration if target is holding a true melee weapon if (Main.player[npc.target].HoldingTrueMeleeWeapon()) { - num421 *= 0.75f; - num422 *= 0.5f; + retinazerMaxSpeed *= 0.75f; + retinazerAccel *= 0.5f; } - Vector2 vector39 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num423 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector39.X; - float num424 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 300f - vector39.Y; - float num425 = (float)Math.Sqrt(num423 * num423 + num424 * num424); - num425 = num421 / num425; - num423 *= num425; - num424 *= num425; - if (npc.velocity.X < num423) + Vector2 retinazerPosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float retinazerTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - retinazerPosition.X; + float retinazerTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 300f - retinazerPosition.Y; + float retinazerTargetDist = (float)Math.Sqrt(retinazerTargetX * retinazerTargetX + retinazerTargetY * retinazerTargetY); + retinazerTargetDist = retinazerMaxSpeed / retinazerTargetDist; + retinazerTargetX *= retinazerTargetDist; + retinazerTargetY *= retinazerTargetDist; + if (npc.velocity.X < retinazerTargetX) { - npc.velocity.X += num422; - if (npc.velocity.X < 0f && num423 > 0f) + npc.velocity.X += retinazerAccel; + if (npc.velocity.X < 0f && retinazerTargetX > 0f) { - npc.velocity.X += num422; + npc.velocity.X += retinazerAccel; } } - else if (npc.velocity.X > num423) + else if (npc.velocity.X > retinazerTargetX) { - npc.velocity.X -= num422; - if (npc.velocity.X > 0f && num423 < 0f) + npc.velocity.X -= retinazerAccel; + if (npc.velocity.X > 0f && retinazerTargetX < 0f) { - npc.velocity.X -= num422; + npc.velocity.X -= retinazerAccel; } } - if (npc.velocity.Y < num424) + if (npc.velocity.Y < retinazerTargetY) { - npc.velocity.Y += num422; - if (npc.velocity.Y < 0f && num424 > 0f) + npc.velocity.Y += retinazerAccel; + if (npc.velocity.Y < 0f && retinazerTargetY > 0f) { - npc.velocity.Y += num422; + npc.velocity.Y += retinazerAccel; } } - else if (npc.velocity.Y > num424) + else if (npc.velocity.Y > retinazerTargetY) { - npc.velocity.Y -= num422; - if (npc.velocity.Y > 0f && num424 < 0f) + npc.velocity.Y -= retinazerAccel; + if (npc.velocity.Y > 0f && retinazerTargetY < 0f) { - npc.velocity.Y -= num422; + npc.velocity.Y -= retinazerAccel; } } npc.ai[2] += 1f; @@ -166,10 +166,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.TargetClosest(); npc.netUpdate = true; } - vector39 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num423 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector39.X; - num424 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector39.Y; - npc.rotation = (float)Math.Atan2(num424, num423) - 1.57f; + retinazerPosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + retinazerTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - retinazerPosition.X; + retinazerTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - retinazerPosition.Y; + npc.rotation = (float)Math.Atan2(retinazerTargetY, retinazerTargetX) - 1.57f; if (Main.netMode == NetmodeID.MultiplayerClient) { return false; @@ -194,89 +194,88 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.localAI[1] > 180f && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { npc.localAI[1] = 0f; - float num426 = 8.5f; + float retinazerLaserSpeed = 8.5f; int attackDamage_ForProjectiles4 = Main.expertMode ? 23 : 25; - int num427 = 100; if (Main.expertMode) { - num426 = 10f; + retinazerLaserSpeed = 10f; } - num425 = (float)Math.Sqrt(num423 * num423 + num424 * num424); - num425 = num426 / num425; - num423 *= num425; - num424 *= num425; - vector39.X += num423 * 15f; - vector39.Y += num424 * 15f; - int num428 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector39.X, vector39.Y, num423, num424, num427, attackDamage_ForProjectiles4, 0f, Main.myPlayer); + retinazerTargetDist = (float)Math.Sqrt(retinazerTargetX * retinazerTargetX + retinazerTargetY * retinazerTargetY); + retinazerTargetDist = retinazerLaserSpeed / retinazerTargetDist; + retinazerTargetX *= retinazerTargetDist; + retinazerTargetY *= retinazerTargetDist; + retinazerPosition.X += retinazerTargetX * 15f; + retinazerPosition.Y += retinazerTargetY * 15f; + int retinazerLaser = Projectile.NewProjectile(npc.GetSource_FromAI(), retinazerPosition.X, retinazerPosition.Y, retinazerTargetX, retinazerTargetY, 100, attackDamage_ForProjectiles4, 0f, Main.myPlayer); } return false; } - int num429 = 1; + int retinazerFaceDirection = 1; if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + Main.player[npc.target].width) { - num429 = -1; + retinazerFaceDirection = -1; } - float num430 = 8f; - float num431 = 0.2f; + float retinazerSpeedPhase2 = 8f; + float retinazerAccelPhase2 = 0.2f; if (Main.expertMode) { - num430 = 9.5f; - num431 = 0.25f; + retinazerSpeedPhase2 = 9.5f; + retinazerAccelPhase2 = 0.25f; } if (Main.getGoodWorld) { - num430 *= 1.15f; - num431 *= 1.15f; + retinazerSpeedPhase2 *= 1.15f; + retinazerAccelPhase2 *= 1.15f; } // Reduce acceleration if target is holding a true melee weapon if (Main.player[npc.target].HoldingTrueMeleeWeapon()) { - num430 *= 0.75f; - num431 *= 0.5f; + retinazerSpeedPhase2 *= 0.75f; + retinazerAccelPhase2 *= 0.5f; } - Vector2 vector40 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num432 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (num429 * 340) - vector40.X; - float num433 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector40.Y; - float num434 = (float)Math.Sqrt(num432 * num432 + num433 * num433); - num434 = num430 / num434; - num432 *= num434; - num433 *= num434; - if (npc.velocity.X < num432) + Vector2 retinazerPhase2Pos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float retinazerPhase2TargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (retinazerFaceDirection * 340) - retinazerPhase2Pos.X; + float retinazerPhase2TargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - retinazerPhase2Pos.Y; + float retinazerPhase2TargetDist = (float)Math.Sqrt(retinazerPhase2TargetX * retinazerPhase2TargetX + retinazerPhase2TargetY * retinazerPhase2TargetY); + retinazerPhase2TargetDist = retinazerSpeedPhase2 / retinazerPhase2TargetDist; + retinazerPhase2TargetX *= retinazerPhase2TargetDist; + retinazerPhase2TargetY *= retinazerPhase2TargetDist; + if (npc.velocity.X < retinazerPhase2TargetX) { - npc.velocity.X += num431; - if (npc.velocity.X < 0f && num432 > 0f) + npc.velocity.X += retinazerAccelPhase2; + if (npc.velocity.X < 0f && retinazerPhase2TargetX > 0f) { - npc.velocity.X += num431; + npc.velocity.X += retinazerAccelPhase2; } } - else if (npc.velocity.X > num432) + else if (npc.velocity.X > retinazerPhase2TargetX) { - npc.velocity.X -= num431; - if (npc.velocity.X > 0f && num432 < 0f) + npc.velocity.X -= retinazerAccelPhase2; + if (npc.velocity.X > 0f && retinazerPhase2TargetX < 0f) { - npc.velocity.X -= num431; + npc.velocity.X -= retinazerAccelPhase2; } } - if (npc.velocity.Y < num433) + if (npc.velocity.Y < retinazerPhase2TargetY) { - npc.velocity.Y += num431; - if (npc.velocity.Y < 0f && num433 > 0f) + npc.velocity.Y += retinazerAccelPhase2; + if (npc.velocity.Y < 0f && retinazerPhase2TargetY > 0f) { - npc.velocity.Y += num431; + npc.velocity.Y += retinazerAccelPhase2; } } - else if (npc.velocity.Y > num433) + else if (npc.velocity.Y > retinazerPhase2TargetY) { - npc.velocity.Y -= num431; - if (npc.velocity.Y > 0f && num433 < 0f) + npc.velocity.Y -= retinazerAccelPhase2; + if (npc.velocity.Y > 0f && retinazerPhase2TargetY < 0f) { - npc.velocity.Y -= num431; + npc.velocity.Y -= retinazerAccelPhase2; } } - vector40 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num432 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector40.X; - num433 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector40.Y; - npc.rotation = (float)Math.Atan2(num433, num432) - 1.57f; + retinazerPhase2Pos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + retinazerPhase2TargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - retinazerPhase2Pos.X; + retinazerPhase2TargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - retinazerPhase2Pos.Y; + npc.rotation = (float)Math.Atan2(retinazerPhase2TargetY, retinazerPhase2TargetX) - 1.57f; if (Main.netMode != NetmodeID.MultiplayerClient) { npc.localAI[1] += 1f; @@ -303,16 +302,14 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.localAI[1] > 60f && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { npc.localAI[1] = 0f; - float num435 = 9f; int attackDamage_ForProjectiles5 = Main.expertMode ? 17 : 18; - int num436 = 100; - num434 = (float)Math.Sqrt(num432 * num432 + num433 * num433); - num434 = num435 / num434; - num432 *= num434; - num433 *= num434; - vector40.X += num432 * 15f; - vector40.Y += num433 * 15f; - int num437 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector40.X, vector40.Y, num432, num433, num436, attackDamage_ForProjectiles5, 0f, Main.myPlayer); + retinazerPhase2TargetDist = (float)Math.Sqrt(retinazerPhase2TargetX * retinazerPhase2TargetX + retinazerPhase2TargetY * retinazerPhase2TargetY); + retinazerPhase2TargetDist = 9f / retinazerPhase2TargetDist; + retinazerPhase2TargetX *= retinazerPhase2TargetDist; + retinazerPhase2TargetY *= retinazerPhase2TargetDist; + retinazerPhase2Pos.X += retinazerPhase2TargetX * 15f; + retinazerPhase2Pos.Y += retinazerPhase2TargetY * 15f; + int retinazerPhase2Laser = Projectile.NewProjectile(npc.GetSource_FromAI(), retinazerPhase2Pos.X, retinazerPhase2Pos.Y, retinazerPhase2TargetX, retinazerPhase2TargetY, 100, attackDamage_ForProjectiles5, 0f, Main.myPlayer); } } npc.ai[2] += 1f; @@ -369,56 +366,56 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses bool enrage = lifeRatio < 0.25f; // I'm not commenting this entire fucking thing, already did spaz, I'm not doing ret - float num376 = npc.position.X + (npc.width / 2) - Main.player[npc.target].position.X - (Main.player[npc.target].width / 2); - float num377 = npc.position.Y + npc.height - 59f - Main.player[npc.target].position.Y - (Main.player[npc.target].height / 2); + float retinazerHoverXDest = npc.position.X + (npc.width / 2) - Main.player[npc.target].position.X - (Main.player[npc.target].width / 2); + float retinazerHoverYDest = npc.position.Y + npc.height - 59f - Main.player[npc.target].position.Y - (Main.player[npc.target].height / 2); - float num378 = (float)Math.Atan2(num377, num376) + MathHelper.PiOver2; - if (num378 < 0f) - num378 += MathHelper.TwoPi; - else if (num378 > MathHelper.TwoPi) - num378 -= MathHelper.TwoPi; + float retinazerHoverRotation = (float)Math.Atan2(retinazerHoverYDest, retinazerHoverXDest) + MathHelper.PiOver2; + if (retinazerHoverRotation < 0f) + retinazerHoverRotation += MathHelper.TwoPi; + else if (retinazerHoverRotation > MathHelper.TwoPi) + retinazerHoverRotation -= MathHelper.TwoPi; - float num379 = 0.1f; - if (npc.rotation < num378) + float retinazerRotationSpeed = 0.1f; + if (npc.rotation < retinazerHoverRotation) { - if ((num378 - npc.rotation) > MathHelper.Pi) - npc.rotation -= num379; + if ((retinazerHoverRotation - npc.rotation) > MathHelper.Pi) + npc.rotation -= retinazerRotationSpeed; else - npc.rotation += num379; + npc.rotation += retinazerRotationSpeed; } - else if (npc.rotation > num378) + else if (npc.rotation > retinazerHoverRotation) { - if ((npc.rotation - num378) > MathHelper.Pi) - npc.rotation += num379; + if ((npc.rotation - retinazerHoverRotation) > MathHelper.Pi) + npc.rotation += retinazerRotationSpeed; else - npc.rotation -= num379; + npc.rotation -= retinazerRotationSpeed; } - if (npc.rotation > num378 - num379 && npc.rotation < num378 + num379) - npc.rotation = num378; + if (npc.rotation > retinazerHoverRotation - retinazerRotationSpeed && npc.rotation < retinazerHoverRotation + retinazerRotationSpeed) + npc.rotation = retinazerHoverRotation; if (npc.rotation < 0f) npc.rotation += MathHelper.TwoPi; else if (npc.rotation > MathHelper.TwoPi) npc.rotation -= MathHelper.TwoPi; - if (npc.rotation > num378 - num379 && npc.rotation < num378 + num379) - npc.rotation = num378; + if (npc.rotation > retinazerHoverRotation - retinazerRotationSpeed && npc.rotation < retinazerHoverRotation + retinazerRotationSpeed) + npc.rotation = retinazerHoverRotation; if (Main.rand.NextBool(5)) { - int num380 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + npc.height * 0.25f), npc.width, (int)(npc.height * 0.5f), 5, npc.velocity.X, 2f, 0, default, 1f); - Dust dust = Main.dust[num380]; + int retiDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + npc.height * 0.25f), npc.width, (int)(npc.height * 0.5f), 5, npc.velocity.X, 2f, 0, default, 1f); + Dust dust = Main.dust[retiDust]; dust.velocity.X *= 0.5f; dust.velocity.Y *= 0.1f; } if (Main.netMode != NetmodeID.MultiplayerClient && !Main.player[npc.target].dead && npc.timeLeft < 10) { - for (int num381 = 0; num381 < Main.maxNPCs; num381++) + for (int i = 0; i < Main.maxNPCs; i++) { - if (num381 != npc.whoAmI && Main.npc[num381].active && (Main.npc[num381].type == NPCID.Retinazer || Main.npc[num381].type == NPCID.Spazmatism) && Main.npc[num381].timeLeft - 1 > npc.timeLeft) - npc.timeLeft = Main.npc[num381].timeLeft - 1; + if (i != npc.whoAmI && Main.npc[i].active && (Main.npc[i].type == NPCID.Retinazer || Main.npc[i].type == NPCID.Spazmatism) && Main.npc[i].timeLeft - 1 > npc.timeLeft) + npc.timeLeft = Main.npc[i].timeLeft - 1; } } @@ -428,11 +425,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { NPC nPC = Main.npc[NPC.mechQueen]; Vector2 mechQueenCenter = nPC.GetMechQueenCenter(); - Vector2 vector42 = new Vector2(-150f, -250f); - vector42 *= 0.75f; - float num418 = nPC.velocity.X * 0.025f; - mechQueenSpacing = mechQueenCenter + vector42; - mechQueenSpacing = mechQueenSpacing.RotatedBy(num418, mechQueenCenter); + Vector2 eyePosition = new Vector2(-150f, -250f); + eyePosition *= 0.75f; + float mechdusaRotation = nPC.velocity.X * 0.025f; + mechQueenSpacing = mechQueenCenter + eyePosition; + mechQueenSpacing = mechQueenSpacing.RotatedBy(mechdusaRotation, mechQueenCenter); } npc.reflectsProjectiles = false; @@ -451,85 +448,84 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { if (npc.ai[1] == 0f) { - float num382 = 8.25f; - float num383 = 0.115f; - num382 += 4f * enrageScale; - num383 += 0.05f * enrageScale; + float retinazerPhase1MaxSpeed = 8.25f; + float retinazerPhase1Acceleration = 0.115f; + retinazerPhase1MaxSpeed += 4f * enrageScale; + retinazerPhase1Acceleration += 0.05f * enrageScale; if (death) { - num382 += 8f * (1f - lifeRatio); - num383 += 0.1f * (1f - lifeRatio); + retinazerPhase1MaxSpeed += 8f * (1f - lifeRatio); + retinazerPhase1Acceleration += 0.1f * (1f - lifeRatio); } if (Main.getGoodWorld) { - num382 *= 1.15f; - num383 *= 1.15f; + retinazerPhase1MaxSpeed *= 1.15f; + retinazerPhase1Acceleration *= 1.15f; } - int num384 = 1; + int retinazerFaceDirection = 1; if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + Main.player[npc.target].width) - num384 = -1; + retinazerFaceDirection = -1; - Vector2 vector40 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num385 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (num384 * 300) - vector40.X; - float num386 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 300f - vector40.Y; + Vector2 retinazerPosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float retinazerTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (retinazerFaceDirection * 300) - retinazerPosition.X; + float retinazerTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 300f - retinazerPosition.Y; if (NPC.IsMechQueenUp) { - num382 = 14f; - num385 = mechQueenSpacing.X; - num386 = mechQueenSpacing.Y; - num385 -= vector40.X; - num386 -= vector40.Y; + retinazerPhase1MaxSpeed = 14f; + retinazerTargetX = mechQueenSpacing.X; + retinazerTargetY = mechQueenSpacing.Y; + retinazerTargetX -= retinazerPosition.X; + retinazerTargetY -= retinazerPosition.Y; } - float num387 = (float)Math.Sqrt(num385 * num385 + num386 * num386); - float num388 = num387; + float retinazerTargetDist = (float)Math.Sqrt(retinazerTargetX * retinazerTargetX + retinazerTargetY * retinazerTargetY); + float retinazerTargetDistCopy = retinazerTargetDist; if (NPC.IsMechQueenUp) { - if (num387 > num382) + if (retinazerTargetDist > retinazerPhase1MaxSpeed) { - num387 = num382 / num387; - num385 *= num387; - num386 *= num387; + retinazerTargetDist = retinazerPhase1MaxSpeed / retinazerTargetDist; + retinazerTargetX *= retinazerTargetDist; + retinazerTargetY *= retinazerTargetDist; } - float num426 = 60f; - npc.velocity.X = (npc.velocity.X * (num426 - 1f) + num385) / num426; - npc.velocity.Y = (npc.velocity.Y * (num426 - 1f) + num386) / num426; + npc.velocity.X = (npc.velocity.X * 59f + retinazerTargetX) / 60f; + npc.velocity.Y = (npc.velocity.Y * 59f + retinazerTargetY) / 60f; } else { - num387 = num382 / num387; - num385 *= num387; - num386 *= num387; + retinazerTargetDist = retinazerPhase1MaxSpeed / retinazerTargetDist; + retinazerTargetX *= retinazerTargetDist; + retinazerTargetY *= retinazerTargetDist; - if (npc.velocity.X < num385) + if (npc.velocity.X < retinazerTargetX) { - npc.velocity.X += num383; - if (npc.velocity.X < 0f && num385 > 0f) - npc.velocity.X += num383; + npc.velocity.X += retinazerPhase1Acceleration; + if (npc.velocity.X < 0f && retinazerTargetX > 0f) + npc.velocity.X += retinazerPhase1Acceleration; } - else if (npc.velocity.X > num385) + else if (npc.velocity.X > retinazerTargetX) { - npc.velocity.X -= num383; - if (npc.velocity.X > 0f && num385 < 0f) - npc.velocity.X -= num383; + npc.velocity.X -= retinazerPhase1Acceleration; + if (npc.velocity.X > 0f && retinazerTargetX < 0f) + npc.velocity.X -= retinazerPhase1Acceleration; } - if (npc.velocity.Y < num386) + if (npc.velocity.Y < retinazerTargetY) { - npc.velocity.Y += num383; - if (npc.velocity.Y < 0f && num386 > 0f) - npc.velocity.Y += num383; + npc.velocity.Y += retinazerPhase1Acceleration; + if (npc.velocity.Y < 0f && retinazerTargetY > 0f) + npc.velocity.Y += retinazerPhase1Acceleration; } - else if (npc.velocity.Y > num386) + else if (npc.velocity.Y > retinazerTargetY) { - npc.velocity.Y -= num383; - if (npc.velocity.Y > 0f && num386 < 0f) - npc.velocity.Y -= num383; + npc.velocity.Y -= retinazerPhase1Acceleration; + if (npc.velocity.Y > 0f && retinazerTargetY < 0f) + npc.velocity.Y -= retinazerPhase1Acceleration; } } @@ -550,7 +546,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.netUpdate = true; } - else if (npc.position.Y + npc.height < Main.player[npc.target].position.Y && num388 < 400f) + else if (npc.position.Y + npc.height < Main.player[npc.target].position.Y && retinazerTargetDistCopy < 400f) { if (!Main.player[npc.target].dead) { @@ -562,25 +558,25 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[3] >= laserGateValue) { npc.ai[3] = 0f; - vector40 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num385 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector40.X; - num386 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector40.Y; + retinazerPosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + retinazerTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - retinazerPosition.X; + retinazerTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - retinazerPosition.Y; if (Main.netMode != NetmodeID.MultiplayerClient) { - float num389 = 10.5f; - num389 += 3f * enrageScale; + float retinazerSpeed = 10.5f; + retinazerSpeed += 3f * enrageScale; int type = ProjectileID.EyeLaser; int damage = npc.GetProjectileDamage(type); - num387 = (float)Math.Sqrt(num385 * num385 + num386 * num386); - num387 = num389 / num387; - num385 *= num387; - num386 *= num387; - vector40.X += num385 * 15f; - vector40.Y += num386 * 15f; + retinazerTargetDist = (float)Math.Sqrt(retinazerTargetX * retinazerTargetX + retinazerTargetY * retinazerTargetY); + retinazerTargetDist = retinazerSpeed / retinazerTargetDist; + retinazerTargetX *= retinazerTargetDist; + retinazerTargetY *= retinazerTargetDist; + retinazerPosition.X += retinazerTargetX * 15f; + retinazerPosition.Y += retinazerTargetY * 15f; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector40.X, vector40.Y, num385, num386, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), retinazerPosition.X, retinazerPosition.Y, retinazerTargetX, retinazerTargetY, type, damage, 0f, Main.myPlayer, 0f, 0f); } } } @@ -588,21 +584,21 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses else if (npc.ai[1] == 1f) { - npc.rotation = num378; - float num393 = 15f; - num393 += 10f * enrageScale; + npc.rotation = retinazerHoverRotation; + float retinazerChargeSpeed = 15f; + retinazerChargeSpeed += 10f * enrageScale; if (death) - num393 += 12f * (1f - lifeRatio); + retinazerChargeSpeed += 12f * (1f - lifeRatio); if (Main.getGoodWorld) - num393 += 2f; + retinazerChargeSpeed += 2f; - Vector2 vector41 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num394 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector41.X; - float num395 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector41.Y; - float num396 = (float)Math.Sqrt(num394 * num394 + num395 * num395); - num396 = num393 / num396; - npc.velocity.X = num394 * num396; - npc.velocity.Y = num395 * num396; + Vector2 retinazerChargePos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float retinazerChargeTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - retinazerChargePos.X; + float retinazerChargeTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - retinazerChargePos.Y; + float retinazerChargeTargetDist = (float)Math.Sqrt(retinazerChargeTargetX * retinazerChargeTargetX + retinazerChargeTargetY * retinazerChargeTargetY); + retinazerChargeTargetDist = retinazerChargeSpeed / retinazerChargeTargetDist; + npc.velocity.X = retinazerChargeTargetX * retinazerChargeTargetDist; + npc.velocity.Y = retinazerChargeTargetY * retinazerChargeTargetDist; npc.ai[1] = 2f; } else if (npc.ai[1] == 2f) @@ -628,7 +624,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.ai[3] += 1f; npc.ai[2] = 0f; npc.TargetClosest(); - npc.rotation = num378; + npc.rotation = retinazerHoverRotation; if (npc.ai[3] >= 3f) { npc.ai[1] = 0f; @@ -683,7 +679,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.netMode != NetmodeID.Server) { - for (int num397 = 0; num397 < 2; num397++) + for (int i = 0; i < 2; i++) { Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 143, 1f); Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 7, 1f); @@ -691,7 +687,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } } - for (int num398 = 0; num398 < 20; num398++) + for (int j = 0; j < 20; j++) { Dust.NewDust(npc.position, npc.width, npc.height, 5, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); } @@ -731,80 +727,80 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[1] == 0f) { - float num399 = 9.5f + (death ? 3f * (0.7f - lifeRatio) : 0f); - float num400 = 0.175f + (death ? 0.05f * (0.7f - lifeRatio) : 0f); - num399 += 4.5f * enrageScale; - num400 += 0.075f * enrageScale; + float retinazerPhase2MaxSpeed = 9.5f + (death ? 3f * (0.7f - lifeRatio) : 0f); + float retinazerPhase2Accel = 0.175f + (death ? 0.05f * (0.7f - lifeRatio) : 0f); + retinazerPhase2MaxSpeed += 4.5f * enrageScale; + retinazerPhase2Accel += 0.075f * enrageScale; if (Main.getGoodWorld) { - num399 *= 1.15f; - num400 *= 1.15f; + retinazerPhase2MaxSpeed *= 1.15f; + retinazerPhase2Accel *= 1.15f; } // Reduce acceleration if target is holding a true melee weapon if (Main.player[npc.target].HoldingTrueMeleeWeapon()) { - num399 *= 0.75f; - num400 *= 0.5f; + retinazerPhase2MaxSpeed *= 0.75f; + retinazerPhase2Accel *= 0.5f; } - Vector2 vector42 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num401 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector42.X; - float num402 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 300f - vector42.Y; + Vector2 eyePosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float retinazerPhase2TargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - eyePosition.X; + float retinazerPhase2TargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 300f - eyePosition.Y; if (NPC.IsMechQueenUp) { - num399 = 14f; - num401 = mechQueenSpacing.X; - num402 = mechQueenSpacing.Y; - num401 -= vector42.X; - num402 -= vector42.Y; + retinazerPhase2MaxSpeed = 14f; + retinazerPhase2TargetX = mechQueenSpacing.X; + retinazerPhase2TargetY = mechQueenSpacing.Y; + retinazerPhase2TargetX -= eyePosition.X; + retinazerPhase2TargetY -= eyePosition.Y; } - float num403 = (float)Math.Sqrt(num401 * num401 + num402 * num402); + float retinazerPhase2TargetDist = (float)Math.Sqrt(retinazerPhase2TargetX * retinazerPhase2TargetX + retinazerPhase2TargetY * retinazerPhase2TargetY); if (NPC.IsMechQueenUp) { - if (num403 > num399) + if (retinazerPhase2TargetDist > retinazerPhase2MaxSpeed) { - num403 = num399 / num403; - num401 *= num403; - num402 *= num403; + retinazerPhase2TargetDist = retinazerPhase2MaxSpeed / retinazerPhase2TargetDist; + retinazerPhase2TargetX *= retinazerPhase2TargetDist; + retinazerPhase2TargetY *= retinazerPhase2TargetDist; } - npc.velocity.X = (npc.velocity.X * 4f + num401) / 5f; - npc.velocity.Y = (npc.velocity.Y * 4f + num402) / 5f; + npc.velocity.X = (npc.velocity.X * 4f + retinazerPhase2TargetX) / 5f; + npc.velocity.Y = (npc.velocity.Y * 4f + retinazerPhase2TargetY) / 5f; } else { - num403 = num399 / num403; - num401 *= num403; - num402 *= num403; + retinazerPhase2TargetDist = retinazerPhase2MaxSpeed / retinazerPhase2TargetDist; + retinazerPhase2TargetX *= retinazerPhase2TargetDist; + retinazerPhase2TargetY *= retinazerPhase2TargetDist; - if (npc.velocity.X < num401) + if (npc.velocity.X < retinazerPhase2TargetX) { - npc.velocity.X += num400; - if (npc.velocity.X < 0f && num401 > 0f) - npc.velocity.X += num400; + npc.velocity.X += retinazerPhase2Accel; + if (npc.velocity.X < 0f && retinazerPhase2TargetX > 0f) + npc.velocity.X += retinazerPhase2Accel; } - else if (npc.velocity.X > num401) + else if (npc.velocity.X > retinazerPhase2TargetX) { - npc.velocity.X -= num400; - if (npc.velocity.X > 0f && num401 < 0f) - npc.velocity.X -= num400; + npc.velocity.X -= retinazerPhase2Accel; + if (npc.velocity.X > 0f && retinazerPhase2TargetX < 0f) + npc.velocity.X -= retinazerPhase2Accel; } - if (npc.velocity.Y < num402) + if (npc.velocity.Y < retinazerPhase2TargetY) { - npc.velocity.Y += num400; - if (npc.velocity.Y < 0f && num402 > 0f) - npc.velocity.Y += num400; + npc.velocity.Y += retinazerPhase2Accel; + if (npc.velocity.Y < 0f && retinazerPhase2TargetY > 0f) + npc.velocity.Y += retinazerPhase2Accel; } - else if (npc.velocity.Y > num402) + else if (npc.velocity.Y > retinazerPhase2TargetY) { - npc.velocity.Y -= num400; - if (npc.velocity.Y > 0f && num402 < 0f) - npc.velocity.Y -= num400; + npc.velocity.Y -= retinazerPhase2Accel; + if (npc.velocity.Y > 0f && retinazerPhase2TargetY < 0f) + npc.velocity.Y -= retinazerPhase2Accel; } } @@ -819,10 +815,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.netUpdate = true; } - vector42 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num401 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector42.X; - num402 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector42.Y; - npc.rotation = (float)Math.Atan2(num402, num401) - MathHelper.PiOver2; + eyePosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + retinazerPhase2TargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - eyePosition.X; + retinazerPhase2TargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - eyePosition.Y; + npc.rotation = (float)Math.Atan2(retinazerPhase2TargetY, retinazerPhase2TargetX) - MathHelper.PiOver2; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -833,23 +829,23 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (canHit || !spazAlive || enrage) { npc.localAI[1] = 0f; - float num404 = 10f; - num404 += enrageScale; + float retinazerPhase2LaserSpeed = 10f; + retinazerPhase2LaserSpeed += enrageScale; int type = ProjectileID.DeathLaser; int damage = npc.GetProjectileDamage(type); - num403 = (float)Math.Sqrt(num401 * num401 + num402 * num402); - num403 = num404 / num403; - num401 *= num403; - num402 *= num403; - vector42.X += num401 * 15f; - vector42.Y += num402 * 15f; + retinazerPhase2TargetDist = (float)Math.Sqrt(retinazerPhase2TargetX * retinazerPhase2TargetX + retinazerPhase2TargetY * retinazerPhase2TargetY); + retinazerPhase2TargetDist = retinazerPhase2LaserSpeed / retinazerPhase2TargetDist; + retinazerPhase2TargetX *= retinazerPhase2TargetDist; + retinazerPhase2TargetY *= retinazerPhase2TargetDist; + eyePosition.X += retinazerPhase2TargetX * 15f; + eyePosition.Y += retinazerPhase2TargetY * 15f; if (canHit) - Projectile.NewProjectile(npc.GetSource_FromAI(), vector42.X, vector42.Y, num401, num402, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), eyePosition.X, eyePosition.Y, retinazerPhase2TargetX, retinazerPhase2TargetY, type, damage, 0f, Main.myPlayer, 0f, 0f); else { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), vector42.X, vector42.Y, num401, num402, type, damage, 0f, Main.myPlayer, 0f, 0f); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), eyePosition.X, eyePosition.Y, retinazerPhase2TargetX, retinazerPhase2TargetY, type, damage, 0f, Main.myPlayer, 0f, 0f); Main.projectile[proj].tileCollide = false; Main.projectile[proj].timeLeft = 300; } @@ -861,65 +857,65 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { if (npc.ai[1] == 1f) { - int num408 = 1; + int retinazerPhase2FaceDirection = 1; if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + Main.player[npc.target].width) - num408 = -1; + retinazerPhase2FaceDirection = -1; - float num409 = 9.5f + (death ? 3f * (0.7f - lifeRatio) : 0f); - float num410 = 0.25f + (death ? 0.075f * (0.7f - lifeRatio) : 0f); - num409 += 4.5f * enrageScale; - num410 += 0.15f * enrageScale; + float retinazerPhase2RapidFireMaxSpeed = 9.5f + (death ? 3f * (0.7f - lifeRatio) : 0f); + float retinazerPhase2RapidFireAccel = 0.25f + (death ? 0.075f * (0.7f - lifeRatio) : 0f); + retinazerPhase2RapidFireMaxSpeed += 4.5f * enrageScale; + retinazerPhase2RapidFireAccel += 0.15f * enrageScale; if (Main.getGoodWorld) { - num409 *= 1.15f; - num410 *= 1.15f; + retinazerPhase2RapidFireMaxSpeed *= 1.15f; + retinazerPhase2RapidFireAccel *= 1.15f; } // Reduce acceleration if target is holding a true melee weapon if (Main.player[npc.target].HoldingTrueMeleeWeapon()) { - num409 *= 0.75f; - num410 *= 0.5f; + retinazerPhase2RapidFireMaxSpeed *= 0.75f; + retinazerPhase2RapidFireAccel *= 0.5f; } - Vector2 vector43 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num411 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (num408 * 340) - vector43.X; - float num412 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector43.Y; - float num413 = (float)Math.Sqrt(num411 * num411 + num412 * num412); - num413 = num409 / num413; - num411 *= num413; - num412 *= num413; + Vector2 retinazerPhase2RapidFirePos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float retinazerPhase2RapidFireTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (retinazerPhase2FaceDirection * 340) - retinazerPhase2RapidFirePos.X; + float retinazerPhase2RapidFireTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - retinazerPhase2RapidFirePos.Y; + float retinazerPhase2RapidFireTargetDist = (float)Math.Sqrt(retinazerPhase2RapidFireTargetX * retinazerPhase2RapidFireTargetX + retinazerPhase2RapidFireTargetY * retinazerPhase2RapidFireTargetY); + retinazerPhase2RapidFireTargetDist = retinazerPhase2RapidFireMaxSpeed / retinazerPhase2RapidFireTargetDist; + retinazerPhase2RapidFireTargetX *= retinazerPhase2RapidFireTargetDist; + retinazerPhase2RapidFireTargetY *= retinazerPhase2RapidFireTargetDist; - if (npc.velocity.X < num411) + if (npc.velocity.X < retinazerPhase2RapidFireTargetX) { - npc.velocity.X += num410; - if (npc.velocity.X < 0f && num411 > 0f) - npc.velocity.X += num410; + npc.velocity.X += retinazerPhase2RapidFireAccel; + if (npc.velocity.X < 0f && retinazerPhase2RapidFireTargetX > 0f) + npc.velocity.X += retinazerPhase2RapidFireAccel; } - else if (npc.velocity.X > num411) + else if (npc.velocity.X > retinazerPhase2RapidFireTargetX) { - npc.velocity.X -= num410; - if (npc.velocity.X > 0f && num411 < 0f) - npc.velocity.X -= num410; + npc.velocity.X -= retinazerPhase2RapidFireAccel; + if (npc.velocity.X > 0f && retinazerPhase2RapidFireTargetX < 0f) + npc.velocity.X -= retinazerPhase2RapidFireAccel; } - if (npc.velocity.Y < num412) + if (npc.velocity.Y < retinazerPhase2RapidFireTargetY) { - npc.velocity.Y += num410; - if (npc.velocity.Y < 0f && num412 > 0f) - npc.velocity.Y += num410; + npc.velocity.Y += retinazerPhase2RapidFireAccel; + if (npc.velocity.Y < 0f && retinazerPhase2RapidFireTargetY > 0f) + npc.velocity.Y += retinazerPhase2RapidFireAccel; } - else if (npc.velocity.Y > num412) + else if (npc.velocity.Y > retinazerPhase2RapidFireTargetY) { - npc.velocity.Y -= num410; - if (npc.velocity.Y > 0f && num412 < 0f) - npc.velocity.Y -= num410; + npc.velocity.Y -= retinazerPhase2RapidFireAccel; + if (npc.velocity.Y > 0f && retinazerPhase2RapidFireTargetY < 0f) + npc.velocity.Y -= retinazerPhase2RapidFireAccel; } - vector43 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num411 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector43.X; - num412 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector43.Y; - npc.rotation = (float)Math.Atan2(num412, num411) - MathHelper.PiOver2; + retinazerPhase2RapidFirePos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + retinazerPhase2RapidFireTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - retinazerPhase2RapidFirePos.X; + retinazerPhase2RapidFireTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - retinazerPhase2RapidFirePos.Y; + npc.rotation = (float)Math.Atan2(retinazerPhase2RapidFireTargetY, retinazerPhase2RapidFireTargetX) - MathHelper.PiOver2; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -930,22 +926,21 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (canHit || !spazAlive || enrage) { npc.localAI[1] = 0f; - float num414 = 9f; int type = ProjectileID.DeathLaser; int damage = (int)Math.Round(npc.GetProjectileDamage(type) * 0.75); - num413 = (float)Math.Sqrt(num411 * num411 + num412 * num412); - num413 = num414 / num413; - num411 *= num413; - num412 *= num413; - vector43.X += num411 * 15f; - vector43.Y += num412 * 15f; + retinazerPhase2RapidFireTargetDist = (float)Math.Sqrt(retinazerPhase2RapidFireTargetX * retinazerPhase2RapidFireTargetX + retinazerPhase2RapidFireTargetY * retinazerPhase2RapidFireTargetY); + retinazerPhase2RapidFireTargetDist = 9f / retinazerPhase2RapidFireTargetDist; + retinazerPhase2RapidFireTargetX *= retinazerPhase2RapidFireTargetDist; + retinazerPhase2RapidFireTargetY *= retinazerPhase2RapidFireTargetDist; + retinazerPhase2RapidFirePos.X += retinazerPhase2RapidFireTargetX * 15f; + retinazerPhase2RapidFirePos.Y += retinazerPhase2RapidFireTargetY * 15f; if (canHit) - Projectile.NewProjectile(npc.GetSource_FromAI(), vector43.X, vector43.Y, num411, num412, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), retinazerPhase2RapidFirePos.X, retinazerPhase2RapidFirePos.Y, retinazerPhase2RapidFireTargetX, retinazerPhase2RapidFireTargetY, type, damage, 0f, Main.myPlayer, 0f, 0f); else { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), vector43.X, vector43.Y, num411, num412, type, damage, 0f, Main.myPlayer, 0f, 0f); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), retinazerPhase2RapidFirePos.X, retinazerPhase2RapidFirePos.Y, retinazerPhase2RapidFireTargetX, retinazerPhase2RapidFireTargetY, type, damage, 0f, Main.myPlayer, 0f, 0f); Main.projectile[proj].tileCollide = false; Main.projectile[proj].timeLeft = 300; } @@ -968,23 +963,23 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses else if (npc.ai[1] == 2f) { // Set rotation and velocity - npc.rotation = num378; - float num450 = 22f + (death ? 8f * (0.7f - lifeRatio) : 0f); - num450 += 10f * enrageScale; + npc.rotation = retinazerHoverRotation; + float retinazerPhase3ChargeSpeed = 22f + (death ? 8f * (0.7f - lifeRatio) : 0f); + retinazerPhase3ChargeSpeed += 10f * enrageScale; if (!spazAlive) - num450 += 2f; + retinazerPhase3ChargeSpeed += 2f; if (Main.getGoodWorld) - num450 += 2f; + retinazerPhase3ChargeSpeed += 2f; - Vector2 vector47 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num451 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector47.X; - float num452 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector47.Y; - float num453 = (float)Math.Sqrt(num451 * num451 + num452 * num452); - num453 = num450 / num453; - npc.velocity.X = num451 * num453; - npc.velocity.Y = num452 * num453; + Vector2 retinazerPhase3ChargePos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float retinazerPhase3ChargeTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - retinazerPhase3ChargePos.X; + float retinazerPhase3ChargeTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - retinazerPhase3ChargePos.Y; + float retinazerPhase3ChargeTargetDist = (float)Math.Sqrt(retinazerPhase3ChargeTargetX * retinazerPhase3ChargeTargetX + retinazerPhase3ChargeTargetY * retinazerPhase3ChargeTargetY); + retinazerPhase3ChargeTargetDist = retinazerPhase3ChargeSpeed / retinazerPhase3ChargeTargetDist; + npc.velocity.X = retinazerPhase3ChargeTargetX * retinazerPhase3ChargeTargetDist; + npc.velocity.Y = retinazerPhase3ChargeTargetY * retinazerPhase3ChargeTargetDist; npc.ai[1] = 3f; } @@ -1018,30 +1013,28 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[2] % fireRate == 0f) { - Vector2 vector34 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num349 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector34.X; - float num350 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector34.Y; - float num351 = (float)Math.Sqrt(num349 * num349 + num350 * num350); + Vector2 retinazerPhase3ChargeLaserPos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float retinazerPhase3ChargeLaserTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - retinazerPhase3ChargeLaserPos.X; + float retinazerPhase3ChargeLaserTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - retinazerPhase3ChargeLaserPos.Y; + float retinazerPhase3ChargeLaserTargetDist = (float)Math.Sqrt(retinazerPhase3ChargeLaserTargetX * retinazerPhase3ChargeLaserTargetX + retinazerPhase3ChargeLaserTargetY * retinazerPhase3ChargeLaserTargetY); if (Main.netMode != NetmodeID.MultiplayerClient) { SoundEngine.PlaySound(SoundID.Item33, npc.position); - - float num353 = 6f; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - vector34 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num349 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector34.X; - num350 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector34.Y; - num351 = (float)Math.Sqrt(num349 * num349 + num350 * num350); - num351 = num353 / num351; - num349 *= num351; - num350 *= num351; - vector34.X += num349; - vector34.Y += num350; + retinazerPhase3ChargeLaserPos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + retinazerPhase3ChargeLaserTargetX = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - retinazerPhase3ChargeLaserPos.X; + retinazerPhase3ChargeLaserTargetY = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - retinazerPhase3ChargeLaserPos.Y; + retinazerPhase3ChargeLaserTargetDist = (float)Math.Sqrt(retinazerPhase3ChargeLaserTargetX * retinazerPhase3ChargeLaserTargetX + retinazerPhase3ChargeLaserTargetY * retinazerPhase3ChargeLaserTargetY); + retinazerPhase3ChargeLaserTargetDist = 6f / retinazerPhase3ChargeLaserTargetDist; + retinazerPhase3ChargeLaserTargetX *= retinazerPhase3ChargeLaserTargetDist; + retinazerPhase3ChargeLaserTargetY *= retinazerPhase3ChargeLaserTargetDist; + retinazerPhase3ChargeLaserPos.X += retinazerPhase3ChargeLaserTargetX; + retinazerPhase3ChargeLaserPos.Y += retinazerPhase3ChargeLaserTargetY; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector34.X, vector34.Y, num349, num350, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), retinazerPhase3ChargeLaserPos.X, retinazerPhase3ChargeLaserPos.Y, retinazerPhase3ChargeLaserTargetX, retinazerPhase3ChargeLaserTargetY, type, damage, 0f, Main.myPlayer, 0f, 0f); } } } @@ -1055,7 +1048,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.ai[2] = 0f; npc.ai[3] += 1f; npc.TargetClosest(); - npc.rotation = num378; + npc.rotation = retinazerHoverRotation; float maxChargeAmt = spazAlive ? 2f : 4f; if (npc.ai[3] >= maxChargeAmt) { @@ -1070,58 +1063,58 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Get in position for charge else if (npc.ai[1] == 4f) { - int num62 = spazAlive ? 600 : 500; - float num63 = 12f + (death ? 4f * (0.7f - lifeRatio) : 0f); - float num64 = 0.3f + (death ? 0.1f * (0.7f - lifeRatio) : 0f); + int chargeLineUpDist = spazAlive ? 600 : 500; + float chargeSpeed = 12f + (death ? 4f * (0.7f - lifeRatio) : 0f); + float chargeAccel = 0.3f + (death ? 0.1f * (0.7f - lifeRatio) : 0f); if (spazAlive) { - num63 *= 0.75f; - num64 *= 0.75f; + chargeSpeed *= 0.75f; + chargeAccel *= 0.75f; } if (Main.getGoodWorld) { - num63 *= 1.15f; - num64 *= 1.15f; + chargeSpeed *= 1.15f; + chargeAccel *= 1.15f; } - int num408 = 1; + int retinazerPhase2FaceDirection = 1; if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + Main.player[npc.target].width) - num408 = -1; + retinazerPhase2FaceDirection = -1; - Vector2 vector11 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num65 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (num62 * num408) - vector11.X; - float num66 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector11.Y; - float num67 = (float)Math.Sqrt(num65 * num65 + num66 * num66); + Vector2 spazmatismRetDeadChargePos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float chargeTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (chargeLineUpDist * retinazerPhase2FaceDirection) - spazmatismRetDeadChargePos.X; + float chargeTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - spazmatismRetDeadChargePos.Y; + float chargeTargetDist = (float)Math.Sqrt(chargeTargetX * chargeTargetX + chargeTargetY * chargeTargetY); - num67 = num63 / num67; - num65 *= num67; - num66 *= num67; + chargeTargetDist = chargeSpeed / chargeTargetDist; + chargeTargetX *= chargeTargetDist; + chargeTargetY *= chargeTargetDist; - if (npc.velocity.X < num65) + if (npc.velocity.X < chargeTargetX) { - npc.velocity.X += num64; - if (npc.velocity.X < 0f && num65 > 0f) - npc.velocity.X += num64; + npc.velocity.X += chargeAccel; + if (npc.velocity.X < 0f && chargeTargetX > 0f) + npc.velocity.X += chargeAccel; } - else if (npc.velocity.X > num65) + else if (npc.velocity.X > chargeTargetX) { - npc.velocity.X -= num64; - if (npc.velocity.X > 0f && num65 < 0f) - npc.velocity.X -= num64; + npc.velocity.X -= chargeAccel; + if (npc.velocity.X > 0f && chargeTargetX < 0f) + npc.velocity.X -= chargeAccel; } - if (npc.velocity.Y < num66) + if (npc.velocity.Y < chargeTargetY) { - npc.velocity.Y += num64; - if (npc.velocity.Y < 0f && num66 > 0f) - npc.velocity.Y += num64; + npc.velocity.Y += chargeAccel; + if (npc.velocity.Y < 0f && chargeTargetY > 0f) + npc.velocity.Y += chargeAccel; } - else if (npc.velocity.Y > num66) + else if (npc.velocity.Y > chargeTargetY) { - npc.velocity.Y -= num64; - if (npc.velocity.Y > 0f && num66 < 0f) - npc.velocity.Y -= num64; + npc.velocity.Y -= chargeAccel; + if (npc.velocity.Y > 0f && chargeTargetY < 0f) + npc.velocity.Y -= chargeAccel; } // Take 1.25 or 1 second to get in position, then charge @@ -1195,47 +1188,47 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses rotationVector = Vector2.Normalize(npcCenter - lookAt) * chargeVelocity; } - float num420 = (float)Math.Atan2(rotationVector.Y, rotationVector.X) + MathHelper.PiOver2; - if (num420 < 0f) - num420 += MathHelper.TwoPi; - else if (num420 > MathHelper.TwoPi) - num420 -= MathHelper.TwoPi; + float spazmatismRotation = (float)Math.Atan2(rotationVector.Y, rotationVector.X) + MathHelper.PiOver2; + if (spazmatismRotation < 0f) + spazmatismRotation += MathHelper.TwoPi; + else if (spazmatismRotation > MathHelper.TwoPi) + spazmatismRotation -= MathHelper.TwoPi; - float num421 = 0.15f; + float spazmatismRotateSpeed = 0.15f; if (NPC.IsMechQueenUp && npc.ai[0] == 3f && npc.ai[1] == 0f) - num421 *= 0.25f; + spazmatismRotateSpeed *= 0.25f; - if (npc.rotation < num420) + if (npc.rotation < spazmatismRotation) { - if ((num420 - npc.rotation) > MathHelper.Pi) - npc.rotation -= num421; + if ((spazmatismRotation - npc.rotation) > MathHelper.Pi) + npc.rotation -= spazmatismRotateSpeed; else - npc.rotation += num421; + npc.rotation += spazmatismRotateSpeed; } - else if (npc.rotation > num420) + else if (npc.rotation > spazmatismRotation) { - if ((npc.rotation - num420) > MathHelper.Pi) - npc.rotation += num421; + if ((npc.rotation - spazmatismRotation) > MathHelper.Pi) + npc.rotation += spazmatismRotateSpeed; else - npc.rotation -= num421; + npc.rotation -= spazmatismRotateSpeed; } - if (npc.rotation > num420 - num421 && npc.rotation < num420 + num421) - npc.rotation = num420; + if (npc.rotation > spazmatismRotation - spazmatismRotateSpeed && npc.rotation < spazmatismRotation + spazmatismRotateSpeed) + npc.rotation = spazmatismRotation; if (npc.rotation < 0f) npc.rotation += MathHelper.TwoPi; else if (npc.rotation > MathHelper.TwoPi) npc.rotation -= MathHelper.TwoPi; - if (npc.rotation > num420 - num421 && npc.rotation < num420 + num421) - npc.rotation = num420; + if (npc.rotation > spazmatismRotation - spazmatismRotateSpeed && npc.rotation < spazmatismRotation + spazmatismRotateSpeed) + npc.rotation = spazmatismRotation; // Dust if (Main.rand.NextBool(5)) { - int num422 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + npc.height * 0.25f), npc.width, (int)(npc.height * 0.5f), 5, npc.velocity.X, 2f, 0, default, 1f); - Dust dust = Main.dust[num422]; + int spazDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + npc.height * 0.25f), npc.width, (int)(npc.height * 0.5f), 5, npc.velocity.X, 2f, 0, default, 1f); + Dust dust = Main.dust[spazDust]; dust.velocity.X *= 0.5f; dust.velocity.Y *= 0.1f; } @@ -1243,10 +1236,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Despawn Twins at the same time if (Main.netMode != NetmodeID.MultiplayerClient && !Main.player[npc.target].dead && npc.timeLeft < 10) { - for (int num423 = 0; num423 < Main.maxNPCs; num423++) + for (int i = 0; i < Main.maxNPCs; i++) { - if (num423 != npc.whoAmI && Main.npc[num423].active && (Main.npc[num423].type == NPCID.Retinazer || Main.npc[num423].type == NPCID.Spazmatism) && Main.npc[num423].timeLeft - 1 > npc.timeLeft) - npc.timeLeft = Main.npc[num423].timeLeft - 1; + if (i != npc.whoAmI && Main.npc[i].active && (Main.npc[i].type == NPCID.Retinazer || Main.npc[i].type == NPCID.Spazmatism) && Main.npc[i].timeLeft - 1 > npc.timeLeft) + npc.timeLeft = Main.npc[i].timeLeft - 1; } } @@ -1256,11 +1249,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { NPC nPC2 = Main.npc[NPC.mechQueen]; Vector2 mechQueenCenter2 = nPC2.GetMechQueenCenter(); - Vector2 vector48 = new Vector2(150f, -250f); - vector48 *= 0.75f; - float num462 = nPC2.velocity.X * 0.025f; - mechQueenSpacing = mechQueenCenter2 + vector48; - mechQueenSpacing = mechQueenSpacing.RotatedBy(num462, mechQueenCenter2); + Vector2 mechdusaSpacingVector = new Vector2(150f, -250f); + mechdusaSpacingVector *= 0.75f; + float mechdusaSpacingVel = nPC2.velocity.X * 0.025f; + mechQueenSpacing = mechQueenCenter2 + mechdusaSpacingVector; + mechQueenSpacing = mechQueenSpacing.RotatedBy(mechdusaSpacingVel, mechQueenCenter2); } npc.reflectsProjectiles = false; @@ -1283,82 +1276,82 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[1] == 0f) { // Velocity - float num424 = 12f; - float num425 = 0.4f; - num424 += 6f * enrageScale; - num425 += 0.2f * enrageScale; + float spazmatismFireballMaxSpeed = 12f; + float spazmatismFireballAccel = 0.4f; + spazmatismFireballMaxSpeed += 6f * enrageScale; + spazmatismFireballAccel += 0.2f * enrageScale; if (death) { - num424 += 9f * (1f - lifeRatio); - num425 += 0.3f * (1f - lifeRatio); + spazmatismFireballMaxSpeed += 9f * (1f - lifeRatio); + spazmatismFireballAccel += 0.3f * (1f - lifeRatio); } if (Main.getGoodWorld) { - num424 *= 1.15f; - num425 *= 1.15f; + spazmatismFireballMaxSpeed *= 1.15f; + spazmatismFireballAccel *= 1.15f; } - int num426 = 1; + int spazmatismFireballFaceDirection = 1; if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + Main.player[npc.target].width) - num426 = -1; + spazmatismFireballFaceDirection = -1; - Vector2 vector44 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num427 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (num426 * 400) - vector44.X; - float num428 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector44.Y; + Vector2 spazmatismFireballPos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float spazmatismFireballTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (spazmatismFireballFaceDirection * 400) - spazmatismFireballPos.X; + float spazmatismFireballTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - spazmatismFireballPos.Y; if (NPC.IsMechQueenUp) { - num424 = 14f; - num427 = mechQueenSpacing.X; - num428 = mechQueenSpacing.Y; - num427 -= vector44.X; - num428 -= vector44.Y; + spazmatismFireballMaxSpeed = 14f; + spazmatismFireballTargetX = mechQueenSpacing.X; + spazmatismFireballTargetY = mechQueenSpacing.Y; + spazmatismFireballTargetX -= spazmatismFireballPos.X; + spazmatismFireballTargetY -= spazmatismFireballPos.Y; } - float num429 = (float)Math.Sqrt(num427 * num427 + num428 * num428); + float spazmatismFireballTargetDist = (float)Math.Sqrt(spazmatismFireballTargetX * spazmatismFireballTargetX + spazmatismFireballTargetY * spazmatismFireballTargetY); if (NPC.IsMechQueenUp) { - if (num429 > num424) + if (spazmatismFireballTargetDist > spazmatismFireballMaxSpeed) { - num429 = num424 / num429; - num427 *= num429; - num428 *= num429; + spazmatismFireballTargetDist = spazmatismFireballMaxSpeed / spazmatismFireballTargetDist; + spazmatismFireballTargetX *= spazmatismFireballTargetDist; + spazmatismFireballTargetY *= spazmatismFireballTargetDist; } - npc.velocity.X = (npc.velocity.X * 4f + num427) / 5f; - npc.velocity.Y = (npc.velocity.Y * 4f + num428) / 5f; + npc.velocity.X = (npc.velocity.X * 4f + spazmatismFireballTargetX) / 5f; + npc.velocity.Y = (npc.velocity.Y * 4f + spazmatismFireballTargetY) / 5f; } else { - num429 = num424 / num429; - num427 *= num429; - num428 *= num429; + spazmatismFireballTargetDist = spazmatismFireballMaxSpeed / spazmatismFireballTargetDist; + spazmatismFireballTargetX *= spazmatismFireballTargetDist; + spazmatismFireballTargetY *= spazmatismFireballTargetDist; - if (npc.velocity.X < num427) + if (npc.velocity.X < spazmatismFireballTargetX) { - npc.velocity.X += num425; - if (npc.velocity.X < 0f && num427 > 0f) - npc.velocity.X += num425; + npc.velocity.X += spazmatismFireballAccel; + if (npc.velocity.X < 0f && spazmatismFireballTargetX > 0f) + npc.velocity.X += spazmatismFireballAccel; } - else if (npc.velocity.X > num427) + else if (npc.velocity.X > spazmatismFireballTargetX) { - npc.velocity.X -= num425; - if (npc.velocity.X > 0f && num427 < 0f) - npc.velocity.X -= num425; + npc.velocity.X -= spazmatismFireballAccel; + if (npc.velocity.X > 0f && spazmatismFireballTargetX < 0f) + npc.velocity.X -= spazmatismFireballAccel; } - if (npc.velocity.Y < num428) + if (npc.velocity.Y < spazmatismFireballTargetY) { - npc.velocity.Y += num425; - if (npc.velocity.Y < 0f && num428 > 0f) - npc.velocity.Y += num425; + npc.velocity.Y += spazmatismFireballAccel; + if (npc.velocity.Y < 0f && spazmatismFireballTargetY > 0f) + npc.velocity.Y += spazmatismFireballAccel; } - else if (npc.velocity.Y > num428) + else if (npc.velocity.Y > spazmatismFireballTargetY) { - npc.velocity.Y -= num425; - if (npc.velocity.Y > 0f && num428 < 0f) - npc.velocity.Y -= num425; + npc.velocity.Y -= spazmatismFireballAccel; + if (npc.velocity.Y > 0f && spazmatismFireballTargetY < 0f) + npc.velocity.Y -= spazmatismFireballAccel; } } @@ -1387,26 +1380,26 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[3] >= 30f) { npc.ai[3] = 0f; - vector44 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num427 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector44.X; - num428 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector44.Y; + spazmatismFireballPos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + spazmatismFireballTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - spazmatismFireballPos.X; + spazmatismFireballTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - spazmatismFireballPos.Y; if (Main.netMode != NetmodeID.MultiplayerClient) { - float num430 = 15f; - num430 += 3f * enrageScale; + float cursedFireballSpeed = 15f; + cursedFireballSpeed += 3f * enrageScale; int type = ProjectileID.CursedFlameHostile; int damage = npc.GetProjectileDamage(type); - num429 = (float)Math.Sqrt(num427 * num427 + num428 * num428); - num429 = num430 / num429; - num427 *= num429; - num428 *= num429; - num427 += Main.rand.Next(-10, 11) * 0.05f; - num428 += Main.rand.Next(-10, 11) * 0.05f; - vector44.X += num427 * 4f; - vector44.Y += num428 * 4f; + spazmatismFireballTargetDist = (float)Math.Sqrt(spazmatismFireballTargetX * spazmatismFireballTargetX + spazmatismFireballTargetY * spazmatismFireballTargetY); + spazmatismFireballTargetDist = cursedFireballSpeed / spazmatismFireballTargetDist; + spazmatismFireballTargetX *= spazmatismFireballTargetDist; + spazmatismFireballTargetY *= spazmatismFireballTargetDist; + spazmatismFireballTargetX += Main.rand.Next(-10, 11) * 0.05f; + spazmatismFireballTargetY += Main.rand.Next(-10, 11) * 0.05f; + spazmatismFireballPos.X += spazmatismFireballTargetX * 4f; + spazmatismFireballPos.Y += spazmatismFireballTargetY * 4f; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector44.X, vector44.Y, num427, num428, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), spazmatismFireballPos.X, spazmatismFireballPos.Y, spazmatismFireballTargetX, spazmatismFireballTargetY, type, damage, 0f, Main.myPlayer, 0f, 0f); } } } @@ -1416,21 +1409,21 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses else if (npc.ai[1] == 1f) { // Rotation and velocity - npc.rotation = num420; - float num434 = 16f; - num434 += 8f * enrageScale; + npc.rotation = spazmatismRotation; + float spazmatismPhase1ChargeSpeed = 16f; + spazmatismPhase1ChargeSpeed += 8f * enrageScale; if (death) - num434 += 12f * (1f - lifeRatio); + spazmatismPhase1ChargeSpeed += 12f * (1f - lifeRatio); if (Main.getGoodWorld) - num434 *= 1.2f; + spazmatismPhase1ChargeSpeed *= 1.2f; - Vector2 vector45 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num435 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector45.X; - float num436 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector45.Y; - float num437 = (float)Math.Sqrt(num435 * num435 + num436 * num436); - num437 = num434 / num437; - npc.velocity.X = num435 * num437; - npc.velocity.Y = num436 * num437; + Vector2 spazmatismPhase1ChargePos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float spazmatismPhase1ChargeTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - spazmatismPhase1ChargePos.X; + float spazmatismPhase1ChargeTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - spazmatismPhase1ChargePos.Y; + float spazmatismPhase1ChargeTargetDist = (float)Math.Sqrt(spazmatismPhase1ChargeTargetX * spazmatismPhase1ChargeTargetX + spazmatismPhase1ChargeTargetY * spazmatismPhase1ChargeTargetY); + spazmatismPhase1ChargeTargetDist = spazmatismPhase1ChargeSpeed / spazmatismPhase1ChargeTargetDist; + npc.velocity.X = spazmatismPhase1ChargeTargetX * spazmatismPhase1ChargeTargetDist; + npc.velocity.Y = spazmatismPhase1ChargeTargetY * spazmatismPhase1ChargeTargetDist; npc.ai[1] = 2f; } else if (npc.ai[1] == 2f) @@ -1459,7 +1452,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.ai[3] += 1f; npc.ai[2] = 0f; npc.TargetClosest(); - npc.rotation = num420; + npc.rotation = spazmatismRotation; float totalCharges = 8f; if (death) totalCharges -= (float)Math.Round(16f * (1f - lifeRatio)); @@ -1523,7 +1516,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.netMode != NetmodeID.Server) { - for (int num438 = 0; num438 < 2; num438++) + for (int i = 0; i < 2; i++) { Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 144, 1f); Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 7, 1f); @@ -1531,7 +1524,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } } - for (int num439 = 0; num439 < 20; num439++) + for (int j = 0; j < 20; j++) { Dust.NewDust(npc.position, npc.width, npc.height, 5, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); } @@ -1576,61 +1569,61 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Shadowflamethrower phase if (npc.ai[1] == 0f) { - float num440 = 6.2f + (death ? 2f * (0.7f - lifeRatio) : 0f); - float num441 = 0.1f + (death ? 0.03f * (0.7f - lifeRatio) : 0f); - num440 += 4f * enrageScale; - num441 += 0.06f * enrageScale; + float spazmatismFlamethrowerMaxSpeed = 6.2f + (death ? 2f * (0.7f - lifeRatio) : 0f); + float spazmatismFlamethrowerAccel = 0.1f + (death ? 0.03f * (0.7f - lifeRatio) : 0f); + spazmatismFlamethrowerMaxSpeed += 4f * enrageScale; + spazmatismFlamethrowerAccel += 0.06f * enrageScale; - int num442 = 1; + int spazmatismFlamethrowerFaceDirection = 1; if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + Main.player[npc.target].width) - num442 = -1; + spazmatismFlamethrowerFaceDirection = -1; - Vector2 vector46 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num443 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (num442 * 180) - vector46.X; - float num444 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector46.Y; - float num445 = (float)Math.Sqrt(num443 * num443 + num444 * num444); + Vector2 spazmatismFlamethrowerPos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float spazmatismFlamethrowerTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (spazmatismFlamethrowerFaceDirection * 180) - spazmatismFlamethrowerPos.X; + float spazmatismFlamethrowerTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - spazmatismFlamethrowerPos.Y; + float spazmatismFlamethrowerTargetDist = (float)Math.Sqrt(spazmatismFlamethrowerTargetX * spazmatismFlamethrowerTargetX + spazmatismFlamethrowerTargetY * spazmatismFlamethrowerTargetY); if (!NPC.IsMechQueenUp) { // Boost speed if too far from target - if (num445 > 300f) - num440 += 0.5f; - if (num445 > 400f) - num440 += 0.5f; + if (spazmatismFlamethrowerTargetDist > 300f) + spazmatismFlamethrowerMaxSpeed += 0.5f; + if (spazmatismFlamethrowerTargetDist > 400f) + spazmatismFlamethrowerMaxSpeed += 0.5f; if (Main.getGoodWorld) { - num440 *= 1.15f; - num441 *= 1.15f; + spazmatismFlamethrowerMaxSpeed *= 1.15f; + spazmatismFlamethrowerAccel *= 1.15f; } - num445 = num440 / num445; - num443 *= num445; - num444 *= num445; + spazmatismFlamethrowerTargetDist = spazmatismFlamethrowerMaxSpeed / spazmatismFlamethrowerTargetDist; + spazmatismFlamethrowerTargetX *= spazmatismFlamethrowerTargetDist; + spazmatismFlamethrowerTargetY *= spazmatismFlamethrowerTargetDist; - if (npc.velocity.X < num443) + if (npc.velocity.X < spazmatismFlamethrowerTargetX) { - npc.velocity.X += num441; - if (npc.velocity.X < 0f && num443 > 0f) - npc.velocity.X += num441; + npc.velocity.X += spazmatismFlamethrowerAccel; + if (npc.velocity.X < 0f && spazmatismFlamethrowerTargetX > 0f) + npc.velocity.X += spazmatismFlamethrowerAccel; } - else if (npc.velocity.X > num443) + else if (npc.velocity.X > spazmatismFlamethrowerTargetX) { - npc.velocity.X -= num441; - if (npc.velocity.X > 0f && num443 < 0f) - npc.velocity.X -= num441; + npc.velocity.X -= spazmatismFlamethrowerAccel; + if (npc.velocity.X > 0f && spazmatismFlamethrowerTargetX < 0f) + npc.velocity.X -= spazmatismFlamethrowerAccel; } - if (npc.velocity.Y < num444) + if (npc.velocity.Y < spazmatismFlamethrowerTargetY) { - npc.velocity.Y += num441; - if (npc.velocity.Y < 0f && num444 > 0f) - npc.velocity.Y += num441; + npc.velocity.Y += spazmatismFlamethrowerAccel; + if (npc.velocity.Y < 0f && spazmatismFlamethrowerTargetY > 0f) + npc.velocity.Y += spazmatismFlamethrowerAccel; } - else if (npc.velocity.Y > num444) + else if (npc.velocity.Y > spazmatismFlamethrowerTargetY) { - npc.velocity.Y -= num441; - if (npc.velocity.Y > 0f && num444 < 0f) - npc.velocity.Y -= num441; + npc.velocity.Y -= spazmatismFlamethrowerAccel; + if (npc.velocity.Y > 0f && spazmatismFlamethrowerTargetY < 0f) + npc.velocity.Y -= spazmatismFlamethrowerAccel; } } @@ -1665,38 +1658,38 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { npc.localAI[1] = 0f; - float num446 = 6f; - num446 += 2f * enrageScale; + float spazmatismShadowFireballSpeed = 6f; + spazmatismShadowFireballSpeed += 2f * enrageScale; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - vector46 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num443 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector46.X; - num444 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector46.Y; - num445 = (float)Math.Sqrt(num443 * num443 + num444 * num444); - num445 = num446 / num445; - num443 *= num445; - num444 *= num445; - num444 += Main.rand.Next(-10, 11) * 0.01f; - num443 += Main.rand.Next(-10, 11) * 0.01f; - num444 += npc.velocity.Y * 0.5f; - num443 += npc.velocity.X * 0.5f; - vector46.X -= num443 * 1f; - vector46.Y -= num444 * 1f; + spazmatismFlamethrowerPos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + spazmatismFlamethrowerTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - spazmatismFlamethrowerPos.X; + spazmatismFlamethrowerTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - spazmatismFlamethrowerPos.Y; + spazmatismFlamethrowerTargetDist = (float)Math.Sqrt(spazmatismFlamethrowerTargetX * spazmatismFlamethrowerTargetX + spazmatismFlamethrowerTargetY * spazmatismFlamethrowerTargetY); + spazmatismFlamethrowerTargetDist = spazmatismShadowFireballSpeed / spazmatismFlamethrowerTargetDist; + spazmatismFlamethrowerTargetX *= spazmatismFlamethrowerTargetDist; + spazmatismFlamethrowerTargetY *= spazmatismFlamethrowerTargetDist; + spazmatismFlamethrowerTargetY += Main.rand.Next(-10, 11) * 0.01f; + spazmatismFlamethrowerTargetX += Main.rand.Next(-10, 11) * 0.01f; + spazmatismFlamethrowerTargetY += npc.velocity.Y * 0.5f; + spazmatismFlamethrowerTargetX += npc.velocity.X * 0.5f; + spazmatismFlamethrowerPos.X -= spazmatismFlamethrowerTargetX * 1f; + spazmatismFlamethrowerPos.Y -= spazmatismFlamethrowerTargetY * 1f; if (NPC.IsMechQueenUp) { - Vector2 vector52 = (npc.rotation + (float)Math.PI / 2f).ToRotationVector2() * num446 + npc.velocity * 0.5f; - num443 = vector52.X; - num444 = vector52.Y; - vector46 = npc.Center - vector52 * 3f; + Vector2 mechdusaSpazShadowFireballPos = (npc.rotation + (float)Math.PI / 2f).ToRotationVector2() * spazmatismShadowFireballSpeed + npc.velocity * 0.5f; + spazmatismFlamethrowerTargetX = mechdusaSpazShadowFireballPos.X; + spazmatismFlamethrowerTargetY = mechdusaSpazShadowFireballPos.Y; + spazmatismFlamethrowerPos = npc.Center - mechdusaSpazShadowFireballPos * 3f; } if (canHit) - Projectile.NewProjectile(npc.GetSource_FromAI(), vector46.X, vector46.Y, num443, num444, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), spazmatismFlamethrowerPos.X, spazmatismFlamethrowerPos.Y, spazmatismFlamethrowerTargetX, spazmatismFlamethrowerTargetY, type, damage, 0f, Main.myPlayer, 0f, 0f); else { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), vector46.X, vector46.Y, num443, num444, type, damage, 0f, Main.myPlayer, 0f, 0f); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), spazmatismFlamethrowerPos.X, spazmatismFlamethrowerPos.Y, spazmatismFlamethrowerTargetX, spazmatismFlamethrowerTargetY, type, damage, 0f, Main.myPlayer, 0f, 0f); Main.projectile[proj].tileCollide = false; } } @@ -1705,24 +1698,23 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (NPC.IsMechQueenUp) { - num440 = 14f; - num443 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector46.X; - num444 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - 300f - vector46.Y; - num443 = mechQueenSpacing.X; - num444 = mechQueenSpacing.Y; - num443 -= vector46.X; - num444 -= vector46.Y; - num445 = (float)Math.Sqrt(num443 * num443 + num444 * num444); - if (num445 > num440) + spazmatismFlamethrowerMaxSpeed = 14f; + spazmatismFlamethrowerTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - spazmatismFlamethrowerPos.X; + spazmatismFlamethrowerTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - 300f - spazmatismFlamethrowerPos.Y; + spazmatismFlamethrowerTargetX = mechQueenSpacing.X; + spazmatismFlamethrowerTargetY = mechQueenSpacing.Y; + spazmatismFlamethrowerTargetX -= spazmatismFlamethrowerPos.X; + spazmatismFlamethrowerTargetY -= spazmatismFlamethrowerPos.Y; + spazmatismFlamethrowerTargetDist = (float)Math.Sqrt(spazmatismFlamethrowerTargetX * spazmatismFlamethrowerTargetX + spazmatismFlamethrowerTargetY * spazmatismFlamethrowerTargetY); + if (spazmatismFlamethrowerTargetDist > spazmatismFlamethrowerMaxSpeed) { - num445 = num440 / num445; - num443 *= num445; - num444 *= num445; + spazmatismFlamethrowerTargetDist = spazmatismFlamethrowerMaxSpeed / spazmatismFlamethrowerTargetDist; + spazmatismFlamethrowerTargetX *= spazmatismFlamethrowerTargetDist; + spazmatismFlamethrowerTargetY *= spazmatismFlamethrowerTargetDist; } - int num490 = 60; - npc.velocity.X = (npc.velocity.X * (float)(num490 - 1) + num443) / (float)num490; - npc.velocity.Y = (npc.velocity.Y * (float)(num490 - 1) + num444) / (float)num490; + npc.velocity.X = (npc.velocity.X * 59f + spazmatismFlamethrowerTargetX) / 60f; + npc.velocity.Y = (npc.velocity.Y * 59f + spazmatismFlamethrowerTargetY) / 60f; } } @@ -1736,14 +1728,14 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses SoundEngine.PlaySound(SoundID.Roar, npc.position); // Set rotation and velocity - npc.rotation = num420; - float num450 = 16.75f + (death ? 5f * (0.7f - lifeRatio) : 0f); - num450 += 8f * enrageScale; + npc.rotation = spazmatismRotation; + float spazmatismPhase2ChargeSpeed = 16.75f + (death ? 5f * (0.7f - lifeRatio) : 0f); + spazmatismPhase2ChargeSpeed += 8f * enrageScale; if (Main.getGoodWorld) - num450 *= 1.2f; + spazmatismPhase2ChargeSpeed *= 1.2f; Vector2 distanceVector = Main.player[npc.target].Center - npc.Center; - npc.velocity = Vector2.Normalize(distanceVector) * num450; + npc.velocity = Vector2.Normalize(distanceVector) * spazmatismPhase2ChargeSpeed; npc.ai[1] = 2f; return false; } @@ -1772,7 +1764,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.ai[3] += 1f; npc.ai[2] = 0f; npc.TargetClosest(); - npc.rotation = num420; + npc.rotation = spazmatismRotation; if (npc.ai[3] >= 5f) { npc.ai[1] = 0f; @@ -1808,38 +1800,38 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses else if (Main.netMode != NetmodeID.MultiplayerClient) { // Velocity - float num48 = 20f + (death ? 6f * (0.7f - lifeRatio) : 0f); - num48 += 10f * enrageScale; + float spazmatismPhase3ChargeSpeed = 20f + (death ? 6f * (0.7f - lifeRatio) : 0f); + spazmatismPhase3ChargeSpeed += 10f * enrageScale; if (npc.ai[2] == -1f || (!retAlive && npc.ai[3] == secondFastCharge)) - num48 *= 1.3f; + spazmatismPhase3ChargeSpeed *= 1.3f; if (Main.getGoodWorld) - num48 *= 1.2f; + spazmatismPhase3ChargeSpeed *= 1.2f; Vector2 distanceVector = Main.player[npc.target].Center + (!retAlive && bossRush ? Main.player[npc.target].velocity * 20f : Vector2.Zero) - npc.Center; - npc.velocity = Vector2.Normalize(distanceVector) * num48; + npc.velocity = Vector2.Normalize(distanceVector) * spazmatismPhase3ChargeSpeed; if (retAlive) { - Vector2 vector10 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num49 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector10.X; - float num50 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector10.Y; - float num51 = (float)Math.Sqrt(num49 * num49 + num50 * num50); - float num52 = num51; + Vector2 spazmatismPhase3ChargePos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float spazmatismPhase3ChargeTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - spazmatismPhase3ChargePos.X; + float spazmatismPhase3ChargeTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - spazmatismPhase3ChargePos.Y; + float spazmatismPhase3ChargeTargetDist = (float)Math.Sqrt(spazmatismPhase3ChargeTargetX * spazmatismPhase3ChargeTargetX + spazmatismPhase3ChargeTargetY * spazmatismPhase3ChargeTargetY); + float spazmatismPhase3ChargeTargetDistCopy = spazmatismPhase3ChargeTargetDist; - if (num52 < 100f) + if (spazmatismPhase3ChargeTargetDistCopy < 100f) { if (Math.Abs(npc.velocity.X) > Math.Abs(npc.velocity.Y)) { - float num56 = Math.Abs(npc.velocity.X); - float num57 = Math.Abs(npc.velocity.Y); + float absoluteSpazXVel = Math.Abs(npc.velocity.X); + float absoluteSpazYVel = Math.Abs(npc.velocity.Y); if (npc.Center.X > Main.player[npc.target].Center.X) - num57 *= -1f; + absoluteSpazYVel *= -1f; if (npc.Center.Y > Main.player[npc.target].Center.Y) - num56 *= -1f; + absoluteSpazXVel *= -1f; - npc.velocity.X = num57; - npc.velocity.Y = num56; + npc.velocity.X = absoluteSpazYVel; + npc.velocity.Y = absoluteSpazXVel; } } } @@ -1858,15 +1850,15 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[2] == 0f) SoundEngine.PlaySound(SoundID.Roar, npc.position); - float num60 = ((!retAlive && npc.ai[3] == 4f) ? 75f : 50f) - (float)Math.Round(death ? 14f * (0.7f - lifeRatio) : 0f); + float spazmatismRetDeadChargeSpeed = ((!retAlive && npc.ai[3] == 4f) ? 75f : 50f) - (float)Math.Round(death ? 14f * (0.7f - lifeRatio) : 0f); npc.ai[2] += 1f; - if (npc.ai[2] == num60 && Vector2.Distance(npc.position, Main.player[npc.target].position) < (retAlive ? 200f : 150f)) + if (npc.ai[2] == spazmatismRetDeadChargeSpeed && Vector2.Distance(npc.position, Main.player[npc.target].position) < (retAlive ? 200f : 150f)) npc.ai[2] -= 1f; // Slow down - if (npc.ai[2] >= num60) + if (npc.ai[2] >= spazmatismRetDeadChargeSpeed) { npc.velocity *= 0.93f; if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) @@ -1878,8 +1870,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; // Charge 3 times - float num61 = num60 + 25f; - if (npc.ai[2] >= num61) + float spazmatismRetDeadChargeTimer = spazmatismRetDeadChargeSpeed + 25f; + if (npc.ai[2] >= spazmatismRetDeadChargeTimer) { npc.netUpdate = true; @@ -1895,54 +1887,54 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Get in position for charge else if (npc.ai[1] == 5f) { - float num62 = retAlive ? 600f : 500f; - float num63 = 16f + (death ? 5f * (0.7f - lifeRatio) : 0f); - float num64 = 0.4f + (death ? 0.1f * (0.7f - lifeRatio) : 0f); + float chargeLineUpDist = retAlive ? 600f : 500f; + float chargeSpeed = 16f + (death ? 5f * (0.7f - lifeRatio) : 0f); + float chargeAccel = 0.4f + (death ? 0.1f * (0.7f - lifeRatio) : 0f); if (retAlive) { - num63 *= 0.75f; - num64 *= 0.75f; + chargeSpeed *= 0.75f; + chargeAccel *= 0.75f; } if (Main.getGoodWorld) { - num63 *= 1.15f; - num64 *= 1.15f; + chargeSpeed *= 1.15f; + chargeAccel *= 1.15f; } - Vector2 vector11 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num65 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector11.X; - float num66 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) + num62 - vector11.Y; - float num67 = (float)Math.Sqrt(num65 * num65 + num66 * num66); + Vector2 spazmatismRetDeadChargePos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float chargeTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - spazmatismRetDeadChargePos.X; + float chargeTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) + chargeLineUpDist - spazmatismRetDeadChargePos.Y; + float chargeTargetDist = (float)Math.Sqrt(chargeTargetX * chargeTargetX + chargeTargetY * chargeTargetY); - num67 = num63 / num67; - num65 *= num67; - num66 *= num67; + chargeTargetDist = chargeSpeed / chargeTargetDist; + chargeTargetX *= chargeTargetDist; + chargeTargetY *= chargeTargetDist; - if (npc.velocity.X < num65) + if (npc.velocity.X < chargeTargetX) { - npc.velocity.X += num64; - if (npc.velocity.X < 0f && num65 > 0f) - npc.velocity.X += num64; + npc.velocity.X += chargeAccel; + if (npc.velocity.X < 0f && chargeTargetX > 0f) + npc.velocity.X += chargeAccel; } - else if (npc.velocity.X > num65) + else if (npc.velocity.X > chargeTargetX) { - npc.velocity.X -= num64; - if (npc.velocity.X > 0f && num65 < 0f) - npc.velocity.X -= num64; + npc.velocity.X -= chargeAccel; + if (npc.velocity.X > 0f && chargeTargetX < 0f) + npc.velocity.X -= chargeAccel; } - if (npc.velocity.Y < num66) + if (npc.velocity.Y < chargeTargetY) { - npc.velocity.Y += num64; - if (npc.velocity.Y < 0f && num66 > 0f) - npc.velocity.Y += num64; + npc.velocity.Y += chargeAccel; + if (npc.velocity.Y < 0f && chargeTargetY > 0f) + npc.velocity.Y += chargeAccel; } - else if (npc.velocity.Y > num66) + else if (npc.velocity.Y > chargeTargetY) { - npc.velocity.Y -= num64; - if (npc.velocity.Y > 0f && num66 < 0f) - npc.velocity.Y -= num64; + npc.velocity.Y -= chargeAccel; + if (npc.velocity.Y > 0f && chargeTargetY < 0f) + npc.velocity.Y -= chargeAccel; } npc.ai[2] += 1f; diff --git a/NPCs/VanillaNPCOverrides/Bosses/WallOfFleshAI.cs b/NPCs/VanillaNPCOverrides/Bosses/WallOfFleshAI.cs index 6c2175e31f..a904b3cf91 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/WallOfFleshAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/WallOfFleshAI.cs @@ -44,28 +44,27 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { if (NPC.CountNPCS(NPCID.FireImp) < 4) { - int num351 = 1000; - for (int num352 = 0; num352 < num351; num352++) + for (int i = 0; i < 1000; i++) { - int num353 = (int)(npc.Center.X / 16f); - int num354 = (int)(npc.Center.Y / 16f); + int targetTileX = (int)(npc.Center.X / 16f); + int targetTileY = (int)(npc.Center.Y / 16f); if (npc.target >= 0) { - num353 = (int)(Main.player[npc.target].Center.X / 16f); - num354 = (int)(Main.player[npc.target].Center.Y / 16f); + targetTileX = (int)(Main.player[npc.target].Center.X / 16f); + targetTileY = (int)(Main.player[npc.target].Center.Y / 16f); } - num353 += Main.rand.Next(-50, 51); - for (num354 += Main.rand.Next(-50, 51); num354 < Main.maxTilesY - 10 && !WorldGen.SolidTile(num353, num354); num354++) + targetTileX += Main.rand.Next(-50, 51); + for (targetTileY += Main.rand.Next(-50, 51); targetTileY < Main.maxTilesY - 10 && !WorldGen.SolidTile(targetTileX, targetTileY); targetTileY++) { } - num354--; - if (!WorldGen.SolidTile(num353, num354)) + targetTileY--; + if (!WorldGen.SolidTile(targetTileX, targetTileY)) { - int num355 = NPC.NewNPC(npc.GetSource_FromAI(), num353 * 16 + 8, num354 * 16, 24); - if (Main.netMode == NetmodeID.Server && num355 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num355); + int impSpawn = NPC.NewNPC(npc.GetSource_FromAI(), targetTileX * 16 + 8, targetTileY * 16, 24); + if (Main.netMode == NetmodeID.Server && impSpawn < Main.maxNPCs) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, impSpawn); break; } @@ -93,17 +92,17 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Leech spawn if (npc.ai[2] > 0f && npc.ai[1] > 60f) { - int num330 = phase3 ? 3 : 2; + int leechAmt = phase3 ? 3 : 2; npc.ai[2] += 1f; npc.ai[1] = 0f; - if (npc.ai[2] > num330) + if (npc.ai[2] > leechAmt) npc.ai[2] = 0f; if (Main.netMode != NetmodeID.MultiplayerClient) { - int num331 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (npc.width / 2)), (int)(npc.position.Y + (npc.height / 2) + 20f), NPCID.LeechHead, 1); - Main.npc[num331].velocity.X = npc.direction * 9; + int leechSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (npc.width / 2)), (int)(npc.position.Y + (npc.height / 2) + 20f), NPCID.LeechHead, 1); + Main.npc[leechSpawn].velocity.X = npc.direction * 9; if (phase2) { @@ -131,79 +130,79 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses Main.wofNPCIndex = npc.whoAmI; // Set eye positions - int num332 = (int)(npc.position.X / 16f); - int num333 = (int)((npc.position.X + npc.width) / 16f); - int num334 = (int)((npc.position.Y + (npc.height / 2)) / 16f); - int num335 = 0; - int num336 = num334 + 7; - while (num335 < 15 && num336 > Main.UnderworldLayer) + int currentEyeTileCenterX = (int)(npc.position.X / 16f); + int currentEyeTileWidthX = (int)((npc.position.X + npc.width) / 16f); + int currentEyeTileHeightY = (int)((npc.position.Y + (npc.height / 2)) / 16f); + int eyeMovementTries = 0; + int eyeMovementTileY = currentEyeTileHeightY + 7; + while (eyeMovementTries < 15 && eyeMovementTileY > Main.UnderworldLayer) { - num336++; - for (int num337 = num332; num337 <= num333; num337++) + eyeMovementTileY++; + for (int eyeMovementTileX = currentEyeTileCenterX; eyeMovementTileX <= currentEyeTileWidthX; eyeMovementTileX++) { try { - if (WorldGen.SolidTile(num337, num336) || Main.tile[num337, num336].LiquidAmount > 0) - num335++; + if (WorldGen.SolidTile(eyeMovementTileX, eyeMovementTileY) || Main.tile[eyeMovementTileX, eyeMovementTileY].LiquidAmount > 0) + eyeMovementTries++; } catch - { num335 += 15; } + { eyeMovementTries += 15; } } } - num336 += 4; + eyeMovementTileY += 4; if (Main.wofDrawAreaBottom == -1) - Main.wofDrawAreaBottom = num336 * 16; - else if (Main.wofDrawAreaBottom > num336 * 16) + Main.wofDrawAreaBottom = eyeMovementTileY * 16; + else if (Main.wofDrawAreaBottom > eyeMovementTileY * 16) { Main.wofDrawAreaBottom--; - if (Main.wofDrawAreaBottom < num336 * 16) - Main.wofDrawAreaBottom = num336 * 16; + if (Main.wofDrawAreaBottom < eyeMovementTileY * 16) + Main.wofDrawAreaBottom = eyeMovementTileY * 16; } - else if (Main.wofDrawAreaBottom < num336 * 16) + else if (Main.wofDrawAreaBottom < eyeMovementTileY * 16) { Main.wofDrawAreaBottom++; - if (Main.wofDrawAreaBottom > num336 * 16) - Main.wofDrawAreaBottom = num336 * 16; + if (Main.wofDrawAreaBottom > eyeMovementTileY * 16) + Main.wofDrawAreaBottom = eyeMovementTileY * 16; } - num335 = 0; - num336 = num334 - 7; - while (num335 < 15 && num336 < Main.maxTilesY - 10) + eyeMovementTries = 0; + eyeMovementTileY = currentEyeTileHeightY - 7; + while (eyeMovementTries < 15 && eyeMovementTileY < Main.maxTilesY - 10) { - num336--; - for (int num338 = num332; num338 <= num333; num338++) + eyeMovementTileY--; + for (int i = currentEyeTileCenterX; i <= currentEyeTileWidthX; i++) { try { - if (WorldGen.SolidTile(num338, num336) || Main.tile[num338, num336].LiquidAmount > 0) - num335++; + if (WorldGen.SolidTile(i, eyeMovementTileY) || Main.tile[i, eyeMovementTileY].LiquidAmount > 0) + eyeMovementTries++; } catch - { num335 += 15; } + { eyeMovementTries += 15; } } } - num336 -= 4; + eyeMovementTileY -= 4; if (Main.wofDrawAreaTop == -1) - Main.wofDrawAreaTop = num336 * 16; - else if (Main.wofDrawAreaTop > num336 * 16) + Main.wofDrawAreaTop = eyeMovementTileY * 16; + else if (Main.wofDrawAreaTop > eyeMovementTileY * 16) { Main.wofDrawAreaTop--; - if (Main.wofDrawAreaTop < num336 * 16) - Main.wofDrawAreaTop = num336 * 16; + if (Main.wofDrawAreaTop < eyeMovementTileY * 16) + Main.wofDrawAreaTop = eyeMovementTileY * 16; } - else if (Main.wofDrawAreaTop < num336 * 16) + else if (Main.wofDrawAreaTop < eyeMovementTileY * 16) { Main.wofDrawAreaTop++; - if (Main.wofDrawAreaTop > num336 * 16) - Main.wofDrawAreaTop = num336 * 16; + if (Main.wofDrawAreaTop > eyeMovementTileY * 16) + Main.wofDrawAreaTop = eyeMovementTileY * 16; } // Set Y position - float num339 = (Main.wofDrawAreaBottom + Main.wofDrawAreaTop) / 2 - npc.height / 2; - int num340 = (Main.maxTilesY - 180) * 16; - if (num339 < num340) - num339 = num340; - npc.position.Y = num339; + float mouthYPosition = (Main.wofDrawAreaBottom + Main.wofDrawAreaTop) / 2 - npc.height / 2; + int worldBottomTileY = (Main.maxTilesY - 180) * 16; + if (mouthYPosition < worldBottomTileY) + mouthYPosition = worldBottomTileY; + npc.position.Y = mouthYPosition; float targetPosition = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); float npcPosition = npc.position.X + (npc.width / 2); @@ -299,23 +298,23 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.TargetClosest(); if (Main.player[npc.target].dead) { - float num359 = float.PositiveInfinity; - int direction2 = 0; - for (int num360 = 0; num360 < Main.maxPlayers; num360++) + float wallVelocity = float.PositiveInfinity; + int wallDirection = 0; + for (int i = 0; i < Main.maxPlayers; i++) { Player player = Main.player[npc.target]; if (player.active) { - float num361 = npc.Distance(player.Center); - if (num359 > num361) + float playerDist = npc.Distance(player.Center); + if (wallVelocity > playerDist) { - num359 = num361; - direction2 = (npc.Center.X < player.Center.X) ? 1 : -1; + wallVelocity = playerDist; + wallDirection = (npc.Center.X < player.Center.X) ? 1 : -1; } } } - npc.direction = direction2; + npc.direction = wallDirection; } npc.velocity.X = npc.direction; @@ -356,23 +355,23 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Direction npc.spriteDirection = npc.direction; - Vector2 vector37 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num342 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector37.X; - float num343 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector37.Y; - float num344 = (float)Math.Sqrt(num342 * num342 + num343 * num343); - num342 *= num344; - num343 *= num344; + Vector2 mouthLocation = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float mouthTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - mouthLocation.X; + float mouthTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - mouthLocation.Y; + float mouthTargetDist = (float)Math.Sqrt(mouthTargetX * mouthTargetX + mouthTargetY * mouthTargetY); + mouthTargetX *= mouthTargetDist; + mouthTargetY *= mouthTargetDist; // Rotation based on direction if (npc.direction > 0) { if (Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) > npc.position.X + (npc.width / 2)) - npc.rotation = (float)Math.Atan2(-num343, -num342) + MathHelper.Pi; + npc.rotation = (float)Math.Atan2(-mouthTargetY, -mouthTargetX) + MathHelper.Pi; else npc.rotation = 0f; } else if (Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) < npc.position.X + (npc.width / 2)) - npc.rotation = (float)Math.Atan2(num343, num342) + MathHelper.Pi; + npc.rotation = (float)Math.Atan2(mouthTargetY, mouthTargetX) + MathHelper.Pi; else npc.rotation = 0f; @@ -401,44 +400,44 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.rand.NextBool(chance)) { - int num346 = 0; + int hungryAmt = 0; float[] array = new float[10]; - for (int num347 = 0; num347 < Main.maxNPCs; num347++) + for (int j = 0; j < Main.maxNPCs; j++) { - if (num346 < 10 && Main.npc[num347].active && Main.npc[num347].type == NPCID.TheHungry) + if (hungryAmt < 10 && Main.npc[j].active && Main.npc[j].type == NPCID.TheHungry) { - array[num346] = Main.npc[num347].ai[0]; - num346++; + array[hungryAmt] = Main.npc[j].ai[0]; + hungryAmt++; } } - int maxValue = 1 + num346 * 2; - if (num346 < 10 && Main.rand.Next(maxValue) <= 1) + int maxValue = 1 + hungryAmt * 2; + if (hungryAmt < 10 && Main.rand.Next(maxValue) <= 1) { - int num348 = -1; - for (int num349 = 0; num349 < 1000; num349++) + int spawnHungryControl = -1; + for (int k = 0; k < 1000; k++) { - int num350 = Main.rand.Next(10); - float num351 = num350 * 0.1f - 0.05f; - bool flag29 = true; - for (int num352 = 0; num352 < num346; num352++) + int randomHungrySpawnValue = Main.rand.Next(10); + float hungryArrayValue = randomHungrySpawnValue * 0.1f - 0.05f; + bool shouldRespawnHungry = true; + for (int i = 0; i < hungryAmt; i++) { - if (num351 == array[num352]) + if (hungryArrayValue == array[i]) { - flag29 = false; + shouldRespawnHungry = false; break; } } - if (flag29) + if (shouldRespawnHungry) { - num348 = num350; + spawnHungryControl = randomHungrySpawnValue; break; } } - if (num348 >= 0) + if (spawnHungryControl >= 0) { - int num353 = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X, (int)num339, NPCID.TheHungry, npc.whoAmI); - Main.npc[num353].ai[0] = num348 * 0.1f - 0.05f; + int hungryRespawns = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X, (int)mouthYPosition, NPCID.TheHungry, npc.whoAmI); + Main.npc[hungryRespawns].ai[0] = spawnHungryControl * 0.1f - 0.05f; } } } @@ -449,25 +448,25 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { npc.localAI[0] = 2f; - num339 = (Main.wofDrawAreaBottom + Main.wofDrawAreaTop) / 2; - num339 = (num339 + Main.wofDrawAreaTop) / 2f; - int num354 = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X, (int)num339, NPCID.WallofFleshEye, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num354].ai[0] = 1f; + mouthYPosition = (Main.wofDrawAreaBottom + Main.wofDrawAreaTop) / 2; + mouthYPosition = (mouthYPosition + Main.wofDrawAreaTop) / 2f; + int eyeSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X, (int)mouthYPosition, NPCID.WallofFleshEye, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[eyeSpawn].ai[0] = 1f; - num339 = (Main.wofDrawAreaBottom + Main.wofDrawAreaTop) / 2; - num339 = (num339 + Main.wofDrawAreaBottom) / 2f; - num354 = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X, (int)num339, NPCID.WallofFleshEye, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num354].ai[0] = -1f; + mouthYPosition = (Main.wofDrawAreaBottom + Main.wofDrawAreaTop) / 2; + mouthYPosition = (mouthYPosition + Main.wofDrawAreaBottom) / 2f; + eyeSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X, (int)mouthYPosition, NPCID.WallofFleshEye, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[eyeSpawn].ai[0] = -1f; - num339 = (Main.wofDrawAreaBottom + Main.wofDrawAreaTop) / 2; - num339 = (num339 + Main.wofDrawAreaBottom) / 2f; + mouthYPosition = (Main.wofDrawAreaBottom + Main.wofDrawAreaTop) / 2; + mouthYPosition = (mouthYPosition + Main.wofDrawAreaBottom) / 2f; - int num; - for (int num355 = 0; num355 < 11; num355 = num + 1) + int hungryIncrement; + for (int j = 0; j < 11; j = hungryIncrement + 1) { - num354 = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X, (int)num339, NPCID.TheHungry, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num354].ai[0] = num355 * 0.1f - 0.05f; - num = num355; + int hungrySpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X, (int)mouthYPosition, NPCID.TheHungry, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[hungrySpawn].ai[0] = j * 0.1f - 0.05f; + hungryIncrement = j; } } @@ -529,35 +528,35 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.position.Y = expectedPosition; } - Vector2 vector38 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num357 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector38.X; - float num358 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector38.Y; - float num359 = (float)Math.Sqrt(num357 * num357 + num358 * num358); - num357 *= num359; - num358 *= num359; + Vector2 eyeLocation = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float eyeTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - eyeLocation.X; + float eyeTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - eyeLocation.Y; + float wallVelocity = (float)Math.Sqrt(eyeTargetX * eyeTargetX + eyeTargetY * eyeTargetY); + eyeTargetX *= wallVelocity; + eyeTargetY *= wallVelocity; // Rotation based on direction and whether to fire lasers or not - bool flag30 = true; + bool shouldFireLasers = true; if (npc.direction > 0) { if (Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) > npc.position.X + (npc.width / 2)) { - npc.rotation = (float)Math.Atan2(-num358, -num357) + MathHelper.Pi; + npc.rotation = (float)Math.Atan2(-eyeTargetY, -eyeTargetX) + MathHelper.Pi; } else { npc.rotation = 0f; - flag30 = false; + shouldFireLasers = false; } } else if (Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) < npc.position.X + (npc.width / 2)) { - npc.rotation = (float)Math.Atan2(num358, num357) + MathHelper.Pi; + npc.rotation = (float)Math.Atan2(eyeTargetY, eyeTargetX) + MathHelper.Pi; } else { npc.rotation = 0f; - flag30 = false; + shouldFireLasers = false; } // Fire lasers @@ -606,7 +605,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.localAI[2] >= 4f) npc.localAI[2] = 0f; - if (flag30) + if (shouldFireLasers) { bool phase2 = lifeRatio < 0.5 || bossRush; float velocity = (fireEnragedLasers ? 3f : 4f) + shootBoost; diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index 1a9535bc48..ad2d2f192f 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -75,7 +75,7 @@ namespace CalamityMod.NPCs.Yharon Main.npcFrameCount[NPC.type] = 7; NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Scale = 0.3f, PortraitScale = 0.4f, @@ -470,12 +470,15 @@ namespace CalamityMod.NPCs.Yharon // Spawn effects if (NPC.ai[0] == -1f) { + // Avoid cheap bullshit + NPC.damage = 0; + NPC.velocity *= 0.98f; - int num1467 = Math.Sign(player.Center.X - NPC.Center.X); - if (num1467 != 0) + int playerFacingDirection = Math.Sign(player.Center.X - NPC.Center.X); + if (playerFacingDirection != 0) { - NPC.direction = num1467; + NPC.direction = playerFacingDirection; NPC.spriteDirection = -NPC.direction; } @@ -498,16 +501,16 @@ namespace CalamityMod.NPCs.Yharon if (NPC.ai[2] == fireTornadoPhaseTimer - 30) { - int num1468 = 72; - for (int num1469 = 0; num1469 < num1468; num1469++) + int dustAmt = 72; + for (int i = 0; i < dustAmt; i++) { - Vector2 vector169 = Vector2.Normalize(NPC.velocity) * new Vector2(NPC.width / 2f, NPC.height) * 0.75f * 0.5f; - vector169 = vector169.RotatedBy((num1469 - (num1468 / 2 - 1)) * MathHelper.TwoPi / num1468) + NPC.Center; - Vector2 value16 = vector169 - NPC.Center; - int num1470 = Dust.NewDust(vector169 + value16, 0, 0, 244, value16.X * 2f, value16.Y * 2f, 100, default, 1.4f); - Main.dust[num1470].noGravity = true; - Main.dust[num1470].noLight = true; - Main.dust[num1470].velocity = Vector2.Normalize(value16) * 3f; + Vector2 dustRotation = Vector2.Normalize(NPC.velocity) * new Vector2(NPC.width / 2f, NPC.height) * 0.75f * 0.5f; + dustRotation = dustRotation.RotatedBy((i - (dustAmt / 2 - 1)) * MathHelper.TwoPi / dustAmt) + NPC.Center; + Vector2 dustDirection = dustRotation - NPC.Center; + int orangeDust = Dust.NewDust(dustRotation + dustDirection, 0, 0, 244, dustDirection.X * 2f, dustDirection.Y * 2f, 100, default, 1.4f); + Main.dust[orangeDust].noGravity = true; + Main.dust[orangeDust].noLight = true; + Main.dust[orangeDust].velocity = Vector2.Normalize(dustDirection) * 3f; } RoarSoundSlot = SoundEngine.PlaySound(RoarSound, NPC.Center); @@ -540,13 +543,13 @@ namespace CalamityMod.NPCs.Yharon else NPC.velocity *= 0.98f; - int num1471 = Math.Sign(player.Center.X - NPC.Center.X); - if (num1471 != 0) + int phaseSwitchFaceDirection = Math.Sign(player.Center.X - NPC.Center.X); + if (phaseSwitchFaceDirection != 0) { - if (NPC.ai[2] == 0f && num1471 != NPC.direction) + if (NPC.ai[2] == 0f && phaseSwitchFaceDirection != NPC.direction) NPC.rotation += pie; - NPC.direction = num1471; + NPC.direction = phaseSwitchFaceDirection; if (NPC.spriteDirection != -NPC.direction) NPC.rotation += pie; @@ -554,6 +557,12 @@ namespace CalamityMod.NPCs.Yharon NPC.spriteDirection = -NPC.direction; } + if (phase2Check) + { + // Avoid cheap bullshit + NPC.damage = 0; + } + NPC.ai[2] += 1f; if (NPC.ai[2] >= phaseSwitchTimer) { @@ -591,9 +600,9 @@ namespace CalamityMod.NPCs.Yharon NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * chargeSpeed; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); - if (num1471 != 0) + if (phaseSwitchFaceDirection != 0) { - NPC.direction = num1471; + NPC.direction = phaseSwitchFaceDirection; if (NPC.spriteDirection == 1) NPC.rotation += pie; @@ -638,9 +647,9 @@ namespace CalamityMod.NPCs.Yharon NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * chargeSpeed * fastChargeVelocityMultiplier; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); - if (num1471 != 0) + if (phaseSwitchFaceDirection != 0) { - NPC.direction = num1471; + NPC.direction = phaseSwitchFaceDirection; if (NPC.spriteDirection == 1) NPC.rotation += pie; @@ -678,11 +687,11 @@ namespace CalamityMod.NPCs.Yharon NPC.ai[1] = Math.Sign((NPC.Center - player.Center).X); Vector2 destination = player.Center + new Vector2(NPC.ai[1], 0); - Vector2 value17 = destination - NPC.Center; - Vector2 vector170 = Vector2.Normalize(value17 - NPC.velocity) * flareBombPhaseVelocity; + Vector2 destinationDist = destination - NPC.Center; + Vector2 flareSpeed = Vector2.Normalize(destinationDist - NPC.velocity) * flareBombPhaseVelocity; if (Vector2.Distance(NPC.Center, destination) > reduceSpeedFlareBombDistance) - NPC.SimpleFlyMovement(vector170, flareBombPhaseAcceleration); + NPC.SimpleFlyMovement(flareSpeed, flareBombPhaseAcceleration); else NPC.velocity *= 0.98f; @@ -699,10 +708,10 @@ namespace CalamityMod.NPCs.Yharon } } - int num1476 = Math.Sign(player.Center.X - NPC.Center.X); - if (num1476 != 0) + int playerFaceDirection = Math.Sign(player.Center.X - NPC.Center.X); + if (playerFaceDirection != 0) { - NPC.direction = num1476; + NPC.direction = playerFaceDirection; if (NPC.spriteDirection != -NPC.direction) NPC.rotation += pie; @@ -750,6 +759,9 @@ namespace CalamityMod.NPCs.Yharon // Enter new phase else if (NPC.ai[0] == 4f) { + // Avoid cheap bullshit + NPC.damage = 0; + NPC.velocity *= 0.9f; NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, 0f, 0.02f); @@ -803,13 +815,13 @@ namespace CalamityMod.NPCs.Yharon else NPC.velocity *= 0.98f; - int num1477 = Math.Sign(player.Center.X - NPC.Center.X); - if (num1477 != 0) + int playerFaceDirectionFurtherPhases = Math.Sign(player.Center.X - NPC.Center.X); + if (playerFaceDirectionFurtherPhases != 0) { - if (NPC.ai[2] == 0f && num1477 != NPC.direction) + if (NPC.ai[2] == 0f && playerFaceDirectionFurtherPhases != NPC.direction) NPC.rotation += pie; - NPC.direction = num1477; + NPC.direction = playerFaceDirectionFurtherPhases; if (NPC.spriteDirection != -NPC.direction) NPC.rotation += pie; @@ -817,6 +829,12 @@ namespace CalamityMod.NPCs.Yharon NPC.spriteDirection = -NPC.direction; } + if (phase3Check) + { + // Avoid cheap bullshit + NPC.damage = 0; + } + NPC.ai[2] += 1f; if (NPC.ai[2] >= phaseSwitchTimer) { @@ -857,9 +875,9 @@ namespace CalamityMod.NPCs.Yharon NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * chargeSpeed; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); - if (num1477 != 0) + if (playerFaceDirectionFurtherPhases != 0) { - NPC.direction = num1477; + NPC.direction = playerFaceDirectionFurtherPhases; if (NPC.spriteDirection == 1) NPC.rotation += pie; @@ -950,9 +968,9 @@ namespace CalamityMod.NPCs.Yharon NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * chargeSpeed * fastChargeVelocityMultiplier; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); - if (num1477 != 0) + if (playerFaceDirectionFurtherPhases != 0) { - NPC.direction = num1477; + NPC.direction = playerFaceDirectionFurtherPhases; if (NPC.spriteDirection == 1) NPC.rotation += pie; @@ -968,9 +986,9 @@ namespace CalamityMod.NPCs.Yharon NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * spinPhaseVelocity; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); - if (num1477 != 0) + if (playerFaceDirectionFurtherPhases != 0) { - NPC.direction = num1477; + NPC.direction = playerFaceDirectionFurtherPhases; if (NPC.spriteDirection == 1) NPC.rotation += pie; @@ -1060,6 +1078,9 @@ namespace CalamityMod.NPCs.Yharon // Enter new phase else if (NPC.ai[0] == 10f) { + // Avoid cheap bullshit + NPC.damage = 0; + NPC.velocity *= 0.9f; NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, 0f, 0.02f); @@ -1149,13 +1170,13 @@ namespace CalamityMod.NPCs.Yharon else NPC.velocity *= 0.98f; - int num1477 = Math.Sign(player.Center.X - NPC.Center.X); - if (num1477 != 0) + int playerFaceDirectionFurtherPhases = Math.Sign(player.Center.X - NPC.Center.X); + if (playerFaceDirectionFurtherPhases != 0) { - if (NPC.ai[2] == 0f && num1477 != NPC.direction) + if (NPC.ai[2] == 0f && playerFaceDirectionFurtherPhases != NPC.direction) NPC.rotation += pie; - NPC.direction = num1477; + NPC.direction = playerFaceDirectionFurtherPhases; if (NPC.spriteDirection != -NPC.direction) NPC.rotation += pie; @@ -1163,6 +1184,12 @@ namespace CalamityMod.NPCs.Yharon NPC.spriteDirection = -NPC.direction; } + if (phase4Check) + { + // Avoid cheap bullshit + NPC.damage = 0; + } + NPC.ai[2] += 1f; if (NPC.ai[2] >= phaseSwitchTimer) { @@ -1206,9 +1233,9 @@ namespace CalamityMod.NPCs.Yharon NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * chargeSpeed; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); - if (num1477 != 0) + if (playerFaceDirectionFurtherPhases != 0) { - NPC.direction = num1477; + NPC.direction = playerFaceDirectionFurtherPhases; if (NPC.spriteDirection == 1) NPC.rotation += pie; @@ -1299,9 +1326,9 @@ namespace CalamityMod.NPCs.Yharon NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * chargeSpeed * fastChargeVelocityMultiplier; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); - if (num1477 != 0) + if (playerFaceDirectionFurtherPhases != 0) { - NPC.direction = num1477; + NPC.direction = playerFaceDirectionFurtherPhases; if (NPC.spriteDirection == 1) NPC.rotation += pie; @@ -1317,9 +1344,9 @@ namespace CalamityMod.NPCs.Yharon NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * spinPhaseVelocity; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); - if (num1477 != 0) + if (playerFaceDirectionFurtherPhases != 0) { - NPC.direction = num1477; + NPC.direction = playerFaceDirectionFurtherPhases; if (NPC.spriteDirection == 1) NPC.rotation += pie; @@ -1417,6 +1444,9 @@ namespace CalamityMod.NPCs.Yharon // Enter new phase else if (NPC.ai[0] == 17f) { + // Avoid cheap bullshit + NPC.damage = 0; + NPC.velocity *= 0.9f; NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, 0f, 0.02f); @@ -1497,11 +1527,11 @@ namespace CalamityMod.NPCs.Yharon NPC.ai[1] = Math.Sign((NPC.Center - player.Center).X); Vector2 destination = player.Center + new Vector2(NPC.ai[1], 0); - Vector2 value17 = destination - NPC.Center; - Vector2 vector170 = Vector2.Normalize(value17 - NPC.velocity) * flareBombPhaseVelocity; + Vector2 destinationDist = destination - NPC.Center; + Vector2 flareSpeed = Vector2.Normalize(destinationDist - NPC.velocity) * flareBombPhaseVelocity; if (Vector2.Distance(NPC.Center, destination) > reduceSpeedFlareBombDistance) - NPC.SimpleFlyMovement(vector170, flareBombPhaseAcceleration); + NPC.SimpleFlyMovement(flareSpeed, flareBombPhaseAcceleration); else NPC.velocity *= 0.98f; @@ -1518,10 +1548,10 @@ namespace CalamityMod.NPCs.Yharon } } - int num1476 = Math.Sign(player.Center.X - NPC.Center.X); - if (num1476 != 0) + int playerFaceDirection = Math.Sign(player.Center.X - NPC.Center.X); + if (playerFaceDirection != 0) { - NPC.direction = num1476; + NPC.direction = playerFaceDirection; if (NPC.spriteDirection != -NPC.direction) NPC.rotation += pie; @@ -1572,6 +1602,7 @@ namespace CalamityMod.NPCs.Yharon } NPC.dontTakeDamage = false; + bool invincible = invincibilityCounter < Phase2InvincibilityTime; if (invincible) { @@ -1584,10 +1615,9 @@ namespace CalamityMod.NPCs.Yharon NPC.netUpdate = true; } else - { NPC.life = NPC.lifeMax; - } } + NPC.dontTakeDamage = true; phase2 = phase3 = phase4 = false; invincibilityCounter++; @@ -1652,16 +1682,42 @@ namespace CalamityMod.NPCs.Yharon switch (secondPhasePhase) { case 1: + + if (phase2) + { + // Avoid cheap bullshit + NPC.damage = 0; + } + calamityGlobalNPC.DR = phase2 ? (bossRush ? 0.99f : 0.7f) : normalDR; calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = phase2; + break; + case 2: + + if (phase3) + { + // Avoid cheap bullshit + NPC.damage = 0; + } + calamityGlobalNPC.DR = phase3 ? (bossRush ? 0.99f : 0.7f) : normalDR; calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = phase3; + break; + case 3: + + if (phase4) + { + // Avoid cheap bullshit + NPC.damage = 0; + } + calamityGlobalNPC.DR = phase4 ? (bossRush ? 0.99f : 0.7f) : normalDR; calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = phase4; + break; } @@ -1759,26 +1815,26 @@ namespace CalamityMod.NPCs.Yharon NPC.velocity *= 0.98f; } - int num27 = (NPC.Center.X < targetData.Center.X) ? 1 : -1; - NPC.direction = NPC.spriteDirection = num27; + int spriteDirection = (NPC.Center.X < targetData.Center.X) ? 1 : -1; + NPC.direction = NPC.spriteDirection = spriteDirection; NPC.ai[1] += 1f; if (NPC.ai[1] >= phaseSwitchTimer) { - int num28 = 1; + int phase2AttackType = 1; if (phase4) { switch ((int)NPC.ai[3]) { case 0: - num28 = 8; //teleport + phase2AttackType = 8; //teleport break; case 1: case 2: - num28 = 7; //fast charge + phase2AttackType = 7; //fast charge break; case 3: - num28 = 5; //fire circle + tornado (only once) + fireballs + phase2AttackType = 5; //fire circle + tornado (only once) + fireballs break; } } @@ -1787,52 +1843,52 @@ namespace CalamityMod.NPCs.Yharon switch ((int)NPC.ai[3]) { case 0: - num28 = 6; //tornado + phase2AttackType = 6; //tornado break; case 1: - num28 = 7; //fast charge + phase2AttackType = 7; //fast charge break; case 2: - num28 = 8; //teleport + phase2AttackType = 8; //teleport break; case 3: - num28 = 7; //fast charge + phase2AttackType = 7; //fast charge break; case 4: - num28 = 5; //fire circle + phase2AttackType = 5; //fire circle break; case 5: - num28 = Main.rand.NextBool() ? 3 : 4; //fireballs + phase2AttackType = Main.rand.NextBool() ? 3 : 4; //fireballs break; case 6: - num28 = 7; //fast charge + phase2AttackType = 7; //fast charge break; case 7: - num28 = 8; //teleport + phase2AttackType = 8; //teleport break; case 8: - num28 = 7; //fast charge + phase2AttackType = 7; //fast charge break; case 9: - num28 = Main.rand.NextBool() ? 4 : 3; //fireballs + phase2AttackType = Main.rand.NextBool() ? 4 : 3; //fireballs break; case 10: - num28 = 6; //tornado + phase2AttackType = 6; //tornado break; case 11: - num28 = 7; //fast charge + phase2AttackType = 7; //fast charge break; case 12: - num28 = 8; //teleport + phase2AttackType = 8; //teleport break; case 13: - num28 = 7; //fast charge + phase2AttackType = 7; //fast charge break; case 14: - num28 = 5; //fire circle + phase2AttackType = 5; //fire circle break; case 15: - num28 = Main.rand.NextBool() ? 3 : 4; //fireballs + phase2AttackType = Main.rand.NextBool() ? 3 : 4; //fireballs break; } } @@ -1841,37 +1897,37 @@ namespace CalamityMod.NPCs.Yharon switch ((int)NPC.ai[3]) { case 0: - num28 = 6; //tornado + phase2AttackType = 6; //tornado break; case 1: - num28 = 7; //fast charge + phase2AttackType = 7; //fast charge break; case 2: - num28 = 2; //charge + phase2AttackType = 2; //charge break; case 3: - num28 = 5; //fire circle + phase2AttackType = 5; //fire circle break; case 4: - num28 = Main.rand.NextBool() ? 3 : 4; //fireballs + phase2AttackType = Main.rand.NextBool() ? 3 : 4; //fireballs break; case 5: - num28 = 7; //fast charge + phase2AttackType = 7; //fast charge break; case 6: - num28 = 2; //charge + phase2AttackType = 2; //charge break; case 7: - num28 = Main.rand.NextBool() ? 4 : 3; //fireballs + phase2AttackType = Main.rand.NextBool() ? 4 : 3; //fireballs break; case 8: - num28 = 7; //fast charge + phase2AttackType = 7; //fast charge break; case 9: - num28 = 2; //charge + phase2AttackType = 2; //charge break; case 10: - num28 = 5; //fire circle + phase2AttackType = 5; //fire circle break; } } @@ -1880,33 +1936,33 @@ namespace CalamityMod.NPCs.Yharon switch ((int)NPC.ai[3]) { case 0: - num28 = 6; //tornado + phase2AttackType = 6; //tornado break; case 1: case 2: - num28 = 2; //charge + phase2AttackType = 2; //charge break; case 3: - num28 = Main.rand.NextBool() ? 3 : 4; //fireballs + phase2AttackType = Main.rand.NextBool() ? 3 : 4; //fireballs break; case 4: case 5: - num28 = 7; //fast charge + phase2AttackType = 7; //fast charge break; case 6: - num28 = Main.rand.NextBool() ? 4 : 3; //fireballs + phase2AttackType = Main.rand.NextBool() ? 4 : 3; //fireballs break; case 7: case 8: - num28 = 2; //charge + phase2AttackType = 2; //charge break; case 9: - num28 = 5; //fire circle + phase2AttackType = 5; //fire circle break; } } - if (num28 == 5 && NPC.ai[1] < phaseSwitchTimer + teleportPhaseTimer) + if (phase2AttackType == 5 && NPC.ai[1] < phaseSwitchTimer + teleportPhaseTimer) { NPC.damage = 0; @@ -1969,7 +2025,7 @@ namespace CalamityMod.NPCs.Yharon return; } - if (num28 == 7 && doFastChargeTelegraph) + if (phase2AttackType == 7 && doFastChargeTelegraph) { float newRotation = NPC.AngleTo(targetData.Center); float amount = 0.04f; @@ -1988,7 +2044,7 @@ namespace CalamityMod.NPCs.Yharon return; } - NPC.ai[0] = num28; + NPC.ai[0] = phase2AttackType; NPC.ai[1] = 0f; NPC.ai[2] = 0f; NPC.ai[3] += 1f; @@ -2041,7 +2097,7 @@ namespace CalamityMod.NPCs.Yharon if (NPC.ai[3] >= aiLimit) NPC.ai[3] = 0f; - switch (num28) + switch (phase2AttackType) { case 2: //charge { @@ -2058,9 +2114,9 @@ namespace CalamityMod.NPCs.Yharon } case 3: //fireballs { - Vector2 vector2 = new Vector2((targetData.Center.X > NPC.Center.X) ? 1 : -1, 0f); - NPC.spriteDirection = (vector2.X > 0f) ? 1 : -1; - NPC.velocity = vector2 * -2f; + Vector2 fireSpitFaceDirection = new Vector2((targetData.Center.X > NPC.Center.X) ? 1 : -1, 0f); + NPC.spriteDirection = (fireSpitFaceDirection.X > 0f) ? 1 : -1; + NPC.velocity = fireSpitFaceDirection * -2f; break; } @@ -2111,12 +2167,12 @@ namespace CalamityMod.NPCs.Yharon // Fireball spit charge else if (NPC.ai[0] == 3f) { - int num29 = (NPC.Center.X < targetData.Center.X) ? 1 : -1; + int fireballFaceDirection = (NPC.Center.X < targetData.Center.X) ? 1 : -1; NPC.ai[1] += 1f; if (NPC.ai[1] < fireballBreathTimer) { - Vector2 destination = targetData.Center + new Vector2(num29, 0); + Vector2 destination = targetData.Center + new Vector2(fireballFaceDirection, 0); Vector2 distanceFromDestination = destination - NPC.Center; Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination - NPC.velocity) * velocity; @@ -2128,7 +2184,7 @@ namespace CalamityMod.NPCs.Yharon NPC.velocity *= 0.98f; } - NPC.direction = NPC.spriteDirection = num29; + NPC.direction = NPC.spriteDirection = fireballFaceDirection; if (Vector2.Distance(destination, NPC.Center) < 32f) NPC.ai[1] = fireballBreathTimer - 1f; @@ -2176,35 +2232,35 @@ namespace CalamityMod.NPCs.Yharon // Splitting fireball breath else if (NPC.ai[0] == 4f) { - int num31 = (NPC.Center.X < targetData.Center.X) ? 1 : -1; - NPC.ai[2] = num31; + int splitFireFaceDirection = (NPC.Center.X < targetData.Center.X) ? 1 : -1; + NPC.ai[2] = splitFireFaceDirection; if (NPC.ai[1] < splittingFireballBreathTimer) { - Vector2 vector5 = targetData.Center + new Vector2(num31 * -750f, -300f); - Vector2 value2 = NPC.SafeDirectionTo(vector5) * splittingFireballBreathPhaseVelocity; + Vector2 splitFireDestination = targetData.Center + new Vector2(splitFireFaceDirection * -750f, -300f); + Vector2 splitFireFinalVelocity = NPC.SafeDirectionTo(splitFireDestination) * splittingFireballBreathPhaseVelocity; - NPC.velocity = Vector2.Lerp(NPC.velocity, value2, 0.0333333351f); + NPC.velocity = Vector2.Lerp(NPC.velocity, splitFireFinalVelocity, 0.0333333351f); int direction = (NPC.Center.X < targetData.Center.X) ? 1 : -1; NPC.direction = NPC.spriteDirection = direction; - if (Vector2.Distance(vector5, NPC.Center) < 32f) + if (Vector2.Distance(splitFireDestination, NPC.Center) < 32f) NPC.ai[1] = splittingFireballBreathTimer - 1f; } else if (NPC.ai[1] == splittingFireballBreathTimer) { - Vector2 vector6 = NPC.SafeDirectionTo(targetData.Center, Vector2.UnitX * NPC.spriteDirection); - vector6.Y *= 0.15f; - vector6 = vector6.SafeNormalize(Vector2.UnitX * NPC.direction); + Vector2 yharonFireballMoveDirection = NPC.SafeDirectionTo(targetData.Center, Vector2.UnitX * NPC.spriteDirection); + yharonFireballMoveDirection.Y *= 0.15f; + yharonFireballMoveDirection = yharonFireballMoveDirection.SafeNormalize(Vector2.UnitX * NPC.direction); - NPC.spriteDirection = (vector6.X > 0f) ? 1 : -1; - NPC.rotation = vector6.ToRotation(); + NPC.spriteDirection = (yharonFireballMoveDirection.X > 0f) ? 1 : -1; + NPC.rotation = yharonFireballMoveDirection.ToRotation(); if (NPC.spriteDirection == -1) NPC.rotation += pie; - NPC.velocity = vector6 * splittingFireballBreathPhaseVelocity; + NPC.velocity = yharonFireballMoveDirection * splittingFireballBreathPhaseVelocity; SoundEngine.PlaySound(FireSound, NPC.Center); } else @@ -2214,11 +2270,11 @@ namespace CalamityMod.NPCs.Yharon float xOffset = 30f; Vector2 position = NPC.Center + new Vector2((110f + xOffset) * NPC.direction, -20f).RotatedBy(NPC.rotation); - int num34 = (int)(NPC.ai[1] - splittingFireballBreathTimer + 1f); + int yharonFireballTimer = (int)(NPC.ai[1] - splittingFireballBreathTimer + 1f); int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - if (num34 <= splittingFireballBreathTimer2 && num34 % splittingFireballBreathDivisor == 0 && Main.netMode != NetmodeID.MultiplayerClient) + if (yharonFireballTimer <= splittingFireballBreathTimer2 && yharonFireballTimer % splittingFireballBreathDivisor == 0 && Main.netMode != NetmodeID.MultiplayerClient) Projectile.NewProjectile(NPC.GetSource_FromAI(), position, NPC.velocity, type, damage, 0f, Main.myPlayer, 0f, 0f); } @@ -2307,8 +2363,8 @@ namespace CalamityMod.NPCs.Yharon Vector2 desiredVelocity2 = NPC.SafeDirectionTo(destination2) * velocity * 1.5f; NPC.SimpleFlyMovement(desiredVelocity2, acceleration * 1.5f); - int num35 = (NPC.Center.X < targetData.Center.X) ? 1 : -1; - NPC.direction = NPC.spriteDirection = num35; + int flareRingFaceDirection = (NPC.Center.X < targetData.Center.X) ? 1 : -1; + NPC.direction = NPC.spriteDirection = flareRingFaceDirection; NPC.ai[2] += 1f; if (NPC.Distance(targetData.Center) < 600f || NPC.ai[2] >= 180f) @@ -2380,6 +2436,9 @@ namespace CalamityMod.NPCs.Yharon // Teleport else if (NPC.ai[0] == 8f) { + // Avoid cheap bullshit + NPC.damage = 0; + if (NPC.Opacity > 0f) { NPC.Opacity -= 0.1f; @@ -2417,6 +2476,9 @@ namespace CalamityMod.NPCs.Yharon // Enter new phase else if (NPC.ai[0] == 9f) { + // Avoid cheap bullshit + NPC.damage = 0; + NPC.velocity *= 0.9f; Vector2 vector = NPC.SafeDirectionTo(targetData.Center, -Vector2.UnitY); @@ -2463,8 +2525,8 @@ namespace CalamityMod.NPCs.Yharon } } - float num42 = NPC.AngleTo(targetData.Center); - float num43 = 0.04f; + float facingAngle = NPC.AngleTo(targetData.Center); + float rotationSpeed = 0.04f; switch ((int)NPC.ai[0]) { @@ -2472,54 +2534,54 @@ namespace CalamityMod.NPCs.Yharon case 7: case 8: case 9: - num43 = 0f; + rotationSpeed = 0f; break; case 3: if (NPC.ai[1] >= fireballBreathTimer) - num43 = 0f; + rotationSpeed = 0f; break; case 4: - num43 = 0.01f; - num42 = pie; + rotationSpeed = 0.01f; + facingAngle = pie; if (NPC.spriteDirection == 1) - num42 += pie; + facingAngle += pie; break; case 6: - num43 = 0.02f; - num42 = 0f; + rotationSpeed = 0.02f; + facingAngle = 0f; if (NPC.spriteDirection == -1) - num42 -= pie; + facingAngle -= pie; break; } if (NPC.spriteDirection == -1) - num42 += pie; + facingAngle += pie; - if (num43 != 0f) - NPC.rotation = NPC.rotation.AngleTowards(num42, num43); + if (rotationSpeed != 0f) + NPC.rotation = NPC.rotation.AngleTowards(facingAngle, rotationSpeed); } #endregion #region Charge Dust private void ChargeDust(int dustAmt, float pie) { - for (int num1474 = 0; num1474 < dustAmt; num1474++) + for (int i = 0; i < dustAmt; i++) { - Vector2 vector171 = Vector2.Normalize(NPC.velocity) * new Vector2((NPC.width + 50) / 2f, NPC.height) * 0.75f; - vector171 = vector171.RotatedBy((num1474 - (dustAmt / 2 - 1)) * (double)pie / (float)dustAmt) + NPC.Center; - Vector2 value18 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 244, value18.X * 2f, value18.Y * 2f, 100, default, 1.4f); - Main.dust[num1475].noGravity = true; - Main.dust[num1475].noLight = true; - Main.dust[num1475].velocity /= 4f; - Main.dust[num1475].velocity -= NPC.velocity; + Vector2 dustRotate = Vector2.Normalize(NPC.velocity) * new Vector2((NPC.width + 50) / 2f, NPC.height) * 0.75f; + dustRotate = dustRotate.RotatedBy((i - (dustAmt / 2 - 1)) * (double)pie / (float)dustAmt) + NPC.Center; + Vector2 dustVel = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); + int chargeDust = Dust.NewDust(dustRotate + dustVel, 0, 0, 244, dustVel.X * 2f, dustVel.Y * 2f, 100, default, 1.4f); + Main.dust[chargeDust].noGravity = true; + Main.dust[chargeDust].noLight = true; + Main.dust[chargeDust].velocity /= 4f; + Main.dust[chargeDust].velocity -= NPC.velocity; } } #endregion @@ -2553,8 +2615,8 @@ namespace CalamityMod.NPCs.Yharon for (int i = 0; i < totalProjectiles; i++) { - Vector2 vector2 = spinningPoint.RotatedBy(radians * i) * projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, vector2, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, 2f, 0f); + Vector2 fireSpitFaceDirection = spinningPoint.RotatedBy(radians * i) * projectileVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, fireSpitFaceDirection, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, 2f, 0f); } float newRadialOffset = (int)aiVariableUsed / (timer / 4) % 2f == 0f ? radialOffset : -radialOffset; @@ -2577,8 +2639,8 @@ namespace CalamityMod.NPCs.Yharon float radians = MathHelper.TwoPi / totalProjectiles; for (int i = 0; i < totalProjectiles; i++) { - Vector2 vector255 = new Vector2(0f, -velocity).RotatedBy(radians * i); - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, vector255, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, ai0, ai1); + Vector2 flareRotationAmt = new Vector2(0f, -velocity).RotatedBy(radians * i); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, flareRotationAmt, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, ai0, ai1); Main.projectile[proj].timeLeft = timeLeft; } } @@ -2606,244 +2668,242 @@ namespace CalamityMod.NPCs.Yharon spriteEffects = ai2 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; Texture2D texture = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(texture.Width / 2, texture.Height / Main.npcFrameCount[NPC.type] / 2); + Vector2 halfSizeTexture = new Vector2(texture.Width / 2, texture.Height / Main.npcFrameCount[NPC.type] / 2); Color color = drawColor; Color invincibleColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0); - Color color36 = Color.White; + Color lerpEndColor = Color.White; - float amount9 = 0f; + float lerpInterpolateValue = 0f; bool invincible = ai2 && invincibilityCounter < Phase2InvincibilityTime; - bool flag8 = NPC.ai[0] > 5f; - bool flag9 = NPC.ai[0] > 12f; - bool flag10 = startSecondAI; - int num150 = 120; - int num151 = 60; + bool enteredSubphase2 = NPC.ai[0] > 5f; + bool enteredSubphase3 = NPC.ai[0] > 12f; + bool enteredPhase2 = startSecondAI; + int afterimageTimer = 120; + int afterimageColorDivisor = 60; - if (flag10) + if (enteredPhase2) color = CalamityGlobalNPC.buffColor(color, 0.9f, 0.7f, 0.3f, 1f); - else if (flag9) + else if (enteredSubphase3) color = CalamityGlobalNPC.buffColor(color, 0.8f, 0.7f, 0.4f, 1f); - else if (flag8) + else if (enteredSubphase2) color = CalamityGlobalNPC.buffColor(color, 0.7f, 0.7f, 0.5f, 1f); - else if (NPC.ai[0] == 4f && NPC.ai[2] > num150) + else if (NPC.ai[0] == 4f && NPC.ai[2] > afterimageTimer) { - float num152 = NPC.ai[2] - num150; - num152 /= num151; - color = CalamityGlobalNPC.buffColor(color, 1f - 0.3f * num152, 1f - 0.3f * num152, 1f - 0.5f * num152, 1f); + float buffColorMult = NPC.ai[2] - afterimageTimer; + buffColorMult /= afterimageColorDivisor; + color = CalamityGlobalNPC.buffColor(color, 1f - 0.3f * buffColorMult, 1f - 0.3f * buffColorMult, 1f - 0.5f * buffColorMult, 1f); } - int num153 = 10; - int num154 = 2; + int afterimageAmt = 10; + int afterimageIncrement = 2; if (NPC.ai[0] == -1f) - num153 = 0; + afterimageAmt = 0; if (idlePhases) - num153 = 7; + afterimageAmt = 7; if (invincible) - color36 = invincibleColor; + lerpEndColor = invincibleColor; else if (chargingOrSpawnPhases) { - color36 = Color.Red; - amount9 = 0.5f; + lerpEndColor = Color.Red; + lerpInterpolateValue = 0.5f; } else color = drawColor; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += num154) + for (int i = 1; i < afterimageAmt; i += afterimageIncrement) { - Color color38 = color; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = color; + afterimageColor = Color.Lerp(afterimageColor, lerpEndColor, lerpInterpolateValue); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - int num156 = 0; - float num157 = 0f; - float scaleFactor9 = 0f; + int additionalAfterimageAmt = 0; + float additionalAfterimageOpacity = 0f; + float afterimageScale = 0f; if (NPC.ai[0] == -1f) - num156 = 0; + additionalAfterimageAmt = 0; if (tornadoPhase) { - int num158 = 60; - int num159 = 30; - if (NPC.ai[2] > num158) + if (NPC.ai[2] > 60) { - num156 = 6; - num157 = 1f - (float)Math.Cos((NPC.ai[2] - num158) / num159 * MathHelper.TwoPi); - num157 /= 3f; - scaleFactor9 = 40f; + additionalAfterimageAmt = 6; + additionalAfterimageOpacity = 1f - (float)Math.Cos((NPC.ai[2] - 60) / 30 * MathHelper.TwoPi); + additionalAfterimageOpacity /= 3f; + afterimageScale = 40f; } } - if (newPhasePhase && NPC.ai[2] > num150) + if (newPhasePhase && NPC.ai[2] > afterimageTimer) { - num156 = 6; - num157 = 1f - (float)Math.Cos((NPC.ai[2] - num150) / num151 * MathHelper.TwoPi); - num157 /= 3f; - scaleFactor9 = 60f; + additionalAfterimageAmt = 6; + additionalAfterimageOpacity = 1f - (float)Math.Cos((NPC.ai[2] - afterimageTimer) / afterimageColorDivisor * MathHelper.TwoPi); + additionalAfterimageOpacity /= 3f; + afterimageScale = 60f; } if (pauseAfterTeleportPhase) { - num156 = 6; - num157 = 1f - (float)Math.Cos(NPC.ai[2] / 30f * MathHelper.TwoPi); - num157 /= 3f; - scaleFactor9 = 20f; + additionalAfterimageAmt = 6; + additionalAfterimageOpacity = 1f - (float)Math.Cos(NPC.ai[2] / 30f * MathHelper.TwoPi); + additionalAfterimageOpacity /= 3f; + afterimageScale = 20f; } if (CalamityConfig.Instance.Afterimages) { - for (int num160 = 0; num160 < num156; num160++) + for (int k = 0; k < additionalAfterimageAmt; k++) { - Color color39 = drawColor; - color39 = Color.Lerp(color39, color36, amount9); - color39 = NPC.GetAlpha(color39); - color39 *= 1f - num157; - Vector2 vector42 = NPC.Center + (num160 / (float)num156 * MathHelper.TwoPi + NPC.rotation).ToRotationVector2() * scaleFactor9 * num157 - screenPos; - vector42 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector42 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture, vector42, NPC.frame, color39, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color additionalAfterimageColor = drawColor; + additionalAfterimageColor = Color.Lerp(additionalAfterimageColor, lerpEndColor, lerpInterpolateValue); + additionalAfterimageColor = NPC.GetAlpha(additionalAfterimageColor); + additionalAfterimageColor *= 1f - additionalAfterimageOpacity; + Vector2 additionalAfterimagePos = NPC.Center + (k / (float)additionalAfterimageAmt * MathHelper.TwoPi + NPC.rotation).ToRotationVector2() * afterimageScale * additionalAfterimageOpacity - screenPos; + additionalAfterimagePos -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + additionalAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture, additionalAfterimagePos, NPC.frame, additionalAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture, vector43, NPC.frame, invincible ? invincibleColor : NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture, drawLocation, NPC.frame, invincible ? invincibleColor : NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - if (flag8 || NPC.ai[0] == 4f || startSecondAI) + if (enteredSubphase2 || NPC.ai[0] == 4f || startSecondAI) { texture = ModContent.Request("CalamityMod/NPCs/Yharon/YharonGlowOrange").Value; - Color color40 = Color.Lerp(Color.White, invincible ? invincibleColor : Color.Orange, 0.5f) * NPC.Opacity; - color36 = invincible ? invincibleColor : Color.Orange; + Color orangeGlowColor = Color.Lerp(Color.White, invincible ? invincibleColor : Color.Orange, 0.5f) * NPC.Opacity; + lerpEndColor = invincible ? invincibleColor : Color.Orange; Texture2D texture2 = ModContent.Request("CalamityMod/NPCs/Yharon/YharonGlowGreen").Value; - Color color43 = Color.Lerp(Color.White, invincible ? invincibleColor : Color.Chartreuse, 0.5f) * NPC.Opacity; - Color color44 = invincible ? invincibleColor : Color.Chartreuse; + Color greenGlowColorOpacity = Color.Lerp(Color.White, invincible ? invincibleColor : Color.Chartreuse, 0.5f) * NPC.Opacity; + Color greenGlowColor = invincible ? invincibleColor : Color.Chartreuse; Texture2D texture3 = ModContent.Request("CalamityMod/NPCs/Yharon/YharonGlowPurple").Value; - Color color45 = Color.Lerp(Color.White, invincible ? invincibleColor : Color.BlueViolet, 0.5f) * NPC.Opacity; - Color color46 = invincible ? invincibleColor : Color.BlueViolet; + Color blueGlowColorOpacity = Color.Lerp(Color.White, invincible ? invincibleColor : Color.BlueViolet, 0.5f) * NPC.Opacity; + Color blueGlowColor = invincible ? invincibleColor : Color.BlueViolet; - amount9 = 1f; - num157 = 0.5f; - scaleFactor9 = 10f; - num154 = 1; + lerpInterpolateValue = 1f; + additionalAfterimageOpacity = 0.5f; + afterimageScale = 10f; + afterimageIncrement = 1; if (newPhasePhase) { - float num161 = NPC.ai[2] - num150; - num161 /= num151; - color36 *= num161; - color40 *= num161; + float glowColorAmplifier = NPC.ai[2] - afterimageTimer; + glowColorAmplifier /= afterimageColorDivisor; + lerpEndColor *= glowColorAmplifier; + orangeGlowColor *= glowColorAmplifier; - if (flag9 || NPC.ai[0] == 10f || startSecondAI) + if (enteredSubphase3 || NPC.ai[0] == 10f || startSecondAI) { - color43 *= num161; - color44 *= num161; + greenGlowColorOpacity *= glowColorAmplifier; + greenGlowColor *= glowColorAmplifier; } - if (flag10 || NPC.ai[0] == 17f) + if (enteredPhase2 || NPC.ai[0] == 17f) { - color45 *= num161; - color46 *= num161; + blueGlowColorOpacity *= glowColorAmplifier; + blueGlowColor *= glowColorAmplifier; } } if (pauseAfterTeleportPhase) { - float num162 = NPC.ai[2]; - num162 /= 30f; + float teleportGlowColorScaler = NPC.ai[2]; + teleportGlowColorScaler /= 30f; - if (num162 > 0.5f) - num162 = 1f - num162; + if (teleportGlowColorScaler > 0.5f) + teleportGlowColorScaler = 1f - teleportGlowColorScaler; - num162 *= 2f; - num162 = 1f - num162; - color36 *= num162; - color40 *= num162; - color43 *= num162; - color44 *= num162; - color45 *= num162; - color46 *= num162; + teleportGlowColorScaler *= 2f; + teleportGlowColorScaler = 1f - teleportGlowColorScaler; + lerpEndColor *= teleportGlowColorScaler; + orangeGlowColor *= teleportGlowColorScaler; + greenGlowColorOpacity *= teleportGlowColorScaler; + greenGlowColor *= teleportGlowColorScaler; + blueGlowColorOpacity *= teleportGlowColorScaler; + blueGlowColor *= teleportGlowColorScaler; } if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163 += num154) + for (int l = 1; l < afterimageAmt; l += afterimageIncrement) { - Color color41 = color40; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector44 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color orangeAfterimageColor = orangeGlowColor; + orangeAfterimageColor = Color.Lerp(orangeAfterimageColor, lerpEndColor, lerpInterpolateValue); + orangeAfterimageColor *= (afterimageAmt - l) / 15f; + Vector2 glowmaskAfterimagePos = NPC.oldPos[l] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + glowmaskAfterimagePos -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + glowmaskAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture, glowmaskAfterimagePos, NPC.frame, orangeAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - if (flag9 || NPC.ai[0] == 10f || startSecondAI) + if (enteredSubphase3 || NPC.ai[0] == 10f || startSecondAI) { - Color color47 = color43; - color47 = Color.Lerp(color47, color44, amount9); - color47 *= (num153 - num163) / 15f; - spriteBatch.Draw(texture2, vector44, NPC.frame, color47, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color greenAfterimageColor = greenGlowColorOpacity; + greenAfterimageColor = Color.Lerp(greenAfterimageColor, greenGlowColor, lerpInterpolateValue); + greenAfterimageColor *= (afterimageAmt - l) / 15f; + spriteBatch.Draw(texture2, glowmaskAfterimagePos, NPC.frame, greenAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } - if (flag10 || NPC.ai[0] == 17f) + if (enteredPhase2 || NPC.ai[0] == 17f) { - Color color48 = color45; - color48 = Color.Lerp(color48, color46, amount9); - color48 *= (num153 - num163) / 15f; - spriteBatch.Draw(texture3, vector44, NPC.frame, color48, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color blueAfterimageColor = blueGlowColorOpacity; + blueAfterimageColor = Color.Lerp(blueAfterimageColor, blueGlowColor, lerpInterpolateValue); + blueAfterimageColor *= (afterimageAmt - l) / 15f; + spriteBatch.Draw(texture3, glowmaskAfterimagePos, NPC.frame, blueAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - for (int num164 = 1; num164 < num156; num164++) + for (int m = 1; m < additionalAfterimageAmt; m++) { - Color color42 = color40; - color42 = Color.Lerp(color42, color36, amount9); - color42 = NPC.GetAlpha(color42); - color42 *= 1f - num157; - Vector2 vector45 = NPC.Center + (num164 / (float)num156 * MathHelper.TwoPi + NPC.rotation).ToRotationVector2() * scaleFactor9 * num157 - screenPos; - vector45 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector45 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture, vector45, NPC.frame, color42, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color additionalOrangeColor = orangeGlowColor; + additionalOrangeColor = Color.Lerp(additionalOrangeColor, lerpEndColor, lerpInterpolateValue); + additionalOrangeColor = NPC.GetAlpha(additionalOrangeColor); + additionalOrangeColor *= 1f - additionalAfterimageOpacity; + Vector2 additionalGlowmaskPos = NPC.Center + (m / (float)additionalAfterimageAmt * MathHelper.TwoPi + NPC.rotation).ToRotationVector2() * afterimageScale * additionalAfterimageOpacity - screenPos; + additionalGlowmaskPos -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + additionalGlowmaskPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture, additionalGlowmaskPos, NPC.frame, additionalOrangeColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - if (flag9 || NPC.ai[0] == 10f || startSecondAI) + if (enteredSubphase3 || NPC.ai[0] == 10f || startSecondAI) { - Color color49 = color43; - color49 = Color.Lerp(color49, color44, amount9); - color49 = NPC.GetAlpha(color49); - color49 *= 1f - num157; - spriteBatch.Draw(texture2, vector45, NPC.frame, color49, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color additionalGreenColor = greenGlowColorOpacity; + additionalGreenColor = Color.Lerp(additionalGreenColor, greenGlowColor, lerpInterpolateValue); + additionalGreenColor = NPC.GetAlpha(additionalGreenColor); + additionalGreenColor *= 1f - additionalAfterimageOpacity; + spriteBatch.Draw(texture2, additionalGlowmaskPos, NPC.frame, additionalGreenColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } - if (flag10 || NPC.ai[0] == 17f) + if (enteredPhase2 || NPC.ai[0] == 17f) { - Color color50 = color45; - color50 = Color.Lerp(color50, color46, amount9); - color50 = NPC.GetAlpha(color50); - color50 *= 1f - num157; - spriteBatch.Draw(texture3, vector45, NPC.frame, color50, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color additionalBlueColor = blueGlowColorOpacity; + additionalBlueColor = Color.Lerp(additionalBlueColor, blueGlowColor, lerpInterpolateValue); + additionalBlueColor = NPC.GetAlpha(additionalBlueColor); + additionalBlueColor *= 1f - additionalAfterimageOpacity; + spriteBatch.Draw(texture3, additionalGlowmaskPos, NPC.frame, additionalBlueColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } } - spriteBatch.Draw(texture, vector43, NPC.frame, color40, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, drawLocation, NPC.frame, orangeGlowColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - if (flag9 || NPC.ai[0] == 10f || startSecondAI) - spriteBatch.Draw(texture2, vector43, NPC.frame, color43, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + if (enteredSubphase3 || NPC.ai[0] == 10f || startSecondAI) + spriteBatch.Draw(texture2, drawLocation, NPC.frame, greenGlowColorOpacity, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - if (flag10 || NPC.ai[0] == 17f) - spriteBatch.Draw(texture3, vector43, NPC.frame, color45, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + if (enteredPhase2 || NPC.ai[0] == 17f) + spriteBatch.Draw(texture3, drawLocation, NPC.frame, blueGlowColorOpacity, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } return false; @@ -2898,7 +2958,7 @@ namespace CalamityMod.NPCs.Yharon // He is the dragon of rebirth afterall var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ModContent.ItemType()); + GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); } // Lore @@ -3021,13 +3081,13 @@ namespace CalamityMod.NPCs.Yharon if (idlePhases) { - int num84 = 5; + int frameTimer = 5; if (!startSecondAI && (NPC.ai[0] == 6f || NPC.ai[0] == 13f)) { - num84 = 4; + frameTimer = 4; } NPC.frameCounter += 1D; - if (NPC.frameCounter > num84) + if (NPC.frameCounter > frameTimer) { NPC.frameCounter = 0D; NPC.frame.Y += frameHeight; @@ -3046,8 +3106,8 @@ namespace CalamityMod.NPCs.Yharon if (tornadoPhase) { - int num85 = 90; - if (NPC.ai[2] < num85 - 30 || NPC.ai[2] > num85 - 10) + int tornadoFrameTimer = 90; + if (NPC.ai[2] < tornadoFrameTimer - 30 || NPC.ai[2] > tornadoFrameTimer - 10) { NPC.frameCounter += 1D; if (NPC.frameCounter > 5D) @@ -3063,7 +3123,7 @@ namespace CalamityMod.NPCs.Yharon else { NPC.frame.Y = frameHeight * 5; - if (NPC.ai[2] > num85 - 20 && NPC.ai[2] < num85 - 15) + if (NPC.ai[2] > tornadoFrameTimer - 20 && NPC.ai[2] < tornadoFrameTimer - 15) { NPC.frame.Y = frameHeight * 6; } @@ -3072,8 +3132,8 @@ namespace CalamityMod.NPCs.Yharon if (newPhasePhase) { - int num86 = 180; - if (NPC.ai[2] < num86 - 60 || NPC.ai[2] > num86 - 20) + int newPhaseFrameTimer = 180; + if (NPC.ai[2] < newPhaseFrameTimer - 60 || NPC.ai[2] > newPhaseFrameTimer - 20) { NPC.frameCounter += 1D; if (NPC.frameCounter > 5D) @@ -3089,7 +3149,7 @@ namespace CalamityMod.NPCs.Yharon else { NPC.frame.Y = frameHeight * 5; - if (NPC.ai[2] > num86 - 50 && NPC.ai[2] < num86 - 25) + if (NPC.ai[2] > newPhaseFrameTimer - 50 && NPC.ai[2] < newPhaseFrameTimer - 25) { NPC.frame.Y = frameHeight * 6; } @@ -3121,23 +3181,23 @@ namespace CalamityMod.NPCs.Yharon NPC.height = 280; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int fieryDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[fieryDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[fieryDust].scale = 0.5f; + Main.dust[fieryDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 244, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int fieryDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 244, 0f, 0f, 100, default, 3f); + Main.dust[fieryDust2].noGravity = true; + Main.dust[fieryDust2].velocity *= 5f; + fieryDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[fieryDust2].velocity *= 2f; } // Turn into dust on death. diff --git a/Particles/AltLineParticle.cs b/Particles/AltLineParticle.cs new file mode 100644 index 0000000000..5dfd32e142 --- /dev/null +++ b/Particles/AltLineParticle.cs @@ -0,0 +1,51 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class AltLineParticle : Particle + { + public Color InitialColor; + public bool AffectedByGravity; + public override bool SetLifetime => true; + public override bool UseCustomDraw => true; + public override bool UseAdditiveBlend => false; + + public override string Texture => "CalamityMod/Particles/DrainLine"; + + public AltLineParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color) + { + Position = relativePosition; + Velocity = velocity; + AffectedByGravity = affectedByGravity; + Scale = scale; + Lifetime = lifetime; + Color = InitialColor = color; + } + + public override void Update() + { + Scale *= 0.95f; + Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)); + Velocity *= 0.95f; + if (Velocity.Length() < 12f && AffectedByGravity) + { + Velocity.X *= 0.94f; + Velocity.Y += 0.25f; + } + Rotation = Velocity.ToRotation() + MathHelper.PiOver2; + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Vector2 scale = new Vector2(0.5f, 1.6f) * Scale; + Texture2D texture = ModContent.Request(Texture).Value; + + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale, 0, 0f); + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale * new Vector2(0.45f, 1f), 0, 0f); + } + } +} diff --git a/Particles/AltSparkParticle.cs b/Particles/AltSparkParticle.cs new file mode 100644 index 0000000000..24fd3ec6c8 --- /dev/null +++ b/Particles/AltSparkParticle.cs @@ -0,0 +1,51 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class AltSparkParticle : Particle + { + public Color InitialColor; + public bool AffectedByGravity; + public override bool SetLifetime => true; + public override bool UseCustomDraw => true; + public override bool UseAdditiveBlend => false; + + public override string Texture => "CalamityMod/Projectiles/StarProj"; + + public AltSparkParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color) + { + Position = relativePosition; + Velocity = velocity; + AffectedByGravity = affectedByGravity; + Scale = scale; + Lifetime = lifetime; + Color = InitialColor = color; + } + + public override void Update() + { + Scale *= 0.95f; + Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)); + Velocity *= 0.95f; + if (Velocity.Length() < 12f && AffectedByGravity) + { + Velocity.X *= 0.94f; + Velocity.Y += 0.25f; + } + Rotation = Velocity.ToRotation() + MathHelper.PiOver2; + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Vector2 scale = new Vector2(0.5f, 1.6f) * Scale; + Texture2D texture = ModContent.Request(Texture).Value; + + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale, 0, 0f); + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale * new Vector2(0.45f, 1f), 0, 0f); + } + } +} diff --git a/Particles/DeathAshParticle.cs b/Particles/DeathAshParticle.cs index 4c0225a57c..8e4464b4b2 100644 --- a/Particles/DeathAshParticle.cs +++ b/Particles/DeathAshParticle.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Graphics; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; @@ -10,7 +11,7 @@ namespace CalamityMod.Particles { public class DeathAshParticle { - internal static Dictionary PendingNPCsToDraw = new Dictionary(); + internal static Dictionary PendingNPCsToDraw = new(); internal static BasicEffect basicShader = null; internal static VertexPositionColorTexture[] VertexCache = new VertexPositionColorTexture[PrimitiveBatchSize * 4]; internal static short[] IndexCache = new short[PrimitiveBatchSize * 6]; @@ -89,7 +90,7 @@ namespace CalamityMod.Particles if (Main.netMode == NetmodeID.Server) return; - PendingNPCsToDraw[npc] = new RenderTarget2D(Main.instance.GraphicsDevice, Main.screenWidth, Main.screenHeight); + PendingNPCsToDraw[npc] = new(true, ManagedRenderTarget.CreateScreenSizedTarget); } public static Dictionary GetColorCacheFromTexture(Texture2D texture, Rectangle? frame = null, bool pruneForEfficency = false) @@ -137,7 +138,7 @@ namespace CalamityMod.Particles foreach (NPC npc in PendingNPCsToDraw.Keys) { - RenderTarget2D temporaryTextureDrawTarget = PendingNPCsToDraw[npc]; + RenderTarget2D temporaryTextureDrawTarget = PendingNPCsToDraw[npc].Target; Rectangle frame = new Rectangle(0, 0, temporaryTextureDrawTarget.Width, temporaryTextureDrawTarget.Height); Dictionary colorsOnNPC = GetColorCacheFromTexture(temporaryTextureDrawTarget, frame, true); diff --git a/Particles/DetailedExplosion.cs b/Particles/DetailedExplosion.cs new file mode 100644 index 0000000000..cee0d32038 --- /dev/null +++ b/Particles/DetailedExplosion.cs @@ -0,0 +1,57 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Particles +{ + public class DetailedExplosion : Particle + { + public override string Texture => "CalamityMod/Particles/DetailedExplosion"; + public bool UseAltVisual = true; + public override bool UseAdditiveBlend => UseAltVisual; + public override bool SetLifetime => true; + public override bool UseCustomDraw => true; + + private float OriginalScale; + private float FinalScale; + private float opacity; + private Vector2 Squish; + private Color BaseColor; + + public DetailedExplosion(Vector2 position, Vector2 velocity, Color color, Vector2 squish, float rotation, float originalScale, float finalScale, int lifeTime, bool UseAdditiveBlend = true) + { + Position = position; + Velocity = velocity; + BaseColor = color; + OriginalScale = originalScale; + FinalScale = finalScale; + Scale = originalScale; + Lifetime = lifeTime; + Squish = squish; + Rotation = rotation; + UseAltVisual = UseAdditiveBlend; + } + + public override void Update() + { + float pulseProgress = PiecewiseAnimation(LifetimeCompletion, new CurveSegment[] { new CurveSegment(EasingType.PolyOut, 0f, 0f, 1f, 4) }); + Scale = MathHelper.Lerp(OriginalScale, FinalScale, pulseProgress); + + opacity = (float)Math.Sin(MathHelper.PiOver2 + LifetimeCompletion * MathHelper.PiOver2); + + Color = BaseColor * opacity; + Lighting.AddLight(Position, Color.R / 255f, Color.G / 255f, Color.B / 255f); + Velocity *= 0.95f; + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D tex = ModContent.Request(Texture).Value; + spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color * opacity, Rotation, tex.Size() / 2f, Scale * Squish, SpriteEffects.None, 0); + } + + } +} diff --git a/Particles/DetailedExplosion.png b/Particles/DetailedExplosion.png new file mode 100644 index 0000000000..f2b4c369ba Binary files /dev/null and b/Particles/DetailedExplosion.png differ diff --git a/Particles/FlameParticle.cs b/Particles/FlameParticle.cs index 128a7e2286..7acd1586aa 100644 --- a/Particles/FlameParticle.cs +++ b/Particles/FlameParticle.cs @@ -5,10 +5,9 @@ namespace CalamityMod.Particles { public class FlameParticle : Particle { - public override string Texture => "CalamityMod/Particles/Fire"; + public override string Texture => "CalamityMod/Particles/Flames"; public override bool UseAdditiveBlend => true; public override bool SetLifetime => true; - public override int FrameVariants => 3; public float RelativePower; @@ -34,6 +33,7 @@ namespace CalamityMod.Particles { Scale += RelativePower * 0.01f; Position.Y -= RelativePower * 1.25f; + Scale *= 0.97f; Color = Color.Lerp(BrightColor, DarkColor, LifetimeCompletion); Color = Color.Lerp(Color, Color.White, Utils.GetLerpValue(0.1f, 0.25f, LifetimeCompletion, true) * Utils.GetLerpValue(0.4f, 0.25f, LifetimeCompletion, true) * 0.7f); diff --git a/Particles/Flames.png b/Particles/Flames.png new file mode 100644 index 0000000000..4a07c0f9e1 Binary files /dev/null and b/Particles/Flames.png differ diff --git a/Particles/GeneralParticleHandler.cs b/Particles/GeneralParticleHandler.cs index 537f172369..6c340cebe1 100644 --- a/Particles/GeneralParticleHandler.cs +++ b/Particles/GeneralParticleHandler.cs @@ -178,7 +178,7 @@ namespace CalamityMod.Particles if (batchedAdditiveBlendParticles.Count > 0) { - rasterizer = Main.Rasterizer; + rasterizer = RasterizerState.CullNone; rasterizer.ScissorTestEnable = true; Main.instance.GraphicsDevice.RasterizerState.ScissorTestEnable = true; Main.instance.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, Main.screenWidth, Main.screenHeight); diff --git a/Particles/GenericBloom.cs b/Particles/GenericBloom.cs index 9cd4d2b52b..52ca597791 100644 --- a/Particles/GenericBloom.cs +++ b/Particles/GenericBloom.cs @@ -9,14 +9,15 @@ namespace CalamityMod.Particles public class GenericBloom : Particle { public override string Texture => "CalamityMod/Particles/Light"; - public override bool UseAdditiveBlend => true; + public bool UseAltVisual = true; + public override bool UseAdditiveBlend => UseAltVisual; public override bool SetLifetime => true; private float opacity; private Color BaseColor; private bool ProduceLight; - public GenericBloom(Vector2 position, Vector2 velocity, Color color, float scale, int lifeTime, bool produceLight = true) + public GenericBloom(Vector2 position, Vector2 velocity, Color color, float scale, int lifeTime, bool produceLight = true, bool AddativeBlend = true) { Position = position; Velocity = velocity; @@ -25,6 +26,7 @@ namespace CalamityMod.Particles Lifetime = lifeTime; Rotation = Main.rand.NextFloat(MathHelper.TwoPi); ProduceLight = produceLight; + UseAltVisual = AddativeBlend; } public override void Update() diff --git a/Particles/LineParticle.cs b/Particles/LineParticle.cs new file mode 100644 index 0000000000..77eb2a91b3 --- /dev/null +++ b/Particles/LineParticle.cs @@ -0,0 +1,51 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class LineParticle : Particle + { + public Color InitialColor; + public bool AffectedByGravity; + public override bool SetLifetime => true; + public override bool UseCustomDraw => true; + public override bool UseAdditiveBlend => true; + + public override string Texture => "CalamityMod/Particles/DrainLineBloom"; + + public LineParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color) + { + Position = relativePosition; + Velocity = velocity; + AffectedByGravity = affectedByGravity; + Scale = scale; + Lifetime = lifetime; + Color = InitialColor = color; + } + + public override void Update() + { + Scale *= 0.95f; + Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)); + Velocity *= 0.95f; + if (Velocity.Length() < 12f && AffectedByGravity) + { + Velocity.X *= 0.94f; + Velocity.Y += 0.25f; + } + Rotation = Velocity.ToRotation() + MathHelper.PiOver2; + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Vector2 scale = new Vector2(0.5f, 1.6f) * Scale; + Texture2D texture = ModContent.Request(Texture).Value; + + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale, 0, 0f); + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale * new Vector2(0.45f, 1f), 0, 0f); + } + } +} diff --git a/Particles/Metaballs/BaseFusableParticleSet.cs b/Particles/Metaballs/BaseFusableParticleSet.cs deleted file mode 100644 index e1c43e51dc..0000000000 --- a/Particles/Metaballs/BaseFusableParticleSet.cs +++ /dev/null @@ -1,113 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using System.Collections.Generic; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; - -namespace CalamityMod.Particles.Metaballs -{ - public abstract class BaseFusableParticleSet - { - public class FusableParticleRenderCollection - { - public BaseFusableParticleSet ParticleSet; - public List BackgroundTargets; - public FusableParticleRenderCollection(BaseFusableParticleSet set, List backgroundTargets) - { - ParticleSet = set; - BackgroundTargets = backgroundTargets; - } - } - - public class FusableParticle - { - public Vector2 Center; - public float Size; - public Vector2 TopLeft => Center + new Vector2(-1f, -1f) * Size * 0.5f; - public Vector2 TopRight => Center + new Vector2(1f, -1f) * Size * 0.5f; - public Vector2 BottomLeft => Center + new Vector2(-1f, 1f) * Size * 0.5f; - public Vector2 BottomRight => Center + new Vector2(1f, 1f) * Size * 0.5f; - - public FusableParticle(Vector2 center, float size) - { - Center = center; - Size = size; - } - } - - public int LayerCount - { - get - { - // Not doing this will result in inevitable crashes down the line as the graphics engine fails. - if (BackgroundShaders.Count != BackgroundTextures.Count) - throw new InvalidOperationException("The number of texture maps and shaders are not equivalent."); - - return BackgroundShaders.Count; - } - } - - internal List DrawDataBuffer = new(); - - public List Particles = new(); - - public FusableParticleRenderCollection RenderCollection => FusableParticleManager.GetParticleRenderCollectionByType(GetType()); - - public List GetBackgroundTargets => RenderCollection.BackgroundTargets; - - public void PrepareSpecialDrawingForNextFrame(params DrawData[] drawContents) => DrawDataBuffer.AddRange(drawContents); - public virtual float BorderSize => 0f; - public virtual bool BorderShouldBeSolid => false; - public virtual Color BorderColor => Color.Transparent; - public virtual void PrepareOptionalShaderData(Effect effect, int index) { } - public abstract List BackgroundShaders { get; } - public abstract List BackgroundTextures { get; } - public abstract FusableParticle SpawnParticle(Vector2 center, float sizeStrength); - public abstract void UpdateBehavior(FusableParticle particle); - public abstract void DrawParticles(); - - /// - /// Temporarily moves from the backbuffer to a specialized render target, draws all particles, and caches the resulting render target for drawing later. - /// - internal void PrepareRenderTargetForDrawing() - { - // Don't bother doing anything if this method is called serverside. - if (Main.netMode == NetmodeID.Server) - return; - - // Don't bother doing anything if the set has no particles to render at the moment, for the sake of optimization. - if (Particles.Count <= 0) - return; - - // Go through each background render target in the set and clear the entire thing to use a base of transparent pixels. - foreach (RenderTarget2D backgroundTarget in GetBackgroundTargets) - { - Main.instance.GraphicsDevice.SetRenderTarget(backgroundTarget); - Main.instance.GraphicsDevice.Clear(Color.Transparent); - - // Clear away any particles that shouldn't exist anymore. - Particles.RemoveAll(p => p.Size <= 5f); - - // Prepare the sprite batch for specialized drawing in prepration that the graphics device will draw to new render targets. - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.EffectMatrix); - - // Draw the surviving particles. - DrawParticles(); - - // Draw all special contents in the draw buffer before clearing it. - foreach (DrawData drawData in DrawDataBuffer) - drawData.Draw(Main.spriteBatch); - - Main.spriteBatch.End(); - } - - // Clear the special draw data buffer. - DrawDataBuffer.Clear(); - - // Return to using the backbuffer after done drawing everything to the background targets. - Main.instance.GraphicsDevice.SetRenderTarget(null); - } - } -} diff --git a/Particles/Metaballs/FusableParticleManager.cs b/Particles/Metaballs/FusableParticleManager.cs deleted file mode 100644 index 0a689c6a03..0000000000 --- a/Particles/Metaballs/FusableParticleManager.cs +++ /dev/null @@ -1,231 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -using static CalamityMod.Particles.Metaballs.BaseFusableParticleSet; - -namespace CalamityMod.Particles.Metaballs -{ - // NOTE: A lot of the functionalities within this system cannot under really any circumstance be used serverside. - // This system is entirely visual. However, servers do not have drawing capabilities, nor even a proper GraphicsDevice - // instance. This system utilizes many things that require both of these things, such as shaders and render targets. - // As such, it is littered with many netMode checks. While some may be overprotective in their nature it is critical that - // failsafes exist there, as visual failures tend to result in engine crashes, which will kill a lot of MP servers. - // If someone other than me for any reason attempts to notably expand upon this system you must keep this in mind. -Dominic - - // TODO -- This can be made into a ModSystem. Its main thread load dependency with render targets is safe to put in OnModLoad. - public static class FusableParticleManager - { - internal static List ParticleSets = new(); - internal static List ExtraModsToLoadSetsFrom = new(); - internal static List ParticleSetTypes = new(); - internal static bool HasBeenFormallyDefined = false; - - /// - /// Loads all render sets. - /// - internal static void LoadParticleRenderSets(bool reload = false, int width = -1, int height = -1) - { - // Don't attempt to prepare anything serverside. - if (Main.netMode == NetmodeID.Server) - return; - - // Use fallbacks for width and height based on the screen. - if (width == -1 || height == -1) - { - width = Main.screenWidth; - height = Main.screenHeight; - } - - // Otherwise, if a width and height are defined, but they are the exact same as the screen bounds, - // do nothing. This indicates that the render targets already have the correct size and re-initailizing would be unnecessary. - else if (width == Main.screenWidth && height == Main.screenHeight) - return; - - // Redefine the particle set list in case the mod was reloaded and this field was nullified during that. - // This does not happen during reloads, as that would delete particles outside of load-time. - if (!reload) - { - ParticleSets = new(); - ParticleSetTypes = new(); - ExtraModsToLoadSetsFrom = new(); - HasBeenFormallyDefined = true; - - FindParticleSetTypesInMod(CalamityMod.Instance, width, height); - foreach (Mod m in ExtraModsToLoadSetsFrom) - FindParticleSetTypesInMod(m, width, height); - } - else - { - DisposeOfOldRenderTargets(); - foreach (Type t in ParticleSetTypes) - CreateParticleSetOfType(t, width, height); - } - } - - internal static void FindParticleSetTypesInMod(Mod mod, int width, int height) - { - // Look through every type in the mod, and check if it's derived from BaseFusableParticleSet. - // If it is, create a default instance of said particle, save it, and create a RenderTarget2D for each individual texture/shader. - foreach (Type type in mod.Code.GetTypes()) - { - // Don't load abstract classes; they cannot have instances. - if (type.IsAbstract) - continue; - - if (type.IsSubclassOf(typeof(BaseFusableParticleSet))) - ParticleSetTypes.Add(type); - } - } - - internal static void CreateParticleSetOfType(Type t, int width, int height) - { - BaseFusableParticleSet instance = Activator.CreateInstance(t) as BaseFusableParticleSet; - List backgroundTargets = new List(); - - // Only generate render targets to use if this isn't called serverside. - if (Main.netMode != NetmodeID.Server) - { - for (int i = 0; i < instance.LayerCount; i++) - backgroundTargets.Add(new RenderTarget2D(Main.instance.GraphicsDevice, width, height, false, default, default, 0, RenderTargetUsage.PreserveContents)); - } - - FusableParticleRenderCollection particleRenderCollection = new FusableParticleRenderCollection(instance, backgroundTargets); - ParticleSets.Add(particleRenderCollection); - } - - internal static void CreateParticleSetOfType(int width, int height) where T : BaseFusableParticleSet => - CreateParticleSetOfType(typeof(T), width, height); - - internal static void DisposeOfOldRenderTargets() - { - // Go through each render collection and manually clear away any render targets. - foreach (FusableParticleRenderCollection particleRenderSet in ParticleSets) - { - foreach (RenderTarget2D target in particleRenderSet.BackgroundTargets) - target?.Dispose(); - } - ParticleSets.RemoveAll(p => p.BackgroundTargets.Any(b => b.IsDisposed)); - } - - /// - /// Unloads all render sets, disposing any created s in the process. - /// - internal static void UnloadParticleRenderSets() - { - DisposeOfOldRenderTargets(); - - foreach (FusableParticleRenderCollection particleRenderSet in ParticleSets) - particleRenderSet.ParticleSet = null; - - HasBeenFormallyDefined = false; - ParticleSets = null; - ExtraModsToLoadSetsFrom = null; - ParticleSetTypes = null; - } - - /// - /// Prepares the render targets of each cached instance in advance. - /// - internal static void PrepareFusableParticleTargets() - { - // Don't attempt to prepare anything serverside, if the particle sets are unloaded, or if on the menu. - if (Main.netMode == NetmodeID.Server || ParticleSets is null || Main.gameMenu) - return; - - // Prepare the render target for all fusable particles. - for (int i = 0; i < ParticleSets.Count; i++) - ParticleSets[i].ParticleSet.PrepareRenderTargetForDrawing(); - } - - /// - /// Renders each cached instance with its connecting shader. - /// - internal static void RenderAllFusableParticles() - { - // Don't attempt to render anything serverside or on the menu. - if (Main.netMode == NetmodeID.Server || Main.gameMenu) - return; - - for (int i = 0; i < ParticleSets.Count; i++) - { - BaseFusableParticleSet particleSet = ParticleSets[i].ParticleSet; - - // Don't bother rendering if the set has no particles to render at the moment, for the sake of optimization. - if (particleSet.Particles.Count <= 0) - continue; - - List backgroundTargets = particleSet.GetBackgroundTargets; - - // Restart the sprite batch. This must be done with an immediate sort mode since a shader is going to be applied. - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - - for (int j = 0; j < particleSet.LayerCount; j++) - { - Effect shader = particleSet.BackgroundShaders[j]; - Texture2D backgroundTexture = particleSet.BackgroundTextures[j]; - - // Draw the current target with the specified shader. - shader.Parameters["edgeBorderSize"].SetValue(particleSet.BorderSize); - shader.Parameters["borderShouldBeSolid"].SetValue(particleSet.BorderShouldBeSolid); - shader.Parameters["edgeBorderColor"].SetValue(particleSet.BorderColor.ToVector3()); - shader.Parameters["screenArea"].SetValue(new Vector2(Main.screenWidth, Main.screenHeight) / Main.GameViewMatrix.Zoom); - shader.Parameters["screenMoveOffset"].SetValue(Main.screenPosition - Main.screenLastPosition); - shader.Parameters["uWorldPosition"].SetValue(Main.screenPosition); - shader.Parameters["renderTargetArea"].SetValue(new Vector2(backgroundTargets[j].Width, backgroundTargets[j].Height)); - shader.Parameters["invertedScreen"].SetValue(Main.LocalPlayer.gravDir == -1f); - shader.Parameters["upscaleFactor"].SetValue(Vector2.One); - shader.Parameters["generalBackgroundOffset"].SetValue(Vector2.Zero); - - // Prepare the background texture for loading. - Main.graphics.GraphicsDevice.Textures[1] = backgroundTexture; - shader.Parameters["uImageSize1"].SetValue(backgroundTexture.Size()); - - // Do any optional shader operations prior to applying the shader. - particleSet.PrepareOptionalShaderData(shader, j); - - // Apply the shader. This is what is used to connect separated blobs together. - shader.CurrentTechnique.Passes[0].Apply(); - - // And draw the particle set's render target with said shader. - Main.spriteBatch.Draw(backgroundTargets[j], Vector2.Zero, Color.White); - } - - Main.spriteBatch.End(); - } - } - - /// - /// Obtains the instance from a given if it is a . - /// - /// The type to check. - internal static FusableParticleRenderCollection GetParticleRenderCollectionByType(Type type) - { - if (Main.netMode == NetmodeID.Server) - return null; - - return ParticleSets.First(s => s.ParticleSet.GetType() == type); - } - - /// - /// Obtains the cached singleton instance of a given . - /// - /// The type to check. - public static T GetParticleSetByType() where T : BaseFusableParticleSet - { - if (Main.netMode == NetmodeID.Server) - return null; - - // Reload particle sets if they are completely unloaded for some reason. - if (ParticleSets.Count <= 0) - LoadParticleRenderSets(true); - - return ParticleSets.First(s => s.ParticleSet.GetType() == typeof(T)).ParticleSet as T; - } - } -} diff --git a/Particles/Metaballs/GruesomeEminenceParticleSet.cs b/Particles/Metaballs/GruesomeEminenceParticleSet.cs deleted file mode 100644 index f72b74a650..0000000000 --- a/Particles/Metaballs/GruesomeEminenceParticleSet.cs +++ /dev/null @@ -1,97 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using System.Collections.Generic; -using System.Linq; -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ModLoader; - -namespace CalamityMod.Particles.Metaballs -{ - public class GruesomeEminenceParticleSet : BaseFusableParticleSet - { - public override float BorderSize => 3f; - public override bool BorderShouldBeSolid => false; - public override Color BorderColor => Color.Lerp(Color.Fuchsia, Color.Black, 0.55f) * 0.85f; - - public override List BackgroundShaders => new() - { - GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, - GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, - GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, - GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, - GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, - }; - public override List BackgroundTextures => new() - { - ModContent.Request("CalamityMod/Particles/Metaballs/GruesomeEminence_Ghost_Layer1").Value, - ModContent.Request("CalamityMod/Particles/Metaballs/GruesomeEminence_Ghost_Layer2").Value, - ModContent.Request("CalamityMod/Particles/Metaballs/GruesomeEminence_Ghost_Layer3").Value, - ModContent.Request("CalamityMod/Particles/Metaballs/GruesomeEminence_Ghost_Layer4").Value, - ModContent.Request("CalamityMod/Particles/Metaballs/GruesomeEminence_Ghost_Layer5").Value, - }; - public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) - { - Particles.Add(new FusableParticle(center, sizeStrength)); - return Particles.Last(); - } - - public override void UpdateBehavior(FusableParticle particle) - { - particle.Size = MathHelper.Clamp(particle.Size - 2.5f, 0f, 400f) * 0.97f; - } - - public override void PrepareOptionalShaderData(Effect effect, int index) - { - switch (index) - { - // Background. - case 0: - Vector2 offset = Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.03f; - effect.Parameters["generalBackgroundOffset"].SetValue(offset); - break; - - // Gaseous skulls. - case 1: - offset = Vector2.One * (float)Math.Cos(Main.GlobalTimeWrappedHourly * 0.041f) * 2f; - offset = offset.RotatedBy((float)Math.Cos(Main.GlobalTimeWrappedHourly * 0.08f) * 0.97f); - effect.Parameters["generalBackgroundOffset"].SetValue(offset); - break; - - // Spooky faces 1. - case 2: - offset = (Main.GlobalTimeWrappedHourly * 2.02f).ToRotationVector2() * 0.036f; - offset.Y += (float)Math.Cos(Main.GlobalTimeWrappedHourly * 0.161f) * 0.5f + 0.5f; - effect.Parameters["generalBackgroundOffset"].SetValue(offset); - break; - - // Spooky faces 2. - case 3: - offset = Vector2.UnitX * Main.GlobalTimeWrappedHourly * -0.04f + (Main.GlobalTimeWrappedHourly * 1.89f).ToRotationVector2() * 0.03f; - offset.Y += CalamityUtils.PerlinNoise2D(Main.GlobalTimeWrappedHourly * 0.187f, Main.GlobalTimeWrappedHourly * 0.193f, 2, 466920161) * 0.025f; - effect.Parameters["generalBackgroundOffset"].SetValue(offset); - break; - - // Spooky faces 3. - case 4: - offset = Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.037f + (Main.GlobalTimeWrappedHourly * 1.77f).ToRotationVector2() * 0.04725f; - offset.Y += CalamityUtils.PerlinNoise2D(Main.GlobalTimeWrappedHourly * 0.187f, Main.GlobalTimeWrappedHourly * 0.193f, 2, 577215664) * 0.05f; - effect.Parameters["generalBackgroundOffset"].SetValue(offset); - break; - } - } - - public override void DrawParticles() - { - Texture2D fusableParticleBase = ModContent.Request("CalamityMod/Particles/Metaballs/FusableParticleBase").Value; - foreach (FusableParticle particle in Particles) - { - Vector2 drawPosition = particle.Center - Main.screenPosition; - Vector2 origin = fusableParticleBase.Size() * 0.5f; - Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size(); - Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0f); - } - } - } -} diff --git a/Particles/Metaballs/PaintParticleSets.cs b/Particles/Metaballs/PaintParticleSets.cs deleted file mode 100644 index bd65882d69..0000000000 --- a/Particles/Metaballs/PaintParticleSets.cs +++ /dev/null @@ -1,71 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System.Collections.Generic; -using System.Linq; -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ModLoader; - -namespace CalamityMod.Particles.Metaballs -{ - public class CyanPaint : PaintParticleSet - { - public override Color BorderColor => Color.Cyan * 0.7f; - } - public class BluePaint : PaintParticleSet - { - public override Color BorderColor => Color.Blue * 0.7f; - } - public class MagentaPaint : PaintParticleSet - { - public override Color BorderColor => Color.Magenta * 0.7f; - } - public class LimePaint : PaintParticleSet - { - public override Color BorderColor => Color.Lime * 0.7f; - } - public class YellowPaint : PaintParticleSet - { - public override Color BorderColor => Color.Yellow * 0.7f; - } - - public abstract class PaintParticleSet : BaseFusableParticleSet - { - public override float BorderSize => 12f; - public override bool BorderShouldBeSolid => false; - - public override List BackgroundShaders => new() - { - GameShaders.Misc["CalamityMod:AdditiveFusableParticleEdge"].Shader, - }; - public override List BackgroundTextures => new() - { - ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value, - }; - public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) - { - Particles.Add(new FusableParticle(center, sizeStrength)); - return Particles.Last(); - } - - public override void UpdateBehavior(FusableParticle particle) - { - particle.Size = MathHelper.Clamp(particle.Size - 0.1f, 0f, 200f) * 0.997f; - if (particle.Size < 20f) - particle.Size = particle.Size * 0.8f - 1f; - } - - public override void DrawParticles() - { - Texture2D fusableParticleBase = ModContent.Request("CalamityMod/Particles/Metaballs/FusableParticleBase").Value; - foreach (FusableParticle particle in Particles) - { - Vector2 drawPosition = particle.Center - Main.screenPosition; - Vector2 origin = fusableParticleBase.Size() * 0.5f; - Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size(); - Color drawColor = Color.Lerp(BorderColor, new Color(0f, 0f, 1f), Utils.GetLerpValue(50f, 100f, particle.Size, true) * 0.1f) * 1.2f; - Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); - } - } - } -} diff --git a/Particles/Metaballs/RancorGroundLavaParticleSet.cs b/Particles/Metaballs/RancorGroundLavaParticleSet.cs deleted file mode 100644 index 0675a3b6c7..0000000000 --- a/Particles/Metaballs/RancorGroundLavaParticleSet.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System.Collections.Generic; -using System.Linq; -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ModLoader; - -namespace CalamityMod.Particles.Metaballs -{ - public class RancorGroundLavaParticleSet : BaseFusableParticleSet - { - public override float BorderSize => 18f; - public override bool BorderShouldBeSolid => false; - public override Color BorderColor => Color.Lerp(Color.Yellow, Color.Red, 0.85f) * 0.85f; - - public override List BackgroundShaders => new() - { - GameShaders.Misc["CalamityMod:AdditiveFusableParticleEdge"].Shader, - }; - public override List BackgroundTextures => new() - { - ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value, - }; - public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) - { - Particles.Add(new FusableParticle(center, sizeStrength)); - return Particles.Last(); - } - - public override void UpdateBehavior(FusableParticle particle) - { - particle.Size = MathHelper.Clamp(particle.Size - 0.15f, 0f, 200f) * 0.997f; - if (particle.Size < 20f) - particle.Size = particle.Size * 0.95f - 0.9f; - } - - public override void DrawParticles() - { - Texture2D fusableParticleBase = ModContent.Request("CalamityMod/Particles/Metaballs/FusableParticleBase").Value; - foreach (FusableParticle particle in Particles) - { - Vector2 drawPosition = particle.Center - Main.screenPosition; - Vector2 origin = fusableParticleBase.Size() * 0.5f; - Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size() * new Vector2(1f, 0.5f); - Color drawColor = Color.Lerp(BorderColor, new Color(0f, 0f, 1f), Utils.GetLerpValue(120f, 135f, particle.Size, true) * 0.1f) * 1.4f; - Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); - } - } - } -} diff --git a/Particles/Metaballs/RancorLavaParticleSet.cs b/Particles/Metaballs/RancorLavaParticleSet.cs deleted file mode 100644 index 9b4431a2e1..0000000000 --- a/Particles/Metaballs/RancorLavaParticleSet.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System.Collections.Generic; -using System.Linq; -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ModLoader; - -namespace CalamityMod.Particles.Metaballs -{ - public class RancorLavaParticleSet : BaseFusableParticleSet - { - public override float BorderSize => 18f; - public override bool BorderShouldBeSolid => false; - public override Color BorderColor => Color.Lerp(Color.Yellow, Color.Red, 0.85f) * 0.85f; - - public override List BackgroundShaders => new() - { - GameShaders.Misc["CalamityMod:AdditiveFusableParticleEdge"].Shader, - }; - public override List BackgroundTextures => new() - { - ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value, - }; - public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) - { - Particles.Add(new FusableParticle(center, sizeStrength)); - return Particles.Last(); - } - - public override void UpdateBehavior(FusableParticle particle) - { - particle.Size = MathHelper.Clamp(particle.Size - 0.24f, 0f, 200f) * 0.9956f; - if (particle.Size < 15f) - particle.Size = particle.Size * 0.95f - 0.9f; - } - - public override void DrawParticles() - { - Texture2D fusableParticleBase = ModContent.Request("CalamityMod/Particles/Metaballs/FusableParticleBase").Value; - foreach (FusableParticle particle in Particles) - { - Vector2 drawPosition = particle.Center - Main.screenPosition; - Vector2 origin = fusableParticleBase.Size() * 0.5f; - Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size(); - Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, BorderColor * 1.2f, 0f, origin, scale, SpriteEffects.None, 0f); - } - } - } -} diff --git a/Particles/Metaballs/StreamGougeLayer.png b/Particles/Metaballs/StreamGougeLayer.png deleted file mode 100644 index 773929e360..0000000000 Binary files a/Particles/Metaballs/StreamGougeLayer.png and /dev/null differ diff --git a/Particles/Metaballs/StreamGougeParticleSet.cs b/Particles/Metaballs/StreamGougeParticleSet.cs deleted file mode 100644 index 08af896b55..0000000000 --- a/Particles/Metaballs/StreamGougeParticleSet.cs +++ /dev/null @@ -1,61 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System.Collections.Generic; -using System.Linq; -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ModLoader; - -namespace CalamityMod.Particles.Metaballs -{ - public class StreamGougeParticleSet : BaseFusableParticleSet - { - public override float BorderSize => 3f; - public override bool BorderShouldBeSolid => false; - public override Color BorderColor => Color.Lerp(Color.DarkBlue, Color.Black, 0.75f) * 0.85f; - - public override List BackgroundShaders => new() - { - GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, - }; - public override List BackgroundTextures => new() - { - ModContent.Request("CalamityMod/Particles/Metaballs/StreamGougeLayer").Value, - }; - public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) - { - Particles.Add(new FusableParticle(center, sizeStrength)); - return Particles.Last(); - } - - public override void UpdateBehavior(FusableParticle particle) - { - particle.Size = MathHelper.Clamp(particle.Size - 1f, 0f, 200f) * 0.98f; - } - - public override void PrepareOptionalShaderData(Effect effect, int index) - { - switch (index) - { - // Background. - case 0: - Vector2 offset = Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.045f; - effect.Parameters["generalBackgroundOffset"].SetValue(offset); - effect.Parameters["upscaleFactor"].SetValue(Vector2.One * -0.3f); - break; - } - } - - public override void DrawParticles() - { - Texture2D fusableParticleBase = ModContent.Request("CalamityMod/Particles/Metaballs/FusableParticleBase").Value; - foreach (FusableParticle particle in Particles) - { - Vector2 drawPosition = particle.Center - Main.screenPosition; - Vector2 origin = fusableParticleBase.Size() * 0.5f; - Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size(); - Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0f); - } - } - } -} diff --git a/Particles/Metaballs/VoidGeneratorParticleSet.cs b/Particles/Metaballs/VoidGeneratorParticleSet.cs deleted file mode 100644 index 9e01ec5462..0000000000 --- a/Particles/Metaballs/VoidGeneratorParticleSet.cs +++ /dev/null @@ -1,62 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System.Collections.Generic; -using System.Linq; -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ModLoader; - -namespace CalamityMod.Particles.Metaballs -{ - //This is basically just the Stream Gouge set but purple - public class VoidGeneratorParticleSet : BaseFusableParticleSet - { - public override float BorderSize => 3f; - public override bool BorderShouldBeSolid => false; - public override Color BorderColor => Color.Lerp(Color.Purple, Color.Black, 0.75f) * 0.85f; - - public override List BackgroundShaders => new List() - { - GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, - }; - public override List BackgroundTextures => new List() - { - ModContent.Request("CalamityMod/Particles/Metaballs/StreamGougeLayer").Value, - }; - public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) - { - Particles.Add(new FusableParticle(center, sizeStrength)); - return Particles.Last(); - } - - public override void UpdateBehavior(FusableParticle particle) - { - particle.Size = MathHelper.Clamp(particle.Size - 1f, 0f, 200f) * 0.98f; - } - - public override void PrepareOptionalShaderData(Effect effect, int index) - { - switch (index) - { - // Background. - case 0: - Vector2 offset = Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.045f; - effect.Parameters["generalBackgroundOffset"].SetValue(offset); - effect.Parameters["upscaleFactor"].SetValue(Vector2.One * -0.3f); - break; - } - } - - public override void DrawParticles() - { - Texture2D fusableParticleBase = ModContent.Request("CalamityMod/Particles/Metaballs/FusableParticleBase").Value; - foreach (FusableParticle particle in Particles) - { - Vector2 drawPosition = particle.Center - Main.screenPosition; - Vector2 origin = fusableParticleBase.Size() * 0.5f; - Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size(); - Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0f); - } - } - } -} diff --git a/Particles/Sparkle2.png b/Particles/Sparkle2.png new file mode 100644 index 0000000000..96ba7f3240 Binary files /dev/null and b/Particles/Sparkle2.png differ diff --git a/Particles/SparkleParticle.cs b/Particles/SparkleParticle.cs new file mode 100644 index 0000000000..1ba9dc8c6a --- /dev/null +++ b/Particles/SparkleParticle.cs @@ -0,0 +1,60 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class SparkleParticle : Particle + { + public override string Texture => "CalamityMod/Particles/Sparkle2"; + public bool UseAltVisual = true; + public override bool UseAdditiveBlend => UseAltVisual; + public override bool UseCustomDraw => true; + public override bool SetLifetime => true; + public override bool Important => imporant; + + public bool imporant; + private float Spin; + private float opacity; + private Color Bloom; + private Color LightColor => Bloom * opacity; + private float BloomScale; + + public SparkleParticle(Vector2 position, Vector2 velocity, Color color, Color bloom, float scale, int lifeTime, float rotationSpeed = 0f, float bloomScale = 1f, bool AddativeBlend = true, bool needed = false) + { + Position = position; + Velocity = velocity; + Color = color; + Bloom = bloom; + Scale = scale; + Lifetime = lifeTime; + Rotation = Main.rand.NextFloat(MathHelper.TwoPi); + Spin = rotationSpeed; + BloomScale = bloomScale; + UseAltVisual = AddativeBlend; + imporant = needed; + } + + public override void Update() + { + opacity = (float)Math.Sin(LifetimeCompletion * MathHelper.Pi); + Lighting.AddLight(Position, LightColor.R / 255f, LightColor.G / 255f, LightColor.B / 255f); + Velocity *= 0.95f; + Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f); + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D starTexture = ModContent.Request(Texture).Value; + Texture2D bloomTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + //Ajust the bloom's texture to be the same size as the star's + float properBloomSize = (float)starTexture.Height / (float)bloomTexture.Height; + + spriteBatch.Draw(bloomTexture, Position - Main.screenPosition, null, Bloom * opacity * 0.5f, 0, bloomTexture.Size()/2f, Scale * BloomScale * properBloomSize, SpriteEffects.None, 0); + spriteBatch.Draw(starTexture, Position - Main.screenPosition, null, Color * opacity * 0.5f, Rotation + MathHelper.PiOver4, starTexture.Size() / 2f, Scale * 0.75f, SpriteEffects.None, 0); + spriteBatch.Draw(starTexture, Position - Main.screenPosition, null, Color * opacity, Rotation, starTexture.Size() / 2f, Scale, SpriteEffects.None, 0); + } + } +} diff --git a/Projectiles/BaseProjectiles/BaseMinionProjectile.cs b/Projectiles/BaseProjectiles/BaseMinionProjectile.cs index 18752d5124..06aebb26f5 100644 --- a/Projectiles/BaseProjectiles/BaseMinionProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseMinionProjectile.cs @@ -40,18 +40,26 @@ namespace CalamityMod.Projectiles.BaseProjectiles public virtual float MinionSlots => 1f; /// - /// The distance in which the minion can detect an enemy, in pixels.
+ /// The max distance in which the minion can detect an enemy, in pixels.
/// is set to this value.
/// Defaults to 1200f (75 tiles). ///
public virtual float EnemyDistanceDetection => 1200f; + /// + /// The min distance in which the minion can detect an enemy before it goes to its correspondent enemy distance detection. + /// Defaults to 960f (60 tiles), the radius of a 1080p monitor at max zoom. + /// + public virtual float MinEnemyDistanceDetection => 960f; + + private float AdaptiveEnemyDistanceDetection => Target == null ? MinEnemyDistanceDetection : EnemyDistanceDetection; + /// /// The amount of local I-Frames this minion has.
- /// Multiplied by so changing won't affect this.
+ /// Multiplied by so changing the updates won't affect this.
/// Defaults to 10. ///
- public int IFrames { get => Projectile.localNPCHitCooldown / Projectile.MaxUpdates; set => Projectile.localNPCHitCooldown = value * Projectile.MaxUpdates; } + public int IFrames { get; set; } = 10; /// /// If , makes the minion only be able to detect and attack enemies through tiles only when there are any bosses alive.
@@ -65,6 +73,12 @@ namespace CalamityMod.Projectiles.BaseProjectiles ///
public virtual bool PreventTargettingUntilTargetHit => true; + /// + /// The amount of animation frames this minion has.
+ /// Defaults to 1 frame. + ///
+ public virtual int AnimationFrames => 1; + /// /// The frames that it takes to go to the next frame of animation.
/// Defaults to 5. @@ -83,14 +97,15 @@ namespace CalamityMod.Projectiles.BaseProjectiles ///
public int TrailCacheLength { get; set; } = 5; - public Player Owner => Main.player[Projectile.owner]; - public CalamityPlayer ModdedOwner => Owner.Calamity(); + public Player Owner { get; set; } + public CalamityPlayer ModdedOwner { get; set; } public NPC Target { get; set; } #endregion public override void SetStaticDefaults() { + Main.projFrames[Type] = AnimationFrames; ProjectileID.Sets.MinionTargettingFeature[Type] = true; ProjectileID.Sets.TrailingMode[Type] = TrailingMode; ProjectileID.Sets.TrailCacheLength[Type] = TrailCacheLength; @@ -119,9 +134,10 @@ namespace CalamityMod.Projectiles.BaseProjectiles public override void AI() { + Projectile.localNPCHitCooldown = IFrames * Projectile.MaxUpdates; + SetOwnerTarget(); CheckMinionExistence(); DoAnimation(); - ChooseTarget(); MinionAI(); } @@ -166,9 +182,14 @@ namespace CalamityMod.Projectiles.BaseProjectiles } /// - /// Where the null property is set to a valid target, a non-null value. + /// Where the null property , and is set to a non-null value. /// - public virtual void ChooseTarget() => Target = Owner.Center.MinionHoming(EnemyDistanceDetection, Owner, !PreHardmodeMinionTileVision || CalamityPlayer.areThereAnyDamnBosses); + public virtual void SetOwnerTarget() + { + Owner = Main.player[Projectile.owner]; + ModdedOwner = Owner.Calamity(); + Target = Owner.Center.MinionHoming(AdaptiveEnemyDistanceDetection, Owner, !PreHardmodeMinionTileVision || CalamityPlayer.areThereAnyDamnBosses); + } #endregion } diff --git a/Projectiles/BaseProjectiles/BaseShortswordProjectile.cs b/Projectiles/BaseProjectiles/BaseShortswordProjectile.cs index 3a596daf0d..8d8a3caa26 100644 --- a/Projectiles/BaseProjectiles/BaseShortswordProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseShortswordProjectile.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles if (ShortswordAIType == ShortswordType.TypicalShortsword && !player.frozen) { - player.direction = Projectile.direction; + player.ChangeDir(Projectile.direction); player.heldProj = Projectile.whoAmI; player.itemTime = player.itemAnimation; diff --git a/Projectiles/BaseProjectiles/BaseSpearProjectile.cs b/Projectiles/BaseProjectiles/BaseSpearProjectile.cs index f4bbf765b8..3120581e05 100644 --- a/Projectiles/BaseProjectiles/BaseSpearProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseSpearProjectile.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles Player player = Main.player[Projectile.owner]; // Adjust owner stats based on this projectile - player.direction = Projectile.direction; + player.ChangeDir(Projectile.direction); player.heldProj = Projectile.whoAmI; player.itemTime = player.itemAnimation; @@ -66,7 +66,8 @@ namespace CalamityMod.Projectiles.BaseProjectiles } // If at the end of the animation, kill the projectile. - if (player.itemAnimation == 0) + //Checking if == 0 is too late, lets the projectile linger into chained item uses. + if (player.itemAnimation <= 1) Projectile.Kill(); Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2 + MathHelper.PiOver4; diff --git a/Projectiles/Boss/ApolloFireball.cs b/Projectiles/Boss/ApolloFireball.cs index 449bdfd0f3..39a8db04fd 100644 --- a/Projectiles/Boss/ApolloFireball.cs +++ b/Projectiles/Boss/ApolloFireball.cs @@ -78,7 +78,7 @@ namespace CalamityMod.Projectiles.Boss float speed2 = 2.8f; float angleRandom = 0.35f; - for (int num53 = 0; num53 < 40; num53++) + for (int i = 0; i < 40; i++) { float dustSpeed = Main.rand.NextFloat(speed1, speed2); Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation()); @@ -86,27 +86,27 @@ namespace CalamityMod.Projectiles.Boss dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); int randomDustType = Main.rand.NextBool() ? 107 : 110; - int num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 1.7f); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - Main.dust[num54].noGravity = true; + int plasmaDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 1.7f); + Main.dust[plasmaDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + Main.dust[plasmaDust].noGravity = true; - Dust dust = Main.dust[num54]; + Dust dust = Main.dust[plasmaDust]; dust.velocity *= 3f; - dust = Main.dust[num54]; + dust = Main.dust[plasmaDust]; - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 0.8f); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + plasmaDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 0.8f); + Main.dust[plasmaDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - dust = Main.dust[num54]; + dust = Main.dust[plasmaDust]; dust.velocity *= 2f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Green * 0.5f; + Main.dust[plasmaDust].noGravity = true; + Main.dust[plasmaDust].fadeIn = 1f; + Main.dust[plasmaDust].color = Color.Green * 0.5f; - dust = Main.dust[num54]; + dust = Main.dust[plasmaDust]; } - for (int num55 = 0; num55 < 20; num55++) + for (int j = 0; j < 20; j++) { float dustSpeed = Main.rand.NextFloat(speed1, speed2); Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation()); @@ -114,13 +114,13 @@ namespace CalamityMod.Projectiles.Boss dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); int randomDustType = Main.rand.NextBool() ? 107 : 110; - int num56 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 2f); - Main.dust[num56].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 3f; - Main.dust[num56].noGravity = true; + int plasmaDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 2f); + Main.dust[plasmaDust2].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 3f; + Main.dust[plasmaDust2].noGravity = true; - Dust dust = Main.dust[num56]; + Dust dust = Main.dust[plasmaDust2]; dust.velocity *= 0.5f; - dust = Main.dust[num56]; + dust = Main.dust[plasmaDust2]; } } } @@ -180,30 +180,30 @@ namespace CalamityMod.Projectiles.Boss } } - for (int num640 = 0; num640 < 200; num640++) + for (int i = 0; i < 200; i++) { - float num641 = 16f; - if (num640 < 150) - num641 = 12f; - if (num640 < 100) - num641 = 8f; - if (num640 < 50) - num641 = 4f; + float dustScale = 16f; + if (i < 150) + dustScale = 12f; + if (i < 100) + dustScale = 8f; + if (i < 50) + dustScale = 4f; - int num643 = Dust.NewDust(Projectile.Center, 6, 6, Main.rand.NextBool() ? 107 : 110, 0f, 0f, 100, default, 1f); - float num644 = Main.dust[num643].velocity.X; - float num645 = Main.dust[num643].velocity.Y; + int plasmaDeathDust = Dust.NewDust(Projectile.Center, 6, 6, Main.rand.NextBool() ? 107 : 110, 0f, 0f, 100, default, 1f); + float plasmaDeathDustX = Main.dust[plasmaDeathDust].velocity.X; + float plasmaDeathDustY = Main.dust[plasmaDeathDust].velocity.Y; - if (num644 == 0f && num645 == 0f) - num644 = 1f; + if (plasmaDeathDustX == 0f && plasmaDeathDustY == 0f) + plasmaDeathDustX = 1f; - float num646 = (float)Math.Sqrt(num644 * num644 + num645 * num645); - num646 = num641 / num646; - num644 *= num646; - num645 *= num646; + float plasmaDeathDustVel = (float)Math.Sqrt(plasmaDeathDustX * plasmaDeathDustX + plasmaDeathDustY * plasmaDeathDustY); + plasmaDeathDustVel = dustScale / plasmaDeathDustVel; + plasmaDeathDustX *= plasmaDeathDustVel; + plasmaDeathDustY *= plasmaDeathDustVel; float scale = 1f; - switch ((int)num641) + switch ((int)dustScale) { case 4: scale = 1.2f; @@ -221,10 +221,10 @@ namespace CalamityMod.Projectiles.Boss break; } - Dust dust = Main.dust[num643]; + Dust dust = Main.dust[plasmaDeathDust]; dust.velocity *= 0.5f; - dust.velocity.X = dust.velocity.X + num644; - dust.velocity.Y = dust.velocity.Y + num645; + dust.velocity.X = dust.velocity.X + plasmaDeathDustX; + dust.velocity.Y = dust.velocity.Y + plasmaDeathDustY; dust.scale = scale; dust.noGravity = true; } diff --git a/Projectiles/Boss/ApolloRocket.cs b/Projectiles/Boss/ApolloRocket.cs index c24d7520f8..01c48380b6 100644 --- a/Projectiles/Boss/ApolloRocket.cs +++ b/Projectiles/Boss/ApolloRocket.cs @@ -67,53 +67,53 @@ namespace CalamityMod.Projectiles.Boss { Projectile.localAI[0] = 1f; - float speed1 = 1.8f; - float speed2 = 2.8f; + float randDustSpeed1 = 1.8f; + float randDustSpeed2 = 2.8f; float angleRandom = 0.35f; - for (int num53 = 0; num53 < 20; num53++) + for (int i = 0; i < 20; i++) { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); + float dustSpeed = Main.rand.NextFloat(randDustSpeed1, randDustSpeed2); Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation()); dustVel = dustVel.RotatedBy(-angleRandom); dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); int randomDustType = Main.rand.NextBool() ? 107 : 110; - int num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 1.7f); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - Main.dust[num54].noGravity = true; + int plasmaDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 1.7f); + Main.dust[plasmaDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + Main.dust[plasmaDust].noGravity = true; - Dust dust = Main.dust[num54]; + Dust dust = Main.dust[plasmaDust]; dust.velocity *= 3f; - dust = Main.dust[num54]; + dust = Main.dust[plasmaDust]; - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 0.8f); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + plasmaDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 0.8f); + Main.dust[plasmaDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - dust = Main.dust[num54]; + dust = Main.dust[plasmaDust]; dust.velocity *= 2f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Green * 0.5f; + Main.dust[plasmaDust].noGravity = true; + Main.dust[plasmaDust].fadeIn = 1f; + Main.dust[plasmaDust].color = Color.Green * 0.5f; - dust = Main.dust[num54]; + dust = Main.dust[plasmaDust]; } - for (int num55 = 0; num55 < 10; num55++) + for (int j = 0; j < 10; j++) { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); + float dustSpeed = Main.rand.NextFloat(randDustSpeed1, randDustSpeed2); Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation()); dustVel = dustVel.RotatedBy(-angleRandom); dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); int randomDustType = Main.rand.NextBool() ? 107 : 110; - int num56 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 2f); - Main.dust[num56].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 3f; - Main.dust[num56].noGravity = true; + int plasmaDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 2f); + Main.dust[plasmaDust2].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 3f; + Main.dust[plasmaDust2].noGravity = true; - Dust dust = Main.dust[num56]; + Dust dust = Main.dust[plasmaDust2]; dust.velocity *= 0.5f; - dust = Main.dust[num56]; + dust = Main.dust[plasmaDust2]; } } @@ -214,7 +214,7 @@ namespace CalamityMod.Projectiles.Boss SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - for (int num621 = 0; num621 < 12; num621++) + for (int i = 0; i < 12; i++) { int randomDustType = Main.rand.NextBool() ? 107 : 110; int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, randomDustType, 0f, 0f, 100, default, 2f); @@ -225,7 +225,7 @@ namespace CalamityMod.Projectiles.Boss Main.dust[dust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 15; num623++) + for (int j = 0; j < 15; j++) { int randomDustType = Main.rand.NextBool() ? 107 : 110; int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, randomDustType, 0f, 0f, 100, default, 3f); diff --git a/Projectiles/Boss/AresLaserBeamStart.cs b/Projectiles/Boss/AresLaserBeamStart.cs index 26be83ad1b..72fd77af59 100644 --- a/Projectiles/Boss/AresLaserBeamStart.cs +++ b/Projectiles/Boss/AresLaserBeamStart.cs @@ -80,7 +80,7 @@ namespace CalamityMod.Projectiles.Boss else Projectile.Kill(); - float num801 = 1f; + float projScale = 1f; Projectile.localAI[0] += 1f; if (Projectile.localAI[0] >= 60f) { @@ -88,38 +88,37 @@ namespace CalamityMod.Projectiles.Boss return; } - Projectile.scale = (float)Math.Sin(Projectile.localAI[0] * (float)Math.PI / 60f) * 10f * num801; - if (Projectile.scale > num801) - Projectile.scale = num801; + Projectile.scale = (float)Math.Sin(Projectile.localAI[0] * (float)Math.PI / 60f) * 10f * projScale; + if (Projectile.scale > projScale) + Projectile.scale = projScale; - float num804 = Projectile.velocity.ToRotation(); - Projectile.rotation = num804 - MathHelper.PiOver2; - Projectile.velocity = num804.ToRotationVector2(); + float projVelRotation = Projectile.velocity.ToRotation(); + Projectile.rotation = projVelRotation - MathHelper.PiOver2; + Projectile.velocity = projVelRotation.ToRotationVector2(); - float num805 = 3f; //3f - float num806 = Projectile.width; + float projWidth = Projectile.width; Vector2 samplingPoint = Projectile.Center; if (vector78.HasValue) samplingPoint = vector78.Value; - float[] array3 = new float[(int)num805]; - Collision.LaserScan(samplingPoint, Projectile.velocity, num806 * Projectile.scale, 2400f, array3); - float num807 = 0f; - for (int num808 = 0; num808 < array3.Length; num808++) + float[] array3 = new float[3]; + Collision.LaserScan(samplingPoint, Projectile.velocity, projWidth * Projectile.scale, 2400f, array3); + float laserLength = 0f; + for (int j = 0; j < array3.Length; j++) { - num807 += array3[num808]; + laserLength += array3[j]; } - num807 /= num805; + laserLength /= 3f; // Fire laser through walls at max length if target cannot be seen if (!Collision.CanHitLine(Main.npc[(int)Projectile.ai[1]].Center, 1, 1, Main.player[Main.npc[(int)Projectile.ai[1]].target].Center, 1, 1)) { - num807 = 2400f; + laserLength = 2400f; } float amount = 0.5f; - Projectile.localAI[1] = MathHelper.Lerp(Projectile.localAI[1], num807, amount); //length of laser, linear interpolation + Projectile.localAI[1] = MathHelper.Lerp(Projectile.localAI[1], laserLength, amount); //length of laser, linear interpolation // Spawn dust at the end of the beam int dustType = (int)CalamityDusts.Brimstone; diff --git a/Projectiles/Boss/AresPlasmaFireball.cs b/Projectiles/Boss/AresPlasmaFireball.cs index bb996d70a9..7f31201977 100644 --- a/Projectiles/Boss/AresPlasmaFireball.cs +++ b/Projectiles/Boss/AresPlasmaFireball.cs @@ -77,48 +77,48 @@ namespace CalamityMod.Projectiles.Boss { Projectile.localAI[0] = 1f; - float speed1 = 1.8f; - float speed2 = 2.8f; + float randDustSpeed1 = 1.8f; + float randDustSpeed2 = 2.8f; float angleRandom = 0.35f; - for (int num53 = 0; num53 < 40; num53++) + for (int i = 0; i < 40; i++) { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); + float dustSpeed = Main.rand.NextFloat(randDustSpeed1, randDustSpeed2); Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation()); dustVel = dustVel.RotatedBy(-angleRandom); dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); int randomDustType = Main.rand.NextBool() ? 107 : 110; - int num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 1.7f); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - Main.dust[num54].noGravity = true; + int plasmaDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 1.7f); + Main.dust[plasmaDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + Main.dust[plasmaDust].noGravity = true; - Dust dust = Main.dust[num54]; + Dust dust = Main.dust[plasmaDust]; dust.velocity *= 3f; - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 0.8f); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + plasmaDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 0.8f); + Main.dust[plasmaDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - dust = Main.dust[num54]; + dust = Main.dust[plasmaDust]; dust.velocity *= 2f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Green * 0.5f; + Main.dust[plasmaDust].noGravity = true; + Main.dust[plasmaDust].fadeIn = 1f; + Main.dust[plasmaDust].color = Color.Green * 0.5f; } - for (int num55 = 0; num55 < 20; num55++) + for (int j = 0; j < 20; j++) { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); + float dustSpeed = Main.rand.NextFloat(randDustSpeed1, randDustSpeed2); Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation()); dustVel = dustVel.RotatedBy(-angleRandom); dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); int randomDustType = Main.rand.NextBool() ? 107 : 110; - int num56 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 2f); - Main.dust[num56].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 3f; - Main.dust[num56].noGravity = true; + int plasmaDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 2f); + Main.dust[plasmaDust2].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 3f; + Main.dust[plasmaDust2].noGravity = true; - Dust dust = Main.dust[num56]; + Dust dust = Main.dust[plasmaDust2]; dust.velocity *= 0.5f; } } @@ -184,30 +184,30 @@ namespace CalamityMod.Projectiles.Boss } } - for (int num640 = 0; num640 < 200; num640++) + for (int i = 0; i < 200; i++) { - float num641 = 16f; - if (num640 < 150) - num641 = 12f; - if (num640 < 100) - num641 = 8f; - if (num640 < 50) - num641 = 4f; + float dustScale = 16f; + if (i < 150) + dustScale = 12f; + if (i < 100) + dustScale = 8f; + if (i < 50) + dustScale = 4f; - int num643 = Dust.NewDust(Projectile.Center, 6, 6, Main.rand.NextBool() ? 107 : 110, 0f, 0f, 100, default, 1f); - float num644 = Main.dust[num643].velocity.X; - float num645 = Main.dust[num643].velocity.Y; + int deathPlasmaDust = Dust.NewDust(Projectile.Center, 6, 6, Main.rand.NextBool() ? 107 : 110, 0f, 0f, 100, default, 1f); + float deathPlasmaDustX = Main.dust[deathPlasmaDust].velocity.X; + float deathPlasmaDustY = Main.dust[deathPlasmaDust].velocity.Y; - if (num644 == 0f && num645 == 0f) - num644 = 1f; + if (deathPlasmaDustX == 0f && deathPlasmaDustY == 0f) + deathPlasmaDustX = 1f; - float num646 = (float)Math.Sqrt(num644 * num644 + num645 * num645); - num646 = num641 / num646; - num644 *= num646; - num645 *= num646; + float deathPlasmaDustVel = (float)Math.Sqrt(deathPlasmaDustX * deathPlasmaDustX + deathPlasmaDustY * deathPlasmaDustY); + deathPlasmaDustVel = dustScale / deathPlasmaDustVel; + deathPlasmaDustX *= deathPlasmaDustVel; + deathPlasmaDustY *= deathPlasmaDustVel; float scale = 1f; - switch ((int)num641) + switch ((int)dustScale) { case 4: scale = 1.2f; @@ -225,10 +225,10 @@ namespace CalamityMod.Projectiles.Boss break; } - Dust dust = Main.dust[num643]; + Dust dust = Main.dust[deathPlasmaDust]; dust.velocity *= 0.5f; - dust.velocity.X = dust.velocity.X + num644; - dust.velocity.Y = dust.velocity.Y + num645; + dust.velocity.X = dust.velocity.X + deathPlasmaDustX; + dust.velocity.Y = dust.velocity.Y + deathPlasmaDustY; dust.scale = scale; dust.noGravity = true; } diff --git a/Projectiles/Boss/AresTeslaOrb.cs b/Projectiles/Boss/AresTeslaOrb.cs index a12991cc6c..499fcd342c 100644 --- a/Projectiles/Boss/AresTeslaOrb.cs +++ b/Projectiles/Boss/AresTeslaOrb.cs @@ -89,7 +89,7 @@ namespace CalamityMod.Projectiles.Boss float speed2 = 2.8f; float angleRandom = 0.35f; - for (int num53 = 0; num53 < 40; num53++) + for (int i = 0; i < 40; i++) { float dustSpeed = Main.rand.NextFloat(speed1, speed2); Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation()); @@ -98,24 +98,24 @@ namespace CalamityMod.Projectiles.Boss int randomDustType = Main.rand.Next(2) == 0 ? 206 : 229; float scale = randomDustType == 206 ? 1.5f : 1f; - int num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 2.5f * scale); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - Main.dust[num54].noGravity = true; + int teslaDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 2.5f * scale); + Main.dust[teslaDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + Main.dust[teslaDust].noGravity = true; - Dust dust = Main.dust[num54]; + Dust dust = Main.dust[teslaDust]; dust.velocity *= 3f; - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 1.5f * scale); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + teslaDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 1.5f * scale); + Main.dust[teslaDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - dust = Main.dust[num54]; + dust = Main.dust[teslaDust]; dust.velocity *= 2f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Cyan * 0.5f; + Main.dust[teslaDust].noGravity = true; + Main.dust[teslaDust].fadeIn = 1f; + Main.dust[teslaDust].color = Color.Cyan * 0.5f; } - for (int num55 = 0; num55 < 20; num55++) + for (int j = 0; j < 20; j++) { float dustSpeed = Main.rand.NextFloat(speed1, speed2); Vector2 dustVel = new Vector2(dustSpeed, 0f).RotatedBy(Projectile.velocity.ToRotation()); @@ -124,11 +124,11 @@ namespace CalamityMod.Projectiles.Boss int randomDustType = Main.rand.Next(2) == 0 ? 206 : 229; float scale = randomDustType == 206 ? 1.5f : 1f; - int num56 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 3f * scale); - Main.dust[num56].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 3f; - Main.dust[num56].noGravity = true; + int teslaDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 3f * scale); + Main.dust[teslaDust2].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 3f; + Main.dust[teslaDust2].noGravity = true; - Dust dust = Main.dust[num56]; + Dust dust = Main.dust[teslaDust2]; dust.velocity *= 0.5f; } } diff --git a/Projectiles/Boss/AstralFlame.cs b/Projectiles/Boss/AstralFlame.cs index f465ac111a..b7fd4f0366 100644 --- a/Projectiles/Boss/AstralFlame.cs +++ b/Projectiles/Boss/AstralFlame.cs @@ -67,9 +67,9 @@ namespace CalamityMod.Projectiles.Boss Lighting.AddLight(Projectile.Center, 0.3f, 0.5f, 0.1f); - int num103 = Player.FindClosest(Projectile.Center, 1, 1); - Vector2 vector11 = Main.player[num103].Center - Projectile.Center; - if (vector11.Length() < 60f) + int targetPlayer = Player.FindClosest(Projectile.Center, 1, 1); + Vector2 playerDist = Main.player[targetPlayer].Center - Projectile.Center; + if (playerDist.Length() < 60f) { Projectile.Kill(); return; @@ -78,9 +78,9 @@ namespace CalamityMod.Projectiles.Boss Projectile.ai[0] += 1f; if (Projectile.ai[0] > 15f) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 100, default, 0.8f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int astralDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 100, default, 0.8f); + Main.dust[astralDust].noGravity = true; + Main.dust[astralDust].velocity *= 0f; } if (Projectile.ai[0] >= 120f) @@ -88,9 +88,9 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.ai[1] < 180f) { float scaleFactor2 = Projectile.velocity.Length(); - vector11.Normalize(); - vector11 *= scaleFactor2; - Projectile.velocity = (Projectile.velocity * 30f + vector11) / 31f; + playerDist.Normalize(); + playerDist *= scaleFactor2; + Projectile.velocity = (Projectile.velocity * 30f + playerDist) / 31f; Projectile.velocity.Normalize(); Projectile.velocity *= scaleFactor2; } @@ -160,18 +160,18 @@ namespace CalamityMod.Projectiles.Boss Projectile.width = Projectile.height = 96; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num193 = 0; num193 < 2; num193++) + for (int i = 0; i < 2; i++) { Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 50, default, 1f); } - for (int num194 = 0; num194 < 20; num194++) + for (int j = 0; j < 20; j++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 0, default, 1.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 50, default, 1f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int deathAstralDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 0, default, 1.5f); + Main.dust[deathAstralDust].noGravity = true; + Main.dust[deathAstralDust].velocity *= 3f; + deathAstralDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 50, default, 1f); + Main.dust[deathAstralDust].velocity *= 2f; + Main.dust[deathAstralDust].noGravity = true; } Projectile.Damage(); } diff --git a/Projectiles/Boss/BigFlare.cs b/Projectiles/Boss/BigFlare.cs index a91f53e261..2b31191ca4 100644 --- a/Projectiles/Boss/BigFlare.cs +++ b/Projectiles/Boss/BigFlare.cs @@ -56,23 +56,23 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.ai[1] > 0f) { - int num625 = (int)Projectile.ai[1] - 1; - if (num625 < 255) + int playerTracker = (int)Projectile.ai[1] - 1; + if (playerTracker < 255) { Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 10f) { - int num626 = 6; - for (int num627 = 0; num627 < num626; num627++) + int dustAmt = 6; + for (int i = 0; i < dustAmt; i++) { - Vector2 vector45 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector45 = vector45.RotatedBy((double)(num627 - (num626 / 2 - 1)) * 3.1415926535897931 / (double)(float)num626, default) + Projectile.Center; - Vector2 value15 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); - int num628 = Dust.NewDust(vector45 + value15, 0, 0, 244, value15.X * 2f, value15.Y * 2f, 100, default, 1.4f); - Main.dust[num628].noGravity = true; - Main.dust[num628].noLight = true; - Main.dust[num628].velocity /= 4f; - Main.dust[num628].velocity -= Projectile.velocity; + Vector2 dustRotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + dustRotate = dustRotate.RotatedBy((double)(i - (dustAmt / 2 - 1)) * 3.1415926535897931 / (double)(float)dustAmt, default) + Projectile.Center; + Vector2 randomDustPos = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + int flareDust = Dust.NewDust(dustRotate + randomDustPos, 0, 0, 244, randomDustPos.X * 2f, randomDustPos.Y * 2f, 100, default, 1.4f); + Main.dust[flareDust].noGravity = true; + Main.dust[flareDust].noLight = true; + Main.dust[flareDust].velocity /= 4f; + Main.dust[flareDust].velocity -= Projectile.velocity; } Projectile.alpha -= 5; if (Projectile.alpha < 100) @@ -81,11 +81,11 @@ namespace CalamityMod.Projectiles.Boss } } - Vector2 value16 = Main.player[num625].Center - Projectile.Center; - float num629 = 4f; - num629 += Projectile.localAI[0] / 60f; - Projectile.velocity = Vector2.Normalize(value16) * num629; - if (value16.Length() < 64f) + Vector2 playerDistance = Main.player[playerTracker].Center - Projectile.Center; + float projVelocityMult = 4f; + projVelocityMult += Projectile.localAI[0] / 60f; + Projectile.velocity = Vector2.Normalize(playerDistance) * projVelocityMult; + if (playerDistance.Length() < 64f) { Projectile.Kill(); } @@ -114,55 +114,54 @@ namespace CalamityMod.Projectiles.Boss { bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; SoundEngine.PlaySound(FlareSound, Projectile.Center); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmtKill = 36; + for (int j = 0; j < dustAmtKill; j++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 244, vector7.X * 2f, vector7.Y * 2f, 100, default, 1.4f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 rotation = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotation = rotation.RotatedBy((double)((float)(j - (dustAmtKill / 2 - 1)) * 6.28318548f / (float)dustAmtKill), default) + Projectile.Center; + Vector2 faceDirection = rotation - Projectile.Center; + int flareDeath = Dust.NewDust(rotation + faceDirection, 0, 0, 244, faceDirection.X * 2f, faceDirection.Y * 2f, 100, default, 1.4f); + Main.dust[flareDeath].noGravity = true; + Main.dust[flareDeath].noLight = true; + Main.dust[flareDeath].velocity = faceDirection; } if (Projectile.owner == Main.myPlayer) { - int num231 = (int)(Projectile.Center.Y / 16f); - int num232 = (int)(Projectile.Center.X / 16f); - int num233 = 100; - if (num232 < 10) + int projTileX = (int)(Projectile.Center.Y / 16f); + int projTileY = (int)(Projectile.Center.X / 16f); + if (projTileY < 10) { - num232 = 10; + projTileY = 10; } - if (num232 > Main.maxTilesX - 10) + if (projTileY > Main.maxTilesX - 10) { - num232 = Main.maxTilesX - 10; + projTileY = Main.maxTilesX - 10; } - if (num231 < 10) + if (projTileX < 10) { - num231 = 10; + projTileX = 10; } - if (num231 > Main.maxTilesY - num233 - 10) + if (projTileX > Main.maxTilesY - 110) { - num231 = Main.maxTilesY - num233 - 10; + projTileX = Main.maxTilesY - 110; } - int spawnAreaY = Main.maxTilesY - num231; - for (int num234 = num231; num234 < num231 + spawnAreaY; num234++) + int spawnAreaY = Main.maxTilesY - projTileX; + for (int k = projTileX; k < projTileX + spawnAreaY; k++) { - Tile tile = Main.tile[num232, num234 + 10]; + Tile tile = Main.tile[projTileY, k + 10]; if (tile.HasTile && !TileID.Sets.Platforms[tile.TileType] && (Main.tileSolid[(int)tile.TileType] || tile.LiquidAmount != 0)) { - num231 = num234; + projTileX = k; break; } } int spawnLimitY = (int)(Main.player[Projectile.owner].Center.Y / 16f) + 50; - if (num231 > spawnLimitY) + if (projTileX > spawnLimitY) { - num231 = spawnLimitY; + projTileX = spawnLimitY; } - int num236 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)(num232 * 16 + 8), (float)(num231 * 16 - 24), 0f, 0f, ModContent.ProjectileType(), 0, 4f, Main.myPlayer, 11f, 16f + (revenge ? 2f : 0f)); - Main.projectile[num236].netUpdate = true; + int infernadoSpawn = Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)(projTileY * 16 + 8), (float)(projTileX * 16 - 24), 0f, 0f, ModContent.ProjectileType(), 0, 4f, Main.myPlayer, 11f, 16f + (revenge ? 2f : 0f)); + Main.projectile[infernadoSpawn].netUpdate = true; } } } diff --git a/Projectiles/Boss/BigFlare2.cs b/Projectiles/Boss/BigFlare2.cs index 79b0ea852b..ef29b09baa 100644 --- a/Projectiles/Boss/BigFlare2.cs +++ b/Projectiles/Boss/BigFlare2.cs @@ -56,23 +56,23 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.ai[1] > 0f) { - int num625 = (int)Projectile.ai[1] - 1; - if (num625 < 255) + int playerTracker = (int)Projectile.ai[1] - 1; + if (playerTracker < 255) { Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 10f) { - int num626 = 6; - for (int num627 = 0; num627 < num626; num627++) + int dustAmt = 6; + for (int i = 0; i < dustAmt; i++) { - Vector2 vector45 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector45 = vector45.RotatedBy((double)(num627 - (num626 / 2 - 1)) * 3.1415926535897931 / (double)(float)num626, default) + Projectile.Center; - Vector2 value15 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); - int num628 = Dust.NewDust(vector45 + value15, 0, 0, 244, value15.X * 2f, value15.Y * 2f, 100, default, 1.4f); - Main.dust[num628].noGravity = true; - Main.dust[num628].noLight = true; - Main.dust[num628].velocity /= 4f; - Main.dust[num628].velocity -= Projectile.velocity; + Vector2 dustRotation = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + dustRotation = dustRotation.RotatedBy((double)(i - (dustAmt / 2 - 1)) * 3.1415926535897931 / (double)(float)dustAmt, default) + Projectile.Center; + Vector2 randomDustPos = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + int flareDust = Dust.NewDust(dustRotation + randomDustPos, 0, 0, 244, randomDustPos.X * 2f, randomDustPos.Y * 2f, 100, default, 1.4f); + Main.dust[flareDust].noGravity = true; + Main.dust[flareDust].noLight = true; + Main.dust[flareDust].velocity /= 4f; + Main.dust[flareDust].velocity -= Projectile.velocity; } Projectile.alpha -= 5; if (Projectile.alpha < 100) @@ -81,11 +81,11 @@ namespace CalamityMod.Projectiles.Boss } } - Vector2 value16 = Main.player[num625].Center - Projectile.Center; - float num629 = 4f; - num629 += Projectile.localAI[0] / 60f; - Projectile.velocity = Vector2.Normalize(value16) * num629; - if (value16.Length() < 64f) + Vector2 playerDistance = Main.player[playerTracker].Center - Projectile.Center; + float projVelocityMult = 4f; + projVelocityMult += Projectile.localAI[0] / 60f; + Projectile.velocity = Vector2.Normalize(playerDistance) * projVelocityMult; + if (playerDistance.Length() < 64f) { Projectile.Kill(); } @@ -114,55 +114,54 @@ namespace CalamityMod.Projectiles.Boss { bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; SoundEngine.PlaySound(FlareSound, Projectile.Center); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int killDustAmt = 36; + for (int i = 0; i < killDustAmt; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 244, vector7.X * 2f, vector7.Y * 2f, 100, default, 1.4f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 killDustRotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + killDustRotate = killDustRotate.RotatedBy((double)((float)(i - (killDustAmt / 2 - 1)) * 6.28318548f / (float)killDustAmt), default) + Projectile.Center; + Vector2 killDustDirection = killDustRotate - Projectile.Center; + int killFlareDust = Dust.NewDust(killDustRotate + killDustDirection, 0, 0, 244, killDustDirection.X * 2f, killDustDirection.Y * 2f, 100, default, 1.4f); + Main.dust[killFlareDust].noGravity = true; + Main.dust[killFlareDust].noLight = true; + Main.dust[killFlareDust].velocity = killDustDirection; } if (Projectile.owner == Main.myPlayer) { - int num231 = (int)(Projectile.Center.Y / 16f); - int num232 = (int)(Projectile.Center.X / 16f); - int num233 = 100; - if (num232 < 10) + int projTileX = (int)(Projectile.Center.Y / 16f); + int projTileY = (int)(Projectile.Center.X / 16f); + if (projTileY < 10) { - num232 = 10; + projTileY = 10; } - if (num232 > Main.maxTilesX - 10) + if (projTileY > Main.maxTilesX - 10) { - num232 = Main.maxTilesX - 10; + projTileY = Main.maxTilesX - 10; } - if (num231 < 10) + if (projTileX < 10) { - num231 = 10; + projTileX = 10; } - if (num231 > Main.maxTilesY - num233 - 10) + if (projTileX > Main.maxTilesY - 110) { - num231 = Main.maxTilesY - num233 - 10; + projTileX = Main.maxTilesY - 110; } - int spawnAreaY = Main.maxTilesY - num231; - for (int num234 = num231; num234 < num231 + spawnAreaY; num234++) + int spawnAreaY = Main.maxTilesY - projTileX; + for (int j = projTileX; j < projTileX + spawnAreaY; j++) { - Tile tile = Main.tile[num232, num234 + 10]; + Tile tile = Main.tile[projTileY, j + 10]; if (tile.HasTile && !TileID.Sets.Platforms[tile.TileType] && (Main.tileSolid[(int)tile.TileType] || tile.LiquidAmount != 0)) { - num231 = num234; + projTileX = j; break; } } int spawnLimitY = (int)(Main.player[Projectile.owner].Center.Y / 16f) + 75; - if (num231 > spawnLimitY) + if (projTileX > spawnLimitY) { - num231 = spawnLimitY; + projTileX = spawnLimitY; } - int num236 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)(num232 * 16 + 8), (float)(num231 * 16 - 24), 0f, 0f, ModContent.ProjectileType(), 0, 4f, Main.myPlayer, 11f, 24f + (revenge ? 2f : 0f)); - Main.projectile[num236].netUpdate = true; + int infernadoSpawn = Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)(projTileY * 16 + 8), (float)(projTileX * 16 - 24), 0f, 0f, ModContent.ProjectileType(), 0, 4f, Main.myPlayer, 11f, 24f + (revenge ? 2f : 0f)); + Main.projectile[infernadoSpawn].netUpdate = true; } } } diff --git a/Projectiles/Boss/BirbAura.cs b/Projectiles/Boss/BirbAura.cs index f211dc83e4..65f3c62477 100644 --- a/Projectiles/Boss/BirbAura.cs +++ b/Projectiles/Boss/BirbAura.cs @@ -1,14 +1,14 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; +using System; using System.IO; +using CalamityMod.Sounds; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; +using Terraria.Audio; using Terraria.Enums; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; -using ReLogic.Content; -using CalamityMod.Sounds; namespace CalamityMod.Projectiles.Boss { @@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Boss if (timer > 0f) timer -= 1f; - float num801 = 1f; + float projScale = 1f; if (timeBeforeVanish == 0f) timeBeforeVanish = Projectile.timeLeft <= 900 ? 900f : 1200f; @@ -77,35 +77,33 @@ namespace CalamityMod.Projectiles.Boss return; } - Projectile.scale = (float)Math.Sin(Projectile.localAI[0] * Math.PI / timeBeforeVanish) * 10f * num801; - if (Projectile.scale > num801) - Projectile.scale = num801; + Projectile.scale = (float)Math.Sin(Projectile.localAI[0] * Math.PI / timeBeforeVanish) * 10f * projScale; + if (Projectile.scale > projScale) + Projectile.scale = projScale; - float num804 = Projectile.velocity.ToRotation(); - Projectile.rotation = num804 - MathHelper.PiOver2; - Projectile.velocity = num804.ToRotationVector2(); + float projVelRotation = Projectile.velocity.ToRotation(); + Projectile.rotation = projVelRotation - MathHelper.PiOver2; + Projectile.velocity = projVelRotation.ToRotationVector2(); - float num805 = 3f; //3f - float num806 = Projectile.width; + float projWidth = Projectile.width; Vector2 samplingPoint = Projectile.Center; if (vector78.HasValue) samplingPoint = vector78.Value; float laserLength = Projectile.ai[1] - 160f; - float[] array3 = new float[(int)num805]; - Collision.LaserScan(samplingPoint, Projectile.velocity, num806 * Projectile.scale, laserLength, array3); - float num807 = 0f; - for (int num808 = 0; num808 < array3.Length; num808++) + float[] array3 = new float[3]; + Collision.LaserScan(samplingPoint, Projectile.velocity, projWidth * Projectile.scale, laserLength, array3); + float auraLength = 0f; + for (int j = 0; j < array3.Length; j++) { - num807 += array3[num808]; + auraLength += array3[j]; } - num807 /= num805; + auraLength /= 3f; - num807 = MathHelper.Clamp(num807, 3600f, 4800f); + auraLength = MathHelper.Clamp(auraLength, 3600f, 4800f); - float amount = 0.5f; - Projectile.localAI[1] = MathHelper.Lerp(Projectile.localAI[1], num807, amount); + Projectile.localAI[1] = MathHelper.Lerp(Projectile.localAI[1], auraLength, 0.5f); DelegateMethods.v3_1 = new Vector3(0.9f, 0.3f, 0.3f); Utils.PlotTileLine(Projectile.Center, Projectile.Center + Projectile.velocity * Projectile.localAI[1], Projectile.width * Projectile.scale, DelegateMethods.CastLight); @@ -137,37 +135,37 @@ namespace CalamityMod.Projectiles.Boss Texture2D texture = ModContent.Request(Texture).Value; Texture2D texture2 = ModContent.Request("CalamityMod/ExtraTextures/Lasers/BirbAuraStart", AssetRequestMode.ImmediateLoad).Value; Texture2D texture3 = ModContent.Request("CalamityMod/ExtraTextures/Lasers/BirbAuraEnd", AssetRequestMode.ImmediateLoad).Value; - float num223 = Projectile.localAI[1]; //length of laser - Color color44 = new Color(128, 128, 128, 0); + float auraDrawLength = Projectile.localAI[1]; //length of laser + Color grayColor = new Color(128, 128, 128, 0); Vector2 vector = Projectile.Center - Main.screenPosition; Rectangle? sourceRectangle2 = null; - Main.EntitySpriteDraw(texture2, vector, sourceRectangle2, color44, Projectile.rotation, texture2.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); - num223 -= (texture2.Height / 2 + texture3.Height) * Projectile.scale; - Vector2 value20 = Projectile.Center; - value20 += Projectile.velocity * Projectile.scale * texture2.Height / 2f; - if (num223 > 0f) + Main.EntitySpriteDraw(texture2, vector, sourceRectangle2, grayColor, Projectile.rotation, texture2.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); + auraDrawLength -= (texture2.Height / 2 + texture3.Height) * Projectile.scale; + Vector2 projCenter = Projectile.Center; + projCenter += Projectile.velocity * Projectile.scale * texture2.Height / 2f; + if (auraDrawLength > 0f) { - float num224 = 0f; - Rectangle rectangle7 = new Rectangle(0, 0, texture.Width, texture.Height); - while (num224 + 1f < num223) + float auraSegment = 0f; + Rectangle drawRectangle = new Rectangle(0, 0, texture.Width, texture.Height); + while (auraSegment + 1f < auraDrawLength) { - if (num223 - num224 < rectangle7.Height) + if (auraDrawLength - auraSegment < drawRectangle.Height) { - rectangle7.Height = (int)(num223 - num224); + drawRectangle.Height = (int)(auraDrawLength - auraSegment); } - Main.EntitySpriteDraw(texture, value20 - Main.screenPosition, new Rectangle?(rectangle7), color44, Projectile.rotation, new Vector2(rectangle7.Width / 2, 0f), Projectile.scale, SpriteEffects.None, 0); - num224 += rectangle7.Height * Projectile.scale; - value20 += Projectile.velocity * rectangle7.Height * Projectile.scale; - rectangle7.Y += texture.Height; - if (rectangle7.Y + rectangle7.Height > texture.Height) + Main.EntitySpriteDraw(texture, projCenter - Main.screenPosition, new Rectangle?(drawRectangle), grayColor, Projectile.rotation, new Vector2(drawRectangle.Width / 2, 0f), Projectile.scale, SpriteEffects.None, 0); + auraSegment += drawRectangle.Height * Projectile.scale; + projCenter += Projectile.velocity * drawRectangle.Height * Projectile.scale; + drawRectangle.Y += texture.Height; + if (drawRectangle.Y + drawRectangle.Height > texture.Height) { - rectangle7.Y = 0; + drawRectangle.Y = 0; } } } - Vector2 vector2 = value20 - Main.screenPosition; + Vector2 vector2 = projCenter - Main.screenPosition; sourceRectangle2 = null; - Main.EntitySpriteDraw(texture3, vector2, sourceRectangle2, color44, Projectile.rotation, texture3.Frame(1, 1, 0, 0).Top(), Projectile.scale, SpriteEffects.None, 0); + Main.EntitySpriteDraw(texture3, vector2, sourceRectangle2, grayColor, Projectile.rotation, texture3.Frame(1, 1, 0, 0).Top(), Projectile.scale, SpriteEffects.None, 0); return false; } @@ -188,8 +186,8 @@ namespace CalamityMod.Projectiles.Boss { return true; } - float num6 = 0f; - if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center + Projectile.velocity * Projectile.localAI[1], 80f * Projectile.scale, ref num6)) + float useless = 0f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center + Projectile.velocity * Projectile.localAI[1], 80f * Projectile.scale, ref useless)) { return true; } diff --git a/Projectiles/Boss/BirbAuraFlare.cs b/Projectiles/Boss/BirbAuraFlare.cs index 1c8dce2446..a865c28167 100644 --- a/Projectiles/Boss/BirbAuraFlare.cs +++ b/Projectiles/Boss/BirbAuraFlare.cs @@ -40,35 +40,35 @@ namespace CalamityMod.Projectiles.Boss { if (Projectile.ai[1] > 0f) { - int num625 = (int)Projectile.ai[1] - 1; - if (num625 < 255) + int playerTracker = (int)Projectile.ai[1] - 1; + if (playerTracker < 255) { Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 10f) { // Dust pulse effect Projectile.localAI[1] = (float)Math.Abs(Math.Cos(MathHelper.ToRadians(Projectile.localAI[0] * 2f))); - int num626 = 18; - for (int num627 = 0; num627 < num626; num627++) + int dustAmt = 18; + for (int i = 0; i < dustAmt; i++) { - Vector2 vector45 = Vector2.Normalize(Projectile.velocity) * new Vector2(Projectile.width / 2f, Projectile.height) * Projectile.localAI[1]; - vector45 = vector45.RotatedBy((num627 - (num626 / 2 - 1)) * 3.1415926535897931 / (float)num626) + Projectile.Center; - Vector2 value15 = ((float)(Main.rand.NextDouble() * Math.PI) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num628 = Dust.NewDust(vector45 + value15, 0, 0, 60, value15.X * 2f, value15.Y * 2f, 100, default, 1f); - Main.dust[num628].scale = 1.4f; - Main.dust[num628].noGravity = true; - Main.dust[num628].noLight = true; - Main.dust[num628].velocity /= 4f; - Main.dust[num628].velocity -= Projectile.velocity; + Vector2 dustRotation = Vector2.Normalize(Projectile.velocity) * new Vector2(Projectile.width / 2f, Projectile.height) * Projectile.localAI[1]; + dustRotation = dustRotation.RotatedBy((i - (dustAmt / 2 - 1)) * 3.1415926535897931 / (float)dustAmt) + Projectile.Center; + Vector2 randomDustPos = ((float)(Main.rand.NextDouble() * Math.PI) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); + int lightningDust = Dust.NewDust(dustRotation + randomDustPos, 0, 0, 60, randomDustPos.X * 2f, randomDustPos.Y * 2f, 100, default, 1f); + Main.dust[lightningDust].scale = 1.4f; + Main.dust[lightningDust].noGravity = true; + Main.dust[lightningDust].noLight = true; + Main.dust[lightningDust].velocity /= 4f; + Main.dust[lightningDust].velocity -= Projectile.velocity; } } - Vector2 value16 = Main.player[num625].Center - Projectile.Center; - float num629 = 4f; + Vector2 playerDistance = Main.player[playerTracker].Center - Projectile.Center; + float projVelocityMult = 4f; float divisor = 60f - 15f * Projectile.ai[0]; - num629 += Projectile.localAI[0] / divisor; - Projectile.velocity = Vector2.Normalize(value16) * num629; - if (value16.Length() < 32f) + projVelocityMult += Projectile.localAI[0] / divisor; + Projectile.velocity = Vector2.Normalize(playerDistance) * projVelocityMult; + if (playerDistance.Length() < 32f) { Projectile.Kill(); } @@ -79,40 +79,39 @@ namespace CalamityMod.Projectiles.Boss public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.DD2_BetsyFireballImpact, Projectile.Center); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int killDustAmt = 36; + for (int i = 0; i < killDustAmt; i++) { Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2(Projectile.width / 2f, Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((num227 - (num226 / 2 - 1)) * MathHelper.TwoPi / num226) + Projectile.Center; + vector6 = vector6.RotatedBy((i - (killDustAmt / 2 - 1)) * MathHelper.TwoPi / killDustAmt) + Projectile.Center; Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 60, vector7.X, vector7.Y, 100, default, 1.4f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + int killLightningDust = Dust.NewDust(vector6 + vector7, 0, 0, 60, vector7.X, vector7.Y, 100, default, 1.4f); + Main.dust[killLightningDust].noGravity = true; + Main.dust[killLightningDust].noLight = true; + Main.dust[killLightningDust].velocity = vector7; } if (Projectile.owner == Main.myPlayer) { - int num231 = (int)(Projectile.Center.Y / 16f); - int num232 = (int)(Projectile.Center.X / 16f); - int num233 = 100; - if (num232 < 10) + int projTileX = (int)(Projectile.Center.Y / 16f); + int projTileY = (int)(Projectile.Center.X / 16f); + if (projTileY < 10) { - num232 = 10; + projTileY = 10; } - if (num232 > Main.maxTilesX - 10) + if (projTileY > Main.maxTilesX - 10) { - num232 = Main.maxTilesX - 10; + projTileY = Main.maxTilesX - 10; } - if (num231 < 10) + if (projTileX < 10) { - num231 = 10; + projTileX = 10; } - if (num231 > Main.maxTilesY - num233 - 10) + if (projTileX > Main.maxTilesY - 110) { - num231 = Main.maxTilesY - num233 - 10; + projTileX = Main.maxTilesY - 110; } - float x = num232 * 16; - float y = num231 * 16 + 900; + float x = projTileY * 16; + float y = projTileX * 16 + 900; Vector2 laserVelocity = new Vector2(x, 160f) - new Vector2(x, y); int type = ModContent.ProjectileType(); int damage = Projectile.GetProjectileDamage(ModContent.NPCType()); @@ -125,9 +124,9 @@ namespace CalamityMod.Projectiles.Boss } laserVelocity = new Vector2(x, 160f) - new Vector2(x, y); laserVelocity.Normalize(); - int num237 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), x, y, 0f, laserVelocity.Y, type, damage, 0f, Main.myPlayer, x, y); - Main.projectile[num237].timeLeft = 900; - Main.projectile[num237].netUpdate = true; + int thirdPhaseRightLaser = Projectile.NewProjectile(Projectile.GetSource_FromThis(), x, y, 0f, laserVelocity.Y, type, damage, 0f, Main.myPlayer, x, y); + Main.projectile[thirdPhaseRightLaser].timeLeft = 900; + Main.projectile[thirdPhaseRightLaser].netUpdate = true; x -= 2000f; if ((int)(x / 16f) < 10) @@ -136,15 +135,15 @@ namespace CalamityMod.Projectiles.Boss } laserVelocity = new Vector2(x, 160f) - new Vector2(x, y); laserVelocity.Normalize(); - int num238 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), x, y, 0f, laserVelocity.Y, type, damage, 0f, Main.myPlayer, x, y); - Main.projectile[num238].timeLeft = 900; - Main.projectile[num238].netUpdate = true; + int thirdPhaseLeftLaser = Projectile.NewProjectile(Projectile.GetSource_FromThis(), x, y, 0f, laserVelocity.Y, type, damage, 0f, Main.myPlayer, x, y); + Main.projectile[thirdPhaseLeftLaser].timeLeft = 900; + Main.projectile[thirdPhaseLeftLaser].netUpdate = true; } else { laserVelocity.Normalize(); - int num236 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), x, y, 0f, laserVelocity.Y, type, damage, 0f, Main.myPlayer, x, y); - Main.projectile[num236].netUpdate = true; + int secondPhaseLaser = Projectile.NewProjectile(Projectile.GetSource_FromThis(), x, y, 0f, laserVelocity.Y, type, damage, 0f, Main.myPlayer, x, y); + Main.projectile[secondPhaseLaser].netUpdate = true; } } } diff --git a/Projectiles/Boss/BloodGeyser.cs b/Projectiles/Boss/BloodGeyser.cs index 45af5469f0..5d81a128e5 100644 --- a/Projectiles/Boss/BloodGeyser.cs +++ b/Projectiles/Boss/BloodGeyser.cs @@ -33,9 +33,9 @@ namespace CalamityMod.Projectiles.Boss Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver2; - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, DustID.Blood, 0f, 0f, 100, default, 0.5f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int bloody = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, DustID.Blood, 0f, 0f, 100, default, 0.5f); + Main.dust[bloody].noGravity = true; + Main.dust[bloody].velocity *= 0f; if (Projectile.velocity.Y < 12f) Projectile.velocity.Y += 0.06f; diff --git a/Projectiles/Boss/BrimstoneBall.cs b/Projectiles/Boss/BrimstoneBall.cs index 8e3b2899ba..74ee3fd7f0 100644 --- a/Projectiles/Boss/BrimstoneBall.cs +++ b/Projectiles/Boss/BrimstoneBall.cs @@ -25,12 +25,12 @@ namespace CalamityMod.Projectiles.Boss Lighting.AddLight(Projectile.Center, 0.25f, 0f, 0f); - for (int num468 = 0; num468 < 2; num468++) + for (int i = 0; i < 2; i++) { Vector2 dspeed = -Projectile.velocity * 0.7f; - int num469 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 150, default, 1.1f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity = dspeed; + int brimDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 150, default, 1.1f); + Main.dust[brimDust].noGravity = true; + Main.dust[brimDust].velocity = dspeed; } } diff --git a/Projectiles/Boss/BrimstoneFire.cs b/Projectiles/Boss/BrimstoneFire.cs index 8cc17235dd..e4f7699ef2 100644 --- a/Projectiles/Boss/BrimstoneFire.cs +++ b/Projectiles/Boss/BrimstoneFire.cs @@ -1,76 +1,153 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Boss { public class BrimstoneFire : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Boss"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override string Texture => "CalamityMod/Projectiles/FireProj"; + + public static int Lifetime => 90; + public static int Fadetime => 80; + public ref float Time => ref Projectile.ai[0]; + public int MistType = -1; public override void SetDefaults() { - Projectile.width = 6; - Projectile.height = 6; + Projectile.width = Projectile.height = 10; Projectile.hostile = true; Projectile.ignoreWater = true; Projectile.penetrate = -1; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 90; + Projectile.MaxUpdates = 3; + Projectile.timeLeft = Lifetime; CooldownSlot = ImmunityCooldownID.Bosses; } public override void AI() { - Lighting.AddLight(Projectile.Center, 0.3f, 0f, 0f); - if (Projectile.ai[0] > 7f) + Time++; + if (Time < Fadetime && Main.rand.NextBool(6)) { - float scalar = 1f; - if (Projectile.ai[0] == 8f) + Vector2 cinderPos = Projectile.Center + Main.rand.NextVector2Circular(60f, 60f) * Utils.Remap(Time, 0f, Lifetime, 0.5f, 1f); + float cinderSize = Utils.GetLerpValue(6f, 12f, Time, true); + Dust cinder = Dust.NewDustDirect(cinderPos, 4, 4, ModContent.DustType(), Projectile.velocity.X * 0.25f, Projectile.velocity.Y * 0.25f); + if (Main.rand.NextBool(3)) { - scalar = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - scalar = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - scalar = 0.75f; - } - Projectile.ai[0] += 1f; - int dustType = (int)CalamityDusts.Brimstone; - if (Main.rand.NextBool()) - { - int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.1f, Projectile.velocity.Y * 0.1f, 100, default, 1f); - Dust dust = Main.dust[fire]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 3f; - } - else - { - dust.scale *= 1.5f; - } - dust.scale *= scalar; + cinder.scale *= 2f; + cinder.velocity *= 2f; } + cinder.noGravity = true; + cinder.scale *= cinderSize * 1.2f; + cinder.velocity += Projectile.velocity * Utils.Remap(Time, 0f, Fadetime * 0.75f, 1f, 0.1f) * Utils.Remap(Time, 0f, Fadetime * 0.1f, 0.1f, 1f); } - else - { - Projectile.ai[0] += 1f; - } - Projectile.rotation += 0.3f * (float)Projectile.direction; + + if (MistType == -1) + MistType = Main.rand.Next(3); + + Lighting.AddLight(Projectile.Center, 0.75f, 0.15f, 0.15f); } + // Keeping the flames in place when hitting a block + public override bool OnTileCollide(Vector2 oldVelocity) + { + Projectile.velocity = oldVelocity * 0.95f; + Projectile.position -= Projectile.velocity; + Time++; + Projectile.timeLeft--; + return false; + } + + // Expanding hitbox + // A bit more generous than Havoc's Breath fire because enemy projectiles + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + int size = (int)Utils.Remap(Time, 0f, Fadetime, 8f, 32f); + + // Shrinks again after fading + if (Time > Fadetime) + size = (int)Utils.Remap(Time, Fadetime, Lifetime, 32f, 0f); + hitbox.Inflate(size, size); + } + + // Anti-wall hacking checks + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => projHitbox.Intersects(targetHitbox) && Collision.CanHit(Projectile.Center, 0, 0, targetHitbox.Center.ToVector2(), 0, 0) ? null : false; + public override void OnHitPlayer(Player target, Player.HurtInfo info) { if (info.Damage <= 0) return; target.AddBuff(ModContent.BuffType(), 150); + + // Cook you up (still scales with player size in case it's manipulated) + int smokeCount = 4 + (int)MathHelper.Clamp(target.width * 0.1f, 0f, 20f); + for (int i = 0; i < smokeCount; i++) + { + Vector2 smokePos = target.Center + Main.rand.NextVector2Circular(target.width * 0.5f, target.height * 0.5f); + Vector2 smokeVel = Vector2.UnitY * Main.rand.NextFloat(-2.4f, -0.8f) * MathHelper.Clamp(target.height * 0.1f, 1f, 10f); + Particle smoke = new MediumMistParticle(smokePos, smokeVel, new Color(255, 50, 50), Color.DimGray, Main.rand.NextFloat(1f, 2f), 245 - Main.rand.Next(50), 0.1f); + GeneralParticleHandler.SpawnParticle(smoke); + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D fire = ModContent.Request(Texture).Value; + Texture2D mist = ModContent.Request("CalamityMod/Particles/MediumMist").Value; + + // The conga line of colors to sift through + Color color1 = new Color(255, 110, 100, 200); + Color color2 = new Color(255, 50, 50, 70); + Color color3 = new Color(255, 100, 100, 100); + Color color4 = new Color(200, 35, 30, 100); + float length = ((Time > Fadetime - 10f) ? 0.1f : 0.15f); + float vOffset = Math.Min(Time, 20f); + float timeRatio = Utils.GetLerpValue(0f, Lifetime, Time); + float fireSize = Utils.Remap(timeRatio, 0.2f, 0.5f, 0.25f, 1f); + + if (timeRatio >= 1f) + return false; + + for (float j = 1f; j >= 0f; j -= length) + { + // Color + Color fireColor = ((timeRatio < 0.1f) ? Color.Lerp(Color.Transparent, color1, Utils.GetLerpValue(0f, 0.1f, timeRatio)) : + ((timeRatio < 0.2f) ? Color.Lerp(color1, color2, Utils.GetLerpValue(0.1f, 0.2f, timeRatio)) : + ((timeRatio < 0.35f) ? color2 : + ((timeRatio < 0.7f) ? Color.Lerp(color2, color3, Utils.GetLerpValue(0.35f, 0.7f, timeRatio)) : + ((timeRatio < 0.85f) ? Color.Lerp(color3, color4, Utils.GetLerpValue(0.7f, 0.85f, timeRatio)) : + Color.Lerp(color4, Color.Transparent, Utils.GetLerpValue(0.85f, 1f, timeRatio))))))); + fireColor *= (1f - j) * Utils.GetLerpValue(0f, 0.2f, timeRatio, true); + Color innerColor = Color.Lerp(fireColor, Color.Black, 0.3f); + + // Positions and rotations + Vector2 firePos = Projectile.Center - Main.screenPosition - Projectile.velocity * vOffset * j; + float mainRot = -j * MathHelper.PiOver2 - Main.GlobalTimeWrappedHourly * (j + 1f) * 2f / length; + float trailRot = MathHelper.PiOver4 - mainRot; + + // Draw one backtrail + Vector2 trailOffset = Projectile.velocity * vOffset * length * 0.5f; + Main.EntitySpriteDraw(fire, firePos - trailOffset, null, innerColor * 0.25f, trailRot, fire.Size() * 0.5f, fireSize, SpriteEffects.None); + + // Draw the main fire + Main.EntitySpriteDraw(fire, firePos, null, innerColor, mainRot, fire.Size() * 0.5f, fireSize, SpriteEffects.None); + + // Draw the masking smoke + Main.spriteBatch.SetBlendState(BlendState.Additive); + Rectangle frame = mist.Frame(1, 3, 0, MistType); + Main.EntitySpriteDraw(mist, firePos, frame, Color.Lerp(fireColor, Color.White, 0.3f), mainRot, frame.Size() * 0.5f, fireSize, SpriteEffects.None); + Main.EntitySpriteDraw(mist, firePos, frame, fireColor, mainRot, frame.Size() * 0.5f, fireSize * 3f, SpriteEffects.None); + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + } + return false; } } } diff --git a/Projectiles/Boss/BrimstoneHellfireball.cs b/Projectiles/Boss/BrimstoneHellfireball.cs index 12748e6d7b..626c209abc 100644 --- a/Projectiles/Boss/BrimstoneHellfireball.cs +++ b/Projectiles/Boss/BrimstoneHellfireball.cs @@ -67,10 +67,10 @@ namespace CalamityMod.Projectiles.Boss Projectile.localAI[0] += 1f; } - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 170, default, 1.1f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int brimDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 170, default, 1.1f); + Main.dust[brimDust].noGravity = true; + Main.dust[brimDust].velocity *= 0.5f; + Main.dust[brimDust].velocity += Projectile.velocity * 0.1f; } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Boss/BrimstoneRay.cs b/Projectiles/Boss/BrimstoneRay.cs index fbd382f4f2..0ea9bcbaa3 100644 --- a/Projectiles/Boss/BrimstoneRay.cs +++ b/Projectiles/Boss/BrimstoneRay.cs @@ -1,17 +1,17 @@ -using CalamityMod.Buffs.DamageOverTime; +using System; +using System.IO; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.NPCs.BrimstoneElemental; -using CalamityMod.Dusts; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; -using System.IO; +using ReLogic.Content; using Terraria; using Terraria.Enums; using Terraria.ID; using Terraria.ModLoader; -using ReLogic.Content; namespace CalamityMod.Projectiles.Boss { @@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Boss else Projectile.Kill(); - float num801 = 1f; + float projScale = 1f; Projectile.localAI[0] += 1f; if (Projectile.localAI[0] >= 45f) { @@ -74,21 +74,20 @@ namespace CalamityMod.Projectiles.Boss return; } - Projectile.scale = (float)Math.Sin(Projectile.localAI[0] * (float)Math.PI / 45f) * 10f * num801; - if (Projectile.scale > num801) - Projectile.scale = num801; + Projectile.scale = (float)Math.Sin(Projectile.localAI[0] * (float)Math.PI / 45f) * 10f * projScale; + if (Projectile.scale > projScale) + Projectile.scale = projScale; - float num804 = Projectile.velocity.ToRotation(); + float projVelRotation = Projectile.velocity.ToRotation(); // Rotating beam for test AI if (Projectile.ai[0] > 0f) - num804 += Main.npc[(int)Projectile.ai[1]].spriteDirection * MathHelper.TwoPi / 360f; + projVelRotation += Main.npc[(int)Projectile.ai[1]].spriteDirection * MathHelper.TwoPi / 360f; - Projectile.rotation = num804 - MathHelper.PiOver2; - Projectile.velocity = num804.ToRotationVector2(); + Projectile.rotation = projVelRotation - MathHelper.PiOver2; + Projectile.velocity = projVelRotation.ToRotationVector2(); - float num805 = 3f; //3f - float num806 = Projectile.width; + float projWidth = Projectile.width; Vector2 samplingPoint = Projectile.Center; if (vector78.HasValue) @@ -96,24 +95,23 @@ namespace CalamityMod.Projectiles.Boss samplingPoint = vector78.Value; } - float[] array3 = new float[(int)num805]; - Collision.LaserScan(samplingPoint, Projectile.velocity, num806 * Projectile.scale, 2400f, array3); - float num807 = 0f; - for (int num808 = 0; num808 < array3.Length; num808++) + float[] array3 = new float[3]; + Collision.LaserScan(samplingPoint, Projectile.velocity, projWidth * Projectile.scale, 2400f, array3); + float rayLength = 0f; + for (int i = 0; i < array3.Length; i++) { - num807 += array3[num808]; + rayLength += array3[i]; } - num807 /= num805; + rayLength /= 3f; // Fire laser through walls at max length if target cannot be seen if (!Collision.CanHitLine(Main.npc[(int)Projectile.ai[1]].Center, 1, 1, Main.player[Main.npc[(int)Projectile.ai[1]].target].Center, 1, 1)) { - num807 = 2400f; + rayLength = 2400f; } - float amount = 0.5f; //0.5f - Projectile.localAI[1] = MathHelper.Lerp(Projectile.localAI[1], num807, amount); //length of laser, linear interpolation - Vector2 vector79 = Projectile.Center + Projectile.velocity * (Projectile.localAI[1] - 14f); + Projectile.localAI[1] = MathHelper.Lerp(Projectile.localAI[1], rayLength, 0.5f); //length of laser, linear interpolation + Vector2 dustSpawnPos = Projectile.Center + Projectile.velocity * (Projectile.localAI[1] - 14f); // Fire brimstone darts along the laser bool bossRush = BossRushEvent.BossRushActive; @@ -143,23 +141,23 @@ namespace CalamityMod.Projectiles.Boss } } - for (int num809 = 0; num809 < 2; num809++) + for (int j = 0; j < 2; j++) { - float num810 = Projectile.velocity.ToRotation() + ((Main.rand.Next(2) == 1) ? -1f : 1f) * MathHelper.PiOver2; - float num811 = (float)Main.rand.NextDouble() * 2f + 2f; - Vector2 vector80 = new Vector2((float)Math.Cos(num810) * num811, (float)Math.Sin(num810) * num811); - int num812 = Dust.NewDust(vector79, 0, 0, (int)CalamityDusts.Brimstone, vector80.X, vector80.Y, 0, default, 1f); - Main.dust[num812].noGravity = true; - Main.dust[num812].scale = 1.7f; + float dustRotation = Projectile.velocity.ToRotation() + ((Main.rand.Next(2) == 1) ? -1f : 1f) * MathHelper.PiOver2; + float randomFloatOffset = (float)Main.rand.NextDouble() * 2f + 2f; + Vector2 dustDirection = new Vector2((float)Math.Cos(dustRotation) * randomFloatOffset, (float)Math.Sin(dustRotation) * randomFloatOffset); + int brimDust = Dust.NewDust(dustSpawnPos, 0, 0, (int)CalamityDusts.Brimstone, dustDirection.X, dustDirection.Y, 0, default, 1f); + Main.dust[brimDust].noGravity = true; + Main.dust[brimDust].scale = 1.7f; } if (Main.rand.NextBool(5)) { - Vector2 value29 = Projectile.velocity.RotatedBy(MathHelper.PiOver2, default) * ((float)Main.rand.NextDouble() - 0.5f) * Projectile.width; - int num813 = Dust.NewDust(vector79 + value29 - Vector2.One * 4f, 8, 8, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); - Dust dust = Main.dust[num813]; + Vector2 extraDustSpawn = Projectile.velocity.RotatedBy(MathHelper.PiOver2, default) * ((float)Main.rand.NextDouble() - 0.5f) * Projectile.width; + int extraBrimDust = Dust.NewDust(dustSpawnPos + extraDustSpawn - Vector2.One * 4f, 8, 8, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); + Dust dust = Main.dust[extraBrimDust]; dust.velocity *= 0.5f; - Main.dust[num813].velocity.Y = -Math.Abs(Main.dust[num813].velocity.Y); + Main.dust[extraBrimDust].velocity.Y = -Math.Abs(Main.dust[extraBrimDust].velocity.Y); } DelegateMethods.v3_1 = new Vector3(0.9f, 0.3f, 0.3f); @@ -175,37 +173,37 @@ namespace CalamityMod.Projectiles.Boss Texture2D texture2D19 = ModContent.Request(Texture).Value; Texture2D texture2D20 = ModContent.Request("CalamityMod/ExtraTextures/Lasers/BrimstoneRayMid", AssetRequestMode.ImmediateLoad).Value; Texture2D texture2D21 = ModContent.Request("CalamityMod/ExtraTextures/Lasers/BrimstoneRayEnd", AssetRequestMode.ImmediateLoad).Value; - float num223 = Projectile.localAI[1]; //length of laser - Color color44 = new Color(255, 255, 255, 0) * 0.9f; + float rayDrawLength = Projectile.localAI[1]; //length of laser + Color baseColor = new Color(255, 255, 255, 0) * 0.9f; Vector2 vector = Projectile.Center - Main.screenPosition; Rectangle? sourceRectangle2 = null; - Main.EntitySpriteDraw(texture2D19, vector, sourceRectangle2, color44, Projectile.rotation, texture2D19.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); - num223 -= (texture2D19.Height / 2 + texture2D21.Height) * Projectile.scale; - Vector2 value20 = Projectile.Center; - value20 += Projectile.velocity * Projectile.scale * texture2D19.Height / 2f; - if (num223 > 0f) + Main.EntitySpriteDraw(texture2D19, vector, sourceRectangle2, baseColor, Projectile.rotation, texture2D19.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); + rayDrawLength -= (texture2D19.Height / 2 + texture2D21.Height) * Projectile.scale; + Vector2 projCenter = Projectile.Center; + projCenter += Projectile.velocity * Projectile.scale * texture2D19.Height / 2f; + if (rayDrawLength > 0f) { - float num224 = 0f; - Rectangle rectangle7 = new Rectangle(0, 0, texture2D20.Width, texture2D20.Height); - while (num224 + 1f < num223) + float raySegment = 0f; + Rectangle drawRectangle = new Rectangle(0, 0, texture2D20.Width, texture2D20.Height); + while (raySegment + 1f < rayDrawLength) { - if (num223 - num224 < rectangle7.Height) + if (rayDrawLength - raySegment < drawRectangle.Height) { - rectangle7.Height = (int)(num223 - num224); + drawRectangle.Height = (int)(rayDrawLength - raySegment); } - Main.EntitySpriteDraw(texture2D20, value20 - Main.screenPosition, new Rectangle?(rectangle7), color44, Projectile.rotation, new Vector2(rectangle7.Width / 2, 0f), Projectile.scale, SpriteEffects.None, 0); - num224 += rectangle7.Height * Projectile.scale; - value20 += Projectile.velocity * rectangle7.Height * Projectile.scale; - rectangle7.Y += texture2D20.Height; - if (rectangle7.Y + rectangle7.Height > texture2D20.Height) + Main.EntitySpriteDraw(texture2D20, projCenter - Main.screenPosition, new Rectangle?(drawRectangle), baseColor, Projectile.rotation, new Vector2(drawRectangle.Width / 2, 0f), Projectile.scale, SpriteEffects.None, 0); + raySegment += drawRectangle.Height * Projectile.scale; + projCenter += Projectile.velocity * drawRectangle.Height * Projectile.scale; + drawRectangle.Y += texture2D20.Height; + if (drawRectangle.Y + drawRectangle.Height > texture2D20.Height) { - rectangle7.Y = 0; + drawRectangle.Y = 0; } } } - Vector2 vector2 = value20 - Main.screenPosition; + Vector2 vector2 = projCenter - Main.screenPosition; sourceRectangle2 = null; - Main.EntitySpriteDraw(texture2D21, vector2, sourceRectangle2, color44, Projectile.rotation, texture2D21.Frame(1, 1, 0, 0).Top(), Projectile.scale, SpriteEffects.None, 0); + Main.EntitySpriteDraw(texture2D21, vector2, sourceRectangle2, baseColor, Projectile.rotation, texture2D21.Frame(1, 1, 0, 0).Top(), Projectile.scale, SpriteEffects.None, 0); return false; } @@ -222,8 +220,8 @@ namespace CalamityMod.Projectiles.Boss { return true; } - float num6 = 0f; - if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center + Projectile.velocity * Projectile.localAI[1], 22f * Projectile.scale, ref num6)) + float useless = 0f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center + Projectile.velocity * Projectile.localAI[1], 22f * Projectile.scale, ref useless)) { return true; } diff --git a/Projectiles/Boss/BrimstoneTargetRay.cs b/Projectiles/Boss/BrimstoneTargetRay.cs index 6e3af11f4e..7b0aa10e12 100644 --- a/Projectiles/Boss/BrimstoneTargetRay.cs +++ b/Projectiles/Boss/BrimstoneTargetRay.cs @@ -1,12 +1,13 @@ -using CalamityMod.NPCs.BrimstoneElemental; +using System.IO; +using CalamityMod.NPCs.BrimstoneElemental; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; -using System.IO; using Terraria; using Terraria.Enums; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Boss { public class BrimstoneTargetRay : ModProjectile, ILocalizedModType @@ -80,8 +81,7 @@ namespace CalamityMod.Projectiles.Boss } } - float num805 = 3f; //3f - float num806 = Projectile.width; + float projWidth = Projectile.width; Vector2 samplingPoint = Projectile.Center; if (vector78.HasValue) @@ -89,23 +89,23 @@ namespace CalamityMod.Projectiles.Boss samplingPoint = vector78.Value; } - float[] array3 = new float[(int)num805]; - Collision.LaserScan(samplingPoint, Projectile.velocity, num806 * Projectile.scale, 2400f, array3); - float num807 = 0f; - for (int num808 = 0; num808 < array3.Length; num808++) + float[] array3 = new float[3]; + Collision.LaserScan(samplingPoint, Projectile.velocity, projWidth * Projectile.scale, 2400f, array3); + float rayLength = 0f; + for (int i = 0; i < array3.Length; i++) { - num807 += array3[num808]; + rayLength += array3[i]; } - num807 /= num805; + rayLength /= 3f; // Fire laser through walls at max length if target cannot be seen if (!Collision.CanHitLine(Main.npc[(int)Projectile.ai[1]].Center, 1, 1, Main.player[Main.npc[(int)Projectile.ai[1]].target].Center, 1, 1)) { - num807 = 2400f; + rayLength = 2400f; } float amount = 0.5f; //0.5f - Projectile.localAI[1] = MathHelper.Lerp(Projectile.localAI[1], num807, amount); //length of laser, linear interpolation + Projectile.localAI[1] = MathHelper.Lerp(Projectile.localAI[1], rayLength, amount); //length of laser, linear interpolation DelegateMethods.v3_1 = new Vector3(0.9f, 0.3f, 0.3f); Utils.PlotTileLine(Projectile.Center, Projectile.Center + Projectile.velocity * Projectile.localAI[1], Projectile.width * Projectile.scale, DelegateMethods.CastLight); @@ -120,37 +120,37 @@ namespace CalamityMod.Projectiles.Boss Texture2D texture2D19 = ModContent.Request(Texture).Value; Texture2D texture2D20 = ModContent.Request("CalamityMod/ExtraTextures/Lasers/BrimstoneRayMid", AssetRequestMode.ImmediateLoad).Value; Texture2D texture2D21 = ModContent.Request("CalamityMod/ExtraTextures/Lasers/BrimstoneRayEnd", AssetRequestMode.ImmediateLoad).Value; - float num223 = Projectile.localAI[1]; //length of laser - Color color44 = new Color(255, 255, 255, 0) * 0.9f; + float rayDrawLength = Projectile.localAI[1]; //length of laser + Color baseColor = new Color(255, 255, 255, 0) * 0.9f; Vector2 vector = Projectile.Center - Main.screenPosition; Rectangle? sourceRectangle2 = null; - Main.EntitySpriteDraw(texture2D19, vector, sourceRectangle2, color44, Projectile.rotation, texture2D19.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); - num223 -= (texture2D19.Height / 2 + texture2D21.Height) * Projectile.scale; - Vector2 value20 = Projectile.Center; - value20 += Projectile.velocity * Projectile.scale * texture2D19.Height / 2f; - if (num223 > 0f) + Main.EntitySpriteDraw(texture2D19, vector, sourceRectangle2, baseColor, Projectile.rotation, texture2D19.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); + rayDrawLength -= (texture2D19.Height / 2 + texture2D21.Height) * Projectile.scale; + Vector2 projCenter = Projectile.Center; + projCenter += Projectile.velocity * Projectile.scale * texture2D19.Height / 2f; + if (rayDrawLength > 0f) { - float num224 = 0f; - Rectangle rectangle7 = new Rectangle(0, 16 * (Projectile.timeLeft / 3 % 5), texture2D20.Width, 16); - while (num224 + 1f < num223) + float raySegment = 0f; + Rectangle drawRectangle = new Rectangle(0, 16 * (Projectile.timeLeft / 3 % 5), texture2D20.Width, 16); + while (raySegment + 1f < rayDrawLength) { - if (num223 - num224 < rectangle7.Height) + if (rayDrawLength - raySegment < drawRectangle.Height) { - rectangle7.Height = (int)(num223 - num224); + drawRectangle.Height = (int)(rayDrawLength - raySegment); } - Main.EntitySpriteDraw(texture2D20, value20 - Main.screenPosition, new Rectangle?(rectangle7), color44, Projectile.rotation, new Vector2(rectangle7.Width / 2, 0f), Projectile.scale, SpriteEffects.None, 0); - num224 += rectangle7.Height * Projectile.scale; - value20 += Projectile.velocity * rectangle7.Height * Projectile.scale; - rectangle7.Y += 16; - if (rectangle7.Y + rectangle7.Height > texture2D20.Height) + Main.EntitySpriteDraw(texture2D20, projCenter - Main.screenPosition, new Rectangle?(drawRectangle), baseColor, Projectile.rotation, new Vector2(drawRectangle.Width / 2, 0f), Projectile.scale, SpriteEffects.None, 0); + raySegment += drawRectangle.Height * Projectile.scale; + projCenter += Projectile.velocity * drawRectangle.Height * Projectile.scale; + drawRectangle.Y += 16; + if (drawRectangle.Y + drawRectangle.Height > texture2D20.Height) { - rectangle7.Y = 0; + drawRectangle.Y = 0; } } } - Vector2 vector2 = value20 - Main.screenPosition; + Vector2 vector2 = projCenter - Main.screenPosition; sourceRectangle2 = null; - Main.EntitySpriteDraw(texture2D21, vector2, sourceRectangle2, color44, Projectile.rotation, texture2D21.Frame(1, 1, 0, 0).Top(), Projectile.scale, SpriteEffects.None, 0); + Main.EntitySpriteDraw(texture2D21, vector2, sourceRectangle2, baseColor, Projectile.rotation, texture2D21.Frame(1, 1, 0, 0).Top(), Projectile.scale, SpriteEffects.None, 0); return false; } @@ -167,8 +167,8 @@ namespace CalamityMod.Projectiles.Boss { return true; } - float num6 = 0f; - if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center + Projectile.velocity * Projectile.localAI[1], 22f * Projectile.scale, ref num6)) + float useless = 0f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center + Projectile.velocity * Projectile.localAI[1], 22f * Projectile.scale, ref useless)) { return true; } diff --git a/Projectiles/Boss/BrimstoneWave.cs b/Projectiles/Boss/BrimstoneWave.cs index 54940b2f6a..d9cd6952b1 100644 --- a/Projectiles/Boss/BrimstoneWave.cs +++ b/Projectiles/Boss/BrimstoneWave.cs @@ -74,8 +74,8 @@ namespace CalamityMod.Projectiles.Boss { SpriteEffects spriteEffects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Texture2D texture = ModContent.Request(Texture).Value; - int num214 = texture.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; + int framing = texture.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; lightColor.R = (byte)(255 * Projectile.Opacity); if (CalamityGlobalNPC.SCal != -1) @@ -87,7 +87,7 @@ namespace CalamityMod.Projectiles.Boss } } - Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, num214 / 2f), Projectile.scale, spriteEffects, 0); + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, framing / 2f), Projectile.scale, spriteEffects, 0); return false; } diff --git a/Projectiles/Boss/DarkEnergyBall.cs b/Projectiles/Boss/DarkEnergyBall.cs index 0f730cec06..237932a27f 100644 --- a/Projectiles/Boss/DarkEnergyBall.cs +++ b/Projectiles/Boss/DarkEnergyBall.cs @@ -103,25 +103,25 @@ namespace CalamityMod.Projectiles.Boss public override void OnKill(int timeLeft) { - for (int num621 = 0; num621 < 3; num621++) + for (int i = 0; i < 3; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; - Main.dust[num622].noGravity = true; + int cosmiliteDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1.2f); + Main.dust[cosmiliteDust].velocity *= 3f; + Main.dust[cosmiliteDust].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[cosmiliteDust].scale = 0.5f; + Main.dust[cosmiliteDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 5; num623++) + for (int j = 0; j < 5; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 2f; + int cosmiliteDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1.7f); + Main.dust[cosmiliteDust2].noGravity = true; + Main.dust[cosmiliteDust2].velocity *= 5f; + cosmiliteDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1f); + Main.dust[cosmiliteDust2].noGravity = true; + Main.dust[cosmiliteDust2].velocity *= 2f; } } } diff --git a/Projectiles/Boss/DarkEnergyBall2.cs b/Projectiles/Boss/DarkEnergyBall2.cs index a9b07a2097..67acbf3fb0 100644 --- a/Projectiles/Boss/DarkEnergyBall2.cs +++ b/Projectiles/Boss/DarkEnergyBall2.cs @@ -101,25 +101,25 @@ namespace CalamityMod.Projectiles.Boss public override void OnKill(int timeLeft) { - for (int num621 = 0; num621 < 3; num621++) + for (int i = 0; i < 3; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; - Main.dust[num622].noGravity = true; + int cosmiliteDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1.2f); + Main.dust[cosmiliteDust].velocity *= 3f; + Main.dust[cosmiliteDust].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[cosmiliteDust].scale = 0.5f; + Main.dust[cosmiliteDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 5; num623++) + for (int j = 0; j < 5; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 2f; + int cosmiliteDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1.7f); + Main.dust[cosmiliteDust2].noGravity = true; + Main.dust[cosmiliteDust2].velocity *= 5f; + cosmiliteDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1f); + Main.dust[cosmiliteDust2].noGravity = true; + Main.dust[cosmiliteDust2].velocity *= 2f; } } } diff --git a/Projectiles/Boss/DeusMine.cs b/Projectiles/Boss/DeusMine.cs index f1f7af7d71..fab0dbc5ea 100644 --- a/Projectiles/Boss/DeusMine.cs +++ b/Projectiles/Boss/DeusMine.cs @@ -101,21 +101,21 @@ namespace CalamityMod.Projectiles.Boss Projectile.width = Projectile.height = 96; Projectile.position.X = Projectile.position.X - (Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (Projectile.height / 2); - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; + int purpleDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.2f); + Main.dust[purpleDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[purpleDust].scale = 0.5f; + Main.dust[purpleDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 1.5f; + int astralDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 100, default, 1.7f); + Main.dust[astralDust].noGravity = true; + Main.dust[astralDust].velocity *= 1.5f; Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 100, default, 1f); } diff --git a/Projectiles/Boss/DoGBeam.cs b/Projectiles/Boss/DoGBeam.cs index c56b150337..7b87515033 100644 --- a/Projectiles/Boss/DoGBeam.cs +++ b/Projectiles/Boss/DoGBeam.cs @@ -44,17 +44,17 @@ namespace CalamityMod.Projectiles.Boss Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) + MathHelper.PiOver2; - int num103 = Player.FindClosest(Projectile.Center, 1, 1); + int playerTracker = Player.FindClosest(Projectile.Center, 1, 1); Projectile.ai[1] += 1f; if (Projectile.ai[1] < 120f && Projectile.ai[1] > 30f) { - float scaleFactor2 = Projectile.velocity.Length(); - Vector2 vector11 = Main.player[num103].Center - Projectile.Center; - vector11.Normalize(); - vector11 *= scaleFactor2; - Projectile.velocity = (Projectile.velocity * 20f + vector11) / 21f; + float projSpeed = Projectile.velocity.Length(); + Vector2 playerDistance = Main.player[playerTracker].Center - Projectile.Center; + playerDistance.Normalize(); + playerDistance *= projSpeed; + Projectile.velocity = (Projectile.velocity * 20f + playerDistance) / 21f; Projectile.velocity.Normalize(); - Projectile.velocity *= scaleFactor2; + Projectile.velocity *= projSpeed; } if (Projectile.timeLeft == 950) diff --git a/Projectiles/Boss/DoGBeamPortal.cs b/Projectiles/Boss/DoGBeamPortal.cs index 970a41e123..f505c744d5 100644 --- a/Projectiles/Boss/DoGBeamPortal.cs +++ b/Projectiles/Boss/DoGBeamPortal.cs @@ -58,25 +58,25 @@ namespace CalamityMod.Projectiles.Boss { SoundEngine.PlaySound(SoundID.Item92, Projectile.Center); - for (int num621 = 0; num621 < 15; num621++) + for (int i = 0; i < 15; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; - Main.dust[num622].noGravity = true; + int ectoDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 1.2f); + Main.dust[ectoDust].velocity *= 3f; + Main.dust[ectoDust].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[ectoDust].scale = 0.5f; + Main.dust[ectoDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 1f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 2f; + int ectoDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 1.7f); + Main.dust[ectoDust2].noGravity = true; + Main.dust[ectoDust2].velocity *= 5f; + ectoDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 1f); + Main.dust[ectoDust2].noGravity = true; + Main.dust[ectoDust2].velocity *= 2f; } Projectile.ai[1] = Projectile.ai[0]; diff --git a/Projectiles/Boss/DoGDeath.cs b/Projectiles/Boss/DoGDeath.cs index f2d9570527..8f5f2db940 100644 --- a/Projectiles/Boss/DoGDeath.cs +++ b/Projectiles/Boss/DoGDeath.cs @@ -21,10 +21,10 @@ namespace CalamityMod.Projectiles.Boss } public Vector2 OldVelocity; - public const float TelegraphTotalTime = 210f; - public const float TelegraphFadeTime = 30f; + public const float TelegraphTotalTime = 35f; + public const float TelegraphFadeTime = 5f; public const float TelegraphWidth = 2400f; - public const float FadeTime = 100f; + public const float FadeTime = 20f; public override void SetStaticDefaults() { @@ -41,8 +41,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.tileCollide = false; Projectile.Opacity = 0f; Projectile.penetrate = -1; - Projectile.extraUpdates = 5; - Projectile.timeLeft = 1800; + Projectile.timeLeft = 600; CooldownSlot = ImmunityCooldownID.Bosses; } diff --git a/Projectiles/Boss/DoGFire.cs b/Projectiles/Boss/DoGFire.cs index 008ae249fa..3437032d2d 100644 --- a/Projectiles/Boss/DoGFire.cs +++ b/Projectiles/Boss/DoGFire.cs @@ -83,48 +83,48 @@ namespace CalamityMod.Projectiles.Boss Projectile.width = Projectile.height = 64; Projectile.position.X = Projectile.position.X - Projectile.width / 2; Projectile.position.Y = Projectile.position.Y - Projectile.height / 2; - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int godSlay = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); + Main.dust[godSlay].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[godSlay].scale = 0.5f; + Main.dust[godSlay].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int godSlay2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 3f); + Main.dust[godSlay2].noGravity = true; + Main.dust[godSlay2].velocity *= 5f; + godSlay2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); + Main.dust[godSlay2].velocity *= 2f; } - for (int num640 = 0; num640 < 200; num640++) + for (int k = 0; k < 200; k++) { - float num641 = 12f; - if (num640 < 150) - num641 = 9f; - if (num640 < 100) - num641 = 6f; - if (num640 < 50) - num641 = 3f; + float dustScale = 12f; + if (k < 150) + dustScale = 9f; + if (k < 100) + dustScale = 6f; + if (k < 50) + dustScale = 3f; - int num643 = Dust.NewDust(Projectile.Center, 6, 6, 173, 0f, 0f, 100, default, 1f); - float num644 = Main.dust[num643].velocity.X; - float num645 = Main.dust[num643].velocity.Y; + int scalingDust = Dust.NewDust(Projectile.Center, 6, 6, 173, 0f, 0f, 100, default, 1f); + float scalingDustVelX = Main.dust[scalingDust].velocity.X; + float scalingDustVelY = Main.dust[scalingDust].velocity.Y; - if (num644 == 0f && num645 == 0f) - num644 = 1f; + if (scalingDustVelX == 0f && scalingDustVelY == 0f) + scalingDustVelX = 1f; - float num646 = (float)Math.Sqrt(num644 * num644 + num645 * num645); - num646 = num641 / num646; - num644 *= num646; - num645 *= num646; + float scalingDustVelocity = (float)Math.Sqrt(scalingDustVelX * scalingDustVelX + scalingDustVelY * scalingDustVelY); + scalingDustVelocity = dustScale / scalingDustVelocity; + scalingDustVelX *= scalingDustVelocity; + scalingDustVelY *= scalingDustVelocity; float scale = 1f; - switch ((int)num641) + switch ((int)dustScale) { case 4: scale = 1.2f; @@ -142,10 +142,10 @@ namespace CalamityMod.Projectiles.Boss break; } - Dust dust = Main.dust[num643]; + Dust dust = Main.dust[scalingDust]; dust.velocity *= 0.5f; - dust.velocity.X += num644; - dust.velocity.Y += num645; + dust.velocity.X += scalingDustVelX; + dust.velocity.Y += scalingDustVelY; dust.scale = scale; dust.noGravity = true; } diff --git a/Projectiles/Boss/EssenceDust.cs b/Projectiles/Boss/EssenceDust.cs index fcfac47f19..adac751278 100644 --- a/Projectiles/Boss/EssenceDust.cs +++ b/Projectiles/Boss/EssenceDust.cs @@ -24,11 +24,11 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { Lighting.AddLight(Projectile.Center, 0.45f, 0f, 0.55f); - for (int num468 = 0; num468 < 5; num468++) + for (int i = 0; i < 5; i++) { - int num469 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 0.5f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int essenceDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 0.5f); + Main.dust[essenceDust].noGravity = true; + Main.dust[essenceDust].velocity *= 0f; } } @@ -40,23 +40,23 @@ namespace CalamityMod.Projectiles.Boss Projectile.width = Projectile.height = size; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1f); - Main.dust[num622].velocity *= 3f; + int godSlay = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1f); + Main.dust[godSlay].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[godSlay].scale = 0.5f; + Main.dust[godSlay].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 15; num623++) + for (int j = 0; j < 15; j++) { - int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int godSlay2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); + Main.dust[godSlay2].noGravity = true; + Main.dust[godSlay2].velocity *= 5f; + godSlay2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1f); + Main.dust[godSlay2].velocity *= 2f; } Projectile.Damage(); } diff --git a/Projectiles/Boss/Flare.cs b/Projectiles/Boss/Flare.cs index 4113ded6da..ae7e75876f 100644 --- a/Projectiles/Boss/Flare.cs +++ b/Projectiles/Boss/Flare.cs @@ -55,13 +55,13 @@ namespace CalamityMod.Projectiles.Boss Projectile.frame = 0; } - float num630 = 0.209439516f; - float num631 = 4f; - float num632 = (float)(Math.Cos((double)(num630 * Projectile.ai[0])) - 0.5) * num631; - Projectile.velocity.Y = Projectile.velocity.Y - num632; + float wavingAmplitude = 0.209439516f; + float projVelocityMult = 4f; + float projFloatDirection = (float)(Math.Cos((double)(wavingAmplitude * Projectile.ai[0])) - 0.5) * projVelocityMult; + Projectile.velocity.Y = Projectile.velocity.Y - projFloatDirection; Projectile.ai[0] += 1f; - num632 = (float)(Math.Cos((double)(num630 * Projectile.ai[0])) - 0.5) * num631; - Projectile.velocity.Y = Projectile.velocity.Y + num632; + projFloatDirection = (float)(Math.Cos((double)(wavingAmplitude * Projectile.ai[0])) - 0.5) * projVelocityMult; + Projectile.velocity.Y = Projectile.velocity.Y + projFloatDirection; Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 10f) @@ -95,54 +95,53 @@ namespace CalamityMod.Projectiles.Boss { bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; SoundEngine.PlaySound(FlareSound, Projectile.Center); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int i = 0; i < dustAmt; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 244, vector7.X * 2f, vector7.Y * 2f, 100, default, 1.4f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 dustRotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + dustRotate = dustRotate.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; + Vector2 dustDirection = dustRotate - Projectile.Center; + int flareDust = Dust.NewDust(dustRotate + dustDirection, 0, 0, 244, dustDirection.X * 2f, dustDirection.Y * 2f, 100, default, 1.4f); + Main.dust[flareDust].noGravity = true; + Main.dust[flareDust].noLight = true; + Main.dust[flareDust].velocity = dustDirection; } if (Projectile.owner == Main.myPlayer) { - int num231 = (int)(Projectile.Center.Y / 16f); - int num232 = (int)(Projectile.Center.X / 16f); - int num233 = 100; - if (num232 < 10) + int projTileX = (int)(Projectile.Center.Y / 16f); + int projTileY = (int)(Projectile.Center.X / 16f); + if (projTileY < 10) { - num232 = 10; + projTileY = 10; } - if (num232 > Main.maxTilesX - 10) + if (projTileY > Main.maxTilesX - 10) { - num232 = Main.maxTilesX - 10; + projTileY = Main.maxTilesX - 10; } - if (num231 < 10) + if (projTileX < 10) { - num231 = 10; + projTileX = 10; } - if (num231 > Main.maxTilesY - num233 - 10) + if (projTileX > Main.maxTilesY - 110) { - num231 = Main.maxTilesY - num233 - 10; + projTileX = Main.maxTilesY - 110; } - for (int num234 = num231; num234 < num231 + num233; num234++) + for (int j = projTileX; j < projTileX + 100; j++) { - Tile tile = Main.tile[num232, num234]; + Tile tile = Main.tile[projTileY, j]; if (tile.HasTile && (Main.tileSolid[(int)tile.TileType] || tile.LiquidAmount != 0)) { - num231 = num234; + projTileX = j; break; } } int spawnLimitY = (int)(Main.player[Projectile.owner].Center.Y / 16f) + 25; - if (num231 > spawnLimitY) + if (projTileX > spawnLimitY) { - num231 = spawnLimitY; + projTileX = spawnLimitY; } - int num236 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)(num232 * 16 + 8), (float)(num231 * 16 - 24), 0f, 0f, ModContent.ProjectileType(), 0, 4f, Main.myPlayer, 11f, 10f + (revenge ? 1f : 0f)); - Main.projectile[num236].netUpdate = true; + int flarenadoSpawn = Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)(projTileY * 16 + 8), (float)(projTileX * 16 - 24), 0f, 0f, ModContent.ProjectileType(), 0, 4f, Main.myPlayer, 11f, 10f + (revenge ? 1f : 0f)); + Main.projectile[flarenadoSpawn].netUpdate = true; } } } diff --git a/Projectiles/Boss/FlareBomb.cs b/Projectiles/Boss/FlareBomb.cs index 06308c5beb..78ea47fe01 100644 --- a/Projectiles/Boss/FlareBomb.cs +++ b/Projectiles/Boss/FlareBomb.cs @@ -57,15 +57,14 @@ namespace CalamityMod.Projectiles.Boss return; float inertia = revenge ? 70f : 77f; - float num954 = 40f; - float scaleFactor12 = revenge ? 35f : 28f; - int num959 = (int)Projectile.ai[0]; - if (num959 >= 0 && Main.player[num959].active && !Main.player[num959].dead) + float velocityMult = revenge ? 35f : 28f; + int playerTracker = (int)Projectile.ai[0]; + if (playerTracker >= 0 && Main.player[playerTracker].active && !Main.player[playerTracker].dead) { - if (Projectile.Distance(Main.player[num959].Center) > num954) + if (Projectile.Distance(Main.player[playerTracker].Center) > 40f) { - Vector2 moveDirection = Projectile.SafeDirectionTo(Main.player[num959].Center, Vector2.UnitY); - Projectile.velocity = (Projectile.velocity * (inertia - 1f) + moveDirection * scaleFactor12) / inertia; + Vector2 moveDirection = Projectile.SafeDirectionTo(Main.player[playerTracker].Center, Vector2.UnitY); + Projectile.velocity = (Projectile.velocity * (inertia - 1f) + moveDirection * velocityMult) / inertia; } } else @@ -80,24 +79,24 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.timeLeft < 60) return; - float num1247 = 0.5f; - for (int num1248 = 0; num1248 < Main.maxProjectiles; num1248++) + float acceleration = 0.5f; + for (int j = 0; j < Main.maxProjectiles; j++) { - if (Main.projectile[num1248].active) + if (Main.projectile[j].active) { - if (num1248 != Projectile.whoAmI && Main.projectile[num1248].type == Projectile.type) + if (j != Projectile.whoAmI && Main.projectile[j].type == Projectile.type) { - if (Vector2.Distance(Projectile.Center, Main.projectile[num1248].Center) < 24f) + if (Vector2.Distance(Projectile.Center, Main.projectile[j].Center) < 24f) { - if (Projectile.position.X < Main.projectile[num1248].position.X) - Projectile.velocity.X -= num1247; + if (Projectile.position.X < Main.projectile[j].position.X) + Projectile.velocity.X -= acceleration; else - Projectile.velocity.X += num1247; + Projectile.velocity.X += acceleration; - if (Projectile.position.Y < Main.projectile[num1248].position.Y) - Projectile.velocity.Y -= num1247; + if (Projectile.position.Y < Main.projectile[j].position.Y) + Projectile.velocity.Y -= acceleration; else - Projectile.velocity.Y += num1247; + Projectile.velocity.Y += acceleration; } } } @@ -109,9 +108,9 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { Texture2D texture = ModContent.Request(Texture).Value; - int num214 = texture.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Rectangle(0, y6, texture.Width, num214), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = texture.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Rectangle(0, y6, texture.Width, framing), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } diff --git a/Projectiles/Boss/FlareDust.cs b/Projectiles/Boss/FlareDust.cs index ce1545d979..8016bf2334 100644 --- a/Projectiles/Boss/FlareDust.cs +++ b/Projectiles/Boss/FlareDust.cs @@ -79,17 +79,17 @@ namespace CalamityMod.Projectiles.Boss start = false; } - float amount = Projectile.localAI[0] / 120f; - if (amount > 1f) - amount = 1f; - distance += MathHelper.Lerp(1f, 9f, amount); + float earlyTimeProjSpeed = Projectile.localAI[0] / 120f; + if (earlyTimeProjSpeed > 1f) + earlyTimeProjSpeed = 1f; + distance += MathHelper.Lerp(1f, 9f, earlyTimeProjSpeed); if (Projectile.timeLeft < 380) { - float amount2 = (Projectile.localAI[0] - 300f) / 240f; - if (amount2 > 1f) - amount2 = 1f; - distance += MathHelper.Lerp(1f, 9f, amount2); + float longTimeProjSpeed = (Projectile.localAI[0] - 300f) / 240f; + if (longTimeProjSpeed > 1f) + longTimeProjSpeed = 1f; + distance += MathHelper.Lerp(1f, 9f, longTimeProjSpeed); } double rad = MathHelper.ToRadians(Projectile.ai[1]); @@ -104,7 +104,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.position.Y = startingPosY - (int)(Math.Sin(rad) * distance) - Projectile.height / 2; } - Projectile.ai[1] += (1.1f - amount) * 0.5f; + Projectile.ai[1] += (1.1f - earlyTimeProjSpeed) * 0.5f; Projectile.localAI[0] += 1f; } @@ -113,9 +113,9 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { Texture2D texture = ModContent.Request(Texture).Value; - int num214 = texture.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = texture.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } diff --git a/Projectiles/Boss/FlareDust2.cs b/Projectiles/Boss/FlareDust2.cs index 94d948448a..85c84343bb 100644 --- a/Projectiles/Boss/FlareDust2.cs +++ b/Projectiles/Boss/FlareDust2.cs @@ -53,9 +53,9 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { Texture2D texture = ModContent.Request(Texture).Value; - int num214 = texture.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = texture.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } diff --git a/Projectiles/Boss/Flarenado.cs b/Projectiles/Boss/Flarenado.cs index 7285cde7b5..66c0b66ff5 100644 --- a/Projectiles/Boss/Flarenado.cs +++ b/Projectiles/Boss/Flarenado.cs @@ -105,8 +105,8 @@ namespace CalamityMod.Projectiles.Boss Projectile.netUpdate = true; Vector2 center = Projectile.Center; center.Y -= baseHeight * Projectile.scale / 2f; - float num618 = (scaleBase - Projectile.ai[1] + 1f) * scaleMult / scaleBase; - center.Y -= baseHeight * num618 / 2f; + float finalProjHeight = (scaleBase - Projectile.ai[1] + 1f) * scaleMult / scaleBase; + center.Y -= baseHeight * finalProjHeight / 2f; center.Y += 2f; Projectile.NewProjectile(Projectile.GetSource_FromThis(), center, Projectile.velocity, Projectile.type, Projectile.damage, Projectile.knockBack, Projectile.owner, 11f, Projectile.ai[1] - 1f); } @@ -116,14 +116,14 @@ namespace CalamityMod.Projectiles.Boss bool breakapart = Main.zenithWorld && Projectile.localAI[1] >= breakThreshold; if (Projectile.ai[0] <= 0f && !breakapart) { - float num622 = 0.104719758f; - float num623 = (float)Projectile.width / 5f; - num623 *= 2f; - float num624 = (float)(Math.Cos((double)(num622 * -(double)Projectile.ai[0])) - 0.5) * num623; - Projectile.position.X -= num624 * -Projectile.direction; + float swaySize = 0.104719758f; + float smolWidth = (float)Projectile.width / 5f; + smolWidth *= 2f; + float projXChange = (float)(Math.Cos((double)(swaySize * -(double)Projectile.ai[0])) - 0.5) * smolWidth; + Projectile.position.X -= projXChange * -Projectile.direction; Projectile.ai[0] -= 1f; - num624 = (float)(Math.Cos((double)(num622 * -(double)Projectile.ai[0])) - 0.5) * num623; - Projectile.position.X += num624 * -Projectile.direction; + projXChange = (float)(Math.Cos((double)(swaySize * -(double)Projectile.ai[0])) - 0.5) * smolWidth; + Projectile.position.X += projXChange * -Projectile.direction; } if (Projectile.localAI[1] == breakThreshold && Main.zenithWorld) { @@ -147,9 +147,9 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { Texture2D texture = ModContent.Request(Texture).Value; - int num214 = texture.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = texture.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } diff --git a/Projectiles/Boss/FrostMist.cs b/Projectiles/Boss/FrostMist.cs index 5f7b867522..f1836f7a07 100644 --- a/Projectiles/Boss/FrostMist.cs +++ b/Projectiles/Boss/FrostMist.cs @@ -55,14 +55,14 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.ai[1] == 0f) { - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 187, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int mistDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 187, 0f, 0f, 100, default, 2f); + Main.dust[mistDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[mistDust].scale = 0.5f; + Main.dust[mistDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } Projectile.ai[1] = 1f; @@ -74,15 +74,15 @@ namespace CalamityMod.Projectiles.Boss Projectile.localAI[1] = 0f; for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * -Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy(l * MathHelper.Pi / 6f) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy(Projectile.rotation - MathHelper.PiOver2); - int num9 = Dust.NewDust(Projectile.Center, 0, 0, 187, 0f, 0f, 160, default, 1f); - Main.dust[num9].scale = 1.1f; - Main.dust[num9].noGravity = true; - Main.dust[num9].position = Projectile.Center + vector3; - Main.dust[num9].velocity = Projectile.velocity * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; + Vector2 dustRotation = Vector2.UnitX * -Projectile.width / 2f; + dustRotation += -Vector2.UnitY.RotatedBy(l * MathHelper.Pi / 6f) * new Vector2(8f, 16f); + dustRotation = dustRotation.RotatedBy(Projectile.rotation - MathHelper.PiOver2); + int extraMistDust = Dust.NewDust(Projectile.Center, 0, 0, 187, 0f, 0f, 160, default, 1f); + Main.dust[extraMistDust].scale = 1.1f; + Main.dust[extraMistDust].noGravity = true; + Main.dust[extraMistDust].position = Projectile.Center + dustRotation; + Main.dust[extraMistDust].velocity = Projectile.velocity * 0.1f; + Main.dust[extraMistDust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[extraMistDust].position) * 1.25f; } } @@ -91,17 +91,17 @@ namespace CalamityMod.Projectiles.Boss else Projectile.Opacity = MathHelper.Clamp(1f - ((Projectile.timeLeft - 270) / 30f), 0f, 1f); - int num103 = Player.FindClosest(Projectile.Center, 1, 1); + int playerTracker = Player.FindClosest(Projectile.Center, 1, 1); Projectile.ai[1] += 1f; if (Projectile.ai[1] < 140f && Projectile.ai[1] > 60f) { - float scaleFactor2 = Projectile.velocity.Length(); - Vector2 vector11 = Main.player[num103].Center - Projectile.Center; - vector11.Normalize(); - vector11 *= scaleFactor2; - Projectile.velocity = (Projectile.velocity * 24f + vector11) / 25f; + float projVelocityMult = Projectile.velocity.Length(); + Vector2 playerDistance = Main.player[playerTracker].Center - Projectile.Center; + playerDistance.Normalize(); + playerDistance *= projVelocityMult; + Projectile.velocity = (Projectile.velocity * 24f + playerDistance) / 25f; Projectile.velocity.Normalize(); - Projectile.velocity *= scaleFactor2; + Projectile.velocity *= projVelocityMult; } if (Projectile.velocity.Length() < 12f) Projectile.velocity *= 1.02f; diff --git a/Projectiles/Boss/GreatSandBlast.cs b/Projectiles/Boss/GreatSandBlast.cs index 261318205c..7ffd48a1df 100644 --- a/Projectiles/Boss/GreatSandBlast.cs +++ b/Projectiles/Boss/GreatSandBlast.cs @@ -54,9 +54,9 @@ namespace CalamityMod.Projectiles.Boss { Projectile.alpha = 0; } - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 85, 0f, 0f, 100, default, 1f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int sandyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 85, 0f, 0f, 100, default, 1f); + Main.dust[sandyDust].noGravity = true; + Main.dust[sandyDust].velocity *= 0f; } } @@ -67,16 +67,16 @@ namespace CalamityMod.Projectiles.Boss Projectile.width = Projectile.height = (int)(32 * Projectile.scale); Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int i = 0; i < dustAmt; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 85, vector7.X * 1.5f, vector7.Y * 1.5f, 100, default, 1.2f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 dustRotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + dustRotate = dustRotate.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; + Vector2 dustDirection = dustRotate - Projectile.Center; + int killSand = Dust.NewDust(dustRotate + dustDirection, 0, 0, 85, dustDirection.X * 1.5f, dustDirection.Y * 1.5f, 100, default, 1.2f); + Main.dust[killSand].noGravity = true; + Main.dust[killSand].noLight = true; + Main.dust[killSand].velocity = dustDirection; } Projectile.Damage(); } diff --git a/Projectiles/Boss/HealOrbProv.cs b/Projectiles/Boss/HealOrbProv.cs index 0cd8e9139b..511fcafcca 100644 --- a/Projectiles/Boss/HealOrbProv.cs +++ b/Projectiles/Boss/HealOrbProv.cs @@ -25,48 +25,47 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - int num487 = (int)Projectile.ai[0]; - float num488 = 2.5f; - Vector2 vector36 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num489 = Main.player[num487].Center.X - vector36.X; - float num490 = Main.player[num487].Center.Y - vector36.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - if (num491 < 50f && Projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && Projectile.position.X + (float)Projectile.width > Main.player[num487].position.X && Projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && Projectile.position.Y + (float)Projectile.height > Main.player[num487].position.Y) + int playerTracker = (int)Projectile.ai[0]; + Vector2 projDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float playerDistX = Main.player[playerTracker].Center.X - projDirection.X; + float playerDistY = Main.player[playerTracker].Center.Y - projDirection.Y; + float playerDistance = (float)Math.Sqrt((double)(playerDistX * playerDistX + playerDistY * playerDistY)); + if (playerDistance < 50f && Projectile.position.X < Main.player[playerTracker].position.X + (float)Main.player[playerTracker].width && Projectile.position.X + (float)Projectile.width > Main.player[playerTracker].position.X && Projectile.position.Y < Main.player[playerTracker].position.Y + (float)Main.player[playerTracker].height && Projectile.position.Y + (float)Projectile.height > Main.player[playerTracker].position.Y) { if (Projectile.owner == Main.myPlayer) { - int num492 = (int)Projectile.ai[1]; - Main.player[num487].HealEffect(num492, false); - Main.player[num487].statLife += num492; - if (Main.player[num487].statLife > Main.player[num487].statLifeMax2) + int healAmount = (int)Projectile.ai[1]; + Main.player[playerTracker].HealEffect(healAmount, false); + Main.player[playerTracker].statLife += healAmount; + if (Main.player[playerTracker].statLife > Main.player[playerTracker].statLifeMax2) { - Main.player[num487].statLife = Main.player[num487].statLifeMax2; + Main.player[playerTracker].statLife = Main.player[playerTracker].statLifeMax2; } // TODO -- but why - if (Main.player[num487].statLife < 0) + if (Main.player[playerTracker].statLife < 0) { - Main.player[num487].KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ProvidenceAntiHealing").Format(Main.player[num487].name)), 1000.0, 0, false); + Main.player[playerTracker].KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ProvidenceAntiHealing").Format(Main.player[playerTracker].name)), 1000.0, 0, false); } - NetMessage.SendData(MessageID.SpiritHeal, -1, -1, null, num487, (float)num492, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SpiritHeal, -1, -1, null, playerTracker, (float)healAmount, 0f, 0f, 0, 0, 0); } Projectile.Kill(); } - num491 = num488 / num491; - num489 *= num491; - num490 *= num491; - Projectile.velocity.X = (Projectile.velocity.X * 15f + num489) / 16f; - Projectile.velocity.Y = (Projectile.velocity.Y * 15f + num490) / 16f; - for (int num497 = 0; num497 < 1; num497++) + playerDistance = 2.5f / playerDistance; + playerDistX *= playerDistance; + playerDistY *= playerDistance; + Projectile.velocity.X = (Projectile.velocity.X * 15f + playerDistX) / 16f; + Projectile.velocity.Y = (Projectile.velocity.Y * 15f + playerDistY) / 16f; + for (int i = 0; i < 1; i++) { - float num498 = Projectile.velocity.X * 0.2f * (float)num497; - float num499 = -(Projectile.velocity.Y * 0.2f) * (float)num497; - int num500 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, 1f); - Main.dust[num500].noGravity = true; - Main.dust[num500].velocity *= 0f; - Dust expr_154F9_cp_0 = Main.dust[num500]; - expr_154F9_cp_0.position.X -= num498; - Dust expr_15518_cp_0 = Main.dust[num500]; - expr_15518_cp_0.position.Y -= num499; + float shortXVel = Projectile.velocity.X * 0.2f * (float)i; + float shortYVel = -(Projectile.velocity.Y * 0.2f) * (float)i; + int holyFire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, 1f); + Main.dust[holyFire].noGravity = true; + Main.dust[holyFire].velocity *= 0f; + Dust expr_154F9_cp_0 = Main.dust[holyFire]; + expr_154F9_cp_0.position.X -= shortXVel; + Dust expr_15518_cp_0 = Main.dust[holyFire]; + expr_15518_cp_0.position.Y -= shortYVel; } return; } diff --git a/Projectiles/Boss/HellfireExplosion.cs b/Projectiles/Boss/HellfireExplosion.cs index a3e6051ff3..54bc90aae8 100644 --- a/Projectiles/Boss/HellfireExplosion.cs +++ b/Projectiles/Boss/HellfireExplosion.cs @@ -43,61 +43,61 @@ namespace CalamityMod.Projectiles.Boss SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); Projectile.localAI[0] += 1f; } - bool flag15 = false; - bool flag16 = false; + bool xflag = false; + bool yflag = false; if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) { - flag16 = true; + yflag = true; } if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) { - flag16 = true; + yflag = true; } - if (flag15 && flag16) + if (xflag && yflag) { Projectile.Kill(); } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-10, 11); - float num464 = (float)Main.rand.Next(-10, 11); - float num465 = (float)Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); - Main.dust[num467].noGravity = true; - Main.dust[num467].position.X = Projectile.Center.X; - Main.dust[num467].position.Y = Projectile.Center.Y; - Dust expr_149DF_cp_0 = Main.dust[num467]; + float rando1 = (float)Main.rand.Next(-10, 11); + float rando2 = (float)Main.rand.Next(-10, 11); + float rando3 = (float)Main.rand.Next(3, 9); + float randoAdjuster = (float)Math.Sqrt((double)(rando1 * rando1 + rando2 * rando2)); + randoAdjuster = rando3 / randoAdjuster; + rando1 *= randoAdjuster; + rando2 *= randoAdjuster; + int brimDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); + Main.dust[brimDust].noGravity = true; + Main.dust[brimDust].position.X = Projectile.Center.X; + Main.dust[brimDust].position.Y = Projectile.Center.Y; + Dust expr_149DF_cp_0 = Main.dust[brimDust]; expr_149DF_cp_0.position.X += (float)Main.rand.Next(-10, 11); - Dust expr_14A09_cp_0 = Main.dust[num467]; + Dust expr_14A09_cp_0 = Main.dust[brimDust]; expr_14A09_cp_0.position.Y += (float)Main.rand.Next(-10, 11); - Main.dust[num467].velocity.X = num463; - Main.dust[num467].velocity.Y = num464; - num462++; + Main.dust[brimDust].velocity.X = rando1; + Main.dust[brimDust].velocity.Y = rando2; + timerCounter++; } } diff --git a/Projectiles/Boss/HiveBombGoliath.cs b/Projectiles/Boss/HiveBombGoliath.cs index f65ea162fe..3341fdd1e1 100644 --- a/Projectiles/Boss/HiveBombGoliath.cs +++ b/Projectiles/Boss/HiveBombGoliath.cs @@ -50,33 +50,33 @@ namespace CalamityMod.Projectiles.Boss } if (Math.Abs(Projectile.velocity.X) >= 3f || Math.Abs(Projectile.velocity.Y) >= 3f) { - float num247 = 0f; - float num248 = 0f; + float randDustXVel = 0f; + float randDustYVel = 0f; if (Main.rand.Next(2) == 1) { - num247 = Projectile.velocity.X * 0.5f; - num248 = Projectile.velocity.Y * 0.5f; + randDustXVel = Projectile.velocity.X * 0.5f; + randDustYVel = Projectile.velocity.Y * 0.5f; } - int num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 6, 0f, 0f, 100, default, 0.5f); - Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 31, 0f, 0f, 100, default, 0.25f); - Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num249].velocity *= 0.05f; + int bombDust = Dust.NewDust(new Vector2(Projectile.position.X + 3f + randDustXVel, Projectile.position.Y + 3f + randDustYVel) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 6, 0f, 0f, 100, default, 0.5f); + Main.dust[bombDust].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[bombDust].velocity *= 0.2f; + Main.dust[bombDust].noGravity = true; + bombDust = Dust.NewDust(new Vector2(Projectile.position.X + 3f + randDustXVel, Projectile.position.Y + 3f + randDustYVel) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 31, 0f, 0f, 100, default, 0.25f); + Main.dust[bombDust].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[bombDust].velocity *= 0.05f; } else if (Main.rand.NextBool(4)) { - int num252 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 0.5f); - Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2)).RotatedBy((double)Projectile.rotation, default) * 1.1f; + int smoke = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 0.5f); + Main.dust[smoke].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[smoke].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[smoke].noGravity = true; + Main.dust[smoke].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2)).RotatedBy((double)Projectile.rotation, default) * 1.1f; Main.rand.Next(2); - num252 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 1f); - Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2 - 6)).RotatedBy((double)Projectile.rotation, default) * 1.1f; + smoke = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 1f); + Main.dust[smoke].scale = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[smoke].noGravity = true; + Main.dust[smoke].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2 - 6)).RotatedBy((double)Projectile.rotation, default) * 1.1f; } Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) + 1.57f; } @@ -100,23 +100,23 @@ namespace CalamityMod.Projectiles.Boss Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); Projectile.Damage(); SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - for (int num621 = 0; num621 < 8; num621++) + for (int i = 0; i < 8; i++) { - int num622 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int plagued = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 2f); + Main.dust[plagued].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[plagued].scale = 0.5f; + Main.dust[plagued].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int plagued2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 3f); + Main.dust[plagued2].noGravity = true; + Main.dust[plagued2].velocity *= 5f; + plagued2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 2f); + Main.dust[plagued2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) diff --git a/Projectiles/Boss/HolyBlast.cs b/Projectiles/Boss/HolyBlast.cs index 2c460a9a7e..4e3bf9a0d1 100644 --- a/Projectiles/Boss/HolyBlast.cs +++ b/Projectiles/Boss/HolyBlast.cs @@ -73,15 +73,15 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.localAI[0] == 0f) { int dustType = ProvUtils.GetDustID(Projectile.maxPenetrate); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - Main.dust[num622].noGravity = true; + int holyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); + Main.dust[holyDust].velocity *= 3f; + Main.dust[holyDust].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[holyDust].scale = 0.5f; + Main.dust[holyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } Projectile.localAI[0] = 1f; @@ -105,10 +105,10 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { Texture2D texture = (Projectile.maxPenetrate != (int)Providence.BossMode.Day) ? ModContent.Request(Texture).Value : ModContent.Request("CalamityMod/Projectiles/Boss/HolyBlastNight").Value; - int num214 = texture.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; + int framing = texture.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; 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, y6, texture.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } @@ -134,19 +134,19 @@ namespace CalamityMod.Projectiles.Boss SoundEngine.PlaySound(ImpactSound, Projectile.Center); int dustType = ProvUtils.GetDustID(Projectile.maxPenetrate); - for (int num193 = 0; num193 < 4; num193++) + for (int j = 0; j < 4; j++) { int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 50, default, 2f); Main.dust[dust].noGravity = true; } - for (int num194 = 0; num194 < 40; num194++) + for (int k = 0; k < 40; k++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 4f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 50, default, 2f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int profaned = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 4f); + Main.dust[profaned].noGravity = true; + Main.dust[profaned].velocity *= 3f; + profaned = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 50, default, 2f); + Main.dust[profaned].velocity *= 2f; + Main.dust[profaned].noGravity = true; } } diff --git a/Projectiles/Boss/HolyBomb.cs b/Projectiles/Boss/HolyBomb.cs index 652d7ab616..8a64014ea6 100644 --- a/Projectiles/Boss/HolyBomb.cs +++ b/Projectiles/Boss/HolyBomb.cs @@ -57,19 +57,19 @@ namespace CalamityMod.Projectiles.Boss float velocityY = -2f; int dustType = ProvUtils.GetDustID(Projectile.maxPenetrate); - for (int num193 = 0; num193 < 2; num193++) + for (int i = 0; i < 2; i++) { int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, velocityY, 50, default, 1.5f); Main.dust[dust].noGravity = true; } - for (int num194 = 0; num194 < 20; num194++) + for (int j = 0; j < 20; j++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, velocityY, 0, default, 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 2f; - num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, velocityY, 50, default, 1.5f); - Main.dust[num195].velocity *= 1.5f; - Main.dust[num195].noGravity = true; + int holyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, velocityY, 0, default, 2.5f); + Main.dust[holyDust].noGravity = true; + Main.dust[holyDust].velocity *= 2f; + holyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, velocityY, 50, default, 1.5f); + Main.dust[holyDust].velocity *= 1.5f; + Main.dust[holyDust].noGravity = true; } if (Projectile.owner == Main.myPlayer) @@ -102,10 +102,10 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { Texture2D texture = (Projectile.maxPenetrate == (int)Providence.BossMode.Day) ? ModContent.Request(Texture).Value : ModContent.Request("CalamityMod/Projectiles/Boss/HolyBombNight").Value; - int num214 = texture.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; + int framing = texture.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; 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, y6, texture.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } @@ -119,19 +119,19 @@ namespace CalamityMod.Projectiles.Boss Projectile.position.X = Projectile.position.X - (Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (Projectile.height / 2); int dustType = ProvUtils.GetDustID(Projectile.maxPenetrate); - for (int num193 = 0; num193 < 2; num193++) + for (int i = 0; i < 2; i++) { int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 50, default, 1.5f); Main.dust[dust].noGravity = true; } - for (int num194 = 0; num194 < 20; num194++) + for (int j = 0; j < 20; j++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 50, default, 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int holyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 2.5f); + Main.dust[holyDust].noGravity = true; + Main.dust[holyDust].velocity *= 3f; + holyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 50, default, 1.5f); + Main.dust[holyDust].velocity *= 2f; + Main.dust[holyDust].noGravity = true; } } diff --git a/Projectiles/Boss/HolyFire.cs b/Projectiles/Boss/HolyFire.cs index 4a50fc14d0..76946f295f 100644 --- a/Projectiles/Boss/HolyFire.cs +++ b/Projectiles/Boss/HolyFire.cs @@ -73,10 +73,10 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { Texture2D texture = (Projectile.maxPenetrate == (int)Providence.BossMode.Day) ? ModContent.Request(Texture).Value : ModContent.Request("CalamityMod/Projectiles/Boss/HolyFireNight").Value; - int num214 = texture.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; + int framing = texture.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; 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, y6, texture.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } @@ -122,22 +122,22 @@ namespace CalamityMod.Projectiles.Boss Projectile.position.X = Projectile.position.X - (Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (Projectile.height / 2); int dustType = ProvUtils.GetDustID(Projectile.maxPenetrate); - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); - Main.dust[num622].noGravity = true; + int holyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); + Main.dust[holyDust].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[holyDust].scale = 0.5f; + Main.dust[holyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); - Main.dust[num624].noGravity = true; + int holyDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 3f); + Main.dust[holyDust2].noGravity = true; + holyDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); + Main.dust[holyDust2].noGravity = true; } } diff --git a/Projectiles/Boss/HolyFire2.cs b/Projectiles/Boss/HolyFire2.cs index b3ad4de002..9fc41594ac 100644 --- a/Projectiles/Boss/HolyFire2.cs +++ b/Projectiles/Boss/HolyFire2.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Boss if (Math.Abs(Projectile.velocity.X) < 7f) Projectile.velocity.X *= 1.05f; - int num103 = Player.FindClosest(Projectile.Center, 1, 1); + int playerTracker = Player.FindClosest(Projectile.Center, 1, 1); if (Projectile.ai[1] == 0f) Projectile.damage = Projectile.GetProjectileDamage(ModContent.NPCType()); @@ -65,14 +65,14 @@ namespace CalamityMod.Projectiles.Boss Projectile.ai[1] += 1f; if (Projectile.ai[1] < 180f && Projectile.ai[1] > 60f) { - float scaleFactor2 = Projectile.velocity.Length(); - Vector2 vector11 = Main.player[num103].Center - Projectile.Center; - vector11.Normalize(); - vector11 *= scaleFactor2; + float projVelocityMult = Projectile.velocity.Length(); + Vector2 playerDirection = Main.player[playerTracker].Center - Projectile.Center; + playerDirection.Normalize(); + playerDirection *= projVelocityMult; float inertia = (Projectile.maxPenetrate != (int)Providence.BossMode.Day) ? 20f : 25f; - Projectile.velocity = (Projectile.velocity * (inertia - 1f) + vector11) / inertia; + Projectile.velocity = (Projectile.velocity * (inertia - 1f) + playerDirection) / inertia; Projectile.velocity.Normalize(); - Projectile.velocity *= scaleFactor2; + Projectile.velocity *= projVelocityMult; } Projectile.rotation = Projectile.velocity.X * 0.025f; @@ -86,10 +86,10 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { Texture2D texture = (Projectile.maxPenetrate == (int)Providence.BossMode.Day) ? ModContent.Request(Texture).Value : ModContent.Request("CalamityMod/Projectiles/Boss/HolyFire2Night").Value; - int num214 = texture.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; + int framing = texture.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; 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, y6, texture.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } @@ -103,22 +103,22 @@ namespace CalamityMod.Projectiles.Boss Projectile.position.X = Projectile.position.X - (Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (Projectile.height / 2); int dustType = ProvUtils.GetDustID(Projectile.maxPenetrate); - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); - Main.dust[num622].noGravity = true; + int holyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); + Main.dust[holyDust].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[holyDust].scale = 0.5f; + Main.dust[holyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); - Main.dust[num624].noGravity = true; + int holyDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 3f); + Main.dust[holyDust2].noGravity = true; + holyDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); + Main.dust[holyDust2].noGravity = true; } } diff --git a/Projectiles/Boss/HolyFlare.cs b/Projectiles/Boss/HolyFlare.cs index 9d7bd01c78..3ebb87ca7a 100644 --- a/Projectiles/Boss/HolyFlare.cs +++ b/Projectiles/Boss/HolyFlare.cs @@ -90,10 +90,10 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { Texture2D texture = Projectile.maxPenetrate == (int)Providence.BossMode.Day ? ModContent.Request(Texture).Value : ModContent.Request("CalamityMod/Projectiles/Boss/HolyFlareNight").Value; - int num214 = texture.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; + int framing = texture.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; 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, y6, texture.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } @@ -107,22 +107,22 @@ namespace CalamityMod.Projectiles.Boss Projectile.position.X = Projectile.position.X - (Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (Projectile.height / 2); int dustType = ProvUtils.GetDustID(Projectile.maxPenetrate); - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); - Main.dust[num622].noGravity = true; + int holyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); + Main.dust[holyDust].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[holyDust].scale = 0.5f; + Main.dust[holyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); - Main.dust[num624].noGravity = true; + int holyDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 3f); + Main.dust[holyDust2].noGravity = true; + holyDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); + Main.dust[holyDust2].noGravity = true; } } diff --git a/Projectiles/Boss/HolyLight.cs b/Projectiles/Boss/HolyLight.cs index 0c3b631d90..b0a662ad56 100644 --- a/Projectiles/Boss/HolyLight.cs +++ b/Projectiles/Boss/HolyLight.cs @@ -62,34 +62,32 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { - Texture2D value = ModContent.Request(Texture).Value; - Color color33 = new Color(54, 209, 54, 0); - Vector2 vector28 = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); - Color color34 = color33; - Vector2 origin5 = value.Size() / 2f; - Color color35 = color33 * 0.5f; - float num162 = Utils.GetLerpValue(15f, 30f, Projectile.timeLeft, clamped: true) * Utils.GetLerpValue(240f, 200f, Projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 30f / 0.5f * ((float)Math.PI * 2f) * 3f)) * 0.8f; - Vector2 vector29 = new Vector2(0.5f, 1f) * num162; - Vector2 vector30 = new Vector2(0.5f, 1f) * num162; - color34 *= num162; - color35 *= num162; + Texture2D drawTexture = ModContent.Request(Texture).Value; + Color brightGreen = new Color(54, 209, 54, 0); + Vector2 projDirection = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); + Vector2 halfTextureSize = drawTexture.Size() / 2f; + Color halfBrightGreen = brightGreen * 0.5f; + float timeLeftColorScale = Utils.GetLerpValue(15f, 30f, Projectile.timeLeft, clamped: true) * Utils.GetLerpValue(240f, 200f, Projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 30f / 0.5f * ((float)Math.PI * 2f) * 3f)) * 0.8f; + Vector2 timeLeftDrawEffect = new Vector2(0.5f, 1f) * timeLeftColorScale; + Vector2 timeLeftDrawEffect2 = new Vector2(0.5f, 1f) * timeLeftColorScale; + brightGreen *= timeLeftColorScale; + halfBrightGreen *= timeLeftColorScale; - int num163 = 0; - Vector2 position3 = vector28 + Projectile.velocity.SafeNormalize(Vector2.Zero) * Utils.GetLerpValue(0.5f, 1f, Projectile.localAI[0] / 60f, clamped: true) * num163; + Vector2 position3 = projDirection + Projectile.velocity.SafeNormalize(Vector2.Zero) * Utils.GetLerpValue(0.5f, 1f, Projectile.localAI[0] / 60f, clamped: true) * 0; SpriteEffects spriteEffects = SpriteEffects.None; if (Projectile.spriteDirection == -1) spriteEffects = SpriteEffects.FlipHorizontally; - Main.EntitySpriteDraw(value, position3, null, color34, (float)Math.PI / 2f, origin5, vector29, spriteEffects, 0); - Main.EntitySpriteDraw(value, position3, null, color34, 0f, origin5, vector30, spriteEffects, 0); - Main.EntitySpriteDraw(value, position3, null, color35, (float)Math.PI / 2f, origin5, vector29 * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(value, position3, null, color35, 0f, origin5, vector30 * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, (float)Math.PI / 2f, halfTextureSize, timeLeftDrawEffect, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, 0f, halfTextureSize, timeLeftDrawEffect2, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, position3, null, halfBrightGreen, (float)Math.PI / 2f, halfTextureSize, timeLeftDrawEffect * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, position3, null, halfBrightGreen, 0f, halfTextureSize, timeLeftDrawEffect2 * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(value, position3, null, color34, MathHelper.PiOver4, origin5, vector29 * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(value, position3, null, color34, MathHelper.PiOver4 * 3f, origin5, vector30 * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(value, position3, null, color35, MathHelper.PiOver4, origin5, vector29 * 0.36f, spriteEffects, 0); - Main.EntitySpriteDraw(value, position3, null, color35, MathHelper.PiOver4 * 3f, origin5, vector30 * 0.36f, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, MathHelper.PiOver4, halfTextureSize, timeLeftDrawEffect * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, MathHelper.PiOver4 * 3f, halfTextureSize, timeLeftDrawEffect2 * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, position3, null, halfBrightGreen, MathHelper.PiOver4, halfTextureSize, timeLeftDrawEffect * 0.36f, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, position3, null, halfBrightGreen, MathHelper.PiOver4 * 3f, halfTextureSize, timeLeftDrawEffect2 * 0.36f, spriteEffects, 0); return false; } @@ -103,25 +101,25 @@ namespace CalamityMod.Projectiles.Boss Projectile.height = 40; Projectile.position.X = Projectile.position.X - (Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (Projectile.height / 2); - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - Main.dust[num622].noGravity = true; + int holyYellow = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); + Main.dust[holyYellow].velocity *= 3f; + Main.dust[holyYellow].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[holyYellow].scale = 0.5f; + Main.dust[holyYellow].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 8; num623++) + for (int j = 0; j < 8; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 247, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - Main.dust[num624].noGravity = true; + int holyYellow2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 247, 0f, 0f, 100, default, 3f); + Main.dust[holyYellow2].noGravity = true; + Main.dust[holyYellow2].velocity *= 5f; + holyYellow2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); + Main.dust[holyYellow2].velocity *= 2f; + Main.dust[holyYellow2].noGravity = true; } } } diff --git a/Projectiles/Boss/HolySpear.cs b/Projectiles/Boss/HolySpear.cs index d263512604..4ea6fb76cd 100644 --- a/Projectiles/Boss/HolySpear.cs +++ b/Projectiles/Boss/HolySpear.cs @@ -135,7 +135,7 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { - Texture2D value = ModContent.Request(Texture).Value; + Texture2D drawTexture = ModContent.Request(Texture).Value; bool aimedSpear = Projectile.ai[0] > 0f; int red = 255; @@ -180,17 +180,16 @@ namespace CalamityMod.Projectiles.Boss } Color baseColor = new Color(red, green, blue, 255); - Color color33 = baseColor * 0.5f; - color33.A = 0; - Vector2 vector28 = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); - Color color34 = color33; - Vector2 origin5 = value.Size() / 2f; - Color color35 = color33 * 0.5f; - float num162 = Utils.GetLerpValue(15f, 30f, Projectile.timeLeft, clamped: true) * Utils.GetLerpValue(240f, 200f, Projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 30f / 0.5f * ((float)Math.PI * 2f) * 3f)) * 0.8f; - Vector2 vector29 = new Vector2(1f, 1.5f) * num162; - Vector2 vector30 = new Vector2(0.5f, 1f) * num162; - color34 *= num162; - color35 *= num162; + Color halfBaseColor = baseColor * 0.5f; + halfBaseColor.A = 0; + Vector2 projDirection = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); + Vector2 halfTextureSize = drawTexture.Size() / 2f; + Color halfOfHalfBaseColor = halfBaseColor * 0.5f; + float timeLeftColorScale = Utils.GetLerpValue(15f, 30f, Projectile.timeLeft, clamped: true) * Utils.GetLerpValue(240f, 200f, Projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 30f / 0.5f * ((float)Math.PI * 2f) * 3f)) * 0.8f; + Vector2 timeLeftDrawEffect = new Vector2(1f, 1.5f) * timeLeftColorScale; + Vector2 timeLeftDrawEffect2 = new Vector2(0.5f, 1f) * timeLeftColorScale; + halfBaseColor *= timeLeftColorScale; + halfOfHalfBaseColor *= timeLeftColorScale; SpriteEffects spriteEffects = SpriteEffects.None; if (Projectile.spriteDirection == -1) @@ -200,21 +199,21 @@ namespace CalamityMod.Projectiles.Boss { for (int i = 0; i < Projectile.oldPos.Length; i++) { - Vector2 drawPos = Projectile.oldPos[i] + vector28; - Color color = Projectile.GetAlpha(color34) * ((Projectile.oldPos.Length - i) / Projectile.oldPos.Length); - Main.spriteBatch.Draw(value, drawPos, null, color, Projectile.rotation, origin5, vector29, SpriteEffects.None, 0); - Main.spriteBatch.Draw(value, drawPos, null, color, Projectile.rotation, origin5, vector30, SpriteEffects.None, 0); + Vector2 drawPos = Projectile.oldPos[i] + projDirection; + Color baseColorAlpha = Projectile.GetAlpha(halfBaseColor) * ((Projectile.oldPos.Length - i) / Projectile.oldPos.Length); + Main.spriteBatch.Draw(drawTexture, drawPos, null, baseColorAlpha, Projectile.rotation, halfTextureSize, timeLeftDrawEffect, SpriteEffects.None, 0); + Main.spriteBatch.Draw(drawTexture, drawPos, null, baseColorAlpha, Projectile.rotation, halfTextureSize, timeLeftDrawEffect2, SpriteEffects.None, 0); - color = Projectile.GetAlpha(color35) * ((Projectile.oldPos.Length - i) / Projectile.oldPos.Length); - Main.spriteBatch.Draw(value, drawPos, null, color, Projectile.rotation, origin5, vector29 * 0.6f, SpriteEffects.None, 0); - Main.spriteBatch.Draw(value, drawPos, null, color, Projectile.rotation, origin5, vector30 * 0.6f, SpriteEffects.None, 0); + baseColorAlpha = Projectile.GetAlpha(halfOfHalfBaseColor) * ((Projectile.oldPos.Length - i) / Projectile.oldPos.Length); + Main.spriteBatch.Draw(drawTexture, drawPos, null, baseColorAlpha, Projectile.rotation, halfTextureSize, timeLeftDrawEffect * 0.6f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(drawTexture, drawPos, null, baseColorAlpha, Projectile.rotation, halfTextureSize, timeLeftDrawEffect2 * 0.6f, SpriteEffects.None, 0); } } - Main.EntitySpriteDraw(value, vector28, null, color34, Projectile.rotation, origin5, vector29, spriteEffects, 0); - Main.EntitySpriteDraw(value, vector28, null, color34, Projectile.rotation, origin5, vector30, spriteEffects, 0); - Main.EntitySpriteDraw(value, vector28, null, color35, Projectile.rotation, origin5, vector29 * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(value, vector28, null, color35, Projectile.rotation, origin5, vector30 * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, projDirection, null, halfBaseColor, Projectile.rotation, halfTextureSize, timeLeftDrawEffect, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, projDirection, null, halfBaseColor, Projectile.rotation, halfTextureSize, timeLeftDrawEffect2, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, projDirection, null, halfOfHalfBaseColor, Projectile.rotation, halfTextureSize, timeLeftDrawEffect * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, projDirection, null, halfOfHalfBaseColor, Projectile.rotation, halfTextureSize, timeLeftDrawEffect2 * 0.6f, spriteEffects, 0); return false; } diff --git a/Projectiles/Boss/IceBlast.cs b/Projectiles/Boss/IceBlast.cs index 49b8b443e7..a7c65ab9d4 100644 --- a/Projectiles/Boss/IceBlast.cs +++ b/Projectiles/Boss/IceBlast.cs @@ -66,22 +66,21 @@ namespace CalamityMod.Projectiles.Boss public override void OnKill(int timeLeft) { - int num497 = 5; - SoundEngine.PlaySound(SoundID.Item27, Projectile.Center); - for (int num498 = 0; num498 < num497; num498++) + //SoundEngine.PlaySound(SoundID.Item27, Projectile.Center); + for (int i = 0; i < 5; i++) { - int num499 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 92, 0f, 0f, 0, default, 1f); + int iceDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 92, 0f, 0f, 0, default, 1f); if (!Main.rand.NextBool(3)) { - Dust dust = Main.dust[num499]; + Dust dust = Main.dust[iceDust]; dust.velocity *= 2f; - Main.dust[num499].noGravity = true; - dust = Main.dust[num499]; + Main.dust[iceDust].noGravity = true; + dust = Main.dust[iceDust]; dust.scale *= 1.75f; } else { - Dust dust = Main.dust[num499]; + Dust dust = Main.dust[iceDust]; dust.scale *= 0.5f; } } diff --git a/Projectiles/Boss/IceBomb.cs b/Projectiles/Boss/IceBomb.cs index 981f2fbffa..68c1303b1a 100644 --- a/Projectiles/Boss/IceBomb.cs +++ b/Projectiles/Boss/IceBomb.cs @@ -35,23 +35,23 @@ namespace CalamityMod.Projectiles.Boss Projectile.ai[0] += 1f; if (Projectile.ai[0] == 120f) { - for (int num621 = 0; num621 < 8; num621++) + for (int i = 0; i < 8; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int iceDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 100, default, 2f); + Main.dust[iceDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[iceDust].scale = 0.5f; + Main.dust[iceDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 14; num623++) + for (int j = 0; j < 14; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int iceDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 100, default, 3f); + Main.dust[iceDust2].noGravity = true; + Main.dust[iceDust2].velocity *= 5f; + iceDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 100, default, 2f); + Main.dust[iceDust2].velocity *= 2f; } Projectile.scale = 1.2f; @@ -71,7 +71,7 @@ namespace CalamityMod.Projectiles.Boss public override void OnKill(int timeLeft) { - SoundEngine.PlaySound(SoundID.Item27, Projectile.Center); + //SoundEngine.PlaySound(SoundID.Item27, Projectile.Center); if (Projectile.owner == Main.myPlayer) { diff --git a/Projectiles/Boss/IceRain.cs b/Projectiles/Boss/IceRain.cs index eb2511bfde..8c97860c8b 100644 --- a/Projectiles/Boss/IceRain.cs +++ b/Projectiles/Boss/IceRain.cs @@ -46,11 +46,11 @@ namespace CalamityMod.Projectiles.Boss Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver2; - for (int num322 = 0; num322 < 2; num322++) + for (int i = 0; i < 2; i++) { - int num323 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 92, Projectile.velocity.X, Projectile.velocity.Y, 50, default, 0.6f); - Main.dust[num323].noGravity = true; - Dust dust = Main.dust[num323]; + int icyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 92, Projectile.velocity.X, Projectile.velocity.Y, 50, default, 0.6f); + Main.dust[icyDust].noGravity = true; + Dust dust = Main.dust[icyDust]; dust.velocity *= 0.3f; } } @@ -61,11 +61,11 @@ namespace CalamityMod.Projectiles.Boss Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver2; - for (int num322 = 0; num322 < 2; num322++) + for (int i = 0; i < 2; i++) { - int num323 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 92, Projectile.velocity.X, Projectile.velocity.Y, 50, default, 0.6f); - Main.dust[num323].noGravity = true; - Dust dust = Main.dust[num323]; + int icyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 92, Projectile.velocity.X, Projectile.velocity.Y, 50, default, 0.6f); + Main.dust[icyDust].noGravity = true; + Dust dust = Main.dust[icyDust]; dust.velocity *= 0.3f; } } @@ -90,13 +90,13 @@ namespace CalamityMod.Projectiles.Boss public override void OnKill(int timeLeft) { - SoundEngine.PlaySound(SoundID.Item27 with { Volume = SoundID.Item27.Volume * 0.25f }, Projectile.Center); - for (int num373 = 0; num373 < 3; num373++) + //SoundEngine.PlaySound(SoundID.Item27 with { Volume = SoundID.Item27.Volume * 0.25f }, Projectile.Center); + for (int j = 0; j < 3; j++) { - int num374 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 76, 0f, 0f, 0, default, 1f); - Main.dust[num374].noGravity = true; - Main.dust[num374].noLight = true; - Main.dust[num374].scale = 0.7f; + int snowDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 76, 0f, 0f, 0, default, 1f); + Main.dust[snowDust].noGravity = true; + Main.dust[snowDust].noLight = true; + Main.dust[snowDust].scale = 0.7f; } } diff --git a/Projectiles/Boss/IchorBlob.cs b/Projectiles/Boss/IchorBlob.cs index 8f54945832..db0613fc66 100644 --- a/Projectiles/Boss/IchorBlob.cs +++ b/Projectiles/Boss/IchorBlob.cs @@ -98,37 +98,34 @@ namespace CalamityMod.Projectiles.Boss SoundEngine.PlaySound(SoundID.NPCDeath21, Projectile.Center); // Emit dust - float num50 = 1.6f; - float num51 = 0.8f; - float num52 = 2f; - Vector2 value3 = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2(); - Vector2 value4 = value3 * Projectile.velocity.Length(); - for (int num53 = 0; num53 < 10; num53++) + Vector2 dustRotation = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2(); + Vector2 dustVelocity = dustRotation * Projectile.velocity.Length(); + for (int i = 0; i < 10; i++) { - int num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 170, 0f, 0f, 200, default, num50); - Dust dust = Main.dust[num54]; + int ichorDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 170, 0f, 0f, 200, default, 1.6f); + Dust dust = Main.dust[ichorDust]; dust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; dust.noGravity = true; dust.velocity.Y -= 2f; dust.velocity *= 3f; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 170, 0f, 0f, 100, default, num51); + dust.velocity += dustVelocity * Main.rand.NextFloat(); + ichorDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 170, 0f, 0f, 100, default, 0.8f); dust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; dust.velocity.Y -= 2f; dust.velocity *= 2f; dust.noGravity = true; dust.fadeIn = 1f; - dust.velocity += value4 * Main.rand.NextFloat(); + dust.velocity += dustVelocity * Main.rand.NextFloat(); } - for (int num55 = 0; num55 < 5; num55++) + for (int j = 0; j < 5; j++) { - int num56 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 170, 0f, 0f, 0, default, num52); - Dust dust = Main.dust[num56]; + int ichorDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 170, 0f, 0f, 0, default, 2f); + Dust dust = Main.dust[ichorDust2]; dust.position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 3f; dust.noGravity = true; dust.velocity.Y -= 2f; dust.velocity *= 0.5f; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); + dust.velocity += dustVelocity * (0.6f + 0.6f * Main.rand.NextFloat()); } } diff --git a/Projectiles/Boss/IchorShot.cs b/Projectiles/Boss/IchorShot.cs index 2dcf960210..7706b12242 100644 --- a/Projectiles/Boss/IchorShot.cs +++ b/Projectiles/Boss/IchorShot.cs @@ -42,9 +42,9 @@ namespace CalamityMod.Projectiles.Boss Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver2; - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 170, 0f, 0f, 100, default, 0.5f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int ichorDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 170, 0f, 0f, 100, default, 0.5f); + Main.dust[ichorDust].noGravity = true; + Main.dust[ichorDust].velocity *= 0f; if (Projectile.velocity.Y < 12f) Projectile.velocity.Y += 0.06f; diff --git a/Projectiles/Boss/Infernado.cs b/Projectiles/Boss/Infernado.cs index 213b749959..5f3353a58a 100644 --- a/Projectiles/Boss/Infernado.cs +++ b/Projectiles/Boss/Infernado.cs @@ -107,8 +107,8 @@ namespace CalamityMod.Projectiles.Boss Projectile.netUpdate = true; Vector2 center = Projectile.Center; center.Y -= baseHeight * Projectile.scale / 2f; - float num618 = (scaleBase - Projectile.ai[1] + 1f) * scaleMult / scaleBase; - center.Y -= baseHeight * num618 / 2f; + float finalProjHeight = (scaleBase - Projectile.ai[1] + 1f) * scaleMult / scaleBase; + center.Y -= baseHeight * finalProjHeight / 2f; center.Y += 2f; Projectile.NewProjectile(Projectile.GetSource_FromThis(), center, Projectile.velocity, Projectile.type, Projectile.damage, Projectile.knockBack, Projectile.owner, 11f, Projectile.ai[1] - 1f); } @@ -118,14 +118,14 @@ namespace CalamityMod.Projectiles.Boss bool breakapart = Main.zenithWorld && Projectile.localAI[1] >= breakThreshold; if (Projectile.ai[0] <= 0f && !breakapart) { - float num622 = 0.104719758f; - float num623 = (float)Projectile.width / 5f; - num623 *= 2f; - float num624 = (float)(Math.Cos((double)(num622 * -(double)Projectile.ai[0])) - 0.5) * num623; - Projectile.position.X -= num624 * -Projectile.direction; + float swaySize = 0.104719758f; + float smolWidth = (float)Projectile.width / 5f; + smolWidth *= 2f; + float projXChange = (float)(Math.Cos((double)(swaySize * -(double)Projectile.ai[0])) - 0.5) * smolWidth; + Projectile.position.X -= projXChange * -Projectile.direction; Projectile.ai[0] -= 1f; - num624 = (float)(Math.Cos((double)(num622 * -(double)Projectile.ai[0])) - 0.5) * num623; - Projectile.position.X += num624 * -Projectile.direction; + projXChange = (float)(Math.Cos((double)(swaySize * -(double)Projectile.ai[0])) - 0.5) * smolWidth; + Projectile.position.X += projXChange * -Projectile.direction; } if (Projectile.localAI[1] == breakThreshold && Main.zenithWorld) { @@ -149,9 +149,9 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } diff --git a/Projectiles/Boss/Infernado2.cs b/Projectiles/Boss/Infernado2.cs index 12d35a5f38..f398fe5668 100644 --- a/Projectiles/Boss/Infernado2.cs +++ b/Projectiles/Boss/Infernado2.cs @@ -105,8 +105,8 @@ namespace CalamityMod.Projectiles.Boss Projectile.netUpdate = true; Vector2 center = Projectile.Center; center.Y -= baseHeight * Projectile.scale / 2f; - float num618 = (scaleBase - Projectile.ai[1] + 1f) * scaleMult / scaleBase; - center.Y -= baseHeight * num618 / 2f; + float finalProjHeight = (scaleBase - Projectile.ai[1] + 1f) * scaleMult / scaleBase; + center.Y -= baseHeight * finalProjHeight / 2f; center.Y += 2f; Projectile.NewProjectile(Projectile.GetSource_FromThis(), center, Projectile.velocity, Projectile.type, Projectile.damage, Projectile.knockBack, Projectile.owner, 11f, Projectile.ai[1] - 1f); } @@ -115,14 +115,14 @@ namespace CalamityMod.Projectiles.Boss bool breakapart = Main.zenithWorld && Projectile.ai[0] <= breakThreshold; if (Projectile.ai[0] <= 0f && !breakapart) { - float num622 = 0.104719758f; - float num623 = (float)Projectile.width / 5f; - num623 *= 2f; - float num624 = (float)(Math.Cos((double)(num622 * -(double)Projectile.ai[0])) - 0.5) * num623; - Projectile.position.X -= num624 * -Projectile.direction; + float swaySize = 0.104719758f; + float smolWidth = (float)Projectile.width / 5f; + smolWidth *= 2f; + float projXChange = (float)(Math.Cos((double)(swaySize * -(double)Projectile.ai[0])) - 0.5) * smolWidth; + Projectile.position.X -= projXChange * -Projectile.direction; Projectile.ai[0] -= 1f; - num624 = (float)(Math.Cos((double)(num622 * -(double)Projectile.ai[0])) - 0.5) * num623; - Projectile.position.X += num624 * -Projectile.direction; + projXChange = (float)(Math.Cos((double)(swaySize * -(double)Projectile.ai[0])) - 0.5) * smolWidth; + Projectile.position.X += projXChange * -Projectile.direction; } if (Projectile.ai[0] == breakThreshold && Main.zenithWorld) { @@ -143,9 +143,9 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } diff --git a/Projectiles/Boss/LeviathanBomb.cs b/Projectiles/Boss/LeviathanBomb.cs index 7522da820a..fedea1cbde 100644 --- a/Projectiles/Boss/LeviathanBomb.cs +++ b/Projectiles/Boss/LeviathanBomb.cs @@ -71,23 +71,23 @@ namespace CalamityMod.Projectiles.Boss public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int meteorDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[meteorDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[meteorDust].scale = 0.5f; + Main.dust[meteorDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 15; num623++) + for (int j = 0; j < 15; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int meteorDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 3f); + Main.dust[meteorDust2].noGravity = true; + Main.dust[meteorDust2].velocity *= 5f; + meteorDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[meteorDust2].velocity *= 2f; } } } diff --git a/Projectiles/Boss/MoltenBlast.cs b/Projectiles/Boss/MoltenBlast.cs index 6ccc2dc9a0..a9fb3d86a6 100644 --- a/Projectiles/Boss/MoltenBlast.cs +++ b/Projectiles/Boss/MoltenBlast.cs @@ -75,13 +75,13 @@ namespace CalamityMod.Projectiles.Boss { for (int d = 0; d < 10; d++) { - int num622 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - Main.dust[num622].noGravity = true; + int holyDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); + Main.dust[holyDust].velocity *= 3f; + Main.dust[holyDust].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[holyDust].scale = 0.5f; + Main.dust[holyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } Projectile.localAI[1] = 1f; @@ -94,15 +94,15 @@ namespace CalamityMod.Projectiles.Boss Projectile.localAI[0] = 0f; for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * -Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy(l * 3.14159274f / 6f, default) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy(Projectile.rotation - 1.57079637f, default); - int num9 = Dust.NewDust(Projectile.Center, 0, 0, dustType, 0f, 0f, 160, default, 1f); - Main.dust[num9].scale = 1.1f; - Main.dust[num9].noGravity = true; - Main.dust[num9].position = Projectile.Center + vector3; - Main.dust[num9].velocity = Projectile.velocity * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; + Vector2 dustRotate = Vector2.UnitX * -Projectile.width / 2f; + dustRotate += -Vector2.UnitY.RotatedBy(l * 3.14159274f / 6f, default) * new Vector2(8f, 16f); + dustRotate = dustRotate.RotatedBy(Projectile.rotation - 1.57079637f, default); + int profaned = Dust.NewDust(Projectile.Center, 0, 0, dustType, 0f, 0f, 160, default, 1f); + Main.dust[profaned].scale = 1.1f; + Main.dust[profaned].noGravity = true; + Main.dust[profaned].position = Projectile.Center + dustRotate; + Main.dust[profaned].velocity = Projectile.velocity * 0.1f; + Main.dust[profaned].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[profaned].position) * 1.25f; } } @@ -117,10 +117,10 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { Texture2D texture = (Projectile.maxPenetrate == (int)Providence.BossMode.Day) ? ModContent.Request(Texture).Value : ModContent.Request("CalamityMod/Projectiles/Boss/MoltenBlastNight").Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; 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, y6, texture.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } @@ -141,19 +141,19 @@ namespace CalamityMod.Projectiles.Boss SoundEngine.PlaySound(SoundID.Item74, Projectile.Center); int dustType = ProvUtils.GetDustID(Projectile.maxPenetrate); - for (int num193 = 0; num193 < 4; num193++) + for (int i = 0; i < 4; i++) { int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 50, default, 1.5f); Main.dust[dust].noGravity = true; } - for (int num194 = 0; num194 < 40; num194++) + for (int j = 0; j < 40; j++) { - int num195 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 50, default, 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int killHolyDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 2.5f); + Main.dust[killHolyDust].noGravity = true; + Main.dust[killHolyDust].velocity *= 3f; + killHolyDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 50, default, 1.5f); + Main.dust[killHolyDust].velocity *= 2f; + Main.dust[killHolyDust].noGravity = true; } } diff --git a/Projectiles/Boss/MoltenBlob.cs b/Projectiles/Boss/MoltenBlob.cs index a64b62465a..c551858525 100644 --- a/Projectiles/Boss/MoltenBlob.cs +++ b/Projectiles/Boss/MoltenBlob.cs @@ -86,10 +86,10 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { Texture2D texture = (Projectile.maxPenetrate == (int)Providence.BossMode.Day) ? ModContent.Request(Texture).Value : ModContent.Request("CalamityMod/Projectiles/Boss/MoltenBlobNight").Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; 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, y6, texture.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } @@ -103,22 +103,22 @@ namespace CalamityMod.Projectiles.Boss Projectile.position.X = Projectile.position.X - (Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (Projectile.height / 2); int dustType = ProvUtils.GetDustID(Projectile.maxPenetrate); - for (int num621 = 0; num621 < 3; num621++) + for (int i = 0; i < 3; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); - Main.dust[num622].noGravity = true; + int holyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); + Main.dust[holyDust].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[holyDust].scale = 0.5f; + Main.dust[holyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 5; num623++) + for (int j = 0; j < 5; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); - Main.dust[num624].noGravity = true; + int holyDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 3f); + Main.dust[holyDust2].noGravity = true; + holyDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); + Main.dust[holyDust2].noGravity = true; } } diff --git a/Projectiles/Boss/MushBomb.cs b/Projectiles/Boss/MushBomb.cs index 9669d83276..286c536e13 100644 --- a/Projectiles/Boss/MushBomb.cs +++ b/Projectiles/Boss/MushBomb.cs @@ -111,21 +111,21 @@ namespace CalamityMod.Projectiles.Boss Projectile.height = 20; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 4; num621++) + for (int i = 0; i < 4; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 1.5f; + int shroomDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 2f); + Main.dust[shroomDust].velocity *= 1.5f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[shroomDust].scale = 0.5f; + Main.dust[shroomDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 12; num623++) + for (int j = 0; j < 12; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 2f; + int shroomDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 3f); + Main.dust[shroomDust2].noGravity = true; + Main.dust[shroomDust2].velocity *= 2f; Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 2f); } } diff --git a/Projectiles/Boss/MushBombFall.cs b/Projectiles/Boss/MushBombFall.cs index b39dbdf9a5..2e82c649fd 100644 --- a/Projectiles/Boss/MushBombFall.cs +++ b/Projectiles/Boss/MushBombFall.cs @@ -119,21 +119,21 @@ namespace CalamityMod.Projectiles.Boss Projectile.height = 20; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 4; num621++) + for (int i = 0; i < 4; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 1.5f; + int shroomDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 2f); + Main.dust[shroomDust].velocity *= 1.5f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[shroomDust].scale = 0.5f; + Main.dust[shroomDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 12; num623++) + for (int j = 0; j < 12; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 2f; + int shroomDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 3f); + Main.dust[shroomDust2].noGravity = true; + Main.dust[shroomDust2].velocity *= 2f; Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 2f); } diff --git a/Projectiles/Boss/OldDukeGore.cs b/Projectiles/Boss/OldDukeGore.cs index afd5bd1c2e..f9e876528b 100644 --- a/Projectiles/Boss/OldDukeGore.cs +++ b/Projectiles/Boss/OldDukeGore.cs @@ -61,13 +61,13 @@ namespace CalamityMod.Projectiles.Boss { SoundEngine.PlaySound(SoundID.NPCDeath12, Projectile.Center); - int num226 = 8; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 8; + for (int i = 0; i < dustAmt; i++) { - Vector2 source = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - source = source.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 dustVel = source - Projectile.Center; - int blood = Dust.NewDust(source + dustVel, 0, 0, DustID.Blood, dustVel.X, dustVel.Y, 100, default, 1.2f); + Vector2 dustRotation = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + dustRotation = dustRotation.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; + Vector2 dustVel = dustRotation - Projectile.Center; + int blood = Dust.NewDust(dustRotation + dustVel, 0, 0, DustID.Blood, dustVel.X, dustVel.Y, 100, default, 1.2f); Main.dust[blood].noGravity = true; Main.dust[blood].noLight = true; Main.dust[blood].velocity = dustVel; diff --git a/Projectiles/Boss/PhantomBlast.cs b/Projectiles/Boss/PhantomBlast.cs index e0acb2a64f..a5b7b30f91 100644 --- a/Projectiles/Boss/PhantomBlast.cs +++ b/Projectiles/Boss/PhantomBlast.cs @@ -64,15 +64,15 @@ namespace CalamityMod.Projectiles.Boss Projectile.localAI[1] = 0f; for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * -Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy(l * MathHelper.Pi / 6f) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy(Projectile.rotation - MathHelper.PiOver2); - int num9 = Dust.NewDust(Projectile.Center, 0, 0, 180, 0f, 0f, 160, default, 1f); - Main.dust[num9].scale = 1.1f; - Main.dust[num9].noGravity = true; - Main.dust[num9].position = Projectile.Center + vector3; - Main.dust[num9].velocity = Projectile.velocity * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; + Vector2 dustRotation = Vector2.UnitX * -Projectile.width / 2f; + dustRotation += -Vector2.UnitY.RotatedBy(l * MathHelper.Pi / 6f) * new Vector2(8f, 16f); + dustRotation = dustRotation.RotatedBy(Projectile.rotation - MathHelper.PiOver2); + int phantomDust = Dust.NewDust(Projectile.Center, 0, 0, 180, 0f, 0f, 160, default, 1f); + Main.dust[phantomDust].scale = 1.1f; + Main.dust[phantomDust].noGravity = true; + Main.dust[phantomDust].position = Projectile.Center + dustRotation; + Main.dust[phantomDust].velocity = Projectile.velocity * 0.1f; + Main.dust[phantomDust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[phantomDust].position) * 1.25f; } } } @@ -91,24 +91,24 @@ namespace CalamityMod.Projectiles.Boss Projectile.height = 50; Projectile.position.X = Projectile.position.X - (Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (Projectile.height / 2); - for (int num621 = 0; num621 < 3; num621++) + for (int i = 0; i < 3; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; - Main.dust[num622].noGravity = true; + int killGhostDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 1.2f); + Main.dust[killGhostDust].velocity *= 3f; + Main.dust[killGhostDust].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[killGhostDust].scale = 0.5f; + Main.dust[killGhostDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 5; num623++) + for (int j = 0; j < 5; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int killGhostDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 1.7f); + Main.dust[killGhostDust2].noGravity = true; + Main.dust[killGhostDust2].velocity *= 5f; + killGhostDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 1f); + Main.dust[killGhostDust2].velocity *= 2f; } } diff --git a/Projectiles/Boss/PhantomBlast2.cs b/Projectiles/Boss/PhantomBlast2.cs index 0eddcd73c2..6a2e5fd306 100644 --- a/Projectiles/Boss/PhantomBlast2.cs +++ b/Projectiles/Boss/PhantomBlast2.cs @@ -64,15 +64,15 @@ namespace CalamityMod.Projectiles.Boss Projectile.localAI[1] = 0f; for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * -Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy(l * MathHelper.Pi / 6f) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy(Projectile.rotation - MathHelper.PiOver2); - int num9 = Dust.NewDust(Projectile.Center, 0, 0, 60, 0f, 0f, 160, default, 1f); - Main.dust[num9].scale = 1.1f; - Main.dust[num9].noGravity = true; - Main.dust[num9].position = Projectile.Center + vector3; - Main.dust[num9].velocity = Projectile.velocity * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; + Vector2 dustRotation = Vector2.UnitX * -Projectile.width / 2f; + dustRotation += -Vector2.UnitY.RotatedBy(l * MathHelper.Pi / 6f) * new Vector2(8f, 16f); + dustRotation = dustRotation.RotatedBy(Projectile.rotation - MathHelper.PiOver2); + int phantomDust = Dust.NewDust(Projectile.Center, 0, 0, 60, 0f, 0f, 160, default, 1f); + Main.dust[phantomDust].scale = 1.1f; + Main.dust[phantomDust].noGravity = true; + Main.dust[phantomDust].position = Projectile.Center + dustRotation; + Main.dust[phantomDust].velocity = Projectile.velocity * 0.1f; + Main.dust[phantomDust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[phantomDust].position) * 1.25f; } } } @@ -91,24 +91,24 @@ namespace CalamityMod.Projectiles.Boss Projectile.height = 50; Projectile.position.X = Projectile.position.X - (Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (Projectile.height / 2); - for (int num621 = 0; num621 < 3; num621++) + for (int i = 0; i < 3; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; - Main.dust[num622].noGravity = true; + int killGhostDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.2f); + Main.dust[killGhostDust].velocity *= 3f; + Main.dust[killGhostDust].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[killGhostDust].scale = 0.5f; + Main.dust[killGhostDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 5; num623++) + for (int j = 0; j < 5; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int killGhostDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.7f); + Main.dust[killGhostDust2].noGravity = true; + Main.dust[killGhostDust2].velocity *= 5f; + killGhostDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1f); + Main.dust[killGhostDust2].velocity *= 2f; } } diff --git a/Projectiles/Boss/PhantomGhostShot.cs b/Projectiles/Boss/PhantomGhostShot.cs index 8d2f8c4bc3..c3e95d0d0e 100644 --- a/Projectiles/Boss/PhantomGhostShot.cs +++ b/Projectiles/Boss/PhantomGhostShot.cs @@ -48,13 +48,13 @@ namespace CalamityMod.Projectiles.Boss Projectile.localAI[0] += 1f; if (Projectile.localAI[0] == 6f) { - for (int num151 = 0; num151 < 40; num151++) + for (int i = 0; i < 40; i++) { - int num152 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1f); - Main.dust[num152].velocity *= 3f; - Main.dust[num152].velocity += Projectile.velocity * 0.75f; - Main.dust[num152].scale *= 1.2f; - Main.dust[num152].noGravity = true; + int redDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1f); + Main.dust[redDust].velocity *= 3f; + Main.dust[redDust].velocity += Projectile.velocity * 0.75f; + Main.dust[redDust].scale *= 1.2f; + Main.dust[redDust].noGravity = true; } } diff --git a/Projectiles/Boss/PhantomHookShot.cs b/Projectiles/Boss/PhantomHookShot.cs index 3adaa6fc40..ba8332c594 100644 --- a/Projectiles/Boss/PhantomHookShot.cs +++ b/Projectiles/Boss/PhantomHookShot.cs @@ -48,13 +48,13 @@ namespace CalamityMod.Projectiles.Boss Projectile.localAI[0] += 1f; if (Projectile.localAI[0] == 6f) { - for (int num151 = 0; num151 < 40; num151++) + for (int i = 0; i < 40; i++) { - int num152 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 1f); - Main.dust[num152].velocity *= 3f; - Main.dust[num152].velocity += Projectile.velocity * 0.75f; - Main.dust[num152].scale *= 1.2f; - Main.dust[num152].noGravity = true; + int redDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 1f); + Main.dust[redDust].velocity *= 3f; + Main.dust[redDust].velocity += Projectile.velocity * 0.75f; + Main.dust[redDust].scale *= 1.2f; + Main.dust[redDust].noGravity = true; } } diff --git a/Projectiles/Boss/PhantomMine.cs b/Projectiles/Boss/PhantomMine.cs index efab133679..97897bc811 100644 --- a/Projectiles/Boss/PhantomMine.cs +++ b/Projectiles/Boss/PhantomMine.cs @@ -79,23 +79,23 @@ namespace CalamityMod.Projectiles.Boss Projectile.height = 150; Projectile.position.X = Projectile.position.X - (Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (Projectile.height / 2); - for (int num621 = 0; num621 < 15; num621++) + for (int i = 0; i < 15; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; + int phantomDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 1.2f); + Main.dust[phantomDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[phantomDust].scale = 0.5f; + Main.dust[phantomDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int phantomDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 1.7f); + Main.dust[phantomDust2].noGravity = true; + Main.dust[phantomDust2].velocity *= 5f; + phantomDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1f); + Main.dust[phantomDust2].velocity *= 2f; } } diff --git a/Projectiles/Boss/PhantomShot.cs b/Projectiles/Boss/PhantomShot.cs index 5c78a68f1c..c38d4c962c 100644 --- a/Projectiles/Boss/PhantomShot.cs +++ b/Projectiles/Boss/PhantomShot.cs @@ -55,12 +55,11 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.ai[0] == 0f) Projectile.ai[0] = Projectile.velocity.Length() * 3f; - int num189 = Player.FindClosest(Projectile.Center, 1, 1); - Vector2 vector20 = Main.player[num189].Center - Projectile.Center; - vector20.Normalize(); - vector20 *= Projectile.ai[0]; - int num190 = 80; - Projectile.velocity = (Projectile.velocity * (num190 - 1) + vector20) / num190; + int playerTracker = Player.FindClosest(Projectile.Center, 1, 1); + Vector2 playerDirection = Main.player[playerTracker].Center - Projectile.Center; + playerDirection.Normalize(); + playerDirection *= Projectile.ai[0]; + Projectile.velocity = (Projectile.velocity * 79 + playerDirection) / 80; } } diff --git a/Projectiles/Boss/PhantomShot2.cs b/Projectiles/Boss/PhantomShot2.cs index 058baa4ff0..9263308bc6 100644 --- a/Projectiles/Boss/PhantomShot2.cs +++ b/Projectiles/Boss/PhantomShot2.cs @@ -55,12 +55,11 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.ai[0] == 0f) Projectile.ai[0] = Projectile.velocity.Length() * 2f; - int num189 = Player.FindClosest(Projectile.Center, 1, 1); - Vector2 vector20 = Main.player[num189].Center - Projectile.Center; - vector20.Normalize(); - vector20 *= Projectile.ai[0]; - int num190 = 80; - Projectile.velocity = (Projectile.velocity * (num190 - 1) + vector20) / num190; + int playerTracker = Player.FindClosest(Projectile.Center, 1, 1); + Vector2 playerDirection = Main.player[playerTracker].Center - Projectile.Center; + playerDirection.Normalize(); + playerDirection *= Projectile.ai[0]; + Projectile.velocity = (Projectile.velocity * 79 + playerDirection) / 80; } } diff --git a/Projectiles/Boss/PlagueExplosion.cs b/Projectiles/Boss/PlagueExplosion.cs index a1d0652c79..88853e72ba 100644 --- a/Projectiles/Boss/PlagueExplosion.cs +++ b/Projectiles/Boss/PlagueExplosion.cs @@ -23,39 +23,39 @@ namespace CalamityMod.Projectiles.Boss { Lighting.AddLight(Projectile.Center, 0f, 0.15f, 0f); - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while (num462 < num461) + int timerCounter = 0; + while (timerCounter < projTimer) { - float num463 = Main.rand.Next(-7, 8) * Projectile.scale; - float num464 = Main.rand.Next(-7, 8) * Projectile.scale; - float num465 = Main.rand.Next(2, 6) * Projectile.scale; - float num466 = (float)Math.Sqrt(num463 * num463 + num464 * num464); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 89, 0f, 0f, 100, default); - Main.dust[num467].noGravity = true; - Main.dust[num467].position.X = Projectile.Center.X; - Main.dust[num467].position.Y = Projectile.Center.Y; - Main.dust[num467].position.X += Main.rand.Next(-10, 11); - Main.dust[num467].position.Y += Main.rand.Next(-10, 11); - Main.dust[num467].velocity.X = num463; - Main.dust[num467].velocity.Y = num464; - Main.dust[num467].scale = Projectile.scale * 0.35f; - num462++; + float rando1 = Main.rand.Next(-7, 8) * Projectile.scale; + float rando2 = Main.rand.Next(-7, 8) * Projectile.scale; + float rando3 = Main.rand.Next(2, 6) * Projectile.scale; + float randoAdjuster = (float)Math.Sqrt(rando1 * rando1 + rando2 * rando2); + randoAdjuster = rando3 / randoAdjuster; + rando1 *= randoAdjuster; + rando2 *= randoAdjuster; + int greenPlague = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 89, 0f, 0f, 100, default); + Main.dust[greenPlague].noGravity = true; + Main.dust[greenPlague].position.X = Projectile.Center.X; + Main.dust[greenPlague].position.Y = Projectile.Center.Y; + Main.dust[greenPlague].position.X += Main.rand.Next(-10, 11); + Main.dust[greenPlague].position.Y += Main.rand.Next(-10, 11); + Main.dust[greenPlague].velocity.X = rando1; + Main.dust[greenPlague].velocity.Y = rando2; + Main.dust[greenPlague].scale = Projectile.scale * 0.35f; + timerCounter++; } } diff --git a/Projectiles/Boss/PlagueStingerGoliath.cs b/Projectiles/Boss/PlagueStingerGoliath.cs index 880f332496..172b16a111 100644 --- a/Projectiles/Boss/PlagueStingerGoliath.cs +++ b/Projectiles/Boss/PlagueStingerGoliath.cs @@ -27,17 +27,17 @@ namespace CalamityMod.Projectiles.Boss Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver2; - int num123 = Player.FindClosest(Projectile.Center, 1, 1); + int playerTracker = Player.FindClosest(Projectile.Center, 1, 1); Projectile.localAI[0] += 1f; if (Projectile.localAI[0] < (60f + Projectile.ai[0] * 0.5f) && Projectile.localAI[0] > 30f) { - float scaleFactor2 = Projectile.velocity.Length(); - Vector2 vector17 = Main.player[num123].Center - Projectile.Center; - vector17.Normalize(); - vector17 *= scaleFactor2; - Projectile.velocity = (Projectile.velocity * 24f + vector17) / 25f; + float projVelocity = Projectile.velocity.Length(); + Vector2 playerDirection = Main.player[playerTracker].Center - Projectile.Center; + playerDirection.Normalize(); + playerDirection *= projVelocity; + Projectile.velocity = (Projectile.velocity * 24f + playerDirection) / 25f; Projectile.velocity.Normalize(); - Projectile.velocity *= scaleFactor2; + Projectile.velocity *= projVelocity; } if (Projectile.velocity.Length() < (16f + Projectile.ai[0] * 0.04f)) @@ -55,13 +55,13 @@ namespace CalamityMod.Projectiles.Boss public override void PostDraw(Color lightColor) { Vector2 center = new Vector2(Projectile.Center.X, Projectile.Center.Y); - Vector2 vector11 = new Vector2(ModContent.Request(Texture).Value.Width / 2, ModContent.Request(Texture).Value.Height / 2); - Vector2 vector = center - Main.screenPosition; - vector -= new Vector2(ModContent.Request("CalamityMod/Projectiles/Boss/PlagueStingerGoliathGlow").Value.Width, ModContent.Request("CalamityMod/Projectiles/Boss/PlagueStingerGoliathGlow").Value.Height) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + Projectile.gfxOffY); - Color color = Color.White; - Main.spriteBatch.Draw(ModContent.Request("CalamityMod/Projectiles/Boss/PlagueStingerGoliathGlow").Value, vector, - null, color, Projectile.rotation, vector11, Projectile.scale, SpriteEffects.None, 0); + Vector2 textureArea = new Vector2(ModContent.Request(Texture).Value.Width / 2, ModContent.Request(Texture).Value.Height / 2); + Vector2 drawArea = center - Main.screenPosition; + drawArea -= new Vector2(ModContent.Request("CalamityMod/Projectiles/Boss/PlagueStingerGoliathGlow").Value.Width, ModContent.Request("CalamityMod/Projectiles/Boss/PlagueStingerGoliathGlow").Value.Height) * 1f / 2f; + drawArea += textureArea * 1f + new Vector2(0f, 4f + Projectile.gfxOffY); + Color whiteColor = Color.White; + Main.spriteBatch.Draw(ModContent.Request("CalamityMod/Projectiles/Boss/PlagueStingerGoliathGlow").Value, drawArea, + null, whiteColor, Projectile.rotation, textureArea, Projectile.scale, SpriteEffects.None, 0); } } } diff --git a/Projectiles/Boss/ProvidenceCrystal.cs b/Projectiles/Boss/ProvidenceCrystal.cs index 9d30598545..25c7473ed1 100644 --- a/Projectiles/Boss/ProvidenceCrystal.cs +++ b/Projectiles/Boss/ProvidenceCrystal.cs @@ -74,12 +74,12 @@ namespace CalamityMod.Projectiles.Boss Color BaseColor = ProvUtils.GetProjectileColor(Projectile.maxPenetrate, 0); float Brightness = 0.8f; Color DustColor = Color.Lerp(BaseColor, Color.White, Brightness); - Dust dust34 = Main.dust[Dust.NewDust(Projectile.Top, 0, 0, 267, 0f, 0f, 100, DustColor, 1f)]; - dust34.velocity.X = 0f; - dust34.noGravity = true; - dust34.fadeIn = 1f; - dust34.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * (4f * Main.rand.NextFloat() + 26f); - dust34.scale = 0.5f; + Dust crystalDust = Main.dust[Dust.NewDust(Projectile.Top, 0, 0, 267, 0f, 0f, 100, DustColor, 1f)]; + crystalDust.velocity.X = 0f; + crystalDust.noGravity = true; + crystalDust.fadeIn = 1f; + crystalDust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * (4f * Main.rand.NextFloat() + 26f); + crystalDust.scale = 0.5f; } float lifeRatio = Projectile.ai[0]; @@ -126,18 +126,18 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { - Color color25 = Lighting.GetColor((int)(Projectile.position.X + Projectile.width * 0.5) / 16, (int)((Projectile.position.Y + Projectile.height * 0.5) / 16.0)); - Vector2 vector59 = Projectile.position + new Vector2(Projectile.width, Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; + Color colorArea = Lighting.GetColor((int)(Projectile.position.X + Projectile.width * 0.5) / 16, (int)((Projectile.position.Y + Projectile.height * 0.5) / 16.0)); + Vector2 drawArea = Projectile.position + new Vector2(Projectile.width, Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; Texture2D texture2D34 = ModContent.Request(Texture).Value; - Rectangle rectangle17 = texture2D34.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); - Color alpha5 = Projectile.GetAlpha(color25); - Vector2 origin11 = rectangle17.Size() / 2f; - float scaleFactor5 = (float)Math.Cos(MathHelper.TwoPi * (Projectile.localAI[0] / 60f)) + 3f + 3f; - for (float num286 = 0f; num286 < 4f; num286 += 1f) + Rectangle textureRect = texture2D34.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); + Color colorAlpha = Projectile.GetAlpha(colorArea); + Vector2 halfRect = textureRect.Size() / 2f; + float scaleFactor = (float)Math.Cos(MathHelper.TwoPi * (Projectile.localAI[0] / 60f)) + 3f + 3f; + for (float i = 0f; i < 4f; i += 1f) { - double angle = num286 * MathHelper.PiOver2; + double angle = i * MathHelper.PiOver2; Vector2 center = default; - Main.spriteBatch.Draw(texture2D34, vector59 + Vector2.UnitY.RotatedBy(angle, center) * scaleFactor5, new Microsoft.Xna.Framework.Rectangle?(rectangle17), alpha5 * 0.2f, Projectile.rotation, origin11, Projectile.scale, SpriteEffects.None, 0); + Main.spriteBatch.Draw(texture2D34, drawArea + Vector2.UnitY.RotatedBy(angle, center) * scaleFactor, new Microsoft.Xna.Framework.Rectangle?(textureRect), colorAlpha * 0.2f, Projectile.rotation, halfRect, Projectile.scale, SpriteEffects.None, 0); } return false; } diff --git a/Projectiles/Boss/ProvidenceCrystalShard.cs b/Projectiles/Boss/ProvidenceCrystalShard.cs index 93a7be7cc8..94da33c373 100644 --- a/Projectiles/Boss/ProvidenceCrystalShard.cs +++ b/Projectiles/Boss/ProvidenceCrystalShard.cs @@ -96,71 +96,71 @@ namespace CalamityMod.Projectiles.Boss Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) - MathHelper.PiOver2; - for (int num979 = 0; num979 < 2; num979++) + for (int i = 0; i < 2; i++) { if (Main.rand.NextBool(10)) { - Vector2 value55 = Vector2.UnitY.RotatedBy(num979 * MathHelper.Pi).RotatedBy(Projectile.rotation); - Dust dust24 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 225, newColor2, 1.5f)]; - dust24.noGravity = true; - dust24.noLight = true; - dust24.scale = Projectile.Opacity * Projectile.localAI[0]; - dust24.position = Projectile.Center; - dust24.velocity = value55; + Vector2 dustRotation = Vector2.UnitY.RotatedBy(i * MathHelper.Pi).RotatedBy(Projectile.rotation); + Dust crystalDust = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 225, newColor2, 1.5f)]; + crystalDust.noGravity = true; + crystalDust.noLight = true; + crystalDust.scale = Projectile.Opacity * Projectile.localAI[0]; + crystalDust.position = Projectile.Center; + crystalDust.velocity = dustRotation; } } - for (int num980 = 0; num980 < 2; num980++) + for (int j = 0; j < 2; j++) { if (Main.rand.NextBool(10)) { - Vector2 value56 = Vector2.UnitY.RotatedBy(num980 * MathHelper.Pi); - Dust dust25 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 225, newColor2, 1.5f)]; - dust25.noGravity = true; - dust25.noLight = true; - dust25.scale = Projectile.Opacity * Projectile.localAI[0]; - dust25.position = Projectile.Center; - dust25.velocity = value56; + Vector2 dustRotate = Vector2.UnitY.RotatedBy(j * MathHelper.Pi); + Dust crystalDust2 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 225, newColor2, 1.5f)]; + crystalDust2.noGravity = true; + crystalDust2.noLight = true; + crystalDust2.scale = Projectile.Opacity * Projectile.localAI[0]; + crystalDust2.position = Projectile.Center; + crystalDust2.velocity = dustRotate; } } if (Main.rand.NextBool(10)) { - float scaleFactor13 = 1f + Main.rand.NextFloat() * 2f; + float dustVelScale = 1f + Main.rand.NextFloat() * 2f; float fadeIn = 1f + Main.rand.NextFloat(); - float num981 = 1f + Main.rand.NextFloat(); - Vector2 vector136 = Utils.RandomVector2(Main.rand, -1f, 1f); - if (vector136 != Vector2.Zero) + float dustScale = 1f + Main.rand.NextFloat(); + Vector2 randomDustOffset = Utils.RandomVector2(Main.rand, -1f, 1f); + if (randomDustOffset != Vector2.Zero) { - vector136.Normalize(); + randomDustOffset.Normalize(); } - vector136 *= 16f + Main.rand.NextFloat() * 16f; - Vector2 vector137 = Projectile.Center + vector136; - Point point3 = vector137.ToTileCoordinates(); - bool flag52 = true; - if (!WorldGen.InWorld(point3.X, point3.Y, 0)) + randomDustOffset *= 16f + Main.rand.NextFloat() * 16f; + Vector2 dustPos = Projectile.Center + randomDustOffset; + Point dustTileCoords = dustPos.ToTileCoordinates(); + bool shouldSpawn = true; + if (!WorldGen.InWorld(dustTileCoords.X, dustTileCoords.Y, 0)) { - flag52 = false; + shouldSpawn = false; } - if (flag52 && WorldGen.SolidTile(point3.X, point3.Y)) + if (shouldSpawn && WorldGen.SolidTile(dustTileCoords.X, dustTileCoords.Y)) { - flag52 = false; + shouldSpawn = false; } - if (flag52) + if (shouldSpawn) { - Dust dust26 = Main.dust[Dust.NewDust(vector137, 0, 0, 267, 0f, 0f, 127, newColor2, 1f)]; - dust26.noGravity = true; - dust26.position = vector137; - dust26.velocity = -Vector2.UnitY * scaleFactor13 * (Main.rand.NextFloat() * 0.9f + 1.6f); - dust26.fadeIn = fadeIn; - dust26.scale = num981; - dust26.noLight = true; - Dust dust27 = Dust.CloneDust(dust26); - Dust dust = dust27; + Dust holyDust = Main.dust[Dust.NewDust(dustPos, 0, 0, 267, 0f, 0f, 127, newColor2, 1f)]; + holyDust.noGravity = true; + holyDust.position = dustPos; + holyDust.velocity = -Vector2.UnitY * dustVelScale * (Main.rand.NextFloat() * 0.9f + 1.6f); + holyDust.fadeIn = fadeIn; + holyDust.scale = dustScale; + holyDust.noLight = true; + Dust holyDust2 = Dust.CloneDust(holyDust); + Dust dust = holyDust2; dust.scale *= 0.65f; - dust = dust27; + dust = holyDust2; dust.fadeIn *= 0.65f; - dust27.color = new Color(255, 255, 255, 255); + holyDust2.color = new Color(255, 255, 255, 255); } } } @@ -169,41 +169,41 @@ namespace CalamityMod.Projectiles.Boss { SoundEngine.PlaySound(SoundID.Item27, Projectile.Center); Vector2 spinningpoint = new Vector2(0f, -3f).RotatedByRandom(MathHelper.Pi); - float num69 = Main.rand.Next(7, 13); - Vector2 value5 = new Vector2(1.6f, 1.5f); + float dustAmt = Main.rand.Next(7, 13); + Vector2 randomDustVelMod = new Vector2(1.6f, 1.5f); Color newColor = Main.hslToRgb(Projectile.ai[0], 1f, 0.5f); newColor.A = 255; - for (float num70 = 0f; num70 < num69; num70++) + for (float i = 0f; i < dustAmt; i++) { - int num71 = Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 0, newColor, 1f); - Main.dust[num71].position = Projectile.Center; - Main.dust[num71].velocity = spinningpoint.RotatedBy(MathHelper.TwoPi * num70 / num69) * value5 * (0.8f + Main.rand.NextFloat() * 0.4f); - Main.dust[num71].noGravity = true; - Main.dust[num71].scale = 2f; - Main.dust[num71].fadeIn = Main.rand.NextFloat() * 2f; - Dust dust11 = Dust.CloneDust(num71); - Dust dust = dust11; + int killDust = Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 0, newColor, 1f); + Main.dust[killDust].position = Projectile.Center; + Main.dust[killDust].velocity = spinningpoint.RotatedBy(MathHelper.TwoPi * i / dustAmt) * randomDustVelMod * (0.8f + Main.rand.NextFloat() * 0.4f); + Main.dust[killDust].noGravity = true; + Main.dust[killDust].scale = 2f; + Main.dust[killDust].fadeIn = Main.rand.NextFloat() * 2f; + Dust killDustClone = Dust.CloneDust(killDust); + Dust dust = killDustClone; dust.scale /= 2f; - dust = dust11; + dust = killDustClone; dust.fadeIn /= 2f; - dust11.color = new Color(255, 255, 255, 255); + killDustClone.color = new Color(255, 255, 255, 255); } - for (float num73 = 0f; num73 < num69; num73++) + for (float j = 0f; j < dustAmt; j++) { - int num74 = Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 0, newColor, 1f); - Main.dust[num74].position = Projectile.Center; - Main.dust[num74].velocity = spinningpoint.RotatedBy(MathHelper.TwoPi * num73 / num69) * value5 * (0.8f + Main.rand.NextFloat() * 0.4f); - Dust dust = Main.dust[num74]; + int killDust2 = Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 0, newColor, 1f); + Main.dust[killDust2].position = Projectile.Center; + Main.dust[killDust2].velocity = spinningpoint.RotatedBy(MathHelper.TwoPi * j / dustAmt) * randomDustVelMod * (0.8f + Main.rand.NextFloat() * 0.4f); + Dust dust = Main.dust[killDust2]; dust.velocity *= Main.rand.NextFloat() * 0.8f; dust.noGravity = true; dust.scale = Main.rand.NextFloat() * 1f; dust.fadeIn = Main.rand.NextFloat() * 2f; - Dust dust12 = Dust.CloneDust(num74); - dust = dust12; + Dust killDustClone2 = Dust.CloneDust(killDust2); + dust = killDustClone2; dust.scale /= 2f; - dust = dust12; + dust = killDustClone2; dust.fadeIn /= 2f; - dust12.color = new Color(255, 255, 255, 255); + killDustClone2.color = new Color(255, 255, 255, 255); } } diff --git a/Projectiles/Boss/ProvidenceHolyRay.cs b/Projectiles/Boss/ProvidenceHolyRay.cs index 5cf320e796..5baa4af276 100644 --- a/Projectiles/Boss/ProvidenceHolyRay.cs +++ b/Projectiles/Boss/ProvidenceHolyRay.cs @@ -1,4 +1,5 @@ -using CalamityMod.Buffs.DamageOverTime; +using System; +using System.IO; using CalamityMod.NPCs; using CalamityMod.NPCs.ProfanedGuardians; using CalamityMod.NPCs.Providence; @@ -6,12 +7,11 @@ using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; -using System; -using System.IO; using Terraria; using Terraria.Enums; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Boss { public class ProvidenceHolyRay : ModProjectile, ILocalizedModType @@ -76,7 +76,7 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero) Projectile.velocity = -Vector2.UnitY; - float num801 = Main.npc[(int)Projectile.ai[1]].type == ModContent.NPCType() ? 0.66f : 1f; + float projScale = Main.npc[(int)Projectile.ai[1]].type == ModContent.NPCType() ? 0.66f : 1f; Projectile.localAI[0] += 1f; if (Projectile.localAI[0] >= (scissorLasers ? 100f : 180f)) { @@ -84,56 +84,54 @@ namespace CalamityMod.Projectiles.Boss return; } - Projectile.scale = (float)Math.Sin(Projectile.localAI[0] * MathHelper.Pi / (scissorLasers ? 100f : 180f)) * 10f * num801; - if (Projectile.scale > num801) - Projectile.scale = num801; + Projectile.scale = (float)Math.Sin(Projectile.localAI[0] * MathHelper.Pi / (scissorLasers ? 100f : 180f)) * 10f * projScale; + if (Projectile.scale > projScale) + Projectile.scale = projScale; - float num804 = Projectile.velocity.ToRotation(); - num804 += Projectile.ai[0]; - Projectile.rotation = num804 - MathHelper.PiOver2; - Projectile.velocity = num804.ToRotationVector2(); + float projVelRotation = Projectile.velocity.ToRotation(); + projVelRotation += Projectile.ai[0]; + Projectile.rotation = projVelRotation - MathHelper.PiOver2; + Projectile.velocity = projVelRotation.ToRotationVector2(); - float num805 = 3f; - float num806 = Projectile.width; + float projWidth = Projectile.width; Vector2 samplingPoint = Projectile.Center; if (vector78.HasValue) samplingPoint = vector78.Value; - float[] array3 = new float[(int)num805]; - Collision.LaserScan(samplingPoint, Projectile.velocity, num806 * Projectile.scale, 2400f, array3); - float num807 = 0f; - for (int num808 = 0; num808 < array3.Length; num808++) + float[] array3 = new float[3]; + Collision.LaserScan(samplingPoint, Projectile.velocity, projWidth * Projectile.scale, 2400f, array3); + float rayLength = 0f; + for (int i = 0; i < array3.Length; i++) { - num807 += array3[num808]; + rayLength += array3[i]; } - num807 /= num805; + rayLength /= 3f; // Fire laser through walls at max length if target cannot be seen if (!Collision.CanHitLine(Main.npc[(int)Projectile.ai[1]].Center, 1, 1, Main.player[Main.npc[(int)Projectile.ai[1]].target].Center, 1, 1)) - num807 = 2400f; + rayLength = 2400f; int dustType = ProvUtils.GetDustID(Projectile.maxPenetrate); - float amount = 0.5f; - Projectile.localAI[1] = MathHelper.Lerp(Projectile.localAI[1], num807, amount); // Length of laser, linear interpolation - Vector2 vector79 = Projectile.Center + Projectile.velocity * (Projectile.localAI[1] - 14f); - for (int num809 = 0; num809 < 2; num809++) + Projectile.localAI[1] = MathHelper.Lerp(Projectile.localAI[1], rayLength, 0.5f); // Length of laser, linear interpolation + Vector2 dustRotation = Projectile.Center + Projectile.velocity * (Projectile.localAI[1] - 14f); + for (int j = 0; j < 2; j++) { - float num810 = Projectile.velocity.ToRotation() + (Main.rand.NextBool() ? -1f : 1f) * MathHelper.PiOver2; - float num811 = (float)Main.rand.NextDouble() * 2f + 2f; - Vector2 vector80 = new Vector2((float)Math.Cos(num810) * num811, (float)Math.Sin(num810) * num811); - int num812 = Dust.NewDust(vector79, 0, 0, dustType, vector80.X, vector80.Y, 0, default, 1f); - Main.dust[num812].noGravity = true; - Main.dust[num812].scale = 1.7f; + float randDustDirection = Projectile.velocity.ToRotation() + (Main.rand.NextBool() ? -1f : 1f) * MathHelper.PiOver2; + float randDustVel = (float)Main.rand.NextDouble() * 2f + 2f; + Vector2 finalDustVel = new Vector2((float)Math.Cos(randDustDirection) * randDustVel, (float)Math.Sin(randDustDirection) * randDustVel); + int holyDust = Dust.NewDust(dustRotation, 0, 0, dustType, finalDustVel.X, finalDustVel.Y, 0, default, 1f); + Main.dust[holyDust].noGravity = true; + Main.dust[holyDust].scale = 1.7f; } if (Main.rand.NextBool(5)) { - Vector2 value29 = Projectile.velocity.RotatedBy(MathHelper.PiOver2, default) * ((float)Main.rand.NextDouble() - 0.5f) * Projectile.width; - int num813 = Dust.NewDust(vector79 + value29 - Vector2.One * 4f, 8, 8, dustType, 0f, 0f, 100, default, 1.5f); - Dust dust = Main.dust[num813]; + Vector2 extraDustRotate = Projectile.velocity.RotatedBy(MathHelper.PiOver2, default) * ((float)Main.rand.NextDouble() - 0.5f) * Projectile.width; + int extraHolyDust = Dust.NewDust(dustRotation + extraDustRotate - Vector2.One * 4f, 8, 8, dustType, 0f, 0f, 100, default, 1.5f); + Dust dust = Main.dust[extraHolyDust]; dust.velocity *= 0.5f; - Main.dust[num813].velocity.Y = -Math.Abs(Main.dust[num813].velocity.Y); + Main.dust[extraHolyDust].velocity.Y = -Math.Abs(Main.dust[extraHolyDust].velocity.Y); } DelegateMethods.v3_1 = new Vector3(0.3f, 0.65f, 0.7f); @@ -153,38 +151,38 @@ namespace CalamityMod.Projectiles.Boss Texture2D texture2D21 = dayTime ? ModContent.Request("CalamityMod/ExtraTextures/Lasers/ProvidenceHolyRayEnd", AssetRequestMode.ImmediateLoad).Value : ModContent.Request("CalamityMod/ExtraTextures/Lasers/ProvidenceHolyRayEndNight", AssetRequestMode.ImmediateLoad).Value; - float num223 = Projectile.localAI[1]; //length of laser - Color color44 = ProvUtils.GetProjectileColor(Projectile.maxPenetrate, 0) * 0.9f; + float rayDrawLength = Projectile.localAI[1]; //length of laser + Color baseColor = ProvUtils.GetProjectileColor(Projectile.maxPenetrate, 0) * 0.9f; Vector2 vector = Projectile.Center - Main.screenPosition; Rectangle? sourceRectangle2 = null; - Main.spriteBatch.Draw(texture2D19, vector, sourceRectangle2, color44, Projectile.rotation, texture2D19.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); - num223 -= (texture2D19.Height / 2 + texture2D21.Height) * Projectile.scale; - Vector2 value20 = Projectile.Center; - value20 += Projectile.velocity * Projectile.scale * texture2D19.Height / 2f; + Main.spriteBatch.Draw(texture2D19, vector, sourceRectangle2, baseColor, Projectile.rotation, texture2D19.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); + rayDrawLength -= (texture2D19.Height / 2 + texture2D21.Height) * Projectile.scale; + Vector2 projCenter = Projectile.Center; + projCenter += Projectile.velocity * Projectile.scale * texture2D19.Height / 2f; - if (num223 > 0f) + if (rayDrawLength > 0f) { - float num224 = 0f; - Rectangle rectangle7 = new Rectangle(0, 36 * (Projectile.timeLeft / 3 % 4), texture2D20.Width, 36); - while (num224 + 1f < num223) + float raySegment = 0f; + Rectangle drawRectangle = new Rectangle(0, 36 * (Projectile.timeLeft / 3 % 4), texture2D20.Width, 36); + while (raySegment + 1f < rayDrawLength) { - if (num223 - num224 < rectangle7.Height) - rectangle7.Height = (int)(num223 - num224); + if (rayDrawLength - raySegment < drawRectangle.Height) + drawRectangle.Height = (int)(rayDrawLength - raySegment); - Main.spriteBatch.Draw(texture2D20, value20 - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(rectangle7), color44, Projectile.rotation, new Vector2(rectangle7.Width / 2, 0f), Projectile.scale, SpriteEffects.None, 0); - num224 += rectangle7.Height * Projectile.scale; - value20 += Projectile.velocity * rectangle7.Height * Projectile.scale; - rectangle7.Y += 36; + Main.spriteBatch.Draw(texture2D20, projCenter - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(drawRectangle), baseColor, Projectile.rotation, new Vector2(drawRectangle.Width / 2, 0f), Projectile.scale, SpriteEffects.None, 0); + raySegment += drawRectangle.Height * Projectile.scale; + projCenter += Projectile.velocity * drawRectangle.Height * Projectile.scale; + drawRectangle.Y += 36; - if (rectangle7.Y + rectangle7.Height > texture2D20.Height) - rectangle7.Y = 0; + if (drawRectangle.Y + drawRectangle.Height > texture2D20.Height) + drawRectangle.Y = 0; } } - Vector2 vector2 = value20 - Main.screenPosition; + Vector2 vector2 = projCenter - Main.screenPosition; sourceRectangle2 = null; - Main.spriteBatch.Draw(texture2D21, vector2, sourceRectangle2, color44, Projectile.rotation, texture2D21.Frame(1, 1, 0, 0).Top(), Projectile.scale, SpriteEffects.None, 0); + Main.spriteBatch.Draw(texture2D21, vector2, sourceRectangle2, baseColor, Projectile.rotation, texture2D21.Frame(1, 1, 0, 0).Top(), Projectile.scale, SpriteEffects.None, 0); return false; } @@ -200,9 +198,9 @@ namespace CalamityMod.Projectiles.Boss { if (projHitbox.Intersects(targetHitbox)) return true; - - float num6 = 0f; - if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center + Projectile.velocity * Projectile.localAI[1], 22f * Projectile.scale, ref num6)) + + float useless = 0f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center + Projectile.velocity * Projectile.localAI[1], 22f * Projectile.scale, ref useless)) return true; return false; diff --git a/Projectiles/Boss/RavagerFlame.cs b/Projectiles/Boss/RavagerFlame.cs index 9629040da1..3902567863 100644 --- a/Projectiles/Boss/RavagerFlame.cs +++ b/Projectiles/Boss/RavagerFlame.cs @@ -29,11 +29,11 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - for (int num468 = 0; num468 < 2; num468++) + for (int i = 0; i < 2; i++) { - int num469 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100, default, 3f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int icyFlame = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100, default, 3f); + Main.dust[icyFlame].noGravity = true; + Main.dust[icyFlame].velocity *= 0f; } if (Projectile.ai[1] == 0f) { diff --git a/Projectiles/Boss/RedLightning.cs b/Projectiles/Boss/RedLightning.cs index 842c5d54d7..7f0a8ad5b8 100644 --- a/Projectiles/Boss/RedLightning.cs +++ b/Projectiles/Boss/RedLightning.cs @@ -49,40 +49,40 @@ namespace CalamityMod.Projectiles.Boss { if (Projectile.frameCounter == 0 || Projectile.oldPos[0] == Vector2.Zero) { - for (int num31 = Projectile.oldPos.Length - 1; num31 > 0; num31--) + for (int i = Projectile.oldPos.Length - 1; i > 0; i--) { - Projectile.oldPos[num31] = Projectile.oldPos[num31 - 1]; + Projectile.oldPos[i] = Projectile.oldPos[i - 1]; } Projectile.oldPos[0] = Projectile.position; if (Projectile.velocity == Vector2.Zero) { - float num32 = Projectile.rotation + MathHelper.PiOver2 + ((Main.rand.Next(2) == 1) ? -1f : 1f) * MathHelper.PiOver2; - float num33 = (float)Main.rand.NextDouble() * 2f + 2f; - Vector2 vector2 = new Vector2((float)Math.Cos((double)num32) * num33, (float)Math.Sin((double)num32) * num33); - int num34 = Dust.NewDust(Projectile.oldPos[Projectile.oldPos.Length - 1], 0, 0, 60, vector2.X, vector2.Y, 0, default, 1f); - Main.dust[num34].noGravity = true; - Main.dust[num34].scale = 1.7f; + float dustRotation = Projectile.rotation + MathHelper.PiOver2 + ((Main.rand.Next(2) == 1) ? -1f : 1f) * MathHelper.PiOver2; + float randDustRotateMod = (float)Main.rand.NextDouble() * 2f + 2f; + Vector2 dustVelocity = new Vector2((float)Math.Cos((double)dustRotation) * randDustRotateMod, (float)Math.Sin((double)dustRotation) * randDustRotateMod); + int redDust = Dust.NewDust(Projectile.oldPos[Projectile.oldPos.Length - 1], 0, 0, 60, dustVelocity.X, dustVelocity.Y, 0, default, 1f); + Main.dust[redDust].noGravity = true; + Main.dust[redDust].scale = 1.7f; } } - int num3 = Projectile.frameCounter; - Projectile.frameCounter = num3 + 1; + int inc = Projectile.frameCounter; + Projectile.frameCounter = inc + 1; Lighting.AddLight(Projectile.Center, 0.8f, 0.25f, 0.15f); if (Projectile.velocity == Vector2.Zero) { if (Projectile.frameCounter >= Projectile.extraUpdates * 2) { Projectile.frameCounter = 0; - bool flag36 = true; - for (int num855 = 1; num855 < Projectile.oldPos.Length; num855 = num3 + 1) + bool lightningExpired = true; + for (int j = 1; j < Projectile.oldPos.Length; j = inc + 1) { - if (Projectile.oldPos[num855] != Projectile.oldPos[0]) + if (Projectile.oldPos[j] != Projectile.oldPos[0]) { - flag36 = false; + lightningExpired = false; } - num3 = num855; + inc = j; } - if (flag36) + if (lightningExpired) { Projectile.Kill(); return; @@ -90,66 +90,66 @@ namespace CalamityMod.Projectiles.Boss } if (Main.rand.Next(Projectile.extraUpdates) == 0) { - for (int num856 = 0; num856 < 2; num856 = num3 + 1) + for (int k = 0; k < 2; k = inc + 1) { - float num857 = Projectile.rotation + ((Main.rand.Next(2) == 1) ? -1f : 1f) * MathHelper.PiOver2; - float num858 = (float)Main.rand.NextDouble() * 0.8f + 1f; - Vector2 vector96 = new Vector2((float)Math.Cos((double)num857) * num858, (float)Math.Sin((double)num857) * num858); - int num859 = Dust.NewDust(Projectile.Center, 0, 0, 60, vector96.X, vector96.Y, 0, default, 1f); - Main.dust[num859].noGravity = true; - Main.dust[num859].scale = 1.2f; - num3 = num856; + float extraDustRotate = Projectile.rotation + ((Main.rand.Next(2) == 1) ? -1f : 1f) * MathHelper.PiOver2; + float extraRandRotate = (float)Main.rand.NextDouble() * 0.8f + 1f; + Vector2 dustVelocity = new Vector2((float)Math.Cos((double)extraDustRotate) * extraRandRotate, (float)Math.Sin((double)extraDustRotate) * extraRandRotate); + int extraRedDust = Dust.NewDust(Projectile.Center, 0, 0, 60, dustVelocity.X, dustVelocity.Y, 0, default, 1f); + Main.dust[extraRedDust].noGravity = true; + Main.dust[extraRedDust].scale = 1.2f; + inc = k; } if (Main.rand.NextBool(5)) { - Vector2 value39 = Projectile.velocity.RotatedBy((double)MathHelper.PiOver2, default(Vector2)) * ((float)Main.rand.NextDouble() - 0.5f) * (float)Projectile.width; - int num860 = Dust.NewDust(Projectile.Center + value39 - Vector2.One * 4f, 8, 8, 60, 0f, 0f, 100, default, 1.5f); - Dust dust = Main.dust[num860]; + Vector2 moreDustRotation = Projectile.velocity.RotatedBy((double)MathHelper.PiOver2, default(Vector2)) * ((float)Main.rand.NextDouble() - 0.5f) * (float)Projectile.width; + int moreExtraRedDust = Dust.NewDust(Projectile.Center + moreDustRotation - Vector2.One * 4f, 8, 8, 60, 0f, 0f, 100, default, 1.5f); + Dust dust = Main.dust[moreExtraRedDust]; dust.velocity *= 0.5f; - Main.dust[num860].velocity.Y = -Math.Abs(Main.dust[num860].velocity.Y); + Main.dust[moreExtraRedDust].velocity.Y = -Math.Abs(Main.dust[moreExtraRedDust].velocity.Y); } } } else if (Projectile.frameCounter >= Projectile.extraUpdates * 2) { Projectile.frameCounter = 0; - float num861 = Projectile.velocity.Length(); + float projSpeed = Projectile.velocity.Length(); UnifiedRandom unifiedRandom = new UnifiedRandom((int)Projectile.ai[1]); - int num862 = 0; - Vector2 vector97 = -Vector2.UnitY; - Vector2 vector98; + int frameIncrement = 0; + Vector2 randomLightningMovement = -Vector2.UnitY; + Vector2 lightningYRotation; do { - int num863 = unifiedRandom.Next(); - Projectile.ai[1] = (float)num863; - num863 %= 100; - float f = (float)num863 / 100f * MathHelper.TwoPi; - vector98 = f.ToRotationVector2(); - if (vector98.Y > 0f) + int randomIncrement = unifiedRandom.Next(); + Projectile.ai[1] = (float)randomIncrement; + randomIncrement %= 100; + float f = (float)randomIncrement / 100f * MathHelper.TwoPi; + lightningYRotation = f.ToRotationVector2(); + if (lightningYRotation.Y > 0f) { - vector98.Y *= -1f; + lightningYRotation.Y *= -1f; } - bool flag37 = false; - if (vector98.Y > -0.02f) + bool stopLightning = false; + if (lightningYRotation.Y > -0.02f) { - flag37 = true; + stopLightning = true; } - if (vector98.X * (float)(Projectile.extraUpdates + 1) * 2f * num861 + Projectile.localAI[0] > 40f) + if (lightningYRotation.X * (float)(Projectile.extraUpdates + 1) * 2f * projSpeed + Projectile.localAI[0] > 40f) { - flag37 = true; + stopLightning = true; } - if (vector98.X * (float)(Projectile.extraUpdates + 1) * 2f * num861 + Projectile.localAI[0] < -40f) + if (lightningYRotation.X * (float)(Projectile.extraUpdates + 1) * 2f * projSpeed + Projectile.localAI[0] < -40f) { - flag37 = true; + stopLightning = true; } - if (!flag37) + if (!stopLightning) { goto IL_25086; } - num3 = num862; - num862 = num3 + 1; + inc = frameIncrement; + frameIncrement = inc + 1; } - while (num3 < 100); + while (inc < 100); Projectile.velocity = Vector2.Zero; Projectile.localAI[1] = 1f; @@ -157,13 +157,13 @@ namespace CalamityMod.Projectiles.Boss goto IL_25092; IL_25086: - vector97 = vector98; + randomLightningMovement = lightningYRotation; IL_25092: if (Projectile.velocity != Vector2.Zero) { - Projectile.localAI[0] += vector97.X * (float)(Projectile.extraUpdates + 1) * 2f * num861; - Projectile.velocity = vector97.RotatedBy((double)(Projectile.ai[0] + MathHelper.PiOver2), default(Vector2)) * num861; + Projectile.localAI[0] += randomLightningMovement.X * (float)(Projectile.extraUpdates + 1) * 2f * projSpeed; + Projectile.velocity = randomLightningMovement.RotatedBy((double)(Projectile.ai[0] + MathHelper.PiOver2), default(Vector2)) * projSpeed; Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; } } @@ -182,39 +182,39 @@ namespace CalamityMod.Projectiles.Boss Vector2 end = Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; Texture2D tex3 = ModContent.Request("CalamityMod/ExtraTextures/Lasers/RedLightningTexture").Value; Projectile.GetAlpha(lightColor); - Vector2 scale16 = new Vector2(Projectile.scale) / 2f; - for (int num289 = 0; num289 < 3; num289++) + Vector2 lightningScale = new Vector2(Projectile.scale) / 2f; + for (int i = 0; i < 3; i++) { - if (num289 == 0) + if (i == 0) { - scale16 = new Vector2(Projectile.scale) * 0.6f; + lightningScale = new Vector2(Projectile.scale) * 0.6f; DelegateMethods.c_1 = new Microsoft.Xna.Framework.Color(219, 104, 58, 0) * 0.5f; } - else if (num289 == 1) + else if (i == 1) { - scale16 = new Vector2(Projectile.scale) * 0.4f; + lightningScale = new Vector2(Projectile.scale) * 0.4f; DelegateMethods.c_1 = new Microsoft.Xna.Framework.Color(255, 126, 56, 0) * 0.5f; } else { - scale16 = new Vector2(Projectile.scale) * 0.2f; + lightningScale = new Vector2(Projectile.scale) * 0.2f; DelegateMethods.c_1 = new Microsoft.Xna.Framework.Color(255, 128, 128, 0) * 0.5f; } DelegateMethods.f_1 = 1f; - for (int num290 = Projectile.oldPos.Length - 1; num290 > 0; num290--) + for (int j = Projectile.oldPos.Length - 1; j > 0; j--) { - if (!(Projectile.oldPos[num290] == Vector2.Zero)) + if (!(Projectile.oldPos[j] == Vector2.Zero)) { - Vector2 start = Projectile.oldPos[num290] + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; - Vector2 end2 = Projectile.oldPos[num290 - 1] + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; - Utils.DrawLaser(Main.spriteBatch, tex3, start, end2, scale16, new Utils.LaserLineFraming(DelegateMethods.LightningLaserDraw)); + Vector2 start = Projectile.oldPos[j] + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; + Vector2 end2 = Projectile.oldPos[j - 1] + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; + Utils.DrawLaser(Main.spriteBatch, tex3, start, end2, lightningScale, new Utils.LaserLineFraming(DelegateMethods.LightningLaserDraw)); } } if (Projectile.oldPos[0] != Vector2.Zero) { DelegateMethods.f_1 = 1f; Vector2 start2 = Projectile.oldPos[0] + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; - Utils.DrawLaser(Main.spriteBatch, tex3, start2, end, scale16, new Utils.LaserLineFraming(DelegateMethods.LightningLaserDraw)); + Utils.DrawLaser(Main.spriteBatch, tex3, start2, end, lightningScale, new Utils.LaserLineFraming(DelegateMethods.LightningLaserDraw)); } } return false; diff --git a/Projectiles/Boss/RedLightningFeather.cs b/Projectiles/Boss/RedLightningFeather.cs index 6eb5b4c6d5..c3a4960d09 100644 --- a/Projectiles/Boss/RedLightningFeather.cs +++ b/Projectiles/Boss/RedLightningFeather.cs @@ -67,15 +67,15 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.velocity.Length() < 10f) Projectile.velocity *= 1.015f; - int num103 = Player.FindClosest(Projectile.Center, 1, 1); - float scaleFactor2 = Projectile.velocity.Length(); - Vector2 vector11 = Main.player[num103].Center - Projectile.Center; - vector11.Normalize(); - vector11 *= scaleFactor2; + int playerTracker = Player.FindClosest(Projectile.Center, 1, 1); + float projVelocity = Projectile.velocity.Length(); + Vector2 playerDirection = Main.player[playerTracker].Center - Projectile.Center; + playerDirection.Normalize(); + playerDirection *= projVelocity; - Projectile.velocity = (Projectile.velocity * 19f + vector11) / 20f; + Projectile.velocity = (Projectile.velocity * 19f + playerDirection) / 20f; Projectile.velocity.Normalize(); - Projectile.velocity *= scaleFactor2; + Projectile.velocity *= projVelocity; } else { @@ -106,18 +106,18 @@ namespace CalamityMod.Projectiles.Boss private void EmitDust() { SoundEngine.PlaySound(SoundID.Item109, Projectile.Center); - for (int num193 = 0; num193 < 6; num193++) + for (int j = 0; j < 6; j++) { Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.5f); } - for (int num194 = 0; num194 < 10; num194++) + for (int k = 0; k < 10; k++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 0, default, 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int redDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 0, default, 2.5f); + Main.dust[redDust].noGravity = true; + Main.dust[redDust].velocity *= 3f; + redDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.5f); + Main.dust[redDust].velocity *= 2f; + Main.dust[redDust].noGravity = true; } } diff --git a/Projectiles/Boss/SandBlast.cs b/Projectiles/Boss/SandBlast.cs index 0010d9bd83..1cc9041def 100644 --- a/Projectiles/Boss/SandBlast.cs +++ b/Projectiles/Boss/SandBlast.cs @@ -46,23 +46,23 @@ namespace CalamityMod.Projectiles.Boss SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); for (int dust = 0; dust <= 3; dust++) { - float num463 = Main.rand.Next(-10, 11); - float num464 = Main.rand.Next(-10, 11); - float num465 = Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt(num463 * num463 + num464 * num464); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 85, 0f, 0f, 100, default, 1.2f); - Main.dust[num467].noGravity = true; - Main.dust[num467].position.X = Projectile.Center.X; - Main.dust[num467].position.Y = Projectile.Center.Y; - Dust expr_149DF_cp_0 = Main.dust[num467]; + float rando1 = Main.rand.Next(-10, 11); + float rando2 = Main.rand.Next(-10, 11); + float rando3 = Main.rand.Next(3, 9); + float randoAdjuster = (float)Math.Sqrt(rando1 * rando1 + rando2 * rando2); + randoAdjuster = rando3 / randoAdjuster; + rando1 *= randoAdjuster; + rando2 *= randoAdjuster; + int sandyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 85, 0f, 0f, 100, default, 1.2f); + Main.dust[sandyDust].noGravity = true; + Main.dust[sandyDust].position.X = Projectile.Center.X; + Main.dust[sandyDust].position.Y = Projectile.Center.Y; + Dust expr_149DF_cp_0 = Main.dust[sandyDust]; expr_149DF_cp_0.position.X += Main.rand.Next(-10, 11); - Dust expr_14A09_cp_0 = Main.dust[num467]; + Dust expr_14A09_cp_0 = Main.dust[sandyDust]; expr_14A09_cp_0.position.Y += Main.rand.Next(-10, 11); - Main.dust[num467].velocity.X = num463; - Main.dust[num467].velocity.Y = num464; + Main.dust[sandyDust].velocity.X = rando1; + Main.dust[sandyDust].velocity.Y = rando2; } } diff --git a/Projectiles/Boss/SandTooth.cs b/Projectiles/Boss/SandTooth.cs index 0fa14963f7..f2ae2e532c 100644 --- a/Projectiles/Boss/SandTooth.cs +++ b/Projectiles/Boss/SandTooth.cs @@ -20,18 +20,18 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - int num103 = Player.FindClosest(Projectile.Center, 1, 1); + int playerTracker = Player.FindClosest(Projectile.Center, 1, 1); Projectile.ai[1] += 1f; if (Projectile.ai[1] < 150f && Projectile.ai[1] > 30f) { float inertia = 30f; - float scaleFactor2 = Projectile.velocity.Length(); - Vector2 vector11 = Main.player[num103].Center - Projectile.Center; - vector11.Normalize(); - vector11 *= scaleFactor2; - Projectile.velocity = (Projectile.velocity * (inertia - 1f) + vector11) / inertia; + float projVelocity = Projectile.velocity.Length(); + Vector2 playerDirection = Main.player[playerTracker].Center - Projectile.Center; + playerDirection.Normalize(); + playerDirection *= projVelocity; + Projectile.velocity = (Projectile.velocity * (inertia - 1f) + playerDirection) / inertia; Projectile.velocity.Normalize(); - Projectile.velocity *= scaleFactor2; + Projectile.velocity *= projVelocity; } else if (Projectile.ai[0] == 1f) { diff --git a/Projectiles/Boss/ScavengerLaser.cs b/Projectiles/Boss/ScavengerLaser.cs index 9d96038f72..9003cd2f52 100644 --- a/Projectiles/Boss/ScavengerLaser.cs +++ b/Projectiles/Boss/ScavengerLaser.cs @@ -61,8 +61,8 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.alpha < 40) { - int num805 = Dust.NewDust(Projectile.Center - Vector2.One * 5f, 10, 10, 244, -Projectile.velocity.X / 3f, -Projectile.velocity.Y / 3f, 150, Color.Transparent, 0.6f); - Main.dust[num805].noGravity = true; + int laserDust = Dust.NewDust(Projectile.Center - Vector2.One * 5f, 10, 10, 244, -Projectile.velocity.X / 3f, -Projectile.velocity.Y / 3f, 150, Color.Transparent, 0.6f); + Main.dust[laserDust].noGravity = true; } Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; @@ -121,44 +121,44 @@ namespace CalamityMod.Projectiles.Boss float speed = revenge ? 9f : 7.5f; - Vector2 vector70 = Main.player[(int)Projectile.ai[1]].Center - Projectile.Center; - if (vector70.Length() < 20f) + Vector2 playerDistance = Main.player[(int)Projectile.ai[1]].Center - Projectile.Center; + if (playerDistance.Length() < 20f) { Projectile.Kill(); return; } - vector70.Normalize(); - vector70 *= 14f; - vector70 = Vector2.Lerp(Projectile.velocity, vector70, 0.6f); - if (vector70.Y < speed) - vector70.Y = speed; + playerDistance.Normalize(); + playerDistance *= 14f; + playerDistance = Vector2.Lerp(Projectile.velocity, playerDistance, 0.6f); + if (playerDistance.Y < speed) + playerDistance.Y = speed; - float num804 = 0.4f; - if (Projectile.velocity.X < vector70.X) + float projVelocityMult = 0.4f; + if (Projectile.velocity.X < playerDistance.X) { - Projectile.velocity.X = Projectile.velocity.X + num804; - if (Projectile.velocity.X < 0f && vector70.X > 0f) - Projectile.velocity.X = Projectile.velocity.X + num804; + Projectile.velocity.X = Projectile.velocity.X + projVelocityMult; + if (Projectile.velocity.X < 0f && playerDistance.X > 0f) + Projectile.velocity.X = Projectile.velocity.X + projVelocityMult; } - else if (Projectile.velocity.X > vector70.X) + else if (Projectile.velocity.X > playerDistance.X) { - Projectile.velocity.X = Projectile.velocity.X - num804; - if (Projectile.velocity.X > 0f && vector70.X < 0f) - Projectile.velocity.X = Projectile.velocity.X - num804; + Projectile.velocity.X = Projectile.velocity.X - projVelocityMult; + if (Projectile.velocity.X > 0f && playerDistance.X < 0f) + Projectile.velocity.X = Projectile.velocity.X - projVelocityMult; } - if (Projectile.velocity.Y < vector70.Y) + if (Projectile.velocity.Y < playerDistance.Y) { - Projectile.velocity.Y = Projectile.velocity.Y + num804; - if (Projectile.velocity.Y < 0f && vector70.Y > 0f) - Projectile.velocity.Y = Projectile.velocity.Y + num804; + Projectile.velocity.Y = Projectile.velocity.Y + projVelocityMult; + if (Projectile.velocity.Y < 0f && playerDistance.Y > 0f) + Projectile.velocity.Y = Projectile.velocity.Y + projVelocityMult; } - else if (Projectile.velocity.Y > vector70.Y) + else if (Projectile.velocity.Y > playerDistance.Y) { - Projectile.velocity.Y = Projectile.velocity.Y - num804; - if (Projectile.velocity.Y > 0f && vector70.Y < 0f) - Projectile.velocity.Y = Projectile.velocity.Y - num804; + Projectile.velocity.Y = Projectile.velocity.Y - projVelocityMult; + if (Projectile.velocity.Y > 0f && playerDistance.Y < 0f) + Projectile.velocity.Y = Projectile.velocity.Y - projVelocityMult; } } } @@ -189,18 +189,18 @@ namespace CalamityMod.Projectiles.Boss Projectile.width = Projectile.height = 64; Projectile.position.X = Projectile.position.X - (Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (Projectile.height / 2); - for (int num193 = 0; num193 < 2; num193++) + for (int i = 0; i < 2; i++) { Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 1.5f); } - for (int num194 = 0; num194 < 20; num194++) + for (int j = 0; j < 20; j++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 0, default, 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int killDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 0, default, 2.5f); + Main.dust[killDust].noGravity = true; + Main.dust[killDust].velocity *= 3f; + killDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 1.5f); + Main.dust[killDust].velocity *= 2f; + Main.dust[killDust].noGravity = true; } Projectile.Damage(); } diff --git a/Projectiles/Boss/ScavengerNuke.cs b/Projectiles/Boss/ScavengerNuke.cs index 19a762295d..41a14e4ea0 100644 --- a/Projectiles/Boss/ScavengerNuke.cs +++ b/Projectiles/Boss/ScavengerNuke.cs @@ -59,12 +59,12 @@ namespace CalamityMod.Projectiles.Boss Lighting.AddLight(Projectile.Center, 1f, 0.7f, 0f); - int num959 = (int)Projectile.ai[0]; - if (num959 >= 0 && Main.player[num959].active && !Main.player[num959].dead) + int playerTracker = (int)Projectile.ai[0]; + if (playerTracker >= 0 && Main.player[playerTracker].active && !Main.player[playerTracker].dead) { - if (Projectile.Distance(Main.player[num959].Center) > 320f) + if (Projectile.Distance(Main.player[playerTracker].Center) > 320f) { - Vector2 moveDirection = Projectile.SafeDirectionTo(Main.player[num959].Center, Vector2.UnitY); + Vector2 moveDirection = Projectile.SafeDirectionTo(Main.player[playerTracker].Center, Vector2.UnitY); Projectile.velocity = (Projectile.velocity * (inertia - 1f) + moveDirection * scaleFactor12) / inertia; } } @@ -89,23 +89,23 @@ namespace CalamityMod.Projectiles.Boss Projectile.position.X = Projectile.position.X - (Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (Projectile.height / 2); Projectile.Damage(); - for (int num621 = 0; num621 < 30; num621++) + for (int i = 0; i < 30; i++) { - int num622 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int nukeDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[nukeDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[nukeDust].scale = 0.5f; + Main.dust[nukeDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 40; num623++) + for (int j = 0; j < 40; j++) { - int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int nukeDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 3f); + Main.dust[nukeDust2].noGravity = true; + Main.dust[nukeDust2].velocity *= 5f; + nukeDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[nukeDust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) diff --git a/Projectiles/Boss/ShadeNimbusHostile.cs b/Projectiles/Boss/ShadeNimbusHostile.cs index d275b00760..4c9005206e 100644 --- a/Projectiles/Boss/ShadeNimbusHostile.cs +++ b/Projectiles/Boss/ShadeNimbusHostile.cs @@ -51,9 +51,9 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.ai[0] >= (Main.getGoodWorld ? 10f : 36f)) { Projectile.ai[0] = 0f; - int num414 = (int)(Projectile.position.X + 14f + (float)Main.rand.Next(Projectile.width - 28)); - int num415 = (int)(Projectile.position.Y + (float)Projectile.height + 4f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)num414, (float)num415, 0f, 4f, ModContent.ProjectileType(), Projectile.damage, 0f, Main.myPlayer, 0f, 0f); + int rainSpawnX = (int)(Projectile.position.X + 14f + (float)Main.rand.Next(Projectile.width - 28)); + int rainSpawnY = (int)(Projectile.position.Y + (float)Projectile.height + 4f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)rainSpawnX, (float)rainSpawnY, 0f, 4f, ModContent.ProjectileType(), Projectile.damage, 0f, Main.myPlayer, 0f, 0f); } } } diff --git a/Projectiles/Boss/ShaderainHostile.cs b/Projectiles/Boss/ShaderainHostile.cs index 4a5ed32fdb..a38be847da 100644 --- a/Projectiles/Boss/ShaderainHostile.cs +++ b/Projectiles/Boss/ShaderainHostile.cs @@ -26,8 +26,8 @@ namespace CalamityMod.Projectiles.Boss public override void OnKill(int timeLeft) { - int num310 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + (float)Projectile.height - 2f), 2, 2, 14, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num310]; + int shadeDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + (float)Projectile.height - 2f), 2, 2, 14, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[shadeDust]; dust.position.X -= 2f; dust.alpha = 38; dust.velocity *= 0.1f; diff --git a/Projectiles/Boss/ShadowflameFireball.cs b/Projectiles/Boss/ShadowflameFireball.cs index 9e8caf3edf..3d7dffc402 100644 --- a/Projectiles/Boss/ShadowflameFireball.cs +++ b/Projectiles/Boss/ShadowflameFireball.cs @@ -58,19 +58,19 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.ai[1] == 1f) { - int num103 = (int)Player.FindClosest(Projectile.Center, 1, 1); - Vector2 vector11 = Main.player[num103].Center - Projectile.Center; + int playerTracker = (int)Player.FindClosest(Projectile.Center, 1, 1); + Vector2 playerDirection = Main.player[playerTracker].Center - Projectile.Center; Projectile.ai[0] += 1f; if (Projectile.ai[0] >= 60f) { if (Projectile.ai[0] < 240f) { - float scaleFactor2 = Projectile.velocity.Length(); - vector11.Normalize(); - vector11 *= scaleFactor2; - Projectile.velocity = (Projectile.velocity * 24f + vector11) / 25f; + float scaleFactor = Projectile.velocity.Length(); + playerDirection.Normalize(); + playerDirection *= scaleFactor; + Projectile.velocity = (Projectile.velocity * 24f + playerDirection) / 25f; Projectile.velocity.Normalize(); - Projectile.velocity *= scaleFactor2; + Projectile.velocity *= scaleFactor; } else if (Projectile.velocity.Length() < 18f) { diff --git a/Projectiles/Boss/SignusScythe.cs b/Projectiles/Boss/SignusScythe.cs index 739b8d7ca1..9ec4ca3095 100644 --- a/Projectiles/Boss/SignusScythe.cs +++ b/Projectiles/Boss/SignusScythe.cs @@ -54,20 +54,20 @@ namespace CalamityMod.Projectiles.Boss SoundEngine.PlaySound(SoundID.Item73, Projectile.Center); } - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int shadowDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1f); + Main.dust[shadowDust].noGravity = true; + Main.dust[shadowDust].velocity *= 0f; Projectile.ai[0] += 1f; if (Projectile.ai[0] >= 150f) { if (Projectile.ai[1] > 0f && Projectile.ai[0] < 160f) { - int num625 = (int)Projectile.ai[1] - 1; - if (num625 < Main.maxPlayers) + int playerTracker = (int)Projectile.ai[1] - 1; + if (playerTracker < Main.maxPlayers) { - Vector2 value16 = Main.player[num625].Center - Projectile.Center; - Projectile.velocity = Vector2.Normalize(value16) * 22f; + Vector2 playerDirection = Main.player[playerTracker].Center - Projectile.Center; + Projectile.velocity = Vector2.Normalize(playerDirection) * 22f; } } } @@ -95,23 +95,23 @@ namespace CalamityMod.Projectiles.Boss public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item74, Projectile.Center); - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1f); - Main.dust[num622].velocity *= 3f; + int killDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1f); + Main.dust[killDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[killDust].scale = 0.5f; + Main.dust[killDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.5f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int killDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.5f); + Main.dust[killDust2].noGravity = true; + Main.dust[killDust2].velocity *= 5f; + killDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1f); + Main.dust[killDust2].velocity *= 2f; } } } diff --git a/Projectiles/Boss/SkyFlare.cs b/Projectiles/Boss/SkyFlare.cs index 143fbf0bbf..6375930d03 100644 --- a/Projectiles/Boss/SkyFlare.cs +++ b/Projectiles/Boss/SkyFlare.cs @@ -57,9 +57,9 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } @@ -67,59 +67,58 @@ namespace CalamityMod.Projectiles.Boss { bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; SoundEngine.PlaySound(FlareSound, Projectile.Center); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int i = 0; i < dustAmt; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 244, vector7.X * 2f, vector7.Y * 2f, 100, default, 1.4f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 dustRotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + dustRotate = dustRotate.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; + Vector2 dustDirection = dustRotate - Projectile.Center; + int flareDust = Dust.NewDust(dustRotate + dustDirection, 0, 0, 244, dustDirection.X * 2f, dustDirection.Y * 2f, 100, default, 1.4f); + Main.dust[flareDust].noGravity = true; + Main.dust[flareDust].noLight = true; + Main.dust[flareDust].velocity = dustDirection; } if (Projectile.owner == Main.myPlayer) { - int num231 = (int)(Projectile.Center.Y / 16f); - int num232 = (int)(Projectile.Center.X / 16f); - int num233 = 100; - if (num232 < 10) + int projTileX = (int)(Projectile.Center.Y / 16f); + int projTileY = (int)(Projectile.Center.X / 16f); + if (projTileY < 10) { - num232 = 10; + projTileY = 10; } - if (num232 > Main.maxTilesX - 10) + if (projTileY > Main.maxTilesX - 10) { - num232 = Main.maxTilesX - 10; + projTileY = Main.maxTilesX - 10; } - if (num231 < 10) + if (projTileX < 10) { - num231 = 10; + projTileX = 10; } - if (num231 > Main.maxTilesY - num233 - 10) + if (projTileX > Main.maxTilesY - 110) { - num231 = Main.maxTilesY - num233 - 10; + projTileX = Main.maxTilesY - 110; } - for (int num234 = num231; num234 < num231 + num233; num234++) + for (int j = projTileX; j < projTileX + 100; j++) { - Tile tile = Main.tile[num232, num234]; + Tile tile = Main.tile[projTileY, j]; if (tile.HasTile && (Main.tileSolid[(int)tile.TileType] || tile.LiquidAmount != 0)) { - num231 = num234; + projTileX = j; break; } } int tornadoType = Main.rand.Next(6); if (tornadoType < 5) { - int num235 = Main.expertMode ? 180 : 300; //720 - int num236 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)(num232 * 16 + 8), (float)(num231 * 16 - 24), 0f, 0f, ModContent.ProjectileType(), num235, 4f, Main.myPlayer, 16f, 15f + (revenge ? 4f : 0f)); - Main.projectile[num236].netUpdate = true; + int nadoDamage = Main.expertMode ? 180 : 300; //720 + int nadoSpawn = Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)(projTileY * 16 + 8), (float)(projTileX * 16 - 24), 0f, 0f, ModContent.ProjectileType(), nadoDamage, 4f, Main.myPlayer, 16f, 15f + (revenge ? 4f : 0f)); + Main.projectile[nadoSpawn].netUpdate = true; } else { - int num235 = Main.expertMode ? 230 : 400; //920 - int num236 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)(num232 * 16 + 8), (float)(num231 * 16 - 24), 0f, 0f, ModContent.ProjectileType(), num235, 4f, Main.myPlayer, 16f, 16f + (revenge ? 4f : 0f)); - Main.projectile[num236].netUpdate = true; + int nadoDamage = Main.expertMode ? 230 : 400; //920 + int nadoSpawn = Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)(projTileY * 16 + 8), (float)(projTileX * 16 - 24), 0f, 0f, ModContent.ProjectileType(), nadoDamage, 4f, Main.myPlayer, 16f, 16f + (revenge ? 4f : 0f)); + Main.projectile[nadoSpawn].netUpdate = true; } } } diff --git a/Projectiles/Boss/SkyFlareRevenge.cs b/Projectiles/Boss/SkyFlareRevenge.cs index 5f17cc6013..bc3a7fbde6 100644 --- a/Projectiles/Boss/SkyFlareRevenge.cs +++ b/Projectiles/Boss/SkyFlareRevenge.cs @@ -47,9 +47,9 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } diff --git a/Projectiles/Boss/StormWeaverFrostWaveTelegraph.cs b/Projectiles/Boss/StormWeaverFrostWaveTelegraph.cs index 080e9f6d5b..edf43f9d7e 100644 --- a/Projectiles/Boss/StormWeaverFrostWaveTelegraph.cs +++ b/Projectiles/Boss/StormWeaverFrostWaveTelegraph.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { - Texture2D pulseTexture = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/PulseAura").Value; + Texture2D pulseTexture = ModContent.Request("CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value; // Aura drawing. for (int i = 0; i < 5; i++) diff --git a/Projectiles/Boss/VileClot.cs b/Projectiles/Boss/VileClot.cs index 7f90a96afd..318e4c2e35 100644 --- a/Projectiles/Boss/VileClot.cs +++ b/Projectiles/Boss/VileClot.cs @@ -31,9 +31,9 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.velocity.Length() < 12f) Projectile.velocity *= 1.01f; - int num104 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), + int vileDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.SulfurousSeaAcid, Projectile.velocity.X * 0.1f, Projectile.velocity.Y * 0.1f, 100, default, 1.5f); - Main.dust[num104].noGravity = true; + Main.dust[vileDust].noGravity = true; Projectile.rotation += 0.3f * (float)Projectile.direction; } @@ -49,14 +49,14 @@ namespace CalamityMod.Projectiles.Boss public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item10, Projectile.Center); - for (int num584 = 0; num584 < 6; num584++) + for (int i = 0; i < 6; i++) { - int num585 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.SulfurousSeaAcid, -Projectile.velocity.X * 0.2f, -Projectile.velocity.Y * 0.2f, 100, default, 2.5f); - Main.dust[num585].noGravity = true; - Dust dust = Main.dust[num585]; + int killDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.SulfurousSeaAcid, -Projectile.velocity.X * 0.2f, -Projectile.velocity.Y * 0.2f, 100, default, 2.5f); + Main.dust[killDust].noGravity = true; + Dust dust = Main.dust[killDust]; dust.velocity *= 2f; - num585 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.SulfurousSeaAcid, -Projectile.velocity.X * 0.2f, -Projectile.velocity.Y * 0.2f, 100, default, 1.2f); - dust = Main.dust[num585]; + killDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.SulfurousSeaAcid, -Projectile.velocity.X * 0.2f, -Projectile.velocity.Y * 0.2f, 100, default, 1.2f); + dust = Main.dust[killDust]; dust.velocity *= 2f; } } diff --git a/Projectiles/Boss/WaterSpear.cs b/Projectiles/Boss/WaterSpear.cs index 50003e6dea..a3323c537b 100644 --- a/Projectiles/Boss/WaterSpear.cs +++ b/Projectiles/Boss/WaterSpear.cs @@ -45,14 +45,14 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.ai[1] == 0f) { - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int waterDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 2f); + Main.dust[waterDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[waterDust].scale = 0.5f; + Main.dust[waterDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } Projectile.ai[1] = 1f; diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index c7748164a9..14fe8d3633 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -6,6 +6,7 @@ using CalamityMod.Dusts; using CalamityMod.EntitySources; using CalamityMod.Events; using CalamityMod.Items.Accessories; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.NPCs; using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; @@ -109,6 +110,7 @@ namespace CalamityMod.Projectiles public int stealthStrikeHitCount = 0; public bool extorterBoost = false; public bool LocketClone = false; + public bool CannotProc = false; // Note: Although this was intended for fishing line colors, I use this as an AI variable a lot because vanilla only has 4 that sometimes are already in use. ~Ben // TODO -- uses of this variable are undocumented and unstable. Remove it from the API surface. @@ -160,7 +162,7 @@ namespace CalamityMod.Projectiles } #endregion On Spawn - #region SetDefaults + #region Set Defaults public override void SetDefaults(Projectile projectile) { // OLD 1.3 CODE: Disable Lunatic Cultist's homing resistance globally @@ -171,7 +173,7 @@ namespace CalamityMod.Projectiles } #endregion - #region PreAI + #region Pre AI public override bool PreAI(Projectile projectile) { #region Vanilla Summons AI Changes @@ -188,6 +190,10 @@ namespace CalamityMod.Projectiles if (projectile.type == ProjectileID.FlyingImp) return ImpMinionAI.DoImpMinionAI(projectile); + // Raven Staff's minion changes. + if (projectile.type == ProjectileID.Raven) + return RavenMinionAI.DoRavenMinionAI(projectile); + // // SENTRY AI CHANGES: // @@ -1010,7 +1016,109 @@ namespace CalamityMod.Projectiles if (CalamityWorld.revenge || BossRushEvent.BossRushActive) { - if (projectile.type == ProjectileID.DemonSickle) + if (projectile.type == ProjectileID.DeerclopsIceSpike) + { + int dustType = 16; + float dustVelocityMultiplier = 0.75f; + int numDust = 5; + int numDust2 = 5; + int fadeInTime = 10; + int fadeOutGateValue = 10; + float killGateValue = 20f; + int maxFrames = 5; + + bool fadeIn = projectile.ai[0] < (float)fadeInTime; + bool fadeOut = projectile.ai[0] >= (float)fadeOutGateValue; + bool killProjectile = projectile.ai[0] >= killGateValue; + projectile.ai[0] += 1f; + if (projectile.localAI[0] == 0f) + { + projectile.localAI[0] = 1f; + projectile.rotation = projectile.velocity.ToRotation(); + projectile.frame = Main.rand.Next(maxFrames); + + for (int i = 0; i < numDust; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(24f, 24f), dustType, projectile.velocity * dustVelocityMultiplier * MathHelper.Lerp(0.2f, 0.7f, Main.rand.NextFloat())); + dust.velocity += Main.rand.NextVector2Circular(0.5f, 0.5f); + dust.scale = 0.8f + Main.rand.NextFloat() * 0.5f; + } + + for (int j = 0; j < numDust2; j++) + { + Dust dust2 = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(24f, 24f), dustType, Main.rand.NextVector2Circular(2f, 2f) + projectile.velocity * dustVelocityMultiplier * MathHelper.Lerp(0.2f, 0.5f, Main.rand.NextFloat())); + dust2.velocity += Main.rand.NextVector2Circular(0.5f, 0.5f); + dust2.scale = 0.8f + Main.rand.NextFloat() * 0.5f; + dust2.fadeIn = 1f; + } + + SoundEngine.PlaySound(SoundID.DeerclopsIceAttack, projectile.Center); + } + + if (fadeIn) + { + projectile.Opacity += 0.1f; + projectile.scale = projectile.Opacity * projectile.ai[1]; + } + + if (fadeOut) + projectile.Opacity -= 0.2f; + + if (killProjectile) + projectile.Kill(); + + return false; + } + + // Override Deerclops rubble behavior to create a wave of rubble instead of it all flying up at the same time + // Rubble doesn't deal damage if it's not moving + else if (projectile.type == ProjectileID.DeerclopsRangedProjectile) + { + projectile.ai[0] += 1f; + + projectile.frame = (int)projectile.ai[1]; + + if (projectile.localAI[0] == 0f) + { + projectile.localAI[0] = 1f; + projectile.rotation = projectile.velocity.ToRotation(); + for (int dustIndex = 0; dustIndex < 5; dustIndex++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(24f, 24f), 16, projectile.velocity * MathHelper.Lerp(0.2f, 0.7f, Main.rand.NextFloat())); + dust.velocity += Main.rand.NextVector2Circular(0.5f, 0.5f); + dust.scale = 0.8f + Main.rand.NextFloat() * 0.5f; + } + + for (int dustIndex = 0; dustIndex < 5; dustIndex++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(24f, 24f), 16, Main.rand.NextVector2Circular(2f, 2f) + projectile.velocity * MathHelper.Lerp(0.2f, 0.5f, Main.rand.NextFloat())); + dust.velocity += Main.rand.NextVector2Circular(0.5f, 0.5f); + dust.scale = 0.8f + Main.rand.NextFloat() * 0.5f; + dust.fadeIn = 1f; + } + } + + if (projectile.ai[0] >= 5f + projectile.ai[2]) + projectile.velocity.Y += 0.15f; + + // Create a wave of rubble + // Make sure the projectile doesn't despawn before it starts going up + if (projectile.ai[0] <= projectile.ai[2]) + { + projectile.timeLeft += 1; + + // Use the expected velocity when the time is right + if (projectile.ai[0] == projectile.ai[2]) + { + projectile.velocity *= 100f; + projectile.velocity *= 12f + Main.rand.NextFloat() * 2f; + } + } + + return false; + } + + else if (projectile.type == ProjectileID.DemonSickle) { if (Main.wofNPCIndex < 0 || !Main.npc[Main.wofNPCIndex].active || Main.npc[Main.wofNPCIndex].life <= 0) return true; @@ -2114,7 +2222,8 @@ namespace CalamityMod.Projectiles { if (projectile.type != ProjectileType()) projectile.extraUpdates += 1; - if (projectile.type == ProjectileID.MechanicalPiranha) { + if (projectile.type == ProjectileID.MechanicalPiranha) + { projectile.localNPCHitCooldown *= 2; projectile.timeLeft *= 2; } @@ -2304,6 +2413,8 @@ namespace CalamityMod.Projectiles if (projectile.CountsAsClass()) { + if (!LocketClone && !CannotProc) + { if (modPlayer.nanotech) { if (Main.player[projectile.owner].miscCounter % 30 == 0 && projectile.FinalExtraUpdate()) @@ -2311,6 +2422,9 @@ namespace CalamityMod.Projectiles if (projectile.owner == Main.myPlayer && player.ownedProjectileCounts[ProjectileType()] < 5) { int damage = (int)player.GetTotalDamage().ApplyTo(60); + if (modPlayer.oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, Vector2.Zero, ProjectileType(), damage, 0f, projectile.owner); } } @@ -2322,6 +2436,9 @@ namespace CalamityMod.Projectiles if (projectile.owner == Main.myPlayer && player.ownedProjectileCounts[ProjectileType()] < 5) { int damage = (int)player.GetTotalDamage().ApplyTo(45); + if (modPlayer.oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + int proj = Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, Vector2.Zero, ProjectileType(), damage, 0f, projectile.owner); if (proj.WithinBounds(Main.maxProjectiles)) Main.projectile[proj].DamageType = DamageClass.Generic; @@ -2336,10 +2453,15 @@ namespace CalamityMod.Projectiles if (projectile.owner == Main.myPlayer && player.ownedProjectileCounts[ProjectileType()] < 5) { int damage = (int)player.GetTotalDamage().ApplyTo(DragonScales.ShitBaseDamage); - int proj = Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, Vector2.One.RotatedByRandom(MathHelper.TwoPi), ProjectileType(), - damage, 0f, projectile.owner); + if (modPlayer.oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + + int proj = Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * 1.2f, ProjectileType(), damage, 0f, projectile.owner); if (proj.WithinBounds(Main.maxProjectiles)) + { Main.projectile[proj].DamageType = DamageClass.Generic; + Main.projectile[proj].ArmorPenetration = 10; + } } } } @@ -2352,6 +2474,9 @@ namespace CalamityMod.Projectiles { // Daedalus Rogue Crystals: 2 x 25%, soft cap starts at 120 base damage int crystalDamage = CalamityUtils.DamageSoftCap(projectile.damage * 0.25, 30); + if (modPlayer.oldFashioned) + crystalDamage = CalamityUtils.CalcOldFashionedDamage(crystalDamage); + for (int i = 0; i < 2; i++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); @@ -2362,9 +2487,10 @@ namespace CalamityMod.Projectiles } } } - + } + if (player.meleeEnchant > 0 && !projectile.noEnchantments && !projectile.noEnchantmentVisuals) - { + { switch (player.meleeEnchant) { case 1: @@ -2457,7 +2583,7 @@ namespace CalamityMod.Projectiles dust.noGravity = dust.type == 121 ? false : true; if (!player.Calamity().flaskHoly) dust.fadeIn = 1f; - dust.velocity = player.Calamity().flaskHoly && Main.rand.NextBool(3) ? new Vector2(Main.rand.NextFloat(-0.9f, 0.9f), Main.rand.NextFloat(-6.6f, -9.8f)) : dust.type == 121 ? new Vector2 (Main.rand.NextFloat(-0.7f, 0.7f), Main.rand.NextFloat(0.6f, 1.8f)) : -projectile.velocity * 0.2f; + dust.velocity = player.Calamity().flaskHoly && Main.rand.NextBool(3) ? new Vector2(Main.rand.NextFloat(-0.9f, 0.9f), Main.rand.NextFloat(-6.6f, -9.8f)) : dust.type == 121 ? new Vector2(Main.rand.NextFloat(-0.7f, 0.7f), Main.rand.NextFloat(0.6f, 1.8f)) : -projectile.velocity * 0.2f; } } } @@ -2660,6 +2786,18 @@ namespace CalamityMod.Projectiles switch (projectile.type) { + // Rev+ Deerclops ice spikes can only deal damage while they're not fading out + case ProjectileID.DeerclopsIceSpike: + if (CalamityWorld.revenge || BossRushEvent.BossRushActive) + return projectile.ai[0] < 10f; + break; + + // Rev+ Deerclops rubble doesn't deal damage while it's not flying upwards + case ProjectileID.DeerclopsRangedProjectile: + if (CalamityWorld.revenge || BossRushEvent.BossRushActive) + return projectile.ai[0] > projectile.ai[2]; + break; + // Storm Weaver frost waves don't deal damage unless they're at their max velocity case ProjectileID.FrostWave: if (projectile.ai[1] > 0f) @@ -2772,6 +2910,17 @@ namespace CalamityMod.Projectiles public override bool PreDraw(Projectile projectile, ref Color lightColor) { + #region Vanilla Summons Drawing Changes + + // + // MINION AI CHANGES: + // + + if (projectile.type == ProjectileID.Raven) + return RavenMinionAI.DoRavenMinionDrawing(projectile, ref lightColor); + + #endregion + // Chlorophyte Crystal AI rework. if (projectile.type == ProjectileID.CrystalLeaf) return ChlorophyteCrystalAI.DoChlorophyteCrystalDrawing(projectile); @@ -2848,6 +2997,9 @@ namespace CalamityMod.Projectiles { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); int damage = (int)player.GetTotalDamage().ApplyTo(20); + if (player.Calamity().oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + int soul = Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, velocity, ProjectileType(), damage, 0f, projectile.owner); Main.projectile[soul].tileCollide = false; if (soul.WithinBounds(Main.maxProjectiles)) @@ -2858,6 +3010,9 @@ namespace CalamityMod.Projectiles if (modPlayer.scuttlersJewel && stealthStrike && modPlayer.scuttlerCooldown <= 0) { int damage = (int)player.GetTotalDamage().ApplyTo(15); + if (modPlayer.oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + int spike = Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, Vector2.Zero, ProjectileType(), damage, projectile.knockBack, projectile.owner); Main.projectile[spike].frame = 4; if (spike.WithinBounds(Main.maxProjectiles)) @@ -2878,7 +3033,7 @@ namespace CalamityMod.Projectiles } #endregion - #region LifeSteal + #region Life Steal public static bool CanSpawnLifeStealProjectile(float healMultiplier, float healAmount) { if (healMultiplier <= 0f || (int)healAmount <= 0) diff --git a/Projectiles/CalamityGlobalProjectileTweaks.cs b/Projectiles/CalamityGlobalProjectileTweaks.cs index 1525b8ebf0..6273a0bc92 100644 --- a/Projectiles/CalamityGlobalProjectileTweaks.cs +++ b/Projectiles/CalamityGlobalProjectileTweaks.cs @@ -128,17 +128,18 @@ namespace CalamityMod.Projectiles { ProjectileID.CobaltChainsaw, standardChainsawTweaks }, { ProjectileID.CobaltDrill, standardDrillTweaks }, { ProjectileID.CrystalBullet, standardBulletTweaks }, - { ProjectileID.CrystalVileShardHead, Do(LocalIFrames(10)) }, - { ProjectileID.CrystalVileShardShaft, Do(LocalIFrames(10)) }, + { ProjectileID.CrystalVileShardHead, Do(LocalIFrames(23)) }, + { ProjectileID.CrystalVileShardShaft, Do(LocalIFrames(23)) }, { ProjectileID.CursedBullet, standardBulletTweaks }, { ProjectileID.DD2SquireSonicBoom, Do(PiercingExact(3)) }, // Flying Dragon { ProjectileID.EmeraldBolt, Do(NoPiercing) }, { ProjectileID.EmpressBlade, Do(LocalIFrames(30)) }, // Terraprisma { ProjectileID.EnchantedBoomerang, Do(ExtraUpdatesExact(1)) }, { ProjectileID.ExplosiveBullet, standardBulletTweaks }, + { ProjectileID.FairyQueenRangedItemShot, Do(PiercingExact(7), ExtraUpdatesExact(1)) }, // Eventide Convert { ProjectileID.FlaironBubble, Do(ExtraUpdatesExact(1), TimeLeftExact(400)) }, { ProjectileID.Flamarang, Do(ExtraUpdatesExact(2)) }, - { ProjectileID.Flames, Do(IDStaticIFrames(10)) }, // Flamethrower + Elf Melter + { ProjectileID.Flames, Do(IDStaticIFrames(5)) }, // Flamethrower AND Elf Melter flames { ProjectileID.FlamingJack, Do(ExtraUpdatesExact(1)) }, { ProjectileID.FlowerPetal, Do(MaxUpdatesExact(4), LocalIFrames(10)) }, // Orichalcum armor { ProjectileID.FlowerPow, Do(ExtraUpdatesExact(1)) }, diff --git a/Projectiles/DraedonsArsenal/FrequencyManipulatorProjectile.cs b/Projectiles/DraedonsArsenal/FrequencyManipulatorProjectile.cs index 17b698af4f..69527765f3 100644 --- a/Projectiles/DraedonsArsenal/FrequencyManipulatorProjectile.cs +++ b/Projectiles/DraedonsArsenal/FrequencyManipulatorProjectile.cs @@ -56,7 +56,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public void ManipulatePlayerItemValues(Player player) { - player.direction = Projectile.direction; + player.ChangeDir(Projectile.direction); player.heldProj = Projectile.whoAmI; player.itemRotation = Projectile.rotation; player.itemTime = player.itemAnimation; diff --git a/Projectiles/DraedonsArsenal/GatlingLaserProj.cs b/Projectiles/DraedonsArsenal/GatlingLaserProj.cs index c47b5f9259..f6b0fe0b94 100644 --- a/Projectiles/DraedonsArsenal/GatlingLaserProj.cs +++ b/Projectiles/DraedonsArsenal/GatlingLaserProj.cs @@ -29,9 +29,10 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void AI() { + if (SoundEngine.TryGetActiveSound(gatlingLaserLoopID, out var ShootingSound) && ShootingSound.IsPlaying) + ShootingSound.Position = Projectile.Center; Player player = Main.player[Projectile.owner]; - float num = MathHelper.PiOver2; - Vector2 vector = player.RotatedRelativePoint(player.MountedCenter, true); + Vector2 playerRotation = player.RotatedRelativePoint(player.MountedCenter, true); if (Projectile.type == ModContent.ProjectileType()) { if (Projectile.ai[0] < 5f) @@ -80,26 +81,26 @@ namespace CalamityMod.Projectiles.DraedonsArsenal if (stillInUse && hasMana && hasCharge) { float scaleFactor = player.ActiveItem().shootSpeed * Projectile.scale; - Vector2 value2 = vector; - Vector2 value3 = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - value2; + Vector2 laserDirection = playerRotation; + Vector2 aimDirection = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - laserDirection; if (player.gravDir == -1f) { - value3.Y = Main.screenHeight - Main.mouseY + Main.screenPosition.Y - value2.Y; + aimDirection.Y = Main.screenHeight - Main.mouseY + Main.screenPosition.Y - laserDirection.Y; } - Vector2 vector3 = Vector2.Normalize(value3); - if (float.IsNaN(vector3.X) || float.IsNaN(vector3.Y)) + Vector2 projVelocity = Vector2.Normalize(aimDirection); + if (float.IsNaN(projVelocity.X) || float.IsNaN(projVelocity.Y)) { - vector3 = -Vector2.UnitY; + projVelocity = -Vector2.UnitY; } - vector3 *= scaleFactor; - if (vector3.X != Projectile.velocity.X || vector3.Y != Projectile.velocity.Y) + projVelocity *= scaleFactor; + if (projVelocity.X != Projectile.velocity.X || projVelocity.Y != Projectile.velocity.Y) { Projectile.netUpdate = true; } - Projectile.velocity = vector3; + Projectile.velocity = projVelocity; int type = ModContent.ProjectileType(); float velocity = 3f; - value2 = Projectile.Center; + laserDirection = Projectile.Center; Vector2 spinningpoint = Vector2.Normalize(Projectile.velocity) * velocity; double spread = Math.PI / 32D; @@ -109,19 +110,19 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { spinningpoint = -Vector2.UnitY; } - Vector2 velocity2 = new Vector2(spinningpoint.X, spinningpoint.Y); - if (velocity2.Length() > 5f) + Vector2 projVelocitySpread = new Vector2(spinningpoint.X, spinningpoint.Y); + if (projVelocitySpread.Length() > 5f) { - velocity2.Normalize(); - velocity2 *= 5f; + projVelocitySpread.Normalize(); + projVelocitySpread *= 5f; } - float SpeedX = velocity2.X + Main.rand.Next(-1, 2) * 0.005f; - float SpeedY = velocity2.Y + Main.rand.Next(-1, 2) * 0.005f; + float SpeedX = projVelocitySpread.X + Main.rand.Next(-1, 2) * 0.005f; + float SpeedY = projVelocitySpread.Y + Main.rand.Next(-1, 2) * 0.005f; float ai0 = Projectile.ai[0] - 2f; // 0, 1, or 2 // Use charge when firing a laser. modItem.Charge -= GatlingLaser.HoldoutChargeUse; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), value2.X, value2.Y, SpeedX, SpeedY, type, currentDamage, Projectile.knockBack, Projectile.owner, ai0, 0f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), laserDirection.X, laserDirection.Y, SpeedX, SpeedY, type, currentDamage, Projectile.knockBack, Projectile.owner, ai0, 0f); } else { @@ -135,7 +136,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal } } Projectile.position = player.RotatedRelativePoint(player.MountedCenter, true) - Projectile.Size / 2f; - Projectile.rotation = Projectile.velocity.ToRotation() + num; + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; Projectile.spriteDirection = Projectile.direction; Projectile.timeLeft = 2; player.ChangeDir(Projectile.direction); diff --git a/Projectiles/DraedonsArsenal/GatlingLaserShot.cs b/Projectiles/DraedonsArsenal/GatlingLaserShot.cs index bca69fa66a..aae0a0d746 100644 --- a/Projectiles/DraedonsArsenal/GatlingLaserShot.cs +++ b/Projectiles/DraedonsArsenal/GatlingLaserShot.cs @@ -1,5 +1,7 @@ using System; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using ReLogic.Utilities; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -12,6 +14,9 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; private int dust = 182; + private Player Owner => Main.player[Projectile.owner]; + + private int Time = 0; public override void SetDefaults() { @@ -26,44 +31,18 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void AI() { + Time++; Lighting.AddLight(Projectile.Center, 0.2f, 0f, 0f); - - float createDustVar = 10f; - Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] > createDustVar) + if (Projectile.timeLeft % 11 == 0 && Time > 12 && Time < 460) { - Vector2 value7 = new Vector2(5f, 10f); - Vector2 value8 = Vector2.UnitX * -12f; - - switch ((int)Projectile.ai[0]) - { - case 0: - int num41 = Dust.NewDust(Projectile.Center, 0, 0, dust, 0f, 0f, 160, default, 0.8f); - Main.dust[num41].noGravity = true; - Main.dust[num41].position = Projectile.Center; - Main.dust[num41].velocity = Projectile.velocity; - break; - case 1: - value8 = -Vector2.UnitY.RotatedBy(24f * 0.1308997f + 0f * MathHelper.Pi) * value7 * 0.5f; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, dust, 0f, 0f, 160, default, 0.8f); - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8; - Main.dust[num42].velocity = Projectile.velocity; - break; - case 2: - value8 = -Vector2.UnitY.RotatedBy(24f * 0.1308997f + 1f * MathHelper.Pi) * value7 * 0.5f; - int num43 = Dust.NewDust(Projectile.Center, 0, 0, dust, 0f, 0f, 160, default, 0.8f); - Main.dust[num43].noGravity = true; - Main.dust[num43].position = Projectile.Center + value8; - Main.dust[num43].velocity = Projectile.velocity; - break; - default: - break; - } + SparkParticle spark = new SparkParticle(Projectile.Center, Projectile.velocity * 0.01f, false, 6, 1.7f, Color.Red); + GeneralParticleHandler.SpawnParticle(spark); + } + if (Projectile.timeLeft % 4 == 0 && Time > 12 && Time < 460) + { + SparkParticle spark2 = new SparkParticle(Projectile.Center, Projectile.velocity * 0.01f, false, 6, 0.4f, Color.White); + GeneralParticleHandler.SpawnParticle(spark2); } - - if (Projectile.localAI[0] == createDustVar) - LaserBurst(1.8f, 3f); } public override void OnKill(int timeLeft) @@ -76,31 +55,29 @@ namespace CalamityMod.Projectiles.DraedonsArsenal LaserBurst(2.4f, 4.2f); // 60 dusts - int num3; - for (int num640 = 0; num640 < 100; num640 = num3 + 1) + int inc; + for (int i = 0; i < 100; i = inc + 1) { - float num641 = 4f; + int gatlingDust = Dust.NewDust(Projectile.Center, 6, 6, dust, 0f, 0f, 100, default, 1f); + float dustVelX = Main.dust[gatlingDust].velocity.X; + float dustVelY = Main.dust[gatlingDust].velocity.Y; - int num643 = Dust.NewDust(Projectile.Center, 6, 6, dust, 0f, 0f, 100, default, 1f); - float num644 = Main.dust[num643].velocity.X; - float num645 = Main.dust[num643].velocity.Y; + if (dustVelX == 0f && dustVelY == 0f) + dustVelX = 1f; - if (num644 == 0f && num645 == 0f) - num644 = 1f; + float dustVelocity = (float)Math.Sqrt(dustVelX * dustVelX + dustVelY * dustVelY); + dustVelocity = 4f / dustVelocity; + dustVelX *= dustVelocity; + dustVelY *= dustVelocity; - float num646 = (float)Math.Sqrt(num644 * num644 + num645 * num645); - num646 = num641 / num646; - num644 *= num646; - num645 *= num646; - - Dust dust2 = Main.dust[num643]; + Dust dust2 = Main.dust[gatlingDust]; dust2.velocity *= 0.5f; - dust2.velocity.X = dust2.velocity.X + num644; - dust2.velocity.Y = dust2.velocity.Y + num645; + dust2.velocity.X = dust2.velocity.X + dustVelX; + dust2.velocity.Y = dust2.velocity.Y + dustVelY; dust2.scale = 0.66f; dust2.noGravity = true; - num3 = num640; + inc = i; } } @@ -108,52 +85,52 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { float angleRandom = 0.05f; - int num3; - for (int num53 = 0; num53 < 4; num53 = num3 + 1) + int inc; + for (int j = 0; j < 4; j = inc + 1) { float dustSpeed = Main.rand.NextFloat(speed1, speed2); Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation()); dustVel = dustVel.RotatedBy(-angleRandom); dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - int num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dust, dustVel.X, dustVel.Y, 200, default, 0.9f); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - Main.dust[num54].noGravity = true; + int burstDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dust, dustVel.X, dustVel.Y, 200, default, 0.9f); + Main.dust[burstDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + Main.dust[burstDust].noGravity = true; - Dust dust2 = Main.dust[num54]; + Dust dust2 = Main.dust[burstDust]; dust2.velocity *= 3f; - dust2 = Main.dust[num54]; + dust2 = Main.dust[burstDust]; - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dust, dustVel.X, dustVel.Y, 100, default, 0.66f); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + burstDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dust, dustVel.X, dustVel.Y, 100, default, 0.66f); + Main.dust[burstDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - dust2 = Main.dust[num54]; + dust2 = Main.dust[burstDust]; dust2.velocity *= 2f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Crimson * 0.5f; + Main.dust[burstDust].noGravity = true; + Main.dust[burstDust].fadeIn = 1f; + Main.dust[burstDust].color = Color.Crimson * 0.5f; - dust2 = Main.dust[num54]; + dust2 = Main.dust[burstDust]; - num3 = num53; + inc = j; } - for (int num55 = 0; num55 < 2; num55 = num3 + 1) + for (int k = 0; k < 2; k = inc + 1) { float dustSpeed = Main.rand.NextFloat(speed1, speed2); Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation()); dustVel = dustVel.RotatedBy(-angleRandom); dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - int num56 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dust, dustVel.X, dustVel.Y, 0, default, 1.2f); - Main.dust[num56].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 3f; - Main.dust[num56].noGravity = true; + int moreBurstDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dust, dustVel.X, dustVel.Y, 0, default, 1.2f); + Main.dust[moreBurstDust].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 3f; + Main.dust[moreBurstDust].noGravity = true; - Dust dust2 = Main.dust[num56]; + Dust dust2 = Main.dust[moreBurstDust]; dust2.velocity *= 0.5f; - dust2 = Main.dust[num56]; + dust2 = Main.dust[moreBurstDust]; - num3 = num55; + inc = k; } } } diff --git a/Projectiles/DraedonsArsenal/LaserRifleShot.cs b/Projectiles/DraedonsArsenal/LaserRifleShot.cs index 18b8691de0..29e284b6fc 100644 --- a/Projectiles/DraedonsArsenal/LaserRifleShot.cs +++ b/Projectiles/DraedonsArsenal/LaserRifleShot.cs @@ -32,15 +32,12 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > createDustVar) { - Vector2 value7 = new Vector2(5f, 10f); - Vector2 value8 = Vector2.UnitX * -12f; - for (int i = 0; i < 2; i++) { - int num41 = Dust.NewDust(Projectile.Center, 0, 0, dust, 0f, 0f, 160, Projectile.ai[0] == 0f ? default : new Color(255, 255, 0), 2f); - Main.dust[num41].noGravity = true; - Main.dust[num41].position = Projectile.Center; - Main.dust[num41].velocity = Projectile.velocity; + int laserDust = Dust.NewDust(Projectile.Center, 0, 0, dust, 0f, 0f, 160, Projectile.ai[0] == 0f ? default : new Color(255, 255, 0), 2f); + Main.dust[laserDust].noGravity = true; + Main.dust[laserDust].position = Projectile.Center; + Main.dust[laserDust].velocity = Projectile.velocity; } } @@ -62,26 +59,24 @@ namespace CalamityMod.Projectiles.DraedonsArsenal LaserBurst(2.4f, 4.2f); // 60 dusts - for (int num640 = 0; num640 < 100; num640++) + for (int i = 0; i < 100; i++) { - float num641 = 4f; + int killDust = Dust.NewDust(Projectile.Center, 6, 6, dust, 0f, 0f, 100, default, 2f); + float killDustX = Main.dust[killDust].velocity.X; + float killDustY = Main.dust[killDust].velocity.Y; - int num643 = Dust.NewDust(Projectile.Center, 6, 6, dust, 0f, 0f, 100, default, 2f); - float num644 = Main.dust[num643].velocity.X; - float num645 = Main.dust[num643].velocity.Y; + if (killDustX == 0f && killDustY == 0f) + killDustX = 1f; - if (num644 == 0f && num645 == 0f) - num644 = 1f; + float killDustVelocity = (float)Math.Sqrt(killDustX * killDustX + killDustY * killDustY); + killDustVelocity = 4f / killDustVelocity; + killDustX *= killDustVelocity; + killDustY *= killDustVelocity; - float num646 = (float)Math.Sqrt(num644 * num644 + num645 * num645); - num646 = num641 / num646; - num644 *= num646; - num645 *= num646; - - Dust dust2 = Main.dust[num643]; + Dust dust2 = Main.dust[killDust]; dust2.velocity *= 0.5f; - dust2.velocity.X = dust2.velocity.X + num644; - dust2.velocity.Y = dust2.velocity.Y + num645; + dust2.velocity.X = dust2.velocity.X + killDustX; + dust2.velocity.Y = dust2.velocity.Y + killDustY; dust2.noGravity = true; } } @@ -90,47 +85,47 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { float angleRandom = 0.05f; - for (int num53 = 0; num53 < 20; num53++) + for (int i = 0; i < 20; i++) { float dustSpeed = Main.rand.NextFloat(speed1, speed2); Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation()); dustVel = dustVel.RotatedBy(-angleRandom); dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - int num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dust, dustVel.X, dustVel.Y, 200, default, 2.5f); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - Main.dust[num54].noGravity = true; + int burstDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dust, dustVel.X, dustVel.Y, 200, default, 2.5f); + Main.dust[burstDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + Main.dust[burstDust].noGravity = true; - Dust dust2 = Main.dust[num54]; + Dust dust2 = Main.dust[burstDust]; dust2.velocity *= 3f; - dust2 = Main.dust[num54]; + dust2 = Main.dust[burstDust]; - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dust, dustVel.X, dustVel.Y, 100, default, 1.9f); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + burstDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dust, dustVel.X, dustVel.Y, 100, default, 1.9f); + Main.dust[burstDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - dust2 = Main.dust[num54]; + dust2 = Main.dust[burstDust]; dust2.velocity *= 2f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Orange * 0.5f; + Main.dust[burstDust].noGravity = true; + Main.dust[burstDust].fadeIn = 1f; + Main.dust[burstDust].color = Color.Orange * 0.5f; - dust2 = Main.dust[num54]; + dust2 = Main.dust[burstDust]; } - for (int num55 = 0; num55 < 10; num55++) + for (int j = 0; j < 10; j++) { float dustSpeed = Main.rand.NextFloat(speed1, speed2); Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation()); dustVel = dustVel.RotatedBy(-angleRandom); dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - int num56 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dust, dustVel.X, dustVel.Y, 0, default, 3.2f); - Main.dust[num56].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 3f; - Main.dust[num56].noGravity = true; + int burstDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dust, dustVel.X, dustVel.Y, 0, default, 3.2f); + Main.dust[burstDust2].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 3f; + Main.dust[burstDust2].noGravity = true; - Dust dust2 = Main.dust[num56]; + Dust dust2 = Main.dust[burstDust2]; dust2.velocity *= 0.5f; - dust2 = Main.dust[num56]; + dust2 = Main.dust[burstDust2]; } } } diff --git a/Projectiles/DraedonsArsenal/PlasmaCasterShot.cs b/Projectiles/DraedonsArsenal/PlasmaCasterShot.cs index a30502d230..dc43fcf7ea 100644 --- a/Projectiles/DraedonsArsenal/PlasmaCasterShot.cs +++ b/Projectiles/DraedonsArsenal/PlasmaCasterShot.cs @@ -36,15 +36,15 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > createDustVar) { - for (int num447 = 0; num447 < 2; num447++) + for (int i = 0; i < 2; i++) { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * (num447 * 0.25f); - int num448 = Dust.NewDust(vector33, 1, 1, dustTypeOnTimer, 0f, 0f, 0, default, 1f); - Main.dust[num448].noGravity = true; - Main.dust[num448].position = vector33; - Main.dust[num448].scale = Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.2f; + Vector2 dustRotation = Projectile.position; + dustRotation -= Projectile.velocity * (i * 0.25f); + int dustSpawn = Dust.NewDust(dustRotation, 1, 1, dustTypeOnTimer, 0f, 0f, 0, default, 1f); + Main.dust[dustSpawn].noGravity = true; + Main.dust[dustSpawn].position = dustRotation; + Main.dust[dustSpawn].scale = Main.rand.Next(70, 110) * 0.013f; + Main.dust[dustSpawn].velocity *= 0.2f; } Projectile.ai[0] += 1f; @@ -59,28 +59,28 @@ namespace CalamityMod.Projectiles.DraedonsArsenal } else { - Vector2 value7 = new Vector2(5f, 10f); + Vector2 dustRotateVector = new Vector2(5f, 10f); - for (int num41 = 0; num41 < 2; num41++) + for (int j = 0; j < 2; j++) { - Vector2 value8 = Vector2.UnitX * -12f; - value8 = -Vector2.UnitY.RotatedBy(Projectile.ai[0] * 0.1308997f + num41 * MathHelper.Pi) * value7 * 0.75f; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, dust1, 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = 0.6f; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8; - Main.dust[num42].velocity = Projectile.velocity; + Vector2 dustRotate = Vector2.UnitX * -12f; + dustRotate = -Vector2.UnitY.RotatedBy(Projectile.ai[0] * 0.1308997f + j * MathHelper.Pi) * dustRotateVector * 0.75f; + int plasmaDust = Dust.NewDust(Projectile.Center, 0, 0, dust1, 0f, 0f, 160, default, 1f); + Main.dust[plasmaDust].scale = 0.6f; + Main.dust[plasmaDust].noGravity = true; + Main.dust[plasmaDust].position = Projectile.Center + dustRotate; + Main.dust[plasmaDust].velocity = Projectile.velocity; } - for (int num41 = 0; num41 < 2; num41++) + for (int j = 0; j < 2; j++) { - Vector2 value8 = Vector2.UnitX * -12f; - value8 = -Vector2.UnitY.RotatedBy(Projectile.ai[0] * 0.1308997f + num41 * MathHelper.Pi) * value7 * 1.5f; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, dust2, 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = 0.6f; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8; - Main.dust[num42].velocity = Projectile.velocity; + Vector2 dustRotate = Vector2.UnitX * -12f; + dustRotate = -Vector2.UnitY.RotatedBy(Projectile.ai[0] * 0.1308997f + j * MathHelper.Pi) * dustRotateVector * 1.5f; + int plasmaDust = Dust.NewDust(Projectile.Center, 0, 0, dust2, 0f, 0f, 160, default, 1f); + Main.dust[plasmaDust].scale = 0.6f; + Main.dust[plasmaDust].noGravity = true; + Main.dust[plasmaDust].position = Projectile.Center + dustRotate; + Main.dust[plasmaDust].velocity = Projectile.velocity; } } } @@ -102,30 +102,30 @@ namespace CalamityMod.Projectiles.DraedonsArsenal PlasmaBurst(1.8f, 3.6f); // 60 dusts - for (int num640 = 0; num640 < 400; num640++) + for (int i = 0; i < 400; i++) { - float num641 = 16f; - if (num640 < 300) - num641 = 12f; - if (num640 < 200) - num641 = 8f; - if (num640 < 100) - num641 = 4f; + float dustScale = 16f; + if (i < 300) + dustScale = 12f; + if (i < 200) + dustScale = 8f; + if (i < 100) + dustScale = 4f; - int num643 = Dust.NewDust(Projectile.Center, 6, 6, Main.rand.NextBool() ? dust1 : dust2, 0f, 0f, 100, default, 1f); - float num644 = Main.dust[num643].velocity.X; - float num645 = Main.dust[num643].velocity.Y; + int deathDust = Dust.NewDust(Projectile.Center, 6, 6, Main.rand.NextBool() ? dust1 : dust2, 0f, 0f, 100, default, 1f); + float deathDustX = Main.dust[deathDust].velocity.X; + float deathDustY = Main.dust[deathDust].velocity.Y; - if (num644 == 0f && num645 == 0f) - num644 = 1f; + if (deathDustX == 0f && deathDustY == 0f) + deathDustX = 1f; - float num646 = (float)Math.Sqrt(num644 * num644 + num645 * num645); - num646 = num641 / num646; - num644 *= num646; - num645 *= num646; + float deathDustVel = (float)Math.Sqrt(deathDustX * deathDustX + deathDustY * deathDustY); + deathDustVel = dustScale / deathDustVel; + deathDustX *= deathDustVel; + deathDustY *= deathDustVel; float scale = 1f; - switch ((int)num641) + switch ((int)dustScale) { case 4: scale = 1.2f; @@ -143,10 +143,10 @@ namespace CalamityMod.Projectiles.DraedonsArsenal break; } - Dust dust = Main.dust[num643]; + Dust dust = Main.dust[deathDust]; dust.velocity *= 0.5f; - dust.velocity.X = dust.velocity.X + num644; - dust.velocity.Y = dust.velocity.Y + num645; + dust.velocity.X = dust.velocity.X + deathDustX; + dust.velocity.Y = dust.velocity.Y + deathDustY; dust.scale = scale; dust.noGravity = true; } @@ -156,7 +156,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { float angleRandom = 0.35f; - for (int num53 = 0; num53 < 40; num53++) + for (int i = 0; i < 40; i++) { float dustSpeed = Main.rand.NextFloat(speed1, speed2); Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation()); @@ -164,27 +164,27 @@ namespace CalamityMod.Projectiles.DraedonsArsenal dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); int randomDustType = Main.rand.Next(2) == 0 ? dust1 : dust2; - int num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 1.7f); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - Main.dust[num54].noGravity = true; + int plasmaBurstDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 1.7f); + Main.dust[plasmaBurstDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + Main.dust[plasmaBurstDust].noGravity = true; - Dust dust = Main.dust[num54]; + Dust dust = Main.dust[plasmaBurstDust]; dust.velocity *= 3f; - dust = Main.dust[num54]; + dust = Main.dust[plasmaBurstDust]; - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 0.8f); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + plasmaBurstDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 0.8f); + Main.dust[plasmaBurstDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - dust = Main.dust[num54]; + dust = Main.dust[plasmaBurstDust]; dust.velocity *= 2f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Green * 0.5f; + Main.dust[plasmaBurstDust].noGravity = true; + Main.dust[plasmaBurstDust].fadeIn = 1f; + Main.dust[plasmaBurstDust].color = Color.Green * 0.5f; - dust = Main.dust[num54]; + dust = Main.dust[plasmaBurstDust]; } - for (int num55 = 0; num55 < 20; num55++) + for (int j = 0; j < 20; j++) { float dustSpeed = Main.rand.NextFloat(speed1, speed2); Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation()); @@ -192,13 +192,13 @@ namespace CalamityMod.Projectiles.DraedonsArsenal dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); int randomDustType = Main.rand.Next(2) == 0 ? dust1 : dust2; - int num56 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 2f); - Main.dust[num56].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 3f; - Main.dust[num56].noGravity = true; + int plasmaBurstDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 2f); + Main.dust[plasmaBurstDust2].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 3f; + Main.dust[plasmaBurstDust2].noGravity = true; - Dust dust = Main.dust[num56]; + Dust dust = Main.dust[plasmaBurstDust2]; dust.velocity *= 0.5f; - dust = Main.dust[num56]; + dust = Main.dust[plasmaBurstDust2]; } } } diff --git a/Projectiles/DraedonsArsenal/PulseAura.png b/Projectiles/DraedonsArsenal/PulseAura.png deleted file mode 100644 index 8e2d2a871c..0000000000 Binary files a/Projectiles/DraedonsArsenal/PulseAura.png and /dev/null differ diff --git a/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs b/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs index 82c9c77400..756c4112b3 100644 --- a/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs +++ b/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs @@ -135,7 +135,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { Player player = Main.player[Projectile.owner]; Texture2D chainTexture = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/PulseDragonChain").Value; - Texture2D pulseTexture = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/PulseAura").Value; + Texture2D pulseTexture = ModContent.Request("CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value; Texture2D dragonHeadTexture = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/PulseDragonProjectile").Value; if (ReelingBack) dragonHeadTexture = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/PulseDragonHeadClosed").Value; diff --git a/Projectiles/DraedonsArsenal/PulseRifleShot.cs b/Projectiles/DraedonsArsenal/PulseRifleShot.cs index e1d60d1435..8f8b09c5af 100644 --- a/Projectiles/DraedonsArsenal/PulseRifleShot.cs +++ b/Projectiles/DraedonsArsenal/PulseRifleShot.cs @@ -38,42 +38,42 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > createDustVar) { - for (int num447 = 0; num447 < 2; num447++) + for (int i = 0; i < 2; i++) { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * (num447 * 0.25f); - int num448 = Dust.NewDust(vector33, 1, 1, dust1, 0f, 0f, 0, default, 1f); - Main.dust[num448].noGravity = true; - Main.dust[num448].position = vector33; - Main.dust[num448].scale = Main.rand.Next(70, 110) * 0.013f; + Vector2 projPos = Projectile.position; + projPos -= Projectile.velocity * (i * 0.25f); + int purpleDust = Dust.NewDust(projPos, 1, 1, dust1, 0f, 0f, 0, default, 1f); + Main.dust[purpleDust].noGravity = true; + Main.dust[purpleDust].position = projPos; + Main.dust[purpleDust].scale = Main.rand.Next(70, 110) * 0.013f; - int num449 = Dust.NewDust(vector33, 1, 1, dust3, 0f, 0f, 0, default, 1f); - Main.dust[num449].noGravity = true; - Main.dust[num449].position = vector33; - Main.dust[num449].scale = Main.rand.Next(70, 110) * 0.013f; + int pinkDust = Dust.NewDust(projPos, 1, 1, dust3, 0f, 0f, 0, default, 1f); + Main.dust[pinkDust].noGravity = true; + Main.dust[pinkDust].position = projPos; + Main.dust[pinkDust].scale = Main.rand.Next(70, 110) * 0.013f; } if (notSplitProjectile) { - Vector2 value7 = new Vector2(5f, 10f); - Vector2 value8 = Vector2.UnitX * -12f; + Vector2 dustRotateVector = new Vector2(5f, 10f); + Vector2 dustRotate = Vector2.UnitX * -12f; - for (int num41 = 0; num41 < 2; num41++) + for (int k = 0; k < 2; k++) { - value8 = -Vector2.UnitY.RotatedBy(24f * 0.1308997f + 0f * MathHelper.Pi) * value7; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, dust2, 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = 1.5f; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8; + dustRotate = -Vector2.UnitY.RotatedBy(24f * 0.1308997f + 0f * MathHelper.Pi) * dustRotateVector; + int darkPurpDust = Dust.NewDust(Projectile.Center, 0, 0, dust2, 0f, 0f, 160, default, 1f); + Main.dust[darkPurpDust].scale = 1.5f; + Main.dust[darkPurpDust].noGravity = true; + Main.dust[darkPurpDust].position = Projectile.Center + dustRotate; } - for (int num41 = 0; num41 < 2; num41++) + for (int k = 0; k < 2; k++) { - value8 = -Vector2.UnitY.RotatedBy(24f * 0.1308997f + 1f * MathHelper.Pi) * value7; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, dust2, 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = 1.5f; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8; + dustRotate = -Vector2.UnitY.RotatedBy(24f * 0.1308997f + 1f * MathHelper.Pi) * dustRotateVector; + int darkPurpDust = Dust.NewDust(Projectile.Center, 0, 0, dust2, 0f, 0f, 160, default, 1f); + Main.dust[darkPurpDust].scale = 1.5f; + Main.dust[darkPurpDust].noGravity = true; + Main.dust[darkPurpDust].position = Projectile.Center + dustRotate; } } } @@ -153,47 +153,47 @@ namespace CalamityMod.Projectiles.DraedonsArsenal int half = totalDust / 2; int x = (int)(totalDust * 0.625f); - for (int num647 = 0; num647 < totalDust; num647++) + for (int i = 0; i < totalDust; i++) { - float num648 = 2f * (num647 / (float)fourth); + float dustSpeed = 2f * (i / (float)fourth); int dustType = dust1; - if (num647 > fourth) + if (i > fourth) { - num648 = speed1; + dustSpeed = speed1; } - if (num647 > x) + if (i > x) { - num648 = speed1 * 1.3f; + dustSpeed = speed1 * 1.3f; dustType = dust3; } - int num650 = Dust.NewDust(Projectile.Center, 6, 6, dustType, 0f, 0f, 100, default, 1f); - float num651 = Main.dust[num650].velocity.X; - float num652 = Main.dust[num650].velocity.Y; - if (num651 == 0f && num652 == 0f) + int killDust = Dust.NewDust(Projectile.Center, 6, 6, dustType, 0f, 0f, 100, default, 1f); + float killDustX = Main.dust[killDust].velocity.X; + float killDustY = Main.dust[killDust].velocity.Y; + if (killDustX == 0f && killDustY == 0f) { - num651 = 1f; + killDustX = 1f; } - float num653 = (float)Math.Sqrt(num651 * num651 + num652 * num652); - num653 = num648 / num653; - if (num647 <= half) + float killDustYVel = (float)Math.Sqrt(killDustX * killDustX + killDustY * killDustY); + killDustYVel = dustSpeed / killDustYVel; + if (i <= half) { - num651 *= num653; - num652 *= num653; + killDustX *= killDustYVel; + killDustY *= killDustYVel; } else { - num651 = num651 * num653 * 1.25f; - num652 = num652 * num653 * 0.75f; + killDustX = killDustX * killDustYVel * 1.25f; + killDustY = killDustY * killDustYVel * 0.75f; } - Dust dust2 = Main.dust[num650]; + Dust dust2 = Main.dust[killDust]; dust2.velocity *= 0.5f; - dust2.velocity.X = dust2.velocity.X + num651; - dust2.velocity.Y = dust2.velocity.Y + num652; + dust2.velocity.X = dust2.velocity.X + killDustX; + dust2.velocity.Y = dust2.velocity.Y + killDustY; - if (num647 > fourth) + if (i > fourth) { dust2.scale = 1.3f; } @@ -206,47 +206,47 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { float angleRandom = 0.05f; - for (int num53 = 0; num53 < 50; num53++) + for (int i = 0; i < 50; i++) { float dustSpeed = Main.rand.NextFloat(speed1, speed2); Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation()); dustVel = dustVel.RotatedBy(-angleRandom); dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - int num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dust3, dustVel.X, dustVel.Y, 200, default, 1.7f); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - Main.dust[num54].noGravity = true; + int pulseDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dust3, dustVel.X, dustVel.Y, 200, default, 1.7f); + Main.dust[pulseDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + Main.dust[pulseDust].noGravity = true; - Dust dust = Main.dust[num54]; + Dust dust = Main.dust[pulseDust]; dust.velocity *= 3f; - dust = Main.dust[num54]; + dust = Main.dust[pulseDust]; - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dust1, dustVel.X, dustVel.Y, 100, default, 1f); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + pulseDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dust1, dustVel.X, dustVel.Y, 100, default, 1f); + Main.dust[pulseDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - dust = Main.dust[num54]; + dust = Main.dust[pulseDust]; dust.velocity *= 2f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Green * 0.5f; + Main.dust[pulseDust].noGravity = true; + Main.dust[pulseDust].fadeIn = 1f; + Main.dust[pulseDust].color = Color.Green * 0.5f; - dust = Main.dust[num54]; + dust = Main.dust[pulseDust]; } - for (int num55 = 0; num55 < 25; num55++) + for (int j = 0; j < 25; j++) { float dustSpeed = Main.rand.NextFloat(speed1, speed2); Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation()); dustVel = dustVel.RotatedBy(-angleRandom); dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - int num56 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dust2, dustVel.X, dustVel.Y, 0, default, 3f); - Main.dust[num56].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 3f; - Main.dust[num56].noGravity = true; + int pulseDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dust2, dustVel.X, dustVel.Y, 0, default, 3f); + Main.dust[pulseDust2].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 3f; + Main.dust[pulseDust2].noGravity = true; - Dust dust = Main.dust[num56]; + Dust dust = Main.dust[pulseDust2]; dust.velocity *= 0.5f; - dust = Main.dust[num56]; + dust = Main.dust[pulseDust2]; } } } diff --git a/Projectiles/DraedonsArsenal/TeslaCannonShot.cs b/Projectiles/DraedonsArsenal/TeslaCannonShot.cs index 5b1a0f7c39..a9ac5ec782 100644 --- a/Projectiles/DraedonsArsenal/TeslaCannonShot.cs +++ b/Projectiles/DraedonsArsenal/TeslaCannonShot.cs @@ -37,14 +37,14 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > createDustVar) { - for (int num447 = 0; num447 < 2; num447++) + for (int i = 0; i < 2; i++) { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * (num447 * 0.25f); - int num448 = Dust.NewDust(vector33, 1, 1, dustArray[3], 0f, 0f, 0, default, 1f); - Main.dust[num448].noGravity = true; - Main.dust[num448].position = vector33; - Main.dust[num448].scale = Main.rand.Next(70, 110) * 0.026f; + Vector2 projPos = Projectile.position; + projPos -= Projectile.velocity * (i * 0.25f); + int teslaDust = Dust.NewDust(projPos, 1, 1, dustArray[3], 0f, 0f, 0, default, 1f); + Main.dust[teslaDust].noGravity = true; + Main.dust[teslaDust].position = projPos; + Main.dust[teslaDust].scale = Main.rand.Next(70, 110) * 0.026f; } if (Main.rand.Next(6) == 0) @@ -60,35 +60,35 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Projectile.ai[0] = 0f; else { - Vector2 value7 = new Vector2(5f, 10f); - Vector2 value8 = Vector2.UnitX * -12f; + Vector2 dustRotateVector = new Vector2(5f, 10f); + Vector2 dustRotate = Vector2.UnitX * -12f; float scale = 1f; - for (int num41 = 0; num41 < 2; num41++) + for (int j = 0; j < 2; j++) { - value8 = -Vector2.UnitY.RotatedBy(Projectile.ai[0] * 0.1308997f + num41 * MathHelper.Pi) * value7; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, dustArray[2], 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = scale; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8; + dustRotate = -Vector2.UnitY.RotatedBy(Projectile.ai[0] * 0.1308997f + j * MathHelper.Pi) * dustRotateVector; + int lightBlueDust = Dust.NewDust(Projectile.Center, 0, 0, dustArray[2], 0f, 0f, 160, default, 1f); + Main.dust[lightBlueDust].scale = scale; + Main.dust[lightBlueDust].noGravity = true; + Main.dust[lightBlueDust].position = Projectile.Center + dustRotate; } - for (int num41 = 0; num41 < 2; num41++) + for (int j = 0; j < 2; j++) { - value8 = -Vector2.UnitY.RotatedBy(Projectile.ai[0] * 0.1308997f + num41 * MathHelper.Pi) * value7 * 1.5f; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, dustArray[1], 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = scale; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8; + dustRotate = -Vector2.UnitY.RotatedBy(Projectile.ai[0] * 0.1308997f + j * MathHelper.Pi) * dustRotateVector * 1.5f; + int lightBlueDust = Dust.NewDust(Projectile.Center, 0, 0, dustArray[1], 0f, 0f, 160, default, 1f); + Main.dust[lightBlueDust].scale = scale; + Main.dust[lightBlueDust].noGravity = true; + Main.dust[lightBlueDust].position = Projectile.Center + dustRotate; } - for (int num41 = 0; num41 < 2; num41++) + for (int j = 0; j < 2; j++) { - value8 = -Vector2.UnitY.RotatedBy(Projectile.ai[0] * 0.1308997f + num41 * MathHelper.Pi) * value7 * 2f; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, dustArray[0], 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = scale; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8; + dustRotate = -Vector2.UnitY.RotatedBy(Projectile.ai[0] * 0.1308997f + j * MathHelper.Pi) * dustRotateVector * 2f; + int lightBlueDust = Dust.NewDust(Projectile.Center, 0, 0, dustArray[0], 0f, 0f, 160, default, 1f); + Main.dust[lightBlueDust].scale = scale; + Main.dust[lightBlueDust].noGravity = true; + Main.dust[lightBlueDust].position = Projectile.Center + dustRotate; } } @@ -96,15 +96,12 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { if (arcs < 10) { - Vector2 vector35 = new Vector2(Projectile.position.X + Projectile.width * 0.5f, Projectile.position.Y + Projectile.height * 0.5f); - float num474 = 600f; - for (int i = 0; i < Main.maxNPCs; i++) { if (!Main.npc[i].CanBeChasedBy(Projectile, false) || !Collision.CanHit(Projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) continue; - if (Projectile.Center.ManhattanDistance(Main.npc[i].Center) < num474) + if (Projectile.Center.ManhattanDistance(Main.npc[i].Center) < 600f) { Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.SafeDirectionTo(Main.npc[i].Center) * 2f, Projectile.type, (int)(Projectile.damage * 0.6), Projectile.knockBack * 0.6f, Projectile.owner, 0f, -1f); @@ -146,81 +143,81 @@ namespace CalamityMod.Projectiles.DraedonsArsenal float dustSpeed = notArcingProjectile ? 12f : 6f; - for (int num672 = 0; num672 < dustAmt; num672++) + for (int i = 0; i < dustAmt; i++) { int dustType = dustArray[4]; - float num674 = dustSpeed; - if (num672 > fourth) + float deathDustSpeed = dustSpeed; + if (i > fourth) { - num674 = dustSpeed * 0.6875f; + deathDustSpeed = dustSpeed * 0.6875f; dustType = dustArray[5]; } - if (num672 > half) + if (i > half) { - num674 = dustSpeed * 0.5f; + deathDustSpeed = dustSpeed * 0.5f; dustType = dustArray[4]; } - if (num672 > threeFourths) + if (i > threeFourths) { - num674 = dustSpeed * 0.3125f; + deathDustSpeed = dustSpeed * 0.3125f; dustType = dustArray[5]; } float scale = (dustType == dustArray[4] ? 3f : 1.5f); - int num675 = Dust.NewDust(Projectile.Center, 6, 6, dustType, 0f, 0f, 100, default, scale); - float num676 = Main.dust[num675].velocity.X; - float num677 = Main.dust[num675].velocity.Y; + int deathDarkBlue = Dust.NewDust(Projectile.Center, 6, 6, dustType, 0f, 0f, 100, default, scale); + float deathDustX = Main.dust[deathDarkBlue].velocity.X; + float deathDustY = Main.dust[deathDarkBlue].velocity.Y; - if (num676 == 0f && num677 == 0f) - num676 = 1f; + if (deathDustX == 0f && deathDustY == 0f) + deathDustX = 1f; - float num678 = (float)Math.Sqrt(num676 * num676 + num677 * num677); - num678 = num674 / num678; - if (num672 > threeFourths) + float deathDustVel = (float)Math.Sqrt(deathDustX * deathDustX + deathDustY * deathDustY); + deathDustVel = deathDustSpeed / deathDustVel; + if (i > threeFourths) { - num676 = num676 * num678 * 0.7f; - num677 *= num678; + deathDustX = deathDustX * deathDustVel * 0.7f; + deathDustY *= deathDustVel; } - else if (num672 > half) + else if (i > half) { - num676 *= num678; - num677 = num677 * num678 * 0.7f; + deathDustX *= deathDustVel; + deathDustY = deathDustY * deathDustVel * 0.7f; } - else if (num672 > fourth) + else if (i > fourth) { - num676 = num676 * num678 * 0.7f; - num677 *= num678; + deathDustX = deathDustX * deathDustVel * 0.7f; + deathDustY *= deathDustVel; } else { - num676 *= num678; - num677 = num677 * num678 * 0.7f; + deathDustX *= deathDustVel; + deathDustY = deathDustY * deathDustVel * 0.7f; } - Dust dust8 = Main.dust[num675]; + Dust dust8 = Main.dust[deathDarkBlue]; dust8.velocity *= 0.5f; - dust8.velocity.X = dust8.velocity.X + num676; - dust8.velocity.Y = dust8.velocity.Y + num677; + dust8.velocity.X = dust8.velocity.X + deathDustX; + dust8.velocity.Y = dust8.velocity.Y + deathDustY; dust8.noGravity = true; - if (num672 > threeFourths) + if (i > threeFourths) { - int num650 = Dust.NewDust(Projectile.Center, 6, 6, dustArray[5], 0f, 0f, 100, default, 1.3f); - float num651 = Main.dust[num650].velocity.X; - float num652 = Main.dust[num650].velocity.Y; + int tealDust = Dust.NewDust(Projectile.Center, 6, 6, dustArray[5], 0f, 0f, 100, default, 1.3f); + float tealDustX = Main.dust[tealDust].velocity.X; + float tealDustY = Main.dust[tealDust].velocity.Y; - if (num651 == 0f && num652 == 0f) - num651 = 1f; + if (tealDustX == 0f && tealDustY == 0f) + tealDustX = 1f; - float num653 = (float)Math.Sqrt(num651 * num651 + num652 * num652); - num653 = 16f / num653; - num651 = num651 * num653 * 1.25f; - num652 = num652 * num653 * 0.75f; + float tealDustVel = (float)Math.Sqrt(tealDustX * tealDustX + tealDustY * tealDustY); + tealDustVel = 16f / tealDustVel; + tealDustX = tealDustX * tealDustVel * 1.25f; + tealDustY = tealDustY * tealDustVel * 0.75f; - Dust dust9 = Main.dust[num650]; + Dust dust9 = Main.dust[tealDust]; dust9.velocity *= 0.5f; - dust9.velocity.X = dust9.velocity.X + num651; - dust9.velocity.Y = dust9.velocity.Y + num652; + dust9.velocity.X = dust9.velocity.X + tealDustX; + dust9.velocity.Y = dust9.velocity.Y + tealDustY; dust9.noGravity = true; } } @@ -230,7 +227,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { float angleRandom = 0.05f; - for (int num53 = 0; num53 < 40; num53++) + for (int i = 0; i < 40; i++) { float dustSpeed = Main.rand.NextFloat(speed1, speed2); Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation()); @@ -239,27 +236,27 @@ namespace CalamityMod.Projectiles.DraedonsArsenal int randomDustType = Main.rand.Next(2) == 0 ? dustArray[4] : dustArray[5]; float scale = randomDustType == dustArray[4] ? 1.5f : 1f; - int num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 2.5f * scale); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - Main.dust[num54].noGravity = true; + int electricDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 2.5f * scale); + Main.dust[electricDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + Main.dust[electricDust].noGravity = true; - Dust dust = Main.dust[num54]; + Dust dust = Main.dust[electricDust]; dust.velocity *= 3f; - dust = Main.dust[num54]; + dust = Main.dust[electricDust]; - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 1.5f * scale); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + electricDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 1.5f * scale); + Main.dust[electricDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - dust = Main.dust[num54]; + dust = Main.dust[electricDust]; dust.velocity *= 2f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Cyan * 0.5f; + Main.dust[electricDust].noGravity = true; + Main.dust[electricDust].fadeIn = 1f; + Main.dust[electricDust].color = Color.Cyan * 0.5f; - dust = Main.dust[num54]; + dust = Main.dust[electricDust]; } - for (int num55 = 0; num55 < 20; num55++) + for (int j = 0; j < 20; j++) { float dustSpeed = Main.rand.NextFloat(speed1, speed2); Vector2 dustVel = new Vector2(dustSpeed, 0f).RotatedBy(Projectile.velocity.ToRotation()); @@ -268,13 +265,13 @@ namespace CalamityMod.Projectiles.DraedonsArsenal int randomDustType = Main.rand.Next(2) == 0 ? dustArray[4] : dustArray[5]; float scale = randomDustType == dustArray[4] ? 1.5f : 1f; - int num56 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 3f * scale); - Main.dust[num56].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 3f; - Main.dust[num56].noGravity = true; + int electricDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 3f * scale); + Main.dust[electricDust2].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 3f; + Main.dust[electricDust2].noGravity = true; - Dust dust = Main.dust[num56]; + Dust dust = Main.dust[electricDust2]; dust.velocity *= 0.5f; - dust = Main.dust[num56]; + dust = Main.dust[electricDust2]; } } } diff --git a/Projectiles/Enemy/CrimsonSpike.cs b/Projectiles/Enemy/CrimsonSpike.cs index 41947aea1d..8308f706c3 100644 --- a/Projectiles/Enemy/CrimsonSpike.cs +++ b/Projectiles/Enemy/CrimsonSpike.cs @@ -25,10 +25,10 @@ namespace CalamityMod.Projectiles.Enemy { Color dustColor = Color.Crimson; dustColor.A = 150; - int num67 = Dust.NewDust(Projectile.position - Projectile.velocity * 3f, Projectile.width, Projectile.height, 260, 0f, 0f, 50, dustColor, 1.2f); - Main.dust[num67].velocity *= 0.3f; - Main.dust[num67].velocity += Projectile.velocity * 0.3f; - Main.dust[num67].noGravity = true; + int redSpiky = Dust.NewDust(Projectile.position - Projectile.velocity * 3f, Projectile.width, Projectile.height, 260, 0f, 0f, 50, dustColor, 1.2f); + Main.dust[redSpiky].velocity *= 0.3f; + Main.dust[redSpiky].velocity += Projectile.velocity * 0.3f; + Main.dust[redSpiky].noGravity = true; } Projectile.Opacity += 0.2f; diff --git a/Projectiles/Enemy/EarthRockBig.cs b/Projectiles/Enemy/EarthRockBig.cs index f9464dc62e..edc68e0e4b 100644 --- a/Projectiles/Enemy/EarthRockBig.cs +++ b/Projectiles/Enemy/EarthRockBig.cs @@ -57,23 +57,23 @@ namespace CalamityMod.Projectiles.Enemy Projectile.height = 60; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 15; num621++) + for (int i = 0; i < 15; i++) { - int num622 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 8, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; + int earthyDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 8, 0f, 0f, 100, default, 1.2f); + Main.dust[earthyDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[earthyDust].scale = 0.5f; + Main.dust[earthyDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 1, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 8, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int earthyDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 1, 0f, 0f, 100, default, 1.7f); + Main.dust[earthyDust2].noGravity = true; + Main.dust[earthyDust2].velocity *= 5f; + earthyDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 8, 0f, 0f, 100, default, 1f); + Main.dust[earthyDust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) diff --git a/Projectiles/Enemy/EarthRockSmall.cs b/Projectiles/Enemy/EarthRockSmall.cs index f4104cfa59..299f26e190 100644 --- a/Projectiles/Enemy/EarthRockSmall.cs +++ b/Projectiles/Enemy/EarthRockSmall.cs @@ -35,23 +35,23 @@ namespace CalamityMod.Projectiles.Enemy Projectile.height = 50; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 8, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; + int earthyDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 8, 0f, 0f, 100, default, 1.2f); + Main.dust[earthyDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[earthyDust].scale = 0.5f; + Main.dust[earthyDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 1, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 8, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int earthyDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 1, 0f, 0f, 100, default, 1.7f); + Main.dust[earthyDust2].noGravity = true; + Main.dust[earthyDust2].velocity *= 5f; + earthyDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 8, 0f, 0f, 100, default, 1f); + Main.dust[earthyDust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) diff --git a/Projectiles/Enemy/FlameBurstHostile.cs b/Projectiles/Enemy/FlameBurstHostile.cs index 5299d1e5ab..330565f9d5 100644 --- a/Projectiles/Enemy/FlameBurstHostile.cs +++ b/Projectiles/Enemy/FlameBurstHostile.cs @@ -34,46 +34,46 @@ namespace CalamityMod.Projectiles.Enemy Projectile.height = 20; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int flameDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[flameDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[flameDust].scale = 0.5f; + Main.dust[flameDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int sparkDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 3f); + Main.dust[sparkDust].noGravity = true; + Main.dust[sparkDust].velocity *= 5f; + sparkDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); + Main.dust[sparkDust].velocity *= 2f; } count += 1f; } Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { - for (int num468 = 0; num468 < 5; num468++) + for (int k = 0; k < 5; k++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 0.75f); - Main.dust[num469].velocity *= 0f; + int sparky = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 0.75f); + Main.dust[sparky].velocity *= 0f; } } - int num103 = (int)Player.FindClosest(Projectile.Center, 1, 1); + int playerTarget = (int)Player.FindClosest(Projectile.Center, 1, 1); Projectile.ai[1] += 1f; if (Projectile.ai[1] < 200f && Projectile.ai[1] > 40f) { - float scaleFactor2 = Projectile.velocity.Length(); - Vector2 vector11 = Main.player[num103].Center - Projectile.Center; - vector11.Normalize(); - vector11 *= scaleFactor2; - Projectile.velocity = (Projectile.velocity * 24f + vector11) / 25f; + float scaleFactor = Projectile.velocity.Length(); + Vector2 playerDistance = Main.player[playerTarget].Center - Projectile.Center; + playerDistance.Normalize(); + playerDistance *= scaleFactor; + Projectile.velocity = (Projectile.velocity * 24f + playerDistance) / 25f; Projectile.velocity.Normalize(); - Projectile.velocity *= scaleFactor2; + Projectile.velocity *= scaleFactor; } if (Projectile.ai[0] < 0f) { diff --git a/Projectiles/Enemy/HorsWaterBlast.cs b/Projectiles/Enemy/HorsWaterBlast.cs index 74f98882b7..63afd6fa39 100644 --- a/Projectiles/Enemy/HorsWaterBlast.cs +++ b/Projectiles/Enemy/HorsWaterBlast.cs @@ -26,26 +26,26 @@ namespace CalamityMod.Projectiles.Enemy { if (Projectile.ai[1] == 0f) { - for (int num621 = 0; num621 < 20; num621++) + for (int i = 0; i < 20; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int waterDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 2f); + Main.dust[waterDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[waterDust].scale = 0.5f; + Main.dust[waterDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } Projectile.ai[1] = 1f; SoundEngine.PlaySound(SoundID.Item21, Projectile.position); } Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.35f / 255f); - for (int num457 = 0; num457 < 10; num457++) + for (int j = 0; j < 10; j++) { - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 1.2f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int watery = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 1.2f); + Main.dust[watery].noGravity = true; + Main.dust[watery].velocity *= 0.5f; + Main.dust[watery].velocity += Projectile.velocity * 0.1f; } } @@ -54,23 +54,23 @@ namespace CalamityMod.Projectiles.Enemy SoundEngine.PlaySound(SoundID.Item21, Projectile.position); for (int dust = 0; dust <= 40; dust++) { - float num463 = (float)Main.rand.Next(-10, 11); - float num464 = (float)Main.rand.Next(-10, 11); - float num465 = (float)Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 1.2f); - Main.dust[num467].noGravity = true; - Main.dust[num467].position.X = Projectile.Center.X; - Main.dust[num467].position.Y = Projectile.Center.Y; - Dust expr_149DF_cp_0 = Main.dust[num467]; + float rando1 = (float)Main.rand.Next(-10, 11); + float rando2 = (float)Main.rand.Next(-10, 11); + float rando3 = (float)Main.rand.Next(3, 9); + float randoAdjuster = (float)Math.Sqrt((double)(rando1 * rando1 + rando2 * rando2)); + randoAdjuster = rando3 / randoAdjuster; + rando1 *= randoAdjuster; + rando2 *= randoAdjuster; + int killWaterDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 1.2f); + Main.dust[killWaterDust].noGravity = true; + Main.dust[killWaterDust].position.X = Projectile.Center.X; + Main.dust[killWaterDust].position.Y = Projectile.Center.Y; + Dust expr_149DF_cp_0 = Main.dust[killWaterDust]; expr_149DF_cp_0.position.X += (float)Main.rand.Next(-10, 11); - Dust expr_14A09_cp_0 = Main.dust[num467]; + Dust expr_14A09_cp_0 = Main.dust[killWaterDust]; expr_14A09_cp_0.position.Y += (float)Main.rand.Next(-10, 11); - Main.dust[num467].velocity.X = num463; - Main.dust[num467].velocity.Y = num464; + Main.dust[killWaterDust].velocity.X = rando1; + Main.dust[killWaterDust].velocity.Y = rando2; } } diff --git a/Projectiles/Enemy/InkBombHostile.cs b/Projectiles/Enemy/InkBombHostile.cs index b120709e00..62983c68ea 100644 --- a/Projectiles/Enemy/InkBombHostile.cs +++ b/Projectiles/Enemy/InkBombHostile.cs @@ -56,13 +56,13 @@ namespace CalamityMod.Projectiles.Enemy SoundEngine.PlaySound(SoundID.NPCDeath28, Projectile.position); if (Projectile.owner == Main.myPlayer) { - int num320 = Main.rand.Next(5, 9); - for (int num321 = 0; num321 < num320; num321++) + int randProjAmt = Main.rand.Next(5, 9); + for (int i = 0; i < randProjAmt; i++) { - Vector2 vector15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - vector15.Normalize(); - vector15 *= Main.rand.Next(50, 401) * 0.01f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, vector15.X, vector15.Y, ModContent.ProjectileType(), (int)Math.Round(Projectile.damage * 0.165), 1f, Projectile.owner, Main.rand.Next(-45, 1)); + Vector2 randProjRotation = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + randProjRotation.Normalize(); + randProjRotation *= Main.rand.Next(50, 401) * 0.01f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, randProjRotation.X, randProjRotation.Y, ModContent.ProjectileType(), (int)Math.Round(Projectile.damage * 0.165), 1f, Projectile.owner, Main.rand.Next(-45, 1)); } } Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); @@ -71,23 +71,23 @@ namespace CalamityMod.Projectiles.Enemy Projectile.height = 60; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 54, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int inkDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 54, 0f, 0f, 100, default, 2f); + Main.dust[inkDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[inkDust].scale = 0.5f; + Main.dust[inkDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 15; num623++) + for (int j = 0; j < 15; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 109, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 109, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int inkDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 109, 0f, 0f, 100, default, 3f); + Main.dust[inkDust2].noGravity = true; + Main.dust[inkDust2].velocity *= 5f; + inkDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 109, 0f, 0f, 100, default, 2f); + Main.dust[inkDust2].velocity *= 2f; } } diff --git a/Projectiles/Enemy/PearlBurst.cs b/Projectiles/Enemy/PearlBurst.cs index 37320e5ec0..479090ce09 100644 --- a/Projectiles/Enemy/PearlBurst.cs +++ b/Projectiles/Enemy/PearlBurst.cs @@ -67,15 +67,15 @@ namespace CalamityMod.Projectiles.Enemy Projectile.localAI[0] = 0f; for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); - int num9 = Dust.NewDust(Projectile.Center, 0, 0, 92, 0f, 0f, 160, default, 1f); - Main.dust[num9].scale = 1.1f; - Main.dust[num9].noGravity = true; - Main.dust[num9].position = Projectile.Center + vector3; - Main.dust[num9].velocity = Projectile.velocity * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; + Vector2 dustRotation = Vector2.UnitX * (float)-(float)Projectile.width / 2f; + dustRotation += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); + dustRotation = dustRotation.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); + int pearlDust = Dust.NewDust(Projectile.Center, 0, 0, 92, 0f, 0f, 160, default, 1f); + Main.dust[pearlDust].scale = 1.1f; + Main.dust[pearlDust].noGravity = true; + Main.dust[pearlDust].position = Projectile.Center + dustRotation; + Main.dust[pearlDust].velocity = Projectile.velocity * 0.1f; + Main.dust[pearlDust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[pearlDust].position) * 1.25f; } } } diff --git a/Projectiles/Enemy/PufferExplosion.cs b/Projectiles/Enemy/PufferExplosion.cs index 22bf6542bc..0538e7a4b8 100644 --- a/Projectiles/Enemy/PufferExplosion.cs +++ b/Projectiles/Enemy/PufferExplosion.cs @@ -34,61 +34,61 @@ namespace CalamityMod.Projectiles.Enemy SoundEngine.PlaySound(SoundID.Item20, Projectile.position); Projectile.localAI[0] += 1f; } - bool flag15 = false; - bool flag16 = false; + bool xflag = false; + bool yflag = false; if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) { - flag16 = true; + yflag = true; } if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) { - flag16 = true; + yflag = true; } - if (flag15 && flag16) + if (xflag && yflag) { Projectile.Kill(); } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-30, 35); - float num464 = (float)Main.rand.Next(-30, 35); - float num465 = (float)Main.rand.Next(13, 18); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); - Main.dust[num467].noGravity = true; - Main.dust[num467].position.X = Projectile.Center.X; - Main.dust[num467].position.Y = Projectile.Center.Y; - Dust expr_149DF_cp_0 = Main.dust[num467]; + float rando1 = (float)Main.rand.Next(-30, 35); + float rando2 = (float)Main.rand.Next(-30, 35); + float rando3 = (float)Main.rand.Next(13, 18); + float randoAdjuster = (float)Math.Sqrt((double)(rando1 * rando1 + rando2 * rando2)); + randoAdjuster = rando3 / randoAdjuster; + rando1 *= randoAdjuster; + rando2 *= randoAdjuster; + int explodeBrimStyle = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); + Main.dust[explodeBrimStyle].noGravity = true; + Main.dust[explodeBrimStyle].position.X = Projectile.Center.X; + Main.dust[explodeBrimStyle].position.Y = Projectile.Center.Y; + Dust expr_149DF_cp_0 = Main.dust[explodeBrimStyle]; expr_149DF_cp_0.position.X += (float)Main.rand.Next(-10, 11); - Dust expr_14A09_cp_0 = Main.dust[num467]; + Dust expr_14A09_cp_0 = Main.dust[explodeBrimStyle]; expr_14A09_cp_0.position.Y += (float)Main.rand.Next(-10, 11); - Main.dust[num467].velocity.X = num463; - Main.dust[num467].velocity.Y = num464; - num462++; + Main.dust[explodeBrimStyle].velocity.X = rando1; + Main.dust[explodeBrimStyle].velocity.Y = rando2; + timerCounter++; } } } diff --git a/Projectiles/Enemy/StormMarkHostile.cs b/Projectiles/Enemy/StormMarkHostile.cs index 0a4e988b8c..21b06efcf0 100644 --- a/Projectiles/Enemy/StormMarkHostile.cs +++ b/Projectiles/Enemy/StormMarkHostile.cs @@ -34,34 +34,34 @@ namespace CalamityMod.Projectiles.Enemy if (Projectile.localAI[1] < 30f) { int totalDust = Projectile.ai[0] != 0f ? 2 : 1; - for (int num1134 = 0; num1134 < totalDust; num1134++) + for (int i = 0; i < totalDust; i++) { - float value79 = -0.5f; - float value80 = 0.9f; - float amount4 = Main.rand.NextFloat(); - Vector2 value81 = new Vector2(MathHelper.Lerp(0.1f, 1f, Main.rand.NextFloat()), MathHelper.Lerp(value79, value80, amount4)); - value81.X *= MathHelper.Lerp(2.2f, 0.6f, amount4); - value81.X *= -1f; - Vector2 value82 = new Vector2(2f, 10f); - Vector2 position4 = Projectile.Center + new Vector2(60f, Projectile.ai[0] != 0f ? 800f : 200f) * value81 * 0.5f + value82; - Dust dust34 = Main.dust[Dust.NewDust(position4, 0, 0, 16, 0f, 0f, 0, default, 0.5f)]; - dust34.position = position4; - dust34.customData = Projectile.Center + value82; - dust34.fadeIn = 1f; - dust34.scale = 0.3f; - if (value81.X > -1.2f) + float lerpvalue = -0.5f; + float lerpvalue2 = 0.9f; + float randomLerp = Main.rand.NextFloat(); + Vector2 dustMovement = new Vector2(MathHelper.Lerp(0.1f, 1f, Main.rand.NextFloat()), MathHelper.Lerp(lerpvalue, lerpvalue2, randomLerp)); + dustMovement.X *= MathHelper.Lerp(2.2f, 0.6f, randomLerp); + dustMovement.X *= -1f; + Vector2 dustMovement2 = new Vector2(2f, 10f); + Vector2 position4 = Projectile.Center + new Vector2(60f, Projectile.ai[0] != 0f ? 800f : 200f) * dustMovement * 0.5f + dustMovement2; + Dust stormy = Main.dust[Dust.NewDust(position4, 0, 0, 16, 0f, 0f, 0, default, 0.5f)]; + stormy.position = position4; + stormy.customData = Projectile.Center + dustMovement2; + stormy.fadeIn = 1f; + stormy.scale = 0.3f; + if (dustMovement.X > -1.2f) { - dust34.velocity.X = 1f + Main.rand.NextFloat(); + stormy.velocity.X = 1f + Main.rand.NextFloat(); } - dust34.velocity.Y = Main.rand.NextFloat() * -0.5f - 1f; + stormy.velocity.Y = Main.rand.NextFloat() * -0.5f - 1f; } } if (Projectile.localAI[0] == 0f) { Projectile.localAI[0] = 0.8f; Projectile.direction = 1; - Point point9 = Projectile.Center.ToTileCoordinates(); - Projectile.Center = new Vector2((float)(point9.X * 16 + 8), (float)(point9.Y * 16 + 8)); + Point projCenter = Projectile.Center.ToTileCoordinates(); + Projectile.Center = new Vector2((float)(projCenter.X * 16 + 8), (float)(projCenter.Y * 16 + 8)); } Projectile.rotation = Projectile.localAI[1] / 40f * 6.28318548f * (float)Projectile.direction; if (Projectile.localAI[1] < 33f) @@ -90,30 +90,30 @@ namespace CalamityMod.Projectiles.Enemy { Lighting.AddLight(Projectile.Center, newColor3.ToVector3() * 0.5f); } - for (int num1135 = 0; num1135 < 2; num1135++) + for (int j = 0; j < 2; j++) { if (Main.rand.NextBool(10)) { - Vector2 value83 = Vector2.UnitY.RotatedBy((double)((float)num1135 * 3.14159274f), default).RotatedBy((double)Projectile.rotation, default); - Dust dust35 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 16, 0f, 0f, 225, newColor3, 1f)]; - dust35.noGravity = true; - dust35.noLight = true; - dust35.scale = Projectile.Opacity * Projectile.localAI[0]; - dust35.position = Projectile.Center; - dust35.velocity = value83 * 2.5f; + Vector2 dustVel = Vector2.UnitY.RotatedBy((double)((float)j * 3.14159274f), default).RotatedBy((double)Projectile.rotation, default); + Dust stormDust = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 16, 0f, 0f, 225, newColor3, 1f)]; + stormDust.noGravity = true; + stormDust.noLight = true; + stormDust.scale = Projectile.Opacity * Projectile.localAI[0]; + stormDust.position = Projectile.Center; + stormDust.velocity = dustVel * 2.5f; } } - for (int num1136 = 0; num1136 < 2; num1136++) + for (int k = 0; k < 2; k++) { if (Main.rand.NextBool(10)) { - Vector2 value84 = Vector2.UnitY.RotatedBy((double)((float)num1136 * 3.14159274f), default); - Dust dust36 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 16, 0f, 0f, 225, newColor3, 1.5f)]; - dust36.noGravity = true; - dust36.noLight = true; - dust36.scale = Projectile.Opacity * Projectile.localAI[0]; - dust36.position = Projectile.Center; - dust36.velocity = value84 * 2.5f; + Vector2 dustVel2 = Vector2.UnitY.RotatedBy((double)((float)k * 3.14159274f), default); + Dust stormDust2 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 16, 0f, 0f, 225, newColor3, 1.5f)]; + stormDust2.noGravity = true; + stormDust2.noLight = true; + stormDust2.scale = Projectile.Opacity * Projectile.localAI[0]; + stormDust2.position = Projectile.Center; + stormDust2.velocity = dustVel2 * 2.5f; } } if (Projectile.localAI[1] < 33f || Projectile.localAI[1] > 87f) @@ -135,16 +135,16 @@ namespace CalamityMod.Projectiles.Enemy public override bool PreDraw(ref Color lightColor) { - Color color25 = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); - Vector2 vector38 = Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; + Color originalColor = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); + Vector2 drawPos = Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; Texture2D texture2D27 = ModContent.Request(Texture).Value; - Rectangle rectangle11 = texture2D27.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); - Color alpha5 = Projectile.GetAlpha(color25); - Vector2 origin7 = rectangle11.Size() / 2f; - Color color47 = Main.hslToRgb(0.25f, 1f, 1f).MultiplyRGBA(new Color(255, 255, 255, 0)); - Main.spriteBatch.Draw(texture2D27, vector38, new Microsoft.Xna.Framework.Rectangle?(rectangle11), color47, 0f, origin7, new Vector2(1f, 5f) * Projectile.scale * 2f, SpriteEffects.None, 0); - Main.spriteBatch.Draw(texture2D27, vector38, new Microsoft.Xna.Framework.Rectangle?(rectangle11), alpha5, Projectile.rotation, origin7, Projectile.scale, SpriteEffects.None, 0); - Main.spriteBatch.Draw(texture2D27, vector38, new Microsoft.Xna.Framework.Rectangle?(rectangle11), alpha5, 0f, origin7, new Vector2(1f, 8f) * Projectile.scale, SpriteEffects.None, 0); + Rectangle rectangl = texture2D27.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); + Color alphaColor = Projectile.GetAlpha(originalColor); + Vector2 halfRect = rectangl.Size() / 2f; + Color whiteColor = Main.hslToRgb(0.25f, 1f, 1f).MultiplyRGBA(new Color(255, 255, 255, 0)); + Main.spriteBatch.Draw(texture2D27, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangl), whiteColor, 0f, halfRect, new Vector2(1f, 5f) * Projectile.scale * 2f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(texture2D27, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangl), alphaColor, Projectile.rotation, halfRect, Projectile.scale, SpriteEffects.None, 0); + Main.spriteBatch.Draw(texture2D27, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangl), alphaColor, 0f, halfRect, new Vector2(1f, 8f) * Projectile.scale, SpriteEffects.None, 0); return false; } } diff --git a/Projectiles/Enemy/SulphuricAcidBubble.cs b/Projectiles/Enemy/SulphuricAcidBubble.cs index 10dd5292e6..acc97e0f35 100644 --- a/Projectiles/Enemy/SulphuricAcidBubble.cs +++ b/Projectiles/Enemy/SulphuricAcidBubble.cs @@ -86,12 +86,12 @@ namespace CalamityMod.Projectiles.Enemy public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; lightColor.R = (byte)(255 * Projectile.Opacity); lightColor.G = (byte)(255 * Projectile.Opacity); lightColor.B = (byte)(255 * Projectile.Opacity); - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } @@ -113,15 +113,15 @@ namespace CalamityMod.Projectiles.Enemy Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num246 = 0; num246 < 25; num246++) + for (int i = 0; i < 25; i++) { - int num247 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 0, default, 1f); - Main.dust[num247].position = (Main.dust[num247].position + Projectile.position) / 2f; - Main.dust[num247].velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - Main.dust[num247].velocity.Normalize(); - Dust dust = Main.dust[num247]; + int toxicDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 0, default, 1f); + Main.dust[toxicDust].position = (Main.dust[toxicDust].position + Projectile.position) / 2f; + Main.dust[toxicDust].velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + Main.dust[toxicDust].velocity.Normalize(); + Dust dust = Main.dust[toxicDust]; dust.velocity *= (float)Main.rand.Next(1, 30) * 0.1f; - Main.dust[num247].alpha = 255 - (int)(Projectile.Opacity * 255f); + Main.dust[toxicDust].alpha = 255 - (int)(Projectile.Opacity * 255f); } } } diff --git a/Projectiles/Enemy/TornadoHostile.cs b/Projectiles/Enemy/TornadoHostile.cs index ef78d90a71..61def509db 100644 --- a/Projectiles/Enemy/TornadoHostile.cs +++ b/Projectiles/Enemy/TornadoHostile.cs @@ -28,76 +28,74 @@ namespace CalamityMod.Projectiles.Enemy public override void AI() { - float num1125 = Projectile.ai[1] == 1f ? 900f : 600f; + float projTimer = Projectile.ai[1] == 1f ? 900f : 600f; if (Projectile.soundDelay == 0) { Projectile.soundDelay = -1; SoundEngine.PlaySound(SoundID.Item122, Projectile.position); } Projectile.ai[0] += 1f; - if (Projectile.ai[0] >= num1125) + if (Projectile.ai[0] >= projTimer) { Projectile.Kill(); } - float num1127 = Projectile.ai[1] == 1f ? 90f : 15f; - float num1128 = Projectile.ai[1] == 1f ? 90f : 15f; - Point point8 = Projectile.Center.ToTileCoordinates(); - int num1129; - int num1130; - Collision.ExpandVertically(point8.X, point8.Y, out num1129, out num1130, (int)num1127, (int)num1128); - num1129++; - num1130--; - Vector2 value72 = new Vector2((float)point8.X, (float)num1129) * 16f + new Vector2(8f); - Vector2 value73 = new Vector2((float)point8.X, (float)num1130) * 16f + new Vector2(8f); - Vector2 vector146 = Vector2.Lerp(value72, value73, 0.5f); - Vector2 value74 = new Vector2(0f, value73.Y - value72.Y); - value74.X = value74.Y * 0.2f; - Projectile.width = (int)(value74.X * (Projectile.ai[1] == 1f ? 0.167f : 0.65f)); - Projectile.height = (int)value74.Y; - Projectile.Center = vector146; + float expandSizeX = Projectile.ai[1] == 1f ? 90f : 15f; + float expandSizeY = Projectile.ai[1] == 1f ? 90f : 15f; + Point projCenterTile = Projectile.Center.ToTileCoordinates(); + int sizeMod; + int sizeMod2; + Collision.ExpandVertically(projCenterTile.X, projCenterTile.Y, out sizeMod, out sizeMod2, (int)expandSizeX, (int)expandSizeY); + sizeMod++; + sizeMod2--; + Vector2 sizeModVector = new Vector2((float)projCenterTile.X, (float)sizeMod) * 16f + new Vector2(8f); + Vector2 sizeModVector2 = new Vector2((float)projCenterTile.X, (float)sizeMod2) * 16f + new Vector2(8f); + Vector2 centering = Vector2.Lerp(sizeModVector, sizeModVector2, 0.5f); + Vector2 sizeModPos = new Vector2(0f, sizeModVector2.Y - sizeModVector.Y); + sizeModPos.X = sizeModPos.Y * 0.2f; + Projectile.width = (int)(sizeModPos.X * (Projectile.ai[1] == 1f ? 0.167f : 0.65f)); + Projectile.height = (int)sizeModPos.Y; + Projectile.Center = centering; if (Projectile.owner == Main.myPlayer) { - bool flag74 = false; - Vector2 center16 = Main.player[Projectile.owner].Center; + bool breakFlag = false; + Vector2 playerCenter = Main.player[Projectile.owner].Center; Vector2 top = Main.player[Projectile.owner].Top; - for (float num1131 = 0f; num1131 < 1f; num1131 += 0.05f) + for (float i = 0f; i < 1f; i += 0.05f) { - Vector2 position2 = Vector2.Lerp(value72, value73, num1131); - if (Collision.CanHitLine(position2, 0, 0, center16, 0, 0) || Collision.CanHitLine(position2, 0, 0, top, 0, 0)) + Vector2 position2 = Vector2.Lerp(sizeModVector, sizeModVector2, i); + if (Collision.CanHitLine(position2, 0, 0, playerCenter, 0, 0) || Collision.CanHitLine(position2, 0, 0, top, 0, 0)) { - flag74 = true; + breakFlag = true; break; } } - if (!flag74 && Projectile.ai[0] < num1125 - 120f) + if (!breakFlag && Projectile.ai[0] < projTimer - 120f) { - float num1132 = Projectile.ai[0] % 60f; - Projectile.ai[0] = num1125 - 120f + num1132; + float aiDecrement = Projectile.ai[0] % 60f; + Projectile.ai[0] = projTimer - 120f + aiDecrement; Projectile.netUpdate = true; } } - if (Projectile.ai[0] < num1125 - 120f) + if (Projectile.ai[0] < projTimer - 120f) { - for (int num1133 = 0; num1133 < 1; num1133++) + for (int j = 0; j < 1; j++) { - float value75 = -0.5f; - float value76 = 0.9f; - float amount3 = Main.rand.NextFloat(); - Vector2 value77 = new Vector2(MathHelper.Lerp(0.1f, 1f, Main.rand.NextFloat()), MathHelper.Lerp(value75, value76, amount3)); - value77.X *= MathHelper.Lerp(2.2f, 0.6f, amount3); - value77.X *= -1f; - Vector2 value78 = new Vector2(6f, 10f); - Vector2 position3 = vector146 + value74 * value77 * 0.5f + value78; - Dust dust33 = Main.dust[Dust.NewDust(position3, 0, 0, 16, 0f, 0f, 0, default, 1.5f)]; - dust33.position = position3; - dust33.customData = vector146 + value78; - dust33.fadeIn = 1f; - dust33.scale = 0.3f; - if (value77.X > -1.2f) + float lerpRandomizer = Main.rand.NextFloat(); + Vector2 dustVelocity = new Vector2(MathHelper.Lerp(0.1f, 1f, Main.rand.NextFloat()), MathHelper.Lerp(-0.5f, 0.9f, lerpRandomizer)); + dustVelocity.X *= MathHelper.Lerp(2.2f, 0.6f, lerpRandomizer); + dustVelocity.X *= -1f; + Vector2 dustCustomData = new Vector2(6f, 10f); + Vector2 dustPosition = centering + sizeModPos * dustVelocity * 0.5f + dustCustomData; + Dust cloudDust = Main.dust[Dust.NewDust(dustPosition, 0, 0, 16, 0f, 0f, 0, default, 1.5f)]; + cloudDust.position = dustPosition; + cloudDust.customData = centering + dustCustomData; + cloudDust.fadeIn = 1f; + cloudDust.scale = 0.3f; + if (dustVelocity.X > -1.2f) { - dust33.velocity.X = 1f + Main.rand.NextFloat(); + cloudDust.velocity.X = 1f + Main.rand.NextFloat(); } - dust33.velocity.Y = Main.rand.NextFloat() * -0.5f - 1f; + cloudDust.velocity.Y = Main.rand.NextFloat() * -0.5f - 1f; } } } @@ -106,57 +104,57 @@ namespace CalamityMod.Projectiles.Enemy public override bool PreDraw(ref Color lightColor) { - float num226 = Projectile.ai[1] == 1f ? 900f : 600f; - float num227 = Projectile.ai[1] == 1f ? 90f : 15f; - float num228 = Projectile.ai[1] == 1f ? 90f : 15f; - float num229 = Projectile.ai[0]; - float scale5 = MathHelper.Clamp(num229 / 30f, 0f, 1f); - if (num229 > num226 - 60f) + float aiTrackCheck = Projectile.ai[1] == 1f ? 900f : 600f; + float expandSizeX2 = Projectile.ai[1] == 1f ? 90f : 15f; + float expandSizeY2 = Projectile.ai[1] == 1f ? 90f : 15f; + float aiTracker = Projectile.ai[0]; + float trackerClamp = MathHelper.Clamp(aiTracker / 30f, 0f, 1f); + if (aiTracker > aiTrackCheck - 60f) { - scale5 = MathHelper.Lerp(1f, 0f, (num229 - (num226 - 60f)) / 60f); + trackerClamp = MathHelper.Lerp(1f, 0f, (aiTracker - (aiTrackCheck - 60f)) / 60f); } - Point point5 = Projectile.Center.ToTileCoordinates(); - int num230; - int num231; - Collision.ExpandVertically(point5.X, point5.Y, out num230, out num231, (int)num227, (int)num228); - num230++; - num231--; - float num232 = 0.2f; - Vector2 value32 = new Vector2((float)point5.X, (float)num230) * 16f + new Vector2(8f); - Vector2 value33 = new Vector2((float)point5.X, (float)num231) * 16f + new Vector2(8f); - Vector2.Lerp(value32, value33, 0.5f); - Vector2 vector33 = new Vector2(0f, value33.Y - value32.Y); - vector33.X = vector33.Y * num232; - new Vector2(value32.X - vector33.X / 2f, value32.Y); + Point centerPoint = Projectile.Center.ToTileCoordinates(); + int sizeModding; + int sizeModding2; + Collision.ExpandVertically(centerPoint.X, centerPoint.Y, out sizeModding, out sizeModding2, (int)expandSizeX2, (int)expandSizeY2); + sizeModding++; + sizeModding2--; + float vectorMult = 0.2f; + Vector2 sizeModdingVector = new Vector2((float)centerPoint.X, (float)sizeModding) * 16f + new Vector2(8f); + Vector2 sizeModdingVector2 = new Vector2((float)centerPoint.X, (float)sizeModding2) * 16f + new Vector2(8f); + Vector2.Lerp(sizeModdingVector, sizeModdingVector2, 0.5f); + Vector2 sizeModdingPos = new Vector2(0f, sizeModdingVector2.Y - sizeModdingVector.Y); + sizeModdingPos.X = sizeModdingPos.Y * vectorMult; + new Vector2(sizeModdingVector.X - sizeModdingPos.X / 2f, sizeModdingVector.Y); Texture2D texture2D23 = ModContent.Request(Texture).Value; - Rectangle rectangle9 = texture2D23.Frame(1, 1, 0, 0); - Vector2 origin3 = rectangle9.Size() / 2f; - float num233 = -0.06283186f * num229; - Vector2 spinningpoint2 = Vector2.UnitY.RotatedBy((double)(num229 * 0.1f), default); - float num234 = 0f; - float num235 = 5.1f; - Color value34 = new Color(225, 225, 225); - for (float num236 = (float)(int)value33.Y; num236 > (float)(int)value32.Y; num236 -= num235) + Rectangle drawRectangle = texture2D23.Frame(1, 1, 0, 0); + Vector2 smallRect = drawRectangle.Size() / 2f; + float aiTrackMult = -0.06283186f * aiTracker; + Vector2 spinningpoint2 = Vector2.UnitY.RotatedBy((double)(aiTracker * 0.1f), default); + float incrementStorage = 0f; + float increment = 5.1f; + Color cloudColor = new Color(225, 225, 225); + for (float k = (float)(int)sizeModdingVector2.Y; k > (float)(int)sizeModdingVector.Y; k -= increment) { - num234 += num235; - float num237 = num234 / vector33.Y; - float num238 = num234 * 6.28318548f / -20f; - float num239 = num237 - 0.15f; - Vector2 vector34 = spinningpoint2.RotatedBy((double)num238, default); - Vector2 value35 = new Vector2(0f, num237 + 1f); - value35.X = value35.Y * num232; - Color color39 = Color.Lerp(Color.Transparent, value34, num237 * 2f); - if (num237 > 0.5f) + incrementStorage += increment; + float colorChanger = incrementStorage / sizeModdingPos.Y; + float incStorageMult = incrementStorage * 6.28318548f / -20f; + float lowerColorChanger = colorChanger - 0.15f; + Vector2 spinArea = spinningpoint2.RotatedBy((double)incStorageMult, default); + Vector2 colorChangeVector = new Vector2(0f, colorChanger + 1f); + colorChangeVector.X = colorChangeVector.Y * vectorMult; + Color newCloudColor = Color.Lerp(Color.Transparent, cloudColor, colorChanger * 2f); + if (colorChanger > 0.5f) { - color39 = Color.Lerp(Color.Transparent, value34, 2f - num237 * 2f); + newCloudColor = Color.Lerp(Color.Transparent, cloudColor, 2f - colorChanger * 2f); } - color39.A = (byte)((float)color39.A * 0.5f); - color39 *= scale5; - vector34 *= value35 * 100f; - vector34.Y = 0f; - vector34.X = 0f; - vector34 += new Vector2(value33.X, num236) - Main.screenPosition; - Main.spriteBatch.Draw(texture2D23, vector34, new Microsoft.Xna.Framework.Rectangle?(rectangle9), color39, num233 + num238, origin3, 1f + num239, SpriteEffects.None, 0); + newCloudColor.A = (byte)((float)newCloudColor.A * 0.5f); + newCloudColor *= trackerClamp; + spinArea *= colorChangeVector * 100f; + spinArea.Y = 0f; + spinArea.X = 0f; + spinArea += new Vector2(sizeModdingVector2.X, k) - Main.screenPosition; + Main.spriteBatch.Draw(texture2D23, spinArea, new Microsoft.Xna.Framework.Rectangle?(drawRectangle), newCloudColor, aiTrackMult + incStorageMult, smallRect, 1f + lowerColorChanger, SpriteEffects.None, 0); } return false; } diff --git a/Projectiles/Environment/BrimstoneGeyser.cs b/Projectiles/Environment/BrimstoneGeyser.cs index 16f793ac1d..1de3662158 100644 --- a/Projectiles/Environment/BrimstoneGeyser.cs +++ b/Projectiles/Environment/BrimstoneGeyser.cs @@ -29,11 +29,11 @@ namespace CalamityMod.Projectiles.Environment public override void AI() { - int num1 = Math.Sign(Projectile.velocity.Y); - int num2 = num1 == -1 ? 0 : 1; + int isActive = Math.Sign(Projectile.velocity.Y); + int dustCustomData = isActive == -1 ? 0 : 1; if (Projectile.ai[0] == 0f) { - if (!Collision.SolidCollision(Projectile.position + new Vector2(0f, num1 == -1 ? (float) (Projectile.height - 48) : 0f), Projectile.width, 48) && !Collision.WetCollision(Projectile.position + new Vector2(0f, num1 == -1 ? (float) (Projectile.height - 20) : 0f), Projectile.width, 20)) + if (!Collision.SolidCollision(Projectile.position + new Vector2(0f, isActive == -1 ? (float) (Projectile.height - 48) : 0f), Projectile.width, 48) && !Collision.WetCollision(Projectile.position + new Vector2(0f, isActive == -1 ? (float) (Projectile.height - 20) : 0f), Projectile.width, 20)) { Projectile.velocity = new Vector2(0f, (float) Math.Sign(Projectile.velocity.Y) * (1f / 1000f)); Projectile.ai[0] = 1f; @@ -45,13 +45,13 @@ namespace CalamityMod.Projectiles.Environment if (Projectile.ai[1] >= 60f) Projectile.Kill(); - for (int index1 = 0; index1 < 3; ++index1) + for (int i = 0; i < 3; ++i) { - int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 100, new Color(), 1f); - Main.dust[index2].scale = 0.1f + Main.rand.Next(5) * 0.1f; - Main.dust[index2].fadeIn = 1.5f + Main.rand.Next(5) * 0.1f; - Main.dust[index2].noGravity = true; - Main.dust[index2].position = Projectile.Center + new Vector2(0f, (float) (-Projectile.height / 2)).RotatedBy((double)Projectile.rotation, new Vector2()) * 1.1f; + int brimDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 100, new Color(), 1f); + Main.dust[brimDust].scale = 0.1f + Main.rand.Next(5) * 0.1f; + Main.dust[brimDust].fadeIn = 1.5f + Main.rand.Next(5) * 0.1f; + Main.dust[brimDust].noGravity = true; + Main.dust[brimDust].position = Projectile.Center + new Vector2(0f, (float) (-Projectile.height / 2)).RotatedBy((double)Projectile.rotation, new Vector2()) * 1.1f; } } @@ -60,21 +60,21 @@ namespace CalamityMod.Projectiles.Environment Projectile.velocity = new Vector2(0f, (float) Math.Sign(Projectile.velocity.Y) * (1f / 1000f)); - if (num1 != 0) + if (isActive != 0) { - int num3 = 16; - int num4 = 320; - while (num3 < num4 && !Collision.SolidCollision(Projectile.position + new Vector2(0f, num1 == -1 ? (float)(Projectile.height - num3 - 16) : 0f), Projectile.width, num3 + 16)) - num3 += 16; + int heightIncrease = 16; + int maxHeight = 320; + while (heightIncrease < maxHeight && !Collision.SolidCollision(Projectile.position + new Vector2(0f, isActive == -1 ? (float)(Projectile.height - heightIncrease - 16) : 0f), Projectile.width, heightIncrease + 16)) + heightIncrease += 16; - if (num1 == -1) + if (isActive == -1) { Projectile.position.Y += (float)Projectile.height; - Projectile.height = num3; - Projectile.position.Y -= (float)num3; + Projectile.height = heightIncrease; + Projectile.position.Y -= (float)heightIncrease; } else - Projectile.height = num3; + Projectile.height = heightIncrease; } Projectile.ai[1] += 1f; @@ -84,52 +84,52 @@ namespace CalamityMod.Projectiles.Environment if (Projectile.localAI[0] == 0f) { Projectile.localAI[0] = 1f; - for (int index1 = 0; index1 < 60; ++index1) + for (int i = 0; i < 60; ++i) { - int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, -2.5f * (float) -num1, 0, new Color(), 1f); - Dust dust = Main.dust[index2]; + int brimDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, -2.5f * (float) -isActive, 0, new Color(), 1f); + Dust dust = Main.dust[brimDust]; dust.alpha = 200; dust.velocity *= new Vector2(0.3f, 2f); - dust.velocity.Y += (float)(2 * num1); + dust.velocity.Y += (float)(2 * isActive); dust.scale += Main.rand.NextFloat(); - dust.position = new Vector2(Projectile.Center.X, Projectile.Center.Y + (float) Projectile.height * 0.5f * (float) -num1); - dust.customData = (object) num2; - if (num1 == -1 && Main.rand.Next(4) != 0) + dust.position = new Vector2(Projectile.Center.X, Projectile.Center.Y + (float) Projectile.height * 0.5f * (float) -isActive); + dust.customData = (object) dustCustomData; + if (isActive == -1 && Main.rand.Next(4) != 0) { dust.velocity.Y -= 0.2f; } } SoundEngine.PlaySound(SoundID.Item34, Projectile.position); } - if (num1 == 1) + if (isActive == 1) { - for (int index1 = 0; index1 < 9; ++index1) + for (int i = 0; i < 9; ++i) { - int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, -2.5f * (float) -num1, 0, new Color(), 1f); - Dust dust = Main.dust[index2]; + int brimDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, -2.5f * (float) -isActive, 0, new Color(), 1f); + Dust dust = Main.dust[brimDust]; dust.alpha = 200; dust.velocity *= new Vector2(0.3f, 2f); - dust.velocity.Y += (float)(2 * num1); + dust.velocity.Y += (float)(2 * isActive); dust.scale += Main.rand.NextFloat(); - dust.position = new Vector2(Projectile.Center.X, Projectile.Center.Y + (float) Projectile.height * 0.5f * (float) -num1); - dust.customData = (object)num2; - if (num1 == -1 && Main.rand.Next(4) != 0) + dust.position = new Vector2(Projectile.Center.X, Projectile.Center.Y + (float) Projectile.height * 0.5f * (float) -isActive); + dust.customData = (object)dustCustomData; + if (isActive == -1 && Main.rand.Next(4) != 0) { - Main.dust[index2].velocity.Y -= 0.2f; + Main.dust[brimDust].velocity.Y -= 0.2f; } } } int Height = (int)(Projectile.ai[1] / 60f * (float)Projectile.height) * 3; if (Height > Projectile.height) Height = Projectile.height; - Vector2 Position = Projectile.position + (num1 == -1 ? new Vector2(0f, (float) (Projectile.height - Height)) : Vector2.Zero); - Vector2 vector2 = Projectile.position + (num1 == -1 ? new Vector2(0f, (float) Projectile.height) : Vector2.Zero); - for (int index1 = 0; index1 < 6; ++index1) + Vector2 Position = Projectile.position + (isActive == -1 ? new Vector2(0f, (float) (Projectile.height - Height)) : Vector2.Zero); + Vector2 vector2 = Projectile.position + (isActive == -1 ? new Vector2(0f, (float) Projectile.height) : Vector2.Zero); + for (int i = 0; i < 6; ++i) { if (Main.rand.Next(3) < 2) { - int index2 = Dust.NewDust(Position, Projectile.width, Height, dustType, 0f, 0f, 90, new Color(), 2.5f); - Dust dust = Main.dust[index2]; + int brimDust = Dust.NewDust(Position, Projectile.width, Height, dustType, 0f, 0f, 90, new Color(), 2.5f); + Dust dust = Main.dust[brimDust]; dust.noGravity = true; dust.fadeIn = 1f; if (dust.velocity.Y > 0f) @@ -148,25 +148,25 @@ namespace CalamityMod.Projectiles.Environment dust.scale *= 0.3f; } else - Main.dust[index2].velocity = Projectile.DirectionFrom(Main.dust[index2].position) * Main.dust[index2].velocity.Length() * 0.25f; - Main.dust[index2].velocity.Y *= (float)-num1; - Main.dust[index2].customData = (object)num2; + Main.dust[brimDust].velocity = Projectile.DirectionFrom(Main.dust[brimDust].position) * Main.dust[brimDust].velocity.Length() * 0.25f; + Main.dust[brimDust].velocity.Y *= (float)-isActive; + Main.dust[brimDust].customData = (object)dustCustomData; } } - for (int index1 = 0; index1 < 6; ++index1) + for (int i = 0; i < 6; ++i) { if (Main.rand.NextFloat() >= 0.5f) { - int index2 = Dust.NewDust(Position, Projectile.width, Height, dustType, 0f, -2.5f * (float) -num1, 0, new Color(), 1f); - Dust dust = Main.dust[index2]; + int brimDust = Dust.NewDust(Position, Projectile.width, Height, dustType, 0f, -2.5f * (float) -isActive, 0, new Color(), 1f); + Dust dust = Main.dust[brimDust]; dust.alpha = 200; dust.velocity *= new Vector2(0.6f, 1.5f); dust.scale += Main.rand.NextFloat(); - if (num1 == -1 && Main.rand.Next(4) != 0) + if (isActive == -1 && Main.rand.Next(4) != 0) { dust.velocity.Y -= 0.2f; } - dust.customData = (object)num2; + dust.customData = (object)dustCustomData; } } } diff --git a/Projectiles/Environment/LavaChunk.cs b/Projectiles/Environment/LavaChunk.cs index beb37b7f2a..95ee91bc2d 100644 --- a/Projectiles/Environment/LavaChunk.cs +++ b/Projectiles/Environment/LavaChunk.cs @@ -46,20 +46,20 @@ namespace CalamityMod.Projectiles.Environment } if (Projectile.scale > 0.25f) { - for (int num246 = 0; num246 < 2; num246++) + for (int i = 0; i < 2; i++) { - float num248 = 0f; - if (num246 == 1) + float dustYOffset = 0f; + if (i == 1) { - num248 = Projectile.velocity.Y * 0.5f; + dustYOffset = Projectile.velocity.Y * 0.5f; } - int num249 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 6, 0f, 0f, 100, default, Projectile.scale); - Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - num249 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 31, 0f, 0f, 100, default, Projectile.scale * 0.5f); - Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num249].velocity *= 0.05f; + int lavaDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 3f + dustYOffset) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 6, 0f, 0f, 100, default, Projectile.scale); + Main.dust[lavaDust].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[lavaDust].velocity *= 0.2f; + Main.dust[lavaDust].noGravity = true; + lavaDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 3f + dustYOffset) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 31, 0f, 0f, 100, default, Projectile.scale * 0.5f); + Main.dust[lavaDust].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[lavaDust].velocity *= 0.05f; } } else @@ -86,9 +86,9 @@ namespace CalamityMod.Projectiles.Environment public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } } diff --git a/Projectiles/Environment/SmokeTelegraph.cs b/Projectiles/Environment/SmokeTelegraph.cs index a14193c9e5..9d214531f1 100644 --- a/Projectiles/Environment/SmokeTelegraph.cs +++ b/Projectiles/Environment/SmokeTelegraph.cs @@ -27,11 +27,11 @@ namespace CalamityMod.Projectiles.Environment public override void AI() { - int num1 = Math.Sign(Projectile.velocity.Y); - int num2 = num1 == -1 ? 0 : 1; + int isActive = Math.Sign(Projectile.velocity.Y); + int dustCustomData = isActive == -1 ? 0 : 1; if (Projectile.ai[0] == 0f) { - if (!Collision.SolidCollision(Projectile.position + new Vector2(0f, num1 == -1 ? (float) (Projectile.height - 48) : 0f), Projectile.width, 48) && !Collision.WetCollision(Projectile.position + new Vector2(0f, num1 == -1 ? (float) (Projectile.height - 20) : 0f), Projectile.width, 20)) + if (!Collision.SolidCollision(Projectile.position + new Vector2(0f, isActive == -1 ? (float) (Projectile.height - 48) : 0f), Projectile.width, 48) && !Collision.WetCollision(Projectile.position + new Vector2(0f, isActive == -1 ? (float) (Projectile.height - 20) : 0f), Projectile.width, 20)) { Projectile.velocity = new Vector2(0f, (float) Math.Sign(Projectile.velocity.Y) * (1f / 1000f)); Projectile.ai[0] = 1f; @@ -43,13 +43,13 @@ namespace CalamityMod.Projectiles.Environment if (Projectile.ai[1] >= 60f) Projectile.Kill(); - for (int index1 = 0; index1 < 3; ++index1) + for (int i = 0; i < 3; ++i) { - int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 100, new Color(), 1f); - Main.dust[index2].scale = 0.1f + Main.rand.Next(5) * 0.1f; - Main.dust[index2].fadeIn = 1.5f + Main.rand.Next(5) * 0.1f; - Main.dust[index2].noGravity = true; - Main.dust[index2].position = Projectile.Center + new Vector2(0f, (float) (-Projectile.height / 2)).RotatedBy((double)Projectile.rotation, new Vector2()) * 1.1f; + int smoky = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 100, new Color(), 1f); + Main.dust[smoky].scale = 0.1f + Main.rand.Next(5) * 0.1f; + Main.dust[smoky].fadeIn = 1.5f + Main.rand.Next(5) * 0.1f; + Main.dust[smoky].noGravity = true; + Main.dust[smoky].position = Projectile.Center + new Vector2(0f, (float) (-Projectile.height / 2)).RotatedBy((double)Projectile.rotation, new Vector2()) * 1.1f; } } @@ -58,21 +58,21 @@ namespace CalamityMod.Projectiles.Environment Projectile.velocity = new Vector2(0f, (float) Math.Sign(Projectile.velocity.Y) * (1f / 1000f)); - if (num1 != 0) + if (isActive != 0) { - int num3 = 16; - int num4 = 320; - while (num3 < num4 && !Collision.SolidCollision(Projectile.position + new Vector2(0f, num1 == -1 ? (float)(Projectile.height - num3 - 16) : 0f), Projectile.width, num3 + 16)) - num3 += 16; + int heightIncrease = 16; + int maxHeight = 320; + while (heightIncrease < maxHeight && !Collision.SolidCollision(Projectile.position + new Vector2(0f, isActive == -1 ? (float)(Projectile.height - heightIncrease - 16) : 0f), Projectile.width, heightIncrease + 16)) + heightIncrease += 16; - if (num1 == -1) + if (isActive == -1) { Projectile.position.Y += (float)Projectile.height; - Projectile.height = num3; - Projectile.position.Y -= (float)num3; + Projectile.height = heightIncrease; + Projectile.position.Y -= (float)heightIncrease; } else - Projectile.height = num3; + Projectile.height = heightIncrease; } Projectile.ai[1] += 1f; @@ -82,52 +82,52 @@ namespace CalamityMod.Projectiles.Environment if (Projectile.localAI[0] == 0f) { Projectile.localAI[0] = 1f; - for (int index1 = 0; index1 < 60; ++index1) + for (int i = 0; i < 60; ++i) { - int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, -2.5f * (float) -num1, 0, new Color(), 1f); - Dust dust = Main.dust[index2]; + int smoky = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, -2.5f * (float) -isActive, 0, new Color(), 1f); + Dust dust = Main.dust[smoky]; dust.alpha = 200; dust.velocity *= new Vector2(0.3f, 2f); - dust.velocity.Y += (float)(2 * num1); + dust.velocity.Y += (float)(2 * isActive); dust.scale += Main.rand.NextFloat(); - dust.position = new Vector2(Projectile.Center.X, Projectile.Center.Y + (float) Projectile.height * 0.5f * (float) -num1); - dust.customData = (object) num2; - if (num1 == -1 && Main.rand.Next(4) != 0) + dust.position = new Vector2(Projectile.Center.X, Projectile.Center.Y + (float) Projectile.height * 0.5f * (float) -isActive); + dust.customData = (object) dustCustomData; + if (isActive == -1 && Main.rand.Next(4) != 0) { dust.velocity.Y -= 0.2f; } } SoundEngine.PlaySound(SoundID.Item34, Projectile.position); } - if (num1 == 1) + if (isActive == 1) { - for (int index1 = 0; index1 < 9; ++index1) + for (int i = 0; i < 9; ++i) { - int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, -2.5f * (float) -num1, 0, new Color(), 1f); - Dust dust = Main.dust[index2]; + int smoky = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, -2.5f * (float) -isActive, 0, new Color(), 1f); + Dust dust = Main.dust[smoky]; dust.alpha = 200; dust.velocity *= new Vector2(0.3f, 2f); - dust.velocity.Y += (float)(2 * num1); + dust.velocity.Y += (float)(2 * isActive); dust.scale += Main.rand.NextFloat(); - dust.position = new Vector2(Projectile.Center.X, Projectile.Center.Y + (float) Projectile.height * 0.5f * (float) -num1); - dust.customData = (object)num2; - if (num1 == -1 && Main.rand.Next(4) != 0) + dust.position = new Vector2(Projectile.Center.X, Projectile.Center.Y + (float) Projectile.height * 0.5f * (float) -isActive); + dust.customData = (object)dustCustomData; + if (isActive == -1 && Main.rand.Next(4) != 0) { - Main.dust[index2].velocity.Y -= 0.2f; + Main.dust[smoky].velocity.Y -= 0.2f; } } } int Height = (int)(Projectile.ai[1] / 60f * (float)Projectile.height) * 3; if (Height > Projectile.height) Height = Projectile.height; - Vector2 Position = Projectile.position + (num1 == -1 ? new Vector2(0f, (float) (Projectile.height - Height)) : Vector2.Zero); - Vector2 vector2 = Projectile.position + (num1 == -1 ? new Vector2(0f, (float) Projectile.height) : Vector2.Zero); - for (int index1 = 0; index1 < 6; ++index1) + Vector2 Position = Projectile.position + (isActive == -1 ? new Vector2(0f, (float) (Projectile.height - Height)) : Vector2.Zero); + Vector2 vector2 = Projectile.position + (isActive == -1 ? new Vector2(0f, (float) Projectile.height) : Vector2.Zero); + for (int i = 0; i < 6; ++i) { if (Main.rand.Next(3) < 2) { - int index2 = Dust.NewDust(Position, Projectile.width, Height, dustType, 0f, 0f, 90, new Color(), 2.5f); - Dust dust = Main.dust[index2]; + int smoky = Dust.NewDust(Position, Projectile.width, Height, dustType, 0f, 0f, 90, new Color(), 2.5f); + Dust dust = Main.dust[smoky]; dust.noGravity = true; dust.fadeIn = 1f; if (dust.velocity.Y > 0f) @@ -146,25 +146,25 @@ namespace CalamityMod.Projectiles.Environment dust.scale *= 0.3f; } else - Main.dust[index2].velocity = Projectile.DirectionFrom(Main.dust[index2].position) * Main.dust[index2].velocity.Length() * 0.25f; - Main.dust[index2].velocity.Y *= (float)-num1; - Main.dust[index2].customData = (object)num2; + Main.dust[smoky].velocity = Projectile.DirectionFrom(Main.dust[smoky].position) * Main.dust[smoky].velocity.Length() * 0.25f; + Main.dust[smoky].velocity.Y *= (float)-isActive; + Main.dust[smoky].customData = (object)dustCustomData; } } - for (int index1 = 0; index1 < 6; ++index1) + for (int i = 0; i < 6; ++i) { if (Main.rand.NextFloat() >= 0.5f) { - int index2 = Dust.NewDust(Position, Projectile.width, Height, dustType, 0f, -2.5f * (float) -num1, 0, new Color(), 1f); - Dust dust = Main.dust[index2]; + int smoky = Dust.NewDust(Position, Projectile.width, Height, dustType, 0f, -2.5f * (float) -isActive, 0, new Color(), 1f); + Dust dust = Main.dust[smoky]; dust.alpha = 200; dust.velocity *= new Vector2(0.6f, 1.5f); dust.scale += Main.rand.NextFloat(); - if (num1 == -1 && Main.rand.Next(4) != 0) + if (isActive == -1 && Main.rand.Next(4) != 0) { dust.velocity.Y -= 0.2f; } - dust.customData = (object)num2; + dust.customData = (object)dustCustomData; } } } diff --git a/Projectiles/FireProj.png b/Projectiles/FireProj.png new file mode 100644 index 0000000000..49851837be Binary files /dev/null and b/Projectiles/FireProj.png differ diff --git a/Projectiles/Healing/AbsorberAura.cs b/Projectiles/Healing/AbsorberAura.cs index 505f68fc7b..0d682a3905 100644 --- a/Projectiles/Healing/AbsorberAura.cs +++ b/Projectiles/Healing/AbsorberAura.cs @@ -18,7 +18,6 @@ namespace CalamityMod.Projectiles.Healing { public new string LocalizationCategory => "Projectiles.Healing"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private static float Radius = 160f; private int AbDust = ModContent.DustType(); public int ShinkGrow = 0; public int Framecounter = 0; diff --git a/Projectiles/Healing/BlueJellyAura.cs b/Projectiles/Healing/BlueJellyAura.cs index 8245496e2f..5f9a35526e 100644 --- a/Projectiles/Healing/BlueJellyAura.cs +++ b/Projectiles/Healing/BlueJellyAura.cs @@ -18,7 +18,6 @@ namespace CalamityMod.Projectiles.Healing { public new string LocalizationCategory => "Projectiles.Healing"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private static float Radius = 160f; public int ShinkGrow = 0; public int Framecounter = 0; public int CleanseOnce = 1; diff --git a/Projectiles/Healing/EmpyreanHealOrb.cs b/Projectiles/Healing/EmpyreanHealOrb.cs index a6f863adcf..7b46370a34 100644 --- a/Projectiles/Healing/EmpyreanHealOrb.cs +++ b/Projectiles/Healing/EmpyreanHealOrb.cs @@ -20,15 +20,15 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { Projectile.HealingProjectile((int)Projectile.ai[1], (int)Projectile.ai[0], 5.5f, 15f); - float num498 = Projectile.velocity.X * 0.2f; - float num499 = -(Projectile.velocity.Y * 0.2f); + float dustX = Projectile.velocity.X * 0.2f; + float dustY = -(Projectile.velocity.Y * 0.2f); if (Projectile.timeLeft % 2 == 0) { - int num500 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 62, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[num500]; + int healDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 62, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[healDust]; dust.noGravity = true; - dust.position.X -= num498; - dust.position.Y -= num499; + dust.position.X -= dustX; + dust.position.Y -= dustY; } } } diff --git a/Projectiles/Healing/EssenceFlame.cs b/Projectiles/Healing/EssenceFlame.cs index 8a6b21d5bd..c5877a25e2 100644 --- a/Projectiles/Healing/EssenceFlame.cs +++ b/Projectiles/Healing/EssenceFlame.cs @@ -52,23 +52,23 @@ namespace CalamityMod.Projectiles.Healing Projectile.height = 50; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int godSlay = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); + Main.dust[godSlay].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[godSlay].scale = 0.5f; + Main.dust[godSlay].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 15; num623++) + for (int j = 0; j < 15; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int godSlay2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 3f); + Main.dust[godSlay2].noGravity = true; + Main.dust[godSlay2].velocity *= 5f; + godSlay2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); + Main.dust[godSlay2].velocity *= 2f; } } } diff --git a/Projectiles/Healing/FungalHeal.cs b/Projectiles/Healing/FungalHeal.cs index 042b605de8..8f13ec8042 100644 --- a/Projectiles/Healing/FungalHeal.cs +++ b/Projectiles/Healing/FungalHeal.cs @@ -20,20 +20,20 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { Projectile.HealingProjectile((int)Projectile.ai[1], (int)Projectile.ai[0], 5f, 15f); - float num494 = Projectile.velocity.X * 0.334f; - float num495 = -(Projectile.velocity.Y * 0.334f); - int num496 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 0.5f); - Dust dust = Main.dust[num496]; + float dustX = Projectile.velocity.X * 0.334f; + float dustY = -(Projectile.velocity.Y * 0.334f); + int fungi = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 0.5f); + Dust dust = Main.dust[fungi]; dust.noGravity = true; - dust.position.X -= num494; - dust.position.Y -= num495; - float num498 = Projectile.velocity.X * 0.2f; - float num499 = -(Projectile.velocity.Y * 0.2f); - int num500 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 0.7f); - Dust dust2 = Main.dust[num500]; + dust.position.X -= dustX; + dust.position.Y -= dustY; + float dustX2 = Projectile.velocity.X * 0.2f; + float dustY2 = -(Projectile.velocity.Y * 0.2f); + int fungi2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 0.7f); + Dust dust2 = Main.dust[fungi2]; dust2.noGravity = true; - dust2.position.X -= num498; - dust2.position.Y -= num499; + dust2.position.X -= dustX2; + dust2.position.Y -= dustY2; } } } diff --git a/Projectiles/Healing/GreenJellyAura.cs b/Projectiles/Healing/GreenJellyAura.cs index 7a4f2e8d89..4a8c181709 100644 --- a/Projectiles/Healing/GreenJellyAura.cs +++ b/Projectiles/Healing/GreenJellyAura.cs @@ -18,7 +18,6 @@ namespace CalamityMod.Projectiles.Healing { public new string LocalizationCategory => "Projectiles.Healing"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private static float Radius = 160f; public int ShinkGrow = 0; public int Framecounter = 0; public int CleanseOnce = 1; diff --git a/Projectiles/Healing/PinkJellyAura.cs b/Projectiles/Healing/PinkJellyAura.cs index 461df9446b..25212adfce 100644 --- a/Projectiles/Healing/PinkJellyAura.cs +++ b/Projectiles/Healing/PinkJellyAura.cs @@ -16,7 +16,6 @@ namespace CalamityMod.Projectiles.Healing { public new string LocalizationCategory => "Projectiles.Healing"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private static float Radius = 160f; public int ShinkGrow = 0; public int Framecounter = 0; public int PulseOnce = 1; diff --git a/Projectiles/Healing/RainHeal.cs b/Projectiles/Healing/RainHeal.cs index e76b1cc791..b9b3902bb3 100644 --- a/Projectiles/Healing/RainHeal.cs +++ b/Projectiles/Healing/RainHeal.cs @@ -30,13 +30,13 @@ namespace CalamityMod.Projectiles.Healing Projectile.HealingProjectile(8, Projectile.owner, 12f, 15f, false); } - float num498 = Projectile.velocity.X * 0.2f; - float num499 = -(Projectile.velocity.Y * 0.2f); - int num500 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Dust dust = Main.dust[num500]; + float dustX = Projectile.velocity.X * 0.2f; + float dustY = -(Projectile.velocity.Y * 0.2f); + int rainbow = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Dust dust = Main.dust[rainbow]; dust.noGravity = true; - dust.position.X -= num498; - dust.position.Y -= num499; + dust.position.X -= dustX; + dust.position.Y -= dustY; } } } diff --git a/Projectiles/Healing/RoyalHeal.cs b/Projectiles/Healing/RoyalHeal.cs index 9c0016a0b7..f65c93ec2a 100644 --- a/Projectiles/Healing/RoyalHeal.cs +++ b/Projectiles/Healing/RoyalHeal.cs @@ -20,25 +20,25 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { Projectile.HealingProjectile((int)Projectile.ai[1], (int)Projectile.ai[0], 5.5f, 15f); - for (int num493 = 0; num493 < 3; num493++) + for (int i = 0; i < 3; i++) { - float num494 = Projectile.velocity.X * 0.334f * (float)num493; - float num495 = -(Projectile.velocity.Y * 0.334f) * (float)num493; - int num496 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 20, 0f, 0f, 100, default, 1.1f); - Dust dust = Main.dust[num496]; + float dustX = Projectile.velocity.X * 0.334f * (float)i; + float dustY = -(Projectile.velocity.Y * 0.334f) * (float)i; + int pureHeal = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 20, 0f, 0f, 100, default, 1.1f); + Dust dust = Main.dust[pureHeal]; dust.noGravity = true; - dust.position.X -= num494; - dust.position.Y -= num495; + dust.position.X -= dustX; + dust.position.Y -= dustY; } - for (int num497 = 0; num497 < 5; num497++) + for (int j = 0; j < 5; j++) { - float num498 = Projectile.velocity.X * 0.2f * (float)num497; - float num499 = -(Projectile.velocity.Y * 0.2f) * (float)num497; - int num500 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 20, 0f, 0f, 100, default, 1.3f); - Dust dust2 = Main.dust[num500]; + float dustX2 = Projectile.velocity.X * 0.2f * (float)j; + float dustY2 = -(Projectile.velocity.Y * 0.2f) * (float)j; + int pureHeal2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 20, 0f, 0f, 100, default, 1.3f); + Dust dust2 = Main.dust[pureHeal2]; dust2.noGravity = true; - dust2.position.X -= num498; - dust2.position.Y -= num499; + dust2.position.X -= dustX2; + dust2.position.Y -= dustY2; } } } diff --git a/Projectiles/Healing/ShinobiHealOrb.cs b/Projectiles/Healing/ShinobiHealOrb.cs index 001ea12b6a..be3d5edd5e 100644 --- a/Projectiles/Healing/ShinobiHealOrb.cs +++ b/Projectiles/Healing/ShinobiHealOrb.cs @@ -23,11 +23,11 @@ namespace CalamityMod.Projectiles.Healing { Projectile.HealingProjectile((int)Projectile.ai[1], Projectile.owner, 6f, 15f); - for (int num468 = 0; num468 < 3; num468++) + for (int i = 0; i < 3; i++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 15, 0f, 0f, 100, default, 1.3f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int magicHeal = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 15, 0f, 0f, 100, default, 1.3f); + Main.dust[magicHeal].noGravity = true; + Main.dust[magicHeal].velocity *= 0f; } } } diff --git a/Projectiles/Healing/SilvaOrb.cs b/Projectiles/Healing/SilvaOrb.cs index eb43f6cf2e..a78c26ef64 100644 --- a/Projectiles/Healing/SilvaOrb.cs +++ b/Projectiles/Healing/SilvaOrb.cs @@ -49,12 +49,12 @@ namespace CalamityMod.Projectiles.Healing public override void OnKill(int timeLeft) { - for (int num407 = 0; num407 < 5; num407++) + for (int i = 0; i < 5; i++) { - int num408 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 157, 0f, 0f, 0, new Color(Main.DiscoR, 203, 103), 1f); - Main.dust[num408].noGravity = true; - Main.dust[num408].velocity *= 1.5f; - Main.dust[num408].scale = 1.5f; + int silvaHeal = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 157, 0f, 0f, 0, new Color(Main.DiscoR, 203, 103), 1f); + Main.dust[silvaHeal].noGravity = true; + Main.dust[silvaHeal].velocity *= 1.5f; + Main.dust[silvaHeal].scale = 1.5f; } } } diff --git a/Projectiles/Healing/TransfusionTrail.cs b/Projectiles/Healing/TransfusionTrail.cs index 0062ee8f9e..74a3c75371 100644 --- a/Projectiles/Healing/TransfusionTrail.cs +++ b/Projectiles/Healing/TransfusionTrail.cs @@ -20,22 +20,22 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { Projectile.HealingProjectile((int)Projectile.ai[1], (int)Projectile.ai[0], 6.5f, 15f); - float num494 = Projectile.velocity.X * 0.334f; - float num495 = -(Projectile.velocity.Y * 0.334f); - int num496 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 183, 0f, 0f, 100, default, 0.7f); - Dust dust = Main.dust[num496]; + float dustX = Projectile.velocity.X * 0.334f; + float dustY = -(Projectile.velocity.Y * 0.334f); + int healRed = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 183, 0f, 0f, 100, default, 0.7f); + Dust dust = Main.dust[healRed]; dust.noGravity = true; - dust.position.X -= num494; - dust.position.Y -= num495; - for (int num497 = 0; num497 < 2; num497++) + dust.position.X -= dustX; + dust.position.Y -= dustY; + for (int i = 0; i < 2; i++) { - float num498 = Projectile.velocity.X * 0.2f * (float)num497; - float num499 = -(Projectile.velocity.Y * 0.2f) * (float)num497; - int num500 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 183, 0f, 0f, 100, default, 0.9f); - Dust dust2 = Main.dust[num500]; + float dustyX = Projectile.velocity.X * 0.2f * (float)i; + float dustyY = -(Projectile.velocity.Y * 0.2f) * (float)i; + int healRedMore = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 183, 0f, 0f, 100, default, 0.9f); + Dust dust2 = Main.dust[healRedMore]; dust2.noGravity = true; - dust2.position.X -= num498; - dust2.position.Y -= num499; + dust2.position.X -= dustyX; + dust2.position.Y -= dustyY; } } } diff --git a/Projectiles/Magic/AbyssBall.cs b/Projectiles/Magic/AbyssBall.cs index f233bc9fdb..be7d0bb39e 100644 --- a/Projectiles/Magic/AbyssBall.cs +++ b/Projectiles/Magic/AbyssBall.cs @@ -42,23 +42,23 @@ namespace CalamityMod.Projectiles.Magic Projectile.localNPCHitCooldown = 10; Projectile.Damage(); SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - for (int num621 = 0; num621 < 30; num621++) + for (int i = 0; i < 30; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; + int abyssal = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.2f); + Main.dust[abyssal].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[abyssal].scale = 0.5f; + Main.dust[abyssal].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 60; num623++) + for (int j = 0; j < 60; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int abyssal2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.7f); + Main.dust[abyssal2].noGravity = true; + Main.dust[abyssal2].velocity *= 5f; + abyssal2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1f); + Main.dust[abyssal2].velocity *= 2f; } } } diff --git a/Projectiles/Magic/AcidGunStream.cs b/Projectiles/Magic/AcidGunStream.cs index 89fc919e93..5ebffcd0cb 100644 --- a/Projectiles/Magic/AcidGunStream.cs +++ b/Projectiles/Magic/AcidGunStream.cs @@ -39,7 +39,6 @@ namespace CalamityMod.Projectiles.Magic Projectile.localAI[0] += 1f; return; } - Projectile.velocity.Y += 0.075f; for (int i = 0; i < 3; i++) { Vector2 positionDelta = Projectile.velocity / 3f * i; @@ -58,6 +57,9 @@ namespace CalamityMod.Projectiles.Magic Main.dust[dustIdx].velocity *= 0.25f; Main.dust[dustIdx].velocity += Projectile.velocity * 0.5f; } + + if (Projectile.localAI[1] >= 10f) + Projectile.velocity.Y += 0.075f; } // If any of the streams are destroyed, kill the accompanying acid streams diff --git a/Projectiles/Magic/AcidicSaxBubble.cs b/Projectiles/Magic/AcidicSaxBubble.cs index 0d2cbd1a27..bbe7b4eae8 100644 --- a/Projectiles/Magic/AcidicSaxBubble.cs +++ b/Projectiles/Magic/AcidicSaxBubble.cs @@ -50,11 +50,11 @@ namespace CalamityMod.Projectiles.Magic if (counter >= 120f) { counter = 0f; - Vector2 vector15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - vector15.Normalize(); - vector15 *= (float)Main.rand.Next(50, 401) * 0.01f; + Vector2 mistRandDirection = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + mistRandDirection.Normalize(); + mistRandDirection *= (float)Main.rand.Next(50, 401) * 0.01f; int damage = (int)Main.player[Projectile.owner].GetTotalDamage().ApplyTo(BelchingSaxophone.BaseDamage); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, vector15.X, vector15.Y, ModContent.ProjectileType(), damage, 1f, Projectile.owner, 0f, 0f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, mistRandDirection.X, mistRandDirection.Y, ModContent.ProjectileType(), damage, 1f, Projectile.owner, 0f, 0f); } else counter += 1f; @@ -64,10 +64,9 @@ namespace CalamityMod.Projectiles.Magic Projectile.ai[1] += 1f; if (Projectile.ai[1] >= 6f) { - int num982 = 20; if (Projectile.alpha > 0) { - Projectile.alpha -= num982; + Projectile.alpha -= 20; } if (Projectile.alpha < 80) { @@ -129,9 +128,9 @@ namespace CalamityMod.Projectiles.Magic public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } @@ -152,17 +151,17 @@ namespace CalamityMod.Projectiles.Magic Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); SoundEngine.PlaySound(SoundID.Item54, Projectile.Center); - int num3; - for (int num246 = 0; num246 < 25; num246 = num3 + 1) + int inc; + for (int i = 0; i < 25; i = inc + 1) { - int num247 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 0, default, 1f); - Main.dust[num247].position = (Main.dust[num247].position + Projectile.position) / 2f; - Main.dust[num247].velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - Main.dust[num247].velocity.Normalize(); - Dust dust = Main.dust[num247]; + int toxicDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 0, default, 1f); + Main.dust[toxicDust].position = (Main.dust[toxicDust].position + Projectile.position) / 2f; + Main.dust[toxicDust].velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + Main.dust[toxicDust].velocity.Normalize(); + Dust dust = Main.dust[toxicDust]; dust.velocity *= (float)Main.rand.Next(1, 30) * 0.1f; - Main.dust[num247].alpha = Projectile.alpha; - num3 = num246; + Main.dust[toxicDust].alpha = Projectile.alpha; + inc = i; } Projectile.maxPenetrate = -1; Projectile.penetrate = -1; diff --git a/Projectiles/Magic/AquamarineBolt.cs b/Projectiles/Magic/AquamarineBolt.cs index e3744e47fb..2d4c0481b6 100644 --- a/Projectiles/Magic/AquamarineBolt.cs +++ b/Projectiles/Magic/AquamarineBolt.cs @@ -26,17 +26,15 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0.25f / 255f); - int num154 = 14; - int num155 = Dust.NewDust(Projectile.Center, Projectile.width - num154 * 2, Projectile.height - num154 * 2, 68, 0f, 0f, 100, default, 1.5f); - Main.dust[num155].noGravity = true; - Main.dust[num155].velocity *= 0.1f; - Main.dust[num155].velocity += Projectile.velocity * 0.5f; + int aquaDust = Dust.NewDust(Projectile.Center, Projectile.width - 28, Projectile.height - 28, 68, 0f, 0f, 100, default, 1.5f); + Main.dust[aquaDust].noGravity = true; + Main.dust[aquaDust].velocity *= 0.1f; + Main.dust[aquaDust].velocity += Projectile.velocity * 0.5f; if (Main.rand.NextBool(16)) { - int num156 = 16; - int num157 = Dust.NewDust(Projectile.Center, Projectile.width - num156 * 2, Projectile.height - num156 * 2, 68, 0f, 0f, 100, default, 1f); - Main.dust[num157].velocity *= 0.25f; - Main.dust[num157].velocity += Projectile.velocity * 0.5f; + int aquaticDust = Dust.NewDust(Projectile.Center, Projectile.width - 32, Projectile.height - 32, 68, 0f, 0f, 100, default, 1f); + Main.dust[aquaticDust].velocity *= 0.25f; + Main.dust[aquaticDust].velocity += Projectile.velocity * 0.5f; } Projectile.rotation += 0.3f * (float)Projectile.direction; } diff --git a/Projectiles/Magic/Asteroid.cs b/Projectiles/Magic/Asteroid.cs index 86230b40c3..18011bb5ab 100644 --- a/Projectiles/Magic/Asteroid.cs +++ b/Projectiles/Magic/Asteroid.cs @@ -38,26 +38,24 @@ namespace CalamityMod.Projectiles.Magic Projectile.scale = Projectile.ai[1]; Projectile.rotation += Projectile.velocity.X * 2f; Vector2 position = Projectile.Center + Vector2.Normalize(Projectile.velocity) * 10f; - Dust dust20 = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 107, 0f, 0f, 0, default, 1f)]; - dust20.position = position; - dust20.velocity = Projectile.velocity.RotatedBy(1.5707963705062866, default) * 0.33f + Projectile.velocity / 4f; - dust20.position += Projectile.velocity.RotatedBy(1.5707963705062866, default); - dust20.fadeIn = 0.5f; - dust20.noGravity = true; - dust20 = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 107, 0f, 0f, 0, default, 1f)]; - dust20.position = position; - dust20.velocity = Projectile.velocity.RotatedBy(-1.5707963705062866, default) * 0.33f + Projectile.velocity / 4f; - dust20.position += Projectile.velocity.RotatedBy(-1.5707963705062866, default); - dust20.fadeIn = 0.5f; - dust20.noGravity = true; - for (int num189 = 0; num189 < 1; num189++) - { - int num190 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 0, default, 1f); - Main.dust[num190].velocity *= 0.5f; - Main.dust[num190].scale *= 1.3f; - Main.dust[num190].fadeIn = 1f; - Main.dust[num190].noGravity = true; - } + Dust greenDust = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 107, 0f, 0f, 0, default, 1f)]; + greenDust.position = position; + greenDust.velocity = Projectile.velocity.RotatedBy(1.5707963705062866, default) * 0.33f + Projectile.velocity / 4f; + greenDust.position += Projectile.velocity.RotatedBy(1.5707963705062866, default); + greenDust.fadeIn = 0.5f; + greenDust.noGravity = true; + greenDust = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 107, 0f, 0f, 0, default, 1f)]; + greenDust.position = position; + greenDust.velocity = Projectile.velocity.RotatedBy(-1.5707963705062866, default) * 0.33f + Projectile.velocity / 4f; + greenDust.position += Projectile.velocity.RotatedBy(-1.5707963705062866, default); + greenDust.fadeIn = 0.5f; + greenDust.noGravity = true; + + int moreGreen = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 0, default, 1f); + Main.dust[moreGreen].velocity *= 0.5f; + Main.dust[moreGreen].scale *= 1.3f; + Main.dust[moreGreen].fadeIn = 1f; + Main.dust[moreGreen].noGravity = true; } public override void OnKill(int timeLeft) @@ -69,25 +67,25 @@ namespace CalamityMod.Projectiles.Magic Projectile.height = (int)(128f * Projectile.scale); Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num336 = 0; num336 < 4; num336++) + for (int i = 0; i < 4; i++) { Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 1.5f); } - for (int num337 = 0; num337 < 16; num337++) + for (int j = 0; j < 16; j++) { - int num338 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, default, 2.5f); - Main.dust[num338].noGravity = true; - Main.dust[num338].velocity *= 3f; - num338 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, default, 1.5f); - Main.dust[num338].velocity *= 2f; - Main.dust[num338].noGravity = true; + int killDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, default, 2.5f); + Main.dust[killDust].noGravity = true; + Main.dust[killDust].velocity *= 3f; + killDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, default, 1.5f); + Main.dust[killDust].velocity *= 2f; + Main.dust[killDust].noGravity = true; } if (Main.netMode != NetmodeID.Server) { - for (int num339 = 0; num339 < 2; num339++) + for (int k = 0; k < 2; k++) { - int num340 = Gore.NewGore(Projectile.GetSource_Death(), Projectile.position + new Vector2((float)(Projectile.width * Main.rand.Next(100)) / 100f, (float)(Projectile.height * Main.rand.Next(100)) / 100f) - Vector2.One * 10f, default, Main.rand.Next(61, 64), 1f); - Gore gore = Main.gore[num340]; + int gored = Gore.NewGore(Projectile.GetSource_Death(), Projectile.position + new Vector2((float)(Projectile.width * Main.rand.Next(100)) / 100f, (float)(Projectile.height * Main.rand.Next(100)) / 100f) - Vector2.One * 10f, default, Main.rand.Next(61, 64), 1f); + Gore gore = Main.gore[gored]; gore.velocity *= 0.3f; gore.velocity.X += (float)Main.rand.Next(-10, 11) * 0.05f; gore.velocity.Y += (float)Main.rand.Next(-10, 11) * 0.05f; @@ -99,18 +97,18 @@ namespace CalamityMod.Projectiles.Magic Projectile.maxPenetrate = 0; Projectile.Damage(); } - for (int num341 = 0; num341 < 5; num341++) + for (int l = 0; l < 5; l++) { - int num342 = Utils.SelectRandom(Main.rand, new int[] + int dustType = Utils.SelectRandom(Main.rand, new int[] { 107, 259, 158 }); - int num343 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, num342, 2.5f * (float)Projectile.direction, -2.5f, 0, default, 1f); - Main.dust[num343].alpha = 200; - Main.dust[num343].velocity *= 2.4f; - Main.dust[num343].scale += Main.rand.NextFloat(); + int exploding = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 2.5f * (float)Projectile.direction, -2.5f, 0, default, 1f); + Main.dust[exploding].alpha = 200; + Main.dust[exploding].velocity *= 2.4f; + Main.dust[exploding].scale += Main.rand.NextFloat(); } } diff --git a/Projectiles/Magic/AsteroidMolten.cs b/Projectiles/Magic/AsteroidMolten.cs index 0177e8edc7..8046e5fdf2 100644 --- a/Projectiles/Magic/AsteroidMolten.cs +++ b/Projectiles/Magic/AsteroidMolten.cs @@ -39,26 +39,24 @@ namespace CalamityMod.Projectiles.Magic Projectile.scale = Projectile.ai[1]; Projectile.rotation += Projectile.velocity.X * 2f; Vector2 position = Projectile.Center + Vector2.Normalize(Projectile.velocity) * 10f; - Dust dust20 = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 0, new Color(255, Main.DiscoG, 0), 1f)]; - dust20.position = position; - dust20.velocity = Projectile.velocity.RotatedBy(1.5707963705062866, default) * 0.33f + Projectile.velocity / 4f; - dust20.position += Projectile.velocity.RotatedBy(1.5707963705062866, default); - dust20.fadeIn = 0.5f; - dust20.noGravity = true; - dust20 = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 0, new Color(255, Main.DiscoG, 0), 1f)]; - dust20.position = position; - dust20.velocity = Projectile.velocity.RotatedBy(-1.5707963705062866, default) * 0.33f + Projectile.velocity / 4f; - dust20.position += Projectile.velocity.RotatedBy(-1.5707963705062866, default); - dust20.fadeIn = 0.5f; - dust20.noGravity = true; - for (int num189 = 0; num189 < 1; num189++) - { - int num190 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 0, new Color(255, Main.DiscoG, 0), 1f); - Main.dust[num190].velocity *= 0.5f; - Main.dust[num190].scale *= 1.3f; - Main.dust[num190].fadeIn = 1f; - Main.dust[num190].noGravity = true; - } + Dust flaming = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 0, new Color(255, Main.DiscoG, 0), 1f)]; + flaming.position = position; + flaming.velocity = Projectile.velocity.RotatedBy(1.5707963705062866, default) * 0.33f + Projectile.velocity / 4f; + flaming.position += Projectile.velocity.RotatedBy(1.5707963705062866, default); + flaming.fadeIn = 0.5f; + flaming.noGravity = true; + flaming = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 0, new Color(255, Main.DiscoG, 0), 1f)]; + flaming.position = position; + flaming.velocity = Projectile.velocity.RotatedBy(-1.5707963705062866, default) * 0.33f + Projectile.velocity / 4f; + flaming.position += Projectile.velocity.RotatedBy(-1.5707963705062866, default); + flaming.fadeIn = 0.5f; + flaming.noGravity = true; + + int fiery = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 0, new Color(255, Main.DiscoG, 0), 1f); + Main.dust[fiery].velocity *= 0.5f; + Main.dust[fiery].scale *= 1.3f; + Main.dust[fiery].fadeIn = 1f; + Main.dust[fiery].noGravity = true; } public override void OnKill(int timeLeft) @@ -70,25 +68,25 @@ namespace CalamityMod.Projectiles.Magic Projectile.height = (int)(128f * Projectile.scale); Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num336 = 0; num336 < 8; num336++) + for (int i = 0; i < 8; i++) { Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, new Color(255, Main.DiscoG, 0), 1.5f); } - for (int num337 = 0; num337 < 32; num337++) + for (int j = 0; j < 32; j++) { - int num338 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, new Color(255, Main.DiscoG, 0), 2.5f); - Main.dust[num338].noGravity = true; - Main.dust[num338].velocity *= 3f; - num338 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, new Color(255, Main.DiscoG, 0), 1.5f); - Main.dust[num338].velocity *= 2f; - Main.dust[num338].noGravity = true; + int killFire = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, new Color(255, Main.DiscoG, 0), 2.5f); + Main.dust[killFire].noGravity = true; + Main.dust[killFire].velocity *= 3f; + killFire = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, new Color(255, Main.DiscoG, 0), 1.5f); + Main.dust[killFire].velocity *= 2f; + Main.dust[killFire].noGravity = true; } if (Main.netMode != NetmodeID.Server) { - for (int num339 = 0; num339 < 2; num339++) + for (int k = 0; k < 2; k++) { - int num340 = Gore.NewGore(Projectile.GetSource_Death(), Projectile.position + new Vector2((float)(Projectile.width * Main.rand.Next(100)) / 100f, (float)(Projectile.height * Main.rand.Next(100)) / 100f) - Vector2.One * 10f, default, Main.rand.Next(61, 64), 1f); - Gore gore = Main.gore[num340]; + int gored = Gore.NewGore(Projectile.GetSource_Death(), Projectile.position + new Vector2((float)(Projectile.width * Main.rand.Next(100)) / 100f, (float)(Projectile.height * Main.rand.Next(100)) / 100f) - Vector2.One * 10f, default, Main.rand.Next(61, 64), 1f); + Gore gore = Main.gore[gored]; gore.velocity *= 0.3f; gore.velocity.X += (float)Main.rand.Next(-10, 11) * 0.05f; gore.velocity.Y += (float)Main.rand.Next(-10, 11) * 0.05f; @@ -100,18 +98,18 @@ namespace CalamityMod.Projectiles.Magic Projectile.maxPenetrate = 0; Projectile.Damage(); } - for (int num341 = 0; num341 < 5; num341++) + for (int l = 0; l < 5; l++) { - int num342 = Utils.SelectRandom(Main.rand, new int[] + int dustType = Utils.SelectRandom(Main.rand, new int[] { 244, 259, 158 }); - int num343 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, num342, 2.5f * (float)Projectile.direction, -2.5f, 0, new Color(255, Main.DiscoG, 0), 1f); - Main.dust[num343].alpha = 200; - Main.dust[num343].velocity *= 2.4f; - Main.dust[num343].scale += Main.rand.NextFloat(); + int exploding = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 2.5f * (float)Projectile.direction, -2.5f, 0, new Color(255, Main.DiscoG, 0), 1f); + Main.dust[exploding].alpha = 200; + Main.dust[exploding].velocity *= 2.4f; + Main.dust[exploding].scale += Main.rand.NextFloat(); } } diff --git a/Projectiles/Magic/AstralCrystal.cs b/Projectiles/Magic/AstralCrystal.cs index 19cfd9cffe..beca08bfcd 100644 --- a/Projectiles/Magic/AstralCrystal.cs +++ b/Projectiles/Magic/AstralCrystal.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.width = 40; Projectile.height = 40; Projectile.friendly = true; - Projectile.penetrate = 5; + Projectile.penetrate = 2; Projectile.extraUpdates = 2; Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Magic; diff --git a/Projectiles/Magic/AtlantisSpear.cs b/Projectiles/Magic/AtlantisSpear.cs index 85467eec9e..732589d7ca 100644 --- a/Projectiles/Magic/AtlantisSpear.cs +++ b/Projectiles/Magic/AtlantisSpear.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.penetrate = -1; Projectile.extraUpdates = (Main.zenithWorld && devourer) ? 1 : 0; Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = (Main.zenithWorld && devourer) ? 2 : 12; + Projectile.idStaticNPCHitCooldown = (Main.zenithWorld && devourer) ? 2 : 6; } public override void AI() diff --git a/Projectiles/Magic/BeamingBolt.cs b/Projectiles/Magic/BeamingBolt.cs index d8f24724a2..0934bbc373 100644 --- a/Projectiles/Magic/BeamingBolt.cs +++ b/Projectiles/Magic/BeamingBolt.cs @@ -62,7 +62,7 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 8; i++) { Vector2 velocity = ((MathHelper.TwoPi * i / 8f) - (MathHelper.Pi / 8f)).ToRotationVector2() * 4f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.75), Projectile.knockBack, Projectile.owner, Projectile.ai[0]); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 1), Projectile.knockBack, Projectile.owner, Projectile.ai[0]); } } SoundEngine.PlaySound(SoundID.Item105, Projectile.position); diff --git a/Projectiles/Magic/BeastScythe.cs b/Projectiles/Magic/BeastScythe.cs index 0d91011c7a..bcbf924648 100644 --- a/Projectiles/Magic/BeastScythe.cs +++ b/Projectiles/Magic/BeastScythe.cs @@ -60,70 +60,69 @@ namespace CalamityMod.Projectiles.Magic { if (Main.player[Projectile.owner].channel) { - float num115 = 20f; + float projDelay = 20f; Vector2 vector10 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num116 = (float)Main.mouseX + Main.screenPosition.X - vector10.X; - float num117 = (float)Main.mouseY + Main.screenPosition.Y - vector10.Y; + float projXDirection = (float)Main.mouseX + Main.screenPosition.X - vector10.X; + float projYDirection = (float)Main.mouseY + Main.screenPosition.Y - vector10.Y; if (Main.player[Projectile.owner].gravDir == -1f) { - num117 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector10.Y; + projYDirection = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector10.Y; } - float num118 = (float)Math.Sqrt((double)(num116 * num116 + num117 * num117)); - num118 = (float)Math.Sqrt((double)(num116 * num116 + num117 * num117)); - if (num118 > num115) + float projDistance = (float)Math.Sqrt((double)(projXDirection * projXDirection + projYDirection * projYDirection)); + projDistance = (float)Math.Sqrt((double)(projXDirection * projXDirection + projYDirection * projYDirection)); + if (projDistance > projDelay) { - num118 = num115 / num118; - num116 *= num118; - num117 *= num118; - int num119 = (int)(num116 * 1000f); - int num120 = (int)(Projectile.velocity.X * 1000f); - int num121 = (int)(num117 * 1000f); - int num122 = (int)(Projectile.velocity.Y * 1000f); - if (num119 != num120 || num121 != num122) + projDistance = projDelay / projDistance; + projXDirection *= projDistance; + projYDirection *= projDistance; + int projXSpeed = (int)(projXDirection * 1000f); + int projXSpeedMagnified = (int)(Projectile.velocity.X * 1000f); + int projYSpeed = (int)(projYDirection * 1000f); + int projYSpeedMagnified = (int)(Projectile.velocity.Y * 1000f); + if (projXSpeed != projXSpeedMagnified || projYSpeed != projYSpeedMagnified) { Projectile.netUpdate = true; } - Projectile.velocity.X = num116; - Projectile.velocity.Y = num117; + Projectile.velocity.X = projXDirection; + Projectile.velocity.Y = projYDirection; } else { - int num123 = (int)(num116 * 1000f); - int num124 = (int)(Projectile.velocity.X * 1000f); - int num125 = (int)(num117 * 1000f); - int num126 = (int)(Projectile.velocity.Y * 1000f); - if (num123 != num124 || num125 != num126) + int projXSpeedElse = (int)(projXDirection * 1000f); + int projXSpeedMagnifiedElse = (int)(Projectile.velocity.X * 1000f); + int projYSpeedElse = (int)(projYDirection * 1000f); + int projYSpeedMagnifiedElse = (int)(Projectile.velocity.Y * 1000f); + if (projXSpeedElse != projXSpeedMagnifiedElse || projYSpeedElse != projYSpeedMagnifiedElse) { Projectile.netUpdate = true; } - Projectile.velocity.X = num116; - Projectile.velocity.Y = num117; + Projectile.velocity.X = projXDirection; + Projectile.velocity.Y = projYDirection; } } else { Projectile.netUpdate = true; - float num127 = 20f; - Vector2 vector11 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num128 = (float)Main.mouseX + Main.screenPosition.X - vector11.X; - float num129 = (float)Main.mouseY + Main.screenPosition.Y - vector11.Y; + Vector2 projDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float projXDir = (float)Main.mouseX + Main.screenPosition.X - projDirection.X; + float projYDir = (float)Main.mouseY + Main.screenPosition.Y - projDirection.Y; if (Main.player[Projectile.owner].gravDir == -1f) { - num129 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector11.Y; + projYDir = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - projDirection.Y; } - float num130 = (float)Math.Sqrt((double)(num128 * num128 + num129 * num129)); - if (num130 == 0f || Projectile.ai[0] < 0f) + float projDistancing = (float)Math.Sqrt((double)(projXDir * projXDir + projYDir * projYDir)); + if (projDistancing == 0f || Projectile.ai[0] < 0f) { - vector11 = new Vector2(Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2), Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2)); - num128 = Projectile.position.X + (float)Projectile.width * 0.5f - vector11.X; - num129 = Projectile.position.Y + (float)Projectile.height * 0.5f - vector11.Y; - num130 = (float)Math.Sqrt((double)(num128 * num128 + num129 * num129)); + projDirection = new Vector2(Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2), Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2)); + projXDir = Projectile.position.X + (float)Projectile.width * 0.5f - projDirection.X; + projYDir = Projectile.position.Y + (float)Projectile.height * 0.5f - projDirection.Y; + projDistancing = (float)Math.Sqrt((double)(projXDir * projXDir + projYDir * projYDir)); } - num130 = num127 / num130; - num128 *= num130; - num129 *= num130; - Projectile.velocity.X = num128; - Projectile.velocity.Y = num129; + projDistancing = 20f / projDistancing; + projXDir *= projDistancing; + projYDir *= projDistancing; + Projectile.velocity.X = projXDir; + Projectile.velocity.Y = projYDir; } } if (Projectile.ai[0] >= 30f) @@ -147,26 +146,26 @@ namespace CalamityMod.Projectiles.Magic Projectile.localNPCHitCooldown = 10; Projectile.damage /= 2; Projectile.Damage(); - bool flag = WorldGen.SolidTile(Framing.GetTileSafely((int)Projectile.position.X / 16, (int)Projectile.position.Y / 16)); + bool isInTile = WorldGen.SolidTile(Framing.GetTileSafely((int)Projectile.position.X / 16, (int)Projectile.position.Y / 16)); for (int m = 0; m < 4; m++) { Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.5f); } for (int n = 0; n < 4; n++) { - int num10 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 0, default, 2.5f); - Main.dust[num10].noGravity = true; - Main.dust[num10].velocity *= 3f; - if (flag) + int beastial = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 0, default, 2.5f); + Main.dust[beastial].noGravity = true; + Main.dust[beastial].velocity *= 3f; + if (isInTile) { - Main.dust[num10].noLight = true; + Main.dust[beastial].noLight = true; } - num10 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.5f); - Main.dust[num10].velocity *= 2f; - Main.dust[num10].noGravity = true; - if (flag) + beastial = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.5f); + Main.dust[beastial].velocity *= 2f; + Main.dust[beastial].noGravity = true; + if (isInTile) { - Main.dust[num10].noLight = true; + Main.dust[beastial].noLight = true; } } } diff --git a/Projectiles/Magic/BigBeamofDeath.cs b/Projectiles/Magic/BigBeamofDeath.cs index cb3ab8efb0..c56ea64535 100644 --- a/Projectiles/Magic/BigBeamofDeath.cs +++ b/Projectiles/Magic/BigBeamofDeath.cs @@ -41,11 +41,11 @@ namespace CalamityMod.Projectiles.Magic Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 9f) { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * 0.25f; - int num448 = Dust.NewDust(vector33, 1, 1, 206, 0f, 0f, 0, default, 3f); - Main.dust[num448].position = vector33; - Main.dust[num448].velocity *= 0.1f; + Vector2 projPos = Projectile.position; + projPos -= Projectile.velocity * 0.25f; + int beamDust = Dust.NewDust(projPos, 1, 1, 206, 0f, 0f, 0, default, 3f); + Main.dust[beamDust].position = projPos; + Main.dust[beamDust].velocity *= 0.1f; } } } diff --git a/Projectiles/Magic/BigBeamofDeath2.cs b/Projectiles/Magic/BigBeamofDeath2.cs index bd60986769..0670ca4928 100644 --- a/Projectiles/Magic/BigBeamofDeath2.cs +++ b/Projectiles/Magic/BigBeamofDeath2.cs @@ -24,11 +24,11 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * 0.25f; - int num448 = Dust.NewDust(vector33, 1, 1, 206, 0f, 0f, 0, default, 3f); - Main.dust[num448].position = vector33; - Main.dust[num448].velocity *= 0.1f; + Vector2 projPos = Projectile.position; + projPos -= Projectile.velocity * 0.25f; + int beamDust = Dust.NewDust(projPos, 1, 1, 206, 0f, 0f, 0, default, 3f); + Main.dust[beamDust].position = projPos; + Main.dust[beamDust].velocity *= 0.1f; } } } diff --git a/Projectiles/Magic/BlackAnurianBubble.cs b/Projectiles/Magic/BlackAnurianBubble.cs index efff9c9206..e7357805fb 100644 --- a/Projectiles/Magic/BlackAnurianBubble.cs +++ b/Projectiles/Magic/BlackAnurianBubble.cs @@ -63,17 +63,17 @@ namespace CalamityMod.Projectiles.Magic public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item54, Projectile.position); - int num3; - for (int num246 = 0; num246 < 25; num246 = num3 + 1) + int inc; + for (int i = 0; i < 25; i = inc + 1) { - int num247 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 14, 0f, 0f, 0, default, 1f); - Main.dust[num247].position = (Main.dust[num247].position + Projectile.position) / 2f; - Main.dust[num247].velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - Main.dust[num247].velocity.Normalize(); - Dust dust = Main.dust[num247]; + int blackDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 14, 0f, 0f, 0, default, 1f); + Main.dust[blackDust].position = (Main.dust[blackDust].position + Projectile.position) / 2f; + Main.dust[blackDust].velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + Main.dust[blackDust].velocity.Normalize(); + Dust dust = Main.dust[blackDust]; dust.velocity *= (float)Main.rand.Next(1, 30) * 0.1f; - Main.dust[num247].alpha = Projectile.alpha; - num3 = num246; + Main.dust[blackDust].alpha = Projectile.alpha; + inc = i; } } } diff --git a/Projectiles/Magic/BlackAnurianPlankton.cs b/Projectiles/Magic/BlackAnurianPlankton.cs index 6120d9cb76..e60b867d46 100644 --- a/Projectiles/Magic/BlackAnurianPlankton.cs +++ b/Projectiles/Magic/BlackAnurianPlankton.cs @@ -49,76 +49,75 @@ namespace CalamityMod.Projectiles.Magic Projectile.alpha = 0; } Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) + 1.57f; - float num373 = Projectile.position.X; - float num374 = Projectile.position.Y; - float num375 = 100000f; - bool flag10 = false; + float projX = Projectile.position.X; + float projY = Projectile.position.Y; + float homingRange = 100000f; + bool isHoming = false; Projectile.ai[0] += 1f; if (Projectile.ai[0] > 30f) { Projectile.ai[0] = 30f; - for (int num376 = 0; num376 < Main.maxNPCs; num376++) + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num376].CanBeChasedBy(Projectile, false) && !Main.npc[num376].wet) + if (Main.npc[i].CanBeChasedBy(Projectile, false) && !Main.npc[i].wet) { - float num377 = Main.npc[num376].position.X + (float)(Main.npc[num376].width / 2); - float num378 = Main.npc[num376].position.Y + (float)(Main.npc[num376].height / 2); - float num379 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num377) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num378); - if (num379 < 800f && num379 < num375 && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[num376].position, Main.npc[num376].width, Main.npc[num376].height)) + float npcX = Main.npc[i].position.X + (float)(Main.npc[i].width / 2); + float npcY = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2); + float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); + if (npcDist < 800f && npcDist < homingRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height)) { - num375 = num379; - num373 = num377; - num374 = num378; - flag10 = true; + homingRange = npcDist; + projX = npcX; + projY = npcY; + isHoming = true; } } } } - if (!flag10) + if (!isHoming) { - num373 = Projectile.position.X + (float)(Projectile.width / 2) + Projectile.velocity.X * 100f; - num374 = Projectile.position.Y + (float)(Projectile.height / 2) + Projectile.velocity.Y * 100f; + projX = Projectile.position.X + (float)(Projectile.width / 2) + Projectile.velocity.X * 100f; + projY = Projectile.position.Y + (float)(Projectile.height / 2) + Projectile.velocity.Y * 100f; } - float num380 = 6f; - float num381 = 0.1f; - Vector2 vector30 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num382 = num373 - vector30.X; - float num383 = num374 - vector30.Y; - float num384 = (float)Math.Sqrt((double)(num382 * num382 + num383 * num383)); - num384 = num380 / num384; - num382 *= num384; - num383 *= num384; - if (Projectile.velocity.X < num382) + float projVelModifier = 0.1f; + Vector2 projDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float xDest = projX - projDirection.X; + float yDest = projY - projDirection.Y; + float destinationDist = (float)Math.Sqrt((double)(xDest * xDest + yDest * yDest)); + destinationDist = 6f / destinationDist; + xDest *= destinationDist; + yDest *= destinationDist; + if (Projectile.velocity.X < xDest) { - Projectile.velocity.X = Projectile.velocity.X + num381; - if (Projectile.velocity.X < 0f && num382 > 0f) + Projectile.velocity.X = Projectile.velocity.X + projVelModifier; + if (Projectile.velocity.X < 0f && xDest > 0f) { - Projectile.velocity.X = Projectile.velocity.X + num381 * 2f; + Projectile.velocity.X = Projectile.velocity.X + projVelModifier * 2f; } } - else if (Projectile.velocity.X > num382) + else if (Projectile.velocity.X > xDest) { - Projectile.velocity.X = Projectile.velocity.X - num381; - if (Projectile.velocity.X > 0f && num382 < 0f) + Projectile.velocity.X = Projectile.velocity.X - projVelModifier; + if (Projectile.velocity.X > 0f && xDest < 0f) { - Projectile.velocity.X = Projectile.velocity.X - num381 * 2f; + Projectile.velocity.X = Projectile.velocity.X - projVelModifier * 2f; } } - if (Projectile.velocity.Y < num383) + if (Projectile.velocity.Y < yDest) { - Projectile.velocity.Y = Projectile.velocity.Y + num381; - if (Projectile.velocity.Y < 0f && num383 > 0f) + Projectile.velocity.Y = Projectile.velocity.Y + projVelModifier; + if (Projectile.velocity.Y < 0f && yDest > 0f) { - Projectile.velocity.Y = Projectile.velocity.Y + num381 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y + projVelModifier * 2f; } } - else if (Projectile.velocity.Y > num383) + else if (Projectile.velocity.Y > yDest) { - Projectile.velocity.Y = Projectile.velocity.Y - num381; - if (Projectile.velocity.Y > 0f && num383 < 0f) + Projectile.velocity.Y = Projectile.velocity.Y - projVelModifier; + if (Projectile.velocity.Y > 0f && yDest < 0f) { - Projectile.velocity.Y = Projectile.velocity.Y - num381 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y - projVelModifier * 2f; } } } diff --git a/Projectiles/Magic/BloodBlast.cs b/Projectiles/Magic/BloodBlast.cs index 8d0adf5fb2..c7e058c507 100644 --- a/Projectiles/Magic/BloodBlast.cs +++ b/Projectiles/Magic/BloodBlast.cs @@ -25,25 +25,25 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { Lighting.AddLight(Projectile.Center, 0.5f, 0f, 0f); - for (int num92 = 0; num92 < 2; num92++) + for (int i = 0; i < 2; i++) { - float num93 = Projectile.velocity.X / 3f * (float)num92; - float num94 = Projectile.velocity.Y / 3f * (float)num92; - int num95 = 4; - int num96 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num95, Projectile.position.Y + (float)num95), Projectile.width - num95 * 2, Projectile.height - num95 * 2, 5, 0f, 0f, 100, default, 1.2f); - Dust dust = Main.dust[num96]; + float shortXVel = Projectile.velocity.X / 3f * (float)i; + float shortYVel = Projectile.velocity.Y / 3f * (float)i; + int fourConst = 4; + int bloody = Dust.NewDust(new Vector2(Projectile.position.X + (float)fourConst, Projectile.position.Y + (float)fourConst), Projectile.width - fourConst * 2, Projectile.height - fourConst * 2, 5, 0f, 0f, 100, default, 1.2f); + Dust dust = Main.dust[bloody]; dust.noGravity = true; dust.velocity *= 0.1f; dust.velocity += Projectile.velocity * 0.1f; - dust.position.X -= num93; - dust.position.Y -= num94; + dust.position.X -= shortXVel; + dust.position.Y -= shortYVel; } if (Main.rand.NextBool(5)) { - int num97 = 4; - int num98 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num97, Projectile.position.Y + (float)num97), Projectile.width - num97 * 2, Projectile.height - num97 * 2, 5, 0f, 0f, 100, default, 0.6f); - Main.dust[num98].velocity *= 0.25f; - Main.dust[num98].velocity += Projectile.velocity * 0.5f; + int otherFourConst = 4; + int graphicContent = Dust.NewDust(new Vector2(Projectile.position.X + (float)otherFourConst, Projectile.position.Y + (float)otherFourConst), Projectile.width - otherFourConst * 2, Projectile.height - otherFourConst * 2, 5, 0f, 0f, 100, default, 0.6f); + Main.dust[graphicContent].velocity *= 0.25f; + Main.dust[graphicContent].velocity += Projectile.velocity * 0.5f; } if (Projectile.ai[1] >= 20f) { diff --git a/Projectiles/Magic/BlueBubble.cs b/Projectiles/Magic/BlueBubble.cs index 78dfc934b6..342bfd69d2 100644 --- a/Projectiles/Magic/BlueBubble.cs +++ b/Projectiles/Magic/BlueBubble.cs @@ -36,13 +36,13 @@ namespace CalamityMod.Projectiles.Magic Projectile.alpha = 0; Vector2 v2 = Projectile.ai[0].ToRotationVector2(); - float num743 = Projectile.velocity.ToRotation(); - float num744 = v2.ToRotation(); - double num745 = num744 - num743; - if (num745 > MathHelper.Pi) - num745 -= MathHelper.TwoPi; - if (num745 < -MathHelper.Pi) - num745 += MathHelper.TwoPi; + float projRotate = Projectile.velocity.ToRotation(); + float aiRotation = v2.ToRotation(); + double projAngle = aiRotation - projRotate; + if (projAngle > MathHelper.Pi) + projAngle -= MathHelper.TwoPi; + if (projAngle < -MathHelper.Pi) + projAngle += MathHelper.TwoPi; Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; @@ -54,12 +54,12 @@ namespace CalamityMod.Projectiles.Magic { SoundEngine.PlaySound(SoundID.Item54, Projectile.Center); int num190 = Main.rand.Next(5, 9); - for (int num191 = 0; num191 < num190; num191++) + for (int i = 0; i < num190; i++) { - int num192 = Dust.NewDust(Projectile.Center, 0, 0, 206, 0f, 0f, 100, default, 1.4f); - Main.dust[num192].velocity *= 0.8f; - Main.dust[num192].position = Vector2.Lerp(Main.dust[num192].position, Projectile.Center, 0.5f); - Main.dust[num192].noGravity = true; + int bubbly = Dust.NewDust(Projectile.Center, 0, 0, 206, 0f, 0f, 100, default, 1.4f); + Main.dust[bubbly].velocity *= 0.8f; + Main.dust[bubbly].position = Vector2.Lerp(Main.dust[bubbly].position, Projectile.Center, 0.5f); + Main.dust[bubbly].noGravity = true; } } } diff --git a/Projectiles/Magic/BrimstoneHellfireballFriendly.cs b/Projectiles/Magic/BrimstoneHellfireballFriendly.cs index 33ed6e693c..dff62e6cec 100644 --- a/Projectiles/Magic/BrimstoneHellfireballFriendly.cs +++ b/Projectiles/Magic/BrimstoneHellfireballFriendly.cs @@ -55,10 +55,10 @@ namespace CalamityMod.Projectiles.Magic Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) - MathHelper.ToRadians(90) * Projectile.direction; - int num458 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 170, default, 1.1f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int brimDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 170, default, 1.1f); + Main.dust[brimDust].noGravity = true; + Main.dust[brimDust].velocity *= 0.5f; + Main.dust[brimDust].velocity += Projectile.velocity * 0.1f; Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.05f / 255f, (255 - Projectile.alpha) * 0.05f / 255f); if (Projectile.localAI[0] == 0f) diff --git a/Projectiles/Magic/BrimstoneTentacle.cs b/Projectiles/Magic/BrimstoneTentacle.cs index 08069f6878..3e243f00b8 100644 --- a/Projectiles/Magic/BrimstoneTentacle.cs +++ b/Projectiles/Magic/BrimstoneTentacle.cs @@ -75,17 +75,17 @@ namespace CalamityMod.Projectiles.Magic Projectile.ai[1] *= 1.05f; if (Projectile.scale < 1f && Projectile.localAI[1] > 5f) { - int num897 = 0; - while ((float)num897 < Projectile.scale * 10f) + int scaleLoopCheck = 0; + while ((float)scaleLoopCheck < Projectile.scale * 10f) { - int num898 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1.5f); - Main.dust[num898].position = (Main.dust[num898].position + Projectile.Center) / 2f; - Main.dust[num898].noGravity = true; - Main.dust[num898].velocity *= 0.1f; - Main.dust[num898].velocity -= Projectile.velocity * (1.3f - Projectile.scale); - Main.dust[num898].fadeIn = (float)(100 + Projectile.owner); - Main.dust[num898].scale += Projectile.scale * 0.75f; - num897++; + int brimDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1.5f); + Main.dust[brimDust].position = (Main.dust[brimDust].position + Projectile.Center) / 2f; + Main.dust[brimDust].noGravity = true; + Main.dust[brimDust].velocity *= 0.1f; + Main.dust[brimDust].velocity -= Projectile.velocity * (1.3f - Projectile.scale); + Main.dust[brimDust].fadeIn = (float)(100 + Projectile.owner); + Main.dust[brimDust].scale += Projectile.scale * 0.75f; + scaleLoopCheck++; } } } diff --git a/Projectiles/Magic/ClamorNoctusStar.cs b/Projectiles/Magic/ClamorNoctusStar.cs index c4e7558dcc..fac42d9be0 100644 --- a/Projectiles/Magic/ClamorNoctusStar.cs +++ b/Projectiles/Magic/ClamorNoctusStar.cs @@ -63,27 +63,27 @@ namespace CalamityMod.Projectiles.Magic Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; - for (int num621 = 0; num621 < 15; num621++) + for (int i = 0; i < 15; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 20, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; + int brightDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 20, 0f, 0f, 100, default, 1.2f); + Main.dust[brightDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[brightDust].scale = 0.5f; + Main.dust[brightDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 20, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 20, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int brightDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 20, 0f, 0f, 100, default, 1.7f); + Main.dust[brightDust2].noGravity = true; + Main.dust[brightDust2].velocity *= 5f; + brightDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 20, 0f, 0f, 100, default, 1f); + Main.dust[brightDust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) { - for (int num480 = 0; num480 < 3; num480++) + for (int k = 0; k < 3; k++) { Gore.NewGore(Projectile.GetSource_Death(), Projectile.position, new Vector2(Projectile.velocity.X * 0.05f, Projectile.velocity.Y * 0.05f), Main.rand.Next(16, 18), 1f); } diff --git a/Projectiles/Magic/ClimaxBeam.cs b/Projectiles/Magic/ClimaxBeam.cs index 7c41edfe75..95d13c8bf5 100644 --- a/Projectiles/Magic/ClimaxBeam.cs +++ b/Projectiles/Magic/ClimaxBeam.cs @@ -22,12 +22,12 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * 0.25f; - int num448 = Dust.NewDust(vector33, 1, 1, 206, 0f, 0f, 0, default, 1.25f); - Main.dust[num448].position = vector33; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.1f; + Vector2 projPos = Projectile.position; + projPos -= Projectile.velocity * 0.25f; + int boltDust = Dust.NewDust(projPos, 1, 1, 206, 0f, 0f, 0, default, 1.25f); + Main.dust[boltDust].position = projPos; + Main.dust[boltDust].scale = (float)Main.rand.Next(70, 110) * 0.013f; + Main.dust[boltDust].velocity *= 0.1f; } } } diff --git a/Projectiles/Magic/ClimaxProj.cs b/Projectiles/Magic/ClimaxProj.cs index 76299da1d8..842271fce3 100644 --- a/Projectiles/Magic/ClimaxProj.cs +++ b/Projectiles/Magic/ClimaxProj.cs @@ -53,15 +53,15 @@ namespace CalamityMod.Projectiles.Magic // but once it's past that then it can fire constantly --Projectile.ai[0]; if (Projectile.ai[0] < 0f) - CalamityUtils.MagnetSphereHitscan(Projectile, 400f, 8f, VoltaicClimax.OrbFireRate, 2, ModContent.ProjectileType(), 1D, true); + CalamityUtils.MagnetSphereHitscan(Projectile, 640f, 8f, VoltaicClimax.OrbFireRate, 2, ModContent.ProjectileType(), 1D, true); } public override Color? GetAlpha(Color lightColor) { if (Projectile.timeLeft < 30) { - float num7 = Projectile.timeLeft / 30f; - Projectile.alpha = (int)(255f - 255f * num7); + float alphaTimer = Projectile.timeLeft / 30f; + Projectile.alpha = (int)(255f - 255f * alphaTimer); } return new Color(255 - Projectile.alpha, 255 - Projectile.alpha, 255 - Projectile.alpha, 0); } @@ -69,9 +69,9 @@ namespace CalamityMod.Projectiles.Magic public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture2D13.Width / 2f, num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture2D13.Width / 2f, framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } diff --git a/Projectiles/Magic/CosmicTentacle.cs b/Projectiles/Magic/CosmicTentacle.cs index 58c85e7690..ac18c8d0d9 100644 --- a/Projectiles/Magic/CosmicTentacle.cs +++ b/Projectiles/Magic/CosmicTentacle.cs @@ -45,12 +45,12 @@ namespace CalamityMod.Projectiles.Magic Projectile.Kill(); } } - Vector2 center10 = Projectile.Center; + Vector2 projCenter = Projectile.Center; Projectile.scale = 1f - Projectile.localAI[0]; Projectile.width = (int)(20f * Projectile.scale); Projectile.height = Projectile.width; - Projectile.position.X = center10.X - (float)(Projectile.width / 2); - Projectile.position.Y = center10.Y - (float)(Projectile.height / 2); + Projectile.position.X = projCenter.X - (float)(Projectile.width / 2); + Projectile.position.Y = projCenter.Y - (float)(Projectile.height / 2); if (Projectile.localAI[0] < 0.1f) { Projectile.localAI[0] += 0.01f; @@ -74,17 +74,17 @@ namespace CalamityMod.Projectiles.Magic Projectile.ai[1] *= 1.05f; if (Projectile.scale < 1f && Projectile.localAI[1] > 5f) { - int num897 = 0; - while ((float)num897 < Projectile.scale * 10f) + int scaleLoopCheck = 0; + while ((float)scaleLoopCheck < Projectile.scale * 10f) { - int num898 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 62, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1.1f); - Main.dust[num898].position = (Main.dust[num898].position + Projectile.Center) / 2f; - Main.dust[num898].noGravity = true; - Main.dust[num898].velocity *= 0.1f; - Main.dust[num898].velocity -= Projectile.velocity * (1.3f - Projectile.scale); - Main.dust[num898].fadeIn = (float)(100 + Projectile.owner); - Main.dust[num898].scale += Projectile.scale * 0.75f; - num897++; + int purpleDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 62, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1.1f); + Main.dust[purpleDust].position = (Main.dust[purpleDust].position + Projectile.Center) / 2f; + Main.dust[purpleDust].noGravity = true; + Main.dust[purpleDust].velocity *= 0.1f; + Main.dust[purpleDust].velocity -= Projectile.velocity * (1.3f - Projectile.scale); + Main.dust[purpleDust].fadeIn = (float)(100 + Projectile.owner); + Main.dust[purpleDust].scale += Projectile.scale * 0.75f; + scaleLoopCheck++; } } } diff --git a/Projectiles/Magic/DarkSparkBeam.cs b/Projectiles/Magic/DarkSparkBeam.cs index ee9196799f..daf5eadd81 100644 --- a/Projectiles/Magic/DarkSparkBeam.cs +++ b/Projectiles/Magic/DarkSparkBeam.cs @@ -1,7 +1,7 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; +using System; using System.IO; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Enums; using Terraria.GameContent.Shaders; @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - Vector2? vector71 = null; + Vector2? chargeUpCenter = null; if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero) Projectile.velocity = -Vector2.UnitY; @@ -53,11 +53,11 @@ namespace CalamityMod.Projectiles.Magic } float laserPosition = (int)Projectile.ai[0] - 2.5f; - Vector2 value36 = Vector2.Normalize(Main.projectile[(int)Projectile.ai[1]].velocity); + Vector2 aimDirection = Vector2.Normalize(Main.projectile[(int)Projectile.ai[1]].velocity); Projectile projectile2 = Main.projectile[(int)Projectile.ai[1]]; - float num811; - Vector2 value37 = Vector2.Zero; - float num812; + float laserNormalize; + Vector2 projDirection = Vector2.Zero; + float laserTimer; float y; float laserRotationSpeed; float scaleFactor6; @@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Magic if (projectile2.ai[0] < 720f) { - num812 = projectile2.ai[0] / 1440f; + laserTimer = projectile2.ai[0] / 1440f; y = 6f + projectile2.ai[0] / 720f * 7f; if (projectile2.ai[0] > 360f) { @@ -112,20 +112,20 @@ namespace CalamityMod.Projectiles.Magic break; } - num812 = 0.5f; + laserTimer = 0.5f; laserRotationSpeed = 10.875f; y = 13f; scaleFactor6 = -7f; } - float num814 = (projectile2.ai[0] + laserPosition * laserRotationSpeed) / (laserRotationSpeed * 6f) * MathHelper.TwoPi; - num811 = Vector2.UnitY.RotatedBy(num814).Y * (MathHelper.Pi / 6) * num812 * 0.33f; - value37 = (Vector2.UnitY.RotatedBy(num814) * new Vector2(4f, y)).RotatedBy(projectile2.velocity.ToRotation()); - Projectile.position = projectile2.Center + value36 * 16f - Projectile.Size / 2f + new Vector2(0f, -Main.projectile[(int)Projectile.ai[1]].gfxOffY); + float laserDirection = (projectile2.ai[0] + laserPosition * laserRotationSpeed) / (laserRotationSpeed * 6f) * MathHelper.TwoPi; + laserNormalize = Vector2.UnitY.RotatedBy(laserDirection).Y * (MathHelper.Pi / 6) * laserTimer * 0.33f; + projDirection = (Vector2.UnitY.RotatedBy(laserDirection) * new Vector2(4f, y)).RotatedBy(projectile2.velocity.ToRotation()); + Projectile.position = projectile2.Center + aimDirection * 16f - Projectile.Size / 2f + new Vector2(0f, -Main.projectile[(int)Projectile.ai[1]].gfxOffY); Projectile.position += projectile2.velocity.ToRotation().ToRotationVector2() * scaleFactor6; - Projectile.position += value37; - Projectile.velocity = Vector2.Normalize(projectile2.velocity).RotatedBy(num811); - Projectile.scale = 1.5f * (1.5f - num812); + Projectile.position += projDirection; + Projectile.velocity = Vector2.Normalize(projectile2.velocity).RotatedBy(laserNormalize); + Projectile.scale = 1.5f * (1.5f - laserTimer); // Takes 360 frames to reach normal damage float amount = projectile2.ai[0] / 1200f; @@ -134,75 +134,71 @@ namespace CalamityMod.Projectiles.Magic Projectile.damage = (int)(projectile2.damage * MathHelper.Lerp(0.25f, 2.2f, amount)); if (projectile2.ai[0] >= 720f) - vector71 = new Vector2?(projectile2.Center); + chargeUpCenter = new Vector2?(projectile2.Center); if (!Collision.CanHitLine(Main.player[Projectile.owner].Center, 0, 0, projectile2.Center, 0, 0)) - vector71 = new Vector2?(Main.player[Projectile.owner].Center); + chargeUpCenter = new Vector2?(Main.player[Projectile.owner].Center); if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero) Projectile.velocity = -Vector2.UnitY; - float num818 = Projectile.velocity.ToRotation(); - Projectile.rotation = num818 - MathHelper.PiOver2; - Projectile.velocity = num818.ToRotationVector2(); + float laserRotate = Projectile.velocity.ToRotation(); + Projectile.rotation = laserRotate - MathHelper.PiOver2; + Projectile.velocity = laserRotate.ToRotationVector2(); - float num819 = 2f; - float num820 = 0f; Vector2 samplingPoint = Projectile.Center; - if (vector71.HasValue) - samplingPoint = vector71.Value; + if (chargeUpCenter.HasValue) + samplingPoint = chargeUpCenter.Value; - float[] array3 = new float[(int)num819]; - Collision.LaserScan(samplingPoint, Projectile.velocity, num820 * Projectile.scale, 2400f, array3); - float num821 = 0f; - for (int num822 = 0; num822 < array3.Length; num822++) - num821 += array3[num822]; - num821 /= num819; + float[] array3 = new float[2]; + Collision.LaserScan(samplingPoint, Projectile.velocity, 0f * Projectile.scale, 2400f, array3); + float beamSeparation = 0f; + for (int i = 0; i < array3.Length; i++) + beamSeparation += array3[i]; + beamSeparation /= 2f; - float amount2 = 0.75f; - Projectile.localAI[1] = MathHelper.Lerp(Projectile.localAI[1], num821, amount2); - if (Math.Abs(Projectile.localAI[1] - num821) < 100f && Projectile.scale > 0.15f) + Projectile.localAI[1] = MathHelper.Lerp(Projectile.localAI[1], beamSeparation, 0.75f); + if (Math.Abs(Projectile.localAI[1] - beamSeparation) < 100f && Projectile.scale > 0.15f) { - Vector2 vector80 = Projectile.Center + Projectile.velocity * (Projectile.localAI[1] - 14.5f * Projectile.scale); - for (int num843 = 0; num843 < 2; num843++) + Vector2 dustSpawn = Projectile.Center + Projectile.velocity * (Projectile.localAI[1] - 14.5f * Projectile.scale); + for (int j = 0; j < 2; j++) { - float num844 = Projectile.velocity.ToRotation() + ((Main.rand.Next(2) == 1) ? -1f : 1f) * MathHelper.PiOver2; - float num845 = (float)Main.rand.NextDouble() * 0.8f + 1f; - Vector2 vector81 = new Vector2((float)Math.Cos(num844) * num845, (float)Math.Sin(num844) * num845); - int num846 = Dust.NewDust(vector80, 0, 0, 267, vector81.X, vector81.Y, 0, color, 3.3f); - Main.dust[num846].color = color; - Main.dust[num846].scale = 1.2f; + float dustRotate = Projectile.velocity.ToRotation() + ((Main.rand.Next(2) == 1) ? -1f : 1f) * MathHelper.PiOver2; + float dustRandom = (float)Main.rand.NextDouble() * 0.8f + 1f; + Vector2 randomRotate = new Vector2((float)Math.Cos(dustRotate) * dustRandom, (float)Math.Sin(dustRotate) * dustRandom); + int rainbowDust = Dust.NewDust(dustSpawn, 0, 0, 267, randomRotate.X, randomRotate.Y, 0, color, 3.3f); + Main.dust[rainbowDust].color = color; + Main.dust[rainbowDust].scale = 1.2f; if (Projectile.scale > 1f) { - Main.dust[num846].velocity *= Projectile.scale; - Main.dust[num846].scale *= Projectile.scale; + Main.dust[rainbowDust].velocity *= Projectile.scale; + Main.dust[rainbowDust].scale *= Projectile.scale; } - Main.dust[num846].noGravity = true; + Main.dust[rainbowDust].noGravity = true; if (Projectile.scale != 1.4f) { - Dust dust9 = Dust.CloneDust(num846); - dust9.color = color; - dust9.scale /= 2f; - dust9.noGravity = true; + Dust rainbowClone = Dust.CloneDust(rainbowDust); + rainbowClone.color = color; + rainbowClone.scale /= 2f; + rainbowClone.noGravity = true; } - Main.dust[num846].color = color; + Main.dust[rainbowDust].color = color; } if (Main.rand.NextBool(5)) { - Vector2 value42 = Projectile.velocity.RotatedBy(MathHelper.PiOver2) * ((float)Main.rand.NextDouble() - 0.5f) * Projectile.width; - int num847 = Dust.NewDust(vector80 + value42 - Vector2.One * 4f, 8, 8, 267, 0f, 0f, 100, color, 5f); - Main.dust[num847].velocity *= 0.5f; - Main.dust[num847].noGravity = true; - Main.dust[num847].velocity.Y = -Math.Abs(Main.dust[num847].velocity.Y); + Vector2 extraDustSpawn = Projectile.velocity.RotatedBy(MathHelper.PiOver2) * ((float)Main.rand.NextDouble() - 0.5f) * Projectile.width; + int extraRainbows = Dust.NewDust(dustSpawn + extraDustSpawn - Vector2.One * 4f, 8, 8, 267, 0f, 0f, 100, color, 5f); + Main.dust[extraRainbows].velocity *= 0.5f; + Main.dust[extraRainbows].noGravity = true; + Main.dust[extraRainbows].velocity.Y = -Math.Abs(Main.dust[extraRainbows].velocity.Y); } DelegateMethods.v3_1 = color.ToVector3() * 0.3f; - float value43 = 0.1f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 20f); Vector2 size = new Vector2(Projectile.velocity.Length() * Projectile.localAI[1], Projectile.width * Projectile.scale); - float num848 = Projectile.velocity.ToRotation(); + float shaderLength = Projectile.velocity.ToRotation(); if (Main.netMode != NetmodeID.Server) - ((WaterShaderData)Filters.Scene["WaterDistortion"].GetShader()).QueueRipple(Projectile.position + new Vector2(size.X * 0.5f, 0f).RotatedBy(num848), color, size, RippleShape.Square, num848); + ((WaterShaderData)Filters.Scene["WaterDistortion"].GetShader()).QueueRipple(Projectile.position + new Vector2(size.X * 0.5f, 0f).RotatedBy(shaderLength), color, size, RippleShape.Square, shaderLength); Utils.PlotTileLine(Projectile.Center, Projectile.Center + Projectile.velocity * Projectile.localAI[1], Projectile.width * Projectile.scale, DelegateMethods.CastLight); } @@ -214,7 +210,7 @@ namespace CalamityMod.Projectiles.Magic return false; Texture2D tex = ModContent.Request(Texture).Value; - float num228 = Projectile.localAI[1]; + float drawArea = Projectile.localAI[1]; Projectile projectile2 = Main.projectile[(int)Projectile.ai[1]]; Color color = new Color(1, 1, 1, 127); if (projectile2.ai[0] < 720f) @@ -259,17 +255,17 @@ namespace CalamityMod.Projectiles.Magic } Color value25 = color; - Vector2 value26 = Projectile.Center.Floor(); - value26 += Projectile.velocity * Projectile.scale * 10.5f; - num228 -= Projectile.scale * 14.5f * Projectile.scale; - Vector2 vector29 = new Vector2(Projectile.scale); + Vector2 drawStart = Projectile.Center.Floor(); + drawStart += Projectile.velocity * Projectile.scale * 10.5f; + drawArea -= Projectile.scale * 14.5f * Projectile.scale; + Vector2 drawScale = new Vector2(Projectile.scale); DelegateMethods.f_1 = 1f; DelegateMethods.c_1 = value25 * 0.75f * Projectile.Opacity; Vector2 projPos = Projectile.oldPos[0]; projPos = new Vector2(Projectile.width, Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; - Utils.DrawLaser(Main.spriteBatch, tex, value26 - Main.screenPosition, value26 + Projectile.velocity * num228 - Main.screenPosition, vector29, new Utils.LaserLineFraming(DelegateMethods.RainbowLaserDraw)); + Utils.DrawLaser(Main.spriteBatch, tex, drawStart - Main.screenPosition, drawStart + Projectile.velocity * drawArea - Main.screenPosition, drawScale, new Utils.LaserLineFraming(DelegateMethods.RainbowLaserDraw)); DelegateMethods.c_1 = color * 0.75f * Projectile.Opacity; - Utils.DrawLaser(Main.spriteBatch, tex, value26 - Main.screenPosition, value26 + Projectile.velocity * num228 - Main.screenPosition, vector29 / 2f, new Utils.LaserLineFraming(DelegateMethods.RainbowLaserDraw)); + Utils.DrawLaser(Main.spriteBatch, tex, drawStart - Main.screenPosition, drawStart + Projectile.velocity * drawArea - Main.screenPosition, drawScale / 2f, new Utils.LaserLineFraming(DelegateMethods.RainbowLaserDraw)); return false; } @@ -285,8 +281,8 @@ namespace CalamityMod.Projectiles.Magic if (projHitbox.Intersects(targetHitbox)) return true; - float num6 = 0f; - if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center + Projectile.velocity * Projectile.localAI[1], 22f * Projectile.scale, ref num6)) + float useless = 0f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center + Projectile.velocity * Projectile.localAI[1], 22f * Projectile.scale, ref useless)) return true; return false; diff --git a/Projectiles/Magic/DarkSparkPrism.cs b/Projectiles/Magic/DarkSparkPrism.cs index 63057334fa..47c4b5985e 100644 --- a/Projectiles/Magic/DarkSparkPrism.cs +++ b/Projectiles/Magic/DarkSparkPrism.cs @@ -47,17 +47,17 @@ namespace CalamityMod.Projectiles.Magic { Player player = Main.player[Projectile.owner]; - float num = 0f; + float piConditional = 0f; if (Projectile.spriteDirection == -1) - num = MathHelper.Pi; + piConditional = MathHelper.Pi; - Vector2 vector = player.RotatedRelativePoint(player.MountedCenter); + Vector2 playerRotation = player.RotatedRelativePoint(player.MountedCenter); - float num26 = 30f; + float hitCooldown = 30f; if (Projectile.ai[0] > 360f) - num26 = 15f; + hitCooldown = 15f; if (Projectile.ai[0] > 480f) - num26 = 5f; + hitCooldown = 5f; Projectile.damage = player.ActiveItem() is null ? 0 : player.GetWeaponDamage(player.ActiveItem()); @@ -73,44 +73,43 @@ namespace CalamityMod.Projectiles.Magic if (Projectile.localAI[1] > 0f) Projectile.localAI[1] -= 1f; - bool flag9 = false; - if (Projectile.ai[0] % num26 == 0f) - flag9 = true; + bool shouldHitNotCharged = false; + if (Projectile.ai[0] % hitCooldown == 0f) + shouldHitNotCharged = true; - int num27 = 10; - bool flag10 = false; - if (Projectile.ai[0] % num26 == 0f) - flag10 = true; + bool shouldHitChargedUp = false; + if (Projectile.ai[0] % hitCooldown == 0f) + shouldHitChargedUp = true; if (Projectile.ai[1] >= 1f) { Projectile.ai[1] = 0f; - flag10 = true; + shouldHitChargedUp = true; if (Main.myPlayer == Projectile.owner) { float scaleFactor5 = player.ActiveItem().shootSpeed * Projectile.scale; - Vector2 value12 = vector; - Vector2 value13 = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - value12; + Vector2 projRotation = playerRotation; + Vector2 gravityAdjustedRotation = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - projRotation; if (player.gravDir == -1f) - value13.Y = Main.screenHeight - Main.mouseY + Main.screenPosition.Y - value12.Y; + gravityAdjustedRotation.Y = Main.screenHeight - Main.mouseY + Main.screenPosition.Y - projRotation.Y; - Vector2 vector11 = Vector2.Normalize(value13); - if (float.IsNaN(vector11.X) || float.IsNaN(vector11.Y)) - vector11 = -Vector2.UnitY; + Vector2 prismDirection = Vector2.Normalize(gravityAdjustedRotation); + if (float.IsNaN(prismDirection.X) || float.IsNaN(prismDirection.Y)) + prismDirection = -Vector2.UnitY; - vector11 = Vector2.Normalize(Vector2.Lerp(vector11, Vector2.Normalize(Projectile.velocity), 0.92f)); - vector11 *= scaleFactor5; - if (vector11.X != Projectile.velocity.X || vector11.Y != Projectile.velocity.Y) + prismDirection = Vector2.Normalize(Vector2.Lerp(prismDirection, Vector2.Normalize(Projectile.velocity), 0.92f)); + prismDirection *= scaleFactor5; + if (prismDirection.X != Projectile.velocity.X || prismDirection.Y != Projectile.velocity.Y) Projectile.netUpdate = true; - Projectile.velocity = vector11; + Projectile.velocity = prismDirection; } } Projectile.frameCounter++; - int num28 = (Projectile.ai[0] < 480f) ? 3 : 1; - if (Projectile.frameCounter >= num28) + int framing = (Projectile.ai[0] < 480f) ? 3 : 1; + if (Projectile.frameCounter >= framing) { Projectile.frameCounter = 0; if (++Projectile.frame >= 4) @@ -118,28 +117,27 @@ namespace CalamityMod.Projectiles.Magic } if (Projectile.soundDelay <= 0) { - Projectile.soundDelay = num27; + Projectile.soundDelay = 10; Projectile.soundDelay *= 2; if (Projectile.ai[0] != 1f) SoundEngine.PlaySound(SoundID.Item15, Projectile.position); } - if (flag10 && Main.myPlayer == Projectile.owner) + if (shouldHitChargedUp && Main.myPlayer == Projectile.owner) { - bool flag11 = !flag9 || player.CheckMana(player.ActiveItem(), -1, true, false); - bool flag12 = player.channel && flag11 && !player.noItems && !player.CCed; - if (flag12) + bool hasMana = !shouldHitNotCharged || player.CheckMana(player.ActiveItem(), -1, true, false); + bool canUseItem = player.channel && hasMana && !player.noItems && !player.CCed; + if (canUseItem) { if (Projectile.ai[0] == 1f) { - Vector2 center3 = Projectile.Center; - Vector2 vector12 = Vector2.Normalize(Projectile.velocity); - if (float.IsNaN(vector12.X) || float.IsNaN(vector12.Y)) - vector12 = -Vector2.UnitY; + Vector2 projCenter = Projectile.Center; + Vector2 beamDirection = Vector2.Normalize(Projectile.velocity); + if (float.IsNaN(beamDirection.X) || float.IsNaN(beamDirection.Y)) + beamDirection = -Vector2.UnitY; - int num29 = Projectile.damage; for (int l = 0; l < 7; l++) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), center3, vector12, ModContent.ProjectileType(), num29, Projectile.knockBack, Projectile.owner, l, Projectile.GetByUUID(Projectile.owner, Projectile.whoAmI)); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), projCenter, beamDirection, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, l, Projectile.GetByUUID(Projectile.owner, Projectile.whoAmI)); Projectile.netUpdate = true; } @@ -149,7 +147,7 @@ namespace CalamityMod.Projectiles.Magic } Projectile.position = player.RotatedRelativePoint(player.MountedCenter, true) - Projectile.Size / 2f; - Projectile.rotation = Projectile.velocity.ToRotation() + num; + Projectile.rotation = Projectile.velocity.ToRotation() + piConditional; Projectile.spriteDirection = Projectile.direction; Projectile.timeLeft = 2; player.ChangeDir(Projectile.direction); @@ -162,10 +160,10 @@ namespace CalamityMod.Projectiles.Magic public override bool PreDraw(ref Color lightColor) { Vector2 mountedCenter = Main.player[Projectile.owner].MountedCenter; - Color color25 = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); + Color prismColorArea = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); if (Projectile.hide && !ProjectileID.Sets.DontAttachHideToAlpha[Projectile.type]) { - color25 = Lighting.GetColor((int)mountedCenter.X / 16, (int)(mountedCenter.Y / 16f)); + prismColorArea = Lighting.GetColor((int)mountedCenter.X / 16, (int)(mountedCenter.Y / 16f)); } SpriteEffects spriteEffects = SpriteEffects.None; if (Projectile.spriteDirection == -1) @@ -173,38 +171,38 @@ namespace CalamityMod.Projectiles.Magic spriteEffects = SpriteEffects.FlipHorizontally; } Texture2D texture2D14 = ModContent.Request(Texture).Value; - int num215 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y7 = num215 * Projectile.frame; - Vector2 vector27 = (Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition).Floor(); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y7 = framing * Projectile.frame; + Vector2 drawStart = (Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition).Floor(); if (Main.player[Projectile.owner].shroomiteStealth && Main.player[Projectile.owner].inventory[Main.player[Projectile.owner].selectedItem].CountsAsClass()) { - float num216 = Main.player[Projectile.owner].stealth; - if ((double)num216 < 0.03) + float playerStealth = Main.player[Projectile.owner].stealth; + if ((double)playerStealth < 0.03) { - num216 = 0.03f; + playerStealth = 0.03f; } - float arg_97B3_0 = (1f + num216 * 10f) / 11f; - color25 *= num216; + float arg_97B3_0 = (1f + playerStealth * 10f) / 11f; + prismColorArea *= playerStealth; } if (Main.player[Projectile.owner].setVortex && Main.player[Projectile.owner].inventory[Main.player[Projectile.owner].selectedItem].CountsAsClass()) { - float num217 = Main.player[Projectile.owner].stealth; - if ((double)num217 < 0.03) + float playerStealthAgain = Main.player[Projectile.owner].stealth; + if ((double)playerStealthAgain < 0.03) { - num217 = 0.03f; + playerStealthAgain = 0.03f; } - float arg_9854_0 = (1f + num217 * 10f) / 11f; - color25 = color25.MultiplyRGBA(new Color(Vector4.Lerp(Vector4.One, new Vector4(0.16f, 0.12f, 0f, 0f), 1f - num217))); + float arg_9854_0 = (1f + playerStealthAgain * 10f) / 11f; + prismColorArea = prismColorArea.MultiplyRGBA(new Color(Vector4.Lerp(Vector4.One, new Vector4(0.16f, 0.12f, 0f, 0f), 1f - playerStealthAgain))); } - Main.spriteBatch.Draw(texture2D14, vector27, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y7, texture2D14.Width, num215)), Projectile.GetAlpha(color25), Projectile.rotation, new Vector2((float)texture2D14.Width / 2f, (float)num215 / 2f), Projectile.scale, spriteEffects, 0); + Main.spriteBatch.Draw(texture2D14, drawStart, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y7, texture2D14.Width, framing)), Projectile.GetAlpha(prismColorArea), Projectile.rotation, new Vector2((float)texture2D14.Width / 2f, (float)framing / 2f), Projectile.scale, spriteEffects, 0); float scaleFactor2 = (float)Math.Cos((double)(6.28318548f * (Projectile.ai[0] / 120f))) * 2f + 2f; if (Projectile.ai[0] > 480f) { scaleFactor2 = 4f; } - for (float num218 = 0f; num218 < 4f; num218 += 1f) + for (float i = 0f; i < 4f; i += 1f) { - Main.spriteBatch.Draw(texture2D14, vector27 + Vector2.UnitY.RotatedBy((double)(num218 * 6.28318548f / 4f), default) * scaleFactor2, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y7, texture2D14.Width, num215)), Projectile.GetAlpha(color25).MultiplyRGBA(new Color(255, 255, 255, 0)) * 0.03f, Projectile.rotation, new Vector2((float)texture2D14.Width / 2f, (float)num215 / 2f), Projectile.scale, spriteEffects, 0); + Main.spriteBatch.Draw(texture2D14, drawStart + Vector2.UnitY.RotatedBy((double)(i * 6.28318548f / 4f), default) * scaleFactor2, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y7, texture2D14.Width, framing)), Projectile.GetAlpha(prismColorArea).MultiplyRGBA(new Color(255, 255, 255, 0)) * 0.03f, Projectile.rotation, new Vector2((float)texture2D14.Width / 2f, (float)framing / 2f), Projectile.scale, spriteEffects, 0); } return false; } diff --git a/Projectiles/Magic/DivineRetributionSpear.cs b/Projectiles/Magic/DivineRetributionSpear.cs index c93a3dbb21..37658c254d 100644 --- a/Projectiles/Magic/DivineRetributionSpear.cs +++ b/Projectiles/Magic/DivineRetributionSpear.cs @@ -32,9 +32,9 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - float num953 = 25f * Projectile.ai[1]; //100 - float scaleFactor12 = 5f * Projectile.ai[1]; //5 - float num954 = 1000f; + float aiVelocityMult = 25f * Projectile.ai[1]; //100 + float scaleFactor = 5f * Projectile.ai[1]; //5 + float homingRange = 1000f; if (Projectile.velocity.X < 0f) { @@ -50,10 +50,10 @@ namespace CalamityMod.Projectiles.Magic Lighting.AddLight(Projectile.Center, 0.7f, 0.3f, 0f); if (Main.player[Projectile.owner].active && !Main.player[Projectile.owner].dead) { - if (Projectile.Distance(Main.player[Projectile.owner].Center) > num954) + if (Projectile.Distance(Main.player[Projectile.owner].Center) > homingRange) { Vector2 moveDirection = Projectile.SafeDirectionTo(Main.player[Projectile.owner].Center, Vector2.UnitY); - Projectile.velocity = (Projectile.velocity * (num953 - 1f) + moveDirection * scaleFactor12) / num953; + Projectile.velocity = (Projectile.velocity * (aiVelocityMult - 1f) + moveDirection * scaleFactor) / aiVelocityMult; return; } @@ -90,18 +90,18 @@ namespace CalamityMod.Projectiles.Magic Projectile.localNPCHitCooldown = 10; Projectile.Damage(); SoundEngine.PlaySound(SoundID.Item74, Projectile.Center); - for (int num193 = 0; num193 < 6; num193++) + for (int i = 0; i < 6; i++) { Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0, 0); } - for (int num194 = 0; num194 < 10; num194++) + for (int j = 0; j < 10; j++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0, 0); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0, 0); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int divinity = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0, 0); + Main.dust[divinity].noGravity = true; + Main.dust[divinity].velocity *= 3f; + divinity = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0, 0); + Main.dust[divinity].velocity *= 2f; + Main.dust[divinity].noGravity = true; } } } diff --git a/Projectiles/Magic/EidolicWailSoundwave.cs b/Projectiles/Magic/EidolicWailSoundwave.cs index 16454f20df..e6fa71eca8 100644 --- a/Projectiles/Magic/EidolicWailSoundwave.cs +++ b/Projectiles/Magic/EidolicWailSoundwave.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.alpha = 100; Projectile.friendly = true; Projectile.ignoreWater = true; - Projectile.penetrate = -1; + Projectile.penetrate = 7; Projectile.DamageType = DamageClass.Magic; Projectile.extraUpdates = 1; Projectile.usesLocalNPCImmunity = true; @@ -64,6 +64,12 @@ namespace CalamityMod.Projectiles.Magic public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { modifiers.SourceDamage *= Projectile.localAI[0]; + + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.75f); // 25% damage nerf for every enemy hit + if (Projectile.damage < 1) + Projectile.damage = 1; + } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) diff --git a/Projectiles/Magic/EldritchTentacle.cs b/Projectiles/Magic/EldritchTentacle.cs index 765a05643b..33e69041c7 100644 --- a/Projectiles/Magic/EldritchTentacle.cs +++ b/Projectiles/Magic/EldritchTentacle.cs @@ -43,12 +43,12 @@ namespace CalamityMod.Projectiles.Magic Projectile.Kill(); } } - Vector2 center10 = Projectile.Center; + Vector2 projCenter = Projectile.Center; Projectile.scale = 1f - Projectile.localAI[0]; Projectile.width = (int)(20f * Projectile.scale); Projectile.height = Projectile.width; - Projectile.position.X = center10.X - (float)(Projectile.width / 2); - Projectile.position.Y = center10.Y - (float)(Projectile.height / 2); + Projectile.position.X = projCenter.X - (float)(Projectile.width / 2); + Projectile.position.Y = projCenter.Y - (float)(Projectile.height / 2); if ((double)Projectile.localAI[0] < 0.1) { Projectile.localAI[0] += 0.01f; @@ -72,17 +72,17 @@ namespace CalamityMod.Projectiles.Magic Projectile.ai[1] *= 1.05f; if (Projectile.scale < 1f) { - int num897 = 0; - while ((float)num897 < Projectile.scale * 10f) + int scaleLoopCheck = 0; + while ((float)scaleLoopCheck < Projectile.scale * 10f) { - int num898 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1.1f); - Main.dust[num898].position = (Main.dust[num898].position + Projectile.Center) / 2f; - Main.dust[num898].noGravity = true; - Main.dust[num898].velocity *= 0.1f; - Main.dust[num898].velocity -= Projectile.velocity * (1.3f - Projectile.scale); - Main.dust[num898].fadeIn = (float)(100 + Projectile.owner); - Main.dust[num898].scale += Projectile.scale * 0.75f; - num897++; + int eldritchRed = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1.1f); + Main.dust[eldritchRed].position = (Main.dust[eldritchRed].position + Projectile.Center) / 2f; + Main.dust[eldritchRed].noGravity = true; + Main.dust[eldritchRed].velocity *= 0.1f; + Main.dust[eldritchRed].velocity -= Projectile.velocity * (1.3f - Projectile.scale); + Main.dust[eldritchRed].fadeIn = (float)(100 + Projectile.owner); + Main.dust[eldritchRed].scale += Projectile.scale * 0.75f; + scaleLoopCheck++; } } } diff --git a/Projectiles/Magic/ElementTentacle.cs b/Projectiles/Magic/ElementTentacle.cs index 84b8ed4038..76ba460e0c 100644 --- a/Projectiles/Magic/ElementTentacle.cs +++ b/Projectiles/Magic/ElementTentacle.cs @@ -46,12 +46,12 @@ namespace CalamityMod.Projectiles.Magic Projectile.Kill(); } } - Vector2 center10 = Projectile.Center; + Vector2 projCenter = Projectile.Center; Projectile.scale = 1f - Projectile.localAI[0]; Projectile.width = (int)(20f * Projectile.scale); Projectile.height = Projectile.width; - Projectile.position.X = center10.X - (float)(Projectile.width / 2); - Projectile.position.Y = center10.Y - (float)(Projectile.height / 2); + Projectile.position.X = projCenter.X - (float)(Projectile.width / 2); + Projectile.position.Y = projCenter.Y - (float)(Projectile.height / 2); if ((double)Projectile.localAI[0] < 0.1) { Projectile.localAI[0] += 0.01f; @@ -75,18 +75,22 @@ namespace CalamityMod.Projectiles.Magic Projectile.ai[1] *= 1.05f; if (Projectile.scale < 1f) { - int num897 = 0; - while ((float)num897 < Projectile.scale * 10f) + int scaleLoopCheck = 0; + while ((float)scaleLoopCheck < Projectile.scale * 10f) { - int num898 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, Projectile.velocity.X, Projectile.velocity.Y, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.1f); - Main.dust[num898].position = (Main.dust[num898].position + Projectile.Center) / 2f; - Main.dust[num898].noGravity = true; - Main.dust[num898].velocity *= 0.1f; - Main.dust[num898].velocity -= Projectile.velocity * (1.3f - Projectile.scale); - Main.dust[num898].scale += Projectile.scale * 0.75f; - num897++; + int rainbow = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, Projectile.velocity.X, Projectile.velocity.Y, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.1f); + Main.dust[rainbow].position = (Main.dust[rainbow].position + Projectile.Center) / 2f; + Main.dust[rainbow].noGravity = true; + Main.dust[rainbow].velocity *= 0.1f; + Main.dust[rainbow].velocity -= Projectile.velocity * (1.3f - Projectile.scale); + Main.dust[rainbow].scale += Projectile.scale * 0.75f; + scaleLoopCheck++; } } } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 120); + } } } diff --git a/Projectiles/Magic/EvergladeSprayProjectile.cs b/Projectiles/Magic/EvergladeSprayProjectile.cs index 81212fa2c0..8d3992e0a8 100644 --- a/Projectiles/Magic/EvergladeSprayProjectile.cs +++ b/Projectiles/Magic/EvergladeSprayProjectile.cs @@ -38,23 +38,23 @@ namespace CalamityMod.Projectiles.Magic return; } Projectile.velocity.Y = Projectile.velocity.Y + 0.075f; - for (int num151 = 0; num151 < 3; num151++) + for (int i = 0; i < 3; i++) { - float num152 = Projectile.velocity.X / 3f * (float)num151; - float num153 = Projectile.velocity.Y / 3f * (float)num151; - int num155 = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, 157, 0f, 0f, 100, default, 1f); - Dust dust = Main.dust[num155]; + float shortXVel = Projectile.velocity.X / 3f * (float)i; + float shortYVel = Projectile.velocity.Y / 3f * (float)i; + int natureDust = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, 157, 0f, 0f, 100, default, 1f); + Dust dust = Main.dust[natureDust]; dust.noGravity = true; dust.velocity *= 0.1f; dust.velocity += Projectile.velocity * 0.5f; - dust.position.X -= num152; - dust.position.Y -= num153; + dust.position.X -= shortXVel; + dust.position.Y -= shortYVel; } if (Main.rand.NextBool(8)) { - int num157 = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, 157, 0f, 0f, 100, default, 0.5f); - Main.dust[num157].velocity *= 0.25f; - Main.dust[num157].velocity += Projectile.velocity * 0.5f; + int natual = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, 157, 0f, 0f, 100, default, 0.5f); + Main.dust[natual].velocity *= 0.25f; + Main.dust[natual].velocity += Projectile.velocity * 0.5f; } } diff --git a/Projectiles/Magic/FatesRevealFlame.cs b/Projectiles/Magic/FatesRevealFlame.cs index 4bfcd0d590..b3e94ed397 100644 --- a/Projectiles/Magic/FatesRevealFlame.cs +++ b/Projectiles/Magic/FatesRevealFlame.cs @@ -28,9 +28,7 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - float num949 = 10f; - float scaleFactor11 = 15f; - float num950 = 160f; + float scaleFactor = 15f; if (Projectile.timeLeft > 30 && Projectile.alpha > 0) { Projectile.alpha -= 25; @@ -43,46 +41,45 @@ namespace CalamityMod.Projectiles.Magic { Projectile.alpha = 0; } - int num3 = Projectile.frameCounter + 1; - Projectile.frameCounter = num3; - if (num3 > 4) + int inc = Projectile.frameCounter + 1; + Projectile.frameCounter = inc; + if (inc > 4) { Projectile.frameCounter = 0; - num3 = Projectile.frame + 1; - Projectile.frame = num3; - if (num3 >= 4) + inc = Projectile.frame + 1; + Projectile.frame = inc; + if (inc >= 4) { Projectile.frame = 0; } } - float num951 = 0.5f; + float dustScale = 0.5f; if (Projectile.timeLeft < 120) { - num951 = 1.1f; + dustScale = 1.1f; } if (Projectile.timeLeft < 60) { - num951 = 1.6f; + dustScale = 1.6f; } float[] var_2_2A211_cp_0 = Projectile.ai; int var_2_2A211_cp_1 = 1; - float num73 = var_2_2A211_cp_0[var_2_2A211_cp_1]; - var_2_2A211_cp_0[var_2_2A211_cp_1] = num73 + 1f; - float num952 = Projectile.ai[1] / 180f * 6.28318548f; - for (float num953 = 0f; num953 < 3f; num953 = num73 + 1f) + float dustIncr = var_2_2A211_cp_0[var_2_2A211_cp_1]; + var_2_2A211_cp_0[var_2_2A211_cp_1] = dustIncr + 1f; + for (float j = 0f; j < 3f; j = dustIncr + 1f) { if (Main.rand.Next(3) != 0) { return; } - Dust dust13 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 60, 0f, -2f, 0, default, 1f)]; - dust13.position = Projectile.Center + Vector2.UnitY.RotatedBy((double)(num953 * 6.28318548f / 3f + Projectile.ai[1]), default) * 10f; - dust13.noGravity = true; - dust13.velocity = Projectile.DirectionFrom(dust13.position); - dust13.scale = num951; - dust13.fadeIn = 0.5f; - dust13.alpha = 200; - num73 = num953; + Dust fateful = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 60, 0f, -2f, 0, default, 1f)]; + fateful.position = Projectile.Center + Vector2.UnitY.RotatedBy((double)(j * 6.28318548f / 3f + Projectile.ai[1]), default) * 10f; + fateful.noGravity = true; + fateful.velocity = Projectile.DirectionFrom(fateful.position); + fateful.scale = dustScale; + fateful.fadeIn = 0.5f; + fateful.alpha = 200; + dustIncr = j; } if (Projectile.timeLeft < 4) { @@ -91,22 +88,22 @@ namespace CalamityMod.Projectiles.Magic Projectile.Center = Projectile.position; // Ozzatron 15FEB2021 -- What the actual fuck is this // projectile.damage = 800; - for (int num955 = 0; num955 < 10; num955 = num3 + 1) + for (int i = 0; i < 10; i = inc + 1) { - Dust dust13 = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 60, 0f, -2f, 0, default, 1f)]; - dust13.noGravity = true; - if (dust13.position != Projectile.Center) - dust13.velocity = Projectile.SafeDirectionTo(dust13.position) * 3f; + Dust fateful = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 60, 0f, -2f, 0, default, 1f)]; + fateful.noGravity = true; + if (fateful.position != Projectile.Center) + fateful.velocity = Projectile.SafeDirectionTo(fateful.position) * 3f; - num3 = num955; + inc = i; } } if (Main.player[Projectile.owner].active && !Main.player[Projectile.owner].dead) { - if (Projectile.Distance(Main.player[Projectile.owner].Center) > num950) + if (Projectile.Distance(Main.player[Projectile.owner].Center) > 160f) { Vector2 moveDirection = Projectile.SafeDirectionTo(Main.player[Projectile.owner].Center, Vector2.UnitY); - Projectile.velocity = (Projectile.velocity * (num949 - 1f) + moveDirection * scaleFactor11) / num949; + Projectile.velocity = (Projectile.velocity * 9f + moveDirection * scaleFactor) / 10f; } } else @@ -122,8 +119,8 @@ namespace CalamityMod.Projectiles.Magic { if (Projectile.timeLeft < 30) { - float num4 = (float)Projectile.timeLeft / 30f; - Projectile.alpha = (int)(255f - 255f * num4); + float aboutToDieAlpha = (float)Projectile.timeLeft / 30f; + Projectile.alpha = (int)(255f - 255f * aboutToDieAlpha); } return new Color(255 - Projectile.alpha, 255 - Projectile.alpha, 255 - Projectile.alpha, 128 - Projectile.alpha / 2); } @@ -143,30 +140,30 @@ namespace CalamityMod.Projectiles.Magic Projectile.Damage(); // Dust code - int num3; - for (int num122 = 0; num122 < 3; num122 = num3 + 1) + int inc; + for (int i = 0; i < 3; i = inc + 1) { - int num123 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.5f); - Main.dust[num123].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; - num3 = num122; + int redFate = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.5f); + Main.dust[redFate].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + inc = i; } - for (int num124 = 0; num124 < 10; num124 = num3 + 1) + for (int j = 0; j < 10; j = inc + 1) { - int num125 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 0, default, 2.5f); - Main.dust[num125].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; - Main.dust[num125].noGravity = true; - Dust dust = Main.dust[num125]; + int redFate2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 0, default, 2.5f); + Main.dust[redFate2].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + Main.dust[redFate2].noGravity = true; + Dust dust = Main.dust[redFate2]; dust.velocity *= 2f; - num3 = num124; + inc = j; } - for (int num126 = 0; num126 < 5; num126 = num3 + 1) + for (int k = 0; k < 5; k = inc + 1) { - int num127 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 0, default, 1.5f); - Main.dust[num127].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 2f; - Main.dust[num127].noGravity = true; - Dust dust = Main.dust[num127]; + int redFate3 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 0, default, 1.5f); + Main.dust[redFate3].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 2f; + Main.dust[redFate3].noGravity = true; + Dust dust = Main.dust[redFate3]; dust.velocity *= 2f; - num3 = num126; + inc = k; } } } diff --git a/Projectiles/Magic/FlareBoltProjectile.cs b/Projectiles/Magic/FlareBoltProjectile.cs index 2fb1353dc1..9b0232fb20 100644 --- a/Projectiles/Magic/FlareBoltProjectile.cs +++ b/Projectiles/Magic/FlareBoltProjectile.cs @@ -37,23 +37,23 @@ namespace CalamityMod.Projectiles.Magic Projectile.alpha = 0; } Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.45f / 255f, (255 - Projectile.alpha) * 0.2f / 255f, (255 - Projectile.alpha) * 0.1f / 255f); - for (int num92 = 0; num92 < 2; num92++) + for (int i = 0; i < 2; i++) { - float num93 = Projectile.velocity.X / 3f * (float)num92; - float num94 = Projectile.velocity.Y / 3f * (float)num92; - int num95 = 4; - int fireDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)num95, Projectile.position.Y + (float)num95), Projectile.width - num95 * 2, Projectile.height - num95 * 2, 174, 0f, 0f, 100, default, 1.2f); + float shortXVel = Projectile.velocity.X / 3f * (float)i; + float shortYVel = Projectile.velocity.Y / 3f * (float)i; + int fourConst = 4; + int fireDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)fourConst, Projectile.position.Y + (float)fourConst), Projectile.width - fourConst * 2, Projectile.height - fourConst * 2, 174, 0f, 0f, 100, default, 1.2f); Dust dust = Main.dust[fireDust]; dust.noGravity = true; dust.velocity *= 0.1f; dust.velocity += Projectile.velocity * 0.1f; - dust.position.X -= num93; - dust.position.Y -= num94; + dust.position.X -= shortXVel; + dust.position.Y -= shortYVel; } if (Main.rand.NextBool(10)) { - int num97 = 4; - int fireDustSmol = Dust.NewDust(new Vector2(Projectile.position.X + (float)num97, Projectile.position.Y + (float)num97), Projectile.width - num97 * 2, Projectile.height - num97 * 2, 174, 0f, 0f, 100, default, 0.6f); + int otherFourConst = 4; + int fireDustSmol = Dust.NewDust(new Vector2(Projectile.position.X + (float)otherFourConst, Projectile.position.Y + (float)otherFourConst), Projectile.width - otherFourConst * 2, Projectile.height - otherFourConst * 2, 174, 0f, 0f, 100, default, 0.6f); Main.dust[fireDustSmol].velocity *= 0.25f; Main.dust[fireDustSmol].velocity += Projectile.velocity * 0.5f; } diff --git a/Projectiles/Magic/ForbiddenSunProjectile.cs b/Projectiles/Magic/ForbiddenSunProjectile.cs index c2fe1d1929..6f673e29b3 100644 --- a/Projectiles/Magic/ForbiddenSunProjectile.cs +++ b/Projectiles/Magic/ForbiddenSunProjectile.cs @@ -48,9 +48,9 @@ namespace CalamityMod.Projectiles.Magic } if (Main.rand.NextBool(4)) { - int num469 = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, Main.rand.NextBool(3) ? 16 : 174, 0f, 0f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int forbid = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, Main.rand.NextBool(3) ? 16 : 174, 0f, 0f); + Main.dust[forbid].noGravity = true; + Main.dust[forbid].velocity *= 0f; } } diff --git a/Projectiles/Magic/ForbiddenSunburst.cs b/Projectiles/Magic/ForbiddenSunburst.cs index 1930749d84..5db1149a09 100644 --- a/Projectiles/Magic/ForbiddenSunburst.cs +++ b/Projectiles/Magic/ForbiddenSunburst.cs @@ -38,38 +38,38 @@ namespace CalamityMod.Projectiles.Magic SoundEngine.PlaySound(SoundID.Item20, Projectile.position); Projectile.localAI[0] += 1f; } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-25, 26); - float num464 = (float)Main.rand.Next(-25, 26); - float num465 = (float)Main.rand.Next(9, 24); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 55, 0f, 0f, 100, default, 2.5f); - Dust dust = Main.dust[num467]; + float rando1 = (float)Main.rand.Next(-25, 26); + float rando2 = (float)Main.rand.Next(-25, 26); + float rando3 = (float)Main.rand.Next(9, 24); + float randoAdjuster = (float)Math.Sqrt((double)(rando1 * rando1 + rando2 * rando2)); + randoAdjuster = rando3 / randoAdjuster; + rando1 *= randoAdjuster; + rando2 *= randoAdjuster; + int orngDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 55, 0f, 0f, 100, default, 2.5f); + Dust dust = Main.dust[orngDust]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = rando1; + dust.velocity.Y = rando2; + timerCounter++; } } diff --git a/Projectiles/Magic/FrigidflashBoltProjectile.cs b/Projectiles/Magic/FrigidflashBoltProjectile.cs index eb61c29906..8949b8a4b5 100644 --- a/Projectiles/Magic/FrigidflashBoltProjectile.cs +++ b/Projectiles/Magic/FrigidflashBoltProjectile.cs @@ -37,43 +37,43 @@ namespace CalamityMod.Projectiles.Magic Projectile.alpha = 0; } Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0.25f / 255f); - for (int num92 = 0; num92 < 2; num92++) + for (int i = 0; i < 2; i++) { - float num93 = Projectile.velocity.X / 3f * (float)num92; - float num94 = Projectile.velocity.Y / 3f * (float)num92; - int num95 = 4; - int fireDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)num95, Projectile.position.Y + (float)num95), Projectile.width - num95 * 2, Projectile.height - num95 * 2, 174, 0f, 0f, 100, default, 1.2f); + float shortXVel = Projectile.velocity.X / 3f * (float)i; + float shortYVel = Projectile.velocity.Y / 3f * (float)i; + int fourConst = 4; + int fireDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)fourConst, Projectile.position.Y + (float)fourConst), Projectile.width - fourConst * 2, Projectile.height - fourConst * 2, 174, 0f, 0f, 100, default, 1.2f); Dust dust = Main.dust[fireDust]; dust.noGravity = true; dust.velocity *= 0.1f; dust.velocity += Projectile.velocity * 0.1f; - dust.position.X -= num93; - dust.position.Y -= num94; + dust.position.X -= shortXVel; + dust.position.Y -= shortYVel; } if (Main.rand.NextBool(10)) { - int num97 = 4; - int fireDustSmol = Dust.NewDust(new Vector2(Projectile.position.X + (float)num97, Projectile.position.Y + (float)num97), Projectile.width - num97 * 2, Projectile.height - num97 * 2, 174, 0f, 0f, 100, default, 0.6f); + int otherFourConst = 4; + int fireDustSmol = Dust.NewDust(new Vector2(Projectile.position.X + (float)otherFourConst, Projectile.position.Y + (float)otherFourConst), Projectile.width - otherFourConst * 2, Projectile.height - otherFourConst * 2, 174, 0f, 0f, 100, default, 0.6f); Main.dust[fireDustSmol].velocity *= 0.25f; Main.dust[fireDustSmol].velocity += Projectile.velocity * 0.5f; } - for (int num105 = 0; num105 < 2; num105++) + for (int j = 0; j < 2; j++) { - float num99 = Projectile.velocity.X / 3f * (float)num105; - float num100 = Projectile.velocity.Y / 3f * (float)num105; - int num101 = 4; - int frostDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)num101, Projectile.position.Y + (float)num101), Projectile.width - num101 * 2, Projectile.height - num101 * 2, 92, 0f, 0f, 100, default, 1.2f); + float shortyX = Projectile.velocity.X / 3f * (float)j; + float shortyY = Projectile.velocity.Y / 3f * (float)j; + int itsAFour = 4; + int frostDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)itsAFour, Projectile.position.Y + (float)itsAFour), Projectile.width - itsAFour * 2, Projectile.height - itsAFour * 2, 92, 0f, 0f, 100, default, 1.2f); Dust dust = Main.dust[frostDust]; dust.noGravity = true; dust.velocity *= 0.1f; dust.velocity += Projectile.velocity * 0.1f; - dust.position.X -= num99; - dust.position.Y -= num100; + dust.position.X -= shortyX; + dust.position.Y -= shortyY; } if (Main.rand.NextBool(10)) { - int num103 = 4; - int frostDustSmol = Dust.NewDust(new Vector2(Projectile.position.X + (float)num103, Projectile.position.Y + (float)num103), Projectile.width - num103 * 2, Projectile.height - num103 * 2, 92, 0f, 0f, 100, default, 0.6f); + int itsStillAFour = 4; + int frostDustSmol = Dust.NewDust(new Vector2(Projectile.position.X + (float)itsStillAFour, Projectile.position.Y + (float)itsStillAFour), Projectile.width - itsStillAFour * 2, Projectile.height - itsStillAFour * 2, 92, 0f, 0f, 100, default, 0.6f); Main.dust[frostDustSmol].velocity *= 0.25f; Main.dust[frostDustSmol].velocity += Projectile.velocity * 0.5f; } diff --git a/Projectiles/Magic/FrostBoltProjectile.cs b/Projectiles/Magic/FrostBoltProjectile.cs index 908408dd8a..3c0d3e3678 100644 --- a/Projectiles/Magic/FrostBoltProjectile.cs +++ b/Projectiles/Magic/FrostBoltProjectile.cs @@ -38,23 +38,23 @@ namespace CalamityMod.Projectiles.Magic Projectile.alpha = 0; } Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.01f / 255f, (255 - Projectile.alpha) * 0.3f / 255f, (255 - Projectile.alpha) * 0.45f / 255f); - for (int num105 = 0; num105 < 2; num105++) + for (int i = 0; i < 2; i++) { - float num99 = Projectile.velocity.X / 3f * (float)num105; - float num100 = Projectile.velocity.Y / 3f * (float)num105; - int num101 = 4; - int frostDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)num101, Projectile.position.Y + (float)num101), Projectile.width - num101 * 2, Projectile.height - num101 * 2, 92, 0f, 0f, 100, default, 1.2f); + float shortXVel = Projectile.velocity.X / 3f * (float)i; + float shortYVel = Projectile.velocity.Y / 3f * (float)i; + int fourConst = 4; + int frostDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)fourConst, Projectile.position.Y + (float)fourConst), Projectile.width - fourConst * 2, Projectile.height - fourConst * 2, 92, 0f, 0f, 100, default, 1.2f); Dust dust = Main.dust[frostDust]; dust.noGravity = true; dust.velocity *= 0.1f; dust.velocity += Projectile.velocity * 0.1f; - dust.position.X -= num99; - dust.position.Y -= num100; + dust.position.X -= shortXVel; + dust.position.Y -= shortYVel; } if (Main.rand.NextBool(10)) { - int num103 = 4; - int frostDustSmol = Dust.NewDust(new Vector2(Projectile.position.X + (float)num103, Projectile.position.Y + (float)num103), Projectile.width - num103 * 2, Projectile.height - num103 * 2, 92, 0f, 0f, 100, default, 0.6f); + int otherFourConst = 4; + int frostDustSmol = Dust.NewDust(new Vector2(Projectile.position.X + (float)otherFourConst, Projectile.position.Y + (float)otherFourConst), Projectile.width - otherFourConst * 2, Projectile.height - otherFourConst * 2, 92, 0f, 0f, 100, default, 0.6f); Main.dust[frostDustSmol].velocity *= 0.25f; Main.dust[frostDustSmol].velocity += Projectile.velocity * 0.5f; } diff --git a/Projectiles/Magic/GhastlyBlast.cs b/Projectiles/Magic/GhastlyBlast.cs index 0cec3b9bf0..e14eaeca67 100644 --- a/Projectiles/Magic/GhastlyBlast.cs +++ b/Projectiles/Magic/GhastlyBlast.cs @@ -59,24 +59,24 @@ namespace CalamityMod.Projectiles.Magic if (Main.rand.NextBool()) { Vector2 vector140 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - Dust dust28 = Main.dust[Dust.NewDust(Projectile.Center - vector140 * 30f, 0, 0, 60, 0f, 0f, 0, default, 1f)]; - dust28.noGravity = true; - dust28.position = Projectile.Center - vector140 * Main.rand.Next(10, 21); - dust28.velocity = vector140.RotatedBy(MathHelper.PiOver2) * 6f; - dust28.scale = 0.5f + Main.rand.NextFloat(); - dust28.fadeIn = 0.5f; - dust28.customData = Projectile; + Dust ghostlyRed = Main.dust[Dust.NewDust(Projectile.Center - vector140 * 30f, 0, 0, 60, 0f, 0f, 0, default, 1f)]; + ghostlyRed.noGravity = true; + ghostlyRed.position = Projectile.Center - vector140 * Main.rand.Next(10, 21); + ghostlyRed.velocity = vector140.RotatedBy(MathHelper.PiOver2) * 6f; + ghostlyRed.scale = 0.5f + Main.rand.NextFloat(); + ghostlyRed.fadeIn = 0.5f; + ghostlyRed.customData = Projectile; } else { Vector2 vector141 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - Dust dust29 = Main.dust[Dust.NewDust(Projectile.Center - vector141 * 30f, 0, 0, 60, 0f, 0f, 0, default, 1f)]; - dust29.noGravity = true; - dust29.position = Projectile.Center - vector141 * 30f; - dust29.velocity = vector141.RotatedBy(-MathHelper.PiOver2) * 3f; - dust29.scale = 0.5f + Main.rand.NextFloat(); - dust29.fadeIn = 0.5f; - dust29.customData = Projectile; + Dust ghostlyRedder = Main.dust[Dust.NewDust(Projectile.Center - vector141 * 30f, 0, 0, 60, 0f, 0f, 0, default, 1f)]; + ghostlyRedder.noGravity = true; + ghostlyRedder.position = Projectile.Center - vector141 * 30f; + ghostlyRedder.velocity = vector141.RotatedBy(-MathHelper.PiOver2) * 3f; + ghostlyRedder.scale = 0.5f + Main.rand.NextFloat(); + ghostlyRedder.fadeIn = 0.5f; + ghostlyRedder.customData = Projectile; } } @@ -108,106 +108,107 @@ namespace CalamityMod.Projectiles.Magic Projectile.rotation -= 0.104719758f; // Excessively complicated dust - int num3; - for (int num1014 = 0; num1014 < 1; num1014 = num3 + 1) + int inc; + for (int i = 0; i < 1; i = inc + 1) { if (Main.rand.NextBool()) { - Vector2 vector142 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - Dust dust30 = Main.dust[Dust.NewDust(Projectile.Center - vector142 * 30f, 0, 0, 60, 0f, 0f, 0, default, 1f)]; - dust30.noGravity = true; - dust30.position = Projectile.Center - vector142 * Main.rand.Next(10, 21); - dust30.velocity = vector142.RotatedBy(MathHelper.PiOver2) * 6f; - dust30.scale = 0.9f + Main.rand.NextFloat(); - dust30.fadeIn = 0.5f; - dust30.customData = Projectile; - vector142 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - dust30.noGravity = true; - dust30.position = Projectile.Center - vector142 * Main.rand.Next(10, 21); - dust30.velocity = vector142.RotatedBy(MathHelper.PiOver2) * 6f; - dust30.scale = 0.9f + Main.rand.NextFloat(); - dust30.fadeIn = 0.5f; - dust30.customData = Projectile; - dust30.color = Color.Crimson; + Vector2 dustRotate = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + Dust complexDust = Main.dust[Dust.NewDust(Projectile.Center - dustRotate * 30f, 0, 0, 60, 0f, 0f, 0, default, 1f)]; + complexDust.noGravity = true; + complexDust.position = Projectile.Center - dustRotate * Main.rand.Next(10, 21); + complexDust.velocity = dustRotate.RotatedBy(MathHelper.PiOver2) * 6f; + complexDust.scale = 0.9f + Main.rand.NextFloat(); + complexDust.fadeIn = 0.5f; + complexDust.customData = Projectile; + dustRotate = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + complexDust.noGravity = true; + complexDust.position = Projectile.Center - dustRotate * Main.rand.Next(10, 21); + complexDust.velocity = dustRotate.RotatedBy(MathHelper.PiOver2) * 6f; + complexDust.scale = 0.9f + Main.rand.NextFloat(); + complexDust.fadeIn = 0.5f; + complexDust.customData = Projectile; + complexDust.color = Color.Crimson; } else { - Vector2 vector143 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - Dust dust31 = Main.dust[Dust.NewDust(Projectile.Center - vector143 * 30f, 0, 0, 60, 0f, 0f, 0, default, 1f)]; - dust31.noGravity = true; - dust31.position = Projectile.Center - vector143 * Main.rand.Next(20, 31); - dust31.velocity = vector143.RotatedBy(-MathHelper.PiOver2) * 5f; - dust31.scale = 0.9f + Main.rand.NextFloat(); - dust31.fadeIn = 0.5f; - dust31.customData = Projectile; + Vector2 moreDustRotate = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + Dust complicatedDust = Main.dust[Dust.NewDust(Projectile.Center - moreDustRotate * 30f, 0, 0, 60, 0f, 0f, 0, default, 1f)]; + complicatedDust.noGravity = true; + complicatedDust.position = Projectile.Center - moreDustRotate * Main.rand.Next(20, 31); + complicatedDust.velocity = moreDustRotate.RotatedBy(-MathHelper.PiOver2) * 5f; + complicatedDust.scale = 0.9f + Main.rand.NextFloat(); + complicatedDust.fadeIn = 0.5f; + complicatedDust.customData = Projectile; } - num3 = num1014; + inc = i; } // Every so many frames, spawn a sub blast. if (Projectile.ai[0] % 30f == 0f && Projectile.ai[0] < 241f && Main.myPlayer == Projectile.owner) { - Vector2 vector144 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * 12f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, vector144.X, vector144.Y, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner, 0f, Projectile.whoAmI); + Vector2 randomSubBlastOffset = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * 12f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, randomSubBlastOffset.X, randomSubBlastOffset.Y, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner, 0f, Projectile.whoAmI); } // Undocumented, unrefactored homing. Will not home through walls. // Apparently has two different homing distances. - Vector2 vector145 = Projectile.Center; - float num1015 = 500f; - bool flag59 = false; - int num1016 = 0; + // ^ See, this is why num variables are EVIL.... -CIT + Vector2 projCenter = Projectile.Center; + float homingRange = 500f; + bool isHoming = false; + int npcTracker = 0; if (Projectile.ai[1] == 0f) { - for (int num1017 = 0; num1017 < Main.maxNPCs; num1017 = num3 + 1) + for (int i = 0; i < Main.maxNPCs; i = inc + 1) { - if (Main.npc[num1017].CanBeChasedBy(Projectile, false)) + if (Main.npc[i].CanBeChasedBy(Projectile, false)) { - Vector2 center13 = Main.npc[num1017].Center; - if (Projectile.Distance(center13) < num1015 && Collision.CanHit(new Vector2(Projectile.position.X + (float)(Projectile.width / 2), Projectile.position.Y + (float)(Projectile.height / 2)), 1, 1, Main.npc[num1017].position, Main.npc[num1017].width, Main.npc[num1017].height)) + Vector2 npcCenter = Main.npc[i].Center; + if (Projectile.Distance(npcCenter) < homingRange && Collision.CanHit(new Vector2(Projectile.position.X + (float)(Projectile.width / 2), Projectile.position.Y + (float)(Projectile.height / 2)), 1, 1, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height)) { - num1015 = Projectile.Distance(center13); - vector145 = center13; - flag59 = true; - num1016 = num1017; + homingRange = Projectile.Distance(npcCenter); + projCenter = npcCenter; + isHoming = true; + npcTracker = i; } } - num3 = num1017; + inc = i; } - if (flag59) + if (isHoming) { - if (Projectile.ai[1] != (float)(num1016 + 1)) + if (Projectile.ai[1] != (float)(npcTracker + 1)) { Projectile.netUpdate = true; } - Projectile.ai[1] = (float)(num1016 + 1); + Projectile.ai[1] = (float)(npcTracker + 1); } - flag59 = false; + isHoming = false; } if (Projectile.ai[1] != 0f) { - int num1018 = (int)(Projectile.ai[1] - 1f); - if (Main.npc[num1018].active && Main.npc[num1018].CanBeChasedBy(Projectile, true) && Projectile.Distance(Main.npc[num1018].Center) < 1000f) + int target = (int)(Projectile.ai[1] - 1f); + if (Main.npc[target].active && Main.npc[target].CanBeChasedBy(Projectile, true) && Projectile.Distance(Main.npc[target].Center) < 1000f) { - flag59 = true; - vector145 = Main.npc[num1018].Center; + isHoming = true; + projCenter = Main.npc[target].Center; } } if (!Projectile.friendly) { - flag59 = false; + isHoming = false; } if (Projectile.localAI[0] < 60f) { Projectile.localAI[0] += 1f; } - if (flag59 && Projectile.localAI[0] >= 60f) + if (isHoming && Projectile.localAI[0] >= 60f) { float HomingVelocity = 24f; int HomingN = 8; - Vector2 vector146 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float dx = vector145.X - vector146.X; - float dy = vector145.Y - vector146.Y; + Vector2 projDistance = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float dx = projCenter.X - projDistance.X; + float dy = projCenter.Y - projDistance.Y; float dist = (float)Math.Sqrt((double)(dx * dx + dy * dy)); dist = HomingVelocity / dist; dx *= dist; @@ -250,89 +251,87 @@ namespace CalamityMod.Projectiles.Magic Projectile.Damage(); SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - for (int num95 = 0; num95 < 4; num95++) + for (int i = 0; i < 4; i++) { - int num96 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.5f); - Main.dust[num96].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + int killRed = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.5f); + Main.dust[killRed].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; } - for (int num97 = 0; num97 < 30; num97++) + for (int j = 0; j < 30; j++) { - int num98 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 200, default, 3.7f); - Dust dust = Main.dust[num98]; + int killRed2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 200, default, 3.7f); + Dust dust = Main.dust[killRed2]; dust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; dust.noGravity = true; dust.velocity *= 3f; - num98 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.5f); + killRed2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.5f); dust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; dust.velocity *= 2f; dust.noGravity = true; dust.fadeIn = 1f; dust.color = Color.Crimson * 0.5f; } - for (int num99 = 0; num99 < 10; num99++) + for (int k = 0; k < 10; k++) { - int num100 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 0, default, 2.7f); - Dust dust = Main.dust[num100]; + int killRed3 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 0, default, 2.7f); + Dust dust = Main.dust[killRed3]; dust.position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 2f; dust.noGravity = true; dust.velocity *= 3f; } - for (int num101 = 0; num101 < 10; num101++) + for (int l = 0; l < 10; l++) { - int num102 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 0, default, 1.5f); - Dust dust = Main.dust[num102]; + int killRed4 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 0, default, 1.5f); + Dust dust = Main.dust[killRed4]; dust.position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 2f; dust.noGravity = true; dust.velocity *= 3f; } if (Main.myPlayer == Projectile.owner) { - for (int num105 = 0; num105 < Main.maxProjectiles; num105++) + for (int numSubBlasts = 0; numSubBlasts < Main.maxProjectiles; numSubBlasts++) { - if (Main.projectile[num105].active && Main.projectile[num105].type == ModContent.ProjectileType() && Main.projectile[num105].ai[1] == Projectile.whoAmI) + if (Main.projectile[numSubBlasts].active && Main.projectile[numSubBlasts].type == ModContent.ProjectileType() && Main.projectile[numSubBlasts].ai[1] == Projectile.whoAmI) { - Main.projectile[num105].Kill(); + Main.projectile[numSubBlasts].Kill(); } } - int num106 = 5; - int num107 = 5; - int num108 = Utils.SelectRandom(Main.rand, new int[] + int dustType = Utils.SelectRandom(Main.rand, new int[] { 60, 180 }); - int num109 = (num108 == 60) ? 180 : 60; - for (int num110 = 0; num110 < num106; num110++) + int subBlastAI = (dustType == 60) ? 180 : 60; + for (int r = 0; r < 5; r++) { - Vector2 vector4 = Projectile.Center + Utils.RandomVector2(Main.rand, -30f, 30f); - Vector2 vector5 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - while (vector5.X == 0f && vector5.Y == 0f) + Vector2 randShardRotate = Projectile.Center + Utils.RandomVector2(Main.rand, -30f, 30f); + Vector2 randShardVel = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + while (randShardVel.X == 0f && randShardVel.Y == 0f) { - vector5 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + randShardVel = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); } - vector5.Normalize(); - if (vector5.Y > 0.2f) + randShardVel.Normalize(); + if (randShardVel.Y > 0.2f) { - vector5.Y *= -1f; + randShardVel.Y *= -1f; } - vector5 *= Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), vector4.X, vector4.Y, vector5.X, vector5.Y, ModContent.ProjectileType(), (int)(Projectile.damage * 0.8), Projectile.knockBack * 0.8f, Projectile.owner, num108, 0f); + randShardVel *= Main.rand.Next(70, 101) * 0.1f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), randShardRotate.X, randShardRotate.Y, randShardVel.X, randShardVel.Y, ModContent.ProjectileType(), (int)(Projectile.damage * 0.8), Projectile.knockBack * 0.8f, Projectile.owner, dustType, 0f); } - for (int num111 = 0; num111 < num107; num111++) + for (int s = 0; s < 5; s++) { - Vector2 vector6 = Projectile.Center + Utils.RandomVector2(Main.rand, -30f, 30f); - Vector2 vector7 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - while (vector7.X == 0f && vector7.Y == 0f) + Vector2 randExplodeRotate = Projectile.Center + Utils.RandomVector2(Main.rand, -30f, 30f); + Vector2 randExplodeVel = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + while (randExplodeVel.X == 0f && randExplodeVel.Y == 0f) { - vector7 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + randExplodeVel = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); } - vector7.Normalize(); - if (vector7.Y > 0.4f) + randExplodeVel.Normalize(); + if (randExplodeVel.Y > 0.4f) { - vector7.Y *= -1f; + randExplodeVel.Y *= -1f; } - vector7 *= Main.rand.Next(40, 81) * 0.1f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), vector6.X, vector6.Y, vector7.X, vector7.Y, ModContent.ProjectileType(), (int)(Projectile.damage * 0.8), Projectile.knockBack * 0.8f, Projectile.owner, num109, 0f); + randExplodeVel *= Main.rand.Next(40, 81) * 0.1f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), randExplodeRotate.X, randExplodeRotate.Y, randExplodeVel.X, randExplodeVel.Y, ModContent.ProjectileType(), (int)(Projectile.damage * 0.8), Projectile.knockBack * 0.8f, Projectile.owner, subBlastAI, 0f); } } } diff --git a/Projectiles/Magic/GhastlyExplosion.cs b/Projectiles/Magic/GhastlyExplosion.cs index b746faa7a2..265bd0bd31 100644 --- a/Projectiles/Magic/GhastlyExplosion.cs +++ b/Projectiles/Magic/GhastlyExplosion.cs @@ -23,33 +23,33 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - int num3; - int num328 = (int)Projectile.ai[0]; - for (int num329 = 0; num329 < 3; num329 = num3 + 1) + int inc; + int dustType = (int)Projectile.ai[0]; + for (int i = 0; i < 3; i = inc + 1) { - int num330 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, Projectile.velocity.X, Projectile.velocity.Y, num328, default, 1.2f); - Main.dust[num330].position = (Main.dust[num330].position + Projectile.Center) / 2f; - Main.dust[num330].noGravity = true; - Dust dust = Main.dust[num330]; + int ghostlyRed = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, Projectile.velocity.X, Projectile.velocity.Y, dustType, default, 1.2f); + Main.dust[ghostlyRed].position = (Main.dust[ghostlyRed].position + Projectile.Center) / 2f; + Main.dust[ghostlyRed].noGravity = true; + Dust dust = Main.dust[ghostlyRed]; dust.velocity *= 0.5f; - num3 = num329; + inc = i; } - for (int num331 = 0; num331 < 2; num331 = num3 + 1) + for (int j = 0; j < 2; j = inc + 1) { - int num330 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, Projectile.velocity.X, Projectile.velocity.Y, num328, default, 0.4f); - if (num331 == 0) + int ghostlyRed = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, Projectile.velocity.X, Projectile.velocity.Y, dustType, default, 0.4f); + if (j == 0) { - Main.dust[num330].position = (Main.dust[num330].position + Projectile.Center * 5f) / 6f; + Main.dust[ghostlyRed].position = (Main.dust[ghostlyRed].position + Projectile.Center * 5f) / 6f; } - else if (num331 == 1) + else if (j == 1) { - Main.dust[num330].position = (Main.dust[num330].position + (Projectile.Center + Projectile.velocity / 2f) * 5f) / 6f; + Main.dust[ghostlyRed].position = (Main.dust[ghostlyRed].position + (Projectile.Center + Projectile.velocity / 2f) * 5f) / 6f; } - Dust dust = Main.dust[num330]; + Dust dust = Main.dust[ghostlyRed]; dust.velocity *= 0.1f; - Main.dust[num330].noGravity = true; - Main.dust[num330].fadeIn = 1f; - num3 = num331; + Main.dust[ghostlyRed].noGravity = true; + Main.dust[ghostlyRed].fadeIn = 1f; + inc = j; } return; } @@ -57,33 +57,32 @@ namespace CalamityMod.Projectiles.Magic public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item50, Projectile.position); - int num3; - for (int num116 = 0; num116 < 20; num116 = num3 + 1) + int inc; + for (int i = 0; i < 20; i = inc + 1) { - int num117 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)Projectile.ai[0], Projectile.velocity.X * 0.1f, Projectile.velocity.Y * 0.1f, 0, default, 0.5f); + int killDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)Projectile.ai[0], Projectile.velocity.X * 0.1f, Projectile.velocity.Y * 0.1f, 0, default, 0.5f); Dust dust; - Main.dust[num117].scale = 1.2f + (float)Main.rand.Next(-10, 11) * 0.01f; - Main.dust[num117].noGravity = true; - dust = Main.dust[num117]; + Main.dust[killDust].scale = 1.2f + (float)Main.rand.Next(-10, 11) * 0.01f; + Main.dust[killDust].noGravity = true; + dust = Main.dust[killDust]; dust.velocity *= 2.5f; - dust = Main.dust[num117]; + dust = Main.dust[killDust]; dust.velocity -= Projectile.oldVelocity / 10f; - num3 = num116; + inc = i; } if (Main.myPlayer == Projectile.owner) { - int num118 = 3; - for (int num119 = 0; num119 < num118; num119 = num3 + 1) + for (int j = 0; j < 3; j = inc + 1) { - Vector2 vector8 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (vector8.X == 0f && vector8.Y == 0f) + Vector2 randShardRotation = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + while (randShardRotation.X == 0f && randShardRotation.Y == 0f) { - vector8 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + randShardRotation = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); } - vector8.Normalize(); - vector8 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.oldPosition.X + (float)(Projectile.width / 2), Projectile.oldPosition.Y + (float)(Projectile.height / 2), vector8.X, vector8.Y, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.8), Projectile.knockBack * 0.8f, Projectile.owner, Projectile.ai[0], 0f); - num3 = num119; + randShardRotation.Normalize(); + randShardRotation *= (float)Main.rand.Next(70, 101) * 0.1f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.oldPosition.X + (float)(Projectile.width / 2), Projectile.oldPosition.Y + (float)(Projectile.height / 2), randShardRotation.X, randShardRotation.Y, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.8), Projectile.knockBack * 0.8f, Projectile.owner, Projectile.ai[0], 0f); + inc = j; } } } diff --git a/Projectiles/Magic/GhastlyExplosionShard.cs b/Projectiles/Magic/GhastlyExplosionShard.cs index f65b51b6fa..2542eb568f 100644 --- a/Projectiles/Magic/GhastlyExplosionShard.cs +++ b/Projectiles/Magic/GhastlyExplosionShard.cs @@ -24,10 +24,10 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - int num332 = (int)Projectile.ai[0]; + int dustType = (int)Projectile.ai[0]; Projectile.ai[1] += 1f; - float num333 = (120f - Projectile.ai[1]) / 120f; + float dustScale = (120f - Projectile.ai[1]) / 120f; if (Projectile.ai[1] > 120f) Projectile.Kill(); @@ -37,30 +37,30 @@ namespace CalamityMod.Projectiles.Magic Projectile.velocity.X *= 0.98f; - int num3; - for (int num334 = 0; num334 < 2; num334 = num3 + 1) + int inc; + for (int i = 0; i < 2; i = inc + 1) { - int num335 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num332, Projectile.velocity.X, Projectile.velocity.Y, 50, default, 1.1f); - Main.dust[num335].position = (Main.dust[num335].position + Projectile.Center) / 2f; - Main.dust[num335].noGravity = true; - Dust dust = Main.dust[num335]; + int explodeDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, Projectile.velocity.X, Projectile.velocity.Y, 50, default, 1.1f); + Main.dust[explodeDust].position = (Main.dust[explodeDust].position + Projectile.Center) / 2f; + Main.dust[explodeDust].noGravity = true; + Dust dust = Main.dust[explodeDust]; dust.velocity *= 0.3f; - dust = Main.dust[num335]; - dust.scale *= num333; - num3 = num334; + dust = Main.dust[explodeDust]; + dust.scale *= dustScale; + inc = i; } - for (int num336 = 0; num336 < 1; num336 = num3 + 1) + for (int j = 0; j < 1; j = inc + 1) { - int num335 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num332, Projectile.velocity.X, Projectile.velocity.Y, 50, default, 0.6f); - Main.dust[num335].position = (Main.dust[num335].position + Projectile.Center * 5f) / 6f; - Dust dust = Main.dust[num335]; + int explodeDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, Projectile.velocity.X, Projectile.velocity.Y, 50, default, 0.6f); + Main.dust[explodeDust].position = (Main.dust[explodeDust].position + Projectile.Center * 5f) / 6f; + Dust dust = Main.dust[explodeDust]; dust.velocity *= 0.1f; - Main.dust[num335].noGravity = true; - Main.dust[num335].fadeIn = 0.9f * num333; - dust = Main.dust[num335]; - dust.scale *= num333; - num3 = num336; + Main.dust[explodeDust].noGravity = true; + Main.dust[explodeDust].fadeIn = 0.9f * dustScale; + dust = Main.dust[explodeDust]; + dust.scale *= dustScale; + inc = j; } if (Projectile.timeLeft < 90) @@ -69,18 +69,18 @@ namespace CalamityMod.Projectiles.Magic public override void OnKill(int timeLeft) { - int num3; - for (int num114 = 0; num114 < 10; num114 = num3 + 1) + int inc; + for (int i = 0; i < 10; i = inc + 1) { - int num115 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)Projectile.ai[0], Projectile.velocity.X * 0.1f, Projectile.velocity.Y * 0.1f, 0, default, 0.5f); + int killDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)Projectile.ai[0], Projectile.velocity.X * 0.1f, Projectile.velocity.Y * 0.1f, 0, default, 0.5f); Dust dust; - Main.dust[num115].scale = 1f + Main.rand.Next(-10, 11) * 0.01f; - Main.dust[num115].noGravity = true; - dust = Main.dust[num115]; + Main.dust[killDust].scale = 1f + Main.rand.Next(-10, 11) * 0.01f; + Main.dust[killDust].noGravity = true; + dust = Main.dust[killDust]; dust.velocity *= 1.25f; - dust = Main.dust[num115]; + dust = Main.dust[killDust]; dust.velocity -= Projectile.oldVelocity / 10f; - num3 = num114; + inc = i; } } } diff --git a/Projectiles/Magic/GhastlySubBlast.cs b/Projectiles/Magic/GhastlySubBlast.cs index 2a506ec8a6..56147fae13 100644 --- a/Projectiles/Magic/GhastlySubBlast.cs +++ b/Projectiles/Magic/GhastlySubBlast.cs @@ -23,17 +23,14 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - bool flag60 = false; - bool flag61 = false; - int num3 = Projectile.type; - int num1024 = ModContent.ProjectileType(); - float num1025 = 420f; + bool unusedBool = false; // yeah idk -CIT + int projType = ModContent.ProjectileType(); float x3 = 0.15f; float y3 = 0.15f; - if (flag61) + if (unusedBool) { - int num1026 = (int)Projectile.ai[1]; - if (!Main.projectile[num1026].active || Main.projectile[num1026].type != num1024) + int projID = (int)Projectile.ai[1]; + if (!Main.projectile[projID].active || Main.projectile[projID].type != projType) { Projectile.Kill(); return; @@ -41,15 +38,15 @@ namespace CalamityMod.Projectiles.Magic Projectile.timeLeft = 2; } Projectile.ai[0] += 1f; - if (Projectile.ai[0] < num1025) + if (Projectile.ai[0] < 420f) { - bool flag62 = true; - int num1027 = (int)Projectile.ai[1]; - if (Main.projectile[num1027].active && Main.projectile[num1027].type == num1024) + bool isActive = true; + int preHomingProjID = (int)Projectile.ai[1]; + if (Main.projectile[preHomingProjID].active && Main.projectile[preHomingProjID].type == projType) { - if (!flag60 && Main.projectile[num1027].oldPos[1] != Vector2.Zero) + if (Main.projectile[preHomingProjID].oldPos[1] != Vector2.Zero) { - Projectile.position += Main.projectile[num1027].position - Main.projectile[num1027].oldPos[1]; + Projectile.position += Main.projectile[preHomingProjID].position - Main.projectile[preHomingProjID].oldPos[1]; } if (Projectile.Center.HasNaNs()) { @@ -59,13 +56,13 @@ namespace CalamityMod.Projectiles.Magic } else { - Projectile.ai[0] = num1025; - flag62 = false; + Projectile.ai[0] = 420f; + isActive = false; Projectile.Kill(); } - if (flag62 && !flag60) + if (isActive) { - Projectile.velocity += new Vector2((float)Math.Sign(Main.projectile[num1027].Center.X - Projectile.Center.X), (float)Math.Sign(Main.projectile[num1027].Center.Y - Projectile.Center.Y)) * new Vector2(x3, y3); + Projectile.velocity += new Vector2((float)Math.Sign(Main.projectile[preHomingProjID].Center.X - Projectile.Center.X), (float)Math.Sign(Main.projectile[preHomingProjID].Center.Y - Projectile.Center.Y)) * new Vector2(x3, y3); if (Projectile.velocity.Length() > 6f) { Projectile.velocity *= 6f / Projectile.velocity.Length(); @@ -73,14 +70,14 @@ namespace CalamityMod.Projectiles.Magic } if (Main.rand.NextBool()) { - int num1028 = Dust.NewDust(Projectile.Center, 8, 8, 60, 0f, 0f, 0, default, 1f); - Main.dust[num1028].position = Projectile.Center; - Main.dust[num1028].velocity = Projectile.velocity; - Main.dust[num1028].noGravity = true; - Main.dust[num1028].scale = 1.5f; - if (flag62) + int ghostlyRed = Dust.NewDust(Projectile.Center, 8, 8, 60, 0f, 0f, 0, default, 1f); + Main.dust[ghostlyRed].position = Projectile.Center; + Main.dust[ghostlyRed].velocity = Projectile.velocity; + Main.dust[ghostlyRed].noGravity = true; + Main.dust[ghostlyRed].scale = 1.5f; + if (isActive) { - Main.dust[num1028].customData = Main.projectile[(int)Projectile.ai[1]]; + Main.dust[ghostlyRed].customData = Main.projectile[(int)Projectile.ai[1]]; } } Projectile.alpha = 255; @@ -91,15 +88,15 @@ namespace CalamityMod.Projectiles.Magic public override void OnKill(int timeLeft) { Projectile.ai[0] = 60f; - for (int num114 = 0; num114 < 10; num114++) + for (int i = 0; i < 10; i++) { - int num115 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)Projectile.ai[0], Projectile.velocity.X * 0.1f, Projectile.velocity.Y * 0.1f, 0, default, 0.5f); + int killDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)Projectile.ai[0], Projectile.velocity.X * 0.1f, Projectile.velocity.Y * 0.1f, 0, default, 0.5f); Dust dust; - Main.dust[num115].scale = 1f + (float)Main.rand.Next(-10, 11) * 0.01f; - Main.dust[num115].noGravity = true; - dust = Main.dust[num115]; + Main.dust[killDust].scale = 1f + (float)Main.rand.Next(-10, 11) * 0.01f; + Main.dust[killDust].noGravity = true; + dust = Main.dust[killDust]; dust.velocity *= 1.25f; - dust = Main.dust[num115]; + dust = Main.dust[killDust]; dust.velocity -= Projectile.oldVelocity / 10f; } } diff --git a/Projectiles/Magic/GhastlyVisageProj.cs b/Projectiles/Magic/GhastlyVisageProj.cs index 636d0f182c..5ac1b0be89 100644 --- a/Projectiles/Magic/GhastlyVisageProj.cs +++ b/Projectiles/Magic/GhastlyVisageProj.cs @@ -33,11 +33,11 @@ namespace CalamityMod.Projectiles.Magic { Lighting.AddLight(Projectile.Center, 0.65f, 0f, 0.1f); Player player = Main.player[Projectile.owner]; - float num = 0f; - Vector2 vector = player.RotatedRelativePoint(player.MountedCenter, true); + float piConditional = 0f; + Vector2 playerRotate = player.RotatedRelativePoint(player.MountedCenter, true); if (Projectile.spriteDirection == -1) { - num = MathHelper.Pi; + piConditional = MathHelper.Pi; } Projectile.frameCounter++; if (Projectile.frameCounter > 4) @@ -50,25 +50,25 @@ namespace CalamityMod.Projectiles.Magic Projectile.frame = 0; } Projectile.ai[0] += 1f; - int num39 = 0; + int aiSoundDelay = 0; if (Projectile.ai[0] >= 240f) { - num39++; + aiSoundDelay++; } if (Projectile.ai[0] >= 480f) { - num39++; + aiSoundDelay++; } - int num40 = 40; - int num41 = 2; + int soundDelayer = 40; + int soundDelayMult = 2; Projectile.ai[1] -= 1f; - bool flag15 = false; + bool isActive = false; if (Projectile.ai[1] <= 0f) { - Projectile.ai[1] = (float)(num40 - num41 * num39); - flag15 = true; + Projectile.ai[1] = (float)(soundDelayer - soundDelayMult * aiSoundDelay); + isActive = true; } - bool flag16 = player.channel && !player.noItems && !player.CCed; + bool canUseItem = player.channel && !player.noItems && !player.CCed; if (Projectile.localAI[0] > 0f) { Projectile.localAI[0] -= 1f; @@ -89,13 +89,13 @@ namespace CalamityMod.Projectiles.Magic else { Projectile.Kill(); - flag15 = false; + isActive = false; } } else { Projectile.Kill(); - flag15 = false; + isActive = false; } } else @@ -107,12 +107,12 @@ namespace CalamityMod.Projectiles.Magic } } Projectile.localAI[1] += 1f; - Projectile.soundDelay = num40 - num41 * num39; + Projectile.soundDelay = soundDelayer - soundDelayMult * aiSoundDelay; - if (flag15) + if (isActive) SoundEngine.PlaySound(SoundID.Item117, Projectile.position); } - else if (Projectile.soundDelay <= 0 && flag16) + else if (Projectile.soundDelay <= 0 && canUseItem) { if (player.statMana < manaCost) { @@ -127,13 +127,13 @@ namespace CalamityMod.Projectiles.Magic else { Projectile.Kill(); - flag15 = false; + isActive = false; } } else { Projectile.Kill(); - flag15 = false; + isActive = false; } } else @@ -144,47 +144,46 @@ namespace CalamityMod.Projectiles.Magic player.manaRegenDelay = (int)player.maxRegenDelay; } } - Projectile.soundDelay = num40 - num41 * num39; - if (Projectile.ai[0] != 1f && flag15) + Projectile.soundDelay = soundDelayer - soundDelayMult * aiSoundDelay; + if (Projectile.ai[0] != 1f && isActive) { SoundEngine.PlaySound(SoundID.Item117, Projectile.position); } Projectile.localAI[0] = 12f; } - if (flag15 && Main.myPlayer == Projectile.owner) + if (isActive && Main.myPlayer == Projectile.owner) { - int num42 = ModContent.ProjectileType(); float coreVelocity = 11.5f; int weaponDamage2 = player.GetWeaponDamage(player.ActiveItem()); float weaponKnockback2 = player.ActiveItem().knockBack; - if (flag16) + if (canUseItem) { weaponKnockback2 = player.GetWeaponKnockback(player.ActiveItem(), weaponKnockback2); float scaleFactor12 = player.ActiveItem().shootSpeed * Projectile.scale; - Vector2 vector19 = vector; - Vector2 value18 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - vector19; + Vector2 playerRotateCopy = playerRotate; + Vector2 projSpawnDirection = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - playerRotateCopy; if (player.gravDir == -1f) { - value18.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - vector19.Y; + projSpawnDirection.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - playerRotateCopy.Y; } - Vector2 value19 = Vector2.Normalize(value18); - if (float.IsNaN(value19.X) || float.IsNaN(value19.Y)) + Vector2 projSpawnDirectNormalize = Vector2.Normalize(projSpawnDirection); + if (float.IsNaN(projSpawnDirectNormalize.X) || float.IsNaN(projSpawnDirectNormalize.Y)) { - value19 = -Vector2.UnitY; + projSpawnDirectNormalize = -Vector2.UnitY; } - value19 *= scaleFactor12; - if (value19.X != Projectile.velocity.X || value19.Y != Projectile.velocity.Y) + projSpawnDirectNormalize *= scaleFactor12; + if (projSpawnDirectNormalize.X != Projectile.velocity.X || projSpawnDirectNormalize.Y != Projectile.velocity.Y) { Projectile.netUpdate = true; } - Projectile.velocity = value19 * 0.55f; - Vector2 vector20 = Vector2.Normalize(Projectile.velocity) * coreVelocity; - if (float.IsNaN(vector20.X) || float.IsNaN(vector20.Y)) + Projectile.velocity = projSpawnDirectNormalize * 0.55f; + Vector2 normalCoreVel = Vector2.Normalize(Projectile.velocity) * coreVelocity; + if (float.IsNaN(normalCoreVel.X) || float.IsNaN(normalCoreVel.Y)) { - vector20 = -Vector2.UnitY; + normalCoreVel = -Vector2.UnitY; } - Vector2 vector21 = vector19 + Utils.RandomVector2(Main.rand, -10f, 10f); - int num44 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), vector21.X, vector21.Y, vector20.X, vector20.Y, num42, weaponDamage2, weaponKnockback2, Projectile.owner, 0f, 0f); + Vector2 randomSpawnOffset = playerRotateCopy + Utils.RandomVector2(Main.rand, -10f, 10f); + int blastProj = Projectile.NewProjectile(Projectile.GetSource_FromThis(), randomSpawnOffset.X, randomSpawnOffset.Y, normalCoreVel.X, normalCoreVel.Y, ModContent.ProjectileType(), weaponDamage2, weaponKnockback2, Projectile.owner, 0f, 0f); } else { @@ -192,7 +191,7 @@ namespace CalamityMod.Projectiles.Magic } } Projectile.position = player.RotatedRelativePoint(player.MountedCenter, true) - Projectile.Size / 2f; - Projectile.rotation = Projectile.velocity.ToRotation() + num; + Projectile.rotation = Projectile.velocity.ToRotation() + piConditional; Projectile.spriteDirection = Projectile.direction; Projectile.timeLeft = 2; player.ChangeDir(Projectile.direction); @@ -205,14 +204,14 @@ namespace CalamityMod.Projectiles.Magic public override void PostDraw(Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; Vector2 origin = new Vector2(13f, 16f); SpriteEffects spriteEffects = SpriteEffects.None; if (Projectile.spriteDirection == -1) spriteEffects = SpriteEffects.FlipHorizontally; - Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Magic/GhastlyVisageProjGlow").Value, Projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Color.White, Projectile.rotation, origin, Projectile.scale, spriteEffects, 0); + Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Magic/GhastlyVisageProjGlow").Value, Projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Color.White, Projectile.rotation, origin, Projectile.scale, spriteEffects, 0); } public override bool? CanDamage() => false; diff --git a/Projectiles/Magic/HadalUrnIsopod.cs b/Projectiles/Magic/HadalUrnIsopod.cs index dc864522fb..6ecee1d2a5 100644 --- a/Projectiles/Magic/HadalUrnIsopod.cs +++ b/Projectiles/Magic/HadalUrnIsopod.cs @@ -58,17 +58,17 @@ namespace CalamityMod.Projectiles.Magic { SoundEngine.PlaySound(SoundID.Item10, Projectile.position); //Black Anurian bubble dust - int num3; - for (int num246 = 0; num246 < 25; num246 = num3 + 1) + int inc; + for (int i = 0; i < 25; i = inc + 1) { - int num247 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 14, 0f, 0f, 0, default, 1f); - Main.dust[num247].position = (Main.dust[num247].position + Projectile.position) / 2f; - Main.dust[num247].velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - Main.dust[num247].velocity.Normalize(); - Dust dust = Main.dust[num247]; + int hadalDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 14, 0f, 0f, 0, default, 1f); + Main.dust[hadalDust].position = (Main.dust[hadalDust].position + Projectile.position) / 2f; + Main.dust[hadalDust].velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + Main.dust[hadalDust].velocity.Normalize(); + Dust dust = Main.dust[hadalDust]; dust.velocity *= (float)Main.rand.Next(1, 30) * 0.1f; - Main.dust[num247].alpha = Projectile.alpha; - num3 = num246; + Main.dust[hadalDust].alpha = Projectile.alpha; + inc = i; } } diff --git a/Projectiles/Magic/HadalUrnLamprey.cs b/Projectiles/Magic/HadalUrnLamprey.cs index 98b8ed3135..8a1007c8b2 100644 --- a/Projectiles/Magic/HadalUrnLamprey.cs +++ b/Projectiles/Magic/HadalUrnLamprey.cs @@ -108,17 +108,17 @@ namespace CalamityMod.Projectiles.Magic public override void OnKill(int timeLeft) { //Black Anurian bubble dust - int num3; - for (int num246 = 0; num246 < 25; num246 = num3 + 1) + int inc; + for (int i = 0; i < 25; i = inc + 1) { - int num247 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 14, 0f, 0f, 0, default, 1f); - Main.dust[num247].position = (Main.dust[num247].position + Projectile.position) / 2f; - Main.dust[num247].velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - Main.dust[num247].velocity.Normalize(); - Dust dust = Main.dust[num247]; + int hadalDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 14, 0f, 0f, 0, default, 1f); + Main.dust[hadalDust].position = (Main.dust[hadalDust].position + Projectile.position) / 2f; + Main.dust[hadalDust].velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + Main.dust[hadalDust].velocity.Normalize(); + Dust dust = Main.dust[hadalDust]; dust.velocity *= (float)Main.rand.Next(1, 30) * 0.1f; - Main.dust[num247].alpha = Projectile.alpha; - num3 = num246; + Main.dust[hadalDust].alpha = Projectile.alpha; + inc = i; } } diff --git a/Projectiles/Magic/HellfireExplosionFriendly.cs b/Projectiles/Magic/HellfireExplosionFriendly.cs index f590b24f4c..f1a07045f4 100644 --- a/Projectiles/Magic/HellfireExplosionFriendly.cs +++ b/Projectiles/Magic/HellfireExplosionFriendly.cs @@ -35,38 +35,38 @@ namespace CalamityMod.Projectiles.Magic SoundEngine.PlaySound(SoundID.Item20, Projectile.position); Projectile.localAI[0] += 1f; } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-10, 11); - float num464 = (float)Main.rand.Next(-10, 11); - float num465 = (float)Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); - Dust dust = Main.dust[num467]; + float rando1 = (float)Main.rand.Next(-10, 11); + float rando2 = (float)Main.rand.Next(-10, 11); + float rando3 = (float)Main.rand.Next(3, 9); + float randoAdjuster = (float)Math.Sqrt((double)(rando1 * rando1 + rando2 * rando2)); + randoAdjuster = rando3 / randoAdjuster; + rando1 *= randoAdjuster; + rando2 *= randoAdjuster; + int brimDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); + Dust dust = Main.dust[brimDust]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = rando1; + dust.velocity.Y = rando2; + timerCounter++; } } diff --git a/Projectiles/Magic/HellwingPillar.cs b/Projectiles/Magic/HellwingPillar.cs index b95bea5926..40a84f7224 100644 --- a/Projectiles/Magic/HellwingPillar.cs +++ b/Projectiles/Magic/HellwingPillar.cs @@ -58,11 +58,10 @@ namespace CalamityMod.Projectiles.Magic scalar = 0.75f; } Projectile.ai[0] += 1f; - int num297 = 127; if (Main.rand.NextBool(3)) { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; + int flareDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 127, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust = Main.dust[flareDust]; if (Main.rand.NextBool(3)) { dust.noGravity = true; diff --git a/Projectiles/Magic/HolyFlame.cs b/Projectiles/Magic/HolyFlame.cs index 0bf44176e0..11dd7cc85a 100644 --- a/Projectiles/Magic/HolyFlame.cs +++ b/Projectiles/Magic/HolyFlame.cs @@ -55,23 +55,23 @@ namespace CalamityMod.Projectiles.Magic Projectile.height = 50; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 20; num621++) + for (int i = 0; i < 20; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int holyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); + Main.dust[holyDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[holyDust].scale = 0.5f; + Main.dust[holyDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 35; num623++) + for (int j = 0; j < 35; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 247, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int holyDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 247, 0f, 0f, 100, default, 3f); + Main.dust[holyDust2].noGravity = true; + Main.dust[holyDust2].velocity *= 5f; + holyDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); + Main.dust[holyDust2].velocity *= 2f; } } diff --git a/Projectiles/Magic/HolyLaser.cs b/Projectiles/Magic/HolyLaser.cs index 259ce46885..d804f3c477 100644 --- a/Projectiles/Magic/HolyLaser.cs +++ b/Projectiles/Magic/HolyLaser.cs @@ -29,21 +29,21 @@ namespace CalamityMod.Projectiles.Magic Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 9f) { - int num249 = Main.rand.Next(2); - if (num249 == 0) + int dustType = Main.rand.Next(2); + if (dustType == 0) { - num249 = 244; + dustType = 244; } else { - num249 = 246; + dustType = 246; } - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * 0.25f; - int num448 = Dust.NewDust(vector33, 1, 1, num249, 0f, 0f, 0, default, 0.25f); - Main.dust[num448].position = vector33; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.1f; + Vector2 projPos = Projectile.position; + projPos -= Projectile.velocity * 0.25f; + int holyDust = Dust.NewDust(projPos, 1, 1, dustType, 0f, 0f, 0, default, 0.25f); + Main.dust[holyDust].position = projPos; + Main.dust[holyDust].scale = (float)Main.rand.Next(70, 110) * 0.013f; + Main.dust[holyDust].velocity *= 0.1f; } } diff --git a/Projectiles/Magic/IcicleStaffProj.cs b/Projectiles/Magic/IcicleStaffProj.cs index df95aabe6e..e9057dda96 100644 --- a/Projectiles/Magic/IcicleStaffProj.cs +++ b/Projectiles/Magic/IcicleStaffProj.cs @@ -27,11 +27,11 @@ namespace CalamityMod.Projectiles.Magic Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { - for (int num468 = 0; num468 < 3; num468++) + for (int i = 0; i < 3; i++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 100, default, 0.75f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int icyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 100, default, 0.75f); + Main.dust[icyDust].noGravity = true; + Main.dust[icyDust].velocity *= 0f; } } } diff --git a/Projectiles/Magic/IcicleStaffProj.png b/Projectiles/Magic/IcicleStaffProj.png index 00b1ef9ae1..b7b31b4005 100644 Binary files a/Projectiles/Magic/IcicleStaffProj.png and b/Projectiles/Magic/IcicleStaffProj.png differ diff --git a/Projectiles/Magic/InfernadoFriendly.cs b/Projectiles/Magic/InfernadoFriendly.cs index f3f9b60c5d..3e0901e896 100644 --- a/Projectiles/Magic/InfernadoFriendly.cs +++ b/Projectiles/Magic/InfernadoFriendly.cs @@ -98,8 +98,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.netUpdate = true; Vector2 center = Projectile.Center; center.Y -= baseHeight * Projectile.scale / 2f; - float num618 = (scaleBase - Projectile.ai[1] + 1f) * scaleMult / scaleBase; - center.Y -= baseHeight * num618 / 2f; + float nextSegmentHeight = (scaleBase - Projectile.ai[1] + 1f) * scaleMult / scaleBase; + center.Y -= baseHeight * nextSegmentHeight / 2f; center.Y += 2f; Projectile segment = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), center, Projectile.velocity, Projectile.type, Projectile.damage, Projectile.knockBack, Projectile.owner, 10f, Projectile.ai[1] - 1f); @@ -114,14 +114,14 @@ namespace CalamityMod.Projectiles.Magic } if (Projectile.ai[0] <= 0f) { - float num622 = 0.104719758f; - float num623 = (float)Projectile.width / 5f; - num623 *= 2f; - float num624 = (float)(Math.Cos((double)(num622 * -(double)Projectile.ai[0])) - 0.5) * num623; - Projectile.position.X -= num624 * -Projectile.direction; + float swaySize = 0.104719758f; + float smolWidth = (float)Projectile.width / 5f; + smolWidth *= 2f; + float projXChange = (float)(Math.Cos((double)(swaySize * -(double)Projectile.ai[0])) - 0.5) * smolWidth; + Projectile.position.X -= projXChange * -Projectile.direction; Projectile.ai[0] -= 1f; - num624 = (float)(Math.Cos((double)(num622 * -(double)Projectile.ai[0])) - 0.5) * num623; - Projectile.position.X += num624 * -Projectile.direction; + projXChange = (float)(Math.Cos((double)(swaySize * -(double)Projectile.ai[0])) - 0.5) * smolWidth; + Projectile.position.X += projXChange * -Projectile.direction; return; } } @@ -143,9 +143,9 @@ namespace CalamityMod.Projectiles.Magic public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } } diff --git a/Projectiles/Magic/InfernadoMarkFriendly.cs b/Projectiles/Magic/InfernadoMarkFriendly.cs index cf15364bf6..9bb73962b2 100644 --- a/Projectiles/Magic/InfernadoMarkFriendly.cs +++ b/Projectiles/Magic/InfernadoMarkFriendly.cs @@ -30,23 +30,23 @@ namespace CalamityMod.Projectiles.Magic { if (Projectile.ai[1] > 0f) { - int num625 = (int)Projectile.ai[1] - 1; - if (num625 < 255) + int playerTrack = (int)Projectile.ai[1] - 1; + if (playerTrack < 255) { Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 10f) { - int num626 = 6; - for (int num627 = 0; num627 < num626; num627++) + int dustAmt = 6; + for (int i = 0; i < dustAmt; i++) { - Vector2 vector45 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector45 = vector45.RotatedBy((double)(num627 - (num626 / 2 - 1)) * 3.1415926535897931 / (double)(float)num626, default) + Projectile.Center; - Vector2 value15 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); - int num628 = Dust.NewDust(vector45 + value15, 0, 0, 244, value15.X * 2f, value15.Y * 2f, 100, default, 1.4f); - Main.dust[num628].noGravity = true; - Main.dust[num628].noLight = true; - Main.dust[num628].velocity /= 4f; - Main.dust[num628].velocity -= Projectile.velocity; + Vector2 dustRotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + dustRotate = dustRotate.RotatedBy((double)(i - (dustAmt / 2 - 1)) * 3.1415926535897931 / (double)(float)dustAmt, default) + Projectile.Center; + Vector2 randDustOffset = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + int fiery = Dust.NewDust(dustRotate + randDustOffset, 0, 0, 244, randDustOffset.X * 2f, randDustOffset.Y * 2f, 100, default, 1.4f); + Main.dust[fiery].noGravity = true; + Main.dust[fiery].noLight = true; + Main.dust[fiery].velocity /= 4f; + Main.dust[fiery].velocity -= Projectile.velocity; } Projectile.alpha -= 5; if (Projectile.alpha < 100) @@ -54,11 +54,11 @@ namespace CalamityMod.Projectiles.Magic Projectile.alpha = 100; } } - Vector2 value16 = Main.player[num625].Center - Projectile.Center; - float num629 = 4f; - num629 += Projectile.localAI[0] / 20f; - Projectile.velocity = Vector2.Normalize(value16) * num629; - if (value16.Length() < 50f) + Vector2 projDirection = Main.player[playerTrack].Center - Projectile.Center; + float velocityMult = 4f; + velocityMult += Projectile.localAI[0] / 20f; + Projectile.velocity = Vector2.Normalize(projDirection) * velocityMult; + if (projDirection.Length() < 50f) { Projectile.Kill(); } @@ -66,13 +66,13 @@ namespace CalamityMod.Projectiles.Magic } else { - float num630 = 0.209439516f; - float num631 = 4f; - float num632 = (float)(Math.Cos((double)(num630 * Projectile.ai[0])) - 0.5) * num631; - Projectile.velocity.Y = Projectile.velocity.Y - num632; + float swaySize = 0.209439516f; + float XChangeMult = 4f; + float projXChange = (float)(Math.Cos((double)(swaySize * Projectile.ai[0])) - 0.5) * XChangeMult; + Projectile.velocity.Y = Projectile.velocity.Y - projXChange; Projectile.ai[0] += 1f; - num632 = (float)(Math.Cos((double)(num630 * Projectile.ai[0])) - 0.5) * num631; - Projectile.velocity.Y = Projectile.velocity.Y + num632; + projXChange = (float)(Math.Cos((double)(swaySize * Projectile.ai[0])) - 0.5) * XChangeMult; + Projectile.velocity.Y = Projectile.velocity.Y + projXChange; Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 10f) { @@ -94,49 +94,49 @@ namespace CalamityMod.Projectiles.Magic public override void OnKill(int timeLeft) { SoundEngine.PlaySound(FlareSound, Projectile.position); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int i = 0; i < dustAmt; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 244, vector7.X * 2f, vector7.Y * 2f, 100, default, 1.4f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int infernadoDust = Dust.NewDust(rotate + faceDirection, 0, 0, 244, faceDirection.X * 2f, faceDirection.Y * 2f, 100, default, 1.4f); + Main.dust[infernadoDust].noGravity = true; + Main.dust[infernadoDust].noLight = true; + Main.dust[infernadoDust].velocity = faceDirection; } if (Projectile.owner == Main.myPlayer) { - int num231 = (int)(Projectile.Center.Y / 16f); - int num232 = (int)(Projectile.Center.X / 16f); - int num233 = 100; - if (num232 < 10) + int projTileY = (int)(Projectile.Center.Y / 16f); + int projTileX = (int)(Projectile.Center.X / 16f); + int offsetUpwards = 100; + if (projTileX < 10) { - num232 = 10; + projTileX = 10; } - if (num232 > Main.maxTilesX - 10) + if (projTileX > Main.maxTilesX - 10) { - num232 = Main.maxTilesX - 10; + projTileX = Main.maxTilesX - 10; } - if (num231 < 10) + if (projTileY < 10) { - num231 = 10; + projTileY = 10; } - if (num231 > Main.maxTilesY - num233 - 10) + if (projTileY > Main.maxTilesY - offsetUpwards - 10) { - num231 = Main.maxTilesY - num233 - 10; + projTileY = Main.maxTilesY - offsetUpwards - 10; } - for (int num234 = num231; num234 < num231 + num233; num234++) + for (int j = projTileY; j < projTileY + offsetUpwards; j++) { - Tile tile = Main.tile[num232, num234]; + Tile tile = Main.tile[projTileX, j]; if (tile.HasTile && (Main.tileSolid[(int)tile.TileType] || tile.LiquidAmount != 0)) { - num231 = num234; + projTileY = j; break; } } - int num236 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)(num232 * 16 + 8), (float)(num231 * 16 - 24), 0f, 0f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack * 30f, Main.myPlayer, 16f, 16f); - Main.projectile[num236].netUpdate = true; + int infernado = Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)(projTileX * 16 + 8), (float)(projTileY * 16 - 24), 0f, 0f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack * 30f, Main.myPlayer, 16f, 16f); + Main.projectile[infernado].netUpdate = true; } } } diff --git a/Projectiles/Magic/InfernalBlade.cs b/Projectiles/Magic/InfernalBlade.cs index 7dcf1e0a59..3ff465d10d 100644 --- a/Projectiles/Magic/InfernalBlade.cs +++ b/Projectiles/Magic/InfernalBlade.cs @@ -33,19 +33,19 @@ namespace CalamityMod.Projectiles.Magic Projectile.alpha = 0; Projectile.scale = 1.1f; Projectile.frame = Main.rand.Next(14); - float num98 = 16f; - int num99 = 0; - while ((float)num99 < num98) + float dustLoopcheck = 16f; + int dustIncr = 0; + while ((float)dustIncr < dustLoopcheck) { - Vector2 vector11 = Vector2.UnitX * 0f; - vector11 += -Vector2.UnitY.RotatedBy((double)((float)num99 * (6.28318548f / num98)), default) * new Vector2(1f, 4f); - vector11 = vector11.RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num100 = Dust.NewDust(Projectile.Center, 0, 0, 182, 0f, 0f, 0, default, 1f); - Main.dust[num100].scale = 1.5f; - Main.dust[num100].noGravity = true; - Main.dust[num100].position = Projectile.Center + vector11; - Main.dust[num100].velocity = Projectile.velocity * 0f + vector11.SafeNormalize(Vector2.UnitY) * 1f; - num99++; + Vector2 dustRotate = Vector2.UnitX * 0f; + dustRotate += -Vector2.UnitY.RotatedBy((double)((float)dustIncr * (6.28318548f / dustLoopcheck)), default) * new Vector2(1f, 4f); + dustRotate = dustRotate.RotatedBy((double)Projectile.velocity.ToRotation(), default); + int deepRed = Dust.NewDust(Projectile.Center, 0, 0, 182, 0f, 0f, 0, default, 1f); + Main.dust[deepRed].scale = 1.5f; + Main.dust[deepRed].noGravity = true; + Main.dust[deepRed].position = Projectile.Center + dustRotate; + Main.dust[deepRed].velocity = Projectile.velocity * 0f + dustRotate.SafeNormalize(Vector2.UnitY) * 1f; + dustIncr++; } } Projectile.rotation = Projectile.velocity.ToRotation() + 0.7853982f; @@ -78,35 +78,31 @@ namespace CalamityMod.Projectiles.Magic { spriteEffects = SpriteEffects.FlipHorizontally; } - Color color25 = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); + Color colorArea = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); Texture2D texture2D3 = ModContent.Request(Texture).Value; - int num155 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y3 = num155 * Projectile.frame; - Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, num155); - Vector2 origin2 = rectangle.Size() / 2f; - float num158 = 0f; - int num156 = 3; - int num157 = 1; - float value4 = 8f; + int textureArea = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y3 = textureArea * Projectile.frame; + Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, textureArea); + Vector2 halfRect = rectangle.Size() / 2f; rectangle = new Rectangle(38 * Projectile.frame, 0, 38, 38); - origin2 = rectangle.Size() / 2f; - for (int num159 = 1; num159 < num156; num159 += num157) + halfRect = rectangle.Size() / 2f; + for (int i = 1; i < 3; i += 1) { - Color color26 = color25; - color26 = Projectile.GetAlpha(color26); - color26 *= (float)(num156 - num159) / ((float)ProjectileID.Sets.TrailCacheLength[Projectile.type] * 1.5f); - Vector2 value5 = Projectile.oldPos[num159]; - float num160 = Projectile.rotation; + Color alphaColor = colorArea; + alphaColor = Projectile.GetAlpha(alphaColor); + alphaColor *= (float)(3 - i) / ((float)ProjectileID.Sets.TrailCacheLength[Projectile.type] * 1.5f); + Vector2 oldPosition = Projectile.oldPos[i]; + float projRotation = Projectile.rotation; SpriteEffects effects = spriteEffects; if (ProjectileID.Sets.TrailingMode[Projectile.type] == 2) { - num160 = Projectile.oldRot[num159]; - effects = (Projectile.oldSpriteDirection[num159] == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + projRotation = Projectile.oldRot[i]; + effects = (Projectile.oldSpriteDirection[i] == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; } - Main.spriteBatch.Draw(texture2D3, value5 + Projectile.Size / 2f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, num160 + Projectile.rotation * num158 * (float)(num159 - 1) * (float)-(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, MathHelper.Lerp(Projectile.scale, value4, (float)num159 / 15f), effects, 0f); + Main.spriteBatch.Draw(texture2D3, oldPosition + Projectile.Size / 2f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), alphaColor, projRotation + Projectile.rotation * 0f * (float)(i - 1) * (float)-(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), halfRect, MathHelper.Lerp(Projectile.scale, 8f, (float)i / 15f), effects, 0f); } - Color color28 = Projectile.GetAlpha(color25); - Main.spriteBatch.Draw(texture2D3, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color28, Projectile.rotation, origin2, Projectile.scale, SpriteEffects.None, 0); + Color alphaColorAgain = Projectile.GetAlpha(colorArea); + Main.spriteBatch.Draw(texture2D3, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), alphaColorAgain, Projectile.rotation, halfRect, Projectile.scale, SpriteEffects.None, 0); return false; } diff --git a/Projectiles/Magic/InfernalBlade2.cs b/Projectiles/Magic/InfernalBlade2.cs index 16e34a343e..5e9cb88dcf 100644 --- a/Projectiles/Magic/InfernalBlade2.cs +++ b/Projectiles/Magic/InfernalBlade2.cs @@ -35,19 +35,19 @@ namespace CalamityMod.Projectiles.Magic Projectile.alpha = 0; Projectile.scale = 1.1f; Projectile.frame = Main.rand.Next(14); - float num98 = 16f; - int num99 = 0; - while ((float)num99 < num98) + float dustLoopCheck = 16f; + int dustIncr = 0; + while ((float)dustIncr < dustLoopCheck) { - Vector2 vector11 = Vector2.UnitX * 0f; - vector11 += -Vector2.UnitY.RotatedBy((double)((float)num99 * (6.28318548f / num98)), default) * new Vector2(1f, 4f); - vector11 = vector11.RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num100 = Dust.NewDust(Projectile.Center, 0, 0, 182, 0f, 0f, 0, default, 1f); - Main.dust[num100].scale = 1.5f; - Main.dust[num100].noGravity = true; - Main.dust[num100].position = Projectile.Center + vector11; - Main.dust[num100].velocity = Projectile.velocity * 0f + vector11.SafeNormalize(Vector2.UnitY) * 1f; - num99++; + Vector2 dustRotate = Vector2.UnitX * 0f; + dustRotate += -Vector2.UnitY.RotatedBy((double)((float)dustIncr * (6.28318548f / dustLoopCheck)), default) * new Vector2(1f, 4f); + dustRotate = dustRotate.RotatedBy((double)Projectile.velocity.ToRotation(), default); + int deepRed = Dust.NewDust(Projectile.Center, 0, 0, 182, 0f, 0f, 0, default, 1f); + Main.dust[deepRed].scale = 1.5f; + Main.dust[deepRed].noGravity = true; + Main.dust[deepRed].position = Projectile.Center + dustRotate; + Main.dust[deepRed].velocity = Projectile.velocity * 0f + dustRotate.SafeNormalize(Vector2.UnitY) * 1f; + dustIncr++; } } Projectile.rotation = Projectile.velocity.ToRotation() + 0.7853982f; @@ -57,17 +57,17 @@ namespace CalamityMod.Projectiles.Magic { Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height); SoundEngine.PlaySound(SoundID.Item10, Projectile.position); - int num487 = Main.rand.Next(4, 10); - for (int num488 = 0; num488 < num487; num488++) + int randDustAmt = Main.rand.Next(4, 10); + for (int i = 0; i < randDustAmt; i++) { - int num489 = Dust.NewDust(Projectile.Center, 0, 0, 182, 0f, 0f, 100, default, 1f); - Main.dust[num489].velocity *= 1.6f; - Dust expr_FEDF_cp_0 = Main.dust[num489]; + int killDeepRed = Dust.NewDust(Projectile.Center, 0, 0, 182, 0f, 0f, 100, default, 1f); + Main.dust[killDeepRed].velocity *= 1.6f; + Dust expr_FEDF_cp_0 = Main.dust[killDeepRed]; expr_FEDF_cp_0.velocity.Y -= 1f; - Main.dust[num489].velocity += -Projectile.velocity * (Main.rand.NextFloat() * 2f - 1f) * 0.5f; - Main.dust[num489].scale = 2f; - Main.dust[num489].fadeIn = 0.5f; - Main.dust[num489].noGravity = true; + Main.dust[killDeepRed].velocity += -Projectile.velocity * (Main.rand.NextFloat() * 2f - 1f) * 0.5f; + Main.dust[killDeepRed].scale = 2f; + Main.dust[killDeepRed].fadeIn = 0.5f; + Main.dust[killDeepRed].noGravity = true; } } @@ -83,35 +83,31 @@ namespace CalamityMod.Projectiles.Magic { spriteEffects = SpriteEffects.FlipHorizontally; } - Color color25 = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); + Color colorArea = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); Texture2D texture2D3 = ModContent.Request(Texture).Value; - int num155 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y3 = num155 * Projectile.frame; - Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, num155); - Vector2 origin2 = rectangle.Size() / 2f; - float num158 = 0f; - int num156 = 3; - int num157 = 1; - float value4 = 8f; + int textureArea = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y3 = textureArea * Projectile.frame; + Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, textureArea); + Vector2 halfRect = rectangle.Size() / 2f; rectangle = new Rectangle(38 * Projectile.frame, 0, 38, 38); - origin2 = rectangle.Size() / 2f; - for (int num159 = 1; num159 < num156; num159 += num157) + halfRect = rectangle.Size() / 2f; + for (int j = 1; j < 3; j += 1) { - Color color26 = color25; - color26 = Projectile.GetAlpha(color26); - color26 *= (float)(num156 - num159) / ((float)ProjectileID.Sets.TrailCacheLength[Projectile.type] * 1.5f); - Vector2 value5 = Projectile.oldPos[num159]; - float num160 = Projectile.rotation; + Color alphaColor = colorArea; + alphaColor = Projectile.GetAlpha(alphaColor); + alphaColor *= (float)(3 - j) / ((float)ProjectileID.Sets.TrailCacheLength[Projectile.type] * 1.5f); + Vector2 oldPosition = Projectile.oldPos[j]; + float projRotation = Projectile.rotation; SpriteEffects effects = spriteEffects; if (ProjectileID.Sets.TrailingMode[Projectile.type] == 2) { - num160 = Projectile.oldRot[num159]; - effects = (Projectile.oldSpriteDirection[num159] == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + projRotation = Projectile.oldRot[j]; + effects = (Projectile.oldSpriteDirection[j] == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; } - Main.spriteBatch.Draw(texture2D3, value5 + Projectile.Size / 2f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, num160 + Projectile.rotation * num158 * (float)(num159 - 1) * (float)-(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, MathHelper.Lerp(Projectile.scale, value4, (float)num159 / 15f), effects, 0f); + Main.spriteBatch.Draw(texture2D3, oldPosition + Projectile.Size / 2f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), alphaColor, projRotation + Projectile.rotation * 0f * (float)(j - 1) * (float)-(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), halfRect, MathHelper.Lerp(Projectile.scale, 8f, (float)j / 15f), effects, 0f); } - Color color28 = Projectile.GetAlpha(color25); - Main.spriteBatch.Draw(texture2D3, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color28, Projectile.rotation, origin2, Projectile.scale, SpriteEffects.None, 0); + Color alphaColorAgain = Projectile.GetAlpha(colorArea); + Main.spriteBatch.Draw(texture2D3, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), alphaColorAgain, Projectile.rotation, halfRect, Projectile.scale, SpriteEffects.None, 0); return false; } diff --git a/Projectiles/Magic/IonBlast.cs b/Projectiles/Magic/IonBlast.cs index 54c505d358..ecab146b29 100644 --- a/Projectiles/Magic/IonBlast.cs +++ b/Projectiles/Magic/IonBlast.cs @@ -42,19 +42,19 @@ namespace CalamityMod.Projectiles.Magic Projectile.alpha = 0; } Lighting.AddLight((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16, 1f, 0f, 0.2f); - float num55 = 100f; - float num56 = 3f; + float projTimer = 100f; + float timerIncr = 3f; if (Projectile.ai[1] == 0f) { - Projectile.localAI[0] += num56; - if (Projectile.localAI[0] > num55) + Projectile.localAI[0] += timerIncr; + if (Projectile.localAI[0] > projTimer) { - Projectile.localAI[0] = num55; + Projectile.localAI[0] = projTimer; } } else { - Projectile.localAI[0] -= num56; + Projectile.localAI[0] -= timerIncr; if (Projectile.localAI[0] <= 0f) { Projectile.Kill(); @@ -74,12 +74,12 @@ namespace CalamityMod.Projectiles.Magic Projectile.localNPCHitCooldown = 10; Projectile.Damage(); SoundEngine.PlaySound(SoundID.Item92, Projectile.Center); - int num212 = Main.rand.Next(15, 30); - for (int num213 = 0; num213 < num212; num213++) + int randDustAmt = Main.rand.Next(15, 30); + for (int i = 0; i < randDustAmt; i++) { - int num214 = Dust.NewDust(Projectile.Center - Projectile.velocity / 2f, 0, 0, 130, 0f, 0f, 100, default, 1f); - Main.dust[num214].velocity *= 2f; - Main.dust[num214].noGravity = true; + int reddish = Dust.NewDust(Projectile.Center - Projectile.velocity / 2f, 0, 0, 130, 0f, 0f, 100, default, 1f); + Main.dust[reddish].velocity *= 2f; + Main.dust[reddish].noGravity = true; } } diff --git a/Projectiles/Magic/LazharSolarBeam.cs b/Projectiles/Magic/LazharSolarBeam.cs index d1c5508d3f..0cb34d1d67 100644 --- a/Projectiles/Magic/LazharSolarBeam.cs +++ b/Projectiles/Magic/LazharSolarBeam.cs @@ -26,15 +26,15 @@ namespace CalamityMod.Projectiles.Magic Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { - for (int num447 = 0; num447 < 4; num447++) + for (int i = 0; i < 4; i++) { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * ((float)num447 * 0.25f); + Vector2 projPos = Projectile.position; + projPos -= Projectile.velocity * ((float)i * 0.25f); Projectile.alpha = 255; - int num448 = Dust.NewDust(vector33, 1, 1, 246, 0f, 0f, 0, default, 1f); - Main.dust[num448].position = vector33; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.2f; + int heatGold = Dust.NewDust(projPos, 1, 1, 246, 0f, 0f, 0, default, 1f); + Main.dust[heatGold].position = projPos; + Main.dust[heatGold].scale = (float)Main.rand.Next(70, 110) * 0.013f; + Main.dust[heatGold].velocity *= 0.2f; } } } @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Magic target.AddBuff(BuffID.Daybreak, 180); if (Projectile.owner == Main.myPlayer) { - int proj = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + int proj = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); if (proj.WithinBounds(Main.maxProjectiles)) Main.projectile[proj].DamageType = DamageClass.Magic; } diff --git a/Projectiles/Magic/LightBall.cs b/Projectiles/Magic/LightBall.cs index 11cb215f48..a55997a16c 100644 --- a/Projectiles/Magic/LightBall.cs +++ b/Projectiles/Magic/LightBall.cs @@ -42,23 +42,23 @@ namespace CalamityMod.Projectiles.Magic Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; + int lightDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 1.2f); + Main.dust[lightDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[lightDust].scale = 0.5f; + Main.dust[lightDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int lightDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 1.7f); + Main.dust[lightDust2].noGravity = true; + Main.dust[lightDust2].velocity *= 5f; + lightDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 1f); + Main.dust[lightDust2].velocity *= 2f; } } } diff --git a/Projectiles/Magic/LiquidBlade.cs b/Projectiles/Magic/LiquidBlade.cs index 9dc075c329..6e378be143 100644 --- a/Projectiles/Magic/LiquidBlade.cs +++ b/Projectiles/Magic/LiquidBlade.cs @@ -1,10 +1,9 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace CalamityMod.Projectiles.Magic { @@ -37,19 +36,19 @@ namespace CalamityMod.Projectiles.Magic Projectile.alpha = 0; Projectile.scale = 1.1f; Projectile.frame = Main.rand.Next(14); - float num98 = 16f; - int num99 = 0; - while ((float)num99 < num98) + float dustLoopCheck = 16f; + int dustIncr = 0; + while ((float)dustIncr < dustLoopCheck) { - Vector2 vector11 = Vector2.UnitX * 0f; - vector11 += -Vector2.UnitY.RotatedBy((double)((float)num99 * (6.28318548f / num98)), default) * new Vector2(1f, 4f); - vector11 = vector11.RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num100 = Dust.NewDust(Projectile.Center, 0, 0, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[num100].scale = 1.5f; - Main.dust[num100].noGravity = true; - Main.dust[num100].position = Projectile.Center + vector11; - Main.dust[num100].velocity = Projectile.velocity * 0f + vector11.SafeNormalize(Vector2.UnitY) * 1f; - num99++; + Vector2 dustRotate = Vector2.UnitX * 0f; + dustRotate += -Vector2.UnitY.RotatedBy((double)((float)dustIncr * (6.28318548f / dustLoopCheck)), default) * new Vector2(1f, 4f); + dustRotate = dustRotate.RotatedBy((double)Projectile.velocity.ToRotation(), default); + int rainbow = Dust.NewDust(Projectile.Center, 0, 0, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Main.dust[rainbow].scale = 1.5f; + Main.dust[rainbow].noGravity = true; + Main.dust[rainbow].position = Projectile.Center + dustRotate; + Main.dust[rainbow].velocity = Projectile.velocity * 0f + dustRotate.SafeNormalize(Vector2.UnitY) * 1f; + dustIncr++; } } Projectile.rotation = Projectile.velocity.ToRotation() + 0.7853982f; @@ -59,11 +58,11 @@ namespace CalamityMod.Projectiles.Magic { Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height); SoundEngine.PlaySound(SoundID.Item10, Projectile.position); - int num487 = Main.rand.Next(4, 10); - for (int num488 = 0; num488 < num487; num488++) + int randDustAmt = Main.rand.Next(4, 10); + for (int j = 0; j < randDustAmt; j++) { - int num489 = Dust.NewDust(Projectile.Center, 0, 0, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Dust dust = Main.dust[num489]; + int rainbowDeath = Dust.NewDust(Projectile.Center, 0, 0, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Dust dust = Main.dust[rainbowDeath]; dust.velocity *= 1.6f; dust.velocity.Y -= 1f; dust.velocity += -Projectile.velocity * (Main.rand.NextFloat() * 2f - 1f) * 0.5f; @@ -85,35 +84,31 @@ namespace CalamityMod.Projectiles.Magic { spriteEffects = SpriteEffects.FlipHorizontally; } - Color color25 = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); + Color colorArea = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); Texture2D texture2D3 = ModContent.Request(Texture).Value; - int num155 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y3 = num155 * Projectile.frame; - Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, num155); - Vector2 origin2 = rectangle.Size() / 2f; - float num158 = 0f; - int num156 = 3; - int num157 = 1; - float value4 = 8f; + int textureArea = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y3 = textureArea * Projectile.frame; + Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, textureArea); + Vector2 halfRect = rectangle.Size() / 2f; rectangle = new Rectangle(38 * Projectile.frame, 0, 38, 38); - origin2 = rectangle.Size() / 2f; - for (int num159 = 1; num159 < num156; num159 += num157) + halfRect = rectangle.Size() / 2f; + for (int i = 1; i < 3; i += 1) { - Color color26 = color25; - color26 = Projectile.GetAlpha(color26); - color26 *= (float)(num156 - num159) / ((float)ProjectileID.Sets.TrailCacheLength[Projectile.type] * 1.5f); - Vector2 value5 = Projectile.oldPos[num159]; - float num160 = Projectile.rotation; + Color alphaColor = colorArea; + alphaColor = Projectile.GetAlpha(alphaColor); + alphaColor *= (float)(3 - i) / ((float)ProjectileID.Sets.TrailCacheLength[Projectile.type] * 1.5f); + Vector2 oldPosition = Projectile.oldPos[i]; + float projRotation = Projectile.rotation; SpriteEffects effects = spriteEffects; if (ProjectileID.Sets.TrailingMode[Projectile.type] == 2) { - num160 = Projectile.oldRot[num159]; - effects = (Projectile.oldSpriteDirection[num159] == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + projRotation = Projectile.oldRot[i]; + effects = (Projectile.oldSpriteDirection[i] == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; } - Main.spriteBatch.Draw(texture2D3, value5 + Projectile.Size / 2f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, num160 + Projectile.rotation * num158 * (float)(num159 - 1) * (float)-(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, MathHelper.Lerp(Projectile.scale, value4, (float)num159 / 15f), effects, 0f); + Main.spriteBatch.Draw(texture2D3, oldPosition + Projectile.Size / 2f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), alphaColor, projRotation + Projectile.rotation * 0f * (float)(i - 1) * (float)-(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), halfRect, MathHelper.Lerp(Projectile.scale, 8f, (float)i / 15f), effects, 0f); } - Color color28 = Projectile.GetAlpha(color25); - Main.spriteBatch.Draw(texture2D3, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color28, Projectile.rotation, origin2, Projectile.scale, SpriteEffects.None, 0); + Color alphaColorAgain = Projectile.GetAlpha(colorArea); + Main.spriteBatch.Draw(texture2D3, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), alphaColorAgain, Projectile.rotation, halfRect, Projectile.scale, SpriteEffects.None, 0); return false; } diff --git a/Projectiles/Magic/LiquidBlade2.cs b/Projectiles/Magic/LiquidBlade2.cs index 29be60a1db..01552c0385 100644 --- a/Projectiles/Magic/LiquidBlade2.cs +++ b/Projectiles/Magic/LiquidBlade2.cs @@ -37,19 +37,19 @@ namespace CalamityMod.Projectiles.Magic Projectile.alpha = 0; Projectile.scale = 1.1f; Projectile.frame = Main.rand.Next(14); - float num98 = 16f; - int num99 = 0; - while ((float)num99 < num98) + float dustLoopCheck = 16f; + int dustIncr = 0; + while ((float)dustIncr < dustLoopCheck) { - Vector2 vector11 = Vector2.UnitX * 0f; - vector11 += -Vector2.UnitY.RotatedBy((double)((float)num99 * (6.28318548f / num98)), default) * new Vector2(1f, 4f); - vector11 = vector11.RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num100 = Dust.NewDust(Projectile.Center, 0, 0, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[num100].scale = 1.5f; - Main.dust[num100].noGravity = true; - Main.dust[num100].position = Projectile.Center + vector11; - Main.dust[num100].velocity = Projectile.velocity * 0f + vector11.SafeNormalize(Vector2.UnitY) * 1f; - num99++; + Vector2 dustRotate = Vector2.UnitX * 0f; + dustRotate += -Vector2.UnitY.RotatedBy((double)((float)dustIncr * (6.28318548f / dustLoopCheck)), default) * new Vector2(1f, 4f); + dustRotate = dustRotate.RotatedBy((double)Projectile.velocity.ToRotation(), default); + int rainbow = Dust.NewDust(Projectile.Center, 0, 0, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Main.dust[rainbow].scale = 1.5f; + Main.dust[rainbow].noGravity = true; + Main.dust[rainbow].position = Projectile.Center + dustRotate; + Main.dust[rainbow].velocity = Projectile.velocity * 0f + dustRotate.SafeNormalize(Vector2.UnitY) * 1f; + dustIncr++; } } Projectile.rotation = Projectile.velocity.ToRotation() + 0.7853982f; @@ -59,11 +59,11 @@ namespace CalamityMod.Projectiles.Magic { Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height); SoundEngine.PlaySound(SoundID.Item10, Projectile.position); - int num487 = Main.rand.Next(4, 10); - for (int num488 = 0; num488 < num487; num488++) + int randDustAmt = Main.rand.Next(4, 10); + for (int i = 0; i < randDustAmt; i++) { - int num489 = Dust.NewDust(Projectile.Center, 0, 0, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Dust dust = Main.dust[num489]; + int rainbowDeath = Dust.NewDust(Projectile.Center, 0, 0, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Dust dust = Main.dust[rainbowDeath]; dust.velocity *= 1.6f; dust.velocity.Y -= 1f; dust.velocity += -Projectile.velocity * (Main.rand.NextFloat() * 2f - 1f) * 0.5f; @@ -85,35 +85,31 @@ namespace CalamityMod.Projectiles.Magic { spriteEffects = SpriteEffects.FlipHorizontally; } - Color color25 = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); + Color colorArea = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); Texture2D texture2D3 = ModContent.Request(Texture).Value; - int num155 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y3 = num155 * Projectile.frame; - Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, num155); - Vector2 origin2 = rectangle.Size() / 2f; - float num158 = 0f; - int num156 = 3; - int num157 = 1; - float value4 = 8f; + int textureArea = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y3 = textureArea * Projectile.frame; + Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, textureArea); + Vector2 halfRect = rectangle.Size() / 2f; rectangle = new Rectangle(38 * Projectile.frame, 0, 38, 38); - origin2 = rectangle.Size() / 2f; - for (int num159 = 1; num159 < num156; num159 += num157) + halfRect = rectangle.Size() / 2f; + for (int j = 1; j < 3; j += 1) { - Color color26 = color25; - color26 = Projectile.GetAlpha(color26); - color26 *= (float)(num156 - num159) / ((float)ProjectileID.Sets.TrailCacheLength[Projectile.type] * 1.5f); - Vector2 value5 = Projectile.oldPos[num159]; - float num160 = Projectile.rotation; + Color alphaColor = colorArea; + alphaColor = Projectile.GetAlpha(alphaColor); + alphaColor *= (float)(3 - j) / ((float)ProjectileID.Sets.TrailCacheLength[Projectile.type] * 1.5f); + Vector2 oldPosition = Projectile.oldPos[j]; + float projRotation = Projectile.rotation; SpriteEffects effects = spriteEffects; if (ProjectileID.Sets.TrailingMode[Projectile.type] == 2) { - num160 = Projectile.oldRot[num159]; - effects = (Projectile.oldSpriteDirection[num159] == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + projRotation = Projectile.oldRot[j]; + effects = (Projectile.oldSpriteDirection[j] == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; } - Main.spriteBatch.Draw(texture2D3, value5 + Projectile.Size / 2f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, num160 + Projectile.rotation * num158 * (float)(num159 - 1) * (float)-(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, MathHelper.Lerp(Projectile.scale, value4, (float)num159 / 15f), effects, 0f); + Main.spriteBatch.Draw(texture2D3, oldPosition + Projectile.Size / 2f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), alphaColor, projRotation + Projectile.rotation * 0f * (float)(j - 1) * (float)-(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), halfRect, MathHelper.Lerp(Projectile.scale, 8f, (float)j / 15f), effects, 0f); } - Color color28 = Projectile.GetAlpha(color25); - Main.spriteBatch.Draw(texture2D3, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color28, Projectile.rotation, origin2, Projectile.scale, SpriteEffects.None, 0); + Color alphaColorAgain = Projectile.GetAlpha(colorArea); + Main.spriteBatch.Draw(texture2D3, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), alphaColorAgain, Projectile.rotation, halfRect, Projectile.scale, SpriteEffects.None, 0); return false; } } diff --git a/Projectiles/Magic/LuxorsGiftMagic.cs b/Projectiles/Magic/LuxorsGiftMagic.cs index 2f4b809d03..8be8db8a32 100644 --- a/Projectiles/Magic/LuxorsGiftMagic.cs +++ b/Projectiles/Magic/LuxorsGiftMagic.cs @@ -56,15 +56,15 @@ namespace CalamityMod.Projectiles.Magic { for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); - int num9 = Dust.NewDust(Projectile.Center, 0, 0, 244, 0f, 0f, 160, default, 1f); - Main.dust[num9].scale = 1.1f; - Main.dust[num9].noGravity = true; - Main.dust[num9].position = Projectile.Center + vector3; - Main.dust[num9].velocity = Projectile.velocity * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; + Vector2 dustRotate = Vector2.UnitX * (float)-(float)Projectile.width / 2f; + dustRotate += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); + dustRotate = dustRotate.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); + int dusty = Dust.NewDust(Projectile.Center, 0, 0, 244, 0f, 0f, 160, default, 1f); + Main.dust[dusty].scale = 1.1f; + Main.dust[dusty].noGravity = true; + Main.dust[dusty].position = Projectile.Center + dustRotate; + Main.dust[dusty].velocity = Projectile.velocity * 0.1f; + Main.dust[dusty].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[dusty].position) * 1.25f; } } } diff --git a/Projectiles/Magic/MadAlchemistsCocktailAlt.cs b/Projectiles/Magic/MadAlchemistsCocktailAlt.cs index 1d889fb007..147f7ba1af 100644 --- a/Projectiles/Magic/MadAlchemistsCocktailAlt.cs +++ b/Projectiles/Magic/MadAlchemistsCocktailAlt.cs @@ -69,46 +69,45 @@ namespace CalamityMod.Projectiles.Magic Projectile.Damage(); // I don't even know what this dust code does - float num51 = 1.8f; - float num52 = 2.5f; - Vector2 value3 = (0f - 1.57079637f).ToRotationVector2(); - Vector2 value4 = value3 * Projectile.velocity.Length() * (float)Projectile.MaxUpdates; - int num3; - for (int num53 = 0; num53 < 40; num53 = num3 + 1) + // So true bestie! -CIT + Vector2 dustRotation = (0f - 1.57079637f).ToRotationVector2(); + Vector2 dustVelocity = dustRotation * Projectile.velocity.Length() * (float)Projectile.MaxUpdates; + int inc; + for (int i = 0; i < 40; i = inc + 1) { - int num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 200, default, num52); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; - Main.dust[num54].noGravity = true; - Dust dust = Main.dust[num54]; + int alchDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 200, default, 2.5f); + Main.dust[alchDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + Main.dust[alchDust].noGravity = true; + Dust dust = Main.dust[alchDust]; dust.velocity *= 4f; - dust = Main.dust[num54]; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 174, 0f, 0f, 100, default, num51); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; - dust = Main.dust[num54]; + dust = Main.dust[alchDust]; + dust.velocity += dustVelocity * Main.rand.NextFloat(); + alchDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 174, 0f, 0f, 100, default, 1.8f); + Main.dust[alchDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + dust = Main.dust[alchDust]; dust.velocity *= 3f; - Main.dust[num54].noGravity = true; - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 229, 0f, 0f, 100, default, num51); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; - dust = Main.dust[num54]; + Main.dust[alchDust].noGravity = true; + alchDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 229, 0f, 0f, 100, default, 1.8f); + Main.dust[alchDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + dust = Main.dust[alchDust]; dust.velocity *= 2f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Green * 0.5f; - dust = Main.dust[num54]; - dust.velocity += value4 * Main.rand.NextFloat(); - num3 = num53; + Main.dust[alchDust].noGravity = true; + Main.dust[alchDust].fadeIn = 1f; + Main.dust[alchDust].color = Color.Green * 0.5f; + dust = Main.dust[alchDust]; + dust.velocity += dustVelocity * Main.rand.NextFloat(); + inc = i; } - for (int num55 = 0; num55 < 20; num55 = num3 + 1) + for (int j = 0; j < 20; j = inc + 1) { - int num56 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 206, 0f, 0f, 0, default, num52); - Main.dust[num56].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 3f; - Main.dust[num56].noGravity = true; - Dust dust = Main.dust[num56]; + int alchDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 206, 0f, 0f, 0, default, 2.5f); + Main.dust[alchDust2].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 3f; + Main.dust[alchDust2].noGravity = true; + Dust dust = Main.dust[alchDust2]; dust.velocity *= 0.5f; - dust = Main.dust[num56]; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); - num3 = num55; + dust = Main.dust[alchDust2]; + dust.velocity += dustVelocity * (0.6f + 0.6f * Main.rand.NextFloat()); + inc = j; } } } diff --git a/Projectiles/Magic/MadAlchemistsCocktailGreen.cs b/Projectiles/Magic/MadAlchemistsCocktailGreen.cs index e6265e1b5e..fe9ae63c68 100644 --- a/Projectiles/Magic/MadAlchemistsCocktailGreen.cs +++ b/Projectiles/Magic/MadAlchemistsCocktailGreen.cs @@ -51,18 +51,17 @@ namespace CalamityMod.Projectiles.Magic float x = Projectile.position.X + (float)Main.rand.Next(-100, 100); float y = Projectile.position.Y - (float)Main.rand.Next(500, 600); Vector2 vector = new Vector2(x, y); - float num15 = Projectile.position.X + (float)(Projectile.width / 2) - vector.X; - float num16 = Projectile.position.Y + (float)(Projectile.height / 2) - vector.Y; - num15 += (float)Main.rand.Next(-100, 101); - int num17 = 25; - float num18 = (float)Math.Sqrt((double)(num15 * num15 + num16 * num16)); - num18 = (float)num17 / num18; - num15 *= num18; - num16 *= num18; + float projSpawnX = Projectile.position.X + (float)(Projectile.width / 2) - vector.X; + float projSpawnY = Projectile.position.Y + (float)(Projectile.height / 2) - vector.Y; + projSpawnX += (float)Main.rand.Next(-100, 101); + float projSpawnDist = (float)Math.Sqrt((double)(projSpawnX * projSpawnX + projSpawnY * projSpawnY)); + projSpawnDist = 25f / projSpawnDist; + projSpawnX *= projSpawnDist; + projSpawnY *= projSpawnDist; - float ai2 = num16 + Projectile.position.Y; + float flareAI = projSpawnY + Projectile.position.Y; if (Projectile.owner == Main.myPlayer) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), x, y, num15, num16, ProjectileID.LunarFlare, Projectile.damage / 2, 5f, Projectile.owner, 0f, ai2); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), x, y, projSpawnX, projSpawnY, ProjectileID.LunarFlare, Projectile.damage / 2, 5f, Projectile.owner, 0f, flareAI); } } } diff --git a/Projectiles/Magic/MadAlchemistsCocktailPurple.cs b/Projectiles/Magic/MadAlchemistsCocktailPurple.cs index cb4474fb96..21be9804fc 100644 --- a/Projectiles/Magic/MadAlchemistsCocktailPurple.cs +++ b/Projectiles/Magic/MadAlchemistsCocktailPurple.cs @@ -51,10 +51,10 @@ namespace CalamityMod.Projectiles.Magic { for (int i = 0; i < numShrapnel; i++) { - Vector2 value17 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - value17.Normalize(); - value17 *= (float)Main.rand.Next(10, 201) * 0.01f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, value17.X, value17.Y, ModContent.ProjectileType(), shrapnelDamage, 0f, Projectile.owner, 0f, (float)Main.rand.Next(-45, 1)); + Vector2 randProjSpawn = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + randProjSpawn.Normalize(); + randProjSpawn *= (float)Main.rand.Next(10, 201) * 0.01f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, randProjSpawn.X, randProjSpawn.Y, ModContent.ProjectileType(), shrapnelDamage, 0f, Projectile.owner, 0f, (float)Main.rand.Next(-45, 1)); } } } diff --git a/Projectiles/Magic/MadAlchemistsCocktailRed.cs b/Projectiles/Magic/MadAlchemistsCocktailRed.cs index b2ada56d4d..a1d38bc5f8 100644 --- a/Projectiles/Magic/MadAlchemistsCocktailRed.cs +++ b/Projectiles/Magic/MadAlchemistsCocktailRed.cs @@ -60,60 +60,58 @@ namespace CalamityMod.Projectiles.Magic Projectile.Damage(); // I don't even know what this dust code does - float num50 = 3f; - float num51 = 2.4f; - float num52 = 3.8f; - Vector2 value3 = (0f - 1.57079637f).ToRotationVector2(); - Vector2 value4 = value3 * Projectile.velocity.Length() * (float)Projectile.MaxUpdates; - int num3; - for (int num53 = 0; num53 < 60; num53 = num3 + 1) + float dustAI = 2.4f; + Vector2 dustRotation = (0f - 1.57079637f).ToRotationVector2(); + Vector2 dustVelocity = dustRotation * Projectile.velocity.Length() * (float)Projectile.MaxUpdates; + int inc; + for (int i = 0; i < 60; i = inc + 1) { - int num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 174, 0f, 0f, 200, default, num50); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; - Main.dust[num54].noGravity = true; - Dust dust = Main.dust[num54]; + int fiery = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 174, 0f, 0f, 200, default, 3f); + Main.dust[fiery].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + Main.dust[fiery].noGravity = true; + Dust dust = Main.dust[fiery]; dust.velocity *= 8f; - dust = Main.dust[num54]; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 174, 0f, 0f, 100, default, num51); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; - dust = Main.dust[num54]; + dust = Main.dust[fiery]; + dust.velocity += dustVelocity * Main.rand.NextFloat(); + fiery = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 174, 0f, 0f, 100, default, dustAI); + Main.dust[fiery].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + dust = Main.dust[fiery]; dust.velocity *= 6f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Crimson * 0.5f; - dust = Main.dust[num54]; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 174, 0f, 0f, 100, default, num51); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; - dust = Main.dust[num54]; + Main.dust[fiery].noGravity = true; + Main.dust[fiery].fadeIn = 1f; + Main.dust[fiery].color = Color.Crimson * 0.5f; + dust = Main.dust[fiery]; + dust.velocity += dustVelocity * Main.rand.NextFloat(); + fiery = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 174, 0f, 0f, 100, default, dustAI); + Main.dust[fiery].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + dust = Main.dust[fiery]; dust.velocity *= 4f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Crimson * 0.5f; - dust = Main.dust[num54]; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 174, 0f, 0f, 100, default, num51); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; - dust = Main.dust[num54]; + Main.dust[fiery].noGravity = true; + Main.dust[fiery].fadeIn = 1f; + Main.dust[fiery].color = Color.Crimson * 0.5f; + dust = Main.dust[fiery]; + dust.velocity += dustVelocity * Main.rand.NextFloat(); + fiery = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 174, 0f, 0f, 100, default, dustAI); + Main.dust[fiery].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + dust = Main.dust[fiery]; dust.velocity *= 2f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Crimson * 0.5f; - dust = Main.dust[num54]; - dust.velocity += value4 * Main.rand.NextFloat(); - num3 = num53; + Main.dust[fiery].noGravity = true; + Main.dust[fiery].fadeIn = 1f; + Main.dust[fiery].color = Color.Crimson * 0.5f; + dust = Main.dust[fiery]; + dust.velocity += dustVelocity * Main.rand.NextFloat(); + inc = i; } - for (int num55 = 0; num55 < 30; num55 = num3 + 1) + for (int j = 0; j < 30; j = inc + 1) { - int num56 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 174, 0f, 0f, 0, default, num52); - Main.dust[num56].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 3f; - Main.dust[num56].noGravity = true; - Dust dust = Main.dust[num56]; + int fiery2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 174, 0f, 0f, 0, default, 3.8f); + Main.dust[fiery2].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 3f; + Main.dust[fiery2].noGravity = true; + Dust dust = Main.dust[fiery2]; dust.velocity *= 0.5f; - dust = Main.dust[num56]; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); - num3 = num55; + dust = Main.dust[fiery2]; + dust.velocity += dustVelocity * (0.6f + 0.6f * Main.rand.NextFloat()); + inc = j; } } } diff --git a/Projectiles/Magic/MadAlchemistsCocktailShrapnel.cs b/Projectiles/Magic/MadAlchemistsCocktailShrapnel.cs index c9f62ef33c..9fc5bfe392 100644 --- a/Projectiles/Magic/MadAlchemistsCocktailShrapnel.cs +++ b/Projectiles/Magic/MadAlchemistsCocktailShrapnel.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - Vector2 value7 = new Vector2(6f, 12f); + Vector2 rotationMult = new Vector2(6f, 12f); Projectile.localAI[0] += 1f; if (Projectile.localAI[0] == 48f) { @@ -32,19 +32,19 @@ namespace CalamityMod.Projectiles.Magic } else { - for (int num41 = 0; num41 < 2; num41++) + for (int i = 0; i < 2; i++) { - Vector2 value8 = Vector2.UnitX * -15f; - value8 = -Vector2.UnitY.RotatedBy((double)(Projectile.localAI[0] * 0.1308997f + (float)num41 * 3.14159274f), default) * value7 * 0.75f; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, 173, 0f, 0f, 160, default, 0.75f); - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8; - Main.dust[num42].velocity = Projectile.velocity; + Vector2 dustRotation = Vector2.UnitX * -15f; + dustRotation = -Vector2.UnitY.RotatedBy((double)(Projectile.localAI[0] * 0.1308997f + (float)i * 3.14159274f), default) * rotationMult * 0.75f; + int shrapnelDust = Dust.NewDust(Projectile.Center, 0, 0, 173, 0f, 0f, 160, default, 0.75f); + Main.dust[shrapnelDust].noGravity = true; + Main.dust[shrapnelDust].position = Projectile.Center + dustRotation; + Main.dust[shrapnelDust].velocity = Projectile.velocity; } } - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1f); - Main.dust[num458].noGravity = true; + int extraDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1f); + Main.dust[extraDust].noGravity = true; if (Projectile.timeLeft < 150) CalamityUtils.HomeInOnNPC(Projectile, true, 600f, 12f, 20f); diff --git a/Projectiles/Magic/MagneticBeam.cs b/Projectiles/Magic/MagneticBeam.cs index 1189876c46..79bffa3f90 100644 --- a/Projectiles/Magic/MagneticBeam.cs +++ b/Projectiles/Magic/MagneticBeam.cs @@ -21,12 +21,12 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * 0.25f; - int num448 = Dust.NewDust(vector33, 1, 1, 173, 0f, 0f, 0, default, 1.25f); - Main.dust[num448].position = vector33; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.1f; + Vector2 projPos = Projectile.position; + projPos -= Projectile.velocity * 0.25f; + int dust = Dust.NewDust(projPos, 1, 1, 173, 0f, 0f, 0, default, 1.25f); + Main.dust[dust].position = projPos; + Main.dust[dust].scale = (float)Main.rand.Next(70, 110) * 0.013f; + Main.dust[dust].velocity *= 0.1f; } } } diff --git a/Projectiles/Magic/MagneticOrb.cs b/Projectiles/Magic/MagneticOrb.cs index 97237d90e0..b24092abef 100644 --- a/Projectiles/Magic/MagneticOrb.cs +++ b/Projectiles/Magic/MagneticOrb.cs @@ -69,8 +69,8 @@ namespace CalamityMod.Projectiles.Magic { if (Projectile.timeLeft < 30) { - float num7 = (float)Projectile.timeLeft / 30f; - Projectile.alpha = (int)(255f - 255f * num7); + float timeAlpha = (float)Projectile.timeLeft / 30f; + Projectile.alpha = (int)(255f - 255f * timeAlpha); } return new Color(255 - Projectile.alpha, 255 - Projectile.alpha, 255 - Projectile.alpha, 0); } @@ -78,9 +78,9 @@ namespace CalamityMod.Projectiles.Magic public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } } diff --git a/Projectiles/Magic/MelterAmp.cs b/Projectiles/Magic/MelterAmp.cs index ebf1fb5118..4623c92bb4 100644 --- a/Projectiles/Magic/MelterAmp.cs +++ b/Projectiles/Magic/MelterAmp.cs @@ -29,9 +29,9 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isProjectile = Projectile.type == ModContent.ProjectileType(); Player player = Main.player[Projectile.owner]; - if (flag64) + if (isProjectile) { if (player.dead) { @@ -64,29 +64,28 @@ namespace CalamityMod.Projectiles.Magic int Damage = Projectile.damage; int type; Projectile.netUpdate = true; - float num127 = 20f; - Vector2 vector11 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num128 = (float)Main.mouseX + Main.screenPosition.X - vector11.X; - float num129 = (float)Main.mouseY + Main.screenPosition.Y - vector11.Y; + Vector2 projAimDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float ampXDirection = (float)Main.mouseX + Main.screenPosition.X - projAimDirection.X; + float ampYDirection = (float)Main.mouseY + Main.screenPosition.Y - projAimDirection.Y; if (player.gravDir == -1f) { - num129 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector11.Y; + ampYDirection = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - projAimDirection.Y; } - float num130 = (float)Math.Sqrt((double)(num128 * num128 + num129 * num129)); - if (num130 == 0f) + float ampAimDistance = (float)Math.Sqrt((double)(ampXDirection * ampXDirection + ampYDirection * ampYDirection)); + if (ampAimDistance == 0f) { - vector11 = new Vector2(player.position.X + (float)(player.width / 2), player.position.Y + (float)(player.height / 2)); - num128 = Projectile.position.X + (float)Projectile.width * 0.5f - vector11.X; - num129 = Projectile.position.Y + (float)Projectile.height * 0.5f - vector11.Y; - num130 = (float)Math.Sqrt((double)(num128 * num128 + num129 * num129)); + projAimDirection = new Vector2(player.position.X + (float)(player.width / 2), player.position.Y + (float)(player.height / 2)); + ampXDirection = Projectile.position.X + (float)Projectile.width * 0.5f - projAimDirection.X; + ampYDirection = Projectile.position.Y + (float)Projectile.height * 0.5f - projAimDirection.Y; + ampAimDistance = (float)Math.Sqrt((double)(ampXDirection * ampXDirection + ampYDirection * ampYDirection)); } - num130 = num127 / num130; - num128 *= num130; - num129 *= num130; - float VelocityX = num128; - float VelocityY = num129; - int note = Main.rand.Next(0, 2); - if (note == 0) + ampAimDistance = 20f / ampAimDistance; + ampXDirection *= ampAimDistance; + ampYDirection *= ampAimDistance; + float VelocityX = ampXDirection; + float VelocityY = ampYDirection; + int noteType = Main.rand.Next(0, 2); + if (noteType == 0) { Damage = (int)(Projectile.damage * 1.5f); type = ModContent.ProjectileType(); diff --git a/Projectiles/Magic/MeteorStar.cs b/Projectiles/Magic/MeteorStar.cs index 4547e0fe9d..9e5de057f1 100644 --- a/Projectiles/Magic/MeteorStar.cs +++ b/Projectiles/Magic/MeteorStar.cs @@ -116,7 +116,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.velocity.X = mouseVec.X; Projectile.velocity.Y = mouseVec.Y; } - player.direction = (Projectile.velocity.X > 0).ToDirectionInt(); + player.ChangeDir((int)Projectile.velocity.X); player.velocity = Projectile.velocity; if (Projectile.velocity.Y > 16f) { diff --git a/Projectiles/Magic/NebulaCloud.cs b/Projectiles/Magic/NebulaCloud.cs index a2aac10fbe..9e97e763f2 100644 --- a/Projectiles/Magic/NebulaCloud.cs +++ b/Projectiles/Magic/NebulaCloud.cs @@ -32,17 +32,14 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - int num925 = ModContent.ProjectileType(); - float num926 = 720f; - float x5 = 0.15f; - float y4 = 0.15f; - bool flag50 = false; - bool flag51 = false; + int mainProjType = ModContent.ProjectileType(); + float projTimer = 720f; + bool unusedFlag = false; - if (flag51) + if (unusedFlag) { - int num927 = (int)Projectile.ai[1]; - if (!Main.projectile[num927].active || Main.projectile[num927].type != num925) + int mainProj = (int)Projectile.ai[1]; + if (!Main.projectile[mainProj].active || Main.projectile[mainProj].type != mainProjType) { Projectile.Kill(); return; @@ -52,15 +49,15 @@ namespace CalamityMod.Projectiles.Magic } Projectile.ai[0]++; - if (!(Projectile.ai[0] < num926)) + if (!(Projectile.ai[0] < projTimer)) return; - bool flag52 = true; - int num928 = (int)Projectile.ai[1]; - if (Main.projectile[num928].active && Main.projectile[num928].type == num925) + bool isActive = true; + int mainProjID = (int)Projectile.ai[1]; + if (Main.projectile[mainProjID].active && Main.projectile[mainProjID].type == mainProjType) { - if (!flag50 && Main.projectile[num928].oldPos[1] != Vector2.Zero) - Projectile.position += Main.projectile[num928].position - Main.projectile[num928].oldPos[1]; + if (Main.projectile[mainProjID].oldPos[1] != Vector2.Zero) + Projectile.position += Main.projectile[mainProjID].position - Main.projectile[mainProjID].oldPos[1]; if (Projectile.Center.HasNaNs()) { @@ -70,28 +67,28 @@ namespace CalamityMod.Projectiles.Magic } else { - Projectile.ai[0] = num926; - flag52 = false; + Projectile.ai[0] = projTimer; + isActive = false; Projectile.Kill(); } - if (flag52 && !flag50) + if (isActive) { - Projectile.velocity += new Vector2(Math.Sign(Main.projectile[num928].Center.X - Projectile.Center.X), Math.Sign(Main.projectile[num928].Center.Y - Projectile.Center.Y)) * new Vector2(x5, y4); + Projectile.velocity += new Vector2(Math.Sign(Main.projectile[mainProjID].Center.X - Projectile.Center.X), Math.Sign(Main.projectile[mainProjID].Center.Y - Projectile.Center.Y)) * new Vector2(0.15f, 0.15f); if (Projectile.velocity.Length() > 6f) Projectile.velocity *= 6f / Projectile.velocity.Length(); } if (Main.rand.NextBool()) { - int num929 = Dust.NewDust(Projectile.Center, 8, 8, 86); - Main.dust[num929].position = Projectile.Center; - Main.dust[num929].velocity = Projectile.velocity; - Main.dust[num929].noGravity = true; - Main.dust[num929].scale = 1.75f; + int purpleDust = Dust.NewDust(Projectile.Center, 8, 8, 86); + Main.dust[purpleDust].position = Projectile.Center; + Main.dust[purpleDust].velocity = Projectile.velocity; + Main.dust[purpleDust].noGravity = true; + Main.dust[purpleDust].scale = 1.75f; - if (flag52) - Main.dust[num929].customData = Main.projectile[(int)Projectile.ai[1]]; + if (isActive) + Main.dust[purpleDust].customData = Main.projectile[(int)Projectile.ai[1]]; } } @@ -99,24 +96,24 @@ namespace CalamityMod.Projectiles.Magic { Projectile.ai[0] = 86f; - for (int num164 = 0; num164 < 15; num164++) + for (int i = 0; i < 15; i++) { - int num165 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)Projectile.ai[0], Projectile.velocity.X * 0.1f, Projectile.velocity.Y * 0.1f, 0, default(Color), 0.75f); + int killDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)Projectile.ai[0], Projectile.velocity.X * 0.1f, Projectile.velocity.Y * 0.1f, 0, default(Color), 0.75f); Dust dust; if (Main.rand.NextBool(3)) { - Main.dust[num165].fadeIn = 0.75f + Main.rand.Next(-10, 11) * 0.015f; - Main.dust[num165].scale = 0.325f + Main.rand.Next(-10, 11) * 0.0075f; - dust = Main.dust[num165]; + Main.dust[killDust].fadeIn = 0.75f + Main.rand.Next(-10, 11) * 0.015f; + Main.dust[killDust].scale = 0.325f + Main.rand.Next(-10, 11) * 0.0075f; + dust = Main.dust[killDust]; dust.type++; } else - Main.dust[num165].scale = 1.5f + Main.rand.Next(-10, 11) * 0.015f; + Main.dust[killDust].scale = 1.5f + Main.rand.Next(-10, 11) * 0.015f; - Main.dust[num165].noGravity = true; - dust = Main.dust[num165]; + Main.dust[killDust].noGravity = true; + dust = Main.dust[killDust]; dust.velocity *= 1.375f; - dust = Main.dust[num165]; + dust = Main.dust[killDust]; dust.velocity -= Projectile.oldVelocity / 20f; } } diff --git a/Projectiles/Magic/NebulaCloudCore.cs b/Projectiles/Magic/NebulaCloudCore.cs index e91c6bbc49..d6666420d1 100644 --- a/Projectiles/Magic/NebulaCloudCore.cs +++ b/Projectiles/Magic/NebulaCloudCore.cs @@ -73,25 +73,25 @@ namespace CalamityMod.Projectiles.Magic { if (Main.rand.NextBool()) { - Vector2 vector93 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - Dust dust45 = Main.dust[Dust.NewDust(Projectile.Center - vector93 * 45f, 0, 0, Utils.SelectRandom(Main.rand, 86, 90))]; - dust45.noGravity = true; - dust45.position = Projectile.Center - vector93 * Main.rand.Next(20, 31); - dust45.velocity = vector93.RotatedBy(MathHelper.PiOver2) * 9f; - dust45.scale = 0.7f + Main.rand.NextFloat(); - dust45.fadeIn = 0.5f; - dust45.customData = this; + Vector2 prettyDustDirect = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + Dust prettyDust = Main.dust[Dust.NewDust(Projectile.Center - prettyDustDirect * 45f, 0, 0, Utils.SelectRandom(Main.rand, 86, 90))]; + prettyDust.noGravity = true; + prettyDust.position = Projectile.Center - prettyDustDirect * Main.rand.Next(20, 31); + prettyDust.velocity = prettyDustDirect.RotatedBy(MathHelper.PiOver2) * 9f; + prettyDust.scale = 0.7f + Main.rand.NextFloat(); + prettyDust.fadeIn = 0.5f; + prettyDust.customData = this; } else { - Vector2 vector94 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - Dust dust46 = Main.dust[Dust.NewDust(Projectile.Center - vector94 * 45f, 0, 0, 240)]; - dust46.noGravity = true; - dust46.position = Projectile.Center - vector94 * 45f; - dust46.velocity = vector94.RotatedBy(-MathHelper.PiOver2) * 4f; - dust46.scale = 0.7f + Main.rand.NextFloat(); - dust46.fadeIn = 0.5f; - dust46.customData = this; + Vector2 prettyDustDirect2 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + Dust prettyDust2 = Main.dust[Dust.NewDust(Projectile.Center - prettyDustDirect2 * 45f, 0, 0, 240)]; + prettyDust2.noGravity = true; + prettyDust2.position = Projectile.Center - prettyDustDirect2 * 45f; + prettyDust2.velocity = prettyDustDirect2.RotatedBy(-MathHelper.PiOver2) * 4f; + prettyDust2.scale = 0.7f + Main.rand.NextFloat(); + prettyDust2.fadeIn = 0.5f; + prettyDust2.customData = this; } } @@ -125,99 +125,99 @@ namespace CalamityMod.Projectiles.Magic // Emit pretty as fuck dust. if (Main.rand.NextBool()) { - Vector2 vector88 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - Dust dust43 = Main.dust[Dust.NewDust(Projectile.Center - vector88 * 45f, 0, 0, 86)]; - dust43.noGravity = true; - dust43.position = Projectile.Center - vector88 * Main.rand.Next(20, 31); - dust43.velocity = vector88.RotatedBy(MathHelper.PiOver2) * 9f; - dust43.scale = 1.2f + Main.rand.NextFloat(); - dust43.fadeIn = 0.5f; - dust43.customData = this; - vector88 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - dust43 = Main.dust[Dust.NewDust(Projectile.Center - vector88 * 45f, 0, 0, 90)]; - dust43.noGravity = true; - dust43.position = Projectile.Center - vector88 * Main.rand.Next(20, 31); - dust43.velocity = vector88.RotatedBy(MathHelper.PiOver2) * 9f; - dust43.scale = 1.2f + Main.rand.NextFloat(); - dust43.fadeIn = 0.5f; - dust43.customData = this; - dust43.color = Color.Purple; + Vector2 slowPrettyDustDirect = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + Dust slowPrettyDust = Main.dust[Dust.NewDust(Projectile.Center - slowPrettyDustDirect * 45f, 0, 0, 86)]; + slowPrettyDust.noGravity = true; + slowPrettyDust.position = Projectile.Center - slowPrettyDustDirect * Main.rand.Next(20, 31); + slowPrettyDust.velocity = slowPrettyDustDirect.RotatedBy(MathHelper.PiOver2) * 9f; + slowPrettyDust.scale = 1.2f + Main.rand.NextFloat(); + slowPrettyDust.fadeIn = 0.5f; + slowPrettyDust.customData = this; + slowPrettyDustDirect = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + slowPrettyDust = Main.dust[Dust.NewDust(Projectile.Center - slowPrettyDustDirect * 45f, 0, 0, 90)]; + slowPrettyDust.noGravity = true; + slowPrettyDust.position = Projectile.Center - slowPrettyDustDirect * Main.rand.Next(20, 31); + slowPrettyDust.velocity = slowPrettyDustDirect.RotatedBy(MathHelper.PiOver2) * 9f; + slowPrettyDust.scale = 1.2f + Main.rand.NextFloat(); + slowPrettyDust.fadeIn = 0.5f; + slowPrettyDust.customData = this; + slowPrettyDust.color = Color.Purple; } else { - Vector2 vector89 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - Dust dust44 = Main.dust[Dust.NewDust(Projectile.Center - vector89 * 45f, 0, 0, 240)]; - dust44.noGravity = true; - dust44.position = Projectile.Center - vector89 * Main.rand.Next(30, 41); - dust44.velocity = vector89.RotatedBy(-MathHelper.PiOver2) * 6f; - dust44.scale = 1.2f + Main.rand.NextFloat(); - dust44.fadeIn = 0.5f; - dust44.customData = this; + Vector2 slowPrettyDustDirect2 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + Dust slowPrettyDust2 = Main.dust[Dust.NewDust(Projectile.Center - slowPrettyDustDirect2 * 45f, 0, 0, 240)]; + slowPrettyDust2.noGravity = true; + slowPrettyDust2.position = Projectile.Center - slowPrettyDustDirect2 * Main.rand.Next(30, 41); + slowPrettyDust2.velocity = slowPrettyDustDirect2.RotatedBy(-MathHelper.PiOver2) * 6f; + slowPrettyDust2.scale = 1.2f + Main.rand.NextFloat(); + slowPrettyDust2.fadeIn = 0.5f; + slowPrettyDust2.customData = this; } // Create the vortexes. if (Projectile.ai[0] % 30f == 0f && Projectile.ai[0] < 241f && Main.myPlayer == Projectile.owner) { - Vector2 vector90 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * 12f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vector90, ModContent.ProjectileType(), Projectile.damage / 2, 0f, Projectile.owner, 0f, Projectile.whoAmI); + Vector2 randomProjRotate = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * 12f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, randomProjRotate, ModContent.ProjectileType(), Projectile.damage / 2, 0f, Projectile.owner, 0f, Projectile.whoAmI); } // Homing. - Vector2 vector91 = Projectile.Center; - float num915 = 1200f; - bool flag49 = false; - int num916 = 0; + Vector2 projCenter = Projectile.Center; + float homingRange = 1200f; + bool isHoming = false; + int npcTrack = 0; if (Projectile.ai[1] == 0f) { for (int i = 0; i < Main.maxNPCs; i++) { if (Main.npc[i].CanBeChasedBy(this)) { - Vector2 center12 = Main.npc[i].Center; - if (Projectile.Distance(center12) < num915 && Collision.CanHit(new Vector2(Projectile.position.X + Projectile.width / 2, Projectile.position.Y + Projectile.height / 2), 1, 1, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height)) + Vector2 npcCenter = Main.npc[i].Center; + if (Projectile.Distance(npcCenter) < homingRange && Collision.CanHit(new Vector2(Projectile.position.X + Projectile.width / 2, Projectile.position.Y + Projectile.height / 2), 1, 1, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height)) { - num915 = Projectile.Distance(center12); - vector91 = center12; - flag49 = true; - num916 = i; + homingRange = Projectile.Distance(npcCenter); + projCenter = npcCenter; + isHoming = true; + npcTrack = i; } } } - if (flag49) + if (isHoming) { - if (Projectile.ai[1] != num916 + 1) + if (Projectile.ai[1] != npcTrack + 1) Projectile.netUpdate = true; - Projectile.ai[1] = num916 + 1; + Projectile.ai[1] = npcTrack + 1; } - flag49 = false; + isHoming = false; } if (Projectile.ai[1] != 0f) { - int num918 = (int)(Projectile.ai[1] - 1f); - if (Main.npc[num918].active && Main.npc[num918].CanBeChasedBy(this, ignoreDontTakeDamage: true) && Projectile.Distance(Main.npc[num918].Center) < 1000f) + int npcID = (int)(Projectile.ai[1] - 1f); + if (Main.npc[npcID].active && Main.npc[npcID].CanBeChasedBy(this, ignoreDontTakeDamage: true) && Projectile.Distance(Main.npc[npcID].Center) < 1000f) { - flag49 = true; - vector91 = Main.npc[num918].Center; + isHoming = true; + projCenter = Main.npc[npcID].Center; } } - if (flag49) + if (isHoming) { - float num919 = IntendedVelocity; + float intendedSpeed = IntendedVelocity; int inertia = 12; - Vector2 vector92 = Projectile.Center; - float num921 = vector91.X - vector92.X; - float num922 = vector91.Y - vector92.Y; - float num923 = (float)Math.Sqrt(num921 * num921 + num922 * num922); - num923 = num919 / num923; - num921 *= num923; - num922 *= num923; - Projectile.velocity.X = (Projectile.velocity.X * (inertia - 1) + num921) / inertia; - Projectile.velocity.Y = (Projectile.velocity.Y * (inertia - 1) + num922) / inertia; + Vector2 projCenterHome = Projectile.Center; + float projXDirection = projCenter.X - projCenterHome.X; + float projYDirection = projCenter.Y - projCenterHome.Y; + float projDistance = (float)Math.Sqrt(projXDirection * projXDirection + projYDirection * projYDirection); + projDistance = intendedSpeed / projDistance; + projXDirection *= projDistance; + projYDirection *= projDistance; + Projectile.velocity.X = (Projectile.velocity.X * (inertia - 1) + projXDirection) / inertia; + Projectile.velocity.Y = (Projectile.velocity.Y * (inertia - 1) + projYDirection) / inertia; } break; @@ -289,62 +289,62 @@ namespace CalamityMod.Projectiles.Magic SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - for (int num145 = 0; num145 < 6; num145++) + for (int i = 0; i < 6; i++) { - int num146 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 240, 0f, 0f, 100, default(Color), 1.75f); - Main.dust[num146].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + int blackDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 240, 0f, 0f, 100, default(Color), 1.75f); + Main.dust[blackDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * (float)Main.rand.NextDouble() * Projectile.width / 2f; } - for (int num147 = 0; num147 < 45; num147++) + for (int j = 0; j < 45; j++) { - int num148 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 62, 0f, 0f, 200, default(Color), 5.05f); - Main.dust[num148].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - Main.dust[num148].noGravity = true; - Dust dust = Main.dust[num148]; + int purpleDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 62, 0f, 0f, 200, default(Color), 5.05f); + Main.dust[purpleDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + Main.dust[purpleDust].noGravity = true; + Dust dust = Main.dust[purpleDust]; dust.velocity *= 4f; - num148 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 90, 0f, 0f, 100, default(Color), 1.75f); - Main.dust[num148].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - dust = Main.dust[num148]; + purpleDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 90, 0f, 0f, 100, default(Color), 1.75f); + Main.dust[purpleDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + dust = Main.dust[purpleDust]; dust.velocity *= 2.5f; - Main.dust[num148].noGravity = true; - Main.dust[num148].fadeIn = 1f; - Main.dust[num148].color = Color.Purple * 0.5f; + Main.dust[purpleDust].noGravity = true; + Main.dust[purpleDust].fadeIn = 1f; + Main.dust[purpleDust].color = Color.Purple * 0.5f; } - for (int num149 = 0; num149 < 15; num149++) + for (int k = 0; k < 15; k++) { - int num150 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 62, 0f, 0f, 0, default(Color), 3.55f); - Main.dust[num150].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(Math.PI).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 2f; - Main.dust[num150].noGravity = true; - Dust dust = Main.dust[num150]; + int purpleDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 62, 0f, 0f, 0, default(Color), 3.55f); + Main.dust[purpleDust2].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(Math.PI).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 2f; + Main.dust[purpleDust2].noGravity = true; + Dust dust = Main.dust[purpleDust2]; dust.velocity *= 4f; } - for (int num151 = 0; num151 < 15; num151++) + for (int l = 0; l < 15; l++) { - int num152 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 240, 0f, 0f, 0, default(Color), 1.75f); - Main.dust[num152].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(Math.PI).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 2f; - Main.dust[num152].noGravity = true; - Dust dust = Main.dust[num152]; + int blackDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 240, 0f, 0f, 0, default(Color), 1.75f); + Main.dust[blackDust2].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(Math.PI).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 2f; + Main.dust[blackDust2].noGravity = true; + Dust dust = Main.dust[blackDust2]; dust.velocity *= 4f; } - for (int num153 = 0; num153 < 3; num153++) + for (int m = 0; m < 3; m++) { - int num154 = Gore.NewGore(Projectile.GetSource_FromThis(), Projectile.position + new Vector2(Projectile.width * Main.rand.Next(100) / 100f, Projectile.height * Main.rand.Next(100) / 100f) - Vector2.One * 10f, default(Vector2), Main.rand.Next(61, 64)); - Main.gore[num154].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - Gore gore = Main.gore[num154]; + int gored = Gore.NewGore(Projectile.GetSource_FromThis(), Projectile.position + new Vector2(Projectile.width * Main.rand.Next(100) / 100f, Projectile.height * Main.rand.Next(100) / 100f) - Vector2.One * 10f, default(Vector2), Main.rand.Next(61, 64)); + Main.gore[gored].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * (float)Main.rand.NextDouble() * Projectile.width / 2f; + Gore gore = Main.gore[gored]; gore.velocity *= 0.5f; - Main.gore[num154].velocity.X += Main.rand.Next(-10, 11) * 0.075f; - Main.gore[num154].velocity.Y += Main.rand.Next(-10, 11) * 0.075f; + Main.gore[gored].velocity.X += Main.rand.Next(-10, 11) * 0.075f; + Main.gore[gored].velocity.Y += Main.rand.Next(-10, 11) * 0.075f; } if (Main.myPlayer == Projectile.owner) { - for (int num155 = 0; num155 < Main.maxProjectiles; num155++) + for (int r = 0; r < Main.maxProjectiles; r++) { - if (Main.projectile[num155].active && Main.projectile[num155].type == ModContent.ProjectileType() && Main.projectile[num155].ai[1] == Projectile.whoAmI) - Main.projectile[num155].Kill(); + if (Main.projectile[r].active && Main.projectile[r].type == ModContent.ProjectileType() && Main.projectile[r].ai[1] == Projectile.whoAmI) + Main.projectile[r].Kill(); } int totalProjectiles = Main.rand.Next(6, 9); diff --git a/Projectiles/Magic/NebulaElementalBeam.cs b/Projectiles/Magic/NebulaElementalBeam.cs index 10591b1a40..0bcde074e7 100644 --- a/Projectiles/Magic/NebulaElementalBeam.cs +++ b/Projectiles/Magic/NebulaElementalBeam.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -58,5 +59,9 @@ namespace CalamityMod.Projectiles.Magic DrawBeamWithColor(Color.Lerp(new Color(254, 190, 243), Color.Transparent, 0.35f), Projectile.scale * 0.6f); return false; } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 30); + } } } diff --git a/Projectiles/Magic/GrandStaffoftheNebulaMage_Held.cs b/Projectiles/Magic/NebulousCataclysm_Held.cs similarity index 98% rename from Projectiles/Magic/GrandStaffoftheNebulaMage_Held.cs rename to Projectiles/Magic/NebulousCataclysm_Held.cs index a52e529c81..a953411c23 100644 --- a/Projectiles/Magic/GrandStaffoftheNebulaMage_Held.cs +++ b/Projectiles/Magic/NebulousCataclysm_Held.cs @@ -10,9 +10,9 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class GrandStaffoftheNebulaMage_Held : ModProjectile + public class NebulousCataclysm_Held : ModProjectile { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + public override LocalizedText DisplayName => CalamityUtils.GetItemName(); private const int TotalXFrames = 2; private const int TotalYFrames = 8; private const int FrameTimer = 6; diff --git a/Projectiles/Magic/GrandStaffoftheNebulaMage_Held.png b/Projectiles/Magic/NebulousCataclysm_Held.png similarity index 100% rename from Projectiles/Magic/GrandStaffoftheNebulaMage_Held.png rename to Projectiles/Magic/NebulousCataclysm_Held.png diff --git a/Projectiles/Magic/NettleRight.cs b/Projectiles/Magic/NettleRight.cs index 2c681a5524..5659b2f4a7 100644 --- a/Projectiles/Magic/NettleRight.cs +++ b/Projectiles/Magic/NettleRight.cs @@ -20,6 +20,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.tileCollide = false; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Magic; + Projectile.penetrate = -1; } public override void AI() diff --git a/Projectiles/Magic/NightBolt.cs b/Projectiles/Magic/NightBolt.cs index 7fc9720094..e151d3486d 100644 --- a/Projectiles/Magic/NightBolt.cs +++ b/Projectiles/Magic/NightBolt.cs @@ -21,14 +21,14 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - for (int num447 = 0; num447 < 2; num447++) + for (int i = 0; i < 2; i++) { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * ((float)num447 * 0.25f); - int num448 = Dust.NewDust(vector33, 1, 1, 27, 0f, 0f, 0, default, 1.25f); - Main.dust[num448].position = vector33; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.1f; + Vector2 projPos = Projectile.position; + projPos -= Projectile.velocity * ((float)i * 0.25f); + int nightDust = Dust.NewDust(projPos, 1, 1, 27, 0f, 0f, 0, default, 1.25f); + Main.dust[nightDust].position = projPos; + Main.dust[nightDust].scale = (float)Main.rand.Next(70, 110) * 0.013f; + Main.dust[nightDust].velocity *= 0.1f; } } } diff --git a/Projectiles/Magic/NuclearFuryProjectile.cs b/Projectiles/Magic/NuclearFuryProjectile.cs index 353fae39e1..5fb99fba69 100644 --- a/Projectiles/Magic/NuclearFuryProjectile.cs +++ b/Projectiles/Magic/NuclearFuryProjectile.cs @@ -32,16 +32,19 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { + if (Projectile.ai[1] == 1f) + Projectile.penetrate = -1; // Gives infinite pierce to Valediction typhoons + Projectile.localAI[1] += 1f; if (Projectile.localAI[1] > 10f && Main.rand.NextBool(3)) { - int num = 6; - for (int index1 = 0; index1 < num; ++index1) + int dustAmt = 6; + for (int i = 0; i < dustAmt; ++i) { - Vector2 vector2_1 = (Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width, (float)Projectile.height) / 2f).RotatedBy((double)(index1 - (num / 2 - 1)) * Math.PI / (double)num, new Vector2()) + Projectile.Center; - Vector2 vector2_2 = ((Main.rand.NextFloat() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); - int index2 = Dust.NewDust(vector2_1 + vector2_2, 0, 0, 217, vector2_2.X * 2f, vector2_2.Y * 2f, 100, new Color(), 1.4f); - Dust dust = Main.dust[index2]; + Vector2 dustRotation = (Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width, (float)Projectile.height) / 2f).RotatedBy((double)(i - (dustAmt / 2 - 1)) * Math.PI / (double)dustAmt, new Vector2()) + Projectile.Center; + Vector2 randomRotation = ((Main.rand.NextFloat() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); + int nuclearDust = Dust.NewDust(dustRotation + randomRotation, 0, 0, 217, randomRotation.X * 2f, randomRotation.Y * 2f, 100, new Color(), 1.4f); + Dust dust = Main.dust[nuclearDust]; dust.noGravity = true; dust.noLight = true; dust.velocity /= 4f; @@ -54,7 +57,7 @@ namespace CalamityMod.Projectiles.Magic } Projectile.rotation += Projectile.velocity.X * 0.1f; Projectile.rotation += Projectile.velocity.Y * 0.1f; - int num1 = -1; + int npcID = -1; Vector2 targetVec = Projectile.Center; float maxDistance = 500f; if (Projectile.localAI[0] > 0f) @@ -79,19 +82,19 @@ namespace CalamityMod.Projectiles.Magic { maxDistance = npcDist; targetVec = npc.Center; - num1 = index; + npcID = index; } } } - if (num1 >= 0) + if (npcID >= 0) { - Projectile.ai[0] = num1 + 1f; + Projectile.ai[0] = npcID + 1f; Projectile.netUpdate = true; } } if (Projectile.localAI[0] == 0f && Projectile.ai[0] == 0f) Projectile.localAI[0] = 30f; - bool flag = false; + bool isHoming = false; if (Projectile.ai[0] != 0f) { int index = (int)(Projectile.ai[0] - 1); @@ -99,29 +102,29 @@ namespace CalamityMod.Projectiles.Magic { if ((Math.Abs(Projectile.Center.X - Main.npc[index].Center.X) + Math.Abs(Projectile.Center.Y - Main.npc[index].Center.Y)) < 1000f) { - flag = true; + isHoming = true; targetVec = Main.npc[index].Center; } } else { Projectile.ai[0] = 0f; - flag = false; + isHoming = false; Projectile.netUpdate = true; } } - if (flag) + if (isHoming) { - double num3 = (double)(targetVec - Projectile.Center).ToRotation() - (double)Projectile.velocity.ToRotation(); - if (num3 > Math.PI) - num3 -= 2.0 * Math.PI; - if (num3 < -1.0 * Math.PI) - num3 += 2.0 * Math.PI; - Projectile.velocity = Projectile.velocity.RotatedBy(num3 * 0.1, new Vector2()); + double homeVelocity = (double)(targetVec - Projectile.Center).ToRotation() - (double)Projectile.velocity.ToRotation(); + if (homeVelocity > Math.PI) + homeVelocity -= 2.0 * Math.PI; + if (homeVelocity < -1.0 * Math.PI) + homeVelocity += 2.0 * Math.PI; + Projectile.velocity = Projectile.velocity.RotatedBy(homeVelocity * 0.1, new Vector2()); } - float num4 = Projectile.velocity.Length(); + float projSpeed = Projectile.velocity.Length(); Projectile.velocity.Normalize(); - Projectile.velocity = Projectile.velocity * (num4 + 1f / 400f); + Projectile.velocity = Projectile.velocity * (projSpeed + 1f / 400f); } public override void OnKill(int timeLeft) diff --git a/Projectiles/Magic/ParticleBeamofDoom.cs b/Projectiles/Magic/ParticleBeamofDoom.cs index 3074764e13..9f9892d94d 100644 --- a/Projectiles/Magic/ParticleBeamofDoom.cs +++ b/Projectiles/Magic/ParticleBeamofDoom.cs @@ -27,11 +27,11 @@ namespace CalamityMod.Projectiles.Magic Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 9f) { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * 0.25f; - int num448 = Dust.NewDust(vector33, 1, 1, 206, 0f, 0f, 0, default, 2.5f); - Main.dust[num448].position = vector33; - Main.dust[num448].velocity *= 0.1f; + Vector2 projPos = Projectile.position; + projPos -= Projectile.velocity * 0.25f; + int particleDust = Dust.NewDust(projPos, 1, 1, 206, 0f, 0f, 0, default, 2.5f); + Main.dust[particleDust].position = projPos; + Main.dust[particleDust].velocity *= 0.1f; } } } diff --git a/Projectiles/Magic/PhantasmalFuryProj.cs b/Projectiles/Magic/PhantasmalFuryProj.cs index 6e656852a9..8cb79d5db9 100644 --- a/Projectiles/Magic/PhantasmalFuryProj.cs +++ b/Projectiles/Magic/PhantasmalFuryProj.cs @@ -50,12 +50,12 @@ namespace CalamityMod.Projectiles.Magic Lighting.AddLight(Projectile.Center, 0.25f, 0.25f, 0.25f); - for (int num457 = 0; num457 < 3; num457++) + for (int i = 0; i < 3; i++) { - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 175, 0f, 0f, 100, default, 2f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int spectre = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 175, 0f, 0f, 100, default, 2f); + Main.dust[spectre].noGravity = true; + Main.dust[spectre].velocity *= 0.5f; + Main.dust[spectre].velocity += Projectile.velocity * 0.1f; } Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); diff --git a/Projectiles/Magic/Phantom.cs b/Projectiles/Magic/Phantom.cs index df91d37233..17efcbd8a3 100644 --- a/Projectiles/Magic/Phantom.cs +++ b/Projectiles/Magic/Phantom.cs @@ -24,10 +24,10 @@ namespace CalamityMod.Projectiles.Magic Lighting.AddLight(Projectile.Center, 0.2f, 0.2f, 0.2f); - for (int num457 = 0; num457 < 2; num457++) + for (int i = 0; i < 2; i++) { - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 175, 0f, 0f, 100, default, 1f); - Main.dust[num458].noGravity = true; + int spectre = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 175, 0f, 0f, 100, default, 1f); + Main.dust[spectre].noGravity = true; } CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 300f, 12f, 20f); diff --git a/Projectiles/Magic/PlagueFang.cs b/Projectiles/Magic/PlagueFang.cs index 3db5038dab..e30b11763e 100644 --- a/Projectiles/Magic/PlagueFang.cs +++ b/Projectiles/Magic/PlagueFang.cs @@ -37,15 +37,15 @@ namespace CalamityMod.Projectiles.Magic } if (Projectile.alpha == 0) { - int num159 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 163, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f); - Main.dust[num159].noGravity = true; - Main.dust[num159].velocity *= 0.6f; - Main.dust[num159].velocity -= Projectile.velocity * 0.4f; + int plagued = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 163, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f); + Main.dust[plagued].noGravity = true; + Main.dust[plagued].velocity *= 0.6f; + Main.dust[plagued].velocity -= Projectile.velocity * 0.4f; - int num160 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 205, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f); - Main.dust[num160].noGravity = true; - Main.dust[num160].velocity *= 0.2f; - Main.dust[num160].velocity -= Projectile.velocity * 0.4f; + int venomed = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 205, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f); + Main.dust[venomed].noGravity = true; + Main.dust[venomed].velocity *= 0.2f; + Main.dust[venomed].velocity -= Projectile.velocity * 0.4f; } } @@ -61,15 +61,15 @@ namespace CalamityMod.Projectiles.Magic public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Dig, Projectile.position); - for (int num301 = 0; num301 < 7; num301++) + for (int i = 0; i < 7; i++) { - int num302 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 163, 0f, 0f, 100, default, 1f); - Main.dust[num302].noGravity = true; - Main.dust[num302].velocity *= 1.2f; - Main.dust[num302].velocity -= Projectile.oldVelocity * 0.3f; + int killPlague = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 163, 0f, 0f, 100, default, 1f); + Main.dust[killPlague].noGravity = true; + Main.dust[killPlague].velocity *= 1.2f; + Main.dust[killPlague].velocity -= Projectile.oldVelocity * 0.3f; - int num402 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 205, 0f, 0f, 100, default, 1f); - Dust dust = Main.dust[num402]; + int killVenom = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 205, 0f, 0f, 100, default, 1f); + Dust dust = Main.dust[killVenom]; dust.noGravity = true; dust.velocity *= 1.2f; dust.velocity -= Projectile.oldVelocity * 0.3f; diff --git a/Projectiles/Magic/PlasmaRay.cs b/Projectiles/Magic/PlasmaRay.cs index 8a4b6da295..2c90f26dfb 100644 --- a/Projectiles/Magic/PlasmaRay.cs +++ b/Projectiles/Magic/PlasmaRay.cs @@ -38,15 +38,15 @@ namespace CalamityMod.Projectiles.Magic Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 9f) { - for (int num447 = 0; num447 < 4; num447++) + for (int i = 0; i < 4; i++) { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * ((float)num447 * 0.25f); + Vector2 projPos = Projectile.position; + projPos -= Projectile.velocity * ((float)i * 0.25f); Projectile.alpha = 255; - int num448 = Dust.NewDust(vector33, 1, 1, 173, 0f, 0f, 0, default, 0.75f); - Main.dust[num448].position = vector33; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.2f; + int purpDust = Dust.NewDust(projPos, 1, 1, 173, 0f, 0f, 0, default, 0.75f); + Main.dust[purpDust].position = projPos; + Main.dust[purpDust].scale = (float)Main.rand.Next(70, 110) * 0.013f; + Main.dust[purpDust].velocity *= 0.2f; } } } diff --git a/Projectiles/Magic/PlasmaRay2.cs b/Projectiles/Magic/PlasmaRay2.cs index c5dde3aa01..b055d0643a 100644 --- a/Projectiles/Magic/PlasmaRay2.cs +++ b/Projectiles/Magic/PlasmaRay2.cs @@ -36,15 +36,15 @@ namespace CalamityMod.Projectiles.Magic Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 9f) { - for (int num447 = 0; num447 < 4; num447++) + for (int i = 0; i < 4; i++) { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * ((float)num447 * 0.25f); + Vector2 projPos = Projectile.position; + projPos -= Projectile.velocity * ((float)i * 0.25f); Projectile.alpha = 255; - int num448 = Dust.NewDust(vector33, 1, 1, 173, 0f, 0f, 0, default, 0.25f); - Main.dust[num448].position = vector33; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.2f; + int purpDust = Dust.NewDust(projPos, 1, 1, 173, 0f, 0f, 0, default, 0.25f); + Main.dust[purpDust].position = projPos; + Main.dust[purpDust].scale = (float)Main.rand.Next(70, 110) * 0.013f; + Main.dust[purpDust].velocity *= 0.2f; } } } diff --git a/Projectiles/Magic/RancorLargeCinder.cs b/Projectiles/Magic/RancorLargeCinder.cs index 61adef419b..45e9a59036 100644 --- a/Projectiles/Magic/RancorLargeCinder.cs +++ b/Projectiles/Magic/RancorLargeCinder.cs @@ -1,5 +1,4 @@ -using CalamityMod.Particles; -using CalamityMod.Particles.Metaballs; +using CalamityMod.Graphics.Metaballs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -45,7 +44,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.velocity.Y += 0.04f; // Create lava particles. - FusableParticleManager.GetParticleSetByType().SpawnParticle(Projectile.Center + Main.rand.NextVector2Circular(6f, 6f), Projectile.scale * 36f); + RancorLavaMetaball.SpawnParticle(Projectile.Center + Main.rand.NextVector2Circular(6f, 6f), Projectile.scale * 36f); Time++; } diff --git a/Projectiles/Magic/RancorLaserbeam.cs b/Projectiles/Magic/RancorLaserbeam.cs index e0b5d5cf70..86ab25cc1b 100644 --- a/Projectiles/Magic/RancorLaserbeam.cs +++ b/Projectiles/Magic/RancorLaserbeam.cs @@ -1,6 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Particles; -using CalamityMod.Particles.Metaballs; +using CalamityMod.Graphics.Metaballs; using CalamityMod.World; using Microsoft.Xna.Framework; using System; @@ -147,7 +146,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.NewProjectile(Projectile.GetSource_FromThis(), endOfLaser, cinderVelocity, type, damage, 0f, Projectile.owner); } - FusableParticleManager.GetParticleSetByType().SpawnParticle(endOfLaser + Main.rand.NextVector2Circular(10f, 10f) + Projectile.velocity * 40f, 135f); + RancorLavaMetaball.SpawnParticle(endOfLaser + Main.rand.NextVector2Circular(10f, 10f) + Projectile.velocity * 40f, 135f); } private float PrimitiveWidthFunction(float completionRatio) => Projectile.scale * 20f; @@ -163,8 +162,7 @@ namespace CalamityMod.Projectiles.Magic public override bool PreDraw(ref Color lightColor) { - if (RayDrawer is null) - RayDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, specialShader: GameShaders.Misc["CalamityMod:Flame"]); + RayDrawer ??= new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, specialShader: GameShaders.Misc["CalamityMod:Flame"]); GameShaders.Misc["CalamityMod:Flame"].UseImage1("Images/Misc/Perlin"); diff --git a/Projectiles/Magic/RougeSlashLarge.cs b/Projectiles/Magic/RougeSlashLarge.cs index 766bd2f43c..f20b716ac9 100644 --- a/Projectiles/Magic/RougeSlashLarge.cs +++ b/Projectiles/Magic/RougeSlashLarge.cs @@ -43,15 +43,15 @@ namespace CalamityMod.Projectiles.Magic Projectile.localAI[1] = 0f; for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * -Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy(l * MathHelper.Pi / 6f) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy(Projectile.rotation - MathHelper.PiOver2); - int num9 = Dust.NewDust(Projectile.Center, 0, 0, 60, 0f, 0f, 160, default, 1f); - Main.dust[num9].scale = 1.1f; - Main.dust[num9].noGravity = true; - Main.dust[num9].position = Projectile.Center + vector3; - Main.dust[num9].velocity = Projectile.velocity * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; + Vector2 dustRotation = Vector2.UnitX * -Projectile.width / 2f; + dustRotation += -Vector2.UnitY.RotatedBy(l * MathHelper.Pi / 6f) * new Vector2(8f, 16f); + dustRotation = dustRotation.RotatedBy(Projectile.rotation - MathHelper.PiOver2); + int rougeDust = Dust.NewDust(Projectile.Center, 0, 0, 60, 0f, 0f, 160, default, 1f); + Main.dust[rougeDust].scale = 1.1f; + Main.dust[rougeDust].noGravity = true; + Main.dust[rougeDust].position = Projectile.Center + dustRotation; + Main.dust[rougeDust].velocity = Projectile.velocity * 0.1f; + Main.dust[rougeDust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[rougeDust].position) * 1.25f; } } } diff --git a/Projectiles/Magic/RougeSlashMedium.cs b/Projectiles/Magic/RougeSlashMedium.cs index 41dc229957..a2cdc52869 100644 --- a/Projectiles/Magic/RougeSlashMedium.cs +++ b/Projectiles/Magic/RougeSlashMedium.cs @@ -43,15 +43,15 @@ namespace CalamityMod.Projectiles.Magic Projectile.localAI[1] = 0f; for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * -Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy(l * MathHelper.Pi / 6f) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy(Projectile.rotation - MathHelper.PiOver2); - int num9 = Dust.NewDust(Projectile.Center, 0, 0, 60, 0f, 0f, 160, default, 1f); - Main.dust[num9].scale = 1.1f; - Main.dust[num9].noGravity = true; - Main.dust[num9].position = Projectile.Center + vector3; - Main.dust[num9].velocity = Projectile.velocity * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; + Vector2 dustRotation = Vector2.UnitX * -Projectile.width / 2f; + dustRotation += -Vector2.UnitY.RotatedBy(l * MathHelper.Pi / 6f) * new Vector2(8f, 16f); + dustRotation = dustRotation.RotatedBy(Projectile.rotation - MathHelper.PiOver2); + int rougeDust = Dust.NewDust(Projectile.Center, 0, 0, 60, 0f, 0f, 160, default, 1f); + Main.dust[rougeDust].scale = 1.1f; + Main.dust[rougeDust].noGravity = true; + Main.dust[rougeDust].position = Projectile.Center + dustRotation; + Main.dust[rougeDust].velocity = Projectile.velocity * 0.1f; + Main.dust[rougeDust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[rougeDust].position) * 1.25f; } } } diff --git a/Projectiles/Magic/RougeSlashSmall.cs b/Projectiles/Magic/RougeSlashSmall.cs index c1236edf92..be03e06883 100644 --- a/Projectiles/Magic/RougeSlashSmall.cs +++ b/Projectiles/Magic/RougeSlashSmall.cs @@ -43,15 +43,15 @@ namespace CalamityMod.Projectiles.Magic Projectile.localAI[1] = 0f; for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * -Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy(l * MathHelper.Pi / 6f) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy(Projectile.rotation - MathHelper.PiOver2); - int num9 = Dust.NewDust(Projectile.Center, 0, 0, 60, 0f, 0f, 160, default, 1f); - Main.dust[num9].scale = 1.1f; - Main.dust[num9].noGravity = true; - Main.dust[num9].position = Projectile.Center + vector3; - Main.dust[num9].velocity = Projectile.velocity * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; + Vector2 dustRotation = Vector2.UnitX * -Projectile.width / 2f; + dustRotation += -Vector2.UnitY.RotatedBy(l * MathHelper.Pi / 6f) * new Vector2(8f, 16f); + dustRotation = dustRotation.RotatedBy(Projectile.rotation - MathHelper.PiOver2); + int rougeDust = Dust.NewDust(Projectile.Center, 0, 0, 60, 0f, 0f, 160, default, 1f); + Main.dust[rougeDust].scale = 1.1f; + Main.dust[rougeDust].noGravity = true; + Main.dust[rougeDust].position = Projectile.Center + dustRotation; + Main.dust[rougeDust].velocity = Projectile.velocity * 0.1f; + Main.dust[rougeDust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[rougeDust].position) * 1.25f; } } } diff --git a/Projectiles/Magic/SHPB.cs b/Projectiles/Magic/SHPB.cs index f42e51aeca..0e15e88b72 100644 --- a/Projectiles/Magic/SHPB.cs +++ b/Projectiles/Magic/SHPB.cs @@ -30,9 +30,9 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight(Projectile.Center, 1f * num, 0.2f * num, 0.75f * num); + float lights = (float)Main.rand.Next(90, 111) * 0.01f; + lights *= Main.essScale; + Lighting.AddLight(Projectile.Center, 1f * lights, 0.2f * lights, 0.75f * lights); Projectile.alpha -= 2; Projectile.frameCounter++; if (Projectile.frameCounter > 4) @@ -64,25 +64,25 @@ namespace CalamityMod.Projectiles.Magic } Projectile.velocity.X *= 0.985f; Projectile.velocity.Y *= 0.985f; - float num472 = Projectile.Center.X; - float num473 = Projectile.Center.Y; - float num474 = 250f; - bool flag17 = false; - for (int num475 = 0; num475 < Main.maxNPCs; num475++) + float projX = Projectile.Center.X; + float projY = Projectile.Center.Y; + float explodeRange = 250f; + bool canExplode = false; + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num475].CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) + if (Main.npc[i].CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num476) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num477); - if (num478 < num474) + float npcX = Main.npc[i].position.X + (float)(Main.npc[i].width / 2); + float npcY = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2); + float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); + if (npcDist < explodeRange) { - num474 = num478; - flag17 = true; + explodeRange = npcDist; + canExplode = true; } } } - if (flag17) + if (canExplode) { explosionTimer--; if (explosionTimer <= 0) @@ -100,9 +100,9 @@ namespace CalamityMod.Projectiles.Magic public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } diff --git a/Projectiles/Magic/SHPExplosion.cs b/Projectiles/Magic/SHPExplosion.cs index 50782c0b7e..1534873dc1 100644 --- a/Projectiles/Magic/SHPExplosion.cs +++ b/Projectiles/Magic/SHPExplosion.cs @@ -25,31 +25,31 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight(Projectile.Center, 5f * num, 1f * num, 4f * num); - float num461 = 25f; + float lights = (float)Main.rand.Next(90, 111) * 0.01f; + lights *= Main.essScale; + Lighting.AddLight(Projectile.Center, 5f * lights, 1f * lights, 4f * lights); + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-40, 41); - float num464 = (float)Main.rand.Next(-40, 41); - float num465 = (float)Main.rand.Next(12, 36); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; + float rando1 = (float)Main.rand.Next(-40, 41); + float rando2 = (float)Main.rand.Next(-40, 41); + float rando3 = (float)Main.rand.Next(12, 36); + float randoAdjust = (float)Math.Sqrt((double)(rando1 * rando1 + rando2 * rando2)); + randoAdjust = rando3 / randoAdjust; + rando1 *= randoAdjust; + rando2 *= randoAdjust; int randomDust = Main.rand.Next(3); if (randomDust == 0) { @@ -63,17 +63,17 @@ namespace CalamityMod.Projectiles.Magic { randomDust = 187; } - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDust, 0f, 0f, 100, default, 2f); - Main.dust[num467].noGravity = true; - Main.dust[num467].position.X = Projectile.Center.X; - Main.dust[num467].position.Y = Projectile.Center.Y; - Dust expr_149DF_cp_0 = Main.dust[num467]; + int EXPLODE = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDust, 0f, 0f, 100, default, 2f); + Main.dust[EXPLODE].noGravity = true; + Main.dust[EXPLODE].position.X = Projectile.Center.X; + Main.dust[EXPLODE].position.Y = Projectile.Center.Y; + Dust expr_149DF_cp_0 = Main.dust[EXPLODE]; expr_149DF_cp_0.position.X += (float)Main.rand.Next(-10, 11); - Dust expr_14A09_cp_0 = Main.dust[num467]; + Dust expr_14A09_cp_0 = Main.dust[EXPLODE]; expr_14A09_cp_0.position.Y += (float)Main.rand.Next(-10, 11); - Main.dust[num467].velocity.X = num463; - Main.dust[num467].velocity.Y = num464; - num462++; + Main.dust[EXPLODE].velocity.X = rando1; + Main.dust[EXPLODE].velocity.Y = rando2; + timerCounter++; } } } diff --git a/Projectiles/Magic/SHPL.cs b/Projectiles/Magic/SHPL.cs index 018a0d42a2..db74a57ca1 100644 --- a/Projectiles/Magic/SHPL.cs +++ b/Projectiles/Magic/SHPL.cs @@ -31,19 +31,18 @@ namespace CalamityMod.Projectiles.Magic Projectile.alpha = 0; } Lighting.AddLight((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16, 0.5f, 0.2f, 0.5f); - float num55 = 100f; - float num56 = 3f; + float timerIncr = 3f; if (Projectile.ai[1] == 0f) { - Projectile.localAI[0] += num56; - if (Projectile.localAI[0] > num55) + Projectile.localAI[0] += timerIncr; + if (Projectile.localAI[0] > 100f) { - Projectile.localAI[0] = num55; + Projectile.localAI[0] = 100f; } } else { - Projectile.localAI[0] -= num56; + Projectile.localAI[0] -= timerIncr; if (Projectile.localAI[0] <= 0f) { Projectile.Kill(); diff --git a/Projectiles/Magic/Sandstream.cs b/Projectiles/Magic/Sandstream.cs new file mode 100644 index 0000000000..ba1a111ee5 --- /dev/null +++ b/Projectiles/Magic/Sandstream.cs @@ -0,0 +1,123 @@ +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class Sandstream : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public int Time = 0; + public bool PostHit = false; + public override void SetDefaults() + { + Projectile.width = 32; + Projectile.height = 32; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.penetrate = -1; + Projectile.extraUpdates = 2; + Projectile.DamageType = DamageClass.Magic; + Projectile.tileCollide = true; + Projectile.timeLeft = 240; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void AI() + { + Time++; + if (Time == 1) + { + for (int i = 0; i <= 10; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center,313, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.2f, 1.2f), 0, default, Main.rand.NextFloat(1.3f, 1.7f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.7f, 2.3f); + } + } + if (PostHit) + { + for (int i = 0; i < 4; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 216 : 32); + dust.noGravity = true; + dust.velocity = new Vector2(0.5f, 0.5f).RotatedByRandom(100); + dust.scale = Main.rand.NextFloat(0.3f, 1.3f); + } + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 313); + dust2.noGravity = true; + dust2.velocity = -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.5f); + dust2.scale = Main.rand.NextFloat(0.3f, 1.3f); + Projectile.penetrate = 1; + Projectile.velocity.Y += 0.1f; + Projectile.velocity.X *= 0.97f; + Projectile.extraUpdates = 3; + } + else + { + if (Main.rand.NextBool(5)) + { + MediumMistParticle SandCloud = new MediumMistParticle(Projectile.Center, (-Projectile.velocity * 0.2f).RotatedByRandom(0.2f), Color.Peru, Color.PeachPuff, MathHelper.Clamp(Main.rand.NextFloat(1.1f, 1.5f) - Time * 0.02f, 0.5f, 2), 120f, Main.rand.NextFloat(0.03f, -0.03f)); + GeneralParticleHandler.SpawnParticle(SandCloud); + } + for (int i = 0; i < 4; i++) + { + float DustArea = MathHelper.Clamp(3 - Time * 0.03f, 1, 3); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(DustArea, DustArea), Main.rand.NextBool(3) ? 216 : 32); + dust.noGravity = true; + dust.velocity = new Vector2(0.5f, 0.5f).RotatedByRandom(100) + Projectile.velocity * 0.3f; + dust.scale = MathHelper.Clamp(Main.rand.NextFloat(1.4f, 1.9f) - Time * 0.01f, 0.9f, 1.5f); + } + + if (Main.rand.NextBool(4)) + { + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 216 : 32); + dust2.noGravity = false; + dust2.velocity = new Vector2(0, Main.rand.NextFloat(1, 4)); + dust2.scale = Main.rand.NextFloat(0.3f, 0.5f); + dust2.fadeIn = 0.7f; + } + Projectile.velocity.Y += 0.035f; + } + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + PostHit = true; + Projectile.timeLeft = 300; + float numberOfDusts = 6f; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) + { + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 offset = new Vector2(Main.rand.NextFloat(0.5f, 1.5f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + Vector2 velOffset = new Vector2(Main.rand.NextFloat(0.5f, 1.5f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + Dust dust = Dust.NewDustPerfect(target.Center + offset, Main.rand.NextBool(3) ? 288 : 207, new Vector2(velOffset.X, velOffset.Y)); + dust.noGravity = false; + dust.velocity = velOffset; + dust.scale = Main.rand.NextFloat(0.5f, 0.8f); + } + } + public override void OnKill(int timeLeft) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage / 3, Projectile.knockBack * 4, Projectile.owner); + float numberOfDusts = 20f; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) + { + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 offset = new Vector2(Main.rand.NextFloat(1.5f, 5.5f), 0).RotatedBy(rot * Main.rand.NextFloat(3.1f, 9.1f)); + Vector2 velOffset = new Vector2(Main.rand.NextFloat(1.5f, 5.5f), 0).RotatedBy(rot * Main.rand.NextFloat(3.1f, 9.1f)); + MediumMistParticle SandCloud = new MediumMistParticle(Projectile.Center + offset, velOffset * Main.rand.NextFloat(1.5f, 3f), Color.Peru, Color.PeachPuff, Main.rand.NextFloat(0.9f, 1.2f), 160f, Main.rand.NextFloat(0.03f, -0.03f)); + GeneralParticleHandler.SpawnParticle(SandCloud); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, Main.rand.NextBool() ? 288 : 207, new Vector2(velOffset.X, velOffset.Y)); + dust.noGravity = false; + dust.velocity = velOffset; + dust.scale = Main.rand.NextFloat(1.2f, 1.6f); + } + } + } +} diff --git a/Projectiles/Magic/SandstreamScepterExplosion.cs b/Projectiles/Magic/SandstreamScepterExplosion.cs new file mode 100644 index 0000000000..6e5e86bd99 --- /dev/null +++ b/Projectiles/Magic/SandstreamScepterExplosion.cs @@ -0,0 +1,30 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Magic +{ + public class SandstreamScepterExplosion : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Player Owner => Main.player[Projectile.owner]; + private static float ExplosionRadius = 112f; + + public override void SetDefaults() + { + //These shouldn't matter because its circular + Projectile.width = 112; + Projectile.height = 112; + Projectile.friendly = true; + Projectile.DamageType = RogueDamageClass.Instance; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 2; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, ExplosionRadius, targetHitbox); + } +} diff --git a/Projectiles/Magic/SanguineFlareProj.cs b/Projectiles/Magic/SanguineFlareProj.cs index 73fe0a05ce..cf6e69a93e 100644 --- a/Projectiles/Magic/SanguineFlareProj.cs +++ b/Projectiles/Magic/SanguineFlareProj.cs @@ -36,6 +36,7 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { + Lighting.AddLight(Projectile.Center, 1f, 0f, 0f); if (Projectile.localAI[0] == 0f) { Projectile.velocity.X = Projectile.velocity.X + (Main.player[Projectile.owner].velocity.X * 0.5f); @@ -57,6 +58,11 @@ namespace CalamityMod.Projectiles.Magic } } + public override Color? GetAlpha(Color lightColor) + { + return new Color(200, 60, 60, Projectile.alpha); + } + public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item14, Projectile.position); @@ -66,23 +72,23 @@ namespace CalamityMod.Projectiles.Magic Projectile.height = 10; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 3; num621++) + for (int i = 0; i < 3; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; + int brimDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.2f); + Main.dust[brimDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[brimDust].scale = 0.5f; + Main.dust[brimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 6; num623++) + for (int j = 0; j < 6; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int brimDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.7f); + Main.dust[brimDust2].noGravity = true; + Main.dust[brimDust2].velocity *= 5f; + brimDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); + Main.dust[brimDust2].velocity *= 2f; } } diff --git a/Projectiles/Magic/SerpentineBody.cs b/Projectiles/Magic/SerpentineBody.cs index 010583229c..88aba041e0 100644 --- a/Projectiles/Magic/SerpentineBody.cs +++ b/Projectiles/Magic/SerpentineBody.cs @@ -25,41 +25,41 @@ namespace CalamityMod.Projectiles.Magic Projectile.DamageType = DamageClass.Magic; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 20; + Projectile.ArmorPenetration = 15; } public override void AI() { Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.55f / 255f, (255 - Projectile.alpha) * 0.55f / 255f); - int num1051 = 10; - Vector2 value68 = Vector2.Zero; + Vector2 zeroing = Vector2.Zero; if (Projectile.ai[1] == 1f) { Projectile.ai[1] = 0f; Projectile.netUpdate = true; } int chase = Projectile.GetByUUID(Projectile.owner, (int)Projectile.ai[0]); - float num1064; - float scaleFactor17; - float scaleFactor18; + float projRotation; + float sixteenScale; + float projScale; if (chase >= 0 && Main.projectile[chase].active) { - value68 = Main.projectile[chase].Center; + zeroing = Main.projectile[chase].Center; Vector2 arg_2DE6A_0 = Main.projectile[chase].velocity; - num1064 = Main.projectile[chase].rotation; - scaleFactor18 = MathHelper.Clamp(Main.projectile[chase].scale, 0f, 50f); - scaleFactor17 = 16f; + projRotation = Main.projectile[chase].rotation; + projScale = MathHelper.Clamp(Main.projectile[chase].scale, 0f, 50f); + sixteenScale = 16f; Main.projectile[chase].localAI[0] = Projectile.localAI[0] + 1f; } else { for (int k = 0; k < 8; k++) { - int num114 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 68, 0f, 0f, 100, default, 1.25f); - Dust dust = Main.dust[num114]; + int seaDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 68, 0f, 0f, 100, default, 1.25f); + Dust dust = Main.dust[seaDust]; dust.velocity *= 0.3f; - Main.dust[num114].position.X = Projectile.position.X + (float)(Projectile.width / 2) + 4f + (float)Main.rand.Next(-4, 5); - Main.dust[num114].position.Y = Projectile.position.Y + (float)(Projectile.height / 2) + (float)Main.rand.Next(-4, 5); - Main.dust[num114].noGravity = true; + Main.dust[seaDust].position.X = Projectile.position.X + (float)(Projectile.width / 2) + 4f + (float)Main.rand.Next(-4, 5); + Main.dust[seaDust].position.Y = Projectile.position.Y + (float)(Projectile.height / 2) + (float)Main.rand.Next(-4, 5); + Main.dust[seaDust].noGravity = true; } Projectile.active = false; Projectile.Kill(); @@ -74,22 +74,22 @@ namespace CalamityMod.Projectiles.Magic Projectile.alpha = 0; } Projectile.velocity = Vector2.Zero; - Vector2 vector134 = value68 - Projectile.Center; - if (num1064 != Projectile.rotation) + Vector2 rotateInLine = zeroing - Projectile.Center; + if (projRotation != Projectile.rotation) { - float num1068 = MathHelper.WrapAngle(num1064 - Projectile.rotation); - vector134 = vector134.RotatedBy((double)(num1068 * 0.1f), default); + float angleWrap = MathHelper.WrapAngle(projRotation - Projectile.rotation); + rotateInLine = rotateInLine.RotatedBy((double)(angleWrap * 0.1f), default); } - Projectile.rotation = vector134.ToRotation() + 1.57079637f; + Projectile.rotation = rotateInLine.ToRotation() + 1.57079637f; Projectile.position = Projectile.Center; - Projectile.scale = scaleFactor18; - Projectile.width = Projectile.height = (int)((float)num1051 * Projectile.scale); + Projectile.scale = projScale; + Projectile.width = Projectile.height = (int)(10f * Projectile.scale); Projectile.Center = Projectile.position; - if (vector134 != Vector2.Zero) + if (rotateInLine != Vector2.Zero) { - Projectile.Center = value68 - Vector2.Normalize(vector134) * scaleFactor17 * scaleFactor18; + Projectile.Center = zeroing - Vector2.Normalize(rotateInLine) * sixteenScale * projScale; } - Projectile.spriteDirection = (vector134.X > 0f) ? 1 : -1; + Projectile.spriteDirection = (rotateInLine.X > 0f) ? 1 : -1; return; } } diff --git a/Projectiles/Magic/SerpentineHead.cs b/Projectiles/Magic/SerpentineHead.cs index b71004de06..eda87d1e9a 100644 --- a/Projectiles/Magic/SerpentineHead.cs +++ b/Projectiles/Magic/SerpentineHead.cs @@ -27,6 +27,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.DamageType = DamageClass.Magic; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 20; + Projectile.ArmorPenetration = 15; } public override void AI() @@ -40,12 +41,12 @@ namespace CalamityMod.Projectiles.Magic { Projectile.alpha = 0; } - int num114 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 68, 0f, 0f, 100, default, 1.25f); - Dust dust = Main.dust[num114]; + int seaDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 68, 0f, 0f, 100, default, 1.25f); + Dust dust = Main.dust[seaDust]; dust.velocity *= 0.3f; - Main.dust[num114].position.X = Projectile.position.X + (float)(Projectile.width / 2) + 4f + (float)Main.rand.Next(-4, 5); - Main.dust[num114].position.Y = Projectile.position.Y + (float)(Projectile.height / 2) + (float)Main.rand.Next(-4, 5); - Main.dust[num114].noGravity = true; + Main.dust[seaDust].position.X = Projectile.position.X + (float)(Projectile.width / 2) + 4f + (float)Main.rand.Next(-4, 5); + Main.dust[seaDust].position.Y = Projectile.position.Y + (float)(Projectile.height / 2) + (float)Main.rand.Next(-4, 5); + Main.dust[seaDust].noGravity = true; Projectile.rotation = Projectile.velocity.ToRotation() + 1.57079637f; int direction = Projectile.direction; Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X > 0f) ? 1 : -1; @@ -53,9 +54,9 @@ namespace CalamityMod.Projectiles.Magic { Projectile.netUpdate = true; } - float num1061 = MathHelper.Clamp(Projectile.localAI[0], 0f, 50f); + float scaleClamp = MathHelper.Clamp(Projectile.localAI[0], 0f, 50f); Projectile.position = Projectile.Center; - Projectile.scale = 1f + num1061 * 0.01f; + Projectile.scale = 1f + scaleClamp * 0.01f; Projectile.width = Projectile.height = (int)(10 * Projectile.scale); Projectile.Center = Projectile.position; @@ -76,70 +77,69 @@ namespace CalamityMod.Projectiles.Magic { if (Main.player[Projectile.owner].channel) { - float num115 = 18f; - Vector2 vector10 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num116 = (float)Main.mouseX + Main.screenPosition.X - vector10.X; - float num117 = (float)Main.mouseY + Main.screenPosition.Y - vector10.Y; + float chaseMouseDist = 18f; + Vector2 projDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float mouseX = (float)Main.mouseX + Main.screenPosition.X - projDirection.X; + float mouseY = (float)Main.mouseY + Main.screenPosition.Y - projDirection.Y; if (Main.player[Projectile.owner].gravDir == -1f) { - num117 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector10.Y; + mouseY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - projDirection.Y; } - float num118 = (float)Math.Sqrt((double)(num116 * num116 + num117 * num117)); - num118 = (float)Math.Sqrt((double)(num116 * num116 + num117 * num117)); - if (num118 > num115) + float mouseDist = (float)Math.Sqrt((double)(mouseX * mouseX + mouseY * mouseY)); + mouseDist = (float)Math.Sqrt((double)(mouseX * mouseX + mouseY * mouseY)); + if (mouseDist > chaseMouseDist) { - num118 = num115 / num118; - num116 *= num118; - num117 *= num118; - int num119 = (int)(num116 * 1000f); - int num120 = (int)(Projectile.velocity.X * 1000f); - int num121 = (int)(num117 * 1000f); - int num122 = (int)(Projectile.velocity.Y * 1000f); - if (num119 != num120 || num121 != num122) + mouseDist = chaseMouseDist / mouseDist; + mouseX *= mouseDist; + mouseY *= mouseDist; + int xVelocity = (int)(mouseX * 1000f); + int exaggeratedXVelocity = (int)(Projectile.velocity.X * 1000f); + int yVelocity = (int)(mouseY * 1000f); + int exaggeratedYVelocity = (int)(Projectile.velocity.Y * 1000f); + if (xVelocity != exaggeratedXVelocity || yVelocity != exaggeratedYVelocity) { Projectile.netUpdate = true; } - Projectile.velocity.X = num116; - Projectile.velocity.Y = num117; + Projectile.velocity.X = mouseX; + Projectile.velocity.Y = mouseY; } else { - int num123 = (int)(num116 * 1000f); - int num124 = (int)(Projectile.velocity.X * 1000f); - int num125 = (int)(num117 * 1000f); - int num126 = (int)(Projectile.velocity.Y * 1000f); - if (num123 != num124 || num125 != num126) + int xVel = (int)(mouseX * 1000f); + int exagXVel = (int)(Projectile.velocity.X * 1000f); + int yVel = (int)(mouseY * 1000f); + int exagYVel = (int)(Projectile.velocity.Y * 1000f); + if (xVel != exagXVel || yVel != exagYVel) { Projectile.netUpdate = true; } - Projectile.velocity.X = num116; - Projectile.velocity.Y = num117; + Projectile.velocity.X = mouseX; + Projectile.velocity.Y = mouseY; } } else if (Projectile.ai[0] <= 0f) { Projectile.netUpdate = true; - float num127 = 12f; - Vector2 vector11 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num128 = (float)Main.mouseX + Main.screenPosition.X - vector11.X; - float num129 = (float)Main.mouseY + Main.screenPosition.Y - vector11.Y; + Vector2 faceDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float miceX = (float)Main.mouseX + Main.screenPosition.X - faceDirection.X; + float miceY = (float)Main.mouseY + Main.screenPosition.Y - faceDirection.Y; if (Main.player[Projectile.owner].gravDir == -1f) { - num129 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector11.Y; + miceY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - faceDirection.Y; } - float num130 = (float)Math.Sqrt((double)(num128 * num128 + num129 * num129)); - if (num130 == 0f || Projectile.ai[0] < 0f) + float miceDist = (float)Math.Sqrt((double)(miceX * miceX + miceY * miceY)); + if (miceDist == 0f || Projectile.ai[0] < 0f) { - vector11 = new Vector2(Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2), Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2)); - num128 = Projectile.position.X + (float)Projectile.width * 0.5f - vector11.X; - num129 = Projectile.position.Y + (float)Projectile.height * 0.5f - vector11.Y; - num130 = (float)Math.Sqrt((double)(num128 * num128 + num129 * num129)); + faceDirection = new Vector2(Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2), Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2)); + miceX = Projectile.position.X + (float)Projectile.width * 0.5f - faceDirection.X; + miceY = Projectile.position.Y + (float)Projectile.height * 0.5f - faceDirection.Y; + miceDist = (float)Math.Sqrt((double)(miceX * miceX + miceY * miceY)); } - num130 = num127 / num130; - num128 *= num130; - num129 *= num130; - Projectile.velocity.X = num128; - Projectile.velocity.Y = num129; + miceDist = 12f / miceDist; + miceX *= miceDist; + miceY *= miceDist; + Projectile.velocity.X = miceX; + Projectile.velocity.Y = miceY; if (Projectile.velocity.X == 0f && Projectile.velocity.Y == 0f) { Projectile.Kill(); @@ -162,12 +162,12 @@ namespace CalamityMod.Projectiles.Magic SoundEngine.PlaySound(SoundID.Item10, Projectile.position); for (int k = 0; k < 8; k++) { - int num114 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 68, 0f, 0f, 100, default, 1.25f); - Dust dust = Main.dust[num114]; + int seaDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 68, 0f, 0f, 100, default, 1.25f); + Dust dust = Main.dust[seaDust]; dust.velocity *= 0.3f; - Main.dust[num114].position.X = Projectile.position.X + (float)(Projectile.width / 2) + 4f + (float)Main.rand.Next(-4, 5); - Main.dust[num114].position.Y = Projectile.position.Y + (float)(Projectile.height / 2) + (float)Main.rand.Next(-4, 5); - Main.dust[num114].noGravity = true; + Main.dust[seaDust].position.X = Projectile.position.X + (float)(Projectile.width / 2) + 4f + (float)Main.rand.Next(-4, 5); + Main.dust[seaDust].position.Y = Projectile.position.Y + (float)(Projectile.height / 2) + (float)Main.rand.Next(-4, 5); + Main.dust[seaDust].noGravity = true; } } } diff --git a/Projectiles/Magic/SerpentineTail.cs b/Projectiles/Magic/SerpentineTail.cs index e4b3dd6d90..671cc97aa0 100644 --- a/Projectiles/Magic/SerpentineTail.cs +++ b/Projectiles/Magic/SerpentineTail.cs @@ -25,41 +25,41 @@ namespace CalamityMod.Projectiles.Magic Projectile.DamageType = DamageClass.Magic; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 20; + Projectile.ArmorPenetration = 15; } public override void AI() { Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0.25f / 255f); - int num1051 = 10; - Vector2 value68 = Vector2.Zero; + Vector2 zeroing = Vector2.Zero; if (Projectile.ai[1] == 1f) { Projectile.ai[1] = 0f; Projectile.netUpdate = true; } int chase = Projectile.GetByUUID(Projectile.owner, (int)Projectile.ai[0]); - float num1064; - float scaleFactor17; - float scaleFactor18; + float projRotation; + float sixteenScale; + float projScale; if (chase >= 0 && Main.projectile[chase].active) { - value68 = Main.projectile[chase].Center; + zeroing = Main.projectile[chase].Center; Vector2 arg_2DE6A_0 = Main.projectile[chase].velocity; - num1064 = Main.projectile[chase].rotation; - scaleFactor18 = MathHelper.Clamp(Main.projectile[chase].scale, 0f, 50f); - scaleFactor17 = 16f; + projRotation = Main.projectile[chase].rotation; + projScale = MathHelper.Clamp(Main.projectile[chase].scale, 0f, 50f); + sixteenScale = 16f; Main.projectile[chase].localAI[0] = Projectile.localAI[0] + 1f; } else { for (int k = 0; k < 8; k++) { - int num114 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 68, 0f, 0f, 100, default, 1.25f); - Dust dust = Main.dust[num114]; + int seaDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 68, 0f, 0f, 100, default, 1.25f); + Dust dust = Main.dust[seaDust]; dust.velocity *= 0.3f; - Main.dust[num114].position.X = Projectile.position.X + (float)(Projectile.width / 2) + 4f + (float)Main.rand.Next(-4, 5); - Main.dust[num114].position.Y = Projectile.position.Y + (float)(Projectile.height / 2) + (float)Main.rand.Next(-4, 5); - Main.dust[num114].noGravity = true; + Main.dust[seaDust].position.X = Projectile.position.X + (float)(Projectile.width / 2) + 4f + (float)Main.rand.Next(-4, 5); + Main.dust[seaDust].position.Y = Projectile.position.Y + (float)(Projectile.height / 2) + (float)Main.rand.Next(-4, 5); + Main.dust[seaDust].noGravity = true; } Projectile.active = false; Projectile.Kill(); @@ -74,22 +74,22 @@ namespace CalamityMod.Projectiles.Magic Projectile.alpha = 0; } Projectile.velocity = Vector2.Zero; - Vector2 vector134 = value68 - Projectile.Center; - if (num1064 != Projectile.rotation) + Vector2 rotateInLine = zeroing - Projectile.Center; + if (projRotation != Projectile.rotation) { - float num1068 = MathHelper.WrapAngle(num1064 - Projectile.rotation); - vector134 = vector134.RotatedBy((double)(num1068 * 0.1f), default); + float angleWrap = MathHelper.WrapAngle(projRotation - Projectile.rotation); + rotateInLine = rotateInLine.RotatedBy((double)(angleWrap * 0.1f), default); } - Projectile.rotation = vector134.ToRotation() + 1.57079637f; + Projectile.rotation = rotateInLine.ToRotation() + 1.57079637f; Projectile.position = Projectile.Center; - Projectile.scale = scaleFactor18; - Projectile.width = Projectile.height = (int)((float)num1051 * Projectile.scale); + Projectile.scale = projScale; + Projectile.width = Projectile.height = (int)(10f * Projectile.scale); Projectile.Center = Projectile.position; - if (vector134 != Vector2.Zero) + if (rotateInLine != Vector2.Zero) { - Projectile.Center = value68 - Vector2.Normalize(vector134) * scaleFactor17 * scaleFactor18; + Projectile.Center = zeroing - Vector2.Normalize(rotateInLine) * sixteenScale * projScale; } - Projectile.spriteDirection = (vector134.X > 0f) ? 1 : -1; + Projectile.spriteDirection = (rotateInLine.X > 0f) ? 1 : -1; return; } } diff --git a/Projectiles/Magic/ShadeNimbus.cs b/Projectiles/Magic/ShadeNimbus.cs index 7f2a1bdea8..9bf3b72a10 100644 --- a/Projectiles/Magic/ShadeNimbus.cs +++ b/Projectiles/Magic/ShadeNimbus.cs @@ -53,9 +53,9 @@ namespace CalamityMod.Projectiles.Magic Projectile.ai[0] = 0f; if (Projectile.owner == Main.myPlayer) { - int num414 = (int)(Projectile.position.X + 14f + (float)Main.rand.Next(Projectile.width - 28)); - int num415 = (int)(Projectile.position.Y + (float)Projectile.height + 4f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)num414, (float)num415, 0f, 5f, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner, 0f, 0f); + int rainX = (int)(Projectile.position.X + 14f + (float)Main.rand.Next(Projectile.width - 28)); + int rainY = (int)(Projectile.position.Y + (float)Projectile.height + 4f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)rainX, (float)rainY, 0f, 5f, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner, 0f, 0f); } } } diff --git a/Projectiles/Magic/ShadecrystalProjectile.cs b/Projectiles/Magic/ShadecrystalProjectile.cs index 7027bd4cae..f224c93e2e 100644 --- a/Projectiles/Magic/ShadecrystalProjectile.cs +++ b/Projectiles/Magic/ShadecrystalProjectile.cs @@ -28,10 +28,10 @@ namespace CalamityMod.Projectiles.Magic if (Main.rand.NextBool(4)) { - int num300 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 70, 0f, 0f, 0, default, 1f); - Main.dust[num300].noGravity = true; - Main.dust[num300].velocity *= 0.2f; - Main.dust[num300].scale *= 0.8f; + int crystalDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 70, 0f, 0f, 0, default, 1f); + Main.dust[crystalDust].noGravity = true; + Main.dust[crystalDust].velocity *= 0.2f; + Main.dust[crystalDust].scale *= 0.8f; } Projectile.velocity *= 0.99f; diff --git a/Projectiles/Magic/Shadowbolt.cs b/Projectiles/Magic/Shadowbolt.cs index fd49a0a11a..5b559abf06 100644 --- a/Projectiles/Magic/Shadowbolt.cs +++ b/Projectiles/Magic/Shadowbolt.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -47,7 +47,8 @@ namespace CalamityMod.Projectiles.Magic public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - Projectile.damage = (int)(Projectile.damage * 1.15); + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 1.15); } public override void AI() @@ -55,15 +56,15 @@ namespace CalamityMod.Projectiles.Magic Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 9f) { - for (int num447 = 0; num447 < 4; num447++) + for (int i = 0; i < 4; i++) { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * ((float)num447 * 0.25f); + Vector2 projPos = Projectile.position; + projPos -= Projectile.velocity * ((float)i * 0.25f); Projectile.alpha = 255; - int num448 = Dust.NewDust(vector33, 1, 1, 173, 0f, 0f, 0, default, 1f); - Main.dust[num448].position = vector33; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.2f; + int shadowDust = Dust.NewDust(projPos, 1, 1, 173, 0f, 0f, 0, default, 1f); + Main.dust[shadowDust].position = projPos; + Main.dust[shadowDust].scale = (float)Main.rand.Next(70, 110) * 0.013f; + Main.dust[shadowDust].velocity *= 0.2f; } } } diff --git a/Projectiles/Magic/SmallSpirit.cs b/Projectiles/Magic/SmallSpirit.cs index fb9abe07fd..3c24b7b56c 100644 --- a/Projectiles/Magic/SmallSpirit.cs +++ b/Projectiles/Magic/SmallSpirit.cs @@ -1,5 +1,4 @@ -using CalamityMod.Particles; -using CalamityMod.Particles.Metaballs; +using CalamityMod.Graphics.Metaballs; using Microsoft.Xna.Framework; using System; using Terraria; @@ -49,7 +48,7 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - float radius = MathHelper.SmoothStep(84f, 44f, (float)Math.Sqrt(1f - Projectile.timeLeft / 360f)); + float radius = MathHelper.SmoothStep(67f, 32f, (float)Math.Sqrt(1f - Projectile.timeLeft / 360f)); // Handle frames. Projectile.frameCounter++; @@ -68,7 +67,7 @@ namespace CalamityMod.Projectiles.Magic { Projectile.hostile = false; - radius += 54f; + radius += 36f; target = ProjectileOwner; flySpeed = 29f; @@ -109,7 +108,7 @@ namespace CalamityMod.Projectiles.Magic // Emit particles. Vector2 spawnPosition = Projectile.Center + Main.rand.NextVector2Circular(5f, 5f) * radius / 130f; - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(spawnPosition, radius); + GruesomeMetaball.SpawnParticle(spawnPosition, Main.rand.NextVector2Circular(6f, 6f), radius); } public override Color? GetAlpha(Color lightColor) => Color.White * Projectile.Opacity; diff --git a/Projectiles/Magic/Snowball.cs b/Projectiles/Magic/Snowball.cs index 5e776b8acd..cf0c9f0d3c 100644 --- a/Projectiles/Magic/Snowball.cs +++ b/Projectiles/Magic/Snowball.cs @@ -38,15 +38,15 @@ namespace CalamityMod.Projectiles.Magic { SoundEngine.PlaySound(SoundID.Item27, Projectile.position); //crystal bullet shards - for (int index1 = 0; index1 < 10; ++index1) + for (int i = 0; i < 10; ++i) { - int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 68, 0f, 0f, 0, new Color(), 1f); - Main.dust[index2].noGravity = true; - Main.dust[index2].velocity *= 2f; + int snow = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 68, 0f, 0f, 0, new Color(), 1f); + Main.dust[snow].noGravity = true; + Main.dust[snow].velocity *= 2f; } if (Projectile.owner == Main.myPlayer) { - for (int index = 0; index < 6; ++index) + for (int j = 0; j < 6; ++j) { float SpeedX = -Projectile.velocity.X * Main.rand.Next(40, 70) * 0.01f + Main.rand.Next(-20, 21) * 0.4f; float SpeedY = -Projectile.velocity.Y * Main.rand.Next(40, 70) * 0.01f + Main.rand.Next(-20, 21) * 0.4f; diff --git a/Projectiles/Magic/SolarElementalBeam.cs b/Projectiles/Magic/SolarElementalBeam.cs index 7c6c372405..ecde7f4ccb 100644 --- a/Projectiles/Magic/SolarElementalBeam.cs +++ b/Projectiles/Magic/SolarElementalBeam.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Projectiles.BaseProjectiles; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -68,6 +69,7 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { + target.AddBuff(ModContent.BuffType(), 30); int type = ModContent.ProjectileType(); int boomDamage = (int)(hit.Damage * 1.1); int boom = Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, type, boomDamage, hit.Knockback, Projectile.owner, 0f, Main.rand.NextFloat(0.85f, 2f)); diff --git a/Projectiles/Magic/SoulPiercerBeam.cs b/Projectiles/Magic/SoulPiercerBeam.cs index 27bc43185f..32865cc081 100644 --- a/Projectiles/Magic/SoulPiercerBeam.cs +++ b/Projectiles/Magic/SoulPiercerBeam.cs @@ -28,13 +28,13 @@ namespace CalamityMod.Projectiles.Magic Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 9f) { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity; + Vector2 projPos = Projectile.position; + projPos -= Projectile.velocity; Projectile.alpha = 255; - int num448 = Dust.NewDust(vector33, 1, 1, 173, 0f, 0f, 0, default, 0.5f); - Main.dust[num448].position = vector33; - Main.dust[num448].scale = Main.rand.Next(70, 110) * 0.014f; - Main.dust[num448].velocity *= 0.2f; + int godSlay = Dust.NewDust(projPos, 1, 1, 173, 0f, 0f, 0, default, 0.5f); + Main.dust[godSlay].position = projPos; + Main.dust[godSlay].scale = Main.rand.Next(70, 110) * 0.014f; + Main.dust[godSlay].velocity *= 0.2f; } } diff --git a/Projectiles/Magic/SoulPiercerBolt.cs b/Projectiles/Magic/SoulPiercerBolt.cs index bef8d1b01c..6d7e9ad409 100644 --- a/Projectiles/Magic/SoulPiercerBolt.cs +++ b/Projectiles/Magic/SoulPiercerBolt.cs @@ -26,12 +26,12 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity; - int num448 = Dust.NewDust(vector33, 1, 1, 173, 0f, 0f, 0, default, 0.5f); - Main.dust[num448].position = vector33; - Main.dust[num448].scale = Main.rand.Next(70, 110) * 0.014f; - Main.dust[num448].velocity *= 0.2f; + Vector2 projPos = Projectile.position; + projPos -= Projectile.velocity; + int godSlay = Dust.NewDust(projPos, 1, 1, 173, 0f, 0f, 0, default, 0.5f); + Main.dust[godSlay].position = projPos; + Main.dust[godSlay].scale = Main.rand.Next(70, 110) * 0.014f; + Main.dust[godSlay].velocity *= 0.2f; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 180); diff --git a/Projectiles/Magic/SpiritCongregation.cs b/Projectiles/Magic/SpiritCongregation.cs index ac81c8ca39..48ffe84e32 100644 --- a/Projectiles/Magic/SpiritCongregation.cs +++ b/Projectiles/Magic/SpiritCongregation.cs @@ -1,15 +1,13 @@ -using CalamityMod.Particles; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.IO; using Terraria; -using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; -using CalamityMod.Particles.Metaballs; -using Terraria.DataStructures; +using System.Collections.Generic; +using CalamityMod.Graphics.Metaballs; namespace CalamityMod.Projectiles.Magic { @@ -62,6 +60,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 12; Projectile.timeLeft = 90000; + Projectile.hide = true; } public override void SendExtraAI(BinaryWriter writer) @@ -229,8 +228,8 @@ namespace CalamityMod.Projectiles.Magic particleSize += (Projectile.oldPosition - Projectile.position).Length() * 4.2f; // Place a hard limit on particle sizes. - if (particleSize > 500f) - particleSize = 500f; + if (particleSize > 210f) + particleSize = 210f; // Make particles shrink when dying. particleSize *= MathHelper.Lerp(1f, 0.5f, Utils.GetLerpValue(0f, 35f, DeathCounter, true)); @@ -240,12 +239,15 @@ namespace CalamityMod.Projectiles.Magic { // Summon a base particle. Vector2 spawnPosition = Projectile.Center + Main.rand.NextVector2Circular(1f, 1f) * particleSize / 26f; - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(spawnPosition, particleSize); + GruesomeMetaball.SpawnParticle(spawnPosition, Main.rand.NextVector2Circular(4.4f, 4.4f), particleSize); // And an "ahead" particle that spawns based on current movement. // This causes the "head" of the overall thing to have bumps when moving. spawnPosition += Projectile.velocity.RotatedByRandom(1.38f) * particleSize / 105f; - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(spawnPosition, particleSize * 0.4f); + GruesomeMetaball.SpawnParticle(spawnPosition, Main.rand.NextVector2Circular(i * 1.5f + 7f, i * 1.5f + 7f), particleSize * 0.3f); + + // Make particle sizes exponentially decrease across loop iterations. + particleSize *= 0.9f; } // Release gas projectiles randomly. This does not happen when dying. @@ -263,41 +265,56 @@ namespace CalamityMod.Projectiles.Magic Projectile.frame = Projectile.frameCounter / 5 % maxFrame; } + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + { + // Ensure that the teeth draw over the metaballs. + overPlayers.Add(index); + } + public override bool PreDraw(ref Color lightColor) { - int maxFrame = CurrentPower <= LargeMouthPowerLowerBound ? 6 : 9; Texture2D texture = ModContent.Request(Texture).Value; - Texture2D backTexture = ModContent.Request("CalamityMod/Projectiles/Magic/SpiritCongregationBack").Value; - Texture2D auraTexture = ModContent.Request("CalamityMod/Projectiles/Magic/SpiritCongregationAura").Value; if (CurrentPower > LargeMouthPowerLowerBound) - { texture = ModContent.Request("CalamityMod/Projectiles/Magic/SpiritCongregationBig").Value; - backTexture = ModContent.Request("CalamityMod/Projectiles/Magic/SpiritCongregationBackBig").Value; - auraTexture = ModContent.Request("CalamityMod/Projectiles/Magic/SpiritCongregationAuraBig").Value; - } - - float offsetFactor = Projectile.scale * ((CongregationDiameter - 54f) / 90f + 1.5f); - offsetFactor *= texture.Width / 90f; - Vector2 drawPosition = Projectile.Center - Main.screenPosition + Projectile.rotation.ToRotationVector2() * offsetFactor * 15f; - Rectangle frame = texture.Frame(1, maxFrame, 0, Projectile.frame); - Vector2 origin = frame.Size() * 0.5f; - SpriteEffects direction = Math.Cos(Projectile.rotation) > 0f ? SpriteEffects.None : SpriteEffects.FlipVertically; - DrawData backTextureDraw = new(backTexture, drawPosition, frame, Color.White, Projectile.rotation, origin, Projectile.scale, direction, 0); - DrawData auraTextureDraw = new(auraTexture, drawPosition, frame, Color.White, Projectile.rotation, origin, Projectile.scale, direction, 0); - FusableParticleManager.GetParticleSetByType()?.PrepareSpecialDrawingForNextFrame(backTextureDraw, auraTextureDraw); - Main.EntitySpriteDraw(texture, drawPosition, frame, Color.White, Projectile.rotation, origin, Projectile.scale, direction, 0); + DrawHead(texture); return false; } - // Damage scales up over time as it grows + public void DrawHead(Texture2D texture, float scaleFactor = 1f) + { + int maxFrame = CurrentPower <= LargeMouthPowerLowerBound ? 6 : 9; + float offsetFactor = Projectile.scale * ((CongregationDiameter - 54f) / 90f + 1.5f); + offsetFactor *= texture.Width / 90f; + + Vector2 drawPosition = Projectile.Center - Main.screenPosition + Projectile.rotation.ToRotationVector2() * offsetFactor * 15f; + Rectangle frame = texture.Frame(1, maxFrame, 0, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + SpriteEffects direction = MathF.Cos(Projectile.rotation) > 0f ? SpriteEffects.None : SpriteEffects.FlipVertically; + + Main.EntitySpriteDraw(texture, drawPosition, frame, Color.White, Projectile.rotation, origin, Projectile.scale * scaleFactor, direction, 0); + } + + public void DrawHeadForMetaball() + { + Texture2D backTexture = ModContent.Request("CalamityMod/Projectiles/Magic/SpiritCongregationBack").Value; + if (CurrentPower > LargeMouthPowerLowerBound) + backTexture = ModContent.Request("CalamityMod/Projectiles/Magic/SpiritCongregationBackBig").Value; + + DrawHead(backTexture, 1.04f); + } + + // Damage scales up over time as it grows. public override void ModifyHitPlayer(Player target, ref Player.HurtModifiers modifiers) { float damageFactor = 0.25f + 0.75f * CurrentPower; int fullPowerDamage; - if (Main.masterMode) fullPowerDamage = 540; - else if (Main.expertMode) fullPowerDamage = 450; - else fullPowerDamage = 360; + if (Main.masterMode) + fullPowerDamage = 540; + else if (Main.expertMode) + fullPowerDamage = 450; + else + fullPowerDamage = 360; modifiers.SourceDamage *= 0f; modifiers.SourceDamage.Flat += (int)(damageFactor * fullPowerDamage); diff --git a/Projectiles/Magic/SpiritDust.cs b/Projectiles/Magic/SpiritDust.cs index 97a8ee4f20..0d01bdc4b7 100644 --- a/Projectiles/Magic/SpiritDust.cs +++ b/Projectiles/Magic/SpiritDust.cs @@ -1,4 +1,4 @@ -using CalamityMod.Particles.Metaballs; +using CalamityMod.Graphics.Metaballs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -8,6 +8,7 @@ namespace CalamityMod.Projectiles.Magic public class SpiritDust : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetDefaults() @@ -24,7 +25,7 @@ namespace CalamityMod.Projectiles.Magic { float radius = MathHelper.SmoothStep(80f, 48f, 1f - Projectile.timeLeft / 90f); Vector2 spawnPosition = Projectile.Center + Main.rand.NextVector2Circular(5f, 5f) * radius / 130f; - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(spawnPosition, radius); + GruesomeMetaball.SpawnParticle(spawnPosition, Main.rand.NextVector2Circular(3f, 3f), radius); } } } diff --git a/Projectiles/Magic/Starblast.cs b/Projectiles/Magic/Starblast.cs index 53e54487b9..fe398010f4 100644 --- a/Projectiles/Magic/Starblast.cs +++ b/Projectiles/Magic/Starblast.cs @@ -38,21 +38,21 @@ namespace CalamityMod.Projectiles.Magic if (Main.rand.NextBool(4)) { - int num193 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 1f); - Main.dust[num193].position = Projectile.Center; - Main.dust[num193].scale += (float)Main.rand.Next(50) * 0.01f; - Main.dust[num193].noGravity = true; - Dust expr_835F_cp_0 = Main.dust[num193]; + int stardust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 1f); + Main.dust[stardust].position = Projectile.Center; + Main.dust[stardust].scale += (float)Main.rand.Next(50) * 0.01f; + Main.dust[stardust].noGravity = true; + Dust expr_835F_cp_0 = Main.dust[stardust]; expr_835F_cp_0.velocity.Y -= 2f; } if (Main.rand.NextBool(6)) { - int num194 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 176, 0f, 0f, 100, default, 1f); - Main.dust[num194].position = Projectile.Center; - Main.dust[num194].scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; - Main.dust[num194].noGravity = true; - Main.dust[num194].velocity *= 0.1f; + int stardustier = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 176, 0f, 0f, 100, default, 1f); + Main.dust[stardustier].position = Projectile.Center; + Main.dust[stardustier].scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; + Main.dust[stardustier].noGravity = true; + Main.dust[stardustier].velocity *= 0.1f; } } } diff --git a/Projectiles/Magic/StardustElementalBeam.cs b/Projectiles/Magic/StardustElementalBeam.cs index 2c1cd8962d..4ff5c27167 100644 --- a/Projectiles/Magic/StardustElementalBeam.cs +++ b/Projectiles/Magic/StardustElementalBeam.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -60,6 +61,7 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { + target.AddBuff(ModContent.BuffType(), 30); if (!Main.rand.NextBool(7)) return; diff --git a/Projectiles/Magic/StickyFeather.cs b/Projectiles/Magic/StickyFeather.cs index ec8cc0d3e1..4bff0a1df1 100644 --- a/Projectiles/Magic/StickyFeather.cs +++ b/Projectiles/Magic/StickyFeather.cs @@ -49,23 +49,23 @@ namespace CalamityMod.Projectiles.Magic Projectile.height = 50; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 15; num621++) + for (int i = 0; i < 15; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 206, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; + int blueDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 206, 0f, 0f, 100, default, 1.2f); + Main.dust[blueDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[blueDust].scale = 0.5f; + Main.dust[blueDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 206, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 206, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int blueDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 206, 0f, 0f, 100, default, 1.7f); + Main.dust[blueDust2].noGravity = true; + Main.dust[blueDust2].velocity *= 5f; + blueDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 206, 0f, 0f, 100, default, 1f); + Main.dust[blueDust2].velocity *= 2f; } } diff --git a/Projectiles/Magic/SupremeDustFlakProjectile.cs b/Projectiles/Magic/SupremeDustFlakProjectile.cs index 2fdfceee12..3da2e15002 100644 --- a/Projectiles/Magic/SupremeDustFlakProjectile.cs +++ b/Projectiles/Magic/SupremeDustFlakProjectile.cs @@ -25,25 +25,25 @@ namespace CalamityMod.Projectiles.Magic Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.35f / 255f, (255 - Projectile.alpha) * 0.3f / 255f, (255 - Projectile.alpha) * 0.01f / 255f); if (Projectile.ai[0] > 7f) { - float num296 = 1f; + float dustScale = 1f; if (Projectile.ai[0] == 8f) { - num296 = 0.25f; + dustScale = 0.25f; } else if (Projectile.ai[0] == 9f) { - num296 = 0.5f; + dustScale = 0.5f; } else if (Projectile.ai[0] == 10f) { - num296 = 0.75f; + dustScale = 0.75f; } Projectile.ai[0] += 1f; - int num297 = 32; - for (int num298 = 0; num298 < 2; num298++) + int dustType = 32; + for (int i = 0; i < 2; i++) { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; + int earthyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust = Main.dust[earthyDust]; if (Main.rand.NextBool(3)) { dust.noGravity = false; @@ -57,12 +57,12 @@ namespace CalamityMod.Projectiles.Magic } dust.velocity.X *= 1.2f; dust.velocity.Y *= 1.2f; - dust.scale *= num296; + dust.scale *= dustScale; } - for (int num298 = 0; num298 < 2; num298++) + for (int i = 0; i < 2; i++) { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; + int earthyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust = Main.dust[earthyDust]; if (Main.rand.NextBool(3)) { dust.noGravity = false; @@ -76,7 +76,7 @@ namespace CalamityMod.Projectiles.Magic } dust.velocity.X *= 1.2f; dust.velocity.Y *= 1.2f; - dust.scale *= num296; + dust.scale *= dustScale; } } else diff --git a/Projectiles/Magic/SupremeDustProjectile.cs b/Projectiles/Magic/SupremeDustProjectile.cs index 1cf678f1eb..4eb19e2b62 100644 --- a/Projectiles/Magic/SupremeDustProjectile.cs +++ b/Projectiles/Magic/SupremeDustProjectile.cs @@ -27,23 +27,23 @@ namespace CalamityMod.Projectiles.Magic Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.95f / 255f, (255 - Projectile.alpha) * 0.85f / 255f, (255 - Projectile.alpha) * 0.01f / 255f); if (Projectile.ai[0] > 7f) { - float num296 = 1f; + float dustScale = 1f; if (Projectile.ai[0] == 8f) { - num296 = 0.25f; + dustScale = 0.25f; } else if (Projectile.ai[0] == 9f) { - num296 = 0.5f; + dustScale = 0.5f; } else if (Projectile.ai[0] == 10f) { - num296 = 0.75f; + dustScale = 0.75f; } Projectile.ai[0] += 1f; - int num297 = 32; - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; + int dustType = 32; + int earthyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust = Main.dust[earthyDust]; if (Main.rand.NextBool()) { dust.noGravity = true; @@ -57,9 +57,9 @@ namespace CalamityMod.Projectiles.Magic } dust.velocity.X *= 1.2f; dust.velocity.Y *= 1.2f; - dust.scale *= num296; - int num399 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust2 = Main.dust[num399]; + dust.scale *= dustScale; + int earthyDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust2 = Main.dust[earthyDust2]; if (Main.rand.NextBool(3)) { dust2.noGravity = true; @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Magic } dust2.velocity.X *= 1.2f; dust2.velocity.Y *= 1.2f; - dust2.scale *= num296; + dust2.scale *= dustScale; } else { diff --git a/Projectiles/Magic/ThunderstormShot.cs b/Projectiles/Magic/ThunderstormShot.cs index baa325157d..b023cbf19a 100644 --- a/Projectiles/Magic/ThunderstormShot.cs +++ b/Projectiles/Magic/ThunderstormShot.cs @@ -27,18 +27,18 @@ namespace CalamityMod.Projectiles.Magic Projectile.ai[0] += 1f; if (Projectile.ai[0] > 9f) { - for (int num121 = 0; num121 < 5; num121++) + for (int i = 0; i < 5; i++) { - Dust dust = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 107, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f)]; - dust.velocity = Vector2.Zero; - dust.position -= Projectile.velocity / 5f * (float)num121; - dust.noGravity = true; - dust.noLight = true; - Dust dust2 = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 229, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f)]; - dust2.velocity = Vector2.Zero; - dust2.position -= Projectile.velocity / 5f * (float)num121; - dust2.noGravity = true; - dust2.noLight = true; + Dust greenDust = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 107, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f)]; + greenDust.velocity = Vector2.Zero; + greenDust.position -= Projectile.velocity / 5f * (float)i; + greenDust.noGravity = true; + greenDust.noLight = true; + Dust lightningDust = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 229, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f)]; + lightningDust.velocity = Vector2.Zero; + lightningDust.position -= Projectile.velocity / 5f * (float)i; + lightningDust.noGravity = true; + lightningDust.noLight = true; } } } @@ -52,26 +52,26 @@ namespace CalamityMod.Projectiles.Magic CalamityUtils.ProjectileRain(source, Projectile.Center, 200f, 100f, 1500f, 1500f, 29f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); } Projectile.ExpandHitboxBy(36); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int j = 0; j < dustAmt; j++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 1f; //0.75 - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 229, vector7.X, vector7.Y, 100, default, 1.2f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 dustRotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 1f; //0.75 + dustRotate = dustRotate.RotatedBy((double)((float)(j - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; + Vector2 dustDirection = dustRotate - Projectile.Center; + int killDust = Dust.NewDust(dustRotate + dustDirection, 0, 0, 229, dustDirection.X, dustDirection.Y, 100, default, 1.2f); + Main.dust[killDust].noGravity = true; + Main.dust[killDust].noLight = true; + Main.dust[killDust].velocity = dustDirection; } - for (int num227 = 0; num227 < num226; num227++) + for (int j = 0; j < dustAmt; j++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 107, vector7.X, vector7.Y, 100, default, 1.2f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 dustRotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + dustRotate = dustRotate.RotatedBy((double)((float)(j - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; + Vector2 dustDirection = dustRotate - Projectile.Center; + int killDust = Dust.NewDust(dustRotate + dustDirection, 0, 0, 107, dustDirection.X, dustDirection.Y, 100, default, 1.2f); + Main.dust[killDust].noGravity = true; + Main.dust[killDust].noLight = true; + Main.dust[killDust].velocity = dustDirection; } Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; diff --git a/Projectiles/Magic/ThunderstormShotSplit.cs b/Projectiles/Magic/ThunderstormShotSplit.cs index ed237b15f7..6fbee3472d 100644 --- a/Projectiles/Magic/ThunderstormShotSplit.cs +++ b/Projectiles/Magic/ThunderstormShotSplit.cs @@ -32,16 +32,16 @@ namespace CalamityMod.Projectiles.Magic Projectile.ai[0] += 1f; if (Projectile.ai[0] > 6f) { - for (int num121 = 0; num121 < 5; num121++) + for (int i = 0; i < 5; i++) { Dust dust = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 107, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 0.5f)]; dust.velocity = Vector2.Zero; - dust.position -= Projectile.velocity / 5f * (float)num121; + dust.position -= Projectile.velocity / 5f * (float)i; dust.noGravity = true; dust.noLight = true; Dust dust2 = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 229, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 0.5f)]; dust2.velocity = Vector2.Zero; - dust2.position -= Projectile.velocity / 5f * (float)num121; + dust2.position -= Projectile.velocity / 5f * (float)i; dust2.noGravity = true; dust2.noLight = true; } @@ -55,26 +55,26 @@ namespace CalamityMod.Projectiles.Magic Projectile.width = Projectile.height = 16; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int j = 0; j < dustAmt; j++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; //0.75 - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 229, vector7.X, vector7.Y, 100, default, 0.6f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 dustRotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; //0.75 + dustRotate = dustRotate.RotatedBy((double)((float)(j - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; + Vector2 dustDirection = dustRotate - Projectile.Center; + int killDust = Dust.NewDust(dustRotate + dustDirection, 0, 0, 229, dustDirection.X, dustDirection.Y, 100, default, 0.6f); + Main.dust[killDust].noGravity = true; + Main.dust[killDust].noLight = true; + Main.dust[killDust].velocity = dustDirection; } - for (int num227 = 0; num227 < num226; num227++) + for (int j = 0; j < dustAmt; j++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.5f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 107, vector7.X, vector7.Y, 100, default, 0.6f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 dustRotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.5f; + dustRotate = dustRotate.RotatedBy((double)((float)(j - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; + Vector2 dustDirection = dustRotate - Projectile.Center; + int killDust = Dust.NewDust(dustRotate + dustDirection, 0, 0, 107, dustDirection.X, dustDirection.Y, 100, default, 0.6f); + Main.dust[killDust].noGravity = true; + Main.dust[killDust].noLight = true; + Main.dust[killDust].velocity = dustDirection; } Projectile.Damage(); } diff --git a/Projectiles/Magic/UberBubble.cs b/Projectiles/Magic/UberBubble.cs index 5f0f16aba1..b0f20140a9 100644 --- a/Projectiles/Magic/UberBubble.cs +++ b/Projectiles/Magic/UberBubble.cs @@ -30,14 +30,14 @@ namespace CalamityMod.Projectiles.Magic if (Projectile.alpha < 0) Projectile.alpha = 0; - Vector2 v2 = Projectile.ai[0].ToRotationVector2(); - float num743 = Projectile.velocity.ToRotation(); - float num744 = v2.ToRotation(); - double num745 = num744 - num743; - if (num745 > MathHelper.Pi) - num745 -= MathHelper.TwoPi; - if (num745 < -MathHelper.Pi) - num745 -= -MathHelper.TwoPi; + Vector2 uber = Projectile.ai[0].ToRotationVector2(); + float projRotation = Projectile.velocity.ToRotation(); + float aiRotation = uber.ToRotation(); + double rotationClamp = aiRotation - projRotation; + if (rotationClamp > MathHelper.Pi) + rotationClamp -= MathHelper.TwoPi; + if (rotationClamp < -MathHelper.Pi) + rotationClamp -= -MathHelper.TwoPi; Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; } @@ -45,13 +45,13 @@ namespace CalamityMod.Projectiles.Magic public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item96, Projectile.position); - int num190 = Main.rand.Next(4, 6); - for (int num191 = 0; num191 < num190; num191++) + int randDustAmt = Main.rand.Next(4, 6); + for (int i = 0; i < randDustAmt; i++) { - int num192 = Dust.NewDust(Projectile.Center, 0, 0, 171, 0f, 0f, 100, default, 1.4f); - Main.dust[num192].velocity *= 0.8f; - Main.dust[num192].position = Vector2.Lerp(Main.dust[num192].position, Projectile.Center, 0.5f); - Main.dust[num192].noGravity = true; + int purpleDust = Dust.NewDust(Projectile.Center, 0, 0, 171, 0f, 0f, 100, default, 1.4f); + Main.dust[purpleDust].velocity *= 0.8f; + Main.dust[purpleDust].position = Vector2.Lerp(Main.dust[purpleDust].position, Projectile.Center, 0.5f); + Main.dust[purpleDust].noGravity = true; } if (Projectile.owner == Main.myPlayer) { diff --git a/Projectiles/Magic/UndinesRetributionSpear.cs b/Projectiles/Magic/UndinesRetributionSpear.cs index dc4918a154..fbd5a1bc29 100644 --- a/Projectiles/Magic/UndinesRetributionSpear.cs +++ b/Projectiles/Magic/UndinesRetributionSpear.cs @@ -43,9 +43,9 @@ namespace CalamityMod.Projectiles.Magic { Projectile.frame = 0; } - float num953 = 25f * Projectile.ai[1]; //100 - float scaleFactor12 = 5f * Projectile.ai[1]; //5 - float num954 = 500f; + float velocityMult = 25f * Projectile.ai[1]; //100 + float velocityScale = 5f * Projectile.ai[1]; //5 + float homingRange = 500f; if (Projectile.velocity.X < 0f) { Projectile.spriteDirection = -1; @@ -59,10 +59,10 @@ namespace CalamityMod.Projectiles.Magic Lighting.AddLight(Projectile.Center, 0f, 0.1f, 0.7f); if (Main.player[Projectile.owner].active && !Main.player[Projectile.owner].dead) { - if (Projectile.Distance(Main.player[Projectile.owner].Center) > num954) + if (Projectile.Distance(Main.player[Projectile.owner].Center) > homingRange) { Vector2 moveDirection = Projectile.SafeDirectionTo(Main.player[Projectile.owner].Center, Vector2.UnitY); - Projectile.velocity = (Projectile.velocity * (num953 - 1f) + moveDirection * scaleFactor12) / num953; + Projectile.velocity = (Projectile.velocity * (velocityMult - 1f) + moveDirection * velocityScale) / velocityMult; return; } @@ -101,18 +101,18 @@ namespace CalamityMod.Projectiles.Magic Projectile.damage /= 2; Projectile.Damage(); SoundEngine.PlaySound(SoundID.Item21, Projectile.position); - for (int num193 = 0; num193 < 4; num193++) + for (int i = 0; i < 4; i++) { Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); } - for (int num194 = 0; num194 < 6; num194++) + for (int j = 0; j < 6; j++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 186, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 186, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int undust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 186, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[undust].noGravity = true; + Main.dust[undust].velocity *= 3f; + undust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 186, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[undust].velocity *= 2f; + Main.dust[undust].noGravity = true; } } } diff --git a/Projectiles/Magic/VenusianBolt.cs b/Projectiles/Magic/VenusianBolt.cs index 8f4959156a..74551fa85b 100644 --- a/Projectiles/Magic/VenusianBolt.cs +++ b/Projectiles/Magic/VenusianBolt.cs @@ -40,12 +40,12 @@ namespace CalamityMod.Projectiles.Magic SoundEngine.PlaySound(SoundID.Item73, Projectile.position); Projectile.localAI[0] += 1f; } - for (int num457 = 0; num457 < 3; num457++) + for (int i = 0; i < 3; i++) { - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 55, 0f, 0f, 100, default, 1.2f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int venusDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 55, 0f, 0f, 100, default, 1.2f); + Main.dust[venusDust].noGravity = true; + Main.dust[venusDust].velocity *= 0.5f; + Main.dust[venusDust].velocity += Projectile.velocity * 0.1f; } } @@ -62,7 +62,7 @@ namespace CalamityMod.Projectiles.Magic float explosionKB = 6f; Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), explosionDamage, explosionKB, Projectile.owner); - int cinderDamage = (int)(Projectile.damage * 0.75); + int cinderDamage = (int)(Projectile.damage * 0.20); float cinderKB = 0f; Vector2 cinderPos = Projectile.oldPosition + 0.5f * Projectile.Size; int numCinders = Main.rand.Next(7, 10); diff --git a/Projectiles/Magic/VenusianExplosion.cs b/Projectiles/Magic/VenusianExplosion.cs index 197b8b7ffc..f1907324d1 100644 --- a/Projectiles/Magic/VenusianExplosion.cs +++ b/Projectiles/Magic/VenusianExplosion.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.timeLeft = 120; Projectile.DamageType = DamageClass.Magic; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; + Projectile.localNPCHitCooldown = 17; } public override void AI() @@ -34,38 +34,38 @@ namespace CalamityMod.Projectiles.Magic SoundEngine.PlaySound(SoundID.Item74, Projectile.position); Projectile.localAI[0] += 1f; } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-30, 31); - float num464 = (float)Main.rand.Next(-30, 31); - float num465 = (float)Main.rand.Next(9, 27); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 55, 0f, 0f, 100, default, 2.5f); - Dust dust = Main.dust[num467]; + float rando1 = (float)Main.rand.Next(-30, 31); + float rando2 = (float)Main.rand.Next(-30, 31); + float rando3 = (float)Main.rand.Next(9, 27); + float randoAdjuster = (float)Math.Sqrt((double)(rando1 * rando1 + rando2 * rando2)); + randoAdjuster = rando3 / randoAdjuster; + rando1 *= randoAdjuster; + rando2 *= randoAdjuster; + int venusDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 55, 0f, 0f, 100, default, 2.5f); + Dust dust = Main.dust[venusDust]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = rando1; + dust.velocity.Y = rando2; + timerCounter++; } return; } diff --git a/Projectiles/Magic/VenusianFlame.cs b/Projectiles/Magic/VenusianFlame.cs index e2d95e1df8..29f067287f 100644 --- a/Projectiles/Magic/VenusianFlame.cs +++ b/Projectiles/Magic/VenusianFlame.cs @@ -107,8 +107,8 @@ namespace CalamityMod.Projectiles.Magic //Dust if (Main.rand.NextBool(4)) { - int num199 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 55, 0f, 0f, 100, default, 1f); - Dust dust = Main.dust[num199]; + int venusDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 55, 0f, 0f, 100, default, 1f); + Dust dust = Main.dust[venusDust]; dust.position.X -= 2f; dust.position.Y += 2f; dust.scale += (float)Main.rand.Next(50) * 0.01f; @@ -117,8 +117,8 @@ namespace CalamityMod.Projectiles.Magic } if (Main.rand.NextBool(10)) { - int num200 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 55, 0f, 0f, 100, default, 1f); - Dust dust2 = Main.dust[num200]; + int venusDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 55, 0f, 0f, 100, default, 1f); + Dust dust2 = Main.dust[venusDust2]; dust2.position.X -= 2f; dust2.position.Y += 2f; dust2.scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; diff --git a/Projectiles/Magic/VisceraBeam.cs b/Projectiles/Magic/VisceraBeam.cs index d6af20bd9a..1af449b9f2 100644 --- a/Projectiles/Magic/VisceraBeam.cs +++ b/Projectiles/Magic/VisceraBeam.cs @@ -63,14 +63,14 @@ namespace CalamityMod.Projectiles.Magic Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 9f) { - for (int num447 = 0; num447 < 4; num447++) + for (int i = 0; i < 4; i++) { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * ((float)num447 * 0.25f); - int num448 = Dust.NewDust(vector33, 1, 1, 5, 0f, 0f, 0, default, 1f); - Main.dust[num448].position = vector33; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.1f; + Vector2 projPos = Projectile.position; + projPos -= Projectile.velocity * ((float)i * 0.25f); + int bloody = Dust.NewDust(projPos, 1, 1, 5, 0f, 0f, 0, default, 1f); + Main.dust[bloody].position = projPos; + Main.dust[bloody].scale = (float)Main.rand.Next(70, 110) * 0.013f; + Main.dust[bloody].velocity *= 0.1f; } } } diff --git a/Projectiles/Magic/VividBolt.cs b/Projectiles/Magic/VividBolt.cs index ee89e008bb..dcb2e61d1e 100644 --- a/Projectiles/Magic/VividBolt.cs +++ b/Projectiles/Magic/VividBolt.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - Vector2 value7 = new Vector2(5f, 10f); + Vector2 rotateVector = new Vector2(5f, 10f); Projectile.ai[0] += 1f; if (Projectile.ai[0] == 48f) { @@ -33,29 +33,29 @@ namespace CalamityMod.Projectiles.Magic } else { - for (int num41 = 0; num41 < 2; num41++) + for (int i = 0; i < 2; i++) { - Vector2 value8 = Vector2.UnitX * -12f; - value8 = -Vector2.UnitY.RotatedBy((double)(Projectile.ai[0] * 0.1308997f + (float)num41 * 3.14159274f), default) * value7 - Projectile.rotation.ToRotationVector2() * 10f; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, 66, 0f, 0f, 160, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[num42].scale = 0.33f; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8; - Main.dust[num42].velocity = Projectile.velocity; + Vector2 dustRotation = Vector2.UnitX * -12f; + dustRotation = -Vector2.UnitY.RotatedBy((double)(Projectile.ai[0] * 0.1308997f + (float)i * 3.14159274f), default) * rotateVector - Projectile.rotation.ToRotationVector2() * 10f; + int exo = Dust.NewDust(Projectile.Center, 0, 0, 66, 0f, 0f, 160, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Main.dust[exo].scale = 0.33f; + Main.dust[exo].noGravity = true; + Main.dust[exo].position = Projectile.Center + dustRotation; + Main.dust[exo].velocity = Projectile.velocity; } } Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { - for (int num447 = 0; num447 < 2; num447++) + for (int j = 0; j < 2; j++) { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * ((float)num447 * 0.25f); - int num448 = Dust.NewDust(vector33, 1, 1, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[num448].noGravity = true; - Main.dust[num448].position = vector33; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.01f; - Main.dust[num448].velocity *= 0.1f; + Vector2 projPos = Projectile.position; + projPos -= Projectile.velocity * ((float)j * 0.25f); + int exod = Dust.NewDust(projPos, 1, 1, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Main.dust[exod].noGravity = true; + Main.dust[exod].position = projPos; + Main.dust[exod].scale = (float)Main.rand.Next(70, 110) * 0.01f; + Main.dust[exod].velocity *= 0.1f; } } } diff --git a/Projectiles/Magic/VividClarityBeam.cs b/Projectiles/Magic/VividClarityBeam.cs index 9828fe8c95..c1166dcde3 100644 --- a/Projectiles/Magic/VividClarityBeam.cs +++ b/Projectiles/Magic/VividClarityBeam.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - Vector2 value7 = new Vector2(5f, 10f); + Vector2 rotateVector = new Vector2(5f, 10f); Projectile.ai[0] += 1f; if (Projectile.ai[0] == 48f) { @@ -34,15 +34,15 @@ namespace CalamityMod.Projectiles.Magic } else { - for (int num41 = 0; num41 < 2; num41++) + for (int i = 0; i < 2; i++) { - Vector2 value8 = Vector2.UnitX * -12f; - value8 = -Vector2.UnitY.RotatedBy((double)(Projectile.ai[0] * 0.1308997f + (float)num41 * 3.14159274f), default) * value7 - Projectile.rotation.ToRotationVector2() * 10f; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, 66, 0f, 0f, 160, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[num42].scale = 0.75f; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8; - Main.dust[num42].velocity = Projectile.velocity; + Vector2 dustRotation = Vector2.UnitX * -12f; + dustRotation = -Vector2.UnitY.RotatedBy((double)(Projectile.ai[0] * 0.1308997f + (float)i * 3.14159274f), default) * rotateVector - Projectile.rotation.ToRotationVector2() * 10f; + int exo = Dust.NewDust(Projectile.Center, 0, 0, 66, 0f, 0f, 160, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Main.dust[exo].scale = 0.75f; + Main.dust[exo].noGravity = true; + Main.dust[exo].position = Projectile.Center + dustRotation; + Main.dust[exo].velocity = Projectile.velocity; } } @@ -56,15 +56,15 @@ namespace CalamityMod.Projectiles.Magic Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { - for (int num447 = 0; num447 < 2; num447++) + for (int j = 0; j < 2; j++) { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * ((float)num447 * 0.25f); - int num448 = Dust.NewDust(vector33, 1, 1, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[num448].noGravity = true; - Main.dust[num448].position = vector33; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.1f; + Vector2 projPos = Projectile.position; + projPos -= Projectile.velocity * ((float)j * 0.25f); + int exod = Dust.NewDust(projPos, 1, 1, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Main.dust[exod].noGravity = true; + Main.dust[exod].position = projPos; + Main.dust[exod].scale = (float)Main.rand.Next(70, 110) * 0.013f; + Main.dust[exod].velocity *= 0.1f; } } } diff --git a/Projectiles/Magic/VividLaser2.cs b/Projectiles/Magic/VividLaser2.cs index 1d38608d9c..ec6e500815 100644 --- a/Projectiles/Magic/VividLaser2.cs +++ b/Projectiles/Magic/VividLaser2.cs @@ -27,13 +27,13 @@ namespace CalamityMod.Projectiles.Magic Projectile.ai[1] += 1f; for (int dust = 0; dust < 2; dust++) { - Vector2 value8 = Vector2.UnitX * -12f; - value8 = -Vector2.UnitY.RotatedBy((double)(Projectile.ai[1] * 0.1308997f + (float)dust * 3.14159274f), default) * value7 - Projectile.rotation.ToRotationVector2() * 10f; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, 66, 0f, 0f, 160, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[num42].scale = 0.75f; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8; - Main.dust[num42].velocity = Projectile.velocity; + Vector2 dustPosOffset = Vector2.UnitX * -12f; + dustPosOffset = -Vector2.UnitY.RotatedBy((double)(Projectile.ai[1] * 0.1308997f + (float)dust * 3.14159274f), default) * value7 - Projectile.rotation.ToRotationVector2() * 10f; + int exo = Dust.NewDust(Projectile.Center, 0, 0, 66, 0f, 0f, 160, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Main.dust[exo].scale = 0.75f; + Main.dust[exo].noGravity = true; + Main.dust[exo].position = Projectile.Center + dustPosOffset; + Main.dust[exo].velocity = Projectile.velocity; } if (Projectile.timeLeft < 110) diff --git a/Projectiles/Magic/VoidVortexProj.cs b/Projectiles/Magic/VoidVortexProj.cs index c02572f62e..89b31722cd 100644 --- a/Projectiles/Magic/VoidVortexProj.cs +++ b/Projectiles/Magic/VoidVortexProj.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.ignoreWater = true; Projectile.tileCollide = false; Projectile.penetrate = -1; - Projectile.timeLeft = 180; + Projectile.timeLeft = 135; Projectile.DamageType = DamageClass.Magic; } @@ -61,8 +61,8 @@ namespace CalamityMod.Projectiles.Magic { if (Projectile.timeLeft < 30) { - float num7 = Projectile.timeLeft / 30f; - Projectile.alpha = (int)(255f - 255f * num7); + float timerAlpha = Projectile.timeLeft / 30f; + Projectile.alpha = (int)(255f - 255f * timerAlpha); } return new Color(255 - Projectile.alpha, 255 - Projectile.alpha, 255 - Projectile.alpha, 0); } @@ -70,9 +70,9 @@ namespace CalamityMod.Projectiles.Magic public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture2D13.Width / 2f, num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture2D13.Width / 2f, framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } diff --git a/Projectiles/Magic/VortexElementalBeam.cs b/Projectiles/Magic/VortexElementalBeam.cs index de347f1fab..904ba805d5 100644 --- a/Projectiles/Magic/VortexElementalBeam.cs +++ b/Projectiles/Magic/VortexElementalBeam.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.IO; @@ -157,6 +158,7 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { + target.AddBuff(ModContent.BuffType(), 30); for (int i = 0; i < Projectile.oldPos.Length - 1; i++) { // Skip zeroed old positions. They are almost certainly a diff --git a/Projectiles/Magic/WaterStream.cs b/Projectiles/Magic/WaterStream.cs deleted file mode 100644 index 4fd299cc10..0000000000 --- a/Projectiles/Magic/WaterStream.cs +++ /dev/null @@ -1,71 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic -{ - public class WaterStream : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Magic"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetDefaults() - { - Projectile.width = 32; - Projectile.height = 32; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.penetrate = 3; - Projectile.extraUpdates = 2; - Projectile.DamageType = DamageClass.Magic; - Projectile.tileCollide = false; - } - - public override void AI() - { - Projectile.ai[1]++; - if (Projectile.ai[1] >= 4f) - { - Projectile.tileCollide = true; - } - if (Projectile.timeLeft % 20 == 0) - { - if (Projectile.owner == Main.myPlayer) - { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); - } - } - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.15f / 255f, (255 - Projectile.alpha) * 0.25f / 255f); - Projectile.scale -= 0.002f; - if (Projectile.scale <= 0f) - { - Projectile.Kill(); - } - if (Projectile.ai[0] <= 3f) - { - Projectile.ai[0] += 1f; - return; - } - Projectile.velocity.Y = Projectile.velocity.Y + 0.075f; - for (int num151 = 0; num151 < 3; num151++) - { - float num152 = Projectile.velocity.X / 3f * (float)num151; - float num153 = Projectile.velocity.Y / 3f * (float)num151; - int num154 = 14; - int num155 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num154, Projectile.position.Y + (float)num154), Projectile.width - num154 * 2, Projectile.height - num154 * 2, 14, 0f, 0f, 100, new Color(0, 255, 255), 1f); - Dust dust = Main.dust[num155]; - dust.noGravity = true; - dust.velocity *= 0.1f; - dust.velocity += Projectile.velocity * 0.5f; - dust.position.X -= num152; - dust.position.Y -= num153; - } - if (Main.rand.NextBool(8)) - { - int num156 = 16; - int num157 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num156, Projectile.position.Y + (float)num156), Projectile.width - num156 * 2, Projectile.height - num156 * 2, 14, 0f, 0f, 100, new Color(0, 255, 255), 0.5f); - Main.dust[num157].velocity *= 0.25f; - Main.dust[num157].velocity += Projectile.velocity * 0.5f; - } - } - } -} diff --git a/Projectiles/Magic/WaterStream2.cs b/Projectiles/Magic/WaterStream2.cs deleted file mode 100644 index b4b97c5fec..0000000000 --- a/Projectiles/Magic/WaterStream2.cs +++ /dev/null @@ -1,59 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic -{ - public class WaterStream2 : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Magic"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetDefaults() - { - Projectile.width = 32; - Projectile.height = 32; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.penetrate = 1; - Projectile.extraUpdates = 2; - Projectile.timeLeft = 80; - Projectile.DamageType = DamageClass.Magic; - } - - public override void AI() - { - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.15f / 255f, (255 - Projectile.alpha) * 0.25f / 255f); - Projectile.scale -= 0.002f; - if (Projectile.scale <= 0f) - { - Projectile.Kill(); - } - if (Projectile.ai[0] <= 3f) - { - Projectile.ai[0] += 1f; - return; - } - Projectile.velocity.Y = Projectile.velocity.Y + 0.075f; - for (int num151 = 0; num151 < 3; num151++) - { - float num152 = Projectile.velocity.X / 3f * (float)num151; - float num153 = Projectile.velocity.Y / 3f * (float)num151; - int num154 = 14; - int num155 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num154, Projectile.position.Y + (float)num154), Projectile.width - num154 * 2, Projectile.height - num154 * 2, 14, 0f, 0f, 100, new Color(0, 255, 255), 1f); - Dust dust = Main.dust[num155]; - dust.noGravity = true; - dust.velocity *= 0.1f; - dust.velocity += Projectile.velocity * 0.5f; - dust.position.X -= num152; - dust.position.Y -= num153; - } - if (Main.rand.NextBool(8)) - { - int num156 = 16; - int num157 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num156, Projectile.position.Y + (float)num156), Projectile.width - num156 * 2, Projectile.height - num156 * 2, 14, 0f, 0f, 100, new Color(0, 255, 255), 0.5f); - Main.dust[num157].velocity *= 0.25f; - Main.dust[num157].velocity += Projectile.velocity * 0.5f; - } - } - } -} diff --git a/Projectiles/Magic/WaywasherProj.cs b/Projectiles/Magic/WaywasherProj.cs index ac620bd33a..aec8731d96 100644 --- a/Projectiles/Magic/WaywasherProj.cs +++ b/Projectiles/Magic/WaywasherProj.cs @@ -25,25 +25,25 @@ namespace CalamityMod.Projectiles.Magic { Projectile.rotation += (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y)) * 0.02f * (float)Projectile.direction; Lighting.AddLight(Projectile.Center, 0f, 0.1f, 0.7f); - for (int num105 = 0; num105 < 2; num105++) + for (int i = 0; i < 2; i++) { - float num99 = Projectile.velocity.X / 3f * (float)num105; - float num100 = Projectile.velocity.Y / 3f * (float)num105; - int num101 = 4; - int num102 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num101, Projectile.position.Y + (float)num101), Projectile.width - num101 * 2, Projectile.height - num101 * 2, 33, 0f, 0f, 0, new Color(64, 224, 208), 1.2f); - Dust dust = Main.dust[num102]; + float shortXVel = Projectile.velocity.X / 3f * (float)i; + float shortYVel = Projectile.velocity.Y / 3f * (float)i; + int fourConst = 4; + int waterDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)fourConst, Projectile.position.Y + (float)fourConst), Projectile.width - fourConst * 2, Projectile.height - fourConst * 2, 33, 0f, 0f, 0, new Color(64, 224, 208), 1.2f); + Dust dust = Main.dust[waterDust]; dust.noGravity = true; dust.velocity *= 0.1f; dust.velocity += Projectile.velocity * 0.1f; - dust.position.X -= num99; - dust.position.Y -= num100; + dust.position.X -= shortXVel; + dust.position.Y -= shortYVel; } if (Main.rand.NextBool(5)) { - int num103 = 4; - int num104 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num103, Projectile.position.Y + (float)num103), Projectile.width - num103 * 2, Projectile.height - num103 * 2, 33, 0f, 0f, 0, new Color(64, 224, 208), 0.6f); - Main.dust[num104].velocity *= 0.25f; - Main.dust[num104].velocity += Projectile.velocity * 0.5f; + int otherFourConst = 4; + int otherWaterDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)otherFourConst, Projectile.position.Y + (float)otherFourConst), Projectile.width - otherFourConst * 2, Projectile.height - otherFourConst * 2, 33, 0f, 0f, 0, new Color(64, 224, 208), 0.6f); + Main.dust[otherWaterDust].velocity *= 0.25f; + Main.dust[otherWaterDust].velocity += Projectile.velocity * 0.5f; } if (Projectile.velocity.Y > 16f) { diff --git a/Projectiles/Magic/WyvernFeatherGreen.cs b/Projectiles/Magic/WyvernFeatherGreen.cs index 8264185eec..30d3a863a3 100644 --- a/Projectiles/Magic/WyvernFeatherGreen.cs +++ b/Projectiles/Magic/WyvernFeatherGreen.cs @@ -47,23 +47,23 @@ namespace CalamityMod.Projectiles.Magic Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; - for (int num621 = 0; num621 < 15; num621++) + for (int i = 0; i < 15; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 61, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; + int greenDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 61, 0f, 0f, 100, default, 1.2f); + Main.dust[greenDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[greenDust].scale = 0.5f; + Main.dust[greenDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 61, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 61, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int greenDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 61, 0f, 0f, 100, default, 1.7f); + Main.dust[greenDust2].noGravity = true; + Main.dust[greenDust2].velocity *= 5f; + greenDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 61, 0f, 0f, 100, default, 1f); + Main.dust[greenDust2].velocity *= 2f; } } diff --git a/Projectiles/Magic/WyvernFeatherPink.cs b/Projectiles/Magic/WyvernFeatherPink.cs index 7e7c0e9253..bf713571f4 100644 --- a/Projectiles/Magic/WyvernFeatherPink.cs +++ b/Projectiles/Magic/WyvernFeatherPink.cs @@ -46,23 +46,23 @@ namespace CalamityMod.Projectiles.Magic Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; - for (int num621 = 0; num621 < 15; num621++) + for (int i = 0; i < 15; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 242, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; + int pinkDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 242, 0f, 0f, 100, default, 1.2f); + Main.dust[pinkDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[pinkDust].scale = 0.5f; + Main.dust[pinkDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 242, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 242, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int pinkDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 242, 0f, 0f, 100, default, 1.7f); + Main.dust[pinkDust2].noGravity = true; + Main.dust[pinkDust2].velocity *= 5f; + pinkDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 242, 0f, 0f, 100, default, 1f); + Main.dust[pinkDust2].velocity *= 2f; } } diff --git a/Projectiles/Magic/WyvernFeatherPurple.cs b/Projectiles/Magic/WyvernFeatherPurple.cs index 0c78e19cd5..d0ac60594d 100644 --- a/Projectiles/Magic/WyvernFeatherPurple.cs +++ b/Projectiles/Magic/WyvernFeatherPurple.cs @@ -46,23 +46,23 @@ namespace CalamityMod.Projectiles.Magic Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; - for (int num621 = 0; num621 < 15; num621++) + for (int i = 0; i < 15; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; + int purpleDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.2f); + Main.dust[purpleDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[purpleDust].scale = 0.5f; + Main.dust[purpleDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int purpleDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.7f); + Main.dust[purpleDust2].noGravity = true; + Main.dust[purpleDust2].velocity *= 5f; + purpleDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1f); + Main.dust[purpleDust2].velocity *= 2f; } } diff --git a/Projectiles/Melee/AegisBeam.cs b/Projectiles/Melee/AegisBeam.cs index 0620e23ebd..bd40232028 100644 --- a/Projectiles/Melee/AegisBeam.cs +++ b/Projectiles/Melee/AegisBeam.cs @@ -35,10 +35,10 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(SoundID.Item73, Projectile.position); Projectile.localAI[0] += 1f; } - int num458 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 246, 0f, 0f, 100, new Color(255, Main.DiscoG, 53), 0.8f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int goldDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 246, 0f, 0f, 100, new Color(255, Main.DiscoG, 53), 0.8f); + Main.dust[goldDust].noGravity = true; + Main.dust[goldDust].velocity *= 0.5f; + Main.dust[goldDust].velocity += Projectile.velocity * 0.1f; } public override void OnKill(int timeLeft) @@ -55,22 +55,22 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); for (int d = 0; d <= 30; d++) { - float num463 = (float)Main.rand.Next(-10, 11); - float num464 = (float)Main.rand.Next(-10, 11); + float rando = (float)Main.rand.Next(-10, 11); + float rando2 = (float)Main.rand.Next(-10, 11); float speed = (float)Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = speed / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, new Color(255, Main.DiscoG, 53), 1.2f); - Dust dust = Main.dust[num467]; + float randoAdjuster = (float)Math.Sqrt((double)(rando * rando + rando2 * rando2)); + randoAdjuster = speed / randoAdjuster; + rando *= randoAdjuster; + rando2 *= randoAdjuster; + int deathDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, new Color(255, Main.DiscoG, 53), 1.2f); + Dust dust = Main.dust[deathDust]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; + dust.velocity.X = rando; + dust.velocity.Y = rando2; } int flameAmt = Main.rand.Next(2, 4); if (Projectile.owner == Main.myPlayer) diff --git a/Projectiles/Melee/AegisBlast.cs b/Projectiles/Melee/AegisBlast.cs index 41171e81ed..623d48f4b4 100644 --- a/Projectiles/Melee/AegisBlast.cs +++ b/Projectiles/Melee/AegisBlast.cs @@ -34,61 +34,61 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(SoundID.Item74, Projectile.position); Projectile.localAI[0] += 1f; } - bool flag15 = false; - bool flag16 = false; + bool xflag = false; + bool yflag = false; if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) { - flag16 = true; + yflag = true; } if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) { - flag16 = true; + yflag = true; } - if (flag15 && flag16) + if (xflag && yflag) { Projectile.Kill(); } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-15, 16); - float num464 = (float)Main.rand.Next(-15, 16); - float num465 = (float)Main.rand.Next(4, 13); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, new Color(255, Main.DiscoG, 53), 1.5f); - Main.dust[num467].noGravity = true; - Main.dust[num467].position.X = Projectile.Center.X; - Main.dust[num467].position.Y = Projectile.Center.Y; - Dust expr_149DF_cp_0 = Main.dust[num467]; + float rando1 = (float)Main.rand.Next(-15, 16); + float rando2 = (float)Main.rand.Next(-15, 16); + float rando3 = (float)Main.rand.Next(4, 13); + float randoAdjuster = (float)Math.Sqrt((double)(rando1 * rando1 + rando2 * rando2)); + randoAdjuster = rando3 / randoAdjuster; + rando1 *= randoAdjuster; + rando2 *= randoAdjuster; + int goldDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, new Color(255, Main.DiscoG, 53), 1.5f); + Main.dust[goldDust].noGravity = true; + Main.dust[goldDust].position.X = Projectile.Center.X; + Main.dust[goldDust].position.Y = Projectile.Center.Y; + Dust expr_149DF_cp_0 = Main.dust[goldDust]; expr_149DF_cp_0.position.X += (float)Main.rand.Next(-10, 11); - Dust expr_14A09_cp_0 = Main.dust[num467]; + Dust expr_14A09_cp_0 = Main.dust[goldDust]; expr_14A09_cp_0.position.Y += (float)Main.rand.Next(-10, 11); - Main.dust[num467].velocity.X = num463; - Main.dust[num467].velocity.Y = num464; - num462++; + Main.dust[goldDust].velocity.X = rando1; + Main.dust[goldDust].velocity.Y = rando2; + timerCounter++; } } diff --git a/Projectiles/Melee/AegisBlast2.cs b/Projectiles/Melee/AegisBlast2.cs index ce706a55df..14462ca888 100644 --- a/Projectiles/Melee/AegisBlast2.cs +++ b/Projectiles/Melee/AegisBlast2.cs @@ -26,61 +26,61 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.15f / 255f, (255 - Projectile.alpha) * 0.15f / 255f, (255 - Projectile.alpha) * 0f / 255f); - bool flag15 = false; - bool flag16 = false; + bool xflag = false; + bool yflag = false; if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) { - flag16 = true; + yflag = true; } if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) { - flag16 = true; + yflag = true; } - if (flag15 && flag16) + if (xflag && yflag) { Projectile.Kill(); } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-5, 6); - float num464 = (float)Main.rand.Next(-5, 6); - float num465 = (float)Main.rand.Next(2, 5); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, new Color(255, Main.DiscoG, 53), 1.5f); - Main.dust[num467].noGravity = true; - Main.dust[num467].position.X = Projectile.Center.X; - Main.dust[num467].position.Y = Projectile.Center.Y; - Dust expr_149DF_cp_0 = Main.dust[num467]; + float rando1 = (float)Main.rand.Next(-5, 6); + float rando2 = (float)Main.rand.Next(-5, 6); + float rando3 = (float)Main.rand.Next(2, 5); + float randoAdjuster = (float)Math.Sqrt((double)(rando1 * rando1 + rando2 * rando2)); + randoAdjuster = rando3 / randoAdjuster; + rando1 *= randoAdjuster; + rando2 *= randoAdjuster; + int goldDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, new Color(255, Main.DiscoG, 53), 1.5f); + Main.dust[goldDust].noGravity = true; + Main.dust[goldDust].position.X = Projectile.Center.X; + Main.dust[goldDust].position.Y = Projectile.Center.Y; + Dust expr_149DF_cp_0 = Main.dust[goldDust]; expr_149DF_cp_0.position.X += (float)Main.rand.Next(-10, 11); - Dust expr_14A09_cp_0 = Main.dust[num467]; + Dust expr_14A09_cp_0 = Main.dust[goldDust]; expr_14A09_cp_0.position.Y += (float)Main.rand.Next(-10, 11); - Main.dust[num467].velocity.X = num463; - Main.dust[num467].velocity.Y = num464; - num462++; + Main.dust[goldDust].velocity.X = rando1; + Main.dust[goldDust].velocity.Y = rando2; + timerCounter++; } } } diff --git a/Projectiles/Melee/AegisFlame.cs b/Projectiles/Melee/AegisFlame.cs index 7e782a0e22..f5c7d0dddd 100644 --- a/Projectiles/Melee/AegisFlame.cs +++ b/Projectiles/Melee/AegisFlame.cs @@ -48,25 +48,25 @@ namespace CalamityMod.Projectiles.Melee Projectile.velocity.Y = Projectile.velocity.Y + 0.2f; } Projectile.rotation += Projectile.velocity.X * 0.1f; - int num199 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 246, 0f, 0f, 100, new Color(255, Main.DiscoG, 53), 1f); - Dust expr_8976_cp_0 = Main.dust[num199]; + int goldFlameDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 246, 0f, 0f, 100, new Color(255, Main.DiscoG, 53), 1f); + Dust expr_8976_cp_0 = Main.dust[goldFlameDust]; expr_8976_cp_0.position.X -= 2f; - Dust expr_8994_cp_0 = Main.dust[num199]; + Dust expr_8994_cp_0 = Main.dust[goldFlameDust]; expr_8994_cp_0.position.Y += 2f; - Main.dust[num199].scale += (float)Main.rand.Next(50) * 0.01f; - Main.dust[num199].noGravity = true; - Dust expr_89E7_cp_0 = Main.dust[num199]; + Main.dust[goldFlameDust].scale += (float)Main.rand.Next(50) * 0.01f; + Main.dust[goldFlameDust].noGravity = true; + Dust expr_89E7_cp_0 = Main.dust[goldFlameDust]; expr_89E7_cp_0.velocity.Y -= 2f; if (Main.rand.NextBool()) { - int num200 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 246, 0f, 0f, 100, new Color(255, Main.DiscoG, 53), 1f); - Dust expr_8A4E_cp_0 = Main.dust[num200]; + int goldFlameDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 246, 0f, 0f, 100, new Color(255, Main.DiscoG, 53), 1f); + Dust expr_8A4E_cp_0 = Main.dust[goldFlameDust2]; expr_8A4E_cp_0.position.X -= 2f; - Dust expr_8A6C_cp_0 = Main.dust[num200]; + Dust expr_8A6C_cp_0 = Main.dust[goldFlameDust2]; expr_8A6C_cp_0.position.Y += 2f; - Main.dust[num200].scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; - Main.dust[num200].noGravity = true; - Main.dust[num200].velocity *= 0.1f; + Main.dust[goldFlameDust2].scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; + Main.dust[goldFlameDust2].noGravity = true; + Main.dust[goldFlameDust2].velocity *= 0.1f; } if ((double)Projectile.velocity.Y < 0.25 && (double)Projectile.velocity.Y > 0.15) { diff --git a/Projectiles/Melee/AmidiasWhirlpool.cs b/Projectiles/Melee/AmidiasWhirlpool.cs index 40e9297957..1d14113510 100644 --- a/Projectiles/Melee/AmidiasWhirlpool.cs +++ b/Projectiles/Melee/AmidiasWhirlpool.cs @@ -31,26 +31,26 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - for (int num105 = 0; num105 < 2; num105++) + for (int i = 0; i < 2; i++) { - float num99 = Projectile.velocity.X / 3f * (float)num105; - float num100 = Projectile.velocity.Y / 3f * (float)num105; - int num101 = 4; - int num102 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num101, Projectile.position.Y + (float)num101), Projectile.width - num101 * 2, Projectile.height - num101 * 2, 33, 0f, 0f, 0, new Color(0, 142, 255), 1.5f); - Dust dust = Main.dust[num102]; + float shortXVel = Projectile.velocity.X / 3f * (float)i; + float shortYVel = Projectile.velocity.Y / 3f * (float)i; + int fourConst = 4; + int waterDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)fourConst, Projectile.position.Y + (float)fourConst), Projectile.width - fourConst * 2, Projectile.height - fourConst * 2, 33, 0f, 0f, 0, new Color(0, 142, 255), 1.5f); + Dust dust = Main.dust[waterDust]; dust.noGravity = true; dust.velocity *= 0.1f; dust.velocity += Projectile.velocity * 0.1f; - dust.position.X -= num99; - dust.position.Y -= num100; + dust.position.X -= shortXVel; + dust.position.Y -= shortYVel; } Projectile.ai[0] += 1f; - int num1013 = 0; + int homeTracker = 0; if (Projectile.velocity.Length() <= 8f) //4 { - num1013 = 1; + homeTracker = 1; } - if (num1013 == 0) + if (homeTracker == 0) { Projectile.rotation -= 0.104719758f; @@ -66,68 +66,67 @@ namespace CalamityMod.Projectiles.Melee Projectile.ai[0] = 0f; } } - else if (num1013 == 1) + else if (homeTracker == 1) { - int num3; + int inc; Projectile.rotation -= 0.104719758f; - Vector2 vector145 = Projectile.Center; - float num1015 = 150f; - bool flag59 = false; - int num1016 = 0; + Vector2 projCenter = Projectile.Center; + float homingRange = 150f; + bool isHoming = false; + int npcTracker = 0; if (Projectile.ai[1] == 0f) { - for (int num1017 = 0; num1017 < Main.maxNPCs; num1017 = num3 + 1) + for (int j = 0; j < Main.maxNPCs; j = inc + 1) { - if (Main.npc[num1017].CanBeChasedBy(Projectile, false)) + if (Main.npc[j].CanBeChasedBy(Projectile, false)) { - Vector2 center13 = Main.npc[num1017].Center; - if (Projectile.Distance(center13) < num1015 && Collision.CanHit(new Vector2(Projectile.position.X + (float)(Projectile.width / 2), Projectile.position.Y + (float)(Projectile.height / 2)), 1, 1, Main.npc[num1017].position, Main.npc[num1017].width, Main.npc[num1017].height)) + Vector2 npcCenter = Main.npc[j].Center; + if (Projectile.Distance(npcCenter) < homingRange && Collision.CanHit(new Vector2(Projectile.position.X + (float)(Projectile.width / 2), Projectile.position.Y + (float)(Projectile.height / 2)), 1, 1, Main.npc[j].position, Main.npc[j].width, Main.npc[j].height)) { - num1015 = Projectile.Distance(center13); - vector145 = center13; - flag59 = true; - num1016 = num1017; + homingRange = Projectile.Distance(npcCenter); + projCenter = npcCenter; + isHoming = true; + npcTracker = j; break; } } - num3 = num1017; + inc = j; } - if (flag59) + if (isHoming) { - if (Projectile.ai[1] != (float)(num1016 + 1)) + if (Projectile.ai[1] != (float)(npcTracker + 1)) { Projectile.netUpdate = true; } - Projectile.ai[1] = (float)(num1016 + 1); + Projectile.ai[1] = (float)(npcTracker + 1); } - flag59 = false; + isHoming = false; } if (Projectile.ai[1] != 0f) { - int num1018 = (int)(Projectile.ai[1] - 1f); - if (Main.npc[num1018].active && Main.npc[num1018].CanBeChasedBy(Projectile, true) && Projectile.Distance(Main.npc[num1018].Center) < 1000f) + int npcTrackAgain = (int)(Projectile.ai[1] - 1f); + if (Main.npc[npcTrackAgain].active && Main.npc[npcTrackAgain].CanBeChasedBy(Projectile, true) && Projectile.Distance(Main.npc[npcTrackAgain].Center) < 1000f) { - flag59 = true; - vector145 = Main.npc[num1018].Center; + isHoming = true; + projCenter = Main.npc[npcTrackAgain].Center; } } if (!Projectile.friendly) { - flag59 = false; + isHoming = false; } - if (flag59) + if (isHoming) { - float num1019 = 24f; - int num1020 = 10; - Vector2 vector146 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num1021 = vector145.X - vector146.X; - float num1022 = vector145.Y - vector146.Y; - float num1023 = (float)Math.Sqrt((double)(num1021 * num1021 + num1022 * num1022)); - num1023 = num1019 / num1023; - num1021 *= num1023; - num1022 *= num1023; - Projectile.velocity.X = (Projectile.velocity.X * (float)(num1020 - 1) + num1021) / (float)num1020; - Projectile.velocity.Y = (Projectile.velocity.Y * (float)(num1020 - 1) + num1022) / (float)num1020; + int waterDust0 = 10; + Vector2 dustDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float waterDust1 = projCenter.X - dustDirection.X; + float waterDust2 = projCenter.Y - dustDirection.Y; + float waterDust3 = (float)Math.Sqrt((double)(waterDust1 * waterDust1 + waterDust2 * waterDust2)); + waterDust3 = 24f / waterDust3; + waterDust1 *= waterDust3; + waterDust2 *= waterDust3; + Projectile.velocity.X = (Projectile.velocity.X * (float)(waterDust0 - 1) + waterDust1) / (float)waterDust0; + Projectile.velocity.Y = (Projectile.velocity.Y * (float)(waterDust0 - 1) + waterDust2) / (float)waterDust0; } } Lighting.AddLight(Projectile.Center, 0f, 0.1f, 0.9f); diff --git a/Projectiles/Melee/ArkOfTheAncients_ParryHoldout.cs b/Projectiles/Melee/ArkOfTheAncients_ParryHoldout.cs index 9ceedb711d..0b157c8738 100644 --- a/Projectiles/Melee/ArkOfTheAncients_ParryHoldout.cs +++ b/Projectiles/Melee/ArkOfTheAncients_ParryHoldout.cs @@ -136,7 +136,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(Projectile.velocity.X); + Owner.ChangeDir(Math.Sign(Projectile.velocity.X)); Owner.itemRotation = Projectile.rotation; if (Owner.direction != 1) { diff --git a/Projectiles/Melee/ArkOfTheAncients_SwungBlade.cs b/Projectiles/Melee/ArkOfTheAncients_SwungBlade.cs index a0a439b6b4..fe2c495ee8 100644 --- a/Projectiles/Melee/ArkOfTheAncients_SwungBlade.cs +++ b/Projectiles/Melee/ArkOfTheAncients_SwungBlade.cs @@ -100,7 +100,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(Projectile.velocity.X); + Owner.ChangeDir(Math.Sign(Projectile.velocity.X)); Owner.itemRotation = Projectile.rotation; if (Owner.direction != 1) { diff --git a/Projectiles/Melee/ArkOfTheCosmos_ParryHoldout.cs b/Projectiles/Melee/ArkOfTheCosmos_ParryHoldout.cs index 1266878a42..0ac82786cb 100644 --- a/Projectiles/Melee/ArkOfTheCosmos_ParryHoldout.cs +++ b/Projectiles/Melee/ArkOfTheCosmos_ParryHoldout.cs @@ -152,7 +152,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(Projectile.velocity.X); + Owner.ChangeDir(Math.Sign(Projectile.velocity.X)); Owner.itemRotation = Projectile.rotation; if (Owner.direction != 1) { diff --git a/Projectiles/Melee/ArkOfTheCosmos_SwungBlade.cs b/Projectiles/Melee/ArkOfTheCosmos_SwungBlade.cs index 2683709591..7881de6e2b 100644 --- a/Projectiles/Melee/ArkOfTheCosmos_SwungBlade.cs +++ b/Projectiles/Melee/ArkOfTheCosmos_SwungBlade.cs @@ -285,7 +285,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(Projectile.velocity.X); + Owner.ChangeDir(Math.Sign(Projectile.velocity.X)); Owner.itemRotation = Projectile.rotation; if (Owner.direction != 1) { @@ -432,13 +432,6 @@ namespace CalamityMod.Projectiles.Melee if (Combo == 3f) { SoundEngine.PlaySound(CommonCalamitySounds.ScissorGuillotineSnapSound with { Volume =CommonCalamitySounds.ScissorGuillotineSnapSound.Volume * 1.3f }, Projectile.Center); - - if (Charge <= 1) - { - ArkoftheCosmos sword = (Owner.HeldItem.ModItem as ArkoftheCosmos); - if (sword != null) - sword.Charge = 2f; - } } } diff --git a/Projectiles/Melee/ArkOfTheElements_ParryHoldout.cs b/Projectiles/Melee/ArkOfTheElements_ParryHoldout.cs index f8c2d01a9c..ae1dfe97fc 100644 --- a/Projectiles/Melee/ArkOfTheElements_ParryHoldout.cs +++ b/Projectiles/Melee/ArkOfTheElements_ParryHoldout.cs @@ -11,6 +11,7 @@ using static Terraria.ModLoader.ModContent; using static CalamityMod.CalamityUtils; using Terraria.Audio; using CalamityMod.Sounds; +using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Melee { @@ -75,6 +76,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { + target.AddBuff(ModContent.BuffType(), 90); if (AlreadyParried > 0) return; @@ -150,7 +152,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(Projectile.velocity.X); + Owner.ChangeDir(Math.Sign(Projectile.velocity.X)); Owner.itemRotation = Projectile.rotation; if (Owner.direction != 1) { diff --git a/Projectiles/Melee/ArkOfTheElements_SwungBlade.cs b/Projectiles/Melee/ArkOfTheElements_SwungBlade.cs index a20072e250..e91203497f 100644 --- a/Projectiles/Melee/ArkOfTheElements_SwungBlade.cs +++ b/Projectiles/Melee/ArkOfTheElements_SwungBlade.cs @@ -11,6 +11,7 @@ using static Terraria.ModLoader.ModContent; using static CalamityMod.CalamityUtils; using Terraria.Audio; using CalamityMod.Sounds; +using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Melee { @@ -223,7 +224,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(Projectile.velocity.X); + Owner.ChangeDir(Math.Sign(Projectile.velocity.X)); Owner.itemRotation = Projectile.rotation; if (Owner.direction != 1) { @@ -241,6 +242,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { + target.AddBuff(ModContent.BuffType(), 60); for (int i = 0; i < 5; i++) { Vector2 particleSpeed = Utils.SafeNormalize(target.Center - Projectile.Center , Vector2.One).RotatedByRandom(MathHelper.PiOver4 * 0.8f) * Main.rand.NextFloat(3.6f, 8f); diff --git a/Projectiles/Melee/BalefulHarvesterProjectile.cs b/Projectiles/Melee/BalefulHarvesterProjectile.cs index 7deb4805d8..6abc9e648a 100644 --- a/Projectiles/Melee/BalefulHarvesterProjectile.cs +++ b/Projectiles/Melee/BalefulHarvesterProjectile.cs @@ -14,12 +14,13 @@ namespace CalamityMod.Projectiles.Melee { ProjectileID.Sets.TrailCacheLength[Projectile.type] = 5; ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + Main.projFrames[Projectile.type] = 5; } public override void SetDefaults() { - Projectile.width = 26; - Projectile.height = 26; + Projectile.width = 46; + Projectile.height = 36; Projectile.friendly = true; Projectile.DamageType = DamageClass.Melee; Projectile.penetrate = 1; @@ -45,40 +46,48 @@ namespace CalamityMod.Projectiles.Melee Projectile.alpha = 0; } + Projectile.frameCounter++; + if (Projectile.frameCounter > 6) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame > 4) + Projectile.frame = 0; + if (Projectile.ai[0] >= 0f && Projectile.ai[0] < 200f) { - int num554 = (int)Projectile.ai[0]; - if (Main.npc[num554].active) + int npcTracker = (int)Projectile.ai[0]; + if (Main.npc[npcTracker].active) { - float num555 = 8f; - Vector2 vector44 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num556 = Main.npc[num554].position.X - vector44.X; - float num557 = Main.npc[num554].position.Y - vector44.Y; - float num558 = (float)Math.Sqrt((double)(num556 * num556 + num557 * num557)); - num558 = num555 / num558; - num556 *= num558; - num557 *= num558; - Projectile.velocity.X = (Projectile.velocity.X * 14f + num556) / 15f; - Projectile.velocity.Y = (Projectile.velocity.Y * 14f + num557) / 15f; + Vector2 projDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float projXVel = Main.npc[npcTracker].position.X - projDirection.X; + float projYVel = Main.npc[npcTracker].position.Y - projDirection.Y; + float projVelocity = (float)Math.Sqrt((double)(projXVel * projXVel + projYVel * projYVel)); + projVelocity = 8f / projVelocity; + projXVel *= projVelocity; + projYVel *= projVelocity; + Projectile.velocity.X = (Projectile.velocity.X * 14f + projXVel) / 15f; + Projectile.velocity.Y = (Projectile.velocity.Y * 14f + projYVel) / 15f; } else { - float num559 = 1000f; - int num3; - for (int num560 = 0; num560 < Main.maxNPCs; num560 = num3 + 1) + float homingRange = 1000f; + int inc; + for (int i = 0; i < Main.maxNPCs; i = inc + 1) { - if (Main.npc[num560].CanBeChasedBy(Projectile, false)) + if (Main.npc[i].CanBeChasedBy(Projectile, false)) { - float num561 = Main.npc[num560].position.X + (float)(Main.npc[num560].width / 2); - float num562 = Main.npc[num560].position.Y + (float)(Main.npc[num560].height / 2); - float num563 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num561) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num562); - if (num563 < num559 && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[num560].position, Main.npc[num560].width, Main.npc[num560].height)) + float npcX = Main.npc[i].position.X + (float)(Main.npc[i].width / 2); + float npcY = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2); + float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); + if (npcDist < homingRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height)) { - num559 = num563; - Projectile.ai[0] = (float)num560; + homingRange = npcDist; + Projectile.ai[0] = (float)i; } } - num3 = num560; + inc = i; } } @@ -93,14 +102,14 @@ namespace CalamityMod.Projectiles.Melee Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X); } - for (int num157 = 0; num157 < 2; num157++) + for (int j = 0; j < 2; j++) { - int num158 = Dust.NewDust(new Vector2(Projectile.position.X + 4f, Projectile.position.Y + 4f), Projectile.width - 8, Projectile.height - 8, Main.rand.NextBool() ? 5 : 6, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 2f); - Main.dust[num158].position -= Projectile.velocity * 2f; - Main.dust[num158].noGravity = true; - Dust expr_7A4A_cp_0_cp_0 = Main.dust[num158]; + int dust = Dust.NewDust(new Vector2(Projectile.position.X + 4f, Projectile.position.Y + 4f), Projectile.width - 8, Projectile.height - 8, Main.rand.NextBool() ? 5 : 6, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 2f); + Main.dust[dust].position -= Projectile.velocity * 2f; + Main.dust[dust].noGravity = true; + Dust expr_7A4A_cp_0_cp_0 = Main.dust[dust]; expr_7A4A_cp_0_cp_0.velocity.X *= 0.3f; - Dust expr_7A65_cp_0_cp_0 = Main.dust[num158]; + Dust expr_7A65_cp_0_cp_0 = Main.dust[dust]; expr_7A65_cp_0_cp_0.velocity.Y *= 0.3f; } @@ -124,23 +133,23 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Dig, Projectile.position); - for (int num621 = 0; num621 < 5; num621++) + for (int j = 0; j < 5; j++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 5, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int deathDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 5, 0f, 0f, 100, default, 2f); + Main.dust[deathDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[deathDust].scale = 0.5f; + Main.dust[deathDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int k = 0; k < 10; k++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int deathDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 3f); + Main.dust[deathDust2].noGravity = true; + Main.dust[deathDust2].velocity *= 5f; + deathDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 2f); + Main.dust[deathDust2].velocity *= 2f; } } diff --git a/Projectiles/Melee/BalefulHarvesterProjectile.png b/Projectiles/Melee/BalefulHarvesterProjectile.png index 55fa05c28b..da20d1059b 100644 Binary files a/Projectiles/Melee/BalefulHarvesterProjectile.png and b/Projectiles/Melee/BalefulHarvesterProjectile.png differ diff --git a/Projectiles/Melee/BallOFuguProj.cs b/Projectiles/Melee/BallOFuguProj.cs index f105a0c7aa..fc786dfeac 100644 --- a/Projectiles/Melee/BallOFuguProj.cs +++ b/Projectiles/Melee/BallOFuguProj.cs @@ -63,13 +63,13 @@ namespace CalamityMod.Projectiles.Melee Projectile.ai[0] = 2f; } Projectile.tileCollide = false; - float num694 = 20f; + float returnSpeed = 20f; if (Projectile.ai[0] == 2f) { - num694 = 40f; + returnSpeed = 40f; } - Projectile.velocity = Vector2.Normalize(projVector) * num694; - if (projVector.Length() < num694) + Projectile.velocity = Vector2.Normalize(projVector) * returnSpeed; + if (projVector.Length() < returnSpeed) { Projectile.Kill(); return; @@ -82,11 +82,11 @@ namespace CalamityMod.Projectiles.Melee } if (Projectile.ai[1] % 6f == 0f && Projectile.owner == Main.myPlayer) { - Vector2 vector63 = projVector * -1f; - vector63.Normalize(); - vector63 *= (float)Main.rand.Next(45, 65) * 0.1f; - vector63 = vector63.RotatedBy((Main.rand.NextDouble() - 0.5) * 1.5707963705062866, default); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, vector63.X, vector63.Y, ModContent.ProjectileType(), (int)(Projectile.damage * 0.6), Projectile.knockBack * 0.2f, Projectile.owner, -10f, 0f); + Vector2 spikeVector = projVector * -1f; + spikeVector.Normalize(); + spikeVector *= (float)Main.rand.Next(45, 65) * 0.1f; + spikeVector = spikeVector.RotatedBy((Main.rand.NextDouble() - 0.5) * 1.5707963705062866, default); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, spikeVector.X, spikeVector.Y, ModContent.ProjectileType(), (int)(Projectile.damage * 0.6), Projectile.knockBack * 0.2f, Projectile.owner, -10f, 0f); } } @@ -103,35 +103,35 @@ namespace CalamityMod.Projectiles.Melee { Vector2 mountedCenter = Main.player[Projectile.owner].MountedCenter; Texture2D texture2D2 = ModContent.Request("CalamityMod/Projectiles/Melee/BallOFuguChain").Value; - Vector2 vector17 = Projectile.Center; + Vector2 projCenter = Projectile.Center; Rectangle? sourceRectangle = null; Vector2 origin = new Vector2((float)texture2D2.Width * 0.5f, (float)texture2D2.Height * 0.5f); - float num91 = (float)texture2D2.Height; - Vector2 vector18 = mountedCenter - vector17; - float rotation15 = (float)Math.Atan2((double)vector18.Y, (double)vector18.X) - 1.57f; - bool flag13 = true; - if (float.IsNaN(vector17.X) && float.IsNaN(vector17.Y)) + float projHeight = (float)texture2D2.Height; + Vector2 actualCenter = mountedCenter - projCenter; + float drawRotation = (float)Math.Atan2((double)actualCenter.Y, (double)actualCenter.X) - 1.57f; + bool isActive = true; + if (float.IsNaN(projCenter.X) && float.IsNaN(projCenter.Y)) { - flag13 = false; + isActive = false; } - if (float.IsNaN(vector18.X) && float.IsNaN(vector18.Y)) + if (float.IsNaN(actualCenter.X) && float.IsNaN(actualCenter.Y)) { - flag13 = false; + isActive = false; } - while (flag13) + while (isActive) { - if (vector18.Length() < num91 + 1f) + if (actualCenter.Length() < projHeight + 1f) { - flag13 = false; + isActive = false; } else { - Vector2 value2 = vector18; - value2.Normalize(); - vector17 += value2 * num91; - vector18 = mountedCenter - vector17; - Color color17 = Lighting.GetColor((int)vector17.X / 16, (int)(vector17.Y / 16f)); - Main.spriteBatch.Draw(texture2D2, vector17 - Main.screenPosition, sourceRectangle, color17, rotation15, origin, 1f, SpriteEffects.None, 0); + Vector2 drawCenter = actualCenter; + drawCenter.Normalize(); + projCenter += drawCenter * projHeight; + actualCenter = mountedCenter - projCenter; + Color drawArea = Lighting.GetColor((int)projCenter.X / 16, (int)(projCenter.Y / 16f)); + Main.spriteBatch.Draw(texture2D2, projCenter - Main.screenPosition, sourceRectangle, drawArea, drawRotation, origin, 1f, SpriteEffects.None, 0); } } return true; diff --git a/Projectiles/Melee/BansheeHookBoom.cs b/Projectiles/Melee/BansheeHookBoom.cs index 27075ae819..81d597f932 100644 --- a/Projectiles/Melee/BansheeHookBoom.cs +++ b/Projectiles/Melee/BansheeHookBoom.cs @@ -40,36 +40,36 @@ namespace CalamityMod.Projectiles.Melee Projectile.width = Projectile.height = (int)(52f * Projectile.scale); Projectile.Center = Projectile.position; Projectile.Damage(); - for (int num1000 = 0; num1000 < 2; num1000++) + for (int i = 0; i < 2; i++) { - int num1001 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.5f); - Main.dust[num1001].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + int bansheeDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.5f); + Main.dust[bansheeDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; } - for (int num1002 = 0; num1002 < 5; num1002++) + for (int j = 0; j < 5; j++) { - int num1003 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 200, default, 2.7f); - Main.dust[num1003].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; - Main.dust[num1003].noGravity = true; - Main.dust[num1003].velocity *= 3f; - num1003 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.5f); - Main.dust[num1003].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; - Main.dust[num1003].velocity *= 2f; - Main.dust[num1003].noGravity = true; - Main.dust[num1003].fadeIn = 2.5f; + int bansheeDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 200, default, 2.7f); + Main.dust[bansheeDust2].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + Main.dust[bansheeDust2].noGravity = true; + Main.dust[bansheeDust2].velocity *= 3f; + bansheeDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.5f); + Main.dust[bansheeDust2].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + Main.dust[bansheeDust2].velocity *= 2f; + Main.dust[bansheeDust2].noGravity = true; + Main.dust[bansheeDust2].fadeIn = 2.5f; } - for (int num1004 = 0; num1004 < 2; num1004++) + for (int k = 0; k < 2; k++) { - int num1005 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 0, default, 2.7f); - Main.dust[num1005].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 2f; - Main.dust[num1005].noGravity = true; - Main.dust[num1005].velocity *= 3f; + int bansheeDust3 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 0, default, 2.7f); + Main.dust[bansheeDust3].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 2f; + Main.dust[bansheeDust3].noGravity = true; + Main.dust[bansheeDust3].velocity *= 3f; } - for (int num1006 = 0; num1006 < 5; num1006++) + for (int l = 0; l < 5; l++) { - int num1007 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 0, default, 1.5f); - Main.dust[num1007].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 2f; - Main.dust[num1007].noGravity = true; - Main.dust[num1007].velocity *= 3f; + int spiritDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 0, default, 1.5f); + Main.dust[spiritDust].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 2f; + Main.dust[spiritDust].noGravity = true; + Main.dust[spiritDust].velocity *= 3f; } } } diff --git a/Projectiles/Melee/BladecrestOathswordProj.cs b/Projectiles/Melee/BladecrestOathswordProj.cs index 4e0b5e15f9..110a0ce3bd 100644 --- a/Projectiles/Melee/BladecrestOathswordProj.cs +++ b/Projectiles/Melee/BladecrestOathswordProj.cs @@ -3,6 +3,7 @@ using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using System; using System.IO; +using CalamityMod.Effects; using Terraria; using Terraria.Graphics.Effects; using Terraria.Graphics.Shaders; @@ -76,10 +77,17 @@ namespace CalamityMod.Projectiles.Melee DecideCurrentState(); Direction = Owner.direction; + + //Set the owner's arm to rotate with the blade + if (Owner.itemAnimation > 0) + { + float armPointingDirection = Projectile.rotation + MathHelper.ToRadians(240); + Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, armPointingDirection); + } // Glue the sword to its owner. Projectile.Opacity = 1f; - Projectile.position = Owner.RotatedRelativePoint(Owner.MountedCenter, true) - Projectile.Size / 2f + Vector2.UnitY * Owner.gfxOffY; + Projectile.position = Owner.RotatedRelativePoint(Owner.MountedCenter, true) - Projectile.Size * 0.5f + Vector2.UnitY * Owner.gfxOffY; float swingSpeedInterpolant = 0.27f; float swingCompletion = 1f - Owner.itemAnimation / (float)Owner.itemAnimationMax; @@ -105,7 +113,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.Opacity = 0f; // Determine the horizontal stretch offset of the blade. This is used in matrix math below to create 2.5D visuals. - BladeHorizontalFactor = MathHelper.Lerp(1f, 1.5f, (aimDirection3D.X * 0.5f + 0.5f) * Utils.GetLerpValue(1f, 0.8f, unchangedSwingCompletion, true)); + BladeHorizontalFactor = MathHelper.Lerp(1f, 1.25f, (aimDirection3D.X * 0.5f + 0.5f) * Utils.GetLerpValue(1f, 0.8f, unchangedSwingCompletion, true)); float baseRotation = new Vector2(aimDirection3D.X, aimDirection3D.Y).ToRotation(); @@ -128,9 +136,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.rotation = Projectile.rotation.AngleTowards(idealRotation, swingSpeedInterpolant * 0.45f).AngleLerp(idealRotation, swingSpeedInterpolant * 0.2f); // Offset the blade so that the handle is attached to the owner's hand. - float horizontalBladeOffset = MathHelper.Lerp(-4f, 10f, Utils.GetLerpValue(1f, 0.72f, unchangedSwingCompletion, true) * Utils.GetLerpValue(0f, 0.28f, unchangedSwingCompletion, true)); - Vector2 bladeOffset = (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * Projectile.width * 0.5f; - bladeOffset += new Vector2(Direction * horizontalBladeOffset, 2f).RotatedBy(Owner.fullRotation) + Vector2.UnitY * Owner.gfxOffY; + Vector2 bladeOffset = (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * Projectile.width * 0.65f; + bladeOffset += Vector2.UnitY * Owner.gfxOffY; Projectile.position += bladeOffset; // Create demon magic dust along the blade when swinging, as well as demon blood scythes. @@ -146,12 +153,12 @@ namespace CalamityMod.Projectiles.Melee shadowflame.noGravity = true; } - if (Main.myPlayer == Projectile.owner && Owner.itemAnimation % 4 == 3 && Owner.itemAnimation < Owner.itemAnimationMax - 3) + if (Main.myPlayer == Projectile.owner && Owner.itemAnimation % 5 == 3 && Owner.itemAnimation < Owner.itemAnimationMax - 3) { Vector2 bloodScytheShootVelocity = (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2(); bloodScytheShootVelocity.Y *= 0.04f; bloodScytheShootVelocity = bloodScytheShootVelocity.SafeNormalize(Vector2.UnitY) * 50f; - Vector2 bloodScytheSpawnPosition = Projectile.Center + bloodScytheShootVelocity.SafeNormalize(Vector2.UnitY) * 50f; + Vector2 bloodScytheSpawnPosition = Projectile.Center + bloodScytheShootVelocity.SafeNormalize(Vector2.UnitY) * 35f; Projectile.NewProjectile(Projectile.GetSource_FromThis(), bloodScytheSpawnPosition, bloodScytheShootVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack * 0.4f, Projectile.owner); } } @@ -179,6 +186,36 @@ namespace CalamityMod.Projectiles.Melee CurrentState = SwingState.Default; } } + + public override bool PreDraw(ref Color lightColor) + { + Main.spriteBatch.EnterShaderRegion(); + + CalamityUtils.CalculatePerspectiveMatricies(out Matrix viewMatrix, out Matrix projectionMatrix); + + GameShaders.Misc["CalamityMod:LinearTransformation"].UseColor(Main.hslToRgb(0.95f, 0.85f, 0.5f)); + GameShaders.Misc["CalamityMod:LinearTransformation"].UseOpacity(0f); + GameShaders.Misc["CalamityMod:LinearTransformation"].Shader.Parameters["uWorldViewProjection"].SetValue(viewMatrix * projectionMatrix); + GameShaders.Misc["CalamityMod:LinearTransformation"].Shader.Parameters["localMatrix"].SetValue(new Matrix() + { + M11 = BladeHorizontalFactor, + M12 = 0f, + M21 = 0f, + M22 = 1f, + }); + GameShaders.Misc["CalamityMod:LinearTransformation"].Apply(); + + CalamityUtils.DrawAfterimagesCentered(Projectile, 2, lightColor); + + Main.spriteBatch.ExitShaderRegion(); + + CalamityUtils.CalculatePerspectiveMatricies(out var view, out var proj); + CalamityShaders.PrimitiveClearShader.Parameters["uWorldViewProjection"].SetValue(view * proj); + CalamityShaders.PrimitiveClearShader.CurrentTechnique.Passes[0].Apply(); + Filters.Scene["CalamityMod:PrimitiveClearShader"].GetShader().Shader.CurrentTechnique.Passes[0].Apply(); + + return false; + } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { diff --git a/Projectiles/Melee/BlazingPhantomBlade.cs b/Projectiles/Melee/BlazingPhantomBlade.cs index 049fb51bd1..cfd9547d08 100644 --- a/Projectiles/Melee/BlazingPhantomBlade.cs +++ b/Projectiles/Melee/BlazingPhantomBlade.cs @@ -23,13 +23,13 @@ namespace CalamityMod.Projectiles.Melee Projectile.friendly = true; Projectile.DamageType = DamageClass.Melee; Projectile.tileCollide = false; - Projectile.penetrate = 3; + Projectile.penetrate = 5; Projectile.ignoreWater = true; AIType = ProjectileID.DeathSickle; Projectile.MaxUpdates = 2; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 20 * Projectile.MaxUpdates; - Projectile.timeLeft = 180 * Projectile.MaxUpdates; + Projectile.timeLeft = 210 * Projectile.MaxUpdates; } public override void AI() @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(BuffID.OnFire, 180); + target.AddBuff(BuffID.OnFire3, 180); } } } diff --git a/Projectiles/Melee/Blood.cs b/Projectiles/Melee/Blood.cs index 360450cb38..bfa2b4bc7a 100644 --- a/Projectiles/Melee/Blood.cs +++ b/Projectiles/Melee/Blood.cs @@ -25,11 +25,11 @@ namespace CalamityMod.Projectiles.Melee Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { - for (int num468 = 0; num468 < 2; num468++) + for (int i = 0; i < 2; i++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 5, 0f, 0f, 100, default, 1f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int blood = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 5, 0f, 0f, 100, default, 1f); + Main.dust[blood].noGravity = true; + Main.dust[blood].velocity *= 0f; } } diff --git a/Projectiles/Melee/Blood2.cs b/Projectiles/Melee/Blood2.cs index 52931358fb..41e14a6e26 100644 --- a/Projectiles/Melee/Blood2.cs +++ b/Projectiles/Melee/Blood2.cs @@ -26,11 +26,11 @@ namespace CalamityMod.Projectiles.Melee Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { - for (int num468 = 0; num468 < 2; num468++) + for (int i = 0; i < 2; i++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 5, 0f, 0f, 100, default, 1f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int blood = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 5, 0f, 0f, 100, default, 1f); + Main.dust[blood].noGravity = true; + Main.dust[blood].velocity *= 0f; } } diff --git a/Projectiles/Melee/BloodBall.cs b/Projectiles/Melee/BloodBall.cs index 69c5acdb19..89ab005342 100644 --- a/Projectiles/Melee/BloodBall.cs +++ b/Projectiles/Melee/BloodBall.cs @@ -25,36 +25,36 @@ namespace CalamityMod.Projectiles.Melee { try { - int num223 = (int)(Projectile.position.X / 16f) - 1; - int num224 = (int)((Projectile.position.X + (float)Projectile.width) / 16f) + 2; - int num225 = (int)(Projectile.position.Y / 16f) - 1; - int num226 = (int)((Projectile.position.Y + (float)Projectile.height) / 16f) + 2; - if (num223 < 0) + int tileXMin = (int)(Projectile.position.X / 16f) - 1; + int tileXMax = (int)((Projectile.position.X + (float)Projectile.width) / 16f) + 2; + int tileYMin = (int)(Projectile.position.Y / 16f) - 1; + int tileYMax = (int)((Projectile.position.Y + (float)Projectile.height) / 16f) + 2; + if (tileXMin < 0) { - num223 = 0; + tileXMin = 0; } - if (num224 > Main.maxTilesX) + if (tileXMax > Main.maxTilesX) { - num224 = Main.maxTilesX; + tileXMax = Main.maxTilesX; } - if (num225 < 0) + if (tileYMin < 0) { - num225 = 0; + tileYMin = 0; } - if (num226 > Main.maxTilesY) + if (tileYMax > Main.maxTilesY) { - num226 = Main.maxTilesY; + tileYMax = Main.maxTilesY; } - for (int num227 = num223; num227 < num224; num227++) + for (int i = tileXMin; i < tileXMax; i++) { - for (int num228 = num225; num228 < num226; num228++) + for (int j = tileYMin; j < tileYMax; j++) { - if (Main.tile[num227, num228] != null && Main.tile[num227, num228].HasUnactuatedTile && (Main.tileSolid[(int)Main.tile[num227, num228].TileType] || (Main.tileSolidTop[(int)Main.tile[num227, num228].TileType] && Main.tile[num227, num228].TileFrameY == 0))) + if (Main.tile[i, j] != null && Main.tile[i, j].HasUnactuatedTile && (Main.tileSolid[(int)Main.tile[i, j].TileType] || (Main.tileSolidTop[(int)Main.tile[i, j].TileType] && Main.tile[i, j].TileFrameY == 0))) { - Vector2 vector19; - vector19.X = (float)(num227 * 16); - vector19.Y = (float)(num228 * 16); - if (Projectile.position.X + (float)Projectile.width - 4f > vector19.X && Projectile.position.X + 4f < vector19.X + 16f && Projectile.position.Y + (float)Projectile.height - 4f > vector19.Y && Projectile.position.Y + 4f < vector19.Y + 16f) + Vector2 projPos; + projPos.X = (float)(i * 16); + projPos.Y = (float)(j * 16); + if (Projectile.position.X + (float)Projectile.width - 4f > projPos.X && Projectile.position.X + 4f < projPos.X + 16f && Projectile.position.Y + (float)Projectile.height - 4f > projPos.Y && Projectile.position.Y + 4f < projPos.Y + 16f) { Projectile.velocity.X = 0f; Projectile.velocity.Y = -0.2f; @@ -105,18 +105,18 @@ namespace CalamityMod.Projectiles.Melee Projectile.height = 22; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num648 = 0; num648 < 20; num648++) + for (int i = 0; i < 20; i++) { - int num649 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 5, 0f, 0f, 100, default, 1.5f); - Main.dust[num649].velocity *= 1.4f; + int blood = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 5, 0f, 0f, 100, default, 1.5f); + Main.dust[blood].velocity *= 1.4f; } - for (int num650 = 0; num650 < 10; num650++) + for (int j = 0; j < 10; j++) { - int num651 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 5, 0f, 0f, 100, default, 2.5f); - Main.dust[num651].noGravity = true; - Main.dust[num651].velocity *= 5f; - num651 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 5, 0f, 0f, 100, default, 1.5f); - Main.dust[num651].velocity *= 3f; + int bloody = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 5, 0f, 0f, 100, default, 2.5f); + Main.dust[bloody].noGravity = true; + Main.dust[bloody].velocity *= 5f; + bloody = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 5, 0f, 0f, 100, default, 1.5f); + Main.dust[bloody].velocity *= 3f; } } diff --git a/Projectiles/Melee/BloodScythe.cs b/Projectiles/Melee/BloodScythe.cs index 80313228dd..5a760e6f83 100644 --- a/Projectiles/Melee/BloodScythe.cs +++ b/Projectiles/Melee/BloodScythe.cs @@ -37,8 +37,8 @@ namespace CalamityMod.Projectiles.Melee if (potentialTarget != null && Projectile.timeLeft >= 480) { float flySpeed = Projectile.velocity.Length(); - if (flySpeed < 8f) - flySpeed = 8f; + if (flySpeed < 10f) + flySpeed = 10f; Projectile.Center = Projectile.Center.MoveTowards(potentialTarget.Center, 1.75f); Projectile.velocity = (Projectile.velocity * 14f + Projectile.SafeDirectionTo(potentialTarget.Center) * flySpeed) / 15f; diff --git a/Projectiles/Melee/BonebreakerProjectile.cs b/Projectiles/Melee/BonebreakerProjectile.cs index 6d2ce4b2e3..17580a6fe9 100644 --- a/Projectiles/Melee/BonebreakerProjectile.cs +++ b/Projectiles/Melee/BonebreakerProjectile.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.penetrate = -1; Projectile.alpha = 255; Projectile.DamageType = DamageClass.MeleeNoSpeed; - Projectile.timeLeft = 600; + Projectile.timeLeft = 240; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -2; } @@ -89,16 +89,16 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(BuffID.BoneJavelin, 240); - target.AddBuff(BuffID.Venom, 120); - target.AddBuff(ModContent.BuffType(), 240); + target.AddBuff(BuffID.BoneJavelin, 180); + target.AddBuff(BuffID.Venom, 90); + target.AddBuff(ModContent.BuffType(), 180); } public override void OnHitPlayer(Player target, Player.HurtInfo info) { - target.AddBuff(BuffID.BoneJavelin, 240); - target.AddBuff(BuffID.Venom, 120); - target.AddBuff(ModContent.BuffType(), 240); + target.AddBuff(BuffID.BoneJavelin, 180); + target.AddBuff(BuffID.Venom, 90); + target.AddBuff(ModContent.BuffType(), 180); } public override bool? CanHitNPC(NPC target) diff --git a/Projectiles/Melee/Brimblast.cs b/Projectiles/Melee/Brimblast.cs index 42b93f9ce6..c71cbaf998 100644 --- a/Projectiles/Melee/Brimblast.cs +++ b/Projectiles/Melee/Brimblast.cs @@ -52,8 +52,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.velocity.Y = Projectile.velocity.Y + 0.2f; } Projectile.rotation += Projectile.velocity.X * 0.1f; - int num199 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); - Dust dust = Main.dust[num199]; + int brimDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); + Dust dust = Main.dust[brimDust]; dust.position.X -= 2f; dust.position.Y += 2f; dust.scale += (float)Main.rand.Next(50) * 0.01f; @@ -61,8 +61,8 @@ namespace CalamityMod.Projectiles.Melee dust.velocity.Y -= 4f; if (Main.rand.NextBool()) { - int num200 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); - Dust dust2 = Main.dust[num200]; + int brimDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); + Dust dust2 = Main.dust[brimDust2]; dust2.position.X -= 2f; dust2.position.Y += 2f; dust2.scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; diff --git a/Projectiles/Melee/BrimlanceHellfireExplosion.cs b/Projectiles/Melee/BrimlanceHellfireExplosion.cs index cd69daba96..0a5c3cda46 100644 --- a/Projectiles/Melee/BrimlanceHellfireExplosion.cs +++ b/Projectiles/Melee/BrimlanceHellfireExplosion.cs @@ -1,4 +1,4 @@ -using CalamityMod.Dusts; +using CalamityMod.Dusts; using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using System; @@ -21,11 +21,11 @@ namespace CalamityMod.Projectiles.Melee Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.tileCollide = false; - Projectile.penetrate = -1; - Projectile.timeLeft = 60; + Projectile.penetrate = 3; + Projectile.timeLeft = 30; Projectile.DamageType = DamageClass.Melee; Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 10; + Projectile.idStaticNPCHitCooldown = 30; } public override void AI() @@ -36,60 +36,60 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(SoundID.Item20, Projectile.position); Projectile.localAI[0] += 1f; } - bool flag15 = false; - bool flag16 = false; + bool xflag = false; + bool yflag = false; if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) { - flag16 = true; + yflag = true; } if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) { - flag16 = true; + yflag = true; } - if (flag15 && flag16) + if (xflag && yflag) { Projectile.Kill(); } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-10, 11); - float num464 = (float)Main.rand.Next(-10, 11); - float num465 = (float)Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); - Dust dust = Main.dust[num467]; + float rand1 = (float)Main.rand.Next(-10, 11); + float rand2 = (float)Main.rand.Next(-10, 11); + float rand3 = (float)Main.rand.Next(3, 9); + float randAdjuster = (float)Math.Sqrt((double)(rand1 * rand1 + rand2 * rand2)); + randAdjuster = rand3 / randAdjuster; + rand1 *= randAdjuster; + rand2 *= randAdjuster; + int brimDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); + Dust dust = Main.dust[brimDust]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = rand1; + dust.velocity.Y = rand2; + timerCounter++; } } diff --git a/Projectiles/Melee/BrimlanceStandingFire.cs b/Projectiles/Melee/BrimlanceStandingFire.cs index 5a011c9c82..bd898c12e0 100644 --- a/Projectiles/Melee/BrimlanceStandingFire.cs +++ b/Projectiles/Melee/BrimlanceStandingFire.cs @@ -60,25 +60,25 @@ namespace CalamityMod.Projectiles.Melee Projectile.ai[1] = 1f; SoundEngine.PlaySound(SoundID.Item13, Projectile.position); } - int num199 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); - Dust expr_8976_cp_0 = Main.dust[num199]; + int brimDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); + Dust expr_8976_cp_0 = Main.dust[brimDust]; expr_8976_cp_0.position.X -= 2f; - Dust expr_8994_cp_0 = Main.dust[num199]; + Dust expr_8994_cp_0 = Main.dust[brimDust]; expr_8994_cp_0.position.Y += 2f; - Main.dust[num199].scale += (float)Main.rand.Next(50) * 0.01f; - Main.dust[num199].noGravity = true; - Dust expr_89E7_cp_0 = Main.dust[num199]; + Main.dust[brimDust].scale += (float)Main.rand.Next(50) * 0.01f; + Main.dust[brimDust].noGravity = true; + Dust expr_89E7_cp_0 = Main.dust[brimDust]; expr_89E7_cp_0.velocity.Y -= 2f; if (Main.rand.NextBool()) { - int num200 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); - Dust expr_8A4E_cp_0 = Main.dust[num200]; + int brimDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); + Dust expr_8A4E_cp_0 = Main.dust[brimDust2]; expr_8A4E_cp_0.position.X -= 2f; - Dust expr_8A6C_cp_0 = Main.dust[num200]; + Dust expr_8A6C_cp_0 = Main.dust[brimDust2]; expr_8A6C_cp_0.position.Y += 2f; - Main.dust[num200].scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; - Main.dust[num200].noGravity = true; - Main.dust[num200].velocity *= 0.1f; + Main.dust[brimDust2].scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; + Main.dust[brimDust2].noGravity = true; + Main.dust[brimDust2].velocity *= 0.1f; } if ((double)Projectile.velocity.Y < 0.25 && (double)Projectile.velocity.Y > 0.15) { diff --git a/Projectiles/Melee/Brimlash2.cs b/Projectiles/Melee/Brimlash2.cs index 2f6f31ea3a..252b5827c5 100644 --- a/Projectiles/Melee/Brimlash2.cs +++ b/Projectiles/Melee/Brimlash2.cs @@ -38,10 +38,10 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.timeLeft < 90) CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 600f, 12f, 15f); - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 235, 0f, 0f, 100, default, 1f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int redderDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 235, 0f, 0f, 100, default, 1f); + Main.dust[redderDust].noGravity = true; + Main.dust[redderDust].velocity *= 0.5f; + Main.dust[redderDust].velocity += Projectile.velocity * 0.1f; } public override Color? GetAlpha(Color lightColor) @@ -61,19 +61,19 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item10, Projectile.position); - int num3; - for (int num795 = 4; num795 < 31; num795 = num3 + 1) + int inc; + for (int i = 4; i < 31; i = inc + 1) { - float num796 = Projectile.oldVelocity.X * (30f / (float)num795); - float num797 = Projectile.oldVelocity.Y * (30f / (float)num795); - int num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, 235, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); - Main.dust[num798].noGravity = true; - Dust dust = Main.dust[num798]; + float dustX = Projectile.oldVelocity.X * (30f / (float)i); + float dustY = Projectile.oldVelocity.Y * (30f / (float)i); + int deathDust = Dust.NewDust(new Vector2(Projectile.oldPosition.X - dustX, Projectile.oldPosition.Y - dustY), 8, 8, 235, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); + Main.dust[deathDust].noGravity = true; + Dust dust = Main.dust[deathDust]; dust.velocity *= 0.5f; - num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, 235, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); - dust = Main.dust[num798]; + deathDust = Dust.NewDust(new Vector2(Projectile.oldPosition.X - dustX, Projectile.oldPosition.Y - dustY), 8, 8, 235, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); + dust = Main.dust[deathDust]; dust.velocity *= 0.05f; - num3 = num795; + inc = i; } } diff --git a/Projectiles/Melee/BrimlashProj.cs b/Projectiles/Melee/BrimlashProj.cs index be62d4248d..58f21983d3 100644 --- a/Projectiles/Melee/BrimlashProj.cs +++ b/Projectiles/Melee/BrimlashProj.cs @@ -41,10 +41,10 @@ namespace CalamityMod.Projectiles.Melee Projectile.Kill(); } Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.05f / 255f, (255 - Projectile.alpha) * 0.05f / 255f); - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int brimDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); + Main.dust[brimDust].noGravity = true; + Main.dust[brimDust].velocity *= 0.5f; + Main.dust[brimDust].velocity += Projectile.velocity * 0.1f; } public override Color? GetAlpha(Color lightColor) @@ -64,19 +64,19 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item10, Projectile.position); - int num3; - for (int num795 = 4; num795 < 31; num795 = num3 + 1) + int inc; + for (int i = 4; i < 31; i = inc + 1) { - float num796 = Projectile.oldVelocity.X * (30f / (float)num795); - float num797 = Projectile.oldVelocity.Y * (30f / (float)num795); - int num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, (int)CalamityDusts.Brimstone, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); - Main.dust[num798].noGravity = true; - Dust dust = Main.dust[num798]; + float dustX = Projectile.oldVelocity.X * (30f / (float)i); + float dustY = Projectile.oldVelocity.Y * (30f / (float)i); + int deathDust = Dust.NewDust(new Vector2(Projectile.oldPosition.X - dustX, Projectile.oldPosition.Y - dustY), 8, 8, (int)CalamityDusts.Brimstone, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); + Main.dust[deathDust].noGravity = true; + Dust dust = Main.dust[deathDust]; dust.velocity *= 0.5f; - num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, (int)CalamityDusts.Brimstone, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); - dust = Main.dust[num798]; + deathDust = Dust.NewDust(new Vector2(Projectile.oldPosition.X - dustX, Projectile.oldPosition.Y - dustY), 8, 8, (int)CalamityDusts.Brimstone, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); + dust = Main.dust[deathDust]; dust.velocity *= 0.05f; - num3 = num795; + inc = i; } if (Projectile.owner == Main.myPlayer) diff --git a/Projectiles/Melee/BrimstoneBoom.cs b/Projectiles/Melee/BrimstoneBoom.cs index adf103f0b4..9f40aef9c7 100644 --- a/Projectiles/Melee/BrimstoneBoom.cs +++ b/Projectiles/Melee/BrimstoneBoom.cs @@ -27,39 +27,39 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { Lighting.AddLight(Projectile.Center, 0.75f, 0f, 0f); - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while (num462 < num461) + int timerCounter = 0; + while (timerCounter < projTimer) { - float num463 = Main.rand.Next(-10, 11); - float num464 = Main.rand.Next(-10, 11); - float num465 = Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt(num463 * num463 + num464 * num464); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); - Main.dust[num467].noGravity = true; - Main.dust[num467].position.X = Projectile.Center.X; - Main.dust[num467].position.Y = Projectile.Center.Y; - Dust expr_149DF_cp_0 = Main.dust[num467]; + float rando1 = Main.rand.Next(-10, 11); + float rando2 = Main.rand.Next(-10, 11); + float rando3 = Main.rand.Next(3, 9); + float randoAdjuster = (float)Math.Sqrt(rando1 * rando1 + rando2 * rando2); + randoAdjuster = rando3 / randoAdjuster; + rando1 *= randoAdjuster; + rando2 *= randoAdjuster; + int brimDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); + Main.dust[brimDust].noGravity = true; + Main.dust[brimDust].position.X = Projectile.Center.X; + Main.dust[brimDust].position.Y = Projectile.Center.Y; + Dust expr_149DF_cp_0 = Main.dust[brimDust]; expr_149DF_cp_0.position.X += Main.rand.Next(-10, 11); - Dust expr_14A09_cp_0 = Main.dust[num467]; + Dust expr_14A09_cp_0 = Main.dust[brimDust]; expr_14A09_cp_0.position.Y += Main.rand.Next(-10, 11); - Main.dust[num467].velocity.X = num463; - Main.dust[num467].velocity.Y = num464; - num462++; + Main.dust[brimDust].velocity.X = rando1; + Main.dust[brimDust].velocity.Y = rando2; + timerCounter++; } } } diff --git a/Projectiles/Melee/BrimstoneSwordExplosion.cs b/Projectiles/Melee/BrimstoneSwordExplosion.cs index 7ea6d6dac0..4424898918 100644 --- a/Projectiles/Melee/BrimstoneSwordExplosion.cs +++ b/Projectiles/Melee/BrimstoneSwordExplosion.cs @@ -36,60 +36,60 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(SoundID.Item20, Projectile.position); Projectile.localAI[0] += 1f; } - bool flag15 = false; - bool flag16 = false; + bool xflag = false; + bool yflag = false; if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) { - flag16 = true; + yflag = true; } if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) { - flag16 = true; + yflag = true; } - if (flag15 && flag16) + if (xflag && yflag) { Projectile.Kill(); } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-10, 11); - float num464 = (float)Main.rand.Next(-10, 11); - float num465 = (float)Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); - Dust dust = Main.dust[num467]; + float rando1 = (float)Main.rand.Next(-10, 11); + float rando2 = (float)Main.rand.Next(-10, 11); + float rando3 = (float)Main.rand.Next(3, 9); + float randoAdjuster = (float)Math.Sqrt((double)(rando1 * rando1 + rando2 * rando2)); + randoAdjuster = rando3 / randoAdjuster; + rando1 *= randoAdjuster; + rando2 *= randoAdjuster; + int brimDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); + Dust dust = Main.dust[brimDust]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = rando1; + dust.velocity.Y = rando2; + timerCounter++; } } diff --git a/Projectiles/Melee/BrinySpout.cs b/Projectiles/Melee/BrinySpout.cs index 0b0e90ff4e..bd4cbec34a 100644 --- a/Projectiles/Melee/BrinySpout.cs +++ b/Projectiles/Melee/BrinySpout.cs @@ -30,11 +30,10 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - int num613 = 16; - int num614 = 16; - float num615 = 1.5f; - int num616 = 150; - int num617 = 42; + int projScale = 32; + float scaleModifier = 1.5f; + int projWidth = 150; + int projHeight = 42; if (Projectile.velocity.X != 0f) { Projectile.direction = Projectile.spriteDirection = -Math.Sign(Projectile.velocity.X); @@ -54,18 +53,18 @@ namespace CalamityMod.Projectiles.Melee Projectile.localAI[0] = 1f; Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y + (float)(Projectile.height / 2); - Projectile.scale = ((float)(num613 + num614) - Projectile.ai[1]) * num615 / (float)(num614 + num613); - Projectile.width = (int)((float)num616 * Projectile.scale); - Projectile.height = (int)((float)num617 * Projectile.scale); + Projectile.scale = ((float)(projScale) - Projectile.ai[1]) * scaleModifier / (float)(projScale); + Projectile.width = (int)((float)projWidth * Projectile.scale); + Projectile.height = (int)((float)projHeight * Projectile.scale); Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); Projectile.netUpdate = true; } if (Projectile.ai[1] != -1f) { - Projectile.scale = ((float)(num613 + num614) - Projectile.ai[1]) * num615 / (float)(num614 + num613); - Projectile.width = (int)((float)num616 * Projectile.scale); - Projectile.height = (int)((float)num617 * Projectile.scale); + Projectile.scale = ((float)(projScale) - Projectile.ai[1]) * scaleModifier / (float)(projScale); + Projectile.width = (int)((float)projWidth * Projectile.scale); + Projectile.height = (int)((float)projHeight * Projectile.scale); } if (!Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) { @@ -91,22 +90,22 @@ namespace CalamityMod.Projectiles.Melee { Projectile.netUpdate = true; Vector2 center = Projectile.Center; - center.Y -= (float)num617 * Projectile.scale / 2f; - float num618 = ((float)(num613 + num614) - Projectile.ai[1] + 1f) * num615 / (float)(num614 + num613); - center.Y -= (float)num617 * num618 / 2f; + center.Y -= (float)projHeight * Projectile.scale / 2f; + float nextSegment = ((float)(projScale) - Projectile.ai[1] + 1f) * scaleModifier / (float)(projScale); + center.Y -= (float)projHeight * nextSegment / 2f; center.Y += 2f; Projectile.NewProjectile(Projectile.GetSource_FromThis(), center.X, center.Y, Projectile.velocity.X, Projectile.velocity.Y, Projectile.type, Projectile.damage, Projectile.knockBack, Projectile.owner, 8f, Projectile.ai[1] - 1f); } if (Projectile.ai[0] <= 0f) { - float num622 = 0.104719758f; - float num623 = (float)Projectile.width / 5f; - num623 *= 2f; - float num624 = (float)(Math.Cos((double)(num622 * -(double)Projectile.ai[0])) - 0.5) * num623; - Projectile.position.X = Projectile.position.X - num624 * (float)-(float)Projectile.direction; + float swaySize = 0.104719758f; + float smolWidth = (float)Projectile.width / 5f; + smolWidth *= 2f; + float projXChange = (float)(Math.Cos((double)(swaySize * -(double)Projectile.ai[0])) - 0.5) * smolWidth; + Projectile.position.X = Projectile.position.X - projXChange * (float)-(float)Projectile.direction; Projectile.ai[0] -= 1f; - num624 = (float)(Math.Cos((double)(num622 * -(double)Projectile.ai[0])) - 0.5) * num623; - Projectile.position.X = Projectile.position.X + num624 * (float)-(float)Projectile.direction; + projXChange = (float)(Math.Cos((double)(swaySize * -(double)Projectile.ai[0])) - 0.5) * smolWidth; + Projectile.position.X = Projectile.position.X + projXChange * (float)-(float)Projectile.direction; } } @@ -118,9 +117,9 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } } diff --git a/Projectiles/Melee/BrinyTyphoonBubble.cs b/Projectiles/Melee/BrinyTyphoonBubble.cs index 35c621594a..5afc1be218 100644 --- a/Projectiles/Melee/BrinyTyphoonBubble.cs +++ b/Projectiles/Melee/BrinyTyphoonBubble.cs @@ -30,23 +30,23 @@ namespace CalamityMod.Projectiles.Melee { if (Projectile.ai[1] > 0f) { - int num625 = (int)Projectile.ai[1] - 1; - if (num625 < 255) + int playerTrack = (int)Projectile.ai[1] - 1; + if (playerTrack < 255) { Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 10f) { - int num626 = 6; - for (int num627 = 0; num627 < num626; num627++) + int dustAmt = 6; + for (int i = 0; i < dustAmt; i++) { - Vector2 vector45 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector45 = vector45.RotatedBy((double)(num627 - (num626 / 2 - 1)) * 3.1415926535897931 / (double)(float)num626, default) + Projectile.Center; - Vector2 value15 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); - int num628 = Dust.NewDust(vector45 + value15, 0, 0, 187, value15.X * 2f, value15.Y * 2f, 100, new Color(53, Main.DiscoG, 255), 1.4f); - Main.dust[num628].noGravity = true; - Main.dust[num628].noLight = true; - Main.dust[num628].velocity /= 4f; - Main.dust[num628].velocity -= Projectile.velocity; + Vector2 dustRotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + dustRotate = dustRotate.RotatedBy((double)(i - (dustAmt / 2 - 1)) * 3.1415926535897931 / (double)(float)dustAmt, default) + Projectile.Center; + Vector2 faceDirection = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + int bluishDust = Dust.NewDust(dustRotate + faceDirection, 0, 0, 187, faceDirection.X * 2f, faceDirection.Y * 2f, 100, new Color(53, Main.DiscoG, 255), 1.4f); + Main.dust[bluishDust].noGravity = true; + Main.dust[bluishDust].noLight = true; + Main.dust[bluishDust].velocity /= 4f; + Main.dust[bluishDust].velocity -= Projectile.velocity; } Projectile.alpha -= 5; if (Projectile.alpha < 100) @@ -56,11 +56,11 @@ namespace CalamityMod.Projectiles.Melee Projectile.rotation += Projectile.velocity.X * 0.1f; Projectile.frame = (int)(Projectile.localAI[0] / 3f) % 3; } - Vector2 value16 = Main.player[num625].Center - Projectile.Center; - float num629 = 4f; - num629 += Projectile.localAI[0] / 20f; - Projectile.velocity = Vector2.Normalize(value16) * num629; - if (value16.Length() < 50f) + Vector2 playerDirection = Main.player[playerTrack].Center - Projectile.Center; + float projVelocity = 4f; + projVelocity += Projectile.localAI[0] / 20f; + Projectile.velocity = Vector2.Normalize(playerDirection) * projVelocity; + if (playerDirection.Length() < 50f) { Projectile.Kill(); } @@ -68,13 +68,12 @@ namespace CalamityMod.Projectiles.Melee } else { - float num630 = 0.209439516f; - float num631 = 4f; - float num632 = (float)(Math.Cos((double)(num630 * Projectile.ai[0])) - 0.5) * num631; - Projectile.velocity.Y = Projectile.velocity.Y - num632; + float spoutSway = 0.209439516f; + float spoutSpawn = (float)(Math.Cos((double)(spoutSway * Projectile.ai[0])) - 0.5) * 4f; + Projectile.velocity.Y = Projectile.velocity.Y - spoutSpawn; Projectile.ai[0] += 1f; - num632 = (float)(Math.Cos((double)(num630 * Projectile.ai[0])) - 0.5) * num631; - Projectile.velocity.Y = Projectile.velocity.Y + num632; + spoutSpawn = (float)(Math.Cos((double)(spoutSway * Projectile.ai[0])) - 0.5) * 4f; + Projectile.velocity.Y = Projectile.velocity.Y + spoutSpawn; Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 10f) { @@ -98,49 +97,49 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item96, Projectile.Center); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int moreDustAmt = 36; + for (int j = 0; j < moreDustAmt; j++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 187, vector7.X * 2f, vector7.Y * 2f, 100, new Color(53, Main.DiscoG, 255), 1.4f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(j - (moreDustAmt / 2 - 1)) * 6.28318548f / (float)moreDustAmt), default) + Projectile.Center; + Vector2 facingDirection = rotate - Projectile.Center; + int killDust = Dust.NewDust(rotate + facingDirection, 0, 0, 187, facingDirection.X * 2f, facingDirection.Y * 2f, 100, new Color(53, Main.DiscoG, 255), 1.4f); + Main.dust[killDust].noGravity = true; + Main.dust[killDust].noLight = true; + Main.dust[killDust].velocity = facingDirection; } if (Projectile.owner == Main.myPlayer) { - int num330 = (int)(Projectile.Center.Y / 16f); - int num331 = (int)(Projectile.Center.X / 16f); - int num332 = 100; - if (num331 < 10) + int projTileX = (int)(Projectile.Center.Y / 16f); + int projTileY = (int)(Projectile.Center.X / 16f); + int posModifier = 100; + if (projTileY < 10) { - num331 = 10; + projTileY = 10; } - if (num331 > Main.maxTilesX - 10) + if (projTileY > Main.maxTilesX - 10) { - num331 = Main.maxTilesX - 10; + projTileY = Main.maxTilesX - 10; } - if (num330 < 10) + if (projTileX < 10) { - num330 = 10; + projTileX = 10; } - if (num330 > Main.maxTilesY - num332 - 10) + if (projTileX > Main.maxTilesY - posModifier - 10) { - num330 = Main.maxTilesY - num332 - 10; + projTileX = Main.maxTilesY - posModifier - 10; } - for (int num333 = num330; num333 < num330 + num332; num333++) + for (int k = projTileX; k < projTileX + posModifier; k++) { - Tile tile = Main.tile[num331, num333]; + Tile tile = Main.tile[projTileY, k]; if (tile.HasTile && (Main.tileSolid[(int)tile.TileType] || tile.LiquidAmount != 0)) { - num330 = num333; + projTileX = k; break; } } - int num335 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)(num331 * 16 + 8), (float)(num330 * 16 - 24), 0f, 0f, ModContent.ProjectileType(), Projectile.damage, 6f, Main.myPlayer, 8f, 25f); - Main.projectile[num335].netUpdate = true; + int SPOUT = Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)(projTileY * 16 + 8), (float)(projTileX * 16 - 24), 0f, 0f, ModContent.ProjectileType(), Projectile.damage, 6f, Main.myPlayer, 8f, 25f); + Main.projectile[SPOUT].netUpdate = true; } } } diff --git a/Projectiles/Melee/BrokenBiomeBlade_AridGrandeur.cs b/Projectiles/Melee/BrokenBiomeBlade_AridGrandeur.cs index 05b4d62867..babd63e22f 100644 --- a/Projectiles/Melee/BrokenBiomeBlade_AridGrandeur.cs +++ b/Projectiles/Melee/BrokenBiomeBlade_AridGrandeur.cs @@ -135,7 +135,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(direction.X); + Owner.ChangeDir(Math.Sign(direction.X)); Owner.itemRotation = direction.ToRotation(); if (Owner.direction != 1) { diff --git a/Projectiles/Melee/BrokenBiomeBlade_BitingEmbrace.cs b/Projectiles/Melee/BrokenBiomeBlade_BitingEmbrace.cs index 609ba39617..53e79d75f0 100644 --- a/Projectiles/Melee/BrokenBiomeBlade_BitingEmbrace.cs +++ b/Projectiles/Melee/BrokenBiomeBlade_BitingEmbrace.cs @@ -175,7 +175,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(rotation.ToRotationVector2().X); + Owner.ChangeDir(Math.Sign(rotation.ToRotationVector2().X)); Owner.itemRotation = rotation; if (Owner.direction != 1) { diff --git a/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort.cs b/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort.cs index fef46bcb24..1723f6e38b 100644 --- a/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort.cs +++ b/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort.cs @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(direction.X); + Owner.ChangeDir(Math.Sign(direction.X)); Owner.itemRotation = direction.ToRotation(); if (Owner.direction != 1) { diff --git a/Projectiles/Melee/BrokenBiomeBlade_GrovetendersTouch.cs b/Projectiles/Melee/BrokenBiomeBlade_GrovetendersTouch.cs index 7560a74a3e..430e73ca0a 100644 --- a/Projectiles/Melee/BrokenBiomeBlade_GrovetendersTouch.cs +++ b/Projectiles/Melee/BrokenBiomeBlade_GrovetendersTouch.cs @@ -124,7 +124,7 @@ namespace CalamityMod.Projectiles.Melee SnapCoyoteTime--; } - Owner.direction = Math.Sign(Projectile.velocity.X); + Owner.ChangeDir(Math.Sign(Projectile.velocity.X)); Projectile.rotation = Projectile.AngleFrom(Owner.Center); //Point away from playah float ratio = GetSwingRatio(); diff --git a/Projectiles/Melee/BurningMeteor.cs b/Projectiles/Melee/BurningMeteor.cs index 280ab258cb..8185479e74 100644 --- a/Projectiles/Melee/BurningMeteor.cs +++ b/Projectiles/Melee/BurningMeteor.cs @@ -54,26 +54,26 @@ namespace CalamityMod.Projectiles.Melee Projectile.localAI[0] = 0f; for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); - int num9 = Dust.NewDust(Projectile.Center, 0, 0, 244, 0f, 0f, 160, default, 1f); - Main.dust[num9].scale = 1.1f; - Main.dust[num9].noGravity = true; - Main.dust[num9].position = Projectile.Center + vector3; - Main.dust[num9].velocity = Projectile.velocity * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; + Vector2 dustRotate = Vector2.UnitX * (float)-(float)Projectile.width / 2f; + dustRotate += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); + dustRotate = dustRotate.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); + int burntDust = Dust.NewDust(Projectile.Center, 0, 0, 244, 0f, 0f, 160, default, 1f); + Main.dust[burntDust].scale = 1.1f; + Main.dust[burntDust].noGravity = true; + Main.dust[burntDust].position = Projectile.Center + dustRotate; + Main.dust[burntDust].velocity = Projectile.velocity * 0.1f; + Main.dust[burntDust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[burntDust].position) * 1.25f; } } Projectile.alpha -= 15; - int num58 = 150; + int alphaControl = 150; if (Projectile.Center.Y >= Projectile.ai[1]) { - num58 = 0; + alphaControl = 0; } - if (Projectile.alpha < num58) + if (Projectile.alpha < alphaControl) { - Projectile.alpha = num58; + Projectile.alpha = alphaControl; } Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; } diff --git a/Projectiles/Melee/ClamCrusherFlail.cs b/Projectiles/Melee/ClamCrusherFlail.cs index b44d07713f..419dc954fe 100644 --- a/Projectiles/Melee/ClamCrusherFlail.cs +++ b/Projectiles/Melee/ClamCrusherFlail.cs @@ -35,26 +35,26 @@ namespace CalamityMod.Projectiles.Melee } if (Projectile.ai[1] >= 5f && (Projectile.ai[1] <= 10f)) { - for (int num105 = 0; num105 < 10; num105++) + for (int i = 0; i < 10; i++) { - float num99 = Projectile.velocity.X / 3f * (float)num105; - float num100 = Projectile.velocity.Y / 3f * (float)num105; - int num101 = 4; - int waterDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)num101, Projectile.position.Y + (float)num101), Projectile.width - num101 * 2, Projectile.height - num101 * 2, 33, 0f, 0f, 0, new Color(0, 142, 255), 1.5f); + float shortXVel = Projectile.velocity.X / 3f * (float)i; + float shortYVel = Projectile.velocity.Y / 3f * (float)i; + int dustPos = 4; + int waterDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)dustPos, Projectile.position.Y + (float)dustPos), Projectile.width - dustPos * 2, Projectile.height - dustPos * 2, 33, 0f, 0f, 0, new Color(0, 142, 255), 1.5f); Dust waterdust = Main.dust[waterDust]; waterdust.noGravity = true; waterdust.velocity *= 0.1f; waterdust.velocity += Projectile.velocity * 0.1f; - waterdust.position.X -= num99; - waterdust.position.Y -= num100; + waterdust.position.X -= shortXVel; + waterdust.position.Y -= shortYVel; } } if (Projectile.ai[1] == 5f) { Projectile.tileCollide = true; } - Vector2 vector62 = Main.player[Projectile.owner].Center - Projectile.Center; - Projectile.rotation = vector62.ToRotation() - 1.57f; + Vector2 flailDirection = Main.player[Projectile.owner].Center - Projectile.Center; + Projectile.rotation = flailDirection.ToRotation() - 1.57f; if (Main.player[Projectile.owner].dead) { Projectile.Kill(); @@ -62,7 +62,7 @@ namespace CalamityMod.Projectiles.Melee } Main.player[Projectile.owner].itemAnimation = 10; Main.player[Projectile.owner].itemTime = 10; - if (vector62.X < 0f) + if (flailDirection.X < 0f) { Main.player[Projectile.owner].ChangeDir(1); Projectile.direction = 1; @@ -72,38 +72,38 @@ namespace CalamityMod.Projectiles.Melee Main.player[Projectile.owner].ChangeDir(-1); Projectile.direction = -1; } - Main.player[Projectile.owner].itemRotation = (vector62 * -1f * (float)Projectile.direction).ToRotation(); - Projectile.spriteDirection = (vector62.X > 0f) ? -1 : 1; + Main.player[Projectile.owner].itemRotation = (flailDirection * -1f * (float)Projectile.direction).ToRotation(); + Projectile.spriteDirection = (flailDirection.X > 0f) ? -1 : 1; if (Projectile.ai[1] >= 45f && (Projectile.ai[0] != 1f || Projectile.ai[0] != 2f)) { Projectile.velocity.Y += 1f; Projectile.velocity.X *= 0.995f; Projectile.damage = finalDamage; } - if (Projectile.ai[0] == 0f && vector62.Length() > 1000f) + if (Projectile.ai[0] == 0f && flailDirection.Length() > 1000f) { Projectile.ai[0] = 1f; } if (Projectile.ai[0] == 1f || Projectile.ai[0] == 2f) { - float num693 = vector62.Length(); - if (num693 > 1500f) + float flailDistance = flailDirection.Length(); + if (flailDistance > 1500f) { Projectile.Kill(); return; } - if (num693 > 600f) + if (flailDistance > 600f) { Projectile.ai[0] = 2f; } Projectile.tileCollide = false; - float num694 = 20f; + float flailSpeed = 20f; if (Projectile.ai[0] == 2f) { - num694 = 40f; + flailSpeed = 40f; } - Projectile.velocity = Vector2.Normalize(vector62) * num694; - if (vector62.Length() < num694) + Projectile.velocity = Vector2.Normalize(flailDirection) * flailSpeed; + if (flailDirection.Length() < flailSpeed) { Projectile.Kill(); return; @@ -124,7 +124,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.ai[0] = 1f; Projectile.netUpdate = true; SoundEngine.PlaySound(GiantClam.SlamSound, Projectile.position); - for (int num105 = 0; num105 < 50; num105++) + for (int i = 0; i < 50; i++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); int waterDust = Dust.NewDust(new Vector2(Projectile.Center.X, Projectile.Center.Y), Projectile.width / 2, Projectile.height / 2, 33, velocity.X, velocity.Y, 0, new Color(0, 142, 255), 1.5f); @@ -138,35 +138,35 @@ namespace CalamityMod.Projectiles.Melee { Vector2 mountedCenter = Main.player[Projectile.owner].MountedCenter; Texture2D texture2D2 = ModContent.Request("CalamityMod/Projectiles/Melee/ClamCrusherChain").Value; - Vector2 vector17 = Projectile.Center; + Vector2 projCenter = Projectile.Center; Rectangle? sourceRectangle = null; Vector2 origin = new Vector2((float)texture2D2.Width * 0.5f, (float)texture2D2.Height * 0.5f); - float num91 = (float)texture2D2.Height; - Vector2 vector18 = mountedCenter - vector17; - float rotation15 = (float)Math.Atan2((double)vector18.Y, (double)vector18.X) - 1.57f; - bool flag13 = true; - if (float.IsNaN(vector17.X) && float.IsNaN(vector17.Y)) + float projHeight = (float)texture2D2.Height; + Vector2 actualCenter = mountedCenter - projCenter; + float flailRotate = (float)Math.Atan2((double)actualCenter.Y, (double)actualCenter.X) - 1.57f; + bool isActive = true; + if (float.IsNaN(projCenter.X) && float.IsNaN(projCenter.Y)) { - flag13 = false; + isActive = false; } - if (float.IsNaN(vector18.X) && float.IsNaN(vector18.Y)) + if (float.IsNaN(actualCenter.X) && float.IsNaN(actualCenter.Y)) { - flag13 = false; + isActive = false; } - while (flag13) + while (isActive) { - if (vector18.Length() < num91 + 1f) + if (actualCenter.Length() < projHeight + 1f) { - flag13 = false; + isActive = false; } else { - Vector2 value2 = vector18; + Vector2 value2 = actualCenter; value2.Normalize(); - vector17 += value2 * num91; - vector18 = mountedCenter - vector17; - Color color17 = Lighting.GetColor((int)vector17.X / 16, (int)(vector17.Y / 16f)); - Main.spriteBatch.Draw(texture2D2, vector17 - Main.screenPosition, sourceRectangle, color17, rotation15, origin, 1f, SpriteEffects.None, 0); + projCenter += value2 * projHeight; + actualCenter = mountedCenter - projCenter; + Color colorArea = Lighting.GetColor((int)projCenter.X / 16, (int)(projCenter.Y / 16f)); + Main.spriteBatch.Draw(texture2D2, projCenter - Main.screenPosition, sourceRectangle, colorArea, flailRotate, origin, 1f, SpriteEffects.None, 0); } } return true; diff --git a/Projectiles/Melee/CometQuasherMeteor.cs b/Projectiles/Melee/CometQuasherMeteor.cs index 4f26b4e4e6..cbdc26cee8 100644 --- a/Projectiles/Melee/CometQuasherMeteor.cs +++ b/Projectiles/Melee/CometQuasherMeteor.cs @@ -43,25 +43,25 @@ namespace CalamityMod.Projectiles.Melee { SoundEngine.PlaySound(SoundID.Item89, Projectile.position); Projectile.ExpandHitboxBy((int)(128f * Projectile.scale)); - for (int index = 0; index < 8; ++index) + for (int i = 0; i < 8; ++i) Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 31, 0.0f, 0.0f, 100, new Color(), 1.5f); - for (int index1 = 0; index1 < 32; ++index1) + for (int j = 0; j < 32; ++j) { - int index2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0.0f, 0.0f, 100, new Color(), 2.5f); - Dust dust1 = Main.dust[index2]; + int fieryDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0.0f, 0.0f, 100, new Color(), 2.5f); + Dust dust1 = Main.dust[fieryDust]; dust1.noGravity = true; dust1.velocity *= 3f; - int index3 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0.0f, 0.0f, 100, new Color(), 1.5f); - Dust dust2 = Main.dust[index3]; + int fieryDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0.0f, 0.0f, 100, new Color(), 1.5f); + Dust dust2 = Main.dust[fieryDust2]; dust2.velocity *= 2f; dust2.noGravity = true; } if (Main.netMode != NetmodeID.Server) { - for (int index1 = 0; index1 < 2; ++index1) + for (int j = 0; j < 2; ++j) { - int index2 = Gore.NewGore(Projectile.GetSource_Death(), Projectile.position + new Vector2((float)(Projectile.width * Main.rand.Next(100)) / 100f, (float)(Projectile.height * Main.rand.Next(100)) / 100f) - Vector2.One * 10f, new Vector2(), Main.rand.Next(61, 64), 1f); - Gore gore = Main.gore[index2]; + int fieryDust = Gore.NewGore(Projectile.GetSource_Death(), Projectile.position + new Vector2((float)(Projectile.width * Main.rand.Next(100)) / 100f, (float)(Projectile.height * Main.rand.Next(100)) / 100f) - Vector2.One * 10f, new Vector2(), Main.rand.Next(61, 64), 1f); + Gore gore = Main.gore[fieryDust]; gore.velocity *= 0.3f; gore.velocity.X += (float)Main.rand.Next(-10, 11) * 0.05f; gore.velocity.Y += (float)Main.rand.Next(-10, 11) * 0.05f; @@ -75,10 +75,10 @@ namespace CalamityMod.Projectiles.Melee Projectile.maxPenetrate = 0; Projectile.Damage(); } - for (int index1 = 0; index1 < 5; ++index1) + for (int j = 0; j < 5; ++j) { - int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, Utils.SelectRandom(Main.rand, new int[3]{ 6, 259, 158 }), 2.5f * (float) Projectile.direction, -2.5f, 0, new Color(), 1f); - Dust dust1 = Main.dust[index2]; + int fieryDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, Utils.SelectRandom(Main.rand, new int[3]{ 6, 259, 158 }), 2.5f * (float) Projectile.direction, -2.5f, 0, new Color(), 1f); + Dust dust1 = Main.dust[fieryDust]; dust1.alpha = 200; dust1.velocity *= 2.4f; dust1.scale += Main.rand.NextFloat(); diff --git a/Projectiles/Melee/CosmicDischargeFlail.cs b/Projectiles/Melee/CosmicDischargeFlail.cs index bdb194086a..cbb4681399 100644 --- a/Projectiles/Melee/CosmicDischargeFlail.cs +++ b/Projectiles/Melee/CosmicDischargeFlail.cs @@ -89,8 +89,8 @@ namespace CalamityMod.Projectiles.Melee { return true; } - float num8 = 0f; - if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center + Projectile.velocity, 16f * Projectile.scale, ref num8)) + float zero = 0f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center + Projectile.velocity, 16f * Projectile.scale, ref zero)) { return true; } diff --git a/Projectiles/Melee/CosmicIceBurst.cs b/Projectiles/Melee/CosmicIceBurst.cs index 81e7e4e20c..5de6f01074 100644 --- a/Projectiles/Melee/CosmicIceBurst.cs +++ b/Projectiles/Melee/CosmicIceBurst.cs @@ -63,36 +63,36 @@ namespace CalamityMod.Projectiles.Melee Projectile.Center = Projectile.position; Projectile.Damage(); SoundEngine.PlaySound(SoundID.Item62, Projectile.position); - for (int num1000 = 0; num1000 < 2; num1000++) + for (int i = 0; i < 2; i++) { - int num1001 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 187, 0f, 0f, 100, new Color(150, 255, 255), 1f); - Main.dust[num1001].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + int cosmicDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 187, 0f, 0f, 100, new Color(150, 255, 255), 1f); + Main.dust[cosmicDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; } - for (int num1002 = 0; num1002 < 3; num1002++) + for (int j = 0; j < 3; j++) { - int num1003 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 200, new Color(150, 255, 255), 1f); - Main.dust[num1003].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; - Main.dust[num1003].noGravity = true; - Main.dust[num1003].velocity *= 3f; - num1003 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 100, new Color(150, 255, 255), 0.6f); - Main.dust[num1003].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; - Main.dust[num1003].velocity *= 2f; - Main.dust[num1003].noGravity = true; - Main.dust[num1003].fadeIn = 2.5f; + int iceDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 200, new Color(150, 255, 255), 1f); + Main.dust[iceDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + Main.dust[iceDust].noGravity = true; + Main.dust[iceDust].velocity *= 3f; + iceDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 100, new Color(150, 255, 255), 0.6f); + Main.dust[iceDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + Main.dust[iceDust].velocity *= 2f; + Main.dust[iceDust].noGravity = true; + Main.dust[iceDust].fadeIn = 2.5f; } - for (int num1004 = 0; num1004 < 2; num1004++) + for (int k = 0; k < 2; k++) { - int num1005 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 0, new Color(150, 255, 255), 1f); - Main.dust[num1005].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 2f; - Main.dust[num1005].noGravity = true; - Main.dust[num1005].velocity *= 3f; + int icyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 0, new Color(150, 255, 255), 1f); + Main.dust[icyDust].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 2f; + Main.dust[icyDust].noGravity = true; + Main.dust[icyDust].velocity *= 3f; } - for (int num1006 = 0; num1006 < 3; num1006++) + for (int l = 0; l < 3; l++) { - int num1007 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 187, 0f, 0f, 0, new Color(150, 255, 255), 0.6f); - Main.dust[num1007].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 2f; - Main.dust[num1007].noGravity = true; - Main.dust[num1007].velocity *= 3f; + int freezeDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 187, 0f, 0f, 0, new Color(150, 255, 255), 0.6f); + Main.dust[freezeDust].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 2f; + Main.dust[freezeDust].noGravity = true; + Main.dust[freezeDust].velocity *= 3f; } } } @@ -100,16 +100,13 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { Vector2 mountedCenter = Main.player[Projectile.owner].MountedCenter; - Color color25 = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); + Color colorArea = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); if (Projectile.hide && !ProjectileID.Sets.DontAttachHideToAlpha[Projectile.type]) { - color25 = Lighting.GetColor((int)mountedCenter.X / 16, (int)(mountedCenter.Y / 16f)); + colorArea = Lighting.GetColor((int)mountedCenter.X / 16, (int)(mountedCenter.Y / 16f)); } - Vector2 vector42 = Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; Texture2D texture2D33 = ModContent.Request(Texture).Value; - Rectangle rectangle15 = texture2D33.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); - Color alpha5 = Projectile.GetAlpha(color25); - Vector2 origin11 = rectangle15.Size() / 2f; + Rectangle rectangl = texture2D33.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); return true; } diff --git a/Projectiles/Melee/CosmicOrb.cs b/Projectiles/Melee/CosmicOrb.cs index 27dc0ee463..d26d6aaea9 100644 --- a/Projectiles/Melee/CosmicOrb.cs +++ b/Projectiles/Melee/CosmicOrb.cs @@ -57,11 +57,11 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(SoundID.Item54, Projectile.position); for (int i = 0; i < 10; i++) { - int num192 = (int)(10f * Projectile.scale); - int d = Dust.NewDust(Projectile.Center - Vector2.One * (float)num192, num192 * 2, num192 * 2, 242, 0f, 0f, 0, default, 1f); + int dustScale = (int)(10f * Projectile.scale); + int d = Dust.NewDust(Projectile.Center - Vector2.One * (float)dustScale, dustScale * 2, dustScale * 2, 242, 0f, 0f, 0, default, 1f); Dust dust = Main.dust[d]; Vector2 offset = Vector2.Normalize(dust.position - Projectile.Center); - dust.position = Projectile.Center + offset * (float)num192 * Projectile.scale; + dust.position = Projectile.Center + offset * (float)dustScale * Projectile.scale; if (i < 30) { dust.velocity = offset * dust.velocity.Length(); diff --git a/Projectiles/Melee/CosmicShivBlade.cs b/Projectiles/Melee/CosmicShivBlade.cs index 64bd722528..092bf4affe 100644 --- a/Projectiles/Melee/CosmicShivBlade.cs +++ b/Projectiles/Melee/CosmicShivBlade.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.tileCollide = false; Projectile.timeLeft = 290; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 5; + Projectile.localNPCHitCooldown = 7; } public override void AI() { diff --git a/Projectiles/Melee/CosmicSpiritBomb1.cs b/Projectiles/Melee/CosmicSpiritBomb1.cs index 8fc061771a..74e36e75d3 100644 --- a/Projectiles/Melee/CosmicSpiritBomb1.cs +++ b/Projectiles/Melee/CosmicSpiritBomb1.cs @@ -23,47 +23,47 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - float num395 = (float)Main.mouseTextColor / 200f - 0.35f; - num395 *= 0.2f; - Projectile.scale = num395 + 0.95f; + float scaleModd = (float)Main.mouseTextColor / 200f - 0.35f; + scaleModd *= 0.2f; + Projectile.scale = scaleModd + 0.95f; - float num947 = (Projectile.Center - Main.player[Projectile.owner].Center).Length() / 100f; - if (num947 <= 2f) + float projDistance = (Projectile.Center - Main.player[Projectile.owner].Center).Length() / 100f; + if (projDistance <= 2f) { - num947 = 1f; + projDistance = 1f; } else { - if (num947 > 8f) + if (projDistance > 8f) { - num947 = 12f; + projDistance = 12f; } - else if (num947 > 6f) + else if (projDistance > 6f) { - num947 = 9f; + projDistance = 9f; } - else if (num947 > 5f) + else if (projDistance > 5f) { - num947 = 7f; + projDistance = 7f; } - else if (num947 > 4f) + else if (projDistance > 4f) { - num947 = 5f; + projDistance = 5f; } - else if (num947 > 3f) + else if (projDistance > 3f) { - num947 = 4f; + projDistance = 4f; } - else if (num947 > 2.5f) + else if (projDistance > 2.5f) { - num947 = 3f; + projDistance = 3f; } else { - num947 = 2f; + projDistance = 2f; } } - Projectile.velocity = Vector2.Normalize(Main.player[Projectile.owner].Center - Projectile.Center) * num947; + Projectile.velocity = Vector2.Normalize(Main.player[Projectile.owner].Center - Projectile.Center) * projDistance; Projectile.rotation += (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y)) * 0.01f * (float)Projectile.direction; } diff --git a/Projectiles/Melee/CosmicSpiritBomb2.cs b/Projectiles/Melee/CosmicSpiritBomb2.cs index a363109413..0635b3f57b 100644 --- a/Projectiles/Melee/CosmicSpiritBomb2.cs +++ b/Projectiles/Melee/CosmicSpiritBomb2.cs @@ -23,47 +23,47 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - float num395 = (float)Main.mouseTextColor / 200f - 0.35f; - num395 *= 0.2f; - Projectile.scale = num395 + 0.95f; + float scaleModd = (float)Main.mouseTextColor / 200f - 0.35f; + scaleModd *= 0.2f; + Projectile.scale = scaleModd + 0.95f; - float num947 = (Projectile.Center - Main.player[Projectile.owner].Center).Length() / 100f; - if (num947 <= 2f) + float projDistance = (Projectile.Center - Main.player[Projectile.owner].Center).Length() / 100f; + if (projDistance <= 2f) { - num947 = 1f; + projDistance = 1f; } else { - if (num947 > 8f) + if (projDistance > 8f) { - num947 = 12f; + projDistance = 12f; } - else if (num947 > 6f) + else if (projDistance > 6f) { - num947 = 9f; + projDistance = 9f; } - else if (num947 > 5f) + else if (projDistance > 5f) { - num947 = 7f; + projDistance = 7f; } - else if (num947 > 4f) + else if (projDistance > 4f) { - num947 = 5f; + projDistance = 5f; } - else if (num947 > 3f) + else if (projDistance > 3f) { - num947 = 4f; + projDistance = 4f; } - else if (num947 > 2.5f) + else if (projDistance > 2.5f) { - num947 = 3f; + projDistance = 3f; } else { - num947 = 2f; + projDistance = 2f; } } - Projectile.velocity = Vector2.Normalize(Main.player[Projectile.owner].Center - Projectile.Center) * num947; + Projectile.velocity = Vector2.Normalize(Main.player[Projectile.owner].Center - Projectile.Center) * projDistance; Projectile.rotation += (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y)) * 0.01f * (float)Projectile.direction; } diff --git a/Projectiles/Melee/CosmicSpiritBomb3.cs b/Projectiles/Melee/CosmicSpiritBomb3.cs index bb97d276a2..f267b25d63 100644 --- a/Projectiles/Melee/CosmicSpiritBomb3.cs +++ b/Projectiles/Melee/CosmicSpiritBomb3.cs @@ -23,47 +23,47 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - float num395 = (float)Main.mouseTextColor / 200f - 0.35f; - num395 *= 0.2f; - Projectile.scale = num395 + 0.95f; + float scaleModd = (float)Main.mouseTextColor / 200f - 0.35f; + scaleModd *= 0.2f; + Projectile.scale = scaleModd + 0.95f; - float num947 = (Projectile.Center - Main.player[Projectile.owner].Center).Length() / 100f; - if (num947 <= 2f) + float projDistance = (Projectile.Center - Main.player[Projectile.owner].Center).Length() / 100f; + if (projDistance <= 2f) { - num947 = 1f; + projDistance = 1f; } else { - if (num947 > 8f) + if (projDistance > 8f) { - num947 = 12f; + projDistance = 12f; } - else if (num947 > 6f) + else if (projDistance > 6f) { - num947 = 9f; + projDistance = 9f; } - else if (num947 > 5f) + else if (projDistance > 5f) { - num947 = 7f; + projDistance = 7f; } - else if (num947 > 4f) + else if (projDistance > 4f) { - num947 = 5f; + projDistance = 5f; } - else if (num947 > 3f) + else if (projDistance > 3f) { - num947 = 4f; + projDistance = 4f; } - else if (num947 > 2.5f) + else if (projDistance > 2.5f) { - num947 = 3f; + projDistance = 3f; } else { - num947 = 2f; + projDistance = 2f; } } - Projectile.velocity = Vector2.Normalize(Main.player[Projectile.owner].Center - Projectile.Center) * num947; + Projectile.velocity = Vector2.Normalize(Main.player[Projectile.owner].Center - Projectile.Center) * projDistance; Projectile.rotation += (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y)) * 0.01f * (float)Projectile.direction; } diff --git a/Projectiles/Melee/CrystylCrusherRay.cs b/Projectiles/Melee/CrystylCrusherRay.cs index 8c2f6ecd47..faedfd0d5f 100644 --- a/Projectiles/Melee/CrystylCrusherRay.cs +++ b/Projectiles/Melee/CrystylCrusherRay.cs @@ -242,44 +242,44 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.owner == Main.myPlayer) { Vector2 destroyVector = Projectile.Center + Projectile.velocity * (Distance - MOVE_DISTANCE); - int num814 = 3; - int num815 = (int)(destroyVector.X / 16f - num814); - int num816 = (int)(destroyVector.X / 16f + num814); - int num817 = (int)(destroyVector.Y / 16f - num814); - int num818 = (int)(destroyVector.Y / 16f + num814); - if (num815 < 0) + int threeMod = 3; + int mineXLeft = (int)(destroyVector.X / 16f - threeMod); + int mineXRight = (int)(destroyVector.X / 16f + threeMod); + int mineXUp = (int)(destroyVector.Y / 16f - threeMod); + int mineXDown = (int)(destroyVector.Y / 16f + threeMod); + if (mineXLeft < 0) { - num815 = 0; + mineXLeft = 0; } - if (num816 > Main.maxTilesX) + if (mineXRight > Main.maxTilesX) { - num816 = Main.maxTilesX; + mineXRight = Main.maxTilesX; } - if (num817 < 0) + if (mineXUp < 0) { - num817 = 0; + mineXUp = 0; } - if (num818 > Main.maxTilesY) + if (mineXDown > Main.maxTilesY) { - num818 = Main.maxTilesY; + mineXDown = Main.maxTilesY; } AchievementsHelper.CurrentlyMining = true; - for (int num824 = num815; num824 <= num816; num824++) + for (int i = mineXLeft; i <= mineXRight; i++) { - for (int num825 = num817; num825 <= num818; num825++) + for (int j = mineXUp; j <= mineXDown; j++) { - float num826 = Math.Abs(num824 - destroyVector.X / 16f); - float num827 = Math.Abs(num825 - destroyVector.Y / 16f); - double num828 = Math.Sqrt(num826 * num826 + num827 * num827); - if (num828 < num814) + float destroyTileX = Math.Abs(i - destroyVector.X / 16f); + float destroyTileY = Math.Abs(j - destroyVector.Y / 16f); + double destroyTileArea = Math.Sqrt(destroyTileX * destroyTileX + destroyTileY * destroyTileY); + if (destroyTileArea < threeMod) { - if (Main.tile[num824, num825] != null && Main.tile[num824, num825].HasTile) + if (Main.tile[i, j] != null && Main.tile[i, j].HasTile) { - WorldGen.KillTile(num824, num825, false, false, false); + WorldGen.KillTile(i, j, false, false, false); DustExplosion(destroyVector); - if (!Main.tile[num824, num825].HasTile && Main.netMode != NetmodeID.SinglePlayer) + if (!Main.tile[i, j].HasTile && Main.netMode != NetmodeID.SinglePlayer) { - NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, num824, num825, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, i, j, 0f, 0, 0, 0); } } } @@ -291,8 +291,8 @@ namespace CalamityMod.Projectiles.Melee private void DustExplosion(Vector2 vector) { - int num226 = 12; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 12; + for (int k = 0; k < dustAmt; k++) { int dustType = Main.rand.Next(3); switch (dustType) @@ -309,13 +309,13 @@ namespace CalamityMod.Projectiles.Melee default: break; } - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2(Projectile.width / 2f, Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((num227 - (num226 / 2 - 1)) * MathHelper.TwoPi / num226, default) + vector; - Vector2 vector7 = vector6 - vector; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, dustType, vector7.X * 0.5f, vector7.Y * 0.5f, 100, new Color(Main.DiscoR, 0, 255), 1f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2(Projectile.width / 2f, Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((k - (dustAmt / 2 - 1)) * MathHelper.TwoPi / dustAmt, default) + vector; + Vector2 faceDirection = rotate - vector; + int explosionDust = Dust.NewDust(rotate + faceDirection, 0, 0, dustType, faceDirection.X * 0.5f, faceDirection.Y * 0.5f, 100, new Color(Main.DiscoR, 0, 255), 1f); + Main.dust[explosionDust].noGravity = true; + Main.dust[explosionDust].noLight = true; + Main.dust[explosionDust].velocity = faceDirection; } } } diff --git a/Projectiles/Melee/Cyclone.cs b/Projectiles/Melee/Cyclone.cs index d4b5f8df47..155fe2442c 100644 --- a/Projectiles/Melee/Cyclone.cs +++ b/Projectiles/Melee/Cyclone.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.penetrate = 2; Projectile.ignoreWater = true; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 30; + Projectile.localNPCHitCooldown = -1; Projectile.tileCollide = false; } @@ -63,20 +63,19 @@ namespace CalamityMod.Projectiles.Melee Projectile.ai[1] = 0; } } - float num472 = Projectile.Center.X; - float num473 = Projectile.Center.Y; - float num474 = 600f; - for (int num475 = 0; num475 < Main.maxNPCs; num475++) + float projX = Projectile.Center.X; + float projY = Projectile.Center.Y; + for (int i = 0; i < Main.maxNPCs; i++) { - NPC npc = Main.npc[num475]; + NPC npc = Main.npc[i]; 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 num478 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcCenterX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcCenterY); - if (num478 < num474) + 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) { - if (npc.position.X < num472) + if (npc.position.X < projX) { npc.velocity.X += 0.05f; } @@ -84,7 +83,7 @@ namespace CalamityMod.Projectiles.Melee { npc.velocity.X -= 0.05f; } - if (npc.position.Y < num473) + if (npc.position.Y < projY) { npc.velocity.Y += 0.05f; } diff --git a/Projectiles/Melee/DarkBall.cs b/Projectiles/Melee/DarkBall.cs index 150a81ced4..1888333251 100644 --- a/Projectiles/Melee/DarkBall.cs +++ b/Projectiles/Melee/DarkBall.cs @@ -26,36 +26,36 @@ namespace CalamityMod.Projectiles.Melee { try { - int num223 = (int)(Projectile.position.X / 16f) - 1; - int num224 = (int)((Projectile.position.X + (float)Projectile.width) / 16f) + 2; - int num225 = (int)(Projectile.position.Y / 16f) - 1; - int num226 = (int)((Projectile.position.Y + (float)Projectile.height) / 16f) + 2; - if (num223 < 0) + int tileXMin = (int)(Projectile.position.X / 16f) - 1; + int tileXMax = (int)((Projectile.position.X + (float)Projectile.width) / 16f) + 2; + int tileYMin = (int)(Projectile.position.Y / 16f) - 1; + int tileYMax = (int)((Projectile.position.Y + (float)Projectile.height) / 16f) + 2; + if (tileXMin < 0) { - num223 = 0; + tileXMin = 0; } - if (num224 > Main.maxTilesX) + if (tileXMax > Main.maxTilesX) { - num224 = Main.maxTilesX; + tileXMax = Main.maxTilesX; } - if (num225 < 0) + if (tileYMin < 0) { - num225 = 0; + tileYMin = 0; } - if (num226 > Main.maxTilesY) + if (tileYMax > Main.maxTilesY) { - num226 = Main.maxTilesY; + tileYMax = Main.maxTilesY; } - for (int num227 = num223; num227 < num224; num227++) + for (int i = tileXMin; i < tileXMax; i++) { - for (int num228 = num225; num228 < num226; num228++) + for (int j = tileYMin; j < tileYMax; j++) { - if (Main.tile[num227, num228] != null && Main.tile[num227, num228].HasUnactuatedTile && (Main.tileSolid[(int)Main.tile[num227, num228].TileType] || (Main.tileSolidTop[(int)Main.tile[num227, num228].TileType] && Main.tile[num227, num228].TileFrameY == 0))) + if (Main.tile[i, j] != null && Main.tile[i, j].HasUnactuatedTile && (Main.tileSolid[(int)Main.tile[i, j].TileType] || (Main.tileSolidTop[(int)Main.tile[i, j].TileType] && Main.tile[i, j].TileFrameY == 0))) { - Vector2 vector19; - vector19.X = (float)(num227 * 16); - vector19.Y = (float)(num228 * 16); - if (Projectile.position.X + (float)Projectile.width - 4f > vector19.X && Projectile.position.X + 4f < vector19.X + 16f && Projectile.position.Y + (float)Projectile.height - 4f > vector19.Y && Projectile.position.Y + 4f < vector19.Y + 16f) + Vector2 projPos; + projPos.X = (float)(i * 16); + projPos.Y = (float)(j * 16); + if (Projectile.position.X + (float)Projectile.width - 4f > projPos.X && Projectile.position.X + 4f < projPos.X + 16f && Projectile.position.Y + (float)Projectile.height - 4f > projPos.Y && Projectile.position.Y + 4f < projPos.Y + 16f) { Projectile.velocity.X = 0f; Projectile.velocity.Y = -0.2f; @@ -106,18 +106,18 @@ namespace CalamityMod.Projectiles.Melee Projectile.height = 22; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num648 = 0; num648 < 20; num648++) + for (int i = 0; i < 20; i++) { - int num649 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 14, 0f, 0f, 100, default, 1.5f); - Main.dust[num649].velocity *= 1.4f; + int corruptDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 14, 0f, 0f, 100, default, 1.5f); + Main.dust[corruptDust].velocity *= 1.4f; } - for (int num650 = 0; num650 < 10; num650++) + for (int j = 0; j < 10; j++) { - int num651 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 14, 0f, 0f, 100, default, 2.5f); - Main.dust[num651].noGravity = true; - Main.dust[num651].velocity *= 5f; - num651 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 14, 0f, 0f, 100, default, 1.5f); - Main.dust[num651].velocity *= 3f; + int corruptDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 14, 0f, 0f, 100, default, 2.5f); + Main.dust[corruptDust2].noGravity = true; + Main.dust[corruptDust2].velocity *= 5f; + corruptDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 14, 0f, 0f, 100, default, 1.5f); + Main.dust[corruptDust2].velocity *= 3f; } } diff --git a/Projectiles/Melee/DarkBeam.cs b/Projectiles/Melee/DarkBeam.cs index ad3dc3be76..05b88ae4cd 100644 --- a/Projectiles/Melee/DarkBeam.cs +++ b/Projectiles/Melee/DarkBeam.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -53,16 +53,16 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(BuffID.Frostburn, 180); + target.AddBuff(BuffID.Frostburn2, 180); } public override void OnKill(int timeLeft) { - for (int num105 = 0; num105 < 20; num105++) + for (int i = 0; i < 20; i++) { - int num102 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 56, 0f, 0f, 0, default, 1f); - Main.dust[num102].noGravity = true; - Main.dust[num102].velocity += Projectile.velocity * 0.1f; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 56, 0f, 0f, 0, default, 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity += Projectile.velocity * 0.1f; } if (Projectile.owner == Main.myPlayer) { diff --git a/Projectiles/Melee/DarkIceZero.cs b/Projectiles/Melee/DarkIceZero.cs index d62ad17a67..8ac81e90c0 100644 --- a/Projectiles/Melee/DarkIceZero.cs +++ b/Projectiles/Melee/DarkIceZero.cs @@ -43,8 +43,8 @@ namespace CalamityMod.Projectiles.Melee } //make pretty dust - int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 172, Projectile.velocity.X, Projectile.velocity.Y, 0, default, 1.25f); - Main.dust[index2].noGravity = true; + int dustSpawns = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 172, Projectile.velocity.X, Projectile.velocity.Y, 0, default, 1.25f); + Main.dust[dustSpawns].noGravity = true; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) @@ -75,15 +75,15 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(SoundID.Item27, Projectile.Center); for (int i = 0; i < 30; i++) { - int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 172, 0f, 0f, 0, default, Main.rand.NextFloat(1f, 2f)); - Main.dust[index2].noGravity = true; - Main.dust[index2].velocity *= 4f; + int dustSpawns = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 172, 0f, 0f, 0, default, Main.rand.NextFloat(1f, 2f)); + Main.dust[dustSpawns].noGravity = true; + Main.dust[dustSpawns].velocity *= 4f; } - for (int index1 = 0; index1 < 20; ++index1) + for (int j = 0; j < 20; ++j) { - int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 68, 0f, 0f, 0, new Color(), 1.3f); - Main.dust[index2].noGravity = true; - Main.dust[index2].velocity *= 1.5f; + int dustSpawns = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 68, 0f, 0f, 0, new Color(), 1.3f); + Main.dust[dustSpawns].noGravity = true; + Main.dust[dustSpawns].velocity *= 1.5f; } } } diff --git a/Projectiles/Melee/DepthOrb.cs b/Projectiles/Melee/DepthOrb.cs index 79dbe135c0..d76bc5f02c 100644 --- a/Projectiles/Melee/DepthOrb.cs +++ b/Projectiles/Melee/DepthOrb.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -20,21 +20,22 @@ namespace CalamityMod.Projectiles.Melee Projectile.DamageType = DamageClass.Melee; Projectile.ignoreWater = true; Projectile.penetrate = 1; - Projectile.timeLeft = 30; + Projectile.extraUpdates = 1; + Projectile.timeLeft = 75; } public override void AI() { Lighting.AddLight(Projectile.Center, 0f, 0f, 0.5f); - int num458 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 0.6f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int waterDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 0.6f); + Main.dust[waterDust].noGravity = true; + Main.dust[waterDust].velocity *= 0.5f; + Main.dust[waterDust].velocity += Projectile.velocity * 0.1f; } public override bool PreDraw(ref Color lightColor) { - if (Projectile.timeLeft > 25) + if (Projectile.timeLeft > 70) return false; Texture2D tex = ModContent.Request(Texture).Value; @@ -55,22 +56,22 @@ namespace CalamityMod.Projectiles.Melee Projectile.Center = Projectile.position; for (int dustIndex = 0; dustIndex < 30; dustIndex++) { - float num463 = (float)Main.rand.Next(-10, 11); - float num464 = (float)Main.rand.Next(-10, 11); - float num465 = (float)Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 1.2f); - Dust dust = Main.dust[num467]; + float rando1 = (float)Main.rand.Next(-10, 11); + float rando2 = (float)Main.rand.Next(-10, 11); + float rando3 = (float)Main.rand.Next(3, 9); + float randoAdjust = (float)Math.Sqrt((double)(rando1 * rando1 + rando2 * rando2)); + randoAdjust = rando3 / randoAdjust; + rando1 *= randoAdjust; + rando2 *= randoAdjust; + int killWaterDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 1.2f); + Dust dust = Main.dust[killWaterDust]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; + dust.velocity.X = rando1; + dust.velocity.Y = rando2; } Projectile.maxPenetrate = -1; Projectile.penetrate = -1; diff --git a/Projectiles/Melee/DepthOrb2.cs b/Projectiles/Melee/DepthOrb2.cs index dd4bbe8eb3..d1d2ad2813 100644 --- a/Projectiles/Melee/DepthOrb2.cs +++ b/Projectiles/Melee/DepthOrb2.cs @@ -30,10 +30,10 @@ namespace CalamityMod.Projectiles.Melee { Lighting.AddLight(Projectile.Center, 0f, 0f, 0.5f); - int num458 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 0.4f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int waterDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 0.4f); + Main.dust[waterDust].noGravity = true; + Main.dust[waterDust].velocity *= 0.5f; + Main.dust[waterDust].velocity += Projectile.velocity * 0.1f; CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, 12f, 20f); } @@ -62,22 +62,22 @@ namespace CalamityMod.Projectiles.Melee Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); for (int dustIndex = 0; dustIndex <= 30; dustIndex++) { - float num463 = (float)Main.rand.Next(-10, 11); - float num464 = (float)Main.rand.Next(-10, 11); - float num465 = (float)Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 1.2f); - Dust dust = Main.dust[num467]; + float rando1 = (float)Main.rand.Next(-10, 11); + float rando2 = (float)Main.rand.Next(-10, 11); + float rando3 = (float)Main.rand.Next(3, 9); + float randoAdjust = (float)Math.Sqrt((double)(rando1 * rando1 + rando2 * rando2)); + randoAdjust = rando3 / randoAdjust; + rando1 *= randoAdjust; + rando2 *= randoAdjust; + int killWaterDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 1.2f); + Dust dust = Main.dust[killWaterDust]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; + dust.velocity.X = rando1; + dust.velocity.Y = rando2; } Projectile.maxPenetrate = -1; Projectile.penetrate = -1; diff --git a/Projectiles/Melee/DevilsSunriseCyclone.cs b/Projectiles/Melee/DevilsSunriseCyclone.cs index 6f85a670ca..8a418a3c09 100644 --- a/Projectiles/Melee/DevilsSunriseCyclone.cs +++ b/Projectiles/Melee/DevilsSunriseCyclone.cs @@ -57,9 +57,9 @@ namespace CalamityMod.Projectiles.Melee Main.dust[dust].velocity *= 0.3f; Main.dust[dust].noGravity = true; - Vector2 vector2 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float x = Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2) - vector2.X; - float y = Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2) - vector2.Y; + Vector2 projDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float x = Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2) - projDirection.X; + float y = Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2) - projDirection.Y; float distanceFromOwner = (float)Math.Sqrt((double)(x * x + y * y)); float speed = 25f; @@ -104,8 +104,8 @@ namespace CalamityMod.Projectiles.Melee if (Main.myPlayer == Projectile.owner) { Rectangle rectangle = new Rectangle((int)Projectile.position.X, (int)Projectile.position.Y, Projectile.width, Projectile.height); - Rectangle value2 = new Rectangle((int)Main.player[Projectile.owner].position.X, (int)Main.player[Projectile.owner].position.Y, Main.player[Projectile.owner].width, Main.player[Projectile.owner].height); - if (rectangle.Intersects(value2)) + Rectangle playerPos = new Rectangle((int)Main.player[Projectile.owner].position.X, (int)Main.player[Projectile.owner].position.Y, Main.player[Projectile.owner].width, Main.player[Projectile.owner].height); + if (rectangle.Intersects(playerPos)) Projectile.Kill(); } } @@ -113,72 +113,72 @@ namespace CalamityMod.Projectiles.Melee { if (Main.player[Projectile.owner].channel) { - Vector2 vector10 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num116 = (float)Main.mouseX + Main.screenPosition.X - vector10.X; - float num117 = (float)Main.mouseY + Main.screenPosition.Y - vector10.Y; + Vector2 projTravel = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float mouseDestX = (float)Main.mouseX + Main.screenPosition.X - projTravel.X; + float mouseDestY = (float)Main.mouseY + Main.screenPosition.Y - projTravel.Y; if (Main.player[Projectile.owner].gravDir == -1f) - num117 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector10.Y; + mouseDestY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - projTravel.Y; if (Projectile.ai[0] < 0f) Projectile.ai[0] += 1f; - float num118 = (float)Math.Sqrt((double)(num116 * num116 + num117 * num117)); - num118 = (float)Math.Sqrt((double)(num116 * num116 + num117 * num117)); - if (num118 > speed) + float mouseDistance = (float)Math.Sqrt((double)(mouseDestX * mouseDestX + mouseDestY * mouseDestY)); + mouseDistance = (float)Math.Sqrt((double)(mouseDestX * mouseDestX + mouseDestY * mouseDestY)); + if (mouseDistance > speed) { - num118 = speed / num118; - num116 *= num118; - num117 *= num118; - int num119 = (int)(num116 * 1000f); - int num120 = (int)(Projectile.velocity.X * 1000f); - int num121 = (int)(num117 * 1000f); - int num122 = (int)(Projectile.velocity.Y * 1000f); + mouseDistance = speed / mouseDistance; + mouseDestX *= mouseDistance; + mouseDestY *= mouseDistance; + int projMouseSpeedX = (int)(mouseDestX * 1000f); + int projMouseSpeedXVel = (int)(Projectile.velocity.X * 1000f); + int projMouseSpeedY = (int)(mouseDestY * 1000f); + int projMouseSpeedYVel = (int)(Projectile.velocity.Y * 1000f); - if (num119 != num120 || num121 != num122) + if (projMouseSpeedX != projMouseSpeedXVel || projMouseSpeedY != projMouseSpeedYVel) Projectile.netUpdate = true; - Projectile.velocity.X = num116; - Projectile.velocity.Y = num117; + Projectile.velocity.X = mouseDestX; + Projectile.velocity.Y = mouseDestY; } else { - int num123 = (int)(num116 * 1000f); - int num124 = (int)(Projectile.velocity.X * 1000f); - int num125 = (int)(num117 * 1000f); - int num126 = (int)(Projectile.velocity.Y * 1000f); + int projMouseSpeedyX = (int)(mouseDestX * 1000f); + int projMouseSpeedyXVel = (int)(Projectile.velocity.X * 1000f); + int projMouseSpeedyY = (int)(mouseDestY * 1000f); + int projMouseSpeedyYVel = (int)(Projectile.velocity.Y * 1000f); - if (num123 != num124 || num125 != num126) + if (projMouseSpeedyX != projMouseSpeedyXVel || projMouseSpeedyY != projMouseSpeedyYVel) Projectile.netUpdate = true; - Projectile.velocity.X = num116; - Projectile.velocity.Y = num117; + Projectile.velocity.X = mouseDestX; + Projectile.velocity.Y = mouseDestY; } } else if (Projectile.ai[0] <= 0f) { Projectile.netUpdate = true; - Vector2 vector11 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num128 = (float)Main.mouseX + Main.screenPosition.X - vector11.X; - float num129 = (float)Main.mouseY + Main.screenPosition.Y - vector11.Y; + Vector2 projDirect = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float miceX = (float)Main.mouseX + Main.screenPosition.X - projDirect.X; + float miceY = (float)Main.mouseY + Main.screenPosition.Y - projDirect.Y; if (Main.player[Projectile.owner].gravDir == -1f) - num129 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector11.Y; + miceY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - projDirect.Y; - float num130 = (float)Math.Sqrt((double)(num128 * num128 + num129 * num129)); - if (num130 == 0f || Projectile.ai[0] < 0f) + float miceDistancing = (float)Math.Sqrt((double)(miceX * miceX + miceY * miceY)); + if (miceDistancing == 0f || Projectile.ai[0] < 0f) { - vector11 = new Vector2(Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2), Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2)); - num128 = Projectile.position.X + (float)Projectile.width * 0.5f - vector11.X; - num129 = Projectile.position.Y + (float)Projectile.height * 0.5f - vector11.Y; - num130 = (float)Math.Sqrt((double)(num128 * num128 + num129 * num129)); + projDirect = new Vector2(Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2), Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2)); + miceX = Projectile.position.X + (float)Projectile.width * 0.5f - projDirect.X; + miceY = Projectile.position.Y + (float)Projectile.height * 0.5f - projDirect.Y; + miceDistancing = (float)Math.Sqrt((double)(miceX * miceX + miceY * miceY)); } - num130 = speed / num130; - num128 *= num130; - num129 *= num130; - Projectile.velocity.X = num128; - Projectile.velocity.Y = num129; + miceDistancing = speed / miceDistancing; + miceX *= miceDistancing; + miceY *= miceDistancing; + Projectile.velocity.X = miceX; + Projectile.velocity.Y = miceY; if (Projectile.velocity.X == 0f && Projectile.velocity.Y == 0f) Projectile.Kill(); @@ -210,16 +210,16 @@ namespace CalamityMod.Projectiles.Melee Projectile.width = Projectile.height = 64; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int i = 0; i < dustAmt; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 66, vector7.X, vector7.Y, 100, new Color(red, greenAndBlue, greenAndBlue), 1f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int cycloneDust = Dust.NewDust(rotate + faceDirection, 0, 0, 66, faceDirection.X, faceDirection.Y, 100, new Color(red, greenAndBlue, greenAndBlue), 1f); + Main.dust[cycloneDust].noGravity = true; + Main.dust[cycloneDust].noLight = true; + Main.dust[cycloneDust].velocity = faceDirection; } Projectile.Damage(); } diff --git a/Projectiles/Melee/DevilsSunriseProj.cs b/Projectiles/Melee/DevilsSunriseProj.cs index b0556cf518..4f05159cff 100644 --- a/Projectiles/Melee/DevilsSunriseProj.cs +++ b/Projectiles/Melee/DevilsSunriseProj.cs @@ -47,11 +47,11 @@ namespace CalamityMod.Projectiles.Melee red = 255; Player player = Main.player[Projectile.owner]; - float num = 0f; - Vector2 vector = player.RotatedRelativePoint(player.MountedCenter, true); + float pi = 0f; + Vector2 playerRotate = player.RotatedRelativePoint(player.MountedCenter, true); if (Projectile.spriteDirection == -1) - num = 3.14159274f; + pi = 3.14159274f; if (++Projectile.frame >= Main.projFrames[Projectile.type]) Projectile.frame = 0; @@ -72,33 +72,33 @@ namespace CalamityMod.Projectiles.Melee if (player.ActiveItem().shoot == Projectile.type) scaleFactor6 = player.ActiveItem().shootSpeed * Projectile.scale; - Vector2 vector13 = Main.MouseWorld - vector; - vector13.Normalize(); - if (vector13.HasNaNs()) - vector13 = Vector2.UnitX * (float)player.direction; + Vector2 slashDirection = Main.MouseWorld - playerRotate; + slashDirection.Normalize(); + if (slashDirection.HasNaNs()) + slashDirection = Vector2.UnitX * (float)player.direction; - vector13 *= scaleFactor6; - if (vector13.X != Projectile.velocity.X || vector13.Y != Projectile.velocity.Y) + slashDirection *= scaleFactor6; + if (slashDirection.X != Projectile.velocity.X || slashDirection.Y != Projectile.velocity.Y) Projectile.netUpdate = true; - Projectile.velocity = vector13; + Projectile.velocity = slashDirection; } else Projectile.Kill(); } - Vector2 vector14 = Projectile.Center + Projectile.velocity * 3f; - Lighting.AddLight(vector14, (float)((double)red * 0.001), 0.1f, 0.1f); + Vector2 dustSpawn = Projectile.Center + Projectile.velocity * 3f; + Lighting.AddLight(dustSpawn, (float)((double)red * 0.001), 0.1f, 0.1f); if (Main.rand.NextBool(3)) { - int dust = Dust.NewDust(vector14 - Projectile.Size / 2f, Projectile.width, Projectile.height, 66, Projectile.velocity.X, Projectile.velocity.Y, 100, new Color(red, greenAndBlue, greenAndBlue), 1f); + int dust = Dust.NewDust(dustSpawn - Projectile.Size / 2f, Projectile.width, Projectile.height, 66, Projectile.velocity.X, Projectile.velocity.Y, 100, new Color(red, greenAndBlue, greenAndBlue), 1f); Main.dust[dust].noGravity = true; Main.dust[dust].position -= Projectile.velocity; } Projectile.position = player.RotatedRelativePoint(player.MountedCenter, true) - Projectile.Size / 2f; - Projectile.rotation = Projectile.velocity.ToRotation() + num; + Projectile.rotation = Projectile.velocity.ToRotation() + pi; Projectile.spriteDirection = Projectile.direction; Projectile.timeLeft = 2; player.ChangeDir(Projectile.direction); diff --git a/Projectiles/Melee/DragonRageStaff.cs b/Projectiles/Melee/DragonRageStaff.cs index de9251d9eb..5973f399e6 100644 --- a/Projectiles/Melee/DragonRageStaff.cs +++ b/Projectiles/Melee/DragonRageStaff.cs @@ -1,15 +1,15 @@ -using CalamityMod.CalPlayer; +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.CalPlayer; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; using Terraria; using Terraria.Enums; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; -using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Melee { @@ -74,14 +74,14 @@ namespace CalamityMod.Projectiles.Melee private void SpawnDust(Player player, int direction) { - float num12 = Projectile.rotation - MathHelper.PiOver4 * direction; - Vector2 value3 = Projectile.Center + (num12 + ((direction == -1) ? MathHelper.Pi : 0f)).ToRotationVector2() * 30f; - Vector2 vector2 = num12.ToRotationVector2(); - Vector2 value4 = vector2.RotatedBy(MathHelper.PiOver2 * Projectile.spriteDirection); + float rotateDirection = Projectile.rotation - MathHelper.PiOver4 * direction; + Vector2 dustSpawn = Projectile.Center + (rotateDirection + ((direction == -1) ? MathHelper.Pi : 0f)).ToRotationVector2() * 30f; + Vector2 staffTipDirection = rotateDirection.ToRotationVector2(); + Vector2 tipDustDirection = staffTipDirection.RotatedBy(MathHelper.PiOver2 * Projectile.spriteDirection); if (Main.rand.NextBool()) { - Dust dust = Dust.NewDustDirect(value3 - new Vector2(5f), 10, 10, 244, player.velocity.X, player.velocity.Y, 150, default, 1f); + Dust dust = Dust.NewDustDirect(dustSpawn - new Vector2(5f), 10, 10, 244, player.velocity.X, player.velocity.Y, 150, default, 1f); dust.velocity = Projectile.SafeDirectionTo(dust.position) * 0.1f + dust.velocity * 0.1f; } for (int j = 0; j < 4; j++) @@ -105,8 +105,8 @@ namespace CalamityMod.Projectiles.Melee if (Main.rand.Next(6) != 0) { Dust dust = Dust.NewDustDirect(Projectile.position, 0, 0, 244, 0f, 0f, 100, default, 1f); - dust.position = Projectile.Center + vector2 * (60f + Main.rand.NextFloat() * 20f) * dustVelMult2; - dust.velocity = value4 * (4f + 4f * Main.rand.NextFloat()) * dustVelMult2 * dustVelMult; + dust.position = Projectile.Center + staffTipDirection * (60f + Main.rand.NextFloat() * 20f) * dustVelMult2; + dust.velocity = tipDustDirection * (4f + 4f * Main.rand.NextFloat()) * dustVelMult2 * dustVelMult; dust.noGravity = true; dust.noLight = true; dust.scale = 0.5f; @@ -182,7 +182,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage / 8, Projectile.knockBack / 3f, Projectile.owner); } - Main.player[Projectile.owner].Calamity().dragonRageCooldown = 60; + Main.player[Projectile.owner].Calamity().dragonRageCooldown = 60; } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) @@ -228,10 +228,10 @@ namespace CalamityMod.Projectiles.Melee public override void CutTiles() { - float num5 = 60f; - float f = Projectile.rotation - MathHelper.PiOver4 * (float)Math.Sign(Projectile.velocity.X); + float staffRadius = 60f; + float spinning = Projectile.rotation - MathHelper.PiOver4 * (float)Math.Sign(Projectile.velocity.X); DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; - Utils.PlotTileLine(Projectile.Center + f.ToRotationVector2() * -num5, Projectile.Center + f.ToRotationVector2() * num5, (float)Projectile.width * Projectile.scale, DelegateMethods.CutTiles); + Utils.PlotTileLine(Projectile.Center + spinning.ToRotationVector2() * -staffRadius, Projectile.Center + spinning.ToRotationVector2() * staffRadius, (float)Projectile.width * Projectile.scale, DelegateMethods.CutTiles); } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) @@ -240,10 +240,10 @@ namespace CalamityMod.Projectiles.Melee { return true; } - float f = Projectile.rotation - MathHelper.PiOver4 * (float)Math.Sign(Projectile.velocity.X); - float num2 = 0f; - float num3 = 110f; - if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center + f.ToRotationVector2() * -num3, Projectile.Center + f.ToRotationVector2() * num3, 23f * Projectile.scale, ref num2)) + float spinning = Projectile.rotation - MathHelper.PiOver4 * (float)Math.Sign(Projectile.velocity.X); + float staffRadiusHit = 110f; + float useless = 0f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center + spinning.ToRotationVector2() * -staffRadiusHit, Projectile.Center + spinning.ToRotationVector2() * staffRadiusHit, 23f * Projectile.scale, ref useless)) { return true; } diff --git a/Projectiles/Melee/Earth2.cs b/Projectiles/Melee/Earth2.cs index 3c029c65ea..6ad47c4d86 100644 --- a/Projectiles/Melee/Earth2.cs +++ b/Projectiles/Melee/Earth2.cs @@ -42,29 +42,29 @@ namespace CalamityMod.Projectiles.Melee } } Projectile.alpha -= 15; - int num58 = 150; + int alphaControl = 150; if (Projectile.Center.Y >= Projectile.ai[1]) { - num58 = 0; + alphaControl = 0; } - if (Projectile.alpha < num58) + if (Projectile.alpha < alphaControl) { - Projectile.alpha = num58; + Projectile.alpha = alphaControl; } Projectile.localAI[0] += (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y)) * 0.01f * (float)Projectile.direction; Projectile.rotation = Projectile.velocity.ToRotation() - 1.57079637f; if (Main.rand.NextBool(16)) { - Vector2 value3 = Vector2.UnitX.RotatedByRandom(1.5707963705062866).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num59 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 229, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1.2f); - Main.dust[num59].velocity = value3 * 0.66f; - Main.dust[num59].position = Projectile.Center + value3 * 12f; + Vector2 dustDirection = Vector2.UnitX.RotatedByRandom(1.5707963705062866).RotatedBy((double)Projectile.velocity.ToRotation(), default); + int greenishDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 229, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1.2f); + Main.dust[greenishDust].velocity = dustDirection * 0.66f; + Main.dust[greenishDust].position = Projectile.Center + dustDirection * 12f; } if (Main.rand.NextBool(48) && Main.netMode != NetmodeID.Server) { - int num60 = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), 16, 1f); - Main.gore[num60].velocity *= 0.66f; - Main.gore[num60].velocity += Projectile.velocity * 0.3f; + int gored = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), 16, 1f); + Main.gore[gored].velocity *= 0.66f; + Main.gore[gored].velocity += Projectile.velocity * 0.3f; } if (Projectile.ai[1] == 1f) { diff --git a/Projectiles/Melee/Earth3.cs b/Projectiles/Melee/Earth3.cs index 762508caf7..60691b5e4e 100644 --- a/Projectiles/Melee/Earth3.cs +++ b/Projectiles/Melee/Earth3.cs @@ -42,29 +42,29 @@ namespace CalamityMod.Projectiles.Melee } } Projectile.alpha -= 15; - int num58 = 150; + int alphaControl = 150; if (Projectile.Center.Y >= Projectile.ai[1]) { - num58 = 0; + alphaControl = 0; } - if (Projectile.alpha < num58) + if (Projectile.alpha < alphaControl) { - Projectile.alpha = num58; + Projectile.alpha = alphaControl; } Projectile.localAI[0] += (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y)) * 0.01f * (float)Projectile.direction; Projectile.rotation = Projectile.velocity.ToRotation() - 1.57079637f; if (Main.rand.NextBool(16)) { - Vector2 value3 = Vector2.UnitX.RotatedByRandom(1.5707963705062866).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num59 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1.2f); - Main.dust[num59].velocity = value3 * 0.66f; - Main.dust[num59].position = Projectile.Center + value3 * 12f; + Vector2 dustDirection = Vector2.UnitX.RotatedByRandom(1.5707963705062866).RotatedBy((double)Projectile.velocity.ToRotation(), default); + int brownDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1.2f); + Main.dust[brownDust].velocity = dustDirection * 0.66f; + Main.dust[brownDust].position = Projectile.Center + dustDirection * 12f; } if (Main.rand.NextBool(48) && Main.netMode != NetmodeID.Server) { - int num60 = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), 16, 1f); - Main.gore[num60].velocity *= 0.66f; - Main.gore[num60].velocity += Projectile.velocity * 0.3f; + int gored = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), 16, 1f); + Main.gore[gored].velocity *= 0.66f; + Main.gore[gored].velocity += Projectile.velocity * 0.3f; } if (Projectile.ai[1] == 1f) { @@ -90,23 +90,23 @@ namespace CalamityMod.Projectiles.Melee Projectile.height = 30; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 20; num621++) + for (int i = 0; i < 20; i++) { - int num622 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dusty = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[dusty].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dusty].scale = 0.5f; + Main.dust[dusty].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } for (int num623 = 0; num623 < 35; num623++) { - int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dusty2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 3f); + Main.dust[dusty2].noGravity = true; + Main.dust[dusty2].velocity *= 5f; + dusty2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[dusty2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) diff --git a/Projectiles/Melee/Earth4.cs b/Projectiles/Melee/Earth4.cs index e69957deb6..3f6f3696ec 100644 --- a/Projectiles/Melee/Earth4.cs +++ b/Projectiles/Melee/Earth4.cs @@ -42,29 +42,29 @@ namespace CalamityMod.Projectiles.Melee } } Projectile.alpha -= 15; - int num58 = 150; + int alphaControl = 150; if (Projectile.Center.Y >= Projectile.ai[1]) { - num58 = 0; + alphaControl = 0; } - if (Projectile.alpha < num58) + if (Projectile.alpha < alphaControl) { - Projectile.alpha = num58; + Projectile.alpha = alphaControl; } Projectile.localAI[0] += (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y)) * 0.01f * (float)Projectile.direction; Projectile.rotation = Projectile.velocity.ToRotation() - 1.57079637f; if (Main.rand.NextBool(16)) { - Vector2 value3 = Vector2.UnitX.RotatedByRandom(1.5707963705062866).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num59 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 74, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1.2f); - Main.dust[num59].velocity = value3 * 0.66f; - Main.dust[num59].position = Projectile.Center + value3 * 12f; + Vector2 dustDirection = Vector2.UnitX.RotatedByRandom(1.5707963705062866).RotatedBy((double)Projectile.velocity.ToRotation(), default); + int brightGreenDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 74, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1.2f); + Main.dust[brightGreenDust].velocity = dustDirection * 0.66f; + Main.dust[brightGreenDust].position = Projectile.Center + dustDirection * 12f; } if (Main.rand.NextBool(48) && Main.netMode != NetmodeID.Server) { - int num60 = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), 16, 1f); - Main.gore[num60].velocity *= 0.66f; - Main.gore[num60].velocity += Projectile.velocity * 0.3f; + int gored = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), 16, 1f); + Main.gore[gored].velocity *= 0.66f; + Main.gore[gored].velocity += Projectile.velocity * 0.3f; } if (Projectile.ai[1] == 1f) { diff --git a/Projectiles/Melee/EarthProj.cs b/Projectiles/Melee/EarthProj.cs index 463be63f40..204ba36e80 100644 --- a/Projectiles/Melee/EarthProj.cs +++ b/Projectiles/Melee/EarthProj.cs @@ -42,14 +42,14 @@ namespace CalamityMod.Projectiles.Melee } } Projectile.alpha -= 15; - int num58 = 150; + int alphaControl = 150; if (Projectile.Center.Y >= Projectile.ai[1]) { - num58 = 0; + alphaControl = 0; } - if (Projectile.alpha < num58) + if (Projectile.alpha < alphaControl) { - Projectile.alpha = num58; + Projectile.alpha = alphaControl; } Projectile.localAI[0] += (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y)) * 0.01f * (float)Projectile.direction; Projectile.rotation = Projectile.velocity.ToRotation() - 1.57079637f; @@ -68,16 +68,16 @@ namespace CalamityMod.Projectiles.Melee } if (Main.rand.NextBool(16)) { - Vector2 value3 = Vector2.UnitX.RotatedByRandom(1.5707963705062866).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num59 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustChoice, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1.2f); - Main.dust[num59].velocity = value3 * 0.66f; - Main.dust[num59].position = Projectile.Center + value3 * 12f; + Vector2 dustDirection = Vector2.UnitX.RotatedByRandom(1.5707963705062866).RotatedBy((double)Projectile.velocity.ToRotation(), default); + int dustOnHit = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustChoice, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1.2f); + Main.dust[dustOnHit].velocity = dustDirection * 0.66f; + Main.dust[dustOnHit].position = Projectile.Center + dustDirection * 12f; } if (Main.rand.NextBool(48) && Main.netMode != NetmodeID.Server) { - int num60 = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), 16, 1f); - Main.gore[num60].velocity *= 0.66f; - Main.gore[num60].velocity += Projectile.velocity * 0.3f; + int gored = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), 16, 1f); + Main.gore[gored].velocity *= 0.66f; + Main.gore[gored].velocity += Projectile.velocity * 0.3f; } if (Projectile.ai[1] == 1f) { diff --git a/Projectiles/Melee/ElementBall.cs b/Projectiles/Melee/ElementBall.cs index e278e8b033..86233f22be 100644 --- a/Projectiles/Melee/ElementBall.cs +++ b/Projectiles/Melee/ElementBall.cs @@ -23,9 +23,9 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - int num250 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[num250].noGravity = true; - Main.dust[num250].velocity *= 0f; + int rainbowDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Main.dust[rainbowDust].noGravity = true; + Main.dust[rainbowDust].velocity *= 0f; CalamityUtils.HomeInOnNPC(Projectile, true, 200f, 12f, 20f); } diff --git a/Projectiles/Melee/ElementBallShiv.cs b/Projectiles/Melee/ElementBallShiv.cs index a4862507a0..619d7eed17 100644 --- a/Projectiles/Melee/ElementBallShiv.cs +++ b/Projectiles/Melee/ElementBallShiv.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -50,6 +51,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { + target.AddBuff(ModContent.BuffType(), 30); OnHitEffects(target.Center); } diff --git a/Projectiles/Melee/ElementalGlassStar.cs b/Projectiles/Melee/ElementalGlassStar.cs index 799748a837..f8e9143f81 100644 --- a/Projectiles/Melee/ElementalGlassStar.cs +++ b/Projectiles/Melee/ElementalGlassStar.cs @@ -6,6 +6,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Melee { @@ -138,5 +139,9 @@ namespace CalamityMod.Projectiles.Melee } } } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 60); + } } } diff --git a/Projectiles/Melee/EmpyreanKnife.cs b/Projectiles/Melee/EmpyreanKnife.cs index f8deb094e6..b37700d8f2 100644 --- a/Projectiles/Melee/EmpyreanKnife.cs +++ b/Projectiles/Melee/EmpyreanKnife.cs @@ -67,12 +67,12 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { - for (int num303 = 0; num303 < 3; num303++) + for (int i = 0; i < 3; i++) { - int num304 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 58, 0f, 0f, 100, default, 0.8f); - Main.dust[num304].noGravity = true; - Main.dust[num304].velocity *= 1.2f; - Main.dust[num304].velocity -= Projectile.oldVelocity * 0.3f; + int empyreanDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 58, 0f, 0f, 100, default, 0.8f); + Main.dust[empyreanDust].noGravity = true; + Main.dust[empyreanDust].velocity *= 1.2f; + Main.dust[empyreanDust].velocity -= Projectile.oldVelocity * 0.3f; } } diff --git a/Projectiles/Melee/EntropicFlechette.cs b/Projectiles/Melee/EntropicFlechette.cs index 930b11bbd1..f598ca5a90 100644 --- a/Projectiles/Melee/EntropicFlechette.cs +++ b/Projectiles/Melee/EntropicFlechette.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { Projectile.rotation = Projectile.velocity.ToRotation(); - Vector2 value7 = new Vector2(6f, 12f); + Vector2 rotateVector = new Vector2(6f, 12f); Projectile.localAI[0] += 1f; if (Projectile.localAI[0] == 48f) { @@ -35,20 +35,20 @@ namespace CalamityMod.Projectiles.Melee } else { - for (int num41 = 0; num41 < 2; num41++) + for (int i = 0; i < 2; i++) { - Vector2 value8 = -Vector2.UnitY.RotatedBy((double)(Projectile.localAI[0] * 0.1308997f + (float)num41 * 3.14159274f), default) * value7; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, 27, 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = 1f; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8; - Main.dust[num42].velocity = Projectile.velocity; + Vector2 dustRotate = -Vector2.UnitY.RotatedBy((double)(Projectile.localAI[0] * 0.1308997f + (float)i * 3.14159274f), default) * rotateVector; + int darkDust = Dust.NewDust(Projectile.Center, 0, 0, 27, 0f, 0f, 160, default, 1f); + Main.dust[darkDust].scale = 1f; + Main.dust[darkDust].noGravity = true; + Main.dust[darkDust].position = Projectile.Center + dustRotate; + Main.dust[darkDust].velocity = Projectile.velocity; } } - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 27, 0f, 0f, 100, default, 0.8f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0f; + int darkestDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 27, 0f, 0f, 100, default, 0.8f); + Main.dust[darkestDust].noGravity = true; + Main.dust[darkestDust].velocity *= 0f; CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, 12f, 20f); } diff --git a/Projectiles/Melee/EntropicFlechetteLarge.cs b/Projectiles/Melee/EntropicFlechetteLarge.cs index d7ac15d055..08aa4c6067 100644 --- a/Projectiles/Melee/EntropicFlechetteLarge.cs +++ b/Projectiles/Melee/EntropicFlechetteLarge.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { Projectile.rotation = Projectile.velocity.ToRotation(); - Vector2 value7 = new Vector2(6f, 12f); + Vector2 rotateVector = new Vector2(6f, 12f); Projectile.localAI[0] += 1f; if (Projectile.localAI[0] == 48f) { @@ -35,20 +35,20 @@ namespace CalamityMod.Projectiles.Melee } else { - for (int num41 = 0; num41 < 2; num41++) + for (int i = 0; i < 2; i++) { - Vector2 value8 = -Vector2.UnitY.RotatedBy((double)(Projectile.localAI[0] * 0.1308997f + (float)num41 * 3.14159274f), default) * value7; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, 27, 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = 1f; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8; - Main.dust[num42].velocity = Projectile.velocity; + Vector2 dustRotate = -Vector2.UnitY.RotatedBy((double)(Projectile.localAI[0] * 0.1308997f + (float)i * 3.14159274f), default) * rotateVector; + int darkDust = Dust.NewDust(Projectile.Center, 0, 0, 27, 0f, 0f, 160, default, 1f); + Main.dust[darkDust].scale = 1f; + Main.dust[darkDust].noGravity = true; + Main.dust[darkDust].position = Projectile.Center + dustRotate; + Main.dust[darkDust].velocity = Projectile.velocity; } } - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 27, 0f, 0f, 100, default, 0.8f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0f; + int darkestDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 27, 0f, 0f, 100, default, 0.8f); + Main.dust[darkestDust].noGravity = true; + Main.dust[darkestDust].velocity *= 0f; CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, 12f, 20f); } diff --git a/Projectiles/Melee/EntropicFlechetteSmall.cs b/Projectiles/Melee/EntropicFlechetteSmall.cs index 533c708ced..1396ebc85d 100644 --- a/Projectiles/Melee/EntropicFlechetteSmall.cs +++ b/Projectiles/Melee/EntropicFlechetteSmall.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { Projectile.rotation = Projectile.velocity.ToRotation(); - Vector2 value7 = new Vector2(6f, 12f); + Vector2 rotateVector = new Vector2(6f, 12f); Projectile.localAI[0] += 1f; if (Projectile.localAI[0] == 48f) { @@ -35,20 +35,20 @@ namespace CalamityMod.Projectiles.Melee } else { - for (int num41 = 0; num41 < 2; num41++) + for (int i = 0; i < 2; i++) { - Vector2 value8 = -Vector2.UnitY.RotatedBy((double)(Projectile.localAI[0] * 0.1308997f + (float)num41 * 3.14159274f), default) * value7; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, 27, 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = 1f; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8; - Main.dust[num42].velocity = Projectile.velocity; + Vector2 dustRotate = -Vector2.UnitY.RotatedBy((double)(Projectile.localAI[0] * 0.1308997f + (float)i * 3.14159274f), default) * rotateVector; + int darkDust = Dust.NewDust(Projectile.Center, 0, 0, 27, 0f, 0f, 160, default, 1f); + Main.dust[darkDust].scale = 1f; + Main.dust[darkDust].noGravity = true; + Main.dust[darkDust].position = Projectile.Center + dustRotate; + Main.dust[darkDust].velocity = Projectile.velocity; } } - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 27, 0f, 0f, 100, default, 0.8f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0f; + int darkestDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 27, 0f, 0f, 100, default, 0.8f); + Main.dust[darkestDust].noGravity = true; + Main.dust[darkestDust].velocity *= 0f; CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, 12f, 20f); } diff --git a/Projectiles/Melee/EssenceFlame2.cs b/Projectiles/Melee/EssenceFlame2.cs index adb3c0b4d2..a99f7fc64d 100644 --- a/Projectiles/Melee/EssenceFlame2.cs +++ b/Projectiles/Melee/EssenceFlame2.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.frame = 0; if (Projectile.timeLeft < 150) - CalamityUtils.HomeInOnNPC(Projectile, true, 600f, 10f, 20f); + CalamityUtils.HomeInOnNPC(Projectile, true, 760f, 10f, 20f); } public override void OnKill(int timeLeft) @@ -56,23 +56,23 @@ namespace CalamityMod.Projectiles.Melee Projectile.height = 50; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int essenceDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); + Main.dust[essenceDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[essenceDust].scale = 0.5f; + Main.dust[essenceDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 8; num623++) + for (int j = 0; j < 8; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int essenceDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 3f); + Main.dust[essenceDust2].noGravity = true; + Main.dust[essenceDust2].velocity *= 5f; + essenceDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); + Main.dust[essenceDust2].velocity *= 2f; } } } diff --git a/Projectiles/Melee/EutrophicSpark.cs b/Projectiles/Melee/EutrophicSpark.cs index dbc92223f8..7dd42bd447 100644 --- a/Projectiles/Melee/EutrophicSpark.cs +++ b/Projectiles/Melee/EutrophicSpark.cs @@ -50,25 +50,25 @@ namespace CalamityMod.Projectiles.Melee Projectile.velocity.Y = Projectile.velocity.Y + 0.2f; } Projectile.rotation += Projectile.velocity.X * 0.1f; - int num199 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 206, 0f, 0f, 100, default, 1f); - Dust expr_8976_cp_0 = Main.dust[num199]; + int eutrophicDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 206, 0f, 0f, 100, default, 1f); + Dust expr_8976_cp_0 = Main.dust[eutrophicDust]; expr_8976_cp_0.position.X -= 2f; - Dust expr_8994_cp_0 = Main.dust[num199]; + Dust expr_8994_cp_0 = Main.dust[eutrophicDust]; expr_8994_cp_0.position.Y += 2f; - Main.dust[num199].scale += (float)Main.rand.Next(50) * 0.01f; - Main.dust[num199].noGravity = true; - Dust expr_89E7_cp_0 = Main.dust[num199]; + Main.dust[eutrophicDust].scale += (float)Main.rand.Next(50) * 0.01f; + Main.dust[eutrophicDust].noGravity = true; + Dust expr_89E7_cp_0 = Main.dust[eutrophicDust]; expr_89E7_cp_0.velocity.Y -= 2f; if (Main.rand.NextBool()) { - int num200 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 206, 0f, 0f, 100, default, 1f); - Dust expr_8A4E_cp_0 = Main.dust[num200]; + int eutrophicDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 206, 0f, 0f, 100, default, 1f); + Dust expr_8A4E_cp_0 = Main.dust[eutrophicDust2]; expr_8A4E_cp_0.position.X -= 2f; - Dust expr_8A6C_cp_0 = Main.dust[num200]; + Dust expr_8A6C_cp_0 = Main.dust[eutrophicDust2]; expr_8A6C_cp_0.position.Y += 2f; - Main.dust[num200].scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; - Main.dust[num200].noGravity = true; - Main.dust[num200].velocity *= 0.1f; + Main.dust[eutrophicDust2].scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; + Main.dust[eutrophicDust2].noGravity = true; + Main.dust[eutrophicDust2].velocity *= 0.1f; } if ((double)Projectile.velocity.Y < 0.25 && (double)Projectile.velocity.Y > 0.15) { diff --git a/Projectiles/Melee/ExobladeProj.cs b/Projectiles/Melee/ExobladeProj.cs index 3ab49c5948..f5f53cd703 100644 --- a/Projectiles/Melee/ExobladeProj.cs +++ b/Projectiles/Melee/ExobladeProj.cs @@ -283,7 +283,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.Center = Owner.RotatedRelativePoint(Owner.MountedCenter, true); Owner.heldProj = Projectile.whoAmI; Owner.SetDummyItemTime(2); - Owner.direction = Direction; + Owner.ChangeDir(Direction); // Decide the arm rotation for the owner. float armRotation = SwordRotation - MathHelper.PiOver2; diff --git a/Projectiles/Melee/Exocomet.cs b/Projectiles/Melee/Exocomet.cs index d2aa0ed6b9..0caae195ec 100644 --- a/Projectiles/Melee/Exocomet.cs +++ b/Projectiles/Melee/Exocomet.cs @@ -53,11 +53,11 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.alpha < 40) { - int num309 = Dust.NewDust(new Vector2(Projectile.position.X - Projectile.velocity.X * 4f + 2f, Projectile.position.Y + 2f - Projectile.velocity.Y * 4f), 8, 8, 107, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, new Color(0, 255, 255), 0.5f); - Main.dust[num309].velocity *= -0.25f; - num309 = Dust.NewDust(new Vector2(Projectile.position.X - Projectile.velocity.X * 4f + 2f, Projectile.position.Y + 2f - Projectile.velocity.Y * 4f), 8, 8, 107, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, new Color(0, 255, 255), 0.5f); - Main.dust[num309].velocity *= -0.25f; - Main.dust[num309].position -= Projectile.velocity * 0.5f; + int exo = Dust.NewDust(new Vector2(Projectile.position.X - Projectile.velocity.X * 4f + 2f, Projectile.position.Y + 2f - Projectile.velocity.Y * 4f), 8, 8, 107, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, new Color(0, 255, 255), 0.5f); + Main.dust[exo].velocity *= -0.25f; + exo = Dust.NewDust(new Vector2(Projectile.position.X - Projectile.velocity.X * 4f + 2f, Projectile.position.Y + 2f - Projectile.velocity.Y * 4f), 8, 8, 107, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, new Color(0, 255, 255), 0.5f); + Main.dust[exo].velocity *= -0.25f; + Main.dust[exo].position -= Projectile.velocity * 0.5f; } Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; @@ -68,15 +68,14 @@ namespace CalamityMod.Projectiles.Melee CalamityUtils.HomeInOnNPC(Projectile, true, 600f, 12f, 20f); else { - float num953 = 100f * Projectile.ai[1]; - float scaleFactor12 = 20f * Projectile.ai[1]; - float num954 = 40f; + float projVelocity = 100f * Projectile.ai[1]; + float scaleFactor = 20f * Projectile.ai[1]; if (Main.player[Projectile.owner].active && !Main.player[Projectile.owner].dead) { - if (Projectile.Distance(Main.player[Projectile.owner].Center) > num954) + if (Projectile.Distance(Main.player[Projectile.owner].Center) > 40f) { Vector2 moveDirection = Projectile.SafeDirectionTo(Main.player[Projectile.owner].Center, Vector2.UnitY); - Projectile.velocity = (Projectile.velocity * (num953 - 1f) + moveDirection * scaleFactor12) / num953; + Projectile.velocity = (Projectile.velocity * (projVelocity - 1f) + moveDirection * scaleFactor) / projVelocity; } } } @@ -134,18 +133,18 @@ namespace CalamityMod.Projectiles.Melee Projectile.width = Projectile.height = 80; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num193 = 0; num193 < 2; num193++) + for (int i = 0; i < 2; i++) { Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); } - for (int num194 = 0; num194 < 20; num194++) + for (int j = 0; j < 20; j++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int exoDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[exoDust].noGravity = true; + Main.dust[exoDust].velocity *= 3f; + exoDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[exoDust].velocity *= 2f; + Main.dust[exoDust].noGravity = true; } } } diff --git a/Projectiles/Melee/FallenPaladinsHammerProj.cs b/Projectiles/Melee/FallenPaladinsHammerProj.cs index 5449be8ca2..c349f3ce14 100644 --- a/Projectiles/Melee/FallenPaladinsHammerProj.cs +++ b/Projectiles/Melee/FallenPaladinsHammerProj.cs @@ -201,7 +201,8 @@ namespace CalamityMod.Projectiles.Melee } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - Projectile.damage = (int)(Projectile.damage * 0.9f); + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.9f); if (Projectile.damage < 1) Projectile.damage = 1; } diff --git a/Projectiles/Melee/Feather.cs b/Projectiles/Melee/Feather.cs index ccfb5db8e1..46df7b87bf 100644 --- a/Projectiles/Melee/Feather.cs +++ b/Projectiles/Melee/Feather.cs @@ -28,11 +28,11 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { - int num3; - for (int num611 = 0; num611 < 10; num611 = num3 + 1) + int inc; + for (int i = 0; i < 10; i = inc + 1) { Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 64, Projectile.velocity.X * 0.1f, Projectile.velocity.Y * 0.1f, 0, default, 1f); - num3 = num611; + inc = i; } } } diff --git a/Projectiles/Melee/Flarefrost.cs b/Projectiles/Melee/Flarefrost.cs index 51dacd41ca..eece894ca7 100644 --- a/Projectiles/Melee/Flarefrost.cs +++ b/Projectiles/Melee/Flarefrost.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - Vector2 value7 = new Vector2(5f, 10f); + Vector2 rotateVector = new Vector2(5f, 10f); Lighting.AddLight(Projectile.Center, 0.25f, 0f, 0.25f); Projectile.localAI[0] += 1f; if (Projectile.localAI[0] == 48f) @@ -33,19 +33,19 @@ namespace CalamityMod.Projectiles.Melee } else { - for (int num41 = 0; num41 < 2; num41++) + for (int i = 0; i < 2; i++) { - int dustType = num41 == 0 ? 67 : 174; - Vector2 value8 = Vector2.UnitX * -12f; - value8 = -Vector2.UnitY.RotatedBy((double)(Projectile.localAI[0] * 0.1308997f + (float)num41 * 3.14159274f), default) * value7; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, dustType, 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = dustType == 67 ? 1.5f : 1f; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8; - Main.dust[num42].velocity = Projectile.velocity; - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 0.8f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0f; + int dustType = i == 0 ? 67 : 174; + Vector2 dustRotate = Vector2.UnitX * -12f; + dustRotate = -Vector2.UnitY.RotatedBy((double)(Projectile.localAI[0] * 0.1308997f + (float)i * 3.14159274f), default) * rotateVector; + int flarefrost = Dust.NewDust(Projectile.Center, 0, 0, dustType, 0f, 0f, 160, default, 1f); + Main.dust[flarefrost].scale = dustType == 67 ? 1.5f : 1f; + Main.dust[flarefrost].noGravity = true; + Main.dust[flarefrost].position = Projectile.Center + dustRotate; + Main.dust[flarefrost].velocity = Projectile.velocity; + int frostflare = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 0.8f); + Main.dust[frostflare].noGravity = true; + Main.dust[frostflare].velocity *= 0f; } } diff --git a/Projectiles/Melee/GaelExplosion.cs b/Projectiles/Melee/GaelExplosion.cs index 65dc01c2b5..0ce3b94ef1 100644 --- a/Projectiles/Melee/GaelExplosion.cs +++ b/Projectiles/Melee/GaelExplosion.cs @@ -35,61 +35,61 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(SoundID.Item74, Projectile.Center); Projectile.localAI[0] += 1f; } - bool flag15 = false; - bool flag16 = false; + bool xflag = false; + bool yflag = false; if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) { - flag16 = true; + yflag = true; } if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) { - flag16 = true; + yflag = true; } - if (flag15 && flag16) + if (xflag && yflag) { Projectile.Kill(); } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-30, 31); - float num464 = (float)Main.rand.Next(-30, 31); - float num465 = (float)Main.rand.Next(9, 27); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 218, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num467].noGravity = true; - Main.dust[num467].position.X = Projectile.Center.X; - Main.dust[num467].position.Y = Projectile.Center.Y; - Dust dust = Main.dust[num467]; + float rando1 = (float)Main.rand.Next(-30, 31); + float rando2 = (float)Main.rand.Next(-30, 31); + float rando3 = (float)Main.rand.Next(9, 27); + float randoAdjuster = (float)Math.Sqrt((double)(rando1 * rando1 + rando2 * rando2)); + randoAdjuster = rando3 / randoAdjuster; + rando1 *= randoAdjuster; + rando2 *= randoAdjuster; + int gaelDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 218, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[gaelDust].noGravity = true; + Main.dust[gaelDust].position.X = Projectile.Center.X; + Main.dust[gaelDust].position.Y = Projectile.Center.Y; + Dust dust = Main.dust[gaelDust]; dust.position.X += (float)Main.rand.Next(-10, 11); - dust = Main.dust[num467]; + dust = Main.dust[gaelDust]; dust.position.Y += (float)Main.rand.Next(-10, 11); - Main.dust[num467].velocity.X = num463; - Main.dust[num467].velocity.Y = num464; - num462++; + Main.dust[gaelDust].velocity.X = rando1; + Main.dust[gaelDust].velocity.Y = rando2; + timerCounter++; } } } diff --git a/Projectiles/Melee/GalacticaComet.cs b/Projectiles/Melee/GalacticaComet.cs index 7a939a2234..159797a916 100644 --- a/Projectiles/Melee/GalacticaComet.cs +++ b/Projectiles/Melee/GalacticaComet.cs @@ -51,39 +51,39 @@ namespace CalamityMod.Projectiles.Melee Projectile.localAI[0] = 0f; for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * MathHelper.Pi / 6f), default) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy((double)(Projectile.rotation - MathHelper.PiOver2), default); - int num9 = Dust.NewDust(Projectile.Center, 0, 0, Main.rand.NextBool() ? 164 : 229, 0f, 0f, 160, default, 1f); - Main.dust[num9].noGravity = true; - Main.dust[num9].position = Projectile.Center + vector3; - Main.dust[num9].velocity = Projectile.velocity * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; + Vector2 dustRotate = Vector2.UnitX * (float)-(float)Projectile.width / 2f; + dustRotate += -Vector2.UnitY.RotatedBy((double)((float)l * MathHelper.Pi / 6f), default) * new Vector2(8f, 16f); + dustRotate = dustRotate.RotatedBy((double)(Projectile.rotation - MathHelper.PiOver2), default); + int galactic = Dust.NewDust(Projectile.Center, 0, 0, Main.rand.NextBool() ? 164 : 229, 0f, 0f, 160, default, 1f); + Main.dust[galactic].noGravity = true; + Main.dust[galactic].position = Projectile.Center + dustRotate; + Main.dust[galactic].velocity = Projectile.velocity * 0.1f; + Main.dust[galactic].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[galactic].position) * 1.25f; } } Projectile.alpha -= 15; - int num58 = 150; + int alphaControl = 150; if (Projectile.Center.Y >= Projectile.ai[1]) - num58 = 0; - if (Projectile.alpha < num58) - Projectile.alpha = num58; + alphaControl = 0; + if (Projectile.alpha < alphaControl) + Projectile.alpha = alphaControl; Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; if (Main.rand.NextBool(16)) { - Vector2 value3 = Vector2.UnitX.RotatedByRandom(MathHelper.PiOver2).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num59 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 164, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1f); - Main.dust[num59].velocity = value3 * 0.66f; - Main.dust[num59].position = Projectile.Center + value3 * 12f; + Vector2 rotation = Vector2.UnitX.RotatedByRandom(MathHelper.PiOver2).RotatedBy((double)Projectile.velocity.ToRotation(), default); + int pinkDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 164, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1f); + Main.dust[pinkDust].velocity = rotation * 0.66f; + Main.dust[pinkDust].position = Projectile.Center + rotation * 12f; } if (Main.rand.NextBool(48) && Main.netMode != NetmodeID.Server) { - int num60 = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), 16, 1f); - Main.gore[num60].velocity *= 0.66f; - Main.gore[num60].velocity += Projectile.velocity * 0.3f; + int gored = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), 16, 1f); + Main.gore[gored].velocity *= 0.66f; + Main.gore[gored].velocity += Projectile.velocity * 0.3f; } if (Projectile.ai[1] == 1f) @@ -120,18 +120,18 @@ namespace CalamityMod.Projectiles.Melee Projectile.width = Projectile.height = 68; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num193 = 0; num193 < 4; num193++) + for (int i = 0; i < 4; i++) { Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 164, 0f, 0f, 50, default, 1.5f); } - for (int num194 = 0; num194 < 20; num194++) + for (int j = 0; j < 20; j++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 229, 0f, 0f, 0, default, 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 229, 0f, 0f, 50, default, 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int galaxyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 229, 0f, 0f, 0, default, 2.5f); + Main.dust[galaxyDust].noGravity = true; + Main.dust[galaxyDust].velocity *= 3f; + galaxyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 229, 0f, 0f, 50, default, 1.5f); + Main.dust[galaxyDust].velocity *= 2f; + Main.dust[galaxyDust].noGravity = true; } Projectile.maxPenetrate = -1; Projectile.penetrate = -1; diff --git a/Projectiles/Melee/Galaxia_AndromedasStride.cs b/Projectiles/Melee/Galaxia_AndromedasStride.cs index a3c98a9327..c356147811 100644 --- a/Projectiles/Melee/Galaxia_AndromedasStride.cs +++ b/Projectiles/Melee/Galaxia_AndromedasStride.cs @@ -197,7 +197,7 @@ namespace CalamityMod.Projectiles.Melee //Scaling based on charge Projectile.scale = 1f + (Charge / MaxCharge * 0.3f); - Owner.direction = Math.Sign(direction.X); + Owner.ChangeDir(Math.Sign(direction.X)); Owner.itemRotation = direction.ToRotation(); if (Owner.direction != 1) diff --git a/Projectiles/Melee/Galaxia_AriesWrath.cs b/Projectiles/Melee/Galaxia_AriesWrath.cs index 9dff39a835..d0e7cd2ecc 100644 --- a/Projectiles/Melee/Galaxia_AriesWrath.cs +++ b/Projectiles/Melee/Galaxia_AriesWrath.cs @@ -166,7 +166,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre "holding" the sword bla bla Owner.heldProj = Projectile.whoAmI; Projectile.velocity = Owner.SafeDirectionTo(Projectile.Center, Vector2.Zero); - Owner.direction = Math.Sign(Projectile.velocity.X); + Owner.ChangeDir(Math.Sign(Projectile.velocity.X)); Owner.itemRotation = Projectile.velocity.ToRotation(); if (Owner.direction != 1) { diff --git a/Projectiles/Melee/Galaxia_PhoenixsPride.cs b/Projectiles/Melee/Galaxia_PhoenixsPride.cs index 185cc57fa5..5b216395f9 100644 --- a/Projectiles/Melee/Galaxia_PhoenixsPride.cs +++ b/Projectiles/Melee/Galaxia_PhoenixsPride.cs @@ -251,7 +251,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(direction.X); + Owner.ChangeDir(Math.Sign(direction.X)); Owner.itemRotation = direction.ToRotation(); if (Owner.direction != 1) { diff --git a/Projectiles/Melee/Galaxia_PolarisGaze.cs b/Projectiles/Melee/Galaxia_PolarisGaze.cs index 1cbef40219..4516bc10f3 100644 --- a/Projectiles/Melee/Galaxia_PolarisGaze.cs +++ b/Projectiles/Melee/Galaxia_PolarisGaze.cs @@ -205,7 +205,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(direction.X); + Owner.ChangeDir(Math.Sign(direction.X)); Owner.itemRotation = direction.ToRotation(); if (Owner.direction != 1) { diff --git a/Projectiles/Melee/GalaxyBlast.cs b/Projectiles/Melee/GalaxyBlast.cs index 20dffd4f3c..fffe60486e 100644 --- a/Projectiles/Melee/GalaxyBlast.cs +++ b/Projectiles/Melee/GalaxyBlast.cs @@ -40,14 +40,14 @@ namespace CalamityMod.Projectiles.Melee Projectile.Kill(); return; } - bool flag5 = WorldGen.SolidTile(Framing.GetTileSafely((int)Projectile.position.X / 16, (int)Projectile.position.Y / 16)); - Dust dust6 = Main.dust[Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 0, default, 1f)]; - dust6.position = Projectile.Center; - dust6.velocity = Vector2.Zero; - dust6.noGravity = true; - if (flag5) + bool isInTile = WorldGen.SolidTile(Framing.GetTileSafely((int)Projectile.position.X / 16, (int)Projectile.position.Y / 16)); + Dust blastDust = Main.dust[Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 0, default, 1f)]; + blastDust.position = Projectile.Center; + blastDust.velocity = Vector2.Zero; + blastDust.noGravity = true; + if (isInTile) { - dust6.noLight = true; + blastDust.noLight = true; } if (Projectile.ai[1] == -1f) { @@ -77,22 +77,22 @@ namespace CalamityMod.Projectiles.Melee Projectile.alpha = 255; if (Projectile.numUpdates == 0) { - int num158 = -1; - float num159 = 60f; - for (int num160 = 0; num160 < Main.maxNPCs; num160++) + int npcTracker = -1; + float homingRange = 60f; + for (int i = 0; i < Main.maxNPCs; i++) { - NPC nPC = Main.npc[num160]; + NPC nPC = Main.npc[i]; if (nPC.CanBeChasedBy(Projectile, false)) { - float num161 = Projectile.Distance(nPC.Center); - if (num161 < num159 && Collision.CanHitLine(Projectile.Center, 0, 0, nPC.Center, 0, 0)) + float npcDistance = Projectile.Distance(nPC.Center); + if (npcDistance < homingRange && Collision.CanHitLine(Projectile.Center, 0, 0, nPC.Center, 0, 0)) { - num159 = num161; - num158 = num160; + homingRange = npcDistance; + npcTracker = i; } } } - if (num158 != -1) + if (npcTracker != -1) { Projectile.ai[0] = 0f; Projectile.ai[1] = -1f; @@ -104,26 +104,26 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - bool flag = WorldGen.SolidTile(Framing.GetTileSafely((int)Projectile.position.X / 16, (int)Projectile.position.Y / 16)); + bool insideTile = WorldGen.SolidTile(Framing.GetTileSafely((int)Projectile.position.X / 16, (int)Projectile.position.Y / 16)); for (int m = 0; m < 4; m++) { Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.5f); } for (int n = 0; n < 4; n++) { - int num10 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 0, default, 2.5f); - Main.dust[num10].noGravity = true; - Main.dust[num10].velocity *= 3f; - if (flag) + int killingPeople = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 0, default, 2.5f); + Main.dust[killingPeople].noGravity = true; + Main.dust[killingPeople].velocity *= 3f; + if (insideTile) { - Main.dust[num10].noLight = true; + Main.dust[killingPeople].noLight = true; } - num10 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.5f); - Main.dust[num10].velocity *= 2f; - Main.dust[num10].noGravity = true; - if (flag) + killingPeople = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.5f); + Main.dust[killingPeople].velocity *= 2f; + Main.dust[killingPeople].noGravity = true; + if (insideTile) { - Main.dust[num10].noLight = true; + Main.dust[killingPeople].noLight = true; } } } diff --git a/Projectiles/Melee/GalaxyBlastType2.cs b/Projectiles/Melee/GalaxyBlastType2.cs index cdd2f8a31e..d48506f7bc 100644 --- a/Projectiles/Melee/GalaxyBlastType2.cs +++ b/Projectiles/Melee/GalaxyBlastType2.cs @@ -41,14 +41,14 @@ namespace CalamityMod.Projectiles.Melee Projectile.Kill(); return; } - bool flag5 = WorldGen.SolidTile(Framing.GetTileSafely((int)Projectile.position.X / 16, (int)Projectile.position.Y / 16)); - Dust dust6 = Main.dust[Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 0, default, 1f)]; - dust6.position = Projectile.Center; - dust6.velocity = Vector2.Zero; - dust6.noGravity = true; - if (flag5) + bool isInTile = WorldGen.SolidTile(Framing.GetTileSafely((int)Projectile.position.X / 16, (int)Projectile.position.Y / 16)); + Dust blastDust = Main.dust[Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 0, default, 1f)]; + blastDust.position = Projectile.Center; + blastDust.velocity = Vector2.Zero; + blastDust.noGravity = true; + if (isInTile) { - dust6.noLight = true; + blastDust.noLight = true; } if (Projectile.ai[1] == -1f) { @@ -78,22 +78,22 @@ namespace CalamityMod.Projectiles.Melee Projectile.alpha = 255; if (Projectile.numUpdates == 0) { - int num158 = -1; - float num159 = 60f; - for (int num160 = 0; num160 < Main.maxNPCs; num160++) + int npcTracker = -1; + float homingRange = 60f; + for (int i = 0; i < Main.maxNPCs; i++) { - NPC nPC = Main.npc[num160]; + NPC nPC = Main.npc[i]; if (nPC.CanBeChasedBy(Projectile, false)) { - float num161 = Projectile.Distance(nPC.Center); - if (num161 < num159 && Collision.CanHitLine(Projectile.Center, 0, 0, nPC.Center, 0, 0)) + float npcDistance = Projectile.Distance(nPC.Center); + if (npcDistance < homingRange && Collision.CanHitLine(Projectile.Center, 0, 0, nPC.Center, 0, 0)) { - num159 = num161; - num158 = num160; + homingRange = npcDistance; + npcTracker = i; } } } - if (num158 != -1) + if (npcTracker != -1) { Projectile.ai[0] = 0f; Projectile.ai[1] = -1f; @@ -105,26 +105,26 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - bool flag = WorldGen.SolidTile(Framing.GetTileSafely((int)Projectile.position.X / 16, (int)Projectile.position.Y / 16)); + bool insideTile = WorldGen.SolidTile(Framing.GetTileSafely((int)Projectile.position.X / 16, (int)Projectile.position.Y / 16)); for (int m = 0; m < 4; m++) { Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); } for (int n = 0; n < 4; n++) { - int num10 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 0, default, 2.5f); - Main.dust[num10].noGravity = true; - Main.dust[num10].velocity *= 3f; - if (flag) + int killingPeople = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 0, default, 2.5f); + Main.dust[killingPeople].noGravity = true; + Main.dust[killingPeople].velocity *= 3f; + if (insideTile) { - Main.dust[num10].noLight = true; + Main.dust[killingPeople].noLight = true; } - num10 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); - Main.dust[num10].velocity *= 2f; - Main.dust[num10].noGravity = true; - if (flag) + killingPeople = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); + Main.dust[killingPeople].velocity *= 2f; + Main.dust[killingPeople].noGravity = true; + if (insideTile) { - Main.dust[num10].noLight = true; + Main.dust[killingPeople].noLight = true; } } } diff --git a/Projectiles/Melee/GalaxyBlastType3.cs b/Projectiles/Melee/GalaxyBlastType3.cs index faeee31dc1..42903a8258 100644 --- a/Projectiles/Melee/GalaxyBlastType3.cs +++ b/Projectiles/Melee/GalaxyBlastType3.cs @@ -40,14 +40,14 @@ namespace CalamityMod.Projectiles.Melee Projectile.Kill(); return; } - bool flag5 = WorldGen.SolidTile(Framing.GetTileSafely((int)Projectile.position.X / 16, (int)Projectile.position.Y / 16)); - Dust dust6 = Main.dust[Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 172, 0f, 0f, 0, default, 1f)]; - dust6.position = Projectile.Center; - dust6.velocity = Vector2.Zero; - dust6.noGravity = true; - if (flag5) + bool isInTile = WorldGen.SolidTile(Framing.GetTileSafely((int)Projectile.position.X / 16, (int)Projectile.position.Y / 16)); + Dust blastDust = Main.dust[Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 172, 0f, 0f, 0, default, 1f)]; + blastDust.position = Projectile.Center; + blastDust.velocity = Vector2.Zero; + blastDust.noGravity = true; + if (isInTile) { - dust6.noLight = true; + blastDust.noLight = true; } if (Projectile.ai[1] == -1f) { @@ -77,22 +77,22 @@ namespace CalamityMod.Projectiles.Melee Projectile.alpha = 255; if (Projectile.numUpdates == 0) { - int num158 = -1; - float num159 = 60f; - for (int num160 = 0; num160 < Main.maxNPCs; num160++) + int npcTracker = -1; + float homingRange = 60f; + for (int i = 0; i < Main.maxNPCs; i++) { - NPC nPC = Main.npc[num160]; + NPC nPC = Main.npc[i]; if (nPC.CanBeChasedBy(Projectile, false)) { - float num161 = Projectile.Distance(nPC.Center); - if (num161 < num159 && Collision.CanHitLine(Projectile.Center, 0, 0, nPC.Center, 0, 0)) + float npcDistance = Projectile.Distance(nPC.Center); + if (npcDistance < homingRange && Collision.CanHitLine(Projectile.Center, 0, 0, nPC.Center, 0, 0)) { - num159 = num161; - num158 = num160; + homingRange = npcDistance; + npcTracker = i; } } } - if (num158 != -1) + if (npcTracker != -1) { Projectile.ai[0] = 0f; Projectile.ai[1] = -1f; @@ -111,19 +111,19 @@ namespace CalamityMod.Projectiles.Melee } for (int n = 0; n < 4; n++) { - int num10 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 172, 0f, 0f, 0, default, 2.5f); - Main.dust[num10].noGravity = true; - Main.dust[num10].velocity *= 3f; + int killingPeople = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 172, 0f, 0f, 0, default, 2.5f); + Main.dust[killingPeople].noGravity = true; + Main.dust[killingPeople].velocity *= 3f; if (flag) { - Main.dust[num10].noLight = true; + Main.dust[killingPeople].noLight = true; } - num10 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 172, 0f, 0f, 100, default, 1.5f); - Main.dust[num10].velocity *= 2f; - Main.dust[num10].noGravity = true; + killingPeople = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 172, 0f, 0f, 100, default, 1.5f); + Main.dust[killingPeople].velocity *= 2f; + Main.dust[killingPeople].noGravity = true; if (flag) { - Main.dust[num10].noLight = true; + Main.dust[killingPeople].noLight = true; } } } diff --git a/Projectiles/Melee/GalaxySmasherHammer.cs b/Projectiles/Melee/GalaxySmasherHammer.cs index c644028d7c..abe30ffb78 100644 --- a/Projectiles/Melee/GalaxySmasherHammer.cs +++ b/Projectiles/Melee/GalaxySmasherHammer.cs @@ -18,7 +18,6 @@ namespace CalamityMod.Projectiles.Melee public static readonly SoundStyle UseSound = new("CalamityMod/Sounds/Item/PwnagehammerSound") { Volume = 0.35f }; public static readonly SoundStyle RedHamSound = new("CalamityMod/Sounds/Item/GalaxySmasherClone") { Volume = 0.6f }; public static readonly SoundStyle UseSoundFunny = new("CalamityMod/Sounds/Item/CalamityBell") { Volume = 1.5f }; - private static float StartDustQuantity = 26f; public ref int EmpoweredHammer => ref Main.player[Projectile.owner].Calamity().GalaxyHammer; public int returnhammer = 0; public float rotatehammer = 10f; @@ -242,7 +241,7 @@ namespace CalamityMod.Projectiles.Melee returnhammer = 1; } - if (PulseCooldown >= 15); + if (PulseCooldown >= 15) { Particle pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, Color.Violet, new Vector2(0.5f, 0.5f), Main.rand.NextFloat(12f, 25f), 0.2f, 1.4f + (EmpoweredHammer * 0.1f), 14); GeneralParticleHandler.SpawnParticle(pulse); @@ -254,7 +253,8 @@ namespace CalamityMod.Projectiles.Melee public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - Projectile.damage = (int)(Projectile.damage * 0.9f); + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.9f); if (Projectile.damage < 1) Projectile.damage = 1; } diff --git a/Projectiles/Melee/GalileosMoon.cs b/Projectiles/Melee/GalileosMoon.cs index 5f3d6c1c25..2f4332f0bf 100644 --- a/Projectiles/Melee/GalileosMoon.cs +++ b/Projectiles/Melee/GalileosMoon.cs @@ -27,11 +27,11 @@ namespace CalamityMod.Projectiles.Melee Projectile.DamageType = DamageClass.Melee; Projectile.tileCollide = false; Projectile.penetrate = -1; - Projectile.extraUpdates = 1; + Projectile.extraUpdates = 2; Projectile.timeLeft = 135 * Projectile.MaxUpdates; Projectile.ignoreWater = true; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = Projectile.MaxUpdates * 10; + Projectile.localNPCHitCooldown = Projectile.MaxUpdates * 13; } public override void AI() diff --git a/Projectiles/Melee/GalileosPlanet.cs b/Projectiles/Melee/GalileosPlanet.cs index df5965c35d..fdb5102f85 100644 --- a/Projectiles/Melee/GalileosPlanet.cs +++ b/Projectiles/Melee/GalileosPlanet.cs @@ -103,30 +103,30 @@ namespace CalamityMod.Projectiles.Melee for (int x = 1; x <= 3; x++) { - int num20 = 36; - for (int i = 0; i < num20; i++) + int dustAmt = 36; + for (int i = 0; i < dustAmt; i++) { Vector2 spinningpoint = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f * 0.5f; - spinningpoint = spinningpoint.RotatedBy((double)((float)(i - (num20 / 2 - 1)) * 6.28318548f / (float)num20), default(Vector2)) + Projectile.Center; + spinningpoint = spinningpoint.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default(Vector2)) + Projectile.Center; Vector2 vector = spinningpoint - Projectile.Center; - int num21 = Dust.NewDust(spinningpoint + vector, 0, 0, 180, vector.X * 2f, vector.Y * 2f, 0, new Color(255, 255, 255), 1f); - Main.dust[num21].noGravity = true; - Main.dust[num21].velocity = Vector2.Normalize(vector) * x; + int stratus = Dust.NewDust(spinningpoint + vector, 0, 0, 180, vector.X * 2f, vector.Y * 2f, 0, new Color(255, 255, 255), 1f); + Main.dust[stratus].noGravity = true; + Main.dust[stratus].velocity = Vector2.Normalize(vector) * x; } } for (int x = 1; x <= 3; x++) { - int num20 = 36; - for (int i = 0; i < num20; i++) + int dustAmt = 36; + for (int i = 0; i < dustAmt; i++) { Vector2 spinningpoint = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f * 0.5f; - spinningpoint = spinningpoint.RotatedBy((double)((float)(i - (num20 / 2 - 1)) * 6.28318548f / (float)num20), default(Vector2)) + Projectile.Center; + spinningpoint = spinningpoint.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default(Vector2)) + Projectile.Center; Vector2 vector = spinningpoint - Projectile.Center; - int num21 = Dust.NewDust(spinningpoint + vector, 0, 0, 180, vector.X * 2f, vector.Y * 2f, 0, new Color(255, 255, 255), 1f); - Main.dust[num21].noGravity = true; - Main.dust[num21].velocity = Vector2.Normalize(vector) * x; - Main.dust[num21].velocity *= 2; + int stratus = Dust.NewDust(spinningpoint + vector, 0, 0, 180, vector.X * 2f, vector.Y * 2f, 0, new Color(255, 255, 255), 1f); + Main.dust[stratus].noGravity = true; + Main.dust[stratus].velocity = Vector2.Normalize(vector) * x; + Main.dust[stratus].velocity *= 2; } } diff --git a/Projectiles/Melee/GhastlySoulLarge.cs b/Projectiles/Melee/GhastlySoulLarge.cs index bd5cec0b55..4d4c4c9f5c 100644 --- a/Projectiles/Melee/GhastlySoulLarge.cs +++ b/Projectiles/Melee/GhastlySoulLarge.cs @@ -45,22 +45,21 @@ namespace CalamityMod.Projectiles.Melee { Projectile.frame = 0; } - int num822 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num822]; + int ghostlyDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[ghostlyDust]; dust.velocity *= 0.1f; - Main.dust[num822].scale = 1.3f; - Main.dust[num822].noGravity = true; - float num953 = 30f * Projectile.ai[1]; //100 - float scaleFactor12 = 6f * Projectile.ai[1]; //5 - float num954 = 900f; + Main.dust[ghostlyDust].scale = 1.3f; + Main.dust[ghostlyDust].noGravity = true; + float projVelocityFactor = 30f * Projectile.ai[1]; //100 + float scaleFactor = 6f * Projectile.ai[1]; //5 Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) - 1.57f; Lighting.AddLight(Projectile.Center, 0.5f, 0.2f, 0.9f); if (Main.player[Projectile.owner].active && !Main.player[Projectile.owner].dead) { - if (Projectile.Distance(Main.player[Projectile.owner].Center) > num954) + if (Projectile.Distance(Main.player[Projectile.owner].Center) > 900f) { Vector2 moveDirection = Projectile.SafeDirectionTo(Main.player[Projectile.owner].Center, Vector2.UnitY); - Projectile.velocity = (Projectile.velocity * (num953 - 1f) + moveDirection * scaleFactor12) / num953; + Projectile.velocity = (Projectile.velocity * (projVelocityFactor - 1f) + moveDirection * scaleFactor) / projVelocityFactor; return; } @@ -112,16 +111,16 @@ namespace CalamityMod.Projectiles.Melee Projectile.localNPCHitCooldown = 10; Projectile.Damage(); SoundEngine.PlaySound(SoulEdge.ProjectileDeathSound, Projectile.Center); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int i = 0; i < dustAmt; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 173, vector7.X * 1.5f, vector7.Y * 1.5f, 100, default, 2f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int killedDust = Dust.NewDust(rotate + faceDirection, 0, 0, 173, faceDirection.X * 1.5f, faceDirection.Y * 1.5f, 100, default, 2f); + Main.dust[killedDust].noGravity = true; + Main.dust[killedDust].noLight = true; + Main.dust[killedDust].velocity = faceDirection; } } } diff --git a/Projectiles/Melee/GhastlySoulMedium.cs b/Projectiles/Melee/GhastlySoulMedium.cs index f06353b0d7..617c424eb9 100644 --- a/Projectiles/Melee/GhastlySoulMedium.cs +++ b/Projectiles/Melee/GhastlySoulMedium.cs @@ -45,22 +45,21 @@ namespace CalamityMod.Projectiles.Melee { Projectile.frame = 0; } - int num822 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num822]; + int ghostlyDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[ghostlyDust]; dust.velocity *= 0.1f; - Main.dust[num822].scale = 1.3f; - Main.dust[num822].noGravity = true; - float num953 = 35f * Projectile.ai[1]; //100 - float scaleFactor12 = 7f * Projectile.ai[1]; //5 - float num954 = 900f; + Main.dust[ghostlyDust].scale = 1.3f; + Main.dust[ghostlyDust].noGravity = true; + float projVelocityFactor = 35f * Projectile.ai[1]; //100 + float scaleFactor = 7f * Projectile.ai[1]; //5 Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) - 1.57f; Lighting.AddLight(Projectile.Center, 0.5f, 0.2f, 0.9f); if (Main.player[Projectile.owner].active && !Main.player[Projectile.owner].dead) { - if (Projectile.Distance(Main.player[Projectile.owner].Center) > num954) + if (Projectile.Distance(Main.player[Projectile.owner].Center) > 900f) { Vector2 moveDirection = Projectile.SafeDirectionTo(Main.player[Projectile.owner].Center, Vector2.UnitY); - Projectile.velocity = (Projectile.velocity * (num953 - 1f) + moveDirection * scaleFactor12) / num953; + Projectile.velocity = (Projectile.velocity * (projVelocityFactor - 1f) + moveDirection * scaleFactor) / projVelocityFactor; return; } @@ -112,16 +111,16 @@ namespace CalamityMod.Projectiles.Melee Projectile.localNPCHitCooldown = 10; Projectile.Damage(); SoundEngine.PlaySound(SoulEdge.ProjectileDeathSound, Projectile.Center); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int i = 0; i < dustAmt; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 173, vector7.X * 1.5f, vector7.Y * 1.5f, 100, default, 2f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int killedDust = Dust.NewDust(rotate + faceDirection, 0, 0, 173, faceDirection.X * 1.5f, faceDirection.Y * 1.5f, 100, default, 2f); + Main.dust[killedDust].noGravity = true; + Main.dust[killedDust].noLight = true; + Main.dust[killedDust].velocity = faceDirection; } } } diff --git a/Projectiles/Melee/GhastlySoulSmall.cs b/Projectiles/Melee/GhastlySoulSmall.cs index 6381fc0eca..9b7833bc18 100644 --- a/Projectiles/Melee/GhastlySoulSmall.cs +++ b/Projectiles/Melee/GhastlySoulSmall.cs @@ -44,22 +44,21 @@ namespace CalamityMod.Projectiles.Melee { Projectile.frame = 0; } - int num822 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num822]; + int ghostlyDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[ghostlyDust]; dust.velocity *= 0.1f; - Main.dust[num822].scale = 1.3f; - Main.dust[num822].noGravity = true; - float num953 = 40f * Projectile.ai[1]; //100 - float scaleFactor12 = 8f * Projectile.ai[1]; //5 - float num954 = 900f; + Main.dust[ghostlyDust].scale = 1.3f; + Main.dust[ghostlyDust].noGravity = true; + float projVelocityFactor = 40f * Projectile.ai[1]; //100 + float scaleFactor = 8f * Projectile.ai[1]; //5 Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) - 1.57f; Lighting.AddLight(Projectile.Center, 0.5f, 0.2f, 0.9f); if (Main.player[Projectile.owner].active && !Main.player[Projectile.owner].dead) { - if (Projectile.Distance(Main.player[Projectile.owner].Center) > num954) + if (Projectile.Distance(Main.player[Projectile.owner].Center) > 900f) { Vector2 moveDirection = Projectile.SafeDirectionTo(Main.player[Projectile.owner].Center, Vector2.UnitY); - Projectile.velocity = (Projectile.velocity * (num953 - 1f) + moveDirection * scaleFactor12) / num953; + Projectile.velocity = (Projectile.velocity * (projVelocityFactor - 1f) + moveDirection * scaleFactor) / projVelocityFactor; return; } @@ -111,16 +110,16 @@ namespace CalamityMod.Projectiles.Melee Projectile.localNPCHitCooldown = 10; Projectile.Damage(); SoundEngine.PlaySound(SoulEdge.ProjectileDeathSound, Projectile.Center); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int i = 0; i < dustAmt; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 173, vector7.X * 1.5f, vector7.Y * 1.5f, 100, default, 2f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int killedDust = Dust.NewDust(rotate + faceDirection, 0, 0, 173, faceDirection.X * 1.5f, faceDirection.Y * 1.5f, 100, default, 2f); + Main.dust[killedDust].noGravity = true; + Main.dust[killedDust].noLight = true; + Main.dust[killedDust].velocity = faceDirection; } } } diff --git a/Projectiles/Melee/GreenWater.cs b/Projectiles/Melee/GreenWater.cs index afc132e469..6ea7da0139 100644 --- a/Projectiles/Melee/GreenWater.cs +++ b/Projectiles/Melee/GreenWater.cs @@ -37,10 +37,10 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(SoundID.Item21, Projectile.position); Projectile.localAI[0] += 1f; } - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 5, 0f, 0f, 100, default, 1f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int hitDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 5, 0f, 0f, 100, default, 1f); + Main.dust[hitDust].noGravity = true; + Main.dust[hitDust].velocity *= 0.5f; + Main.dust[hitDust].velocity += Projectile.velocity * 0.1f; } public override bool PreDraw(ref Color lightColor) @@ -55,19 +55,19 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item10, Projectile.Center); - int num3; - for (int num795 = 4; num795 < 31; num795 = num3 + 1) + int inc; + for (int i = 4; i < 31; i = inc + 1) { - float num796 = Projectile.oldVelocity.X * (30f / (float)num795); - float num797 = Projectile.oldVelocity.Y * (30f / (float)num795); - int num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, 5, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); - Main.dust[num798].noGravity = true; - Dust dust = Main.dust[num798]; + float oldXPos = Projectile.oldVelocity.X * (30f / (float)i); + float oldYPos = Projectile.oldVelocity.Y * (30f / (float)i); + int killDust = Dust.NewDust(new Vector2(Projectile.oldPosition.X - oldXPos, Projectile.oldPosition.Y - oldYPos), 8, 8, 5, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); + Main.dust[killDust].noGravity = true; + Dust dust = Main.dust[killDust]; dust.velocity *= 0.5f; - num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, 5, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); - dust = Main.dust[num798]; + killDust = Dust.NewDust(new Vector2(Projectile.oldPosition.X - oldXPos, Projectile.oldPosition.Y - oldYPos), 8, 8, 5, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); + dust = Main.dust[killDust]; dust.velocity *= 0.05f; - num3 = num795; + inc = i; } } diff --git a/Projectiles/Melee/HolyColliderHolyFire.cs b/Projectiles/Melee/HolyColliderHolyFire.cs index 2bf5b20987..8f23dda5c3 100644 --- a/Projectiles/Melee/HolyColliderHolyFire.cs +++ b/Projectiles/Melee/HolyColliderHolyFire.cs @@ -57,9 +57,9 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } @@ -72,20 +72,20 @@ namespace CalamityMod.Projectiles.Melee Projectile.height = 150; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + int holy = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[holy].scale = 0.5f; + Main.dust[holy].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + int holy2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 3f); + Main.dust[holy2].noGravity = true; + holy2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); } } } diff --git a/Projectiles/Melee/HyperBlade.cs b/Projectiles/Melee/HyperBlade.cs index 5698eadd5e..448ba1ffa1 100644 --- a/Projectiles/Melee/HyperBlade.cs +++ b/Projectiles/Melee/HyperBlade.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -29,14 +29,14 @@ namespace CalamityMod.Projectiles.Melee Projectile.MaxUpdates = 3; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 15 * Projectile.MaxUpdates; - Projectile.timeLeft = 120 * Projectile.MaxUpdates; + Projectile.timeLeft = 150 * Projectile.MaxUpdates; } public override void AI() { Lighting.AddLight(Projectile.Center, 0f, 0.5f, 0f); - CalamityUtils.HomeInOnNPC(Projectile, true, 300f, 10f, 10f); + CalamityUtils.HomeInOnNPC(Projectile, true, 350f, 15f, 10f); } public override Color? GetAlpha(Color lightColor) @@ -58,7 +58,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(BuffID.CursedInferno, 120); + target.AddBuff(BuffID.CursedInferno, 180); } } } diff --git a/Projectiles/Melee/IceBombFriendly.cs b/Projectiles/Melee/IceBombFriendly.cs index 5e0f27bbdb..260d58f52f 100644 --- a/Projectiles/Melee/IceBombFriendly.cs +++ b/Projectiles/Melee/IceBombFriendly.cs @@ -57,23 +57,23 @@ namespace CalamityMod.Projectiles.Melee Projectile.ai[0] += 1f; if (Projectile.ai[0] == 120f) { - for (int num621 = 0; num621 < 8; num621++) + for (int i = 0; i < 8; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int icyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 100, default, 2f); + Main.dust[icyDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[icyDust].scale = 0.5f; + Main.dust[icyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 14; num623++) + for (int j = 0; j < 14; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int icyDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 100, default, 3f); + Main.dust[icyDust2].noGravity = true; + Main.dust[icyDust2].velocity *= 5f; + icyDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 100, default, 2f); + Main.dust[icyDust2].velocity *= 2f; } Projectile.scale = 1f; diff --git a/Projectiles/Melee/IllustriousKnife.cs b/Projectiles/Melee/IllustriousKnife.cs index 8a6a77621f..9be56b2def 100644 --- a/Projectiles/Melee/IllustriousKnife.cs +++ b/Projectiles/Melee/IllustriousKnife.cs @@ -62,12 +62,12 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { - for (int num303 = 0; num303 < 3; num303++) + for (int i = 0; i < 3; i++) { - int num304 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 20, 0f, 0f, 100, default, 0.8f); - Main.dust[num304].noGravity = true; - Main.dust[num304].velocity *= 1.2f; - Main.dust[num304].velocity -= Projectile.oldVelocity * 0.3f; + int illustrious = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 20, 0f, 0f, 100, default, 0.8f); + Main.dust[illustrious].noGravity = true; + Main.dust[illustrious].velocity *= 1.2f; + Main.dust[illustrious].velocity -= Projectile.oldVelocity * 0.3f; } } diff --git a/Projectiles/Melee/InsidiousHarpoon.cs b/Projectiles/Melee/InsidiousHarpoon.cs index 68f57203a5..78bdfa9373 100644 --- a/Projectiles/Melee/InsidiousHarpoon.cs +++ b/Projectiles/Melee/InsidiousHarpoon.cs @@ -39,14 +39,14 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.alpha < 0) Projectile.alpha = 0; - int num297 = 171; + int dustType = 171; if (Main.rand.Next(3) == 0) { - num297 = 46; + dustType = 46; } if (Main.rand.NextBool(9)) { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, num297, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); + Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); } if (Projectile.ai[0] == 0f) { @@ -73,10 +73,10 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { - int num297 = 171; + int dustType = 171; if (Main.rand.Next(3) == 0) { - num297 = 46; + dustType = 46; } SoundEngine.PlaySound(SoundID.Item14, Projectile.position); Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); @@ -86,23 +86,23 @@ namespace CalamityMod.Projectiles.Melee Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); Projectile.Damage(); - for (int num621 = 0; num621 < 15; num621++) + for (int i = 0; i < 15; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; + int deathDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 1.2f); + Main.dust[deathDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[deathDust].scale = 0.5f; + Main.dust[deathDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int deathDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 1.7f); + Main.dust[deathDust2].noGravity = true; + Main.dust[deathDust2].velocity *= 5f; + deathDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 1f); + Main.dust[deathDust2].velocity *= 2f; } } diff --git a/Projectiles/Melee/JudgementProj.cs b/Projectiles/Melee/JudgementProj.cs index e2adcefc5e..b20d1aa80f 100644 --- a/Projectiles/Melee/JudgementProj.cs +++ b/Projectiles/Melee/JudgementProj.cs @@ -52,12 +52,12 @@ namespace CalamityMod.Projectiles.Melee Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.5f / 255f); - for (int num457 = 0; num457 < 2; num457++) + for (int i = 0; i < 2; i++) { - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 91, 0f, 0f, 100, default, 1.25f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int shinyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 91, 0f, 0f, 100, default, 1.25f); + Main.dust[shinyDust].noGravity = true; + Main.dust[shinyDust].velocity *= 0.5f; + Main.dust[shinyDust].velocity += Projectile.velocity * 0.1f; } CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, 9f, 20f); diff --git a/Projectiles/Melee/LaserFountain.cs b/Projectiles/Melee/LaserFountain.cs index 93ff1c72d4..2bcf99ec00 100644 --- a/Projectiles/Melee/LaserFountain.cs +++ b/Projectiles/Melee/LaserFountain.cs @@ -30,11 +30,11 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.owner == Main.myPlayer) { int damage = (int)Main.player[Projectile.owner].GetTotalDamage().ApplyTo(350f); - int projectile1 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, Projectile.knockBack, Projectile.owner, 0f, 0f); - if (projectile1.WithinBounds(Main.maxProjectiles)) + int laserShot = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, Projectile.knockBack, Projectile.owner, 0f, 0f); + if (laserShot.WithinBounds(Main.maxProjectiles)) { - Main.projectile[projectile1].DamageType = DamageClass.Melee; - Main.projectile[projectile1].aiStyle = ProjAIStyleID.Arrow; + Main.projectile[laserShot].DamageType = DamageClass.Melee; + Main.projectile[laserShot].aiStyle = ProjAIStyleID.Arrow; } } Projectile.localAI[0] = 0f; diff --git a/Projectiles/Melee/LifeScythe.cs b/Projectiles/Melee/LifeScythe.cs index 67c99eed4a..6fb0490f00 100644 --- a/Projectiles/Melee/LifeScythe.cs +++ b/Projectiles/Melee/LifeScythe.cs @@ -33,9 +33,9 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - float num395 = Main.mouseTextColor / 200f - 0.35f; - num395 *= 0.2f; - Projectile.scale = num395 + 0.95f; + float scaling = Main.mouseTextColor / 200f - 0.35f; + scaling *= 0.2f; + Projectile.scale = scaling + 0.95f; Lighting.AddLight(Projectile.Center, 0.1f, 0.5f, 0.15f); } diff --git a/Projectiles/Melee/LightBeam.cs b/Projectiles/Melee/LightBeam.cs index a0d407eb9c..eb36e4cf2d 100644 --- a/Projectiles/Melee/LightBeam.cs +++ b/Projectiles/Melee/LightBeam.cs @@ -58,11 +58,11 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { - for (int num105 = 0; num105 < 20; num105++) + for (int i = 0; i < 20; i++) { - int num102 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 73, 0f, 0f, 0, default, 1f); - Main.dust[num102].noGravity = true; - Main.dust[num102].velocity += Projectile.velocity * 0.1f; + int pinkish = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 73, 0f, 0f, 0, default, 1f); + Main.dust[pinkish].noGravity = true; + Main.dust[pinkish].velocity += Projectile.velocity * 0.1f; } if (Projectile.owner == Main.myPlayer) { diff --git a/Projectiles/Melee/LuxorsGiftMelee.cs b/Projectiles/Melee/LuxorsGiftMelee.cs index 956805e7d6..3068ea8f1a 100644 --- a/Projectiles/Melee/LuxorsGiftMelee.cs +++ b/Projectiles/Melee/LuxorsGiftMelee.cs @@ -56,15 +56,15 @@ namespace CalamityMod.Projectiles.Melee { for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); - int num9 = Dust.NewDust(Projectile.Center, 0, 0, (int)CalamityDusts.Brimstone, 0f, 0f, 160, default, 1f); - Main.dust[num9].scale = 1.1f; - Main.dust[num9].noGravity = true; - Main.dust[num9].position = Projectile.Center + vector3; - Main.dust[num9].velocity = Projectile.velocity * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; + Vector2 dustRotate = Vector2.UnitX * (float)-(float)Projectile.width / 2f; + dustRotate += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); + dustRotate = dustRotate.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); + int spawnDust = Dust.NewDust(Projectile.Center, 0, 0, (int)CalamityDusts.Brimstone, 0f, 0f, 160, default, 1f); + Main.dust[spawnDust].scale = 1.1f; + Main.dust[spawnDust].noGravity = true; + Main.dust[spawnDust].position = Projectile.Center + dustRotate; + Main.dust[spawnDust].velocity = Projectile.velocity * 0.1f; + Main.dust[spawnDust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[spawnDust].position) * 1.25f; } } } @@ -85,15 +85,15 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(SoundID.Item10, Projectile.position); for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); - int num9 = Dust.NewDust(Projectile.Center, 0, 0, (int)CalamityDusts.Brimstone, 0f, 0f, 160, default, 1f); - Main.dust[num9].scale = 1.1f; - Main.dust[num9].noGravity = true; - Main.dust[num9].position = Projectile.Center + vector3; - Main.dust[num9].velocity = Projectile.velocity * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; + Vector2 dustRotate = Vector2.UnitX * (float)-(float)Projectile.width / 2f; + dustRotate += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); + dustRotate = dustRotate.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); + int spawnDust = Dust.NewDust(Projectile.Center, 0, 0, (int)CalamityDusts.Brimstone, 0f, 0f, 160, default, 1f); + Main.dust[spawnDust].scale = 1.1f; + Main.dust[spawnDust].noGravity = true; + Main.dust[spawnDust].position = Projectile.Center + dustRotate; + Main.dust[spawnDust].velocity = Projectile.velocity * 0.1f; + Main.dust[spawnDust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[spawnDust].position) * 1.25f; } if (Projectile.velocity.X != oldVelocity.X) { diff --git a/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrence.cs b/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrence.cs index 4e1913951a..1c704c6301 100644 --- a/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrence.cs +++ b/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrence.cs @@ -166,7 +166,7 @@ namespace CalamityMod.Projectiles.Melee //Scaling based on charge Projectile.scale = 1f + (Charge / MaxCharge * 0.3f); - Owner.direction = Math.Sign(direction.X); + Owner.ChangeDir(Math.Sign(direction.X)); Owner.itemRotation = direction.ToRotation(); if (Owner.direction != 1) diff --git a/Projectiles/Melee/MendedBiomeBlade_GestureForTheDrowned.cs b/Projectiles/Melee/MendedBiomeBlade_GestureForTheDrowned.cs index d7a545fb43..3cfc38c2de 100644 --- a/Projectiles/Melee/MendedBiomeBlade_GestureForTheDrowned.cs +++ b/Projectiles/Melee/MendedBiomeBlade_GestureForTheDrowned.cs @@ -49,7 +49,7 @@ namespace CalamityMod.Projectiles.Melee direction = Vector2.UnitY.RotatedBy((MathHelper.PiOver4 + Utils.AngleLerp(0f, MathHelper.PiOver4 * 1.5f, HalfTimer / 20f)) * Math.Sign(Timer - 1 - 20f)) * (float)Math.Sin(HalfTimer / 20f * MathHelper.Pi) * 30; - Owner.direction = Math.Sign(direction.X); + Owner.ChangeDir(Math.Sign(direction.X)); Owner.itemRotation = direction.ToRotation(); if (Owner.direction != 1) { diff --git a/Projectiles/Melee/MendedBiomeBlade_HeavensMight.cs b/Projectiles/Melee/MendedBiomeBlade_HeavensMight.cs index a7e4c331fb..e72bf5ead3 100644 --- a/Projectiles/Melee/MendedBiomeBlade_HeavensMight.cs +++ b/Projectiles/Melee/MendedBiomeBlade_HeavensMight.cs @@ -179,7 +179,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(direction.X); + Owner.ChangeDir(Math.Sign(direction.X)); Owner.itemRotation = direction.ToRotation(); if (Owner.direction != 1) { diff --git a/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeur.cs b/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeur.cs index 79151a8c05..838e3b442a 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeur.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeur.cs @@ -137,7 +137,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(direction.X); + Owner.ChangeDir(Math.Sign(direction.X)); Owner.itemRotation = direction.ToRotation(); if (Owner.direction != 1) { diff --git a/Projectiles/Melee/MendedBiomeBlade_TrueBitingEmbrace.cs b/Projectiles/Melee/MendedBiomeBlade_TrueBitingEmbrace.cs index f8d0ae5130..57368f1322 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TrueBitingEmbrace.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TrueBitingEmbrace.cs @@ -175,7 +175,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(rotation.ToRotationVector2().X); + Owner.ChangeDir(Math.Sign(rotation.ToRotationVector2().X)); Owner.itemRotation = rotation; if (Owner.direction != 1) { diff --git a/Projectiles/Melee/MendedBiomeBlade_TrueDecaysRetort.cs b/Projectiles/Melee/MendedBiomeBlade_TrueDecaysRetort.cs index a6d54f4d91..c0013c4aee 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TrueDecaysRetort.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TrueDecaysRetort.cs @@ -111,7 +111,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(direction.X); + Owner.ChangeDir(Math.Sign(direction.X)); Owner.itemRotation = direction.ToRotation(); if (Owner.direction != 1) { diff --git a/Projectiles/Melee/MendedBiomeBlade_TrueGrovetendersTouch.cs b/Projectiles/Melee/MendedBiomeBlade_TrueGrovetendersTouch.cs index 06f108bb7b..fe00ddb07e 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TrueGrovetendersTouch.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TrueGrovetendersTouch.cs @@ -179,7 +179,7 @@ namespace CalamityMod.Projectiles.Melee SnapCoyoteTime--; } - Owner.direction = Math.Sign(Projectile.velocity.X); + Owner.ChangeDir(Math.Sign(Projectile.velocity.X)); Projectile.rotation = Projectile.AngleFrom(Owner.Center); //Point away from playah float ratio = GetSwingRatio(); diff --git a/Projectiles/Melee/MirrorBlast.cs b/Projectiles/Melee/MirrorBlast.cs index 433c182b49..78194da957 100644 --- a/Projectiles/Melee/MirrorBlast.cs +++ b/Projectiles/Melee/MirrorBlast.cs @@ -28,17 +28,17 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - int num123 = (int)Player.FindClosest(Projectile.Center, 1, 1); + int playerOwner = (int)Player.FindClosest(Projectile.Center, 1, 1); Projectile.ai[1] += 1f; if (Projectile.ai[1] < 110f && Projectile.ai[1] > 30f) { - float scaleFactor2 = Projectile.velocity.Length(); - Vector2 vector17 = Main.player[num123].Center - Projectile.Center; - vector17.Normalize(); - vector17 *= scaleFactor2; - Projectile.velocity = (Projectile.velocity * 24f + vector17) / 25f; + float scaleFactor = Projectile.velocity.Length(); + Vector2 projDirection = Main.player[playerOwner].Center - Projectile.Center; + projDirection.Normalize(); + projDirection *= scaleFactor; + Projectile.velocity = (Projectile.velocity * 24f + projDirection) / 25f; Projectile.velocity.Normalize(); - Projectile.velocity *= scaleFactor2; + Projectile.velocity *= scaleFactor; } if (Projectile.velocity.Length() < 18f) diff --git a/Projectiles/Melee/MourningSkull.cs b/Projectiles/Melee/MourningSkull.cs index 6ec657800a..6f056934c1 100644 --- a/Projectiles/Melee/MourningSkull.cs +++ b/Projectiles/Melee/MourningSkull.cs @@ -58,38 +58,37 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.ai[0] >= 0f && Projectile.ai[0] < 200f) { - int num554 = (int)Projectile.ai[0]; - if (Main.npc[num554].active) + int npcTracker = (int)Projectile.ai[0]; + if (Main.npc[npcTracker].active) { - float num555 = 8f; - Vector2 vector44 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num556 = Main.npc[num554].position.X - vector44.X; - float num557 = Main.npc[num554].position.Y - vector44.Y; - float num558 = (float)Math.Sqrt((double)(num556 * num556 + num557 * num557)); - num558 = num555 / num558; - num556 *= num558; - num557 *= num558; - Projectile.velocity.X = (Projectile.velocity.X * 14f + num556) / 15f; - Projectile.velocity.Y = (Projectile.velocity.Y * 14f + num557) / 15f; + Vector2 projPos = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float npcXDist = Main.npc[npcTracker].position.X - projPos.X; + float npcYDist = Main.npc[npcTracker].position.Y - projPos.Y; + float npcDistance = (float)Math.Sqrt((double)(npcXDist * npcXDist + npcYDist * npcYDist)); + npcDistance = 8f / npcDistance; + npcXDist *= npcDistance; + npcYDist *= npcDistance; + Projectile.velocity.X = (Projectile.velocity.X * 14f + npcXDist) / 15f; + Projectile.velocity.Y = (Projectile.velocity.Y * 14f + npcYDist) / 15f; } else { - float num559 = 1000f; - int num3; - for (int num560 = 0; num560 < Main.maxNPCs; num560 = num3 + 1) + float homingRange = 1000f; + int inc; + for (int j = 0; j < Main.maxNPCs; j = inc + 1) { - if (Main.npc[num560].CanBeChasedBy(Projectile, false)) + if (Main.npc[j].CanBeChasedBy(Projectile, false)) { - float num561 = Main.npc[num560].position.X + (float)(Main.npc[num560].width / 2); - float num562 = Main.npc[num560].position.Y + (float)(Main.npc[num560].height / 2); - float num563 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num561) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num562); - if (num563 < num559 && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[num560].position, Main.npc[num560].width, Main.npc[num560].height)) + float targetX = Main.npc[j].position.X + (float)(Main.npc[j].width / 2); + float targetY = Main.npc[j].position.Y + (float)(Main.npc[j].height / 2); + float targetDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - targetX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - targetY); + if (targetDist < homingRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[j].position, Main.npc[j].width, Main.npc[j].height)) { - num559 = num563; - Projectile.ai[0] = (float)num560; + homingRange = targetDist; + Projectile.ai[0] = (float)j; } } - num3 = num560; + inc = j; } } @@ -104,15 +103,15 @@ namespace CalamityMod.Projectiles.Melee Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X); } - int num564 = 8; - int num565 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num564, Projectile.position.Y + (float)num564), Projectile.width - num564 * 2, Projectile.height - num564 * 2, Main.rand.NextBool() ? 5 : 6, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num565]; + int eightConst = 8; + int mourningDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)eightConst, Projectile.position.Y + (float)eightConst), Projectile.width - eightConst * 2, Projectile.height - eightConst * 2, Main.rand.NextBool() ? 5 : 6, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[mourningDust]; dust.velocity *= 0.5f; - dust = Main.dust[num565]; + dust = Main.dust[mourningDust]; dust.velocity += Projectile.velocity * 0.5f; - Main.dust[num565].noGravity = true; - Main.dust[num565].noLight = true; - Main.dust[num565].scale = 1.4f; + Main.dust[mourningDust].noGravity = true; + Main.dust[mourningDust].noLight = true; + Main.dust[mourningDust].scale = 1.4f; return; } @@ -133,23 +132,23 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item10, Projectile.position); - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 5, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int bloody = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 5, 0f, 0f, 100, default, 2f); + Main.dust[bloody].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[bloody].scale = 0.5f; + Main.dust[bloody].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int fiery = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 3f); + Main.dust[fiery].noGravity = true; + Main.dust[fiery].velocity *= 5f; + fiery = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 2f); + Main.dust[fiery].velocity *= 2f; } } diff --git a/Projectiles/Melee/MurasamaSlash.cs b/Projectiles/Melee/MurasamaSlash.cs index 8d6181b299..f4a7905ee7 100644 --- a/Projectiles/Melee/MurasamaSlash.cs +++ b/Projectiles/Melee/MurasamaSlash.cs @@ -1,5 +1,7 @@ using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; +using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -14,8 +16,11 @@ namespace CalamityMod.Projectiles.Melee public class MurasamaSlash : ModProjectile, ILocalizedModType { public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + private Player Owner => Main.player[Projectile.owner]; + public ref int hitCooldown => ref Main.player[Projectile.owner].Calamity().murasamaHitCooldown; public int frameX = 0; public int frameY = 0; + public int time = 0; public int CurrentFrame { @@ -27,23 +32,21 @@ namespace CalamityMod.Projectiles.Melee } } - // A "slash" is only present during 2 specific frames (ones with a slash effect) right before they transition to the next frame. - // Note: This bool is unused. Murasama formerly only dealt damage when on these frames, but it created a few issues with player usability. - public bool Slashing => CurrentFrame % 7 == 0 && Projectile.frameCounter % 3 == 2; + public bool Slashing = false; public override void SetDefaults() { Projectile.width = 236; - Projectile.height = 180; - Projectile.scale = 2f; + Projectile.height = 236; + Projectile.scale = 1f; Projectile.friendly = true; Projectile.penetrate = -1; Projectile.tileCollide = false; Projectile.DamageType = TrueMeleeNoSpeedDamageClass.Instance; - Projectile.ownerHitCheck = true; Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 21; + Projectile.idStaticNPCHitCooldown = 6; Projectile.frameCounter = 0; + Projectile.alpha = 255; } public override bool PreDraw(ref Color lightColor) @@ -60,7 +63,47 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { + if (time == 0) + { + if (Main.zenithWorld) + Projectile.scale = 2; + CurrentFrame = Main.zenithWorld ? 6 : 10; + Projectile.alpha = 0; + time++; + } Player player = Main.player[Projectile.owner]; + if (CurrentFrame == 0) + { + SoundEngine.PlaySound(Murasama.Swing with { Pitch = -0.1f }, Projectile.Center); + if (hitCooldown == 0) + Slashing = true; + Projectile.numHits = 0; + } + else if (CurrentFrame == 6) + { + SoundEngine.PlaySound(Murasama.BigSwing with { Pitch = 0f }, Projectile.Center); + if (hitCooldown == 0) + Slashing = true; + Projectile.numHits = 0; + } + else if (CurrentFrame == 10) + { + SoundEngine.PlaySound(Murasama.Swing with { Pitch = -0.05f }, Projectile.Center); + if (hitCooldown == 0) + Slashing = true; + Projectile.numHits = 0; + } + else + Slashing = false; + + if (CurrentFrame == 5 && Projectile.frameCounter % 3 == 0) + { + Projectile.damage = (int)(Projectile.damage * 2); + } + if (CurrentFrame == 7 && Projectile.frameCounter % 3 == 0) + { + Projectile.damage = (int)(Projectile.damage * 0.5f); + } //Frames and crap Projectile.frameCounter++; @@ -71,21 +114,8 @@ namespace CalamityMod.Projectiles.Melee CurrentFrame = 0; } - // Play a "droning" noise every so often. - if (Slashing) - { - SoundEngine.PlaySound(SoundID.Item15, Projectile.Center); - } - - // Create idle light and dust. Vector2 origin = Projectile.Center + Projectile.velocity * 3f; - Lighting.AddLight(origin, 3f, 0.2f, 0.2f); - if (Main.rand.NextBool(3)) - { - int redDust = Dust.NewDust(origin - Projectile.Size / 2f, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 2f); - Main.dust[redDust].noGravity = true; - Main.dust[redDust].position -= Projectile.velocity; - } + Lighting.AddLight(origin, Color.Red.ToVector3() * (Slashing == true ? 3.5f : 2f)); Vector2 playerRotatedPoint = player.RotatedRelativePoint(player.MountedCenter, true); if (Main.myPlayer == Projectile.owner) @@ -93,17 +123,24 @@ namespace CalamityMod.Projectiles.Melee if (player.channel && !player.noItems && !player.CCed) HandleChannelMovement(player, playerRotatedPoint); else + { + hitCooldown = Main.zenithWorld ? 0 : 8; Projectile.Kill(); + } } // Rotation and directioning. - float velocityAngle = Projectile.velocity.ToRotation(); - Projectile.rotation = velocityAngle + (Projectile.spriteDirection == -1).ToInt() * MathHelper.Pi; - Projectile.direction = (Math.Cos(velocityAngle) > 0).ToDirectionInt(); + if (Slashing || CurrentFrame == 10) + { + float velocityAngle = Projectile.velocity.ToRotation(); + Projectile.rotation = velocityAngle + (Projectile.spriteDirection == -1).ToInt() * MathHelper.Pi; + } + float velocityAngle2 = Projectile.velocity.ToRotation(); + Projectile.direction = (Math.Cos(velocityAngle2) > 0).ToDirectionInt(); // Positioning close to the end of the player's arm. float offset = 80f * Projectile.scale; - Projectile.position = playerRotatedPoint - Projectile.Size * 0.5f + velocityAngle.ToRotationVector2() * offset; + Projectile.position = playerRotatedPoint - Projectile.Size * 0.5f + velocityAngle2.ToRotationVector2() * offset; // Sprite and player directioning. Projectile.spriteDirection = Projectile.direction; @@ -129,15 +166,65 @@ namespace CalamityMod.Projectiles.Melee Vector2 newVelocity = (Main.MouseWorld - playerRotatedPoint).SafeNormalize(Vector2.UnitX * player.direction) * speed; // Sync if a velocity component changes. - if (Projectile.velocity.X != newVelocity.X || Projectile.velocity.Y != newVelocity.Y) + if (Slashing) { - Projectile.netUpdate = true; + if (Projectile.velocity.X != newVelocity.X || Projectile.velocity.Y != newVelocity.Y) + { + Projectile.netUpdate = true; + } + Projectile.velocity = newVelocity; } - Projectile.velocity = newVelocity; } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (target.Organic()) + SoundEngine.PlaySound(Murasama.OrganicHit with { Pitch = (CurrentFrame == 0 ? -0.1f : CurrentFrame == 6 ? 0.1f : CurrentFrame == 10 ? -0.15f : 0) }, Projectile.Center); + else + SoundEngine.PlaySound(Murasama.InorganicHit with { Pitch = (CurrentFrame == 0 ? -0.1f : CurrentFrame == 6 ? 0.1f : CurrentFrame == 10 ? -0.15f : 0) }, Projectile.Center); + for (int i = 0; i < 3; i++) + { + Color impactColor = CurrentFrame == 6 ? Main.rand.NextBool(3) ? Color.LightCoral : Color.White : Main.rand.NextBool(4) ? Color.LightCoral : Color.Crimson; + float impactParticleScale = Main.rand.NextFloat(1f, 1.75f); + + if (CurrentFrame == 6) + { + SparkleParticle impactParticle2 = new SparkleParticle(target.Center + Main.rand.NextVector2Circular(target.width * 0.75f, target.height * 0.75f), Vector2.Zero, Color.White, Color.Red, impactParticleScale * 1.2f, 8, 0, 4.5f); + GeneralParticleHandler.SpawnParticle(impactParticle2); + } + SparkleParticle impactParticle = new SparkleParticle(target.Center + Main.rand.NextVector2Circular(target.width * 0.75f, target.height * 0.75f), Vector2.Zero, impactColor, Color.Red, impactParticleScale, 8, 0, 2.5f); + GeneralParticleHandler.SpawnParticle(impactParticle); + } + + float sparkCount = MathHelper.Clamp(CurrentFrame == 6 ? 18 - Projectile.numHits * 3 : 5 - Projectile.numHits * 2, 0, 18); + for (int i = 0; i < sparkCount; i++) + { + Vector2 sparkVelocity2 = Projectile.velocity.RotatedBy(CurrentFrame == 0 ? -0.45f * Owner.direction : CurrentFrame == 6 ? 0 : CurrentFrame == 10 ? 0.45f * Owner.direction : 0).RotatedByRandom(0.35f) * Main.rand.NextFloat(0.5f, 1.8f); + int sparkLifetime2 = Main.rand.Next(23, 35); + float sparkScale2 = Main.rand.NextFloat(0.95f, 1.8f); + Color sparkColor2 = CurrentFrame == 6 ? Main.rand.NextBool(3) ? Color.Red : Color.IndianRed : Main.rand.NextBool() ? Color.Red : Color.Firebrick; + if (Main.rand.NextBool()) + { + AltSparkParticle spark = new AltSparkParticle(target.Center + Main.rand.NextVector2Circular(target.width * 0.5f, target.height * 0.5f) + Projectile.velocity * 1.2f, sparkVelocity2 * (CurrentFrame == 6 ? 1f : 0.65f), false, (int)(sparkLifetime2 * (CurrentFrame == 6 ? 1.2f : 1f)), sparkScale2 * (CurrentFrame == 6 ? 1.4f : 1f), sparkColor2); + GeneralParticleHandler.SpawnParticle(spark); + } + else + { + LineParticle spark = new LineParticle(target.Center + Main.rand.NextVector2Circular(target.width * 0.5f, target.height * 0.5f) + Projectile.velocity * 1.2f, sparkVelocity2 * (CurrentFrame == 7 ? 1f : 0.65f), false, (int)(sparkLifetime2 * (CurrentFrame == 7 ? 1.2f : 1f)), sparkScale2 * (CurrentFrame == 7 ? 1.4f : 1f), Main.rand.NextBool() ? Color.Red : Color.Firebrick); + GeneralParticleHandler.SpawnParticle(spark); + } + } + float dustCount = MathHelper.Clamp(CurrentFrame == 6 ? 25 - Projectile.numHits * 3 : 12 - Projectile.numHits * 2, 0, 25); + for (int i = 0; i <= dustCount; i++) + { + int dustID = Main.rand.NextBool(3) ? 182 : Main.rand.NextBool() ? CurrentFrame == 6 ? 309 : 296 : 90; + Dust dust2 = Dust.NewDustPerfect(target.Center + Main.rand.NextVector2Circular(target.width * 0.5f, target.height * 0.5f), dustID, Projectile.velocity.RotatedBy(CurrentFrame == 0 ? -0.45f * Owner.direction : CurrentFrame == 6 ? 0 : CurrentFrame == 10 ? 0.45f * Owner.direction : 0).RotatedByRandom(0.55f) * Main.rand.NextFloat(0.3f, 1.1f)); + dust2.scale = Main.rand.NextFloat(0.9f, 2.4f); + dust2.noGravity = true; + } + } public override Color? GetAlpha(Color lightColor) => new Color(200, 0, 0, 0); - //public override bool? CanDamage() => Slashing; + public override bool? CanDamage() => Slashing == false ? false : null; } } diff --git a/Projectiles/Melee/Nebudust.cs b/Projectiles/Melee/Nebudust.cs index ad433e2bd8..7371c95e26 100644 --- a/Projectiles/Melee/Nebudust.cs +++ b/Projectiles/Melee/Nebudust.cs @@ -28,43 +28,43 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { Lighting.AddLight(Projectile.Center, 0.5f, 0.5f, 0f); - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 60f) { - num461 -= (Projectile.ai[0] - 60f) / 2f; + projTimer -= (Projectile.ai[0] - 60f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; if (Projectile.ai[0] == 0f) { SoundEngine.PlaySound(SoundID.Item105, Projectile.position); } Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-6, 7); - float num464 = (float)Main.rand.Next(-6, 7); - float num465 = (float)Main.rand.Next(2, 5); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 269, 0f, 0f, 100, default, 1f); - Main.dust[num467].noGravity = true; - Main.dust[num467].position.X = Projectile.Center.X; - Main.dust[num467].position.Y = Projectile.Center.Y; - Dust expr_149DF_cp_0 = Main.dust[num467]; + float rando1 = (float)Main.rand.Next(-6, 7); + float rando2 = (float)Main.rand.Next(-6, 7); + float rando5 = (float)Main.rand.Next(2, 5); + float randoAdjuster = (float)Math.Sqrt((double)(rando1 * rando1 + rando2 * rando2)); + randoAdjuster = rando5 / randoAdjuster; + rando1 *= randoAdjuster; + rando2 *= randoAdjuster; + int astra = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 269, 0f, 0f, 100, default, 1f); + Main.dust[astra].noGravity = true; + Main.dust[astra].position.X = Projectile.Center.X; + Main.dust[astra].position.Y = Projectile.Center.Y; + Dust expr_149DF_cp_0 = Main.dust[astra]; expr_149DF_cp_0.position.X += (float)Main.rand.Next(-10, 11); - Dust expr_14A09_cp_0 = Main.dust[num467]; + Dust expr_14A09_cp_0 = Main.dust[astra]; expr_14A09_cp_0.position.Y += (float)Main.rand.Next(-10, 11); - Main.dust[num467].velocity.X = num463; - Main.dust[num467].velocity.Y = num464; - num462++; + Main.dust[astra].velocity.X = rando1; + Main.dust[astra].velocity.Y = rando2; + timerCounter++; } } } diff --git a/Projectiles/Melee/NebulaShot.cs b/Projectiles/Melee/NebulaShot.cs index 0eca731392..0d1af76fbf 100644 --- a/Projectiles/Melee/NebulaShot.cs +++ b/Projectiles/Melee/NebulaShot.cs @@ -42,14 +42,14 @@ namespace CalamityMod.Projectiles.Melee Projectile.alpha = 0; } Lighting.AddLight(Projectile.Center, 0.4f, 0.2f, 0.4f); - for (int num121 = 0; num121 < 5; num121++) + for (int i = 0; i < 5; i++) { - Dust dust4 = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, Main.rand.NextBool(3) ? 56 : 242, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f)]; - dust4.velocity = Vector2.Zero; - dust4.position -= Projectile.velocity / 5f * (float)num121; - dust4.noGravity = true; - dust4.scale = 0.8f; - dust4.noLight = true; + Dust dustSpawn = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, Main.rand.NextBool(3) ? 56 : 242, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f)]; + dustSpawn.velocity = Vector2.Zero; + dustSpawn.position -= Projectile.velocity / 5f * (float)i; + dustSpawn.noGravity = true; + dustSpawn.scale = 0.8f; + dustSpawn.noLight = true; } } diff --git a/Projectiles/Melee/NebulashFlail.cs b/Projectiles/Melee/NebulashFlail.cs index f8a50b26ca..04c51a2b4f 100644 --- a/Projectiles/Melee/NebulashFlail.cs +++ b/Projectiles/Melee/NebulashFlail.cs @@ -1,9 +1,9 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; +using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; -using CalamityMod.Projectiles.BaseProjectiles; namespace CalamityMod.Projectiles.Melee { @@ -40,8 +40,8 @@ namespace CalamityMod.Projectiles.Melee { return true; } - float num8 = 0f; - if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center + Projectile.velocity, 16f * Projectile.scale, ref num8)) + float useless = 0f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center + Projectile.velocity, 16f * Projectile.scale, ref useless)) { return true; } diff --git a/Projectiles/Melee/NeptuneOrb.cs b/Projectiles/Melee/NeptuneOrb.cs index 8f7bc1b7a8..bd0cb4164d 100644 --- a/Projectiles/Melee/NeptuneOrb.cs +++ b/Projectiles/Melee/NeptuneOrb.cs @@ -34,10 +34,10 @@ namespace CalamityMod.Projectiles.Melee int splitDamage = Projectile.damage / 2; Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 15f, ModContent.ProjectileType(), splitDamage, Projectile.knockBack, Projectile.owner, 0f, 0f); } - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 0.4f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int waterDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 0.4f); + Main.dust[waterDust].noGravity = true; + Main.dust[waterDust].velocity *= 0.5f; + Main.dust[waterDust].velocity += Projectile.velocity * 0.1f; } public override bool PreDraw(ref Color lightColor) @@ -64,22 +64,22 @@ namespace CalamityMod.Projectiles.Melee Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); for (int dustIndex = 0; dustIndex <= 30; dustIndex++) { - float num463 = (float)Main.rand.Next(-10, 11); - float num464 = (float)Main.rand.Next(-10, 11); - float num465 = (float)Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 1.2f); - Dust dust = Main.dust[num467]; + float rando1 = (float)Main.rand.Next(-10, 11); + float rando2 = (float)Main.rand.Next(-10, 11); + float rando3 = (float)Main.rand.Next(3, 9); + float randoAdjuster = (float)Math.Sqrt((double)(rando1 * rando1 + rando2 * rando2)); + randoAdjuster = rando3 / randoAdjuster; + rando1 *= randoAdjuster; + rando2 *= randoAdjuster; + int killWatery = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 1.2f); + Dust dust = Main.dust[killWatery]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; + dust.velocity.X = rando1; + dust.velocity.Y = rando2; } Projectile.maxPenetrate = -1; Projectile.penetrate = -1; diff --git a/Projectiles/Melee/Orbacle.cs b/Projectiles/Melee/Orbacle.cs index 45e1a73cce..afb422575d 100644 --- a/Projectiles/Melee/Orbacle.cs +++ b/Projectiles/Melee/Orbacle.cs @@ -7,6 +7,7 @@ namespace CalamityMod.Projectiles.Melee public class Orbacle : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; + public override string Texture => "CalamityMod/ExtraTextures/TinyGreyscaleCircle"; private static int Lifetime = 40; public override void SetDefaults() diff --git a/Projectiles/Melee/OrderbringerAura.cs b/Projectiles/Melee/OrderbringerAura.cs index efc1899506..ebf5317dae 100644 --- a/Projectiles/Melee/OrderbringerAura.cs +++ b/Projectiles/Melee/OrderbringerAura.cs @@ -38,9 +38,9 @@ namespace CalamityMod.Projectiles.Melee Projectile.ai[0] = 0f; if (Projectile.owner == Main.myPlayer) { - int num414 = (int)(Projectile.position.X + 14f + (float)Main.rand.Next(Projectile.width - 28)); - int num415 = (int)(Projectile.position.Y + (float)Projectile.height + 4f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)num414, (float)num415, 0f, 10f, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner, 0f, 0f); + int randOrbXOffset = (int)(Projectile.position.X + 14f + (float)Main.rand.Next(Projectile.width - 28)); + int randOrbYOffset = (int)(Projectile.position.Y + (float)Projectile.height + 4f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)randOrbXOffset, (float)randOrbYOffset, 0f, 10f, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner, 0f, 0f); } } } @@ -48,26 +48,26 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.localAI[0] >= 10f) { Projectile.localAI[0] = 0f; - int num416 = 0; - int num417 = 0; - float num418 = 0f; - int num419 = Projectile.type; - for (int num420 = 0; num420 < 1000; num420++) + int projTimer = 0; + int incTracker = 0; + float aiTracker = 0f; + int theProjectile = Projectile.type; + for (int i = 0; i < 1000; i++) { - if (Main.projectile[num420].active && Main.projectile[num420].owner == Projectile.owner && Main.projectile[num420].type == num419 && Main.projectile[num420].ai[1] < 3600f) + if (Main.projectile[i].active && Main.projectile[i].owner == Projectile.owner && Main.projectile[i].type == theProjectile && Main.projectile[i].ai[1] < 3600f) { - num416++; - if (Main.projectile[num420].ai[1] > num418) + projTimer++; + if (Main.projectile[i].ai[1] > aiTracker) { - num417 = num420; - num418 = Main.projectile[num420].ai[1]; + incTracker = i; + aiTracker = Main.projectile[i].ai[1]; } } } - if (num416 > 1) + if (projTimer > 1) { - Main.projectile[num417].netUpdate = true; - Main.projectile[num417].ai[1] = 36000f; + Main.projectile[incTracker].netUpdate = true; + Main.projectile[incTracker].ai[1] = 36000f; } } } diff --git a/Projectiles/Melee/OrderbringerBeam.cs b/Projectiles/Melee/OrderbringerBeam.cs index aea11d746d..a8a03a1073 100644 --- a/Projectiles/Melee/OrderbringerBeam.cs +++ b/Projectiles/Melee/OrderbringerBeam.cs @@ -83,10 +83,10 @@ namespace CalamityMod.Projectiles.Melee whiteLightTimer = 5; } - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.6f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int rainbow = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.6f); + Main.dust[rainbow].noGravity = true; + Main.dust[rainbow].velocity *= 0.5f; + Main.dust[rainbow].velocity += Projectile.velocity * 0.1f; CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, 10f, 20f); } @@ -108,19 +108,19 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item122, Projectile.Center); - for (int num193 = 0; num193 < 2; num193++) + for (int i = 0; i < 2; i++) { int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.5f); Main.dust[dust].noGravity = true; } - for (int num194 = 0; num194 < 20; num194++) + for (int j = 0; j < 20; j++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int deathRainbow = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 2.5f); + Main.dust[deathRainbow].noGravity = true; + Main.dust[deathRainbow].velocity *= 3f; + deathRainbow = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.5f); + Main.dust[deathRainbow].velocity *= 2f; + Main.dust[deathRainbow].noGravity = true; } if (Projectile.owner == Main.myPlayer) { diff --git a/Projectiles/Melee/OrderbringerRain.cs b/Projectiles/Melee/OrderbringerRain.cs index b07864691c..8bdedf01ad 100644 --- a/Projectiles/Melee/OrderbringerRain.cs +++ b/Projectiles/Melee/OrderbringerRain.cs @@ -34,12 +34,12 @@ namespace CalamityMod.Projectiles.Melee Lighting.AddLight((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16, (float)Main.DiscoR / 200f, (float)Main.DiscoG / 200f, (float)Main.DiscoB / 200f); - for (int num457 = 0; num457 < 2; num457++) + for (int i = 0; i < 2; i++) { - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int rainbow = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Main.dust[rainbow].noGravity = true; + Main.dust[rainbow].velocity *= 0.5f; + Main.dust[rainbow].velocity += Projectile.velocity * 0.1f; } CalamityUtils.HomeInOnNPC(Projectile, true, 200f, 12f, 20f); diff --git a/Projectiles/Melee/OrderbringerWhiteOrb.cs b/Projectiles/Melee/OrderbringerWhiteOrb.cs index 8b57e374b8..cd05a3c73d 100644 --- a/Projectiles/Melee/OrderbringerWhiteOrb.cs +++ b/Projectiles/Melee/OrderbringerWhiteOrb.cs @@ -24,12 +24,12 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { Lighting.AddLight((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16, (float)Main.DiscoR / 200f, (float)Main.DiscoG / 200f, (float)Main.DiscoB / 200f); - for (int num457 = 0; num457 < 2; num457++) + for (int i = 0; i < 2; i++) { - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int rainbow = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Main.dust[rainbow].noGravity = true; + Main.dust[rainbow].velocity *= 0.5f; + Main.dust[rainbow].velocity += Projectile.velocity * 0.1f; } } } diff --git a/Projectiles/Melee/PlagueSeeker.cs b/Projectiles/Melee/PlagueSeeker.cs index a60634f4e0..c3ecf585ce 100644 --- a/Projectiles/Melee/PlagueSeeker.cs +++ b/Projectiles/Melee/PlagueSeeker.cs @@ -37,11 +37,11 @@ namespace CalamityMod.Projectiles.Melee Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { - for (int num468 = 0; num468 < 3; num468++) + for (int i = 0; i < 3; i++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, default, 0.75f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int plagued = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, default, 0.75f); + Main.dust[plagued].noGravity = true; + Main.dust[plagued].velocity *= 0f; } } diff --git a/Projectiles/Melee/RSSolarFlare.cs b/Projectiles/Melee/RSSolarFlare.cs index b94a5734c0..ca34f204d8 100644 --- a/Projectiles/Melee/RSSolarFlare.cs +++ b/Projectiles/Melee/RSSolarFlare.cs @@ -1,11 +1,12 @@ -using CalamityMod.Buffs.DamageOverTime; +using System; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; + namespace CalamityMod.Projectiles.Melee { public class RSSolarFlare : ModProjectile, ILocalizedModType @@ -72,9 +73,9 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } @@ -84,10 +85,9 @@ namespace CalamityMod.Projectiles.Melee double startAngle = Math.Atan2(Projectile.velocity.X, Projectile.velocity.Y) - spread / 2; double deltaAngle = spread / 8f; double offsetAngle; - int i; if (Projectile.owner == Main.myPlayer) { - for (i = 0; i < 1; i++) + for (int i = 0; i < 1; i++) { offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); @@ -101,23 +101,23 @@ namespace CalamityMod.Projectiles.Melee Projectile.height = 50; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 20; num621++) + for (int j = 0; j < 20; j++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 159, 0f, 0f, 100, default, 0.5f); - Main.dust[num622].velocity *= 3f; + int shiny = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 159, 0f, 0f, 100, default, 0.5f); + Main.dust[shiny].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[shiny].scale = 0.5f; + Main.dust[shiny].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 35; num623++) + for (int k = 0; k < 35; k++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 32, 0f, 0f, 100, default, 1f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 159, 0f, 0f, 100, default, 0.5f); - Main.dust[num624].velocity *= 2f; + int shiny2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 32, 0f, 0f, 100, default, 1f); + Main.dust[shiny2].noGravity = true; + Main.dust[shiny2].velocity *= 5f; + shiny2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 159, 0f, 0f, 100, default, 0.5f); + Main.dust[shiny2].velocity *= 2f; } } diff --git a/Projectiles/Melee/RainBolt.cs b/Projectiles/Melee/RainBolt.cs index 9eff0a3558..5eb537263b 100644 --- a/Projectiles/Melee/RainBolt.cs +++ b/Projectiles/Melee/RainBolt.cs @@ -30,9 +30,9 @@ namespace CalamityMod.Projectiles.Melee Projectile.localAI[0] += 1f; } - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 2f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int rainbow = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 2f); + Main.dust[rainbow].noGravity = true; + Main.dust[rainbow].velocity *= 0f; if (Projectile.timeLeft < 150) CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 600f, 12f, 20f); diff --git a/Projectiles/Melee/RainbowBoom.cs b/Projectiles/Melee/RainbowBoom.cs index bb003b38ce..4ea9633a44 100644 --- a/Projectiles/Melee/RainbowBoom.cs +++ b/Projectiles/Melee/RainbowBoom.cs @@ -25,61 +25,61 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - bool flag15 = false; - bool flag16 = false; + bool xflag = false; + bool yflag = false; if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) { - flag16 = true; + yflag = true; } if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) { - flag16 = true; + yflag = true; } - if (flag15 && flag16) + if (xflag && yflag) { Projectile.Kill(); } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-30, 31); - float num464 = (float)Main.rand.Next(-30, 31); - float num465 = (float)Main.rand.Next(9, 27); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[num467].noGravity = true; - Main.dust[num467].position.X = Projectile.Center.X; - Main.dust[num467].position.Y = Projectile.Center.Y; - Dust expr_149DF_cp_0 = Main.dust[num467]; + float rando1 = (float)Main.rand.Next(-30, 31); + float rando2 = (float)Main.rand.Next(-30, 31); + float rando3 = (float)Main.rand.Next(9, 27); + float randoAdjuster = (float)Math.Sqrt((double)(rando1 * rando1 + rando2 * rando2)); + randoAdjuster = rando3 / randoAdjuster; + rando1 *= randoAdjuster; + rando2 *= randoAdjuster; + int rainbow = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Main.dust[rainbow].noGravity = true; + Main.dust[rainbow].position.X = Projectile.Center.X; + Main.dust[rainbow].position.Y = Projectile.Center.Y; + Dust expr_149DF_cp_0 = Main.dust[rainbow]; expr_149DF_cp_0.position.X += (float)Main.rand.Next(-10, 11); - Dust expr_14A09_cp_0 = Main.dust[num467]; + Dust expr_14A09_cp_0 = Main.dust[rainbow]; expr_14A09_cp_0.position.Y += (float)Main.rand.Next(-10, 11); - Main.dust[num467].velocity.X = num463; - Main.dust[num467].velocity.Y = num464; - num462++; + Main.dust[rainbow].velocity.X = rando1; + Main.dust[rainbow].velocity.Y = rando2; + timerCounter++; } } diff --git a/Projectiles/Melee/Razorwind.cs b/Projectiles/Melee/Razorwind.cs index 3ecc436a06..91f164ec01 100644 --- a/Projectiles/Melee/Razorwind.cs +++ b/Projectiles/Melee/Razorwind.cs @@ -44,11 +44,11 @@ namespace CalamityMod.Projectiles.Melee Projectile.localAI[1] += 1f; if (Projectile.localAI[1] > 4f) { - for (int num468 = 0; num468 < 3; num468++) + for (int i = 0; i < 3; i++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 187, 0f, 0f, 100, new Color(53, Main.DiscoG, 255), 2f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int blueDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 187, 0f, 0f, 100, new Color(53, Main.DiscoG, 255), 2f); + Main.dust[blueDust].noGravity = true; + Main.dust[blueDust].velocity *= 0f; } } diff --git a/Projectiles/Melee/RoxShockwave.cs b/Projectiles/Melee/RoxShockwave.cs deleted file mode 100644 index 8b25af0414..0000000000 --- a/Projectiles/Melee/RoxShockwave.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Melee -{ - public class RoxShockwave : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetDefaults() - { - Projectile.penetrate = -1; - Projectile.width = 450; - Projectile.height = 450; - Projectile.DamageType = DamageClass.Melee; - Projectile.friendly = true; - Projectile.tileCollide = false; - Projectile.timeLeft = 40; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - } - } -} diff --git a/Projectiles/Melee/RoxSlam.cs b/Projectiles/Melee/RoxSlam.cs deleted file mode 100644 index 8e2060076b..0000000000 --- a/Projectiles/Melee/RoxSlam.cs +++ /dev/null @@ -1,88 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.Audio; - -namespace CalamityMod.Projectiles.Melee -{ - public class RoxSlam : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetDefaults() - { - Projectile.width = 10; - Projectile.height = 35; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Melee; - Projectile.timeLeft = 400; - Projectile.tileCollide = true; - } - - public override void AI() - { - Player player = Main.player[Projectile.owner]; - //Kills the projectile if the alt attack ended - if (player.itemAnimation == 0) - { - Projectile.Kill(); - } - //Makes the projectiles track the player - float posX; - float posY = player.Center.Y + 63; - // Makes the projectile follow the proper position on the X axis - if (player.direction == 1) - { - posX = player.Center.X + 6; - } - else - { - posX = player.Center.X - 8; - } - Projectile.Center = new Vector2(posX, posY - (player.height / 10f)); - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - //This will only happen if the cooldown was full - if (Projectile.ai[0] == 1 && Main.myPlayer == Projectile.owner) - { - Player player = Main.player[Projectile.owner]; - //Bounce - player.velocity.Y = -18f; - //reset player fall damage - player.fallStart = (int)(player.position.Y / 16f); - //Spawns the shockwave - int slamDamage = (int)player.GetTotalDamage().ApplyTo(300); - float slamKB = player.GetTotalKnockback().ApplyTo(12f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), slamDamage, slamKB, Projectile.owner); - SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - Projectile.Kill(); - //Pretty things - for (int dustexplode = 0; dustexplode < 360; dustexplode++) - { - Vector2 dustd = new Vector2(17f, 17f).RotatedBy(MathHelper.ToRadians(dustexplode)); - int d = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, 51, dustd.X, dustd.Y, 100, default, 3f); - Main.dust[d].noGravity = true; - Main.dust[d].position = Projectile.Center; - } - return false; - } - //If the cooldown wasnt full, just bounce - else if (Main.myPlayer == Projectile.owner) - { - Player player = Main.player[Projectile.owner]; - player.velocity.Y = -14f; - //reset player fall damage - player.fallStart = (int)(player.position.Y / 16f); - SoundEngine.PlaySound(SoundID.Tink, Projectile.position); - Projectile.Kill(); - - return false; - } - return false; - } - } -} diff --git a/Projectiles/Melee/RoxcaliburProj.cs b/Projectiles/Melee/RoxcaliburProj.cs new file mode 100644 index 0000000000..db3223618f --- /dev/null +++ b/Projectiles/Melee/RoxcaliburProj.cs @@ -0,0 +1,290 @@ +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using CalamityMod.Items.Weapons.Melee; + +namespace CalamityMod.Projectiles.Melee +{ + public class RoxcaliburProj : ModProjectile, ILocalizedModType + { + public string LocalizationCategory => "Projectiles.Melee"; + + public override string Texture => "CalamityMod/Items/Weapons/Melee/Roxcalibur"; + + public override void SetDefaults() + { + Projectile.penetrate = -1; + Projectile.width = 100; + Projectile.height = 100; + Projectile.DamageType = DamageClass.Melee; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.scale = 1.3f; + Projectile.timeLeft = 3600; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 150; + } + private const int Charging = 0, Swinging = 1, Plunging = 2, Recoil = 3; + private int Animation = Charging; + + const int plungeSpeed = 20; + + public float BaseChargeTime = 60 * 2; + ref float ChargeLevel => ref Projectile.ai[0]; + ref float HitTimer => ref Projectile.ai[1]; + private Vector2 RockOffset() => Projectile.velocity * 0.25f * Projectile.Size.Length(); + + public override bool? CanDamage() => HitTimer < 5 && Animation != Charging ? base.CanDamage() : false; //returning true means it can damage friendlies etc + + //large "explosion" hitbox that lasts for 5 frames after bonk hit + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + if (HitTimer > 0 && HitTimer < 5) + { + float hitboxModifier = 2f + 1.5f * ChargeLevel; + Vector2 HitboxSize = new(Projectile.width * hitboxModifier, Projectile.height * hitboxModifier); + Vector2 HitboxCenter = Projectile.Center + RockOffset(); + hitbox = new Rectangle((int)(HitboxCenter.X - HitboxSize.X / 2f), (int)(HitboxCenter.Y - HitboxSize.Y / 2f), (int)HitboxSize.X, (int)HitboxSize.Y); + } + + } + + //more precise hitbox. makes the weapon harder to use but looks visually better: use it if you want. +/* + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (HitTimer <= 0) + { + float size = Projectile.Size.Length(); + Vector2 hiltPos = Projectile.Center - Projectile.velocity * size / 2; + Vector2 endPos = Projectile.Center + Projectile.velocity * size / 2; + float useless = 0f; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), hiltPos, endPos, size / 2, ref useless); + } + return base.Colliding(projHitbox, targetHitbox); + } +*/ + + public override void AI() + { + ref float origAnimMax = ref Projectile.ai[2]; + + ref float rotation = ref Projectile.localAI[0]; + ref float playerDirection = ref Projectile.localAI[1]; + ref float PlayedChargeSound = ref Projectile.localAI[2]; + + Player player = Main.player[Projectile.owner]; + if (player == null || !player.active || player.dead) + { + Projectile.Kill(); + return; + } + player.heldProj = Projectile.whoAmI; + if (origAnimMax == 0) + { + origAnimMax = player.itemAnimationMax; + } + float HoldoutRadius = (float)Projectile.Size.Length() / 2; //since sprite is diagonal + + float attackSpeedModifier = origAnimMax / Roxcalibur.BaseUseTime; + float chargeTime = attackSpeedModifier * BaseChargeTime; + + if (player.channel) + { + Animation = Charging; + } + else if (Animation == Charging) //first frame of release + { + Animation = Main.MouseWorld.Y > player.Center.Y ? Plunging : Swinging; + float chargeModifier = ChargeLevel * 2.5f; //modify this to balance damage bonus from charging + + if (Animation == Plunging) + { + Projectile.timeLeft = 60 * 2; //maximum 2 second plunge time + chargeModifier = ChargeLevel * 3.5f; + } + + Projectile.damage = (int)(Projectile.damage * (1 + chargeModifier)); + Projectile.netUpdate = true; + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/LoudSwingWoosh") with { Pitch = -0.5f }, Projectile.Center); + } + switch (Animation) + { + case Charging: + { + if (ChargeLevel < 1) + ChargeLevel += 1f / chargeTime; + else + ChargeLevel = 1; + + int direction = -Math.Sign(player.DirectionTo(Main.MouseWorld).X); + playerDirection = -direction; + float rotModifier = (float)Math.Pow(ChargeLevel, 0.4f); + rotation = Utils.SmoothStep(-MathHelper.PiOver2 / 4, MathHelper.PiOver2 / 1.5f, rotModifier); + rotation *= direction; + Projectile.timeLeft = (int)origAnimMax; + + + if (ChargeLevel >= 1 && player.whoAmI == Main.myPlayer && PlayedChargeSound == 0) + { + PlayedChargeSound = 1; + SoundEngine.PlaySound(SoundID.NPCHit42 with { Pitch = 0.4f }, Projectile.Center); + } + } + break; + case Swinging: + { + if (Projectile.timeLeft > origAnimMax) + { + Projectile.timeLeft = (int)origAnimMax; + } + + float progress = Projectile.timeLeft / origAnimMax; + + float chargeRotModifier = (ChargeLevel + 1f) / 2f; + float animRotModifier = Math.Clamp(progress, 0, 1); + if (animRotModifier > 0.5f) + animRotModifier = 1 - animRotModifier; + animRotModifier *= animRotModifier; + animRotModifier += 0.02f; + rotation += playerDirection * animRotModifier * chargeRotModifier * MathHelper.TwoPi * 0.2f; + + Projectile.localNPCHitCooldown = (int)Math.Ceiling(origAnimMax); //only hit once per swing + //int shardTimer = (int)Math.Ceiling(((1 - ChargeLevel) * 0.6f + 0.4f) * 9); + int shardTimer = ChargeLevel >= 0.95f ? 2 : ChargeLevel >= 0.5f ? 4 : 6; + if (progress < 0.8f && progress > 0.2f && Projectile.timeLeft % shardTimer == 0) + { + Vector2 roxSpeed = (Projectile.velocity * 8f).RotatedByRandom((double)MathHelper.ToRadians(10f)); + int rox = ModContent.ProjectileType(); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center + RockOffset(), roxSpeed, rox, (int)(Projectile.damage * 0.4f), 1f, player.whoAmI, (float)Main.rand.Next(3), 0f, 0f); + } + } + break; + case Plunging: + { + //I would make this set your velocity.Y if it wasn't capped, tried uncapping it by changing Player.maxFallSpeed but it does not work properly! + //this also makes you go through platforms which is cool and good imo + Vector2 plunge = Vector2.UnitY * player.gravDir * plungeSpeed * (ChargeLevel + 1f) / 2f; + if ((player.velocity.Y == 0 && Projectile.velocity.Y * player.gravDir > 0) || Collision.SolidCollision(player.position + plunge, player.width, player.height)) + { + CollisionEffects(); + break; + } + player.position += plunge; + player.velocity.X *= 0.95f; + player.velocity.Y = 0; + + float chargeRotModifier = (ChargeLevel + 1f) / 2f; + + float anglediff = RotationDifference(Projectile.velocity, Vector2.UnitY * player.gravDir); + int dir = Math.Abs(anglediff) > MathHelper.PiOver2 ? (int)playerDirection : Math.Sign(anglediff); + rotation += dir * Math.Abs(anglediff) * 0.12f * chargeRotModifier; + //rotation += playerDirection * animRotModifier * chargeRotModifier * MathHelper.TwoPi * 6 / origAnimMax; + + Projectile.localNPCHitCooldown = (int)Math.Ceiling(origAnimMax); //only hit once per swing + if (Collision.SolidTiles(Projectile.position, Projectile.width, Projectile.height, false)) + { + CollisionEffects(); + break; + } + } + break; + case Recoil: + { + if (Projectile.timeLeft > origAnimMax / 3) + Projectile.timeLeft = (int)(origAnimMax / 3); + float modifier = Math.Clamp(Projectile.timeLeft / origAnimMax, 0, 1); + rotation -= playerDirection * modifier * MathHelper.TwoPi * 2 / origAnimMax; + + } + break; + } + + if (HitTimer > 0 && HitTimer <= 5) + { + HitTimer++; + } + + Projectile.velocity = (-Vector2.UnitY * player.gravDir).RotatedBy(rotation); + Projectile.Center = (Vector2)player.HandPosition + Projectile.velocity * HoldoutRadius; + + Projectile.rotation = Projectile.velocity.ToRotation(); + Projectile.spriteDirection = Projectile.direction = (int)playerDirection; + player.ChangeDir(Projectile.direction); + player.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); + player.itemTime = Math.Max(player.itemTime, 2); + player.itemAnimation = Math.Max(player.itemAnimation, 2); + if (Projectile.spriteDirection == -1) + { + Projectile.rotation += MathHelper.ToRadians(-45f) + MathHelper.Pi; + } + else + { + Projectile.rotation += MathHelper.ToRadians(-135f) + MathHelper.Pi; + } + + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + CollisionEffects(); + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + Projectile.damage = (int)(Projectile.damage * 0.75f); + if (Projectile.damage < 1) + Projectile.damage = 1; + } + + private void CollisionEffects() + { + if (HitTimer == 0) + { + HitTimer = 1; + SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); + if (Animation == Plunging) + { + Player player = Main.player[Projectile.owner]; + player.velocity.Y = -player.gravDir * plungeSpeed * (ChargeLevel + 1f) / 2f; + } + Animation = Recoil; + //dust ring + const int dusts = 24; + for (int i = 0; i < dusts; i++) + { + Vector2 dir = Vector2.UnitY.RotatedBy(MathHelper.TwoPi * i / dusts); + Vector2 pos = Projectile.Center + RockOffset() + dir * 20 * Projectile.scale; + int d = Dust.NewDust(pos, 0, 0, DustID.Stone, dir.X * 12 * Projectile.scale, dir.Y * 12 * Projectile.scale, newColor: Color.Black, Scale: Projectile.scale); + if (d.WithinBounds(Main.maxDust)) + { + Main.dust[d].noGravity = true; + } + } + } + } + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + Rectangle rectangle = texture.Bounds; + Vector2 origin2 = rectangle.Size() / 2f; + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Vector2 pos = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); + + if (Animation == Charging && ChargeLevel > 0.95f) + { + float shake = 2.5f * (ChargeLevel - 0.95f) / 0.05f; + pos += Main.rand.NextVector2Circular(shake, shake); + } + + Main.EntitySpriteDraw(texture, pos, new Microsoft.Xna.Framework.Rectangle?(rectangle), Projectile.GetAlpha(lightColor), Projectile.rotation, origin2, Projectile.scale, effects, 0); + return false; + } + + public static float RotationDifference(Vector2 from, Vector2 to) => (float)Math.Atan2(to.Y * from.X - to.X * from.Y, from.X * to.X + from.Y * to.Y); + } +} diff --git a/Projectiles/Melee/SaharaSlicersBlade.png b/Projectiles/Melee/SaharaSlicersBlade.png new file mode 100644 index 0000000000..abf539a5d6 Binary files /dev/null and b/Projectiles/Melee/SaharaSlicersBlade.png differ diff --git a/Projectiles/Melee/SaharaSlicersBladeAlt.png b/Projectiles/Melee/SaharaSlicersBladeAlt.png new file mode 100644 index 0000000000..989f6b5acf Binary files /dev/null and b/Projectiles/Melee/SaharaSlicersBladeAlt.png differ diff --git a/Projectiles/Melee/SaharaSlicersBolt.cs b/Projectiles/Melee/SaharaSlicersBolt.cs new file mode 100644 index 0000000000..577a22f9fc --- /dev/null +++ b/Projectiles/Melee/SaharaSlicersBolt.cs @@ -0,0 +1,108 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Audio; +using CalamityMod.Particles; + +namespace CalamityMod.Projectiles.Melee +{ + public class SaharaSlicersBolt : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 9; + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + } + public ref int Bolts => ref Main.player[Projectile.owner].Calamity().saharaSlicersBolts; + public override void SetDefaults() + { + Projectile.width = 18; + Projectile.height = 18; + Projectile.friendly = true; + Projectile.penetrate = 2; + Projectile.tileCollide = true; + Projectile.ignoreWater = true; + Projectile.DamageType = DamageClass.Melee; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void AI() + { + Player Owner = Main.player[Projectile.owner]; + float playerDist = Vector2.Distance(Owner.Center, Projectile.Center); + + // Shot Mode + if (Projectile.ai[0] == 1) + { + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + Projectile.extraUpdates = 6; + if (Main.rand.NextBool(2)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(5, 5), Main.rand.NextBool() ? 288 : 207); + dust.scale = Main.rand.NextFloat(0.2f, 0.45f); + dust.noGravity = true; + dust.velocity = -Projectile.velocity * 0.5f; + } + if (Projectile.timeLeft % 2 == 0 && playerDist < 1400f) + { + SparkParticle spark = new SparkParticle(Projectile.Center - Projectile.velocity * 3f, -Projectile.velocity * 0.05f, false, 10, 1f, Color.White * 0.135f); + GeneralParticleHandler.SpawnParticle(spark); + } + } + else // "Quiver" mode + { + // Refresh lifetime + Projectile.timeLeft = 4; + + // If the player uses a bolt, destroy the most recent bolt + if (Bolts < Projectile.ai[1]) + Projectile.Kill(); + + // Setting the bolt's position on the player's back + Projectile.rotation = (21.8f - (Projectile.ai[1] * 0.1f)) * -Owner.direction; + Vector2 BoltPos = Owner.MountedCenter + new Vector2((10 + Projectile.ai[1] * 2.5f) * -Owner.direction, 3f - Projectile.ai[1]); + + Projectile.Center = BoltPos; + } + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + for (int i = 0; i <= 8; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool() ? 288 : 207, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.3f, 1.9f)); + dust.noGravity = false; + dust.scale = Main.rand.NextFloat(0.6f, 0.9f); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool() ? 288 : 207, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.05f, 0.9f)); + dust2.noGravity = false; + dust2.scale = Main.rand.NextFloat(0.6f, 0.9f); + } + } + public override void OnKill(int timeLeft) + { + if (Projectile.ai[0] == 1) + { + SoundEngine.PlaySound(SoundID.Item10, Projectile.position); + for (int i = 0; i <= 5; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool() ? 216 : 207, -Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.2f, 1f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.1f, 1.8f); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool() ? 216 : 207, -Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.05f, 0.4f)); + dust2.noGravity = true; + dust2.scale = Main.rand.NextFloat(1.1f, 1.8f); + } + } + } + public override bool PreDraw(ref Color lightColor) + { + if (Projectile.ai[0] == 1) + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); + return true; + } + public override bool? CanDamage() => Projectile.ai[0] == 1 ? true : false; + } +} diff --git a/Projectiles/Melee/SaharaSlicersBolt.png b/Projectiles/Melee/SaharaSlicersBolt.png new file mode 100644 index 0000000000..9c954972d8 Binary files /dev/null and b/Projectiles/Melee/SaharaSlicersBolt.png differ diff --git a/Projectiles/Melee/SandFire.cs b/Projectiles/Melee/SandFire.cs index 1dafccff81..cc3ae55ea2 100644 --- a/Projectiles/Melee/SandFire.cs +++ b/Projectiles/Melee/SandFire.cs @@ -27,11 +27,11 @@ namespace CalamityMod.Projectiles.Melee Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { - for (int num468 = 0; num468 < 5; num468++) + for (int i = 0; i < 5; i++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 159, 0f, 0f, 100, default, 0.5f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int shiny = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 159, 0f, 0f, 100, default, 0.5f); + Main.dust[shiny].noGravity = true; + Main.dust[shiny].velocity *= 0f; } } diff --git a/Projectiles/Melee/ScourgeoftheCosmosMini.cs b/Projectiles/Melee/ScourgeoftheCosmosMini.cs index 6836a73f50..c7c74e0569 100644 --- a/Projectiles/Melee/ScourgeoftheCosmosMini.cs +++ b/Projectiles/Melee/ScourgeoftheCosmosMini.cs @@ -50,13 +50,13 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.frame > 1) Projectile.frame = 0; - for (int num369 = 0; num369 < 1; num369++) + for (int i = 0; i < 1; i++) { int dustType = Main.rand.NextBool(3) ? 56 : 242; - float dustX = Projectile.velocity.X / 3f * num369; - float dustY = Projectile.velocity.Y / 3f * num369; - int num372 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num372]; + float dustX = Projectile.velocity.X / 3f * i; + float dustY = Projectile.velocity.Y / 3f * i; + int scourgeDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[scourgeDust]; dust.position.X = Projectile.Center.X - dustX; dust.position.Y = Projectile.Center.Y - dustY; dust.velocity *= 0f; @@ -65,9 +65,9 @@ namespace CalamityMod.Projectiles.Melee Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) - MathHelper.PiOver2; - float num373 = Projectile.position.X; - float num374 = Projectile.position.Y; - float num375 = 100000f; + float projX = Projectile.position.X; + float projY = Projectile.position.Y; + float homingRange = 100000f; bool isHoming = false; Projectile.ai[0] += 1f; if (Projectile.ai[0] > 30f) @@ -80,11 +80,11 @@ namespace CalamityMod.Projectiles.Melee float enemyX = Main.npc[enemy].position.X + Main.npc[enemy].width / 2; float enemyY = Main.npc[enemy].position.Y + Main.npc[enemy].height / 2; float enemyDistance = Math.Abs(Projectile.position.X + Projectile.width / 2 - enemyX) + Math.Abs(Projectile.position.Y + Projectile.height / 2 - enemyY); - if (enemyDistance < 800f && enemyDistance < num375 && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[enemy].position, Main.npc[enemy].width, Main.npc[enemy].height)) + if (enemyDistance < 800f && enemyDistance < homingRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[enemy].position, Main.npc[enemy].width, Main.npc[enemy].height)) { - num375 = enemyDistance; - num373 = enemyX; - num374 = enemyY; + homingRange = enemyDistance; + projX = enemyX; + projY = enemyY; isHoming = true; } } @@ -92,41 +92,41 @@ namespace CalamityMod.Projectiles.Melee } if (!isHoming) { - num373 = Projectile.position.X + Projectile.width / 2 + Projectile.velocity.X * 100f; - num374 = Projectile.position.Y + Projectile.height / 2 + Projectile.velocity.Y * 100f; + projX = Projectile.position.X + Projectile.width / 2 + Projectile.velocity.X * 100f; + projY = Projectile.position.Y + Projectile.height / 2 + Projectile.velocity.Y * 100f; } - float num381 = 0.16f; - Vector2 vector30 = new Vector2(Projectile.position.X + Projectile.width * 0.5f, Projectile.position.Y + Projectile.height * 0.5f); - float num382 = num373 - vector30.X; - float num383 = num374 - vector30.Y; - float num384 = (float)Math.Sqrt(num382 * num382 + num383 * num383); - num384 = 10f / num384; - num382 *= num384; - num383 *= num384; - if (Projectile.velocity.X < num382) + float projVelModifier = 0.16f; + Vector2 projDirection = new Vector2(Projectile.position.X + Projectile.width * 0.5f, Projectile.position.Y + Projectile.height * 0.5f); + float projDirectX = projX - projDirection.X; + float projDirectY = projY - projDirection.Y; + float projDistance = (float)Math.Sqrt(projDirectX * projDirectX + projDirectY * projDirectY); + projDistance = 10f / projDistance; + projDirectX *= projDistance; + projDirectY *= projDistance; + if (Projectile.velocity.X < projDirectX) { - Projectile.velocity.X = Projectile.velocity.X + num381; - if (Projectile.velocity.X < 0f && num382 > 0f) - Projectile.velocity.X = Projectile.velocity.X + num381 * 2f; + Projectile.velocity.X = Projectile.velocity.X + projVelModifier; + if (Projectile.velocity.X < 0f && projDirectX > 0f) + Projectile.velocity.X = Projectile.velocity.X + projVelModifier * 2f; } - else if (Projectile.velocity.X > num382) + else if (Projectile.velocity.X > projDirectX) { - Projectile.velocity.X = Projectile.velocity.X - num381; - if (Projectile.velocity.X > 0f && num382 < 0f) - Projectile.velocity.X = Projectile.velocity.X - num381 * 2f; + Projectile.velocity.X = Projectile.velocity.X - projVelModifier; + if (Projectile.velocity.X > 0f && projDirectX < 0f) + Projectile.velocity.X = Projectile.velocity.X - projVelModifier * 2f; } - if (Projectile.velocity.Y < num383) + if (Projectile.velocity.Y < projDirectY) { - Projectile.velocity.Y = Projectile.velocity.Y + num381; - if (Projectile.velocity.Y < 0f && num383 > 0f) - Projectile.velocity.Y = Projectile.velocity.Y + num381 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y + projVelModifier; + if (Projectile.velocity.Y < 0f && projDirectY > 0f) + Projectile.velocity.Y = Projectile.velocity.Y + projVelModifier * 2f; } - else if (Projectile.velocity.Y > num383) + else if (Projectile.velocity.Y > projDirectY) { - Projectile.velocity.Y = Projectile.velocity.Y - num381; - if (Projectile.velocity.Y > 0f && num383 < 0f) - Projectile.velocity.Y = Projectile.velocity.Y - num381 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y - projVelModifier; + if (Projectile.velocity.Y > 0f && projDirectY < 0f) + Projectile.velocity.Y = Projectile.velocity.Y - projVelModifier * 2f; } } @@ -148,10 +148,10 @@ namespace CalamityMod.Projectiles.Melee public override void PostDraw(Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; Vector2 origin = new Vector2(9f, 10f); - Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Melee/ScourgeoftheCosmosMiniGlow").Value, Projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Color.White, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); + Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Melee/ScourgeoftheCosmosMiniGlow").Value, Projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Color.White, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); } } } diff --git a/Projectiles/Melee/ScourgeoftheCosmosProj.cs b/Projectiles/Melee/ScourgeoftheCosmosProj.cs index 6fd5205955..5fa7b6724f 100644 --- a/Projectiles/Melee/ScourgeoftheCosmosProj.cs +++ b/Projectiles/Melee/ScourgeoftheCosmosProj.cs @@ -33,19 +33,19 @@ namespace CalamityMod.Projectiles.Melee { if (Projectile.alpha <= 200) { - int num3; - for (int num20 = 0; num20 < 2; num20 = num3 + 1) + int inc; + for (int i = 0; i < 2; i = inc + 1) { int dustType = Main.rand.NextBool(3) ? 56 : 242; - float num21 = Projectile.velocity.X / 4f * num20; - float num22 = Projectile.velocity.Y / 4f * num20; - int num23 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 1f); - Main.dust[num23].position.X = Projectile.Center.X - num21; - Main.dust[num23].position.Y = Projectile.Center.Y - num22; - Dust dust = Main.dust[num23]; + float shortXVel = Projectile.velocity.X / 4f * i; + float shortYVel = Projectile.velocity.Y / 4f * i; + int scourgeDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 1f); + Main.dust[scourgeDust].position.X = Projectile.Center.X - shortXVel; + Main.dust[scourgeDust].position.Y = Projectile.Center.Y - shortYVel; + Dust dust = Main.dust[scourgeDust]; dust.velocity *= 0f; - Main.dust[num23].scale = 0.7f; - num3 = num20; + Main.dust[scourgeDust].scale = 0.7f; + inc = i; } } Projectile.alpha -= 50; @@ -82,18 +82,18 @@ namespace CalamityMod.Projectiles.Melee Projectile.velocity.Y = -oldVelocity.Y; if (Projectile.owner == Main.myPlayer) { - int num626 = 1; + int minisAmt = 1; if (Main.rand.NextBool(10)) - num626++; - int num3; - for (int num627 = 0; num627 < num626; num627 = num3 + 1) + minisAmt++; + int inc; + for (int j = 0; j < minisAmt; j = inc + 1) { - float num628 = Main.rand.Next(-35, 36) * 0.02f; - float num629 = Main.rand.Next(-35, 36) * 0.02f; - num628 *= 10f; - num629 *= 10f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, num628, num629, ModContent.ProjectileType(), (int)(Projectile.damage * 0.75), Projectile.knockBack * 0.35f, Main.myPlayer); - num3 = num627; + float randXDirect = Main.rand.Next(-35, 36) * 0.02f; + float randYDirect = Main.rand.Next(-35, 36) * 0.02f; + randXDirect *= 10f; + randYDirect *= 10f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, randXDirect, randYDirect, ModContent.ProjectileType(), (int)(Projectile.damage * 0.75), Projectile.knockBack * 0.35f, Main.myPlayer); + inc = j; } } } @@ -103,40 +103,40 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.NPCHit4, Projectile.position); - int num3; - for (int num622 = 0; num622 < 10; num622 = num3 + 1) + int inc; + for (int i = 0; i < 10; i = inc + 1) { int dustType = Main.rand.NextBool(3) ? 56 : 242; - int num623 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num623]; + int killedDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[killedDust]; dust.scale *= 1.1f; - Main.dust[num623].noGravity = true; - num3 = num622; + Main.dust[killedDust].noGravity = true; + inc = i; } - for (int num624 = 0; num624 < 15; num624 = num3 + 1) + for (int j = 0; j < 15; j = inc + 1) { int dustType = Main.rand.NextBool(3) ? 56 : 242; - int num625 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num625]; + int killedDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[killedDust2]; dust.velocity *= 2.5f; - dust = Main.dust[num625]; + dust = Main.dust[killedDust2]; dust.scale *= 0.8f; - Main.dust[num625].noGravity = true; - num3 = num624; + Main.dust[killedDust2].noGravity = true; + inc = j; } if (Projectile.owner == Main.myPlayer) { - int num626 = 3; + int minisAmt = 3; if (Main.rand.NextBool(10)) - num626++; - for (int num627 = 0; num627 < num626; num627 = num3 + 1) + minisAmt++; + for (int j = 0; j < minisAmt; j = inc + 1) { - float num628 = Main.rand.Next(-35, 36) * 0.02f; - float num629 = Main.rand.Next(-35, 36) * 0.02f; - num628 *= 10f; - num629 *= 10f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, num628, num629, ModContent.ProjectileType(), (int)(Projectile.damage * 0.7), Projectile.knockBack * 0.35f, Main.myPlayer); - num3 = num627; + float randXDirect = Main.rand.Next(-35, 36) * 0.02f; + float randYDirect = Main.rand.Next(-35, 36) * 0.02f; + randXDirect *= 10f; + randYDirect *= 10f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, randXDirect, randYDirect, ModContent.ProjectileType(), (int)(Projectile.damage * 0.7), Projectile.knockBack * 0.35f, Main.myPlayer); + inc = j; } } } diff --git a/Projectiles/Melee/Shortswords/AquaticDischargeProj.cs b/Projectiles/Melee/Shortswords/AquaticDischargeProj.cs deleted file mode 100644 index b974f8a408..0000000000 --- a/Projectiles/Melee/Shortswords/AquaticDischargeProj.cs +++ /dev/null @@ -1,68 +0,0 @@ -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Projectiles.BaseProjectiles; -using Microsoft.Xna.Framework; -using System; -using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee.Shortswords -{ - public class AquaticDischargeProj: BaseShortswordProjectile - { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - public override string Texture => "CalamityMod/Items/Weapons/Melee/AquaticDischarge"; - - public override void SetDefaults() - { - Projectile.Size = new Vector2(16); - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.scale = 1f; - Projectile.DamageType = TrueMeleeDamageClass.Instance; - Projectile.ownerHitCheck = true; - Projectile.timeLeft = 360; - Projectile.hide = true; - Projectile.ownerHitCheck = true; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 8; - } - - public override void SetVisualOffsets() - { - const int HalfSpriteWidth = 32 / 2; - const int HalfSpriteHeight = 32 / 2; - - int HalfProjWidth = Projectile.width / 2; - int HalfProjHeight = Projectile.height / 2; - - DrawOriginOffsetX = 0; - DrawOffsetX = -(HalfSpriteWidth - HalfProjWidth); - DrawOriginOffsetY = -(HalfSpriteHeight - HalfProjHeight); - } - - public override void ExtraBehavior() - { - if (Main.rand.NextBool(5)) - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Electric); - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - Player player = Main.player[Projectile.owner]; - var source = Projectile.GetSource_FromThis(); - int sparkDamage = player.CalcIntDamage(0.5f * Projectile.damage); - Projectile.NewProjectile(source, target.Center, Vector2.Zero, ModContent.ProjectileType(), sparkDamage, hit.Knockback, Main.myPlayer); - } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - Player player = Main.player[Projectile.owner]; - var source = Projectile.GetSource_FromThis(); - int sparkDamage = player.CalcIntDamage(0.5f * Projectile.damage); - Projectile.NewProjectile(source, target.Center, Vector2.Zero, ModContent.ProjectileType(), sparkDamage, Projectile.knockBack, Main.myPlayer); - } - } -} diff --git a/Projectiles/Melee/Shortswords/ElementalShivProj.cs b/Projectiles/Melee/Shortswords/ElementalShivProj.cs index 66153daca2..02f4186d60 100644 --- a/Projectiles/Melee/Shortswords/ElementalShivProj.cs +++ b/Projectiles/Melee/Shortswords/ElementalShivProj.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using System; @@ -28,7 +29,7 @@ namespace CalamityMod.Projectiles.Melee.Shortswords Projectile.hide = true; Projectile.ownerHitCheck = true; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 8; + Projectile.localNPCHitCooldown = -1; } public override Action EffectBeforePullback => (proj) => @@ -53,10 +54,14 @@ namespace CalamityMod.Projectiles.Melee.Shortswords { if (Main.rand.NextBool(5)) { - int num250 = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 66, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); - Main.dust[num250].velocity *= 0.2f; - Main.dust[num250].noGravity = true; + int rainbowDust = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 66, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); + Main.dust[rainbowDust].velocity *= 0.2f; + Main.dust[rainbowDust].noGravity = true; } } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 60); + } } } diff --git a/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs b/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs index ed3cfe862b..c57f33da20 100644 --- a/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs +++ b/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs @@ -55,9 +55,9 @@ namespace CalamityMod.Projectiles.Melee.Shortswords { if (Main.rand.NextBool(5)) { - int num250 = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, (Main.rand.NextBool() ? 20 : 176), (float)(Main.player[Projectile.owner].direction * 2), 0f, 150, default, 1.3f); - Main.dust[num250].velocity *= 0.2f; - Main.dust[num250].noGravity = true; + int gladiusDust = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, (Main.rand.NextBool() ? 20 : 176), (float)(Main.player[Projectile.owner].direction * 2), 0f, 150, default, 1.3f); + Main.dust[gladiusDust].velocity *= 0.2f; + Main.dust[gladiusDust].noGravity = true; } } diff --git a/Projectiles/Melee/Shortswords/SaharaSlicersBlade.cs b/Projectiles/Melee/Shortswords/SaharaSlicersBlade.cs new file mode 100644 index 0000000000..ce100b8ac6 --- /dev/null +++ b/Projectiles/Melee/Shortswords/SaharaSlicersBlade.cs @@ -0,0 +1,93 @@ +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee.Shortswords +{ + public class SaharaSlicersBlade: BaseShortswordProjectile + { + public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + public override string Texture => "CalamityMod/Projectiles/Melee/SaharaSlicersBlade"; + public ref int Bolts => ref Main.player[Projectile.owner].Calamity().saharaSlicersBolts; + public override float FadeInDuration => 8f; + public override float FadeOutDuration => 0f; + public override float TotalDuration => 12f; + public override void SetDefaults() + { + Projectile.Size = new Vector2(15); + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.scale = 1f; + Projectile.DamageType = TrueMeleeDamageClass.Instance; + Projectile.ownerHitCheck = true; + Projectile.timeLeft = 360; + Projectile.hide = true; + Projectile.ownerHitCheck = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void SetVisualOffsets() + { + const int HalfSpriteWidth = 32 / 2; + const int HalfSpriteHeight = 32 / 2; + + int HalfProjWidth = Projectile.width / 2; + int HalfProjHeight = Projectile.height / 2; + + DrawOriginOffsetX = 0; + DrawOffsetX = -(HalfSpriteWidth - HalfProjWidth); + DrawOriginOffsetY = -(HalfSpriteHeight - HalfProjHeight); + } + + public override void ExtraBehavior() + { + if (Main.rand.NextBool(2)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(12, 12), 288); + dust.scale = Main.rand.NextFloat(0.15f, 0.6f); + dust.noGravity = true; + dust.velocity = -Projectile.velocity * 0.5f; + } + + float armPointingDirection = ((Owner.Calamity().mouseWorld - Owner.MountedCenter).ToRotation()); + Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, armPointingDirection - MathHelper.PiOver2); + Owner.heldProj = Projectile.whoAmI; + + Projectile.Center = Projectile.Center + new Vector2(0, 1.5f); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + // Add to bolt counter, spawn 2 quiver bolts, and on hit visual + if (Bolts < 10) + { + Bolts++; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, Bolts); + if (Bolts < 10) + { + Bolts++; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, Bolts); + } + } + float numberOfDusts = 5f; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) + { + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 offset = new Vector2(Main.rand.NextFloat(0.5f, 2.5f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + Vector2 velOffset = new Vector2(Main.rand.NextFloat(0.5f, 2.5f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + Dust dust = Dust.NewDustPerfect(target.Center + offset, Main.rand.NextBool() ? 288 : 207, new Vector2(velOffset.X, velOffset.Y)); + dust.noGravity = false; + dust.velocity = velOffset; + dust.scale = Main.rand.NextFloat(1.5f, 1.2f); + } + } + } +} diff --git a/Projectiles/Melee/Shortswords/SaharaSlicersBladeAlt.cs b/Projectiles/Melee/Shortswords/SaharaSlicersBladeAlt.cs new file mode 100644 index 0000000000..f0b332d2fe --- /dev/null +++ b/Projectiles/Melee/Shortswords/SaharaSlicersBladeAlt.cs @@ -0,0 +1,96 @@ +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; +using static Humanizer.In; + +namespace CalamityMod.Projectiles.Melee.Shortswords +{ + public class SaharaSlicersBladeAlt: BaseShortswordProjectile + { + public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + public override string Texture => "CalamityMod/Projectiles/Melee/SaharaSlicersBladeAlt"; + public ref int Bolts => ref Main.player[Projectile.owner].Calamity().saharaSlicersBolts; + public override float FadeInDuration => 8f; + public override float FadeOutDuration => 0f; + public override float TotalDuration => 12f; + public override void SetDefaults() + { + Projectile.Size = new Vector2(15); + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.scale = 1f; + Projectile.DamageType = TrueMeleeDamageClass.Instance; + Projectile.ownerHitCheck = true; + Projectile.timeLeft = 360; + Projectile.hide = true; + Projectile.ownerHitCheck = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void SetVisualOffsets() + { + const int HalfSpriteWidth = 32 / 2; + const int HalfSpriteHeight = 32 / 2; + + int HalfProjWidth = Projectile.width / 2; + int HalfProjHeight = Projectile.height / 2; + + DrawOriginOffsetX = 0; + DrawOffsetX = -(HalfSpriteWidth - HalfProjWidth); + DrawOriginOffsetY = -(HalfSpriteHeight - HalfProjHeight); + } + + public override void ExtraBehavior() + { + if (Main.rand.NextBool(2)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(12, 12), 288); + dust.scale = Main.rand.NextFloat(0.15f, 0.6f); + dust.noGravity = true; + dust.velocity = -Projectile.velocity * 0.5f; + } + + float armPointingDirection = (Owner.Calamity().mouseWorld - Owner.MountedCenter).ToRotation(); + Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, armPointingDirection - MathHelper.PiOver2); + Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, 0); + Owner.heldProj = Projectile.whoAmI; + + Projectile.Center = Projectile.Center + new Vector2(0, -6f); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + // Add to bolt counter, spawn 2 quiver bolts, and on hit visual + if (Bolts < 10) + { + Bolts++; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, Bolts); + if (Bolts < 10) + { + Bolts++; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, Bolts); + } + } + float numberOfDusts = 5f; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) + { + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 offset = new Vector2(Main.rand.NextFloat(0.5f, 2.5f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + Vector2 velOffset = new Vector2(Main.rand.NextFloat(0.5f, 2.5f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + Dust dust = Dust.NewDustPerfect(target.Center + offset, Main.rand.NextBool() ? 288 : 207, new Vector2(velOffset.X, velOffset.Y)); + dust.noGravity = false; + dust.velocity = velOffset; + dust.scale = Main.rand.NextFloat(1.5f, 1.2f); + } + } + } +} diff --git a/Projectiles/Melee/SolarNeedle.cs b/Projectiles/Melee/SolarNeedle.cs index d66fd85928..e31dda80f9 100644 --- a/Projectiles/Melee/SolarNeedle.cs +++ b/Projectiles/Melee/SolarNeedle.cs @@ -9,6 +9,7 @@ using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; using static CalamityMod.CalamityUtils; using Terraria.Audio; +using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Melee @@ -137,6 +138,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { + target.AddBuff(ModContent.BuffType(), 60); Vector2 particleOrigin = target.Hitbox.Size().Length() < 140 ? target.Center : Projectile.Center + Projectile.rotation.ToRotationVector2() * 60f; for (int i = 0; i < 10; i++) { diff --git a/Projectiles/Melee/SolsticeBeam.cs b/Projectiles/Melee/SolsticeBeam.cs index c6a091e7e0..bd8ee4572f 100644 --- a/Projectiles/Melee/SolsticeBeam.cs +++ b/Projectiles/Melee/SolsticeBeam.cs @@ -175,15 +175,15 @@ namespace CalamityMod.Projectiles.Melee break; } SoundEngine.PlaySound(SoundID.Item10, Projectile.position); - for (int num795 = 0; num795 < 27; num795++) + for (int i = 0; i < 27; i++) { - float num796 = Projectile.oldVelocity.X * (30f / (float)num795); - float num797 = Projectile.oldVelocity.Y * (30f / (float)num795); - int num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, dustType, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); - Dust dust = Main.dust[num798]; + float oldXVel = Projectile.oldVelocity.X * (30f / (float)i); + float oldYVel = Projectile.oldVelocity.Y * (30f / (float)i); + int solsticeDust = Dust.NewDust(new Vector2(Projectile.oldPosition.X - oldXVel, Projectile.oldPosition.Y - oldYVel), 8, 8, dustType, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); + Dust dust = Main.dust[solsticeDust]; dust.noGravity = true; dust.velocity *= 0.5f; - num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, dustType, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); + solsticeDust = Dust.NewDust(new Vector2(Projectile.oldPosition.X - oldXVel, Projectile.oldPosition.Y - oldYVel), 8, 8, dustType, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); dust.velocity *= 0.05f; } } diff --git a/Projectiles/Melee/SoulScytheExplosion.cs b/Projectiles/Melee/SoulScytheExplosion.cs index c04a25824c..5b3fc595f6 100644 --- a/Projectiles/Melee/SoulScytheExplosion.cs +++ b/Projectiles/Melee/SoulScytheExplosion.cs @@ -29,23 +29,23 @@ namespace CalamityMod.Projectiles.Melee { if (Projectile.timeLeft == 5) { - for (int num621 = 0; num621 < 30; num621++) + for (int i = 0; i < 30; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int soulDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 2f); + Main.dust[soulDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[soulDust].scale = 0.5f; + Main.dust[soulDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 50; num623++) + for (int j = 0; j < 50; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int soulDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 3f); + Main.dust[soulDust2].noGravity = true; + Main.dust[soulDust2].velocity *= 5f; + soulDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 2f); + Main.dust[soulDust2].velocity *= 2f; } } } diff --git a/Projectiles/Melee/Spark.cs b/Projectiles/Melee/Spark.cs index ee105705d8..31483c64cc 100644 --- a/Projectiles/Melee/Spark.cs +++ b/Projectiles/Melee/Spark.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.width = 6; Projectile.height = 12; Projectile.friendly = true; - Projectile.penetrate = -1; + Projectile.penetrate = 5; Projectile.timeLeft = 60; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 15; @@ -50,25 +50,25 @@ namespace CalamityMod.Projectiles.Melee Projectile.velocity.Y = Projectile.velocity.Y + 0.2f; } Projectile.rotation += Projectile.velocity.X * 0.1f; - int num199 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 206, 0f, 0f, 100, default, 1f); - Dust expr_8976_cp_0 = Main.dust[num199]; + int sparky = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 206, 0f, 0f, 100, default, 1f); + Dust expr_8976_cp_0 = Main.dust[sparky]; expr_8976_cp_0.position.X -= 2f; - Dust expr_8994_cp_0 = Main.dust[num199]; + Dust expr_8994_cp_0 = Main.dust[sparky]; expr_8994_cp_0.position.Y += 2f; - Main.dust[num199].scale += (float)Main.rand.Next(50) * 0.01f; - Main.dust[num199].noGravity = true; - Dust expr_89E7_cp_0 = Main.dust[num199]; + Main.dust[sparky].scale += (float)Main.rand.Next(50) * 0.01f; + Main.dust[sparky].noGravity = true; + Dust expr_89E7_cp_0 = Main.dust[sparky]; expr_89E7_cp_0.velocity.Y -= 2f; if (Main.rand.NextBool()) { - int num200 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 206, 0f, 0f, 100, default, 1f); - Dust expr_8A4E_cp_0 = Main.dust[num200]; + int sparkier = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 206, 0f, 0f, 100, default, 1f); + Dust expr_8A4E_cp_0 = Main.dust[sparkier]; expr_8A4E_cp_0.position.X -= 2f; - Dust expr_8A6C_cp_0 = Main.dust[num200]; + Dust expr_8A6C_cp_0 = Main.dust[sparkier]; expr_8A6C_cp_0.position.Y += 2f; - Main.dust[num200].scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; - Main.dust[num200].noGravity = true; - Main.dust[num200].velocity *= 0.1f; + Main.dust[sparkier].scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; + Main.dust[sparkier].noGravity = true; + Main.dust[sparkier].velocity *= 0.1f; } if ((double)Projectile.velocity.Y < 0.25 && (double)Projectile.velocity.Y > 0.15) { diff --git a/Projectiles/Melee/SpatialSpear.cs b/Projectiles/Melee/SpatialSpear.cs index 0037e5709b..082eeec0c0 100644 --- a/Projectiles/Melee/SpatialSpear.cs +++ b/Projectiles/Melee/SpatialSpear.cs @@ -1,10 +1,12 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using CalamityMod.Buffs.DamageOverTime; + namespace CalamityMod.Projectiles.Melee { public class SpatialSpear : ModProjectile, ILocalizedModType @@ -88,20 +90,23 @@ namespace CalamityMod.Projectiles.Melee Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); return false; } - + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 30); + } public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item10, Projectile.position); - for (int num795 = 4; num795 < 12; num795++) + for (int i = 4; i < 12; i++) { - float num796 = Projectile.oldVelocity.X * (30f / num795); - float num797 = Projectile.oldVelocity.Y * (30f / num795); - int num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, 107, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); - Main.dust[num798].noGravity = true; - Dust dust = Main.dust[num798]; + float projOldX = Projectile.oldVelocity.X * (30f / i); + float projOldY = Projectile.oldVelocity.Y * (30f / i); + int spatial = Dust.NewDust(new Vector2(Projectile.oldPosition.X - projOldX, Projectile.oldPosition.Y - projOldY), 8, 8, 107, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); + Main.dust[spatial].noGravity = true; + Dust dust = Main.dust[spatial]; dust.velocity *= 0.5f; - num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, 107, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); - dust = Main.dust[num798]; + spatial = Dust.NewDust(new Vector2(Projectile.oldPosition.X - projOldX, Projectile.oldPosition.Y - projOldY), 8, 8, 107, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); + dust = Main.dust[spatial]; dust.velocity *= 0.05f; } } diff --git a/Projectiles/Melee/SpatialSpear2.cs b/Projectiles/Melee/SpatialSpear2.cs index 7393c1247e..7deac57c88 100644 --- a/Projectiles/Melee/SpatialSpear2.cs +++ b/Projectiles/Melee/SpatialSpear2.cs @@ -1,3 +1,4 @@ +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -76,19 +77,22 @@ namespace CalamityMod.Projectiles.Melee Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); return false; } - + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 30); + } public override void OnKill(int timeLeft) { - for (int num795 = 4; num795 < 12; num795++) + for (int i = 4; i < 12; i++) { - float num796 = Projectile.oldVelocity.X * (30f / num795); - float num797 = Projectile.oldVelocity.Y * (30f / num795); - int num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, 56, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); - Main.dust[num798].noGravity = true; - Dust dust = Main.dust[num798]; + float projOldX = Projectile.oldVelocity.X * (30f / i); + float projOldY = Projectile.oldVelocity.Y * (30f / i); + int spatial = Dust.NewDust(new Vector2(Projectile.oldPosition.X - projOldX, Projectile.oldPosition.Y - projOldY), 8, 8, 56, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); + Main.dust[spatial].noGravity = true; + Dust dust = Main.dust[spatial]; dust.velocity *= 0.5f; - num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, 56, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); - dust = Main.dust[num798]; + spatial = Dust.NewDust(new Vector2(Projectile.oldPosition.X - projOldX, Projectile.oldPosition.Y - projOldY), 8, 8, 56, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); + dust = Main.dust[spatial]; dust.velocity *= 0.05f; } } diff --git a/Projectiles/Melee/SpatialSpear3.cs b/Projectiles/Melee/SpatialSpear3.cs index ea6ee5469e..00b8011745 100644 --- a/Projectiles/Melee/SpatialSpear3.cs +++ b/Projectiles/Melee/SpatialSpear3.cs @@ -1,3 +1,4 @@ +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -74,19 +75,22 @@ namespace CalamityMod.Projectiles.Melee Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); return false; } - + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 30); + } public override void OnKill(int timeLeft) { - for (int num795 = 4; num795 < 12; num795++) + for (int i = 4; i < 12; i++) { - float num796 = Projectile.oldVelocity.X * (30f / num795); - float num797 = Projectile.oldVelocity.Y * (30f / num795); - int num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, 73, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); - Main.dust[num798].noGravity = true; - Dust dust = Main.dust[num798]; + float projOldX = Projectile.oldVelocity.X * (30f / i); + float projOldY = Projectile.oldVelocity.Y * (30f / i); + int spatial = Dust.NewDust(new Vector2(Projectile.oldPosition.X - projOldX, Projectile.oldPosition.Y - projOldY), 8, 8, 73, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); + Main.dust[spatial].noGravity = true; + Dust dust = Main.dust[spatial]; dust.velocity *= 0.5f; - num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, 73, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); - dust = Main.dust[num798]; + spatial = Dust.NewDust(new Vector2(Projectile.oldPosition.X - projOldX, Projectile.oldPosition.Y - projOldY), 8, 8, 73, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); + dust = Main.dust[spatial]; dust.velocity *= 0.05f; } } diff --git a/Projectiles/Melee/SpatialSpear4.cs b/Projectiles/Melee/SpatialSpear4.cs index cef1703f55..89f1712f64 100644 --- a/Projectiles/Melee/SpatialSpear4.cs +++ b/Projectiles/Melee/SpatialSpear4.cs @@ -1,3 +1,4 @@ +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -59,19 +60,22 @@ namespace CalamityMod.Projectiles.Melee Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); return false; } - + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 30); + } public override void OnKill(int timeLeft) { - for (int num795 = 4; num795 < 12; num795++) + for (int i = 4; i < 12; i++) { - float num796 = Projectile.oldVelocity.X * (30f / num795); - float num797 = Projectile.oldVelocity.Y * (30f / num795); - int num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, 244, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); - Main.dust[num798].noGravity = true; - Dust dust = Main.dust[num798]; + float projOldX = Projectile.oldVelocity.X * (30f / i); + float projOldY = Projectile.oldVelocity.Y * (30f / i); + int spatial = Dust.NewDust(new Vector2(Projectile.oldPosition.X - projOldX, Projectile.oldPosition.Y - projOldY), 8, 8, 244, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); + Main.dust[spatial].noGravity = true; + Dust dust = Main.dust[spatial]; dust.velocity *= 0.5f; - num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, 244, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); - dust = Main.dust[num798]; + spatial = Dust.NewDust(new Vector2(Projectile.oldPosition.X - projOldX, Projectile.oldPosition.Y - projOldY), 8, 8, 244, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); + dust = Main.dust[spatial]; dust.velocity *= 0.05f; } } diff --git a/Projectiles/Melee/Spears/BrimlanceProj.cs b/Projectiles/Melee/Spears/BrimlanceProj.cs index c7583bbda7..07d0b2f5d9 100644 --- a/Projectiles/Melee/Spears/BrimlanceProj.cs +++ b/Projectiles/Melee/Spears/BrimlanceProj.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Melee.Spears Projectile.ownerHitCheck = true; Projectile.hide = true; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 12; + Projectile.localNPCHitCooldown = 60; } public override float InitialSpeed => 3f; @@ -45,12 +45,12 @@ namespace CalamityMod.Projectiles.Melee.Spears if (Projectile.owner == Main.myPlayer) { if (Main.player[Projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()] < 3) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.65), hit.Knockback, Main.myPlayer); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.35), hit.Knockback, Main.myPlayer); for (int i = 0; i < 2; i++) { Vector2 fireVelocity = new Vector2(0f, Main.rand.NextFloat(7f, 10f)).RotatedByRandom(MathHelper.TwoPi); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center, fireVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.4), 0f, Projectile.owner, 0f, 0f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center, fireVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.25), 0f, Projectile.owner, 0f, 0f); } } } diff --git a/Projectiles/Melee/Spears/ElementalLanceProjectile.cs b/Projectiles/Melee/Spears/ElementalLanceProjectile.cs index 5e5f90a1ac..1e307d5728 100644 --- a/Projectiles/Melee/Spears/ElementalLanceProjectile.cs +++ b/Projectiles/Melee/Spears/ElementalLanceProjectile.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using System; @@ -41,5 +42,9 @@ namespace CalamityMod.Projectiles.Melee.Spears Main.dust[idx].noGravity = true; } } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 60); + } } } diff --git a/Projectiles/Melee/Spears/GildedProboscisProj.cs b/Projectiles/Melee/Spears/GildedProboscisProj.cs index e7caef897e..90265cc36b 100644 --- a/Projectiles/Melee/Spears/GildedProboscisProj.cs +++ b/Projectiles/Melee/Spears/GildedProboscisProj.cs @@ -33,8 +33,8 @@ namespace CalamityMod.Projectiles.Melee.Spears { if (Main.rand.NextBool(4)) { - int num = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 60, Projectile.direction * 2, 0f, 150, default, 1f); - Main.dust[num].noGravity = true; + int dust = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 60, Projectile.direction * 2, 0f, 150, default, 1f); + Main.dust[dust].noGravity = true; } } diff --git a/Projectiles/Melee/Spears/RedtideSpearProjectile.cs b/Projectiles/Melee/Spears/RedtideSpearProjectile.cs index 107a2f8429..e1852bf8bb 100644 --- a/Projectiles/Melee/Spears/RedtideSpearProjectile.cs +++ b/Projectiles/Melee/Spears/RedtideSpearProjectile.cs @@ -282,7 +282,7 @@ namespace CalamityMod.Projectiles.Melee.Spears public void UpdateOwnerVars() { - Owner.direction = Math.Sign(BaseRotation.ToRotationVector2().X); + Owner.ChangeDir(Math.Sign(BaseRotation.ToRotationVector2().X)); Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, AppropriateRotation - MathHelper.PiOver2); Owner.heldProj = Projectile.whoAmI; Owner.itemTime = 2; diff --git a/Projectiles/Melee/Spears/StreamGougeProj.cs b/Projectiles/Melee/Spears/StreamGougeProj.cs index 93a0494001..44a50069ab 100644 --- a/Projectiles/Melee/Spears/StreamGougeProj.cs +++ b/Projectiles/Melee/Spears/StreamGougeProj.cs @@ -92,7 +92,7 @@ namespace CalamityMod.Projectiles.Melee.Spears public void DeterminePlayerVariables() { bool spearStillInUse = Owner.channel && !Owner.noItems && !Owner.CCed; - Owner.direction = (Math.Cos(Projectile.rotation - MathHelper.Pi + MathHelper.PiOver4) > 0f).ToDirectionInt(); + Owner.ChangeDir((Math.Cos(Projectile.rotation - MathHelper.Pi + MathHelper.PiOver4) > 0f).ToDirectionInt()); Owner.heldProj = Projectile.whoAmI; Owner.itemTime = Owner.itemAnimation = 2; Owner.itemRotation = CalamityUtils.WrapAngle90Degrees(MathHelper.WrapAngle(Projectile.rotation - MathHelper.Pi + MathHelper.PiOver4)); diff --git a/Projectiles/Melee/Spears/TenebreusTidesProjectile.cs b/Projectiles/Melee/Spears/TenebreusTidesProjectile.cs index efd00ad02a..9d240acb20 100644 --- a/Projectiles/Melee/Spears/TenebreusTidesProjectile.cs +++ b/Projectiles/Melee/Spears/TenebreusTidesProjectile.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Melee.Spears public override Action EffectBeforeReelback => (proj) => { Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X + Projectile.velocity.X, Projectile.Center.Y + Projectile.velocity.Y, Projectile.velocity.X * 2.4f, Projectile.velocity.Y * 2.4f, - ModContent.ProjectileType(), (int)(Projectile.damage * 0.65), Projectile.knockBack * 0.85f, Projectile.owner, 0f, 0f); + ModContent.ProjectileType(), (int)(Projectile.damage * 0.75), Projectile.knockBack * 0.85f, Projectile.owner, 0f, 0f); }; public override void ExtraBehavior() { diff --git a/Projectiles/Melee/StarnightBeam.cs b/Projectiles/Melee/StarnightBeam.cs index 3a304cf341..1fff404fd7 100644 --- a/Projectiles/Melee/StarnightBeam.cs +++ b/Projectiles/Melee/StarnightBeam.cs @@ -49,18 +49,18 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item10, Projectile.position); - int num3; - for (int num795 = 4; num795 < 31; num795 = num3 + 1) + int inc; + for (int i = 4; i < 31; i = inc + 1) { - float num796 = Projectile.oldVelocity.X * (30f / (float)num795); - float num797 = Projectile.oldVelocity.Y * (30f / (float)num795); - int num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, 73, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); - Dust dust = Main.dust[num798]; + float projOldX = Projectile.oldVelocity.X * (30f / (float)i); + float projOldY = Projectile.oldVelocity.Y * (30f / (float)i); + int starnight = Dust.NewDust(new Vector2(Projectile.oldPosition.X - projOldX, Projectile.oldPosition.Y - projOldY), 8, 8, 73, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); + Dust dust = Main.dust[starnight]; dust.noGravity = true; dust.velocity *= 0.5f; - num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, 73, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); + starnight = Dust.NewDust(new Vector2(Projectile.oldPosition.X - projOldX, Projectile.oldPosition.Y - projOldY), 8, 8, 73, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); dust.velocity *= 0.05f; - num3 = num795; + inc = i; } } diff --git a/Projectiles/Melee/StellarContemptEcho.cs b/Projectiles/Melee/StellarContemptEcho.cs index eb29069ef3..239a386e4e 100644 --- a/Projectiles/Melee/StellarContemptEcho.cs +++ b/Projectiles/Melee/StellarContemptEcho.cs @@ -27,8 +27,8 @@ namespace CalamityMod.Projectiles.Melee // This is all copied straight from PwnagehammerEcho with some minor edits. public override void SetDefaults() { - Projectile.width = 78; - Projectile.height = 78; + Projectile.width = 74; + Projectile.height = 76; Projectile.aiStyle = 0; Projectile.friendly = true; Projectile.DamageType = DamageClass.MeleeNoSpeed; diff --git a/Projectiles/Melee/StellarContemptEcho.png b/Projectiles/Melee/StellarContemptEcho.png index 52a0f0c8b1..d79240b38f 100644 Binary files a/Projectiles/Melee/StellarContemptEcho.png and b/Projectiles/Melee/StellarContemptEcho.png differ diff --git a/Projectiles/Melee/StellarContemptHammer.cs b/Projectiles/Melee/StellarContemptHammer.cs index 6146c8cb4c..56522501b2 100644 --- a/Projectiles/Melee/StellarContemptHammer.cs +++ b/Projectiles/Melee/StellarContemptHammer.cs @@ -18,7 +18,6 @@ namespace CalamityMod.Projectiles.Melee public static readonly SoundStyle UseSound = new("CalamityMod/Sounds/Item/PwnagehammerSound") { Volume = 0.35f}; public static readonly SoundStyle RedHamSound = new("CalamityMod/Sounds/Item/StellarContemptClone") { Volume = 0.6f }; public static readonly SoundStyle UseSoundFunny = new("CalamityMod/Sounds/Item/CalamityBell") { Volume = 1.5f}; - private static float StartDustQuantity = 26f; public ref int EmpoweredHammer => ref Main.player[Projectile.owner].Calamity().StellarHammer; public int returnhammer = 0; @@ -270,7 +269,8 @@ namespace CalamityMod.Projectiles.Melee public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - Projectile.damage = (int)(Projectile.damage * 0.9f); + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.9f); if (Projectile.damage < 1) Projectile.damage = 1; } diff --git a/Projectiles/Melee/StormMark.cs b/Projectiles/Melee/StormMark.cs index 3a86561206..163effed93 100644 --- a/Projectiles/Melee/StormMark.cs +++ b/Projectiles/Melee/StormMark.cs @@ -36,34 +36,34 @@ namespace CalamityMod.Projectiles.Melee } if (Projectile.localAI[1] < 30f) { - for (int num1134 = 0; num1134 < 1; num1134++) + for (int i = 0; i < 1; i++) { - float value79 = -0.5f; - float value80 = 0.9f; - float amount4 = Main.rand.NextFloat(); - Vector2 value81 = new Vector2(MathHelper.Lerp(0.1f, 1f, Main.rand.NextFloat()), MathHelper.Lerp(value79, value80, amount4)); - value81.X *= MathHelper.Lerp(2.2f, 0.6f, amount4); - value81.X *= -1f; - Vector2 value82 = new Vector2(2f, 10f); - Vector2 position4 = Projectile.Center + new Vector2(60f, 200f) * value81 * 0.5f + value82; - Dust dust34 = Main.dust[Dust.NewDust(position4, 0, 0, 187, 0f, 0f, 0, default, 0.5f)]; - dust34.position = position4; - dust34.customData = Projectile.Center + value82; - dust34.fadeIn = 1f; - dust34.scale = 0.3f; - if (value81.X > -1.2f) + float lerpvalue1 = -0.5f; + float lerpvalue2 = 0.9f; + float randomLerp = Main.rand.NextFloat(); + Vector2 dustMovement = new Vector2(MathHelper.Lerp(0.1f, 1f, Main.rand.NextFloat()), MathHelper.Lerp(lerpvalue1, lerpvalue2, randomLerp)); + dustMovement.X *= MathHelper.Lerp(2.2f, 0.6f, randomLerp); + dustMovement.X *= -1f; + Vector2 dustMovement2 = new Vector2(2f, 10f); + Vector2 position4 = Projectile.Center + new Vector2(60f, 200f) * dustMovement * 0.5f + dustMovement2; + Dust stormy = Main.dust[Dust.NewDust(position4, 0, 0, 187, 0f, 0f, 0, default, 0.5f)]; + stormy.position = position4; + stormy.customData = Projectile.Center + dustMovement2; + stormy.fadeIn = 1f; + stormy.scale = 0.3f; + if (dustMovement.X > -1.2f) { - dust34.velocity.X = 1f + Main.rand.NextFloat(); + stormy.velocity.X = 1f + Main.rand.NextFloat(); } - dust34.velocity.Y = Main.rand.NextFloat() * -0.5f - 1f; + stormy.velocity.Y = Main.rand.NextFloat() * -0.5f - 1f; } } if (Projectile.localAI[0] == 0f) { Projectile.localAI[0] = 0.8f; Projectile.direction = 1; - Point point9 = Projectile.Center.ToTileCoordinates(); - Projectile.Center = new Vector2((float)(point9.X * 16 + 8), (float)(point9.Y * 16 + 8)); + Point projCenter = Projectile.Center.ToTileCoordinates(); + Projectile.Center = new Vector2((float)(projCenter.X * 16 + 8), (float)(projCenter.Y * 16 + 8)); } Projectile.rotation = Projectile.localAI[1] / 40f * 6.28318548f * (float)Projectile.direction; if (Projectile.localAI[1] < 33f) @@ -92,30 +92,30 @@ namespace CalamityMod.Projectiles.Melee { Lighting.AddLight(Projectile.Center, newColor3.ToVector3() * 0.5f); } - for (int num1135 = 0; num1135 < 2; num1135++) + for (int j = 0; j < 2; j++) { if (Main.rand.NextBool(10)) { - Vector2 value83 = Vector2.UnitY.RotatedBy((double)((float)num1135 * 3.14159274f), default).RotatedBy((double)Projectile.rotation, default); - Dust dust35 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 187, 0f, 0f, 225, newColor3, 1f)]; - dust35.noGravity = true; - dust35.noLight = true; - dust35.scale = Projectile.Opacity * Projectile.localAI[0]; - dust35.position = Projectile.Center; - dust35.velocity = value83 * 2.5f; + Vector2 dustVel = Vector2.UnitY.RotatedBy((double)((float)j * 3.14159274f), default).RotatedBy((double)Projectile.rotation, default); + Dust stormDust = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 187, 0f, 0f, 225, newColor3, 1f)]; + stormDust.noGravity = true; + stormDust.noLight = true; + stormDust.scale = Projectile.Opacity * Projectile.localAI[0]; + stormDust.position = Projectile.Center; + stormDust.velocity = dustVel * 2.5f; } } for (int num1136 = 0; num1136 < 2; num1136++) { if (Main.rand.NextBool(10)) { - Vector2 value84 = Vector2.UnitY.RotatedBy((double)((float)num1136 * 3.14159274f), default); - Dust dust36 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 187, 0f, 0f, 225, newColor3, 1.5f)]; - dust36.noGravity = true; - dust36.noLight = true; - dust36.scale = Projectile.Opacity * Projectile.localAI[0]; - dust36.position = Projectile.Center; - dust36.velocity = value84 * 2.5f; + Vector2 dustVel2 = Vector2.UnitY.RotatedBy((double)((float)num1136 * 3.14159274f), default); + Dust stormDust2 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 187, 0f, 0f, 225, newColor3, 1.5f)]; + stormDust2.noGravity = true; + stormDust2.noLight = true; + stormDust2.scale = Projectile.Opacity * Projectile.localAI[0]; + stormDust2.position = Projectile.Center; + stormDust2.velocity = dustVel2 * 2.5f; } } if (Projectile.localAI[1] < 33f || Projectile.localAI[1] > 87f) @@ -136,16 +136,16 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { - Color color25 = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); - Vector2 vector38 = Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; + Color originalColor = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); + Vector2 drawPos = Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; Texture2D texture2D27 = ModContent.Request(Texture).Value; - Rectangle rectangle11 = texture2D27.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); - Color alpha5 = Projectile.GetAlpha(color25); - Vector2 origin7 = rectangle11.Size() / 2f; - Color color47 = Main.hslToRgb(0.25f, 1f, 1f).MultiplyRGBA(new Color(255, 255, 255, 0)); - Main.spriteBatch.Draw(texture2D27, vector38, new Microsoft.Xna.Framework.Rectangle?(rectangle11), color47, 0f, origin7, new Vector2(1f, 5f) * Projectile.scale * 2f, SpriteEffects.None, 0); - Main.spriteBatch.Draw(texture2D27, vector38, new Microsoft.Xna.Framework.Rectangle?(rectangle11), alpha5, Projectile.rotation, origin7, Projectile.scale, SpriteEffects.None, 0); - Main.spriteBatch.Draw(texture2D27, vector38, new Microsoft.Xna.Framework.Rectangle?(rectangle11), alpha5, 0f, origin7, new Vector2(1f, 8f) * Projectile.scale, SpriteEffects.None, 0); + Rectangle rectangl = texture2D27.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); + Color alphaColor = Projectile.GetAlpha(originalColor); + Vector2 halfRect = rectangl.Size() / 2f; + Color whiteColor = Main.hslToRgb(0.25f, 1f, 1f).MultiplyRGBA(new Color(255, 255, 255, 0)); + Main.spriteBatch.Draw(texture2D27, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangl), whiteColor, 0f, halfRect, new Vector2(1f, 5f) * Projectile.scale * 2f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(texture2D27, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangl), alphaColor, Projectile.rotation, halfRect, Projectile.scale, SpriteEffects.None, 0); + Main.spriteBatch.Draw(texture2D27, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangl), alphaColor, 0f, halfRect, new Vector2(1f, 8f) * Projectile.scale, SpriteEffects.None, 0); return false; } } diff --git a/Projectiles/Melee/StreamGougePortal.cs b/Projectiles/Melee/StreamGougePortal.cs index 3312c33872..b7b02a5d1c 100644 --- a/Projectiles/Melee/StreamGougePortal.cs +++ b/Projectiles/Melee/StreamGougePortal.cs @@ -7,14 +7,15 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; -using CalamityMod.Particles.Metaballs; +using CalamityMod.Graphics.Metaballs; namespace CalamityMod.Projectiles.Melee { public class StreamGougePortal : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; - public static readonly SoundStyle SpawnSound = new SoundStyle("CalamityMod/Sounds/Custom/SwiftSlice") + + public static readonly SoundStyle SpawnSound = new("CalamityMod/Sounds/Custom/SwiftSlice") { PitchVariance = 0.1f }; @@ -43,7 +44,8 @@ namespace CalamityMod.Projectiles.Melee // Play a slice sound when spawning. if (Projectile.localAI[0] == 0f) { - SoundEngine.PlaySound(SpawnSound, Projectile.Center); + float volume = Utils.Remap(Main.LocalPlayer.Distance(Projectile.Center), 600f, 100f, 0.12f, 0.5f); + SoundEngine.PlaySound(SpawnSound with { Volume = volume }, Projectile.Center); Projectile.localAI[0] = 1f; } @@ -106,11 +108,12 @@ namespace CalamityMod.Projectiles.Melee for (int i = 0; i < 20; i++) { Vector2 spawnPosition = target.Center + Main.rand.NextVector2Circular(30f, 30f); - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(spawnPosition, 60f); + StreamGougeMetaball.SpawnParticle(spawnPosition, Main.rand.NextVector2Circular(3f, 3f), 60f); float scale = MathHelper.Lerp(24f, 64f, CalamityUtils.Convert01To010(i / 19f)); spawnPosition = target.Center + Projectile.velocity.SafeNormalize(Vector2.UnitY) * MathHelper.Lerp(-40f, 90f, i / 19f); - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(spawnPosition, scale); + Vector2 particleVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(0.23f) * Main.rand.NextFloat(2.5f, 9f); + StreamGougeMetaball.SpawnParticle(spawnPosition, particleVelocity, scale); } } diff --git a/Projectiles/Melee/StygianShieldAttack.cs b/Projectiles/Melee/StygianShieldAttack.cs index f6e9a7961e..48381f102e 100644 --- a/Projectiles/Melee/StygianShieldAttack.cs +++ b/Projectiles/Melee/StygianShieldAttack.cs @@ -88,7 +88,7 @@ namespace CalamityMod.Projectiles.Melee // Actually set the owner center if there's no issues Owner.Center = Projectile.Center; - Owner.direction = Projectile.direction; + Owner.ChangeDir(Projectile.direction); return; } diff --git a/Projectiles/Melee/SulphurousGrabberBubble.cs b/Projectiles/Melee/SulphurousGrabberBubble.cs index 5054d746ab..1898eba9e7 100644 --- a/Projectiles/Melee/SulphurousGrabberBubble.cs +++ b/Projectiles/Melee/SulphurousGrabberBubble.cs @@ -32,13 +32,13 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item54, Projectile.position); - int num190 = Main.rand.Next(5, 9); - for (int num191 = 0; num191 < num190; num191++) + int randAmt = Main.rand.Next(5, 9); + for (int i = 0; i < randAmt; i++) { - int num192 = Dust.NewDust(Projectile.Center, 0, 0, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 1.4f); - Main.dust[num192].velocity *= 0.8f; - Main.dust[num192].position = Vector2.Lerp(Main.dust[num192].position, Projectile.Center, 0.5f); - Main.dust[num192].noGravity = true; + int toxicDust = Dust.NewDust(Projectile.Center, 0, 0, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 1.4f); + Main.dust[toxicDust].velocity *= 0.8f; + Main.dust[toxicDust].position = Vector2.Lerp(Main.dust[toxicDust].position, Projectile.Center, 0.5f); + Main.dust[toxicDust].noGravity = true; } } } diff --git a/Projectiles/Melee/SulphurousGrabberBubble2.cs b/Projectiles/Melee/SulphurousGrabberBubble2.cs index 3930c4100b..b16fdbf074 100644 --- a/Projectiles/Melee/SulphurousGrabberBubble2.cs +++ b/Projectiles/Melee/SulphurousGrabberBubble2.cs @@ -33,13 +33,13 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item54, Projectile.position); - int num190 = Main.rand.Next(5, 9); - for (int num191 = 0; num191 < num190; num191++) + int randAmt = Main.rand.Next(5, 9); + for (int i = 0; i < randAmt; i++) { - int num192 = Dust.NewDust(Projectile.Center, 0, 0, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 1.4f); - Main.dust[num192].velocity *= 0.8f; - Main.dust[num192].position = Vector2.Lerp(Main.dust[num192].position, Projectile.Center, 0.5f); - Main.dust[num192].noGravity = true; + int toxicDust = Dust.NewDust(Projectile.Center, 0, 0, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 1.4f); + Main.dust[toxicDust].velocity *= 0.8f; + Main.dust[toxicDust].position = Vector2.Lerp(Main.dust[toxicDust].position, Projectile.Center, 0.5f); + Main.dust[toxicDust].noGravity = true; } } } diff --git a/Projectiles/Melee/SunlightBlade.cs b/Projectiles/Melee/SunlightBlade.cs index c15eaaf153..e416eef8b9 100644 --- a/Projectiles/Melee/SunlightBlade.cs +++ b/Projectiles/Melee/SunlightBlade.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -23,13 +23,13 @@ namespace CalamityMod.Projectiles.Melee Projectile.friendly = true; Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Melee; - Projectile.penetrate = 3; + Projectile.penetrate = 6; Projectile.ignoreWater = true; AIType = ProjectileID.DeathSickle; Projectile.MaxUpdates = 2; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10 * Projectile.MaxUpdates; - Projectile.timeLeft = 90 * Projectile.MaxUpdates; + Projectile.timeLeft = 150 * Projectile.MaxUpdates; } public override void AI() diff --git a/Projectiles/Melee/SwordsplosionBlue.cs b/Projectiles/Melee/SwordsplosionBlue.cs index 4e0c6b87b6..ea04cb0b27 100644 --- a/Projectiles/Melee/SwordsplosionBlue.cs +++ b/Projectiles/Melee/SwordsplosionBlue.cs @@ -29,9 +29,9 @@ namespace CalamityMod.Projectiles.Melee Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.3f / 255f, (255 - Projectile.alpha) * 0.4f / 255f, (255 - Projectile.alpha) * 1f / 255f); if (Projectile.localAI[1] > 7f) { - int num308 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, new Color(Main.DiscoR, 203, 103), 1.2f); - Main.dust[num308].velocity *= 0.1f; - Main.dust[num308].noGravity = true; + int blueBoi = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, new Color(Main.DiscoR, 203, 103), 1.2f); + Main.dust[blueBoi].velocity *= 0.1f; + Main.dust[blueBoi].noGravity = true; } Projectile.rotation = Projectile.velocity.ToRotation() + (float)Math.Atan(90); } @@ -55,8 +55,8 @@ namespace CalamityMod.Projectiles.Melee { for (int k = 0; k < 7; k++) { - int num308 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, 0f, 0f, 150, new Color(Main.DiscoR, 203, 103), 1.2f); - Main.dust[num308].noGravity = true; + int blueBoi = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, 0f, 0f, 150, new Color(Main.DiscoR, 203, 103), 1.2f); + Main.dust[blueBoi].noGravity = true; } } } diff --git a/Projectiles/Melee/SwordsplosionGreen.cs b/Projectiles/Melee/SwordsplosionGreen.cs index 4c6520db9a..8643a98643 100644 --- a/Projectiles/Melee/SwordsplosionGreen.cs +++ b/Projectiles/Melee/SwordsplosionGreen.cs @@ -28,9 +28,9 @@ namespace CalamityMod.Projectiles.Melee Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.3f / 255f, (255 - Projectile.alpha) * 0.4f / 255f, (255 - Projectile.alpha) * 1f / 255f); if (Projectile.localAI[1] > 7f) { - int num308 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, new Color(53, Main.DiscoG, 255), 1.2f); - Main.dust[num308].velocity *= 0.1f; - Main.dust[num308].noGravity = true; + int greenBoi = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, new Color(53, Main.DiscoG, 255), 1.2f); + Main.dust[greenBoi].velocity *= 0.1f; + Main.dust[greenBoi].noGravity = true; } Projectile.rotation = Projectile.velocity.ToRotation() + (float)Math.Atan(90); } @@ -54,8 +54,8 @@ namespace CalamityMod.Projectiles.Melee { for (int k = 0; k < 7; k++) { - int num308 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, 0f, 0f, 150, new Color(53, Main.DiscoG, 255), 1.2f); - Main.dust[num308].noGravity = true; + int greenBoi = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, 0f, 0f, 150, new Color(53, Main.DiscoG, 255), 1.2f); + Main.dust[greenBoi].noGravity = true; } } } diff --git a/Projectiles/Melee/SwordsplosionPurple.cs b/Projectiles/Melee/SwordsplosionPurple.cs index 992fc4b9ba..8dd5acffab 100644 --- a/Projectiles/Melee/SwordsplosionPurple.cs +++ b/Projectiles/Melee/SwordsplosionPurple.cs @@ -29,9 +29,9 @@ namespace CalamityMod.Projectiles.Melee Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.3f / 255f, (255 - Projectile.alpha) * 0.4f / 255f, (255 - Projectile.alpha) * 1f / 255f); if (Projectile.localAI[1] > 7f) { - int num308 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, new Color(Main.DiscoR, 100, 255), 1.2f); - Main.dust[num308].velocity *= 0.1f; - Main.dust[num308].noGravity = true; + int purpleBoi = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, new Color(Main.DiscoR, 100, 255), 1.2f); + Main.dust[purpleBoi].velocity *= 0.1f; + Main.dust[purpleBoi].noGravity = true; } Projectile.rotation = Projectile.velocity.ToRotation() + (float)Math.Atan(90); } @@ -55,8 +55,8 @@ namespace CalamityMod.Projectiles.Melee { for (int k = 0; k < 7; k++) { - int num308 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, 0f, 0f, 150, new Color(Main.DiscoR, 100, 255), 1.2f); - Main.dust[num308].noGravity = true; + int purpleBoi = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, 0f, 0f, 150, new Color(Main.DiscoR, 100, 255), 1.2f); + Main.dust[purpleBoi].noGravity = true; } } } diff --git a/Projectiles/Melee/SwordsplosionRed.cs b/Projectiles/Melee/SwordsplosionRed.cs index e56c929093..eb591be3bc 100644 --- a/Projectiles/Melee/SwordsplosionRed.cs +++ b/Projectiles/Melee/SwordsplosionRed.cs @@ -29,9 +29,9 @@ namespace CalamityMod.Projectiles.Melee Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.3f / 255f, (255 - Projectile.alpha) * 0.4f / 255f, (255 - Projectile.alpha) * 1f / 255f); if (Projectile.localAI[1] > 7f) { - int num308 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, new Color(255, Main.DiscoG, 53), 1.2f); - Main.dust[num308].velocity *= 0.1f; - Main.dust[num308].noGravity = true; + int redBoi = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, new Color(255, Main.DiscoG, 53), 1.2f); + Main.dust[redBoi].velocity *= 0.1f; + Main.dust[redBoi].noGravity = true; } Projectile.rotation = Projectile.velocity.ToRotation() + (float)Math.Atan(90); } @@ -55,8 +55,8 @@ namespace CalamityMod.Projectiles.Melee { for (int k = 0; k < 7; k++) { - int num308 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, 0f, 0f, 150, new Color(255, Main.DiscoG, 53), 1.2f); - Main.dust[num308].noGravity = true; + int redBoi = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, 0f, 0f, 150, new Color(255, Main.DiscoG, 53), 1.2f); + Main.dust[redBoi].noGravity = true; } } } diff --git a/Projectiles/Melee/TenebreusTidesWaterProjectile.cs b/Projectiles/Melee/TenebreusTidesWaterProjectile.cs index 32924bb95c..ea37d33a7c 100644 --- a/Projectiles/Melee/TenebreusTidesWaterProjectile.cs +++ b/Projectiles/Melee/TenebreusTidesWaterProjectile.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.aiStyle = ProjAIStyleID.Beam; Projectile.friendly = true; Projectile.DamageType = DamageClass.Melee; - Projectile.penetrate = -1; + Projectile.penetrate = 5; Projectile.timeLeft = 300; Projectile.ignoreWater = true; Projectile.usesIDStaticNPCImmunity = true; @@ -93,14 +93,14 @@ namespace CalamityMod.Projectiles.Melee // Spawns a storm of water projectiles on-hit. public void SwordSpam(Vector2 targetPos) { - int projAmt = 3; + int projAmt = 2; var source = Projectile.GetSource_FromThis(); for (int i = 0; i < projAmt; ++i) { int type = Main.rand.NextBool() ? ModContent.ProjectileType() : ModContent.ProjectileType(); if (Projectile.owner == Main.myPlayer) { - CalamityUtils.ProjectileBarrage(source, Projectile.Center, targetPos, Main.rand.NextBool(), 1000f, 1400f, 80f, 900f, Main.rand.NextFloat(25f, 35f), type, Projectile.damage / 2, Projectile.knockBack * 0.5f, Projectile.owner); + CalamityUtils.ProjectileBarrage(source, Projectile.Center, targetPos, Main.rand.NextBool(), 1000f, 1400f, 80f, 900f, Main.rand.NextFloat(25f, 35f), type, (int)(Projectile.damage * 0.4f), Projectile.knockBack * 0.5f, Projectile.owner); } } } diff --git a/Projectiles/Melee/TenebreusTidesWaterSpear.cs b/Projectiles/Melee/TenebreusTidesWaterSpear.cs index fe24abe9fe..05a3840fc4 100644 --- a/Projectiles/Melee/TenebreusTidesWaterSpear.cs +++ b/Projectiles/Melee/TenebreusTidesWaterSpear.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Projectiles.Melee public new string LocalizationCategory => "Projectiles.Melee"; public override string Texture => "CalamityMod/Projectiles/Magic/UndinesRetributionSpear"; - private int penetrationAmt = 4; + private int penetrationAmt = 2; private bool dontDraw = false; private int drawInt = 0; @@ -29,8 +29,9 @@ namespace CalamityMod.Projectiles.Melee Projectile.penetrate = penetrationAmt; Projectile.timeLeft = 600; Projectile.DamageType = DamageClass.Melee; + Projectile.extraUpdates = 2; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 5; + Projectile.localNPCHitCooldown = 5 * Projectile.MaxUpdates; Projectile.tileCollide = false; Projectile.ignoreWater = true; } diff --git a/Projectiles/Melee/TenebreusTidesWaterSword.cs b/Projectiles/Melee/TenebreusTidesWaterSword.cs index 6a6d36fccf..f4b305e391 100644 --- a/Projectiles/Melee/TenebreusTidesWaterSword.cs +++ b/Projectiles/Melee/TenebreusTidesWaterSword.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Projectiles.Melee public class TenebreusTidesWaterSword : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; - private int penetrationAmt = 4; + private int penetrationAmt = 2; private bool dontDraw = false; private int drawInt = 0; @@ -22,8 +22,9 @@ namespace CalamityMod.Projectiles.Melee Projectile.penetrate = penetrationAmt; Projectile.timeLeft = 600; Projectile.DamageType = DamageClass.Melee; + Projectile.extraUpdates = 2; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 5; + Projectile.localNPCHitCooldown = 5 * Projectile.MaxUpdates; Projectile.tileCollide = false; Projectile.ignoreWater = true; } diff --git a/Projectiles/Melee/TerraSpear.cs b/Projectiles/Melee/TerraSpear.cs index a542f77883..90e863d103 100644 --- a/Projectiles/Melee/TerraSpear.cs +++ b/Projectiles/Melee/TerraSpear.cs @@ -57,19 +57,19 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item10, Projectile.position); - int num3; - for (int num795 = 4; num795 < 31; num795 = num3 + 1) + int inc; + for (int i = 4; i < 31; i = inc + 1) { - float num796 = Projectile.oldVelocity.X * (30f / (float)num795); - float num797 = Projectile.oldVelocity.Y * (30f / (float)num795); - int num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, 107, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); - Main.dust[num798].noGravity = true; - Dust dust = Main.dust[num798]; + float projOldX = Projectile.oldVelocity.X * (30f / (float)i); + float projOldY = Projectile.oldVelocity.Y * (30f / (float)i); + int terraDust = Dust.NewDust(new Vector2(Projectile.oldPosition.X - projOldX, Projectile.oldPosition.Y - projOldY), 8, 8, 107, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); + Main.dust[terraDust].noGravity = true; + Dust dust = Main.dust[terraDust]; dust.velocity *= 0.5f; - num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, 107, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); - dust = Main.dust[num798]; + terraDust = Dust.NewDust(new Vector2(Projectile.oldPosition.X - projOldX, Projectile.oldPosition.Y - projOldY), 8, 8, 107, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); + dust = Main.dust[terraDust]; dust.velocity *= 0.05f; - num3 = num795; + inc = i; } } diff --git a/Projectiles/Melee/TerratomereHoldoutProj.cs b/Projectiles/Melee/TerratomereHoldoutProj.cs index 9963219b7f..64f582b1a2 100644 --- a/Projectiles/Melee/TerratomereHoldoutProj.cs +++ b/Projectiles/Melee/TerratomereHoldoutProj.cs @@ -145,7 +145,7 @@ namespace CalamityMod.Projectiles.Melee Owner.SetDummyItemTime(2); // Make the owner turn in the direction of the blade. - Owner.direction = Direction; + Owner.ChangeDir(Direction); } public void CreateProjectiles() diff --git a/Projectiles/Melee/TerrorBlast.cs b/Projectiles/Melee/TerrorBlast.cs index 86eb76f8f7..cf21a58e37 100644 --- a/Projectiles/Melee/TerrorBlast.cs +++ b/Projectiles/Melee/TerrorBlast.cs @@ -42,12 +42,12 @@ namespace CalamityMod.Projectiles.Melee for (int i = 0; i < 60; i++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 0, default, 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int scaryDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 0, default, 2.5f); + Main.dust[scaryDust].noGravity = true; + Main.dust[scaryDust].velocity *= 3f; + scaryDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.5f); + Main.dust[scaryDust].velocity *= 2f; + Main.dust[scaryDust].noGravity = true; } // Guarantee a hit on all nearby enemies when the projectile explodes. Changing localAI[0] enables it to hit. diff --git a/Projectiles/Melee/TinyCrystal.cs b/Projectiles/Melee/TinyCrystal.cs index 47a5cd8bca..2aa5998eff 100644 --- a/Projectiles/Melee/TinyCrystal.cs +++ b/Projectiles/Melee/TinyCrystal.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -27,27 +27,27 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { int dustType = Projectile.ai[0] == 0f ? 56 : 73; - for (int num92 = 0; num92 < 2; num92++) + for (int i = 0; i < 2; i++) { - float num93 = Projectile.velocity.X / 3f * (float)num92; - float num94 = Projectile.velocity.Y / 3f * (float)num92; - int num95 = 4; - int num96 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num95, Projectile.position.Y + (float)num95), Projectile.width - num95 * 2, Projectile.height - num95 * 2, dustType, 0f, 0f, 100, default, 1.2f); - Main.dust[num96].noGravity = true; - Main.dust[num96].velocity *= 0.1f; - Main.dust[num96].velocity += Projectile.velocity * 0.1f; - Dust expr_47FA_cp_0 = Main.dust[num96]; - expr_47FA_cp_0.position.X -= num93; - Dust expr_4815_cp_0 = Main.dust[num96]; - expr_4815_cp_0.position.Y -= num94; + float shortXVel = Projectile.velocity.X / 3f * (float)i; + float shortYVel = Projectile.velocity.Y / 3f * (float)i; + int dustPosModifier = 4; + int crystalDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)dustPosModifier, Projectile.position.Y + (float)dustPosModifier), Projectile.width - dustPosModifier * 2, Projectile.height - dustPosModifier * 2, dustType, 0f, 0f, 100, default, 1.2f); + Main.dust[crystalDust].noGravity = true; + Main.dust[crystalDust].velocity *= 0.1f; + Main.dust[crystalDust].velocity += Projectile.velocity * 0.1f; + Dust expr_47FA_cp_0 = Main.dust[crystalDust]; + expr_47FA_cp_0.position.X -= shortXVel; + Dust expr_4815_cp_0 = Main.dust[crystalDust]; + expr_4815_cp_0.position.Y -= shortYVel; } if (Main.rand.NextBool(10)) { - int num97 = 4; - int num98 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num97, Projectile.position.Y + (float)num97), Projectile.width - num97 * 2, Projectile.height - num97 * 2, dustType, 0f, 0f, 100, default, 0.6f); - Main.dust[num98].velocity *= 0.25f; - Main.dust[num98].velocity += Projectile.velocity * 0.5f; + int dustPosModifierAgain = 4; + int extraCrystalDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)dustPosModifierAgain, Projectile.position.Y + (float)dustPosModifierAgain), Projectile.width - dustPosModifierAgain * 2, Projectile.height - dustPosModifierAgain * 2, dustType, 0f, 0f, 100, default, 0.6f); + Main.dust[extraCrystalDust].velocity *= 0.25f; + Main.dust[extraCrystalDust].velocity += Projectile.velocity * 0.5f; } if (Projectile.timeLeft < 75) @@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - int buffType = Projectile.ai[0] == 0f ? BuffID.Frostburn : BuffID.OnFire; + int buffType = Projectile.ai[0] == 0f ? BuffID.Frostburn2 : BuffID.OnFire; target.AddBuff(buffType, 90); } } diff --git a/Projectiles/Melee/TinyFlare.cs b/Projectiles/Melee/TinyFlare.cs index 417f980dfc..ef6cb08da4 100644 --- a/Projectiles/Melee/TinyFlare.cs +++ b/Projectiles/Melee/TinyFlare.cs @@ -25,11 +25,11 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - for (int num468 = 0; num468 < 3; num468++) + for (int i = 0; i < 3; i++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 174, 0f, 0f, 100, default, 0.75f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int fiery = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 174, 0f, 0f, 100, default, 0.75f); + Main.dust[fiery].noGravity = true; + Main.dust[fiery].velocity *= 0f; } if (Projectile.timeLeft < 150) diff --git a/Projectiles/Melee/Tornado.cs b/Projectiles/Melee/Tornado.cs index 3ba1e8085d..8a0fe3f3eb 100644 --- a/Projectiles/Melee/Tornado.cs +++ b/Projectiles/Melee/Tornado.cs @@ -59,41 +59,40 @@ namespace CalamityMod.Projectiles.Melee } } - float num1125 = 900f; + float projTimer = 900f; if (Projectile.soundDelay == 0) { Projectile.soundDelay = -1; SoundEngine.PlaySound(SoundID.Item122, Projectile.Center); } Projectile.ai[0] += 1f; - if (Projectile.ai[0] >= num1125) + if (Projectile.ai[0] >= projTimer) { Projectile.Kill(); } if (Projectile.localAI[0] >= 30f) { Projectile.damage = 0; - if (Projectile.ai[0] < num1125 - 120f) + if (Projectile.ai[0] < projTimer - 120f) { - float num1126 = Projectile.ai[0] % 60f; - Projectile.ai[0] = num1125 - 120f + num1126; + float timeModulo = Projectile.ai[0] % 60f; + Projectile.ai[0] = projTimer - 120f + timeModulo; Projectile.netUpdate = true; } } - float num472 = Projectile.Center.X; - float num473 = Projectile.Center.Y; - float num474 = 600f; - for (int num475 = 0; num475 < Main.maxNPCs; num475++) + float projX = Projectile.Center.X; + float projY = Projectile.Center.Y; + for (int i = 0; i < Main.maxNPCs; i++) { - NPC npc = Main.npc[num475]; + NPC npc = Main.npc[i]; 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 num478 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcCenterX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcCenterY); - if (num478 < num474) + float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcCenterX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcCenterY); + if (npcDist < 600f) { - if (npc.position.X < num472) + if (npc.position.X < projX) { npc.velocity.X += 0.02f; } @@ -101,7 +100,7 @@ namespace CalamityMod.Projectiles.Melee { npc.velocity.X -= 0.02f; } - if (npc.position.Y < num473) + if (npc.position.Y < projY) { npc.velocity.Y += 0.02f; } @@ -112,44 +111,42 @@ namespace CalamityMod.Projectiles.Melee } } } - float num1127 = 15f; - float num1128 = 15f; - Point point8 = Projectile.Center.ToTileCoordinates(); - int num1129; - int num1130; - Collision.ExpandVertically(point8.X, point8.Y, out num1129, out num1130, (int)num1127, (int)num1128); - num1129++; - num1130--; - Vector2 value72 = new Vector2((float)point8.X, (float)num1129) * 16f + new Vector2(8f); - Vector2 value73 = new Vector2((float)point8.X, (float)num1130) * 16f + new Vector2(8f); - Vector2 vector146 = Vector2.Lerp(value72, value73, 0.5f); - Vector2 value74 = new Vector2(0f, value73.Y - value72.Y); - value74.X = value74.Y * 0.2f; - Projectile.width = (int)(value74.X * 0.65f); - Projectile.height = (int)value74.Y; - Projectile.Center = vector146; + Point projCenterTile = Projectile.Center.ToTileCoordinates(); + int sizeMod; + int sizeMod2; + Collision.ExpandVertically(projCenterTile.X, projCenterTile.Y, out sizeMod, out sizeMod2, 15, 15); + sizeMod++; + sizeMod2--; + Vector2 sizeModVector = new Vector2((float)projCenterTile.X, (float)sizeMod) * 16f + new Vector2(8f); + Vector2 sizeModVector2 = new Vector2((float)projCenterTile.X, (float)sizeMod2) * 16f + new Vector2(8f); + Vector2 centering = Vector2.Lerp(sizeModVector, sizeModVector2, 0.5f); + Vector2 sizeModPos = new Vector2(0f, sizeModVector2.Y - sizeModVector.Y); + sizeModPos.X = sizeModPos.Y * 0.2f; + Projectile.width = (int)(sizeModPos.X * 0.65f); + Projectile.height = (int)sizeModPos.Y; + Projectile.Center = centering; if (Projectile.owner == Main.myPlayer) { - bool flag74 = false; - Vector2 center16 = Main.player[Projectile.owner].Center; + bool breakFlag = false; + Vector2 playerCenter = Main.player[Projectile.owner].Center; Vector2 top = Main.player[Projectile.owner].Top; - for (float num1131 = 0f; num1131 < 1f; num1131 += 0.05f) + for (float i = 0f; i < 1f; i += 0.05f) { - Vector2 position2 = Vector2.Lerp(value72, value73, num1131); - if (Collision.CanHitLine(position2, 0, 0, center16, 0, 0) || Collision.CanHitLine(position2, 0, 0, top, 0, 0)) + Vector2 position2 = Vector2.Lerp(sizeModVector, sizeModVector2, i); + if (Collision.CanHitLine(position2, 0, 0, playerCenter, 0, 0) || Collision.CanHitLine(position2, 0, 0, top, 0, 0)) { - flag74 = true; + breakFlag = true; break; } } - if (!flag74 && Projectile.ai[0] < num1125 - 120f) + if (!breakFlag && Projectile.ai[0] < projTimer - 120f) { - float num1132 = Projectile.ai[0] % 60f; - Projectile.ai[0] = num1125 - 120f + num1132; + float aiDecrement = Projectile.ai[0] % 60f; + Projectile.ai[0] = projTimer - 120f + aiDecrement; Projectile.netUpdate = true; } } - if (Projectile.ai[0] < num1125 - 120f) + if (Projectile.ai[0] < projTimer - 120f) { return; } @@ -157,57 +154,54 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { - float num226 = 600f; - float num227 = 15f; - float num228 = 15f; - float num229 = Projectile.ai[0]; - float scale5 = MathHelper.Clamp(num229 / 30f, 0f, 1f); - if (num229 > num226 - 60f) + float aiTracker = Projectile.ai[0]; + float trackerClamp = MathHelper.Clamp(aiTracker / 30f, 0f, 1f); + if (aiTracker > 540f) { - scale5 = MathHelper.Lerp(1f, 0f, (num229 - (num226 - 60f)) / 60f); + trackerClamp = MathHelper.Lerp(1f, 0f, (aiTracker - 540f) / 60f); } - Point point5 = Projectile.Center.ToTileCoordinates(); - int num230; - int num231; - Collision.ExpandVertically(point5.X, point5.Y, out num230, out num231, (int)num227, (int)num228); - num230++; - num231--; - float num232 = 0.2f; - Vector2 value32 = new Vector2((float)point5.X, (float)num230) * 16f + new Vector2(8f); - Vector2 value33 = new Vector2((float)point5.X, (float)num231) * 16f + new Vector2(8f); - Vector2.Lerp(value32, value33, 0.5f); - Vector2 vector33 = new Vector2(0f, value33.Y - value32.Y); - vector33.X = vector33.Y * num232; - new Vector2(value32.X - vector33.X / 2f, value32.Y); + Point centerPoint = Projectile.Center.ToTileCoordinates(); + int sizeModding; + int sizeModding2; + Collision.ExpandVertically(centerPoint.X, centerPoint.Y, out sizeModding, out sizeModding2, 15, 15); + sizeModding++; + sizeModding2--; + float vectorMult = 0.2f; + Vector2 sizeModdingVector = new Vector2((float)centerPoint.X, (float)sizeModding) * 16f + new Vector2(8f); + Vector2 sizeModdingVector2 = new Vector2((float)centerPoint.X, (float)sizeModding2) * 16f + new Vector2(8f); + Vector2.Lerp(sizeModdingVector, sizeModdingVector2, 0.5f); + Vector2 sizeModdingPos = new Vector2(0f, sizeModdingVector2.Y - sizeModdingVector.Y); + sizeModdingPos.X = sizeModdingPos.Y * vectorMult; + new Vector2(sizeModdingVector.X - sizeModdingPos.X / 2f, sizeModdingVector.Y); Texture2D texture2D23 = ModContent.Request(Texture).Value; - Rectangle rectangle9 = texture2D23.Frame(1, 1, 0, 0); - Vector2 origin3 = rectangle9.Size() / 2f; - float num233 = -0.06283186f * num229; - Vector2 spinningpoint2 = Vector2.UnitY.RotatedBy((double)(num229 * 0.1f), default); - float num234 = 0f; - float num235 = 5.1f; - Color value34 = new Color(225, 225, 225); - for (float num236 = (float)(int)value33.Y; num236 > (float)(int)value32.Y; num236 -= num235) + Rectangle drawRectangle = texture2D23.Frame(1, 1, 0, 0); + Vector2 smallRect = drawRectangle.Size() / 2f; + float aiTrackMult = -0.06283186f * aiTracker; + Vector2 spinningpoint = Vector2.UnitY.RotatedBy((double)(aiTracker * 0.1f), default); + float incrementStorage = 0f; + float increment = 5.1f; + Color cloudColor = new Color(225, 225, 225); + for (float j = (float)(int)sizeModdingVector2.Y; j > (float)(int)sizeModdingVector.Y; j -= increment) { - num234 += num235; - float num237 = num234 / vector33.Y; - float num238 = num234 * 6.28318548f / -20f; - float num239 = num237 - 0.15f; - Vector2 vector34 = spinningpoint2.RotatedBy((double)num238, default); - Vector2 value35 = new Vector2(0f, num237 + 1f); - value35.X = value35.Y * num232; - Color color39 = Microsoft.Xna.Framework.Color.Lerp(Microsoft.Xna.Framework.Color.Transparent, value34, num237 * 2f); - if (num237 > 0.5f) + incrementStorage += increment; + float colorChanger = incrementStorage / sizeModdingPos.Y; + float incStorageMult = incrementStorage * 6.28318548f / -20f; + float lowerColorChanger = colorChanger - 0.15f; + Vector2 spinArea = spinningpoint.RotatedBy((double)incStorageMult, default); + Vector2 colorChangeVector = new Vector2(0f, colorChanger + 1f); + colorChangeVector.X = colorChangeVector.Y * vectorMult; + Color newCloudColor = Microsoft.Xna.Framework.Color.Lerp(Microsoft.Xna.Framework.Color.Transparent, cloudColor, colorChanger * 2f); + if (colorChanger > 0.5f) { - color39 = Microsoft.Xna.Framework.Color.Lerp(Microsoft.Xna.Framework.Color.Transparent, value34, 2f - num237 * 2f); + newCloudColor = Microsoft.Xna.Framework.Color.Lerp(Microsoft.Xna.Framework.Color.Transparent, cloudColor, 2f - colorChanger * 2f); } - color39.A = (byte)((float)color39.A * 0.5f); - color39 *= scale5; - vector34 *= value35 * 100f; - vector34.Y = 0f; - vector34.X = 0f; - vector34 += new Vector2(value33.X, num236) - Main.screenPosition; - Main.spriteBatch.Draw(texture2D23, vector34, new Microsoft.Xna.Framework.Rectangle?(rectangle9), color39, num233 + num238, origin3, 1f + num239, SpriteEffects.None, 0); + newCloudColor.A = (byte)((float)newCloudColor.A * 0.5f); + newCloudColor *= trackerClamp; + spinArea *= colorChangeVector * 100f; + spinArea.Y = 0f; + spinArea.X = 0f; + spinArea += new Vector2(sizeModdingVector2.X, j) - Main.screenPosition; + Main.spriteBatch.Draw(texture2D23, spinArea, new Microsoft.Xna.Framework.Rectangle?(drawRectangle), newCloudColor, aiTrackMult + incStorageMult, smallRect, 1f + lowerColorChanger, SpriteEffects.None, 0); } return false; } diff --git a/Projectiles/Melee/TriactisHammerProj.cs b/Projectiles/Melee/TriactisHammerProj.cs index 826d855d53..f1595d901b 100644 --- a/Projectiles/Melee/TriactisHammerProj.cs +++ b/Projectiles/Melee/TriactisHammerProj.cs @@ -52,46 +52,45 @@ namespace CalamityMod.Projectiles.Melee else { Projectile.tileCollide = false; - float num42 = 20f; - float num43 = 5f; - Vector2 vector2 = new Vector2(Projectile.position.X + Projectile.width * 0.5f, Projectile.position.Y + Projectile.height * 0.5f); - float num44 = Main.player[Projectile.owner].position.X + Main.player[Projectile.owner].width / 2 - vector2.X; - float num45 = Main.player[Projectile.owner].position.Y + Main.player[Projectile.owner].height / 2 - vector2.Y; - float num46 = (float)Math.Sqrt(num44 * num44 + num45 * num45); - if (num46 > 3000f) + float projVelModifier = 5f; + Vector2 projDirection = new Vector2(Projectile.position.X + Projectile.width * 0.5f, Projectile.position.Y + Projectile.height * 0.5f); + float projXDist = Main.player[Projectile.owner].position.X + Main.player[Projectile.owner].width / 2 - projDirection.X; + float projYDist = Main.player[Projectile.owner].position.Y + Main.player[Projectile.owner].height / 2 - projDirection.Y; + float projDistance = (float)Math.Sqrt(projXDist * projXDist + projYDist * projYDist); + if (projDistance > 3000f) Projectile.Kill(); - num46 = num42 / num46; - num44 *= num46; - num45 *= num46; - if (Projectile.velocity.X < num44) + projDistance = 20f / projDistance; + projXDist *= projDistance; + projYDist *= projDistance; + if (Projectile.velocity.X < projXDist) { - Projectile.velocity.X = Projectile.velocity.X + num43; - if (Projectile.velocity.X < 0f && num44 > 0f) - Projectile.velocity.X = Projectile.velocity.X + num43; + Projectile.velocity.X = Projectile.velocity.X + projVelModifier; + if (Projectile.velocity.X < 0f && projXDist > 0f) + Projectile.velocity.X = Projectile.velocity.X + projVelModifier; } - else if (Projectile.velocity.X > num44) + else if (Projectile.velocity.X > projXDist) { - Projectile.velocity.X = Projectile.velocity.X - num43; - if (Projectile.velocity.X > 0f && num44 < 0f) - Projectile.velocity.X = Projectile.velocity.X - num43; + Projectile.velocity.X = Projectile.velocity.X - projVelModifier; + if (Projectile.velocity.X > 0f && projXDist < 0f) + Projectile.velocity.X = Projectile.velocity.X - projVelModifier; } - if (Projectile.velocity.Y < num45) + if (Projectile.velocity.Y < projYDist) { - Projectile.velocity.Y = Projectile.velocity.Y + num43; - if (Projectile.velocity.Y < 0f && num45 > 0f) - Projectile.velocity.Y = Projectile.velocity.Y + num43; + Projectile.velocity.Y = Projectile.velocity.Y + projVelModifier; + if (Projectile.velocity.Y < 0f && projYDist > 0f) + Projectile.velocity.Y = Projectile.velocity.Y + projVelModifier; } - else if (Projectile.velocity.Y > num45) + else if (Projectile.velocity.Y > projYDist) { - Projectile.velocity.Y = Projectile.velocity.Y - num43; - if (Projectile.velocity.Y > 0f && num45 < 0f) - Projectile.velocity.Y = Projectile.velocity.Y - num43; + Projectile.velocity.Y = Projectile.velocity.Y - projVelModifier; + if (Projectile.velocity.Y > 0f && projYDist < 0f) + Projectile.velocity.Y = Projectile.velocity.Y - projVelModifier; } if (Main.myPlayer == Projectile.owner) { Rectangle rectangle = new Rectangle((int)Projectile.position.X, (int)Projectile.position.Y, Projectile.width, Projectile.height); - Rectangle value2 = new Rectangle((int)Main.player[Projectile.owner].position.X, (int)Main.player[Projectile.owner].position.Y, Main.player[Projectile.owner].width, Main.player[Projectile.owner].height); - if (rectangle.Intersects(value2)) + Rectangle playerArea = new Rectangle((int)Main.player[Projectile.owner].position.X, (int)Main.player[Projectile.owner].position.Y, Main.player[Projectile.owner].width, Main.player[Projectile.owner].height); + if (rectangle.Intersects(playerArea)) Projectile.Kill(); } } @@ -108,23 +107,23 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.owner == Main.myPlayer) Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.25), Projectile.knockBack, Projectile.owner, 0f, 0f); SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, Main.rand.NextBool() ? 89 : 229, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int triactisDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, Main.rand.NextBool() ? 89 : 229, 0f, 0f, 100, default, 2f); + Main.dust[triactisDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[triactisDust].scale = 0.5f; + Main.dust[triactisDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, Main.rand.NextBool() ? 89 : 229, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, Main.rand.NextBool() ? 89 : 229, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int triactisDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, Main.rand.NextBool() ? 89 : 229, 0f, 0f, 100, default, 3f); + Main.dust[triactisDust2].noGravity = true; + Main.dust[triactisDust2].velocity *= 5f; + triactisDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, Main.rand.NextBool() ? 89 : 229, 0f, 0f, 100, default, 2f); + Main.dust[triactisDust2].velocity *= 2f; } } @@ -133,23 +132,23 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.owner == Main.myPlayer) Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.25), Projectile.knockBack, Projectile.owner, 0f, 0f); SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, Main.rand.NextBool() ? 89 : 229, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int triactisDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, Main.rand.NextBool() ? 89 : 229, 0f, 0f, 100, default, 2f); + Main.dust[triactisDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[triactisDust].scale = 0.5f; + Main.dust[triactisDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, Main.rand.NextBool() ? 89 : 229, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, Main.rand.NextBool() ? 89 : 229, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int triactisDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, Main.rand.NextBool() ? 89 : 229, 0f, 0f, 100, default, 3f); + Main.dust[triactisDust2].noGravity = true; + Main.dust[triactisDust2].velocity *= 5f; + triactisDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, Main.rand.NextBool() ? 89 : 229, 0f, 0f, 100, default, 2f); + Main.dust[triactisDust2].velocity *= 2f; } } diff --git a/Projectiles/Melee/TrueArkOfTheAncients_ParryHoldout.cs b/Projectiles/Melee/TrueArkOfTheAncients_ParryHoldout.cs index 6136741449..002ee38331 100644 --- a/Projectiles/Melee/TrueArkOfTheAncients_ParryHoldout.cs +++ b/Projectiles/Melee/TrueArkOfTheAncients_ParryHoldout.cs @@ -138,7 +138,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(Projectile.velocity.X); + Owner.ChangeDir(Math.Sign(Projectile.velocity.X)); Owner.itemRotation = Projectile.rotation; if (Owner.direction != 1) { diff --git a/Projectiles/Melee/TrueArkOfTheAncients_SwungBlade.cs b/Projectiles/Melee/TrueArkOfTheAncients_SwungBlade.cs index 0dcccd6401..d1e64faccc 100644 --- a/Projectiles/Melee/TrueArkOfTheAncients_SwungBlade.cs +++ b/Projectiles/Melee/TrueArkOfTheAncients_SwungBlade.cs @@ -101,7 +101,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(Projectile.velocity.X); + Owner.ChangeDir(Math.Sign(Projectile.velocity.X)); Owner.itemRotation = Projectile.rotation; if (Owner.direction != 1) { diff --git a/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChained.cs b/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChained.cs index 1a7ca57d33..34e6c90b6f 100644 --- a/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChained.cs +++ b/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChained.cs @@ -175,7 +175,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(Projectile.velocity.X); + Owner.ChangeDir(Math.Sign(Projectile.velocity.X)); Owner.itemRotation = Projectile.rotation; if (Owner.direction != 1) { diff --git a/Projectiles/Melee/TrueBiomeBlade_MercurialTides.cs b/Projectiles/Melee/TrueBiomeBlade_MercurialTides.cs index ae01724fbf..d11f6cbaef 100644 --- a/Projectiles/Melee/TrueBiomeBlade_MercurialTides.cs +++ b/Projectiles/Melee/TrueBiomeBlade_MercurialTides.cs @@ -168,7 +168,7 @@ namespace CalamityMod.Projectiles.Melee //Scaling based on charge Projectile.scale = 1f + (Charge / MaxCharge * 0.3f); - Owner.direction = Math.Sign(direction.X); + Owner.ChangeDir(Math.Sign(direction.X)); Owner.itemRotation = direction.ToRotation(); if (Owner.direction != 1) diff --git a/Projectiles/Melee/TrueBiomeBlade_SanguineFury.cs b/Projectiles/Melee/TrueBiomeBlade_SanguineFury.cs index 4fe46aed58..ced8054f2d 100644 --- a/Projectiles/Melee/TrueBiomeBlade_SanguineFury.cs +++ b/Projectiles/Melee/TrueBiomeBlade_SanguineFury.cs @@ -190,7 +190,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(direction.X); + Owner.ChangeDir(Math.Sign(direction.X)); Owner.itemRotation = direction.ToRotation(); if (Owner.direction != 1) { diff --git a/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPride.cs b/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPride.cs index 114fe107e9..ddce8634b1 100644 --- a/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPride.cs +++ b/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPride.cs @@ -239,7 +239,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(direction.X); + Owner.ChangeDir(Math.Sign(direction.X)); Owner.itemRotation = direction.ToRotation(); if (Owner.direction != 1) { diff --git a/Projectiles/Melee/TrueCausticEdgeProjectile.cs b/Projectiles/Melee/TrueCausticEdgeProjectile.cs index 4cc393c505..dc9b04bf46 100644 --- a/Projectiles/Melee/TrueCausticEdgeProjectile.cs +++ b/Projectiles/Melee/TrueCausticEdgeProjectile.cs @@ -74,19 +74,19 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item10, Projectile.position); - int num3; - for (int num795 = 4; num795 < 31; num795 = num3 + 1) + int inc; + for (int i = 4; i < 31; i = inc + 1) { - float num796 = Projectile.oldVelocity.X * (30f / (float)num795); - float num797 = Projectile.oldVelocity.Y * (30f / (float)num795); - int num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, 44, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); - Main.dust[num798].noGravity = true; - Dust dust = Main.dust[num798]; + float oldXVel = Projectile.oldVelocity.X * (30f / (float)i); + float oldYVel = Projectile.oldVelocity.Y * (30f / (float)i); + int causticDust = Dust.NewDust(new Vector2(Projectile.oldPosition.X - oldXVel, Projectile.oldPosition.Y - oldYVel), 8, 8, 44, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f); + Main.dust[causticDust].noGravity = true; + Dust dust = Main.dust[causticDust]; dust.velocity *= 0.5f; - num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, 44, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); - dust = Main.dust[num798]; + causticDust = Dust.NewDust(new Vector2(Projectile.oldPosition.X - oldXVel, Projectile.oldPosition.Y - oldYVel), 8, 8, 44, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f); + dust = Main.dust[causticDust]; dust.velocity *= 0.05f; - num3 = num795; + inc = i; } } } diff --git a/Projectiles/Melee/TumbleweedFlail.cs b/Projectiles/Melee/TumbleweedFlail.cs index 1dfd79bdac..784bb98e58 100644 --- a/Projectiles/Melee/TumbleweedFlail.cs +++ b/Projectiles/Melee/TumbleweedFlail.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - Vector2 vector62 = Main.player[Projectile.owner].Center - Projectile.Center; + Vector2 projDirection = Main.player[Projectile.owner].Center - Projectile.Center; Projectile.rotation += (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y)) * 0.01f * (float)Projectile.direction; if (Main.player[Projectile.owner].dead) { @@ -31,8 +31,8 @@ namespace CalamityMod.Projectiles.Melee } Main.player[Projectile.owner].itemAnimation = 10; Main.player[Projectile.owner].itemTime = 10; - float arg_1DC8F_0 = vector62.X; - if (vector62.X < 0f) + float arg_1DC8F_0 = projDirection.X; + if (projDirection.X < 0f) { Main.player[Projectile.owner].ChangeDir(1); Projectile.direction = 1; @@ -42,32 +42,32 @@ namespace CalamityMod.Projectiles.Melee Main.player[Projectile.owner].ChangeDir(-1); Projectile.direction = -1; } - Main.player[Projectile.owner].itemRotation = (vector62 * -1f * (float)Projectile.direction).ToRotation(); - Projectile.spriteDirection = (vector62.X > 0f) ? -1 : 1; - if (Projectile.ai[0] == 0f && vector62.Length() > 400f) + Main.player[Projectile.owner].itemRotation = (projDirection * -1f * (float)Projectile.direction).ToRotation(); + Projectile.spriteDirection = (projDirection.X > 0f) ? -1 : 1; + if (Projectile.ai[0] == 0f && projDirection.Length() > 400f) { Projectile.ai[0] = 1f; } if (Projectile.ai[0] == 1f || Projectile.ai[0] == 2f) { - float num693 = vector62.Length(); - if (num693 > 1500f) + float projDistance = projDirection.Length(); + if (projDistance > 1500f) { Projectile.Kill(); return; } - if (num693 > 600f) + if (projDistance > 600f) { Projectile.ai[0] = 2f; } Projectile.tileCollide = false; - float num694 = 20f; + float returnLength = 20f; if (Projectile.ai[0] == 2f) { - num694 = 40f; + returnLength = 40f; } - Projectile.velocity = Vector2.Normalize(vector62) * num694; - if (vector62.Length() < num694) + Projectile.velocity = Vector2.Normalize(projDirection) * returnLength; + if (projDirection.Length() < returnLength) { Projectile.Kill(); return; @@ -93,35 +93,35 @@ namespace CalamityMod.Projectiles.Melee { Vector2 mountedCenter = Main.player[Projectile.owner].MountedCenter; Texture2D texture2D2 = ModContent.Request("CalamityMod/Projectiles/Melee/TumbleweedChain").Value; - Vector2 vector17 = Projectile.Center; + Vector2 projCenter = Projectile.Center; Rectangle? sourceRectangle = null; Vector2 origin = new Vector2((float)texture2D2.Width * 0.5f, (float)texture2D2.Height * 0.5f); - float num91 = (float)texture2D2.Height; - Vector2 vector18 = mountedCenter - vector17; - float rotation15 = (float)Math.Atan2((double)vector18.Y, (double)vector18.X) - 1.57f; - bool flag13 = true; - if (float.IsNaN(vector17.X) && float.IsNaN(vector17.Y)) + float projHeight = (float)texture2D2.Height; + Vector2 actualCenter = mountedCenter - projCenter; + float projRotation = (float)Math.Atan2((double)actualCenter.Y, (double)actualCenter.X) - 1.57f; + bool isActive = true; + if (float.IsNaN(projCenter.X) && float.IsNaN(projCenter.Y)) { - flag13 = false; + isActive = false; } - if (float.IsNaN(vector18.X) && float.IsNaN(vector18.Y)) + if (float.IsNaN(actualCenter.X) && float.IsNaN(actualCenter.Y)) { - flag13 = false; + isActive = false; } - while (flag13) + while (isActive) { - if (vector18.Length() < num91 + 1f) + if (actualCenter.Length() < projHeight + 1f) { - flag13 = false; + isActive = false; } else { - Vector2 value2 = vector18; - value2.Normalize(); - vector17 += value2 * num91; - vector18 = mountedCenter - vector17; - Color color17 = Lighting.GetColor((int)vector17.X / 16, (int)(vector17.Y / 16f)); - Main.spriteBatch.Draw(texture2D2, vector17 - Main.screenPosition, sourceRectangle, color17, rotation15, origin, 1f, SpriteEffects.None, 0); + Vector2 centerCopy = actualCenter; + centerCopy.Normalize(); + projCenter += centerCopy * projHeight; + actualCenter = mountedCenter - projCenter; + Color drawArea = Lighting.GetColor((int)projCenter.X / 16, (int)(projCenter.Y / 16f)); + Main.spriteBatch.Draw(texture2D2, projCenter - Main.screenPosition, sourceRectangle, drawArea, projRotation, origin, 1f, SpriteEffects.None, 0); } } return true; @@ -130,23 +130,23 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { SoundEngine.PlaySound(SoundID.NPCDeath15, Projectile.position); - for (int num621 = 0; num621 < 20; num621++) + for (int i = 0; i < 20; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 32, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; + int tumbleDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 32, 0f, 0f, 100, default, 1.2f); + Main.dust[tumbleDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[tumbleDust].scale = 0.5f; + Main.dust[tumbleDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 85, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 85, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int tumbleDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 85, 0f, 0f, 100, default, 1.7f); + Main.dust[tumbleDust2].noGravity = true; + Main.dust[tumbleDust2].velocity *= 5f; + tumbleDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 85, 0f, 0f, 100, default, 1f); + Main.dust[tumbleDust2].velocity *= 2f; } if (Projectile.owner == Main.myPlayer) { diff --git a/Projectiles/Melee/TumbleweedRolling.cs b/Projectiles/Melee/TumbleweedRolling.cs index 7feae93ae6..95bfd673e6 100644 --- a/Projectiles/Melee/TumbleweedRolling.cs +++ b/Projectiles/Melee/TumbleweedRolling.cs @@ -49,23 +49,23 @@ namespace CalamityMod.Projectiles.Melee public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.NPCDeath15, Projectile.position); - for (int num621 = 0; num621 < 20; num621++) + for (int i = 0; i < 20; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 32, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; + int tumbleDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 32, 0f, 0f, 100, default, 1.2f); + Main.dust[tumbleDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[tumbleDust].scale = 0.5f; + Main.dust[tumbleDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 85, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 85, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int tumbleDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 85, 0f, 0f, 100, default, 1.7f); + Main.dust[tumbleDust2].noGravity = true; + Main.dust[tumbleDust2].velocity *= 5f; + tumbleDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 85, 0f, 0f, 100, default, 1f); + Main.dust[tumbleDust2].velocity *= 2f; } } } diff --git a/Projectiles/Melee/TyphonsGreedBubble.cs b/Projectiles/Melee/TyphonsGreedBubble.cs index 66b29cf5a4..e0378a8aca 100644 --- a/Projectiles/Melee/TyphonsGreedBubble.cs +++ b/Projectiles/Melee/TyphonsGreedBubble.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -40,9 +40,14 @@ namespace CalamityMod.Projectiles.Melee { Projectile.frame = 0; } + + if (Projectile.timeLeft < 210) // making it not home right away so the projectiles get closer to the character first, to make it look more natural and overall better. + { + CalamityUtils.HomeInOnNPC(Projectile, true, 450f, 20f, 20f); + } + float inertia = 50f * Projectile.ai[1]; //100 float speed = 10f * Projectile.ai[1]; //5 - float num954 = 40f; if (Math.Abs(Projectile.velocity.X) > 0.2f) { Projectile.spriteDirection = -Projectile.direction; @@ -53,7 +58,7 @@ namespace CalamityMod.Projectiles.Melee Player player = Main.player[Projectile.owner]; if (player.active && !player.dead) { - if (Projectile.Distance(player.Center) > num954) + if (Projectile.Distance(player.Center) > 40f) { Vector2 moveDirection = Projectile.SafeDirectionTo(player.Center, Vector2.UnitY); Projectile.velocity = (Projectile.velocity * (inertia - 1f) + moveDirection * speed) / inertia; @@ -71,12 +76,12 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), - new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), - Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), + Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } @@ -92,18 +97,18 @@ namespace CalamityMod.Projectiles.Melee Projectile.width = Projectile.height = 64; Projectile.position.X -= (float)(Projectile.width / 2); Projectile.position.Y -= (float)(Projectile.height / 2); - for (int num193 = 0; num193 < 2; num193++) + for (int i = 0; i < 2; i++) { Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 33, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); } - for (int num194 = 0; num194 < 6; num194++) + for (int j = 0; j < 6; j++) { - int num195 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 186, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 186, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int bubblyDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 186, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[bubblyDust].noGravity = true; + Main.dust[bubblyDust].velocity *= 3f; + bubblyDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 186, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[bubblyDust].velocity *= 2f; + Main.dust[bubblyDust].noGravity = true; } Projectile.maxPenetrate = -1; Projectile.penetrate = -1; diff --git a/Projectiles/Melee/TyphonsGreedStaff.cs b/Projectiles/Melee/TyphonsGreedStaff.cs index d31601b141..6f2d25a352 100644 --- a/Projectiles/Melee/TyphonsGreedStaff.cs +++ b/Projectiles/Melee/TyphonsGreedStaff.cs @@ -1,7 +1,7 @@ -using CalamityMod.Buffs.DamageOverTime; +using System; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Weapons.Melee; using Microsoft.Xna.Framework; -using System; using Terraria; using Terraria.Enums; using Terraria.Localization; @@ -31,24 +31,25 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - float num = 50f; - float num2 = 2f; + float spinTimer = 50f; + float rotationFactor = 2f; float scaleFactor = 20f; Player player = Main.player[Projectile.owner]; - float num3 = -0.7853982f; - Vector2 value = player.RotatedRelativePoint(player.MountedCenter, true); - Vector2 value2 = Vector2.Zero; + float rotationSpeed = -0.7853982f; + Vector2 actualPosition = player.RotatedRelativePoint(player.MountedCenter, true); + Vector2 rotationPoint = Vector2.Zero; + if (player.dead) { Projectile.Kill(); return; } Lighting.AddLight(player.Center, 0f, 0.2f, 1.45f); - int num9 = Math.Sign(Projectile.velocity.X); - Projectile.velocity = new Vector2((float)num9, 0f); + int rotationVel = Math.Sign(Projectile.velocity.X); + Projectile.velocity = new Vector2((float)rotationVel, 0f); if (Projectile.ai[0] == 0f) { - Projectile.rotation = new Vector2((float)num9, -player.gravDir).ToRotation() + num3 + 3.14159274f; + Projectile.rotation = new Vector2((float)rotationVel, -player.gravDir).ToRotation() + rotationSpeed + 3.14159274f; if (Projectile.velocity.X < 0f) { Projectile.rotation -= 1.57079637f; @@ -59,17 +60,16 @@ namespace CalamityMod.Projectiles.Melee { Projectile.alpha = 0; } - float arg_5DB_0 = Projectile.ai[0] / num; - float num10 = 1f; - Projectile.ai[0] += num10; - Projectile.rotation += 6.28318548f * num2 / num * (float)num9; - bool flag2 = Projectile.ai[0] == (float)(int)(num / 2f); - if (Projectile.ai[0] >= num || (flag2 && !player.controlUseItem)) + float arg_5DB_0 = Projectile.ai[0] / spinTimer; + Projectile.ai[0] += 1f; + Projectile.rotation += 6.28318548f * rotationFactor / spinTimer * (float)rotationVel; + bool isUsing = Projectile.ai[0] == (float)(int)(spinTimer / 2f); + if (Projectile.ai[0] >= spinTimer || (isUsing && !player.controlUseItem)) { Projectile.Kill(); player.reuseDelay = 2; } - else if (flag2) + else if (isUsing) { int expectedDirection = (player.SafeDirectionTo(Main.MouseWorld).X > 0f).ToDirectionInt(); if (expectedDirection != Projectile.velocity.X) @@ -80,15 +80,15 @@ namespace CalamityMod.Projectiles.Melee Projectile.netUpdate = true; } } - float num12 = Projectile.rotation - 0.7853982f * (float)num9; - value2 = (num12 + ((num9 == -1) ? 3.14159274f : 0f)).ToRotationVector2() * (Projectile.ai[0] / num) * scaleFactor; - Vector2 value3 = Projectile.Center + (num12 + ((num9 == -1) ? 3.14159274f : 0f)).ToRotationVector2() * 30f; - Vector2 vector2 = num12.ToRotationVector2(); - Vector2 value4 = vector2.RotatedBy((double)(1.57079637f * (float)Projectile.spriteDirection), default); + float rotateDirection = Projectile.rotation - 0.7853982f * (float)rotationVel; + rotationPoint = (rotateDirection + ((rotationVel == -1) ? 3.14159274f : 0f)).ToRotationVector2() * (Projectile.ai[0] / spinTimer) * scaleFactor; + Vector2 dustSpawn = Projectile.Center + (rotateDirection + ((rotationVel == -1) ? 3.14159274f : 0f)).ToRotationVector2() * 30f; + Vector2 staffTipDirection = rotateDirection.ToRotationVector2(); + Vector2 tipDustDirection = staffTipDirection.RotatedBy((double)(1.57079637f * (float)Projectile.spriteDirection), default); if (Main.rand.NextBool()) { - Dust dust3 = Dust.NewDustDirect(value3 - new Vector2(5f), 10, 10, 33, player.velocity.X, player.velocity.Y, 150, default, 1f); - dust3.velocity = Projectile.SafeDirectionTo(dust3.position) * 0.1f + dust3.velocity * 0.1f; + Dust staffDust = Dust.NewDustDirect(dustSpawn - new Vector2(5f), 10, 10, 33, player.velocity.X, player.velocity.Y, 150, default, 1f); + staffDust.velocity = Projectile.SafeDirectionTo(staffDust.position) * 0.1f + staffDust.velocity * 0.1f; } for (int j = 0; j < 4; j++) { @@ -110,20 +110,20 @@ namespace CalamityMod.Projectiles.Melee } if (Main.rand.Next(6) != 0) { - Dust dust4 = Dust.NewDustDirect(Projectile.position, 0, 0, 186, 0f, 0f, 100, default, 1f); - dust4.position = Projectile.Center + vector2 * (60f + Main.rand.NextFloat() * 20f) * scaleFactor3; - dust4.velocity = value4 * (4f + 4f * Main.rand.NextFloat()) * scaleFactor3 * scaleFactor2; - dust4.noGravity = true; - dust4.noLight = true; - dust4.scale = 0.5f; + Dust staffTipDust = Dust.NewDustDirect(Projectile.position, 0, 0, 186, 0f, 0f, 100, default, 1f); + staffTipDust.position = Projectile.Center + staffTipDirection * (60f + Main.rand.NextFloat() * 20f) * scaleFactor3; + staffTipDust.velocity = tipDustDirection * (4f + 4f * Main.rand.NextFloat()) * scaleFactor3 * scaleFactor2; + staffTipDust.noGravity = true; + staffTipDust.noLight = true; + staffTipDust.scale = 0.5f; if (Main.rand.NextBool(4)) { - dust4.noGravity = false; + staffTipDust.noGravity = false; } } } - Projectile.position = value - Projectile.Size / 2f; - Projectile.position += value2; + Projectile.position = actualPosition - Projectile.Size / 2f; + Projectile.position += rotationPoint; Projectile.spriteDirection = Projectile.direction; Projectile.timeLeft = 2; player.ChangeDir(Projectile.direction); @@ -145,10 +145,10 @@ namespace CalamityMod.Projectiles.Melee public override void CutTiles() { - float num5 = 60f; + float cutRadius = 60f; float f = Projectile.rotation - 0.7853982f * (float)Math.Sign(Projectile.velocity.X); DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; - Utils.PlotTileLine(Projectile.Center + f.ToRotationVector2() * -num5, Projectile.Center + f.ToRotationVector2() * num5, (float)Projectile.width * Projectile.scale, DelegateMethods.CutTiles); + Utils.PlotTileLine(Projectile.Center + f.ToRotationVector2() * -cutRadius, Projectile.Center + f.ToRotationVector2() * cutRadius, (float)Projectile.width * Projectile.scale, DelegateMethods.CutTiles); } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) @@ -158,9 +158,9 @@ namespace CalamityMod.Projectiles.Melee return true; } float f = Projectile.rotation - 0.7853982f * (float)Math.Sign(Projectile.velocity.X); - float num2 = 0f; - float num3 = 110f; - if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center + f.ToRotationVector2() * -num3, Projectile.Center + f.ToRotationVector2() * num3, 23f * Projectile.scale, ref num2)) + float rotationFactor = 0f; + float collisionRadius = 110f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center + f.ToRotationVector2() * -collisionRadius, Projectile.Center + f.ToRotationVector2() * collisionRadius, 23f * Projectile.scale, ref rotationFactor)) { return true; } diff --git a/Projectiles/Melee/UltimusCleaverDust.cs b/Projectiles/Melee/UltimusCleaverDust.cs index 9cf40df931..0b2f2a3f12 100644 --- a/Projectiles/Melee/UltimusCleaverDust.cs +++ b/Projectiles/Melee/UltimusCleaverDust.cs @@ -56,26 +56,26 @@ namespace CalamityMod.Projectiles.Melee Projectile.rotation += Projectile.velocity.X * 0.1f; - int num199 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100, default, 1f); - Dust expr_8976_cp_0 = Main.dust[num199]; + int coldFire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100, default, 1f); + Dust expr_8976_cp_0 = Main.dust[coldFire]; expr_8976_cp_0.position.X -= 2f; - Dust expr_8994_cp_0 = Main.dust[num199]; + Dust expr_8994_cp_0 = Main.dust[coldFire]; expr_8994_cp_0.position.Y += 2f; - Main.dust[num199].scale += (float)Main.rand.Next(50) * 0.01f; - Main.dust[num199].noGravity = true; - Dust expr_89E7_cp_0 = Main.dust[num199]; + Main.dust[coldFire].scale += (float)Main.rand.Next(50) * 0.01f; + Main.dust[coldFire].noGravity = true; + Dust expr_89E7_cp_0 = Main.dust[coldFire]; expr_89E7_cp_0.velocity.Y -= 2f; if (Main.rand.NextBool()) { - int num200 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100, default, 1f); - Dust expr_8A4E_cp_0 = Main.dust[num200]; + int coldFiery = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100, default, 1f); + Dust expr_8A4E_cp_0 = Main.dust[coldFiery]; expr_8A4E_cp_0.position.X -= 2f; - Dust expr_8A6C_cp_0 = Main.dust[num200]; + Dust expr_8A6C_cp_0 = Main.dust[coldFiery]; expr_8A6C_cp_0.position.Y += 2f; - Main.dust[num200].scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; - Main.dust[num200].noGravity = true; - Main.dust[num200].velocity *= 0.1f; + Main.dust[coldFiery].scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; + Main.dust[coldFiery].noGravity = true; + Main.dust[coldFiery].velocity *= 0.1f; } if ((double)Projectile.velocity.Y < 0.25 && (double)Projectile.velocity.Y > 0.15) diff --git a/Projectiles/Melee/UrchinBall.cs b/Projectiles/Melee/UrchinBall.cs index 2d506c0de6..81215289ed 100644 --- a/Projectiles/Melee/UrchinBall.cs +++ b/Projectiles/Melee/UrchinBall.cs @@ -29,8 +29,8 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { Player player = Main.player[Projectile.owner]; - Vector2 vector62 = player.Center - Projectile.Center; - Projectile.rotation = vector62.ToRotation() - 1.57f; + Vector2 projDirection = player.Center - Projectile.Center; + Projectile.rotation = projDirection.ToRotation() - 1.57f; if (player.dead) { Projectile.Kill(); @@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.Melee } player.itemAnimation = 10; player.itemTime = 10; - if (vector62.X < 0f) + if (projDirection.X < 0f) { player.ChangeDir(1); Projectile.direction = 1; @@ -48,9 +48,9 @@ namespace CalamityMod.Projectiles.Melee player.ChangeDir(-1); Projectile.direction = -1; } - player.itemRotation = (vector62 * -1f * (float)Projectile.direction).ToRotation(); - Projectile.spriteDirection = (vector62.X > 0f) ? -1 : 1; - if (Projectile.ai[0] == 0f && vector62.Length() > 400f) + player.itemRotation = (projDirection * -1f * (float)Projectile.direction).ToRotation(); + Projectile.spriteDirection = (projDirection.X > 0f) ? -1 : 1; + if (Projectile.ai[0] == 0f && projDirection.Length() > 400f) { Projectile.ai[0] = 1f; } @@ -62,24 +62,24 @@ namespace CalamityMod.Projectiles.Melee Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, Projectile.velocity.X, Projectile.velocity.Y, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.5), 0f, Main.myPlayer, 0f, 0f); } Projectile.usesLocalNPCImmunity = false; - float num693 = vector62.Length(); - if (num693 > 1500f) + float projDistance = projDirection.Length(); + if (projDistance > 1500f) { Projectile.Kill(); return; } - if (num693 > 600f) + if (projDistance > 600f) { Projectile.ai[0] = 2f; } Projectile.tileCollide = false; - float num694 = 20f; + float returnLength = 20f; if (Projectile.ai[0] == 2f) { - num694 = 40f; + returnLength = 40f; } - Projectile.velocity = Vector2.Normalize(vector62) * num694; - if (vector62.Length() < num694) + Projectile.velocity = Vector2.Normalize(projDirection) * returnLength; + if (projDirection.Length() < returnLength) { Projectile.Kill(); return; @@ -105,35 +105,35 @@ namespace CalamityMod.Projectiles.Melee { Vector2 mountedCenter = Main.player[Projectile.owner].MountedCenter; Texture2D texture2D2 = ModContent.Request("CalamityMod/Projectiles/Melee/UrchinFlailChain").Value; - Vector2 vector17 = Projectile.Center; + Vector2 projCenter = Projectile.Center; Rectangle? sourceRectangle = null; Vector2 origin = new Vector2((float)texture2D2.Width * 0.5f, (float)texture2D2.Height * 0.5f); - float num91 = (float)texture2D2.Height; - Vector2 vector18 = mountedCenter - vector17; - float rotation15 = (float)Math.Atan2((double)vector18.Y, (double)vector18.X) - 1.57f; - bool flag13 = true; - if (float.IsNaN(vector17.X) && float.IsNaN(vector17.Y)) + float projHeight = (float)texture2D2.Height; + Vector2 actualCenter = mountedCenter - projCenter; + float projRotation = (float)Math.Atan2((double)actualCenter.Y, (double)actualCenter.X) - 1.57f; + bool isActive = true; + if (float.IsNaN(projCenter.X) && float.IsNaN(projCenter.Y)) { - flag13 = false; + isActive = false; } - if (float.IsNaN(vector18.X) && float.IsNaN(vector18.Y)) + if (float.IsNaN(actualCenter.X) && float.IsNaN(actualCenter.Y)) { - flag13 = false; + isActive = false; } - while (flag13) + while (isActive) { - if (vector18.Length() < num91 + 1f) + if (actualCenter.Length() < projHeight + 1f) { - flag13 = false; + isActive = false; } else { - Vector2 value2 = vector18; - value2.Normalize(); - vector17 += value2 * num91; - vector18 = mountedCenter - vector17; - Color color17 = Lighting.GetColor((int)vector17.X / 16, (int)(vector17.Y / 16f)); - Main.spriteBatch.Draw(texture2D2, vector17 - Main.screenPosition, sourceRectangle, color17, rotation15, origin, 1f, SpriteEffects.None, 0); + Vector2 centerCopy = actualCenter; + centerCopy.Normalize(); + projCenter += centerCopy * projHeight; + actualCenter = mountedCenter - projCenter; + Color drawArea = Lighting.GetColor((int)projCenter.X / 16, (int)(projCenter.Y / 16f)); + Main.spriteBatch.Draw(texture2D2, projCenter - Main.screenPosition, sourceRectangle, drawArea, projRotation, origin, 1f, SpriteEffects.None, 0); } } return true; diff --git a/Projectiles/Melee/UrchinBallSpike.cs b/Projectiles/Melee/UrchinBallSpike.cs index d29cd719be..238fee7564 100644 --- a/Projectiles/Melee/UrchinBallSpike.cs +++ b/Projectiles/Melee/UrchinBallSpike.cs @@ -54,11 +54,11 @@ namespace CalamityMod.Projectiles.Melee Projectile.height = 20; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num194 = 0; num194 < 20; num194++) + for (int i = 0; i < 20; i++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 14, 0f, 0f, 0, new Color(0, 255, 255), 1f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 2f; + int urchin = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 14, 0f, 0f, 0, new Color(0, 255, 255), 1f); + Main.dust[urchin].noGravity = true; + Main.dust[urchin].velocity *= 2f; } } diff --git a/Projectiles/Melee/UrchinMaceProjectile.cs b/Projectiles/Melee/UrchinMaceProjectile.cs index e3d66ada8d..0870e05a11 100644 --- a/Projectiles/Melee/UrchinMaceProjectile.cs +++ b/Projectiles/Melee/UrchinMaceProjectile.cs @@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - Owner.direction = Math.Sign(Owner.Calamity().mouseWorld.X - Owner.position.X); + Owner.ChangeDir(Math.Sign(Owner.Calamity().mouseWorld.X - Owner.position.X)); Projectile.velocity = Vector2.Zero; @@ -142,7 +142,7 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { - Owner.direction = Math.Sign(Owner.Calamity().mouseWorld.X - Owner.position.X); + Owner.ChangeDir(Math.Sign(Owner.Calamity().mouseWorld.X - Owner.position.X)); Texture2D maceTexture = ModContent.Request(Texture).Value; Texture2D whirlpoolTexture = ModContent.Request("CalamityMod/Projectiles/Melee/RedtideWhirlpool").Value; diff --git a/Projectiles/Melee/ViolenceThrownProjectile.cs b/Projectiles/Melee/ViolenceThrownProjectile.cs index 0a0bbb4a60..7afda2d432 100644 --- a/Projectiles/Melee/ViolenceThrownProjectile.cs +++ b/Projectiles/Melee/ViolenceThrownProjectile.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.ignoreWater = true; Projectile.extraUpdates = 1; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 6; + Projectile.localNPCHitCooldown = 8; Projectile.tileCollide = false; } diff --git a/Projectiles/Melee/VolcanicFireball.cs b/Projectiles/Melee/VolcanicFireball.cs index 52fad75e47..1d3a7398f6 100644 --- a/Projectiles/Melee/VolcanicFireball.cs +++ b/Projectiles/Melee/VolcanicFireball.cs @@ -41,9 +41,9 @@ namespace CalamityMod.Projectiles.Melee Lighting.AddLight(Projectile.Center, 0.4f, 0f, 0f); if (Main.rand.NextBool(4)) { - int num469 = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, Main.rand.NextBool(3) ? 16 : 174, 0f, 0f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int volcano = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, Main.rand.NextBool(3) ? 16 : 174, 0f, 0f); + Main.dust[volcano].noGravity = true; + Main.dust[volcano].velocity *= 0f; } } @@ -51,9 +51,9 @@ namespace CalamityMod.Projectiles.Melee { for (int k = 0; k < 5; k++) { - int num469 = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 174, 0f, 0f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int volcano = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 174, 0f, 0f); + Main.dust[volcano].noGravity = true; + Main.dust[volcano].velocity *= 0f; } } diff --git a/Projectiles/Melee/VolcanicFireballLarge.cs b/Projectiles/Melee/VolcanicFireballLarge.cs index 5c205a0238..9aed240398 100644 --- a/Projectiles/Melee/VolcanicFireballLarge.cs +++ b/Projectiles/Melee/VolcanicFireballLarge.cs @@ -42,9 +42,9 @@ namespace CalamityMod.Projectiles.Melee Lighting.AddLight(Projectile.Center, 0.4f, 0f, 0f); if (Main.rand.NextBool(4)) { - int num469 = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, Main.rand.NextBool(3) ? 16 : 174, 0f, 0f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int volcano = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, Main.rand.NextBool(3) ? 16 : 174, 0f, 0f); + Main.dust[volcano].noGravity = true; + Main.dust[volcano].velocity *= 0f; } } @@ -52,9 +52,9 @@ namespace CalamityMod.Projectiles.Melee { for (int k = 0; k < 5; k++) { - int num469 = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 174, 0f, 0f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int volcano = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 174, 0f, 0f); + Main.dust[volcano].noGravity = true; + Main.dust[volcano].velocity *= 0f; } } diff --git a/Projectiles/Melee/Waterfall.cs b/Projectiles/Melee/Waterfall.cs index 38cc9e8418..183b47508a 100644 --- a/Projectiles/Melee/Waterfall.cs +++ b/Projectiles/Melee/Waterfall.cs @@ -28,33 +28,33 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - for (int num92 = 0; num92 < 2; num92++) + for (int i = 0; i < 2; i++) { - float num93 = Projectile.velocity.X / 3f * (float)num92; - float num94 = Projectile.velocity.Y / 3f * (float)num92; - int num95 = 4; - int num96 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num95, Projectile.position.Y + (float)num95), Projectile.width - num95 * 2, Projectile.height - num95 * 2, 56, 0f, 0f, 100, default, 1.2f); - Main.dust[num96].noGravity = true; - Main.dust[num96].velocity *= 0.25f; - Main.dust[num96].velocity += Projectile.velocity * 0.1f; - Dust expr_47FA_cp_0 = Main.dust[num96]; - expr_47FA_cp_0.position.X -= num93; - Dust expr_4815_cp_0 = Main.dust[num96]; - expr_4815_cp_0.position.Y -= num94; + float shortXVel = Projectile.velocity.X / 3f * (float)i; + float shortYVel = Projectile.velocity.Y / 3f * (float)i; + int fourConst = 4; + int watery = Dust.NewDust(new Vector2(Projectile.position.X + (float)fourConst, Projectile.position.Y + (float)fourConst), Projectile.width - fourConst * 2, Projectile.height - fourConst * 2, 56, 0f, 0f, 100, default, 1.2f); + Main.dust[watery].noGravity = true; + Main.dust[watery].velocity *= 0.25f; + Main.dust[watery].velocity += Projectile.velocity * 0.1f; + Dust expr_47FA_cp_0 = Main.dust[watery]; + expr_47FA_cp_0.position.X -= shortXVel; + Dust expr_4815_cp_0 = Main.dust[watery]; + expr_4815_cp_0.position.Y -= shortYVel; } - for (int num105 = 0; num105 < 2; num105++) + for (int j = 0; j < 2; j++) { - float num99 = Projectile.velocity.X / 3f * (float)num105; - float num100 = Projectile.velocity.Y / 3f * (float)num105; - int num101 = 4; - int num102 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num101, Projectile.position.Y + (float)num101), Projectile.width - num101 * 2, Projectile.height - num101 * 2, 245, 0f, 0f, 100, default, 1.2f); - Main.dust[num102].noGravity = true; - Main.dust[num102].velocity *= 0.1f; - Main.dust[num102].velocity += Projectile.velocity * 0.25f; - Dust expr_47FA_cp_0 = Main.dust[num102]; - expr_47FA_cp_0.position.X -= num99; - Dust expr_4815_cp_0 = Main.dust[num102]; - expr_4815_cp_0.position.Y -= num100; + float shortXVel2 = Projectile.velocity.X / 3f * (float)j; + float shortYVel2 = Projectile.velocity.Y / 3f * (float)j; + int otherFourConst = 4; + int superWet = Dust.NewDust(new Vector2(Projectile.position.X + (float)otherFourConst, Projectile.position.Y + (float)otherFourConst), Projectile.width - otherFourConst * 2, Projectile.height - otherFourConst * 2, 245, 0f, 0f, 100, default, 1.2f); + Main.dust[superWet].noGravity = true; + Main.dust[superWet].velocity *= 0.1f; + Main.dust[superWet].velocity += Projectile.velocity * 0.25f; + Dust expr_47FA_cp_0 = Main.dust[superWet]; + expr_47FA_cp_0.position.X -= shortXVel2; + Dust expr_4815_cp_0 = Main.dust[superWet]; + expr_4815_cp_0.position.Y -= shortYVel2; } Projectile.ai[1] += 1f; diff --git a/Projectiles/Melee/WhiteBoltAura.cs b/Projectiles/Melee/WhiteBoltAura.cs index 04f62d7631..195648c6bc 100644 --- a/Projectiles/Melee/WhiteBoltAura.cs +++ b/Projectiles/Melee/WhiteBoltAura.cs @@ -37,9 +37,9 @@ namespace CalamityMod.Projectiles.Melee Projectile.ai[0] = 0f; if (Projectile.owner == Main.myPlayer) { - int num414 = (int)(Projectile.position.X + 14f + (float)Main.rand.Next(Projectile.width - 28)); - int num415 = (int)(Projectile.position.Y + (float)Projectile.height + 4f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)num414, (float)num415, 0f, 5f, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner, 0f, 0f); + int randOrbXOffset = (int)(Projectile.position.X + 14f + (float)Main.rand.Next(Projectile.width - 28)); + int randOrbYOffset = (int)(Projectile.position.Y + (float)Projectile.height + 4f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)randOrbXOffset, (float)randOrbYOffset, 0f, 5f, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner, 0f, 0f); } } } @@ -47,26 +47,26 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.localAI[0] >= 10f) { Projectile.localAI[0] = 0f; - int num416 = 0; - int num417 = 0; - float num418 = 0f; - int num419 = Projectile.type; - for (int num420 = 0; num420 < 1000; num420++) + int projTimer = 0; + int incTracker = 0; + float aiTracker = 0f; + int theProjectile = Projectile.type; + for (int j = 0; j < 1000; j++) { - if (Main.projectile[num420].active && Main.projectile[num420].owner == Projectile.owner && Main.projectile[num420].type == num419 && Main.projectile[num420].ai[1] < 3600f) + if (Main.projectile[j].active && Main.projectile[j].owner == Projectile.owner && Main.projectile[j].type == theProjectile && Main.projectile[j].ai[1] < 3600f) { - num416++; - if (Main.projectile[num420].ai[1] > num418) + projTimer++; + if (Main.projectile[j].ai[1] > aiTracker) { - num417 = num420; - num418 = Main.projectile[num420].ai[1]; + incTracker = j; + aiTracker = Main.projectile[j].ai[1]; } } } - if (num416 > 1) + if (projTimer > 1) { - Main.projectile[num417].netUpdate = true; - Main.projectile[num417].ai[1] = 36000f; + Main.projectile[incTracker].netUpdate = true; + Main.projectile[incTracker].ai[1] = 36000f; } } } diff --git a/Projectiles/Melee/WhiteOrb.cs b/Projectiles/Melee/WhiteOrb.cs index b74f4bdc2b..0b70581667 100644 --- a/Projectiles/Melee/WhiteOrb.cs +++ b/Projectiles/Melee/WhiteOrb.cs @@ -23,12 +23,12 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { Lighting.AddLight(Projectile.Center, 0.2f, 0.2f, 0.2f); - for (int num457 = 0; num457 < 2; num457++) + for (int i = 0; i < 2; i++) { - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 91, 0f, 0f, 100, default, 1.25f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int shiny = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 91, 0f, 0f, 100, default, 1.25f); + Main.dust[shiny].noGravity = true; + Main.dust[shiny].velocity *= 0.5f; + Main.dust[shiny].velocity += Projectile.velocity * 0.1f; } } } diff --git a/Projectiles/Melee/Whiterain.cs b/Projectiles/Melee/Whiterain.cs index 51cac12528..9f6c09a1fe 100644 --- a/Projectiles/Melee/Whiterain.cs +++ b/Projectiles/Melee/Whiterain.cs @@ -33,12 +33,12 @@ namespace CalamityMod.Projectiles.Melee Lighting.AddLight(Projectile.Center, 0.2f, 0.2f, 0.2f); - for (int num457 = 0; num457 < 2; num457++) + for (int i = 0; i < 2; i++) { - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 91, 0f, 0f, 100, default, 1.25f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int shiny = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 91, 0f, 0f, 100, default, 1.25f); + Main.dust[shiny].noGravity = true; + Main.dust[shiny].velocity *= 0.5f; + Main.dust[shiny].velocity += Projectile.velocity * 0.1f; } CalamityUtils.HomeInOnNPC(Projectile, true, 200f, 12f, 20f); diff --git a/Projectiles/Melee/WulfrumScrewdriverProj.cs b/Projectiles/Melee/WulfrumScrewdriverProj.cs index 06450eb936..055f9e5eaf 100644 --- a/Projectiles/Melee/WulfrumScrewdriverProj.cs +++ b/Projectiles/Melee/WulfrumScrewdriverProj.cs @@ -81,7 +81,7 @@ namespace CalamityMod.Projectiles.Melee //Make the owner look like theyre holding the sword bla bla Owner.heldProj = Projectile.whoAmI; - Owner.direction = Math.Sign(Projectile.velocity.X); + Owner.ChangeDir(MathF.Sign(Projectile.velocity.X)); Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, Projectile.velocity.ToRotation() * Owner.gravDir - MathHelper.PiOver2); Owner.itemTime = 2; Owner.itemAnimation = 2; diff --git a/Projectiles/Melee/YateveoBloomProj.cs b/Projectiles/Melee/YateveoBloomProj.cs index d1e9127de6..0e0aee2827 100644 --- a/Projectiles/Melee/YateveoBloomProj.cs +++ b/Projectiles/Melee/YateveoBloomProj.cs @@ -23,9 +23,9 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - Vector2 vector62 = Main.player[Projectile.owner].MountedCenter - Projectile.Center; - Projectile.rotation = vector62.ToRotation() - 1.57f; - float distance = vector62.Length(); + Vector2 projDirection = Main.player[Projectile.owner].MountedCenter - Projectile.Center; + Projectile.rotation = projDirection.ToRotation() - 1.57f; + float distance = projDirection.Length(); if (Main.player[Projectile.owner].dead) { @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Melee Main.player[Projectile.owner].itemAnimation = 10; Main.player[Projectile.owner].itemTime = 10; - if (vector62.X < 0f) + if (projDirection.X < 0f) { Main.player[Projectile.owner].ChangeDir(1); Projectile.direction = 1; @@ -66,8 +66,8 @@ namespace CalamityMod.Projectiles.Melee } else { - float num211 = 14f / Main.player[Projectile.owner].GetAttackSpeed() * 1.25f; - float num212 = 0.9f / Main.player[Projectile.owner].GetAttackSpeed() * 1.25f; + float meleeSpeedDistance = 14f / Main.player[Projectile.owner].GetAttackSpeed() * 1.25f; + float meleeDamage = 0.9f / Main.player[Projectile.owner].GetAttackSpeed() * 1.25f; if (Projectile.ai[1] == 1f) Projectile.tileCollide = false; @@ -86,27 +86,26 @@ namespace CalamityMod.Projectiles.Melee } if (!Projectile.tileCollide) - num212 *= 2f; + meleeDamage *= 2f; if (distance > 80f || !Projectile.tileCollide) { - distance = num211 / distance; - vector62.X *= distance; - vector62.Y *= distance; + distance = meleeSpeedDistance / distance; + projDirection.X *= distance; + projDirection.Y *= distance; - Vector2 vector21 = new Vector2(Projectile.velocity.X, Projectile.velocity.Y); - float num217 = vector62.X - Projectile.velocity.X; - float num218 = vector62.Y - Projectile.velocity.Y; - float num219 = (float)Math.Sqrt((double)(num217 * num217 + num218 * num218)); + float projXDirect = projDirection.X - Projectile.velocity.X; + float projYDirect = projDirection.Y - Projectile.velocity.Y; + float projDistance = (float)Math.Sqrt((double)(projXDirect * projXDirect + projYDirect * projYDirect)); - num219 = num212 / num219; - num217 *= num219; - num218 *= num219; + projDistance = meleeDamage / projDistance; + projXDirect *= projDistance; + projYDirect *= projDistance; Projectile.velocity.X = Projectile.velocity.X * 0.98f; Projectile.velocity.Y = Projectile.velocity.Y * 0.98f; - Projectile.velocity.X = Projectile.velocity.X + num217; - Projectile.velocity.Y = Projectile.velocity.Y + num218; + Projectile.velocity.X = Projectile.velocity.X + projXDirect; + Projectile.velocity.Y = Projectile.velocity.Y + projYDirect; } else { @@ -183,35 +182,35 @@ namespace CalamityMod.Projectiles.Melee { Vector2 mountedCenter = Main.player[Projectile.owner].MountedCenter; Texture2D texture2D2 = ModContent.Request("CalamityMod/Projectiles/Melee/YateveoBloomChain").Value; - Vector2 vector17 = Projectile.Center; + Vector2 projCenter = Projectile.Center; Rectangle? sourceRectangle = null; Vector2 origin = new Vector2((float)texture2D2.Width * 0.5f, (float)texture2D2.Height * 0.5f); - float num91 = (float)texture2D2.Height; - Vector2 vector18 = mountedCenter - vector17; - float rotation15 = (float)Math.Atan2((double)vector18.Y, (double)vector18.X) - 1.57f; - bool flag13 = true; - if (float.IsNaN(vector17.X) && float.IsNaN(vector17.Y)) + float projHeight = (float)texture2D2.Height; + Vector2 actualCenter = mountedCenter - projCenter; + float projRotation = (float)Math.Atan2((double)actualCenter.Y, (double)actualCenter.X) - 1.57f; + bool isActive = true; + if (float.IsNaN(projCenter.X) && float.IsNaN(projCenter.Y)) { - flag13 = false; + isActive = false; } - if (float.IsNaN(vector18.X) && float.IsNaN(vector18.Y)) + if (float.IsNaN(actualCenter.X) && float.IsNaN(actualCenter.Y)) { - flag13 = false; + isActive = false; } - while (flag13) + while (isActive) { - if (vector18.Length() < num91 + 1f) + if (actualCenter.Length() < projHeight + 1f) { - flag13 = false; + isActive = false; } else { - Vector2 value2 = vector18; - value2.Normalize(); - vector17 += value2 * num91; - vector18 = mountedCenter - vector17; - Color color17 = Lighting.GetColor((int)vector17.X / 16, (int)(vector17.Y / 16f)); - Main.spriteBatch.Draw(texture2D2, vector17 - Main.screenPosition, sourceRectangle, color17, rotation15, origin, 1f, SpriteEffects.None, 0); + Vector2 centerCopy = actualCenter; + centerCopy.Normalize(); + projCenter += centerCopy * projHeight; + actualCenter = mountedCenter - projCenter; + Color drawArea = Lighting.GetColor((int)projCenter.X / 16, (int)(projCenter.Y / 16f)); + Main.spriteBatch.Draw(texture2D2, projCenter - Main.screenPosition, sourceRectangle, drawArea, projRotation, origin, 1f, SpriteEffects.None, 0); } } return true; diff --git a/Projectiles/Melee/Yoyos/GodsGambitYoyo.cs b/Projectiles/Melee/Yoyos/GodsGambitYoyo.cs index daa9ca8d07..45f05b93e3 100644 --- a/Projectiles/Melee/Yoyos/GodsGambitYoyo.cs +++ b/Projectiles/Melee/Yoyos/GodsGambitYoyo.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos public override void SetDefaults() { Projectile.aiStyle = ProjAIStyleID.Yoyo; - Projectile.width = Projectile.height = 16; + Projectile.width = Projectile.height = 22; Projectile.friendly = true; Projectile.DamageType = DamageClass.MeleeNoSpeed; Projectile.penetrate = -1; diff --git a/Projectiles/Melee/Yoyos/GodsGambitYoyo.png b/Projectiles/Melee/Yoyos/GodsGambitYoyo.png index a9645fc47f..aba81eadce 100644 Binary files a/Projectiles/Melee/Yoyos/GodsGambitYoyo.png and b/Projectiles/Melee/Yoyos/GodsGambitYoyo.png differ diff --git a/Projectiles/Melee/Yoyos/SmokingCometYoyo.cs b/Projectiles/Melee/Yoyos/SmokingCometYoyo.cs index 1f8deca17c..21111f7f14 100644 --- a/Projectiles/Melee/Yoyos/SmokingCometYoyo.cs +++ b/Projectiles/Melee/Yoyos/SmokingCometYoyo.cs @@ -81,103 +81,103 @@ namespace CalamityMod.Projectiles.Melee.Yoyos { Vector2 vector = Main.player[Projectile.owner].MountedCenter; vector.Y += Main.player[Projectile.owner].gfxOffY; - float num2 = Projectile.Center.X - vector.X; - float num3 = Projectile.Center.Y - vector.Y; - Math.Sqrt(num2 * num2 + num3 * num3); + float yoyoXVel = Projectile.Center.X - vector.X; + float yoyoYVel = Projectile.Center.Y - vector.Y; + Math.Sqrt(yoyoXVel * yoyoXVel + yoyoYVel * yoyoYVel); if (!Projectile.counterweight) { - int num5 = -1; + int distanceCheck = -1; if (Projectile.position.X + (float)(Projectile.width / 2) < Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2)) - num5 = 1; + distanceCheck = 1; - num5 *= -1; - Main.player[Projectile.owner].itemRotation = (float)Math.Atan2(num3 * (float)num5, num2 * (float)num5); + distanceCheck *= -1; + Main.player[Projectile.owner].itemRotation = (float)Math.Atan2(yoyoYVel * (float)distanceCheck, yoyoXVel * (float)distanceCheck); } - bool flag = true; - if (num2 == 0f && num3 == 0f) + bool isActive = true; + if (yoyoXVel == 0f && yoyoYVel == 0f) { - flag = false; + isActive = false; } else { - float num6 = (float)Math.Sqrt(num2 * num2 + num3 * num3); - num6 = 12f / num6; - num2 *= num6; - num3 *= num6; - vector.X -= num2 * 0.1f; - vector.Y -= num3 * 0.1f; - num2 = Projectile.position.X + (float)Projectile.width * 0.5f - vector.X; - num3 = Projectile.position.Y + (float)Projectile.height * 0.5f - vector.Y; + float yoyoVelocity = (float)Math.Sqrt(yoyoXVel * yoyoXVel + yoyoYVel * yoyoYVel); + yoyoVelocity = 12f / yoyoVelocity; + yoyoXVel *= yoyoVelocity; + yoyoYVel *= yoyoVelocity; + vector.X -= yoyoXVel * 0.1f; + vector.Y -= yoyoYVel * 0.1f; + yoyoXVel = Projectile.position.X + (float)Projectile.width * 0.5f - vector.X; + yoyoYVel = Projectile.position.Y + (float)Projectile.height * 0.5f - vector.Y; } - while (flag) + while (isActive) { - float num7 = 12f; - float num8 = (float)Math.Sqrt(num2 * num2 + num3 * num3); - float num9 = num8; - if (float.IsNaN(num8) || float.IsNaN(num9)) + float chainWidth = 12f; + float yoyoVelocityAgain = (float)Math.Sqrt(yoyoXVel * yoyoXVel + yoyoYVel * yoyoYVel); + float yoyoVelocityCopy = yoyoVelocityAgain; + if (float.IsNaN(yoyoVelocityAgain) || float.IsNaN(yoyoVelocityCopy)) { - flag = false; + isActive = false; continue; } - if (num8 < 20f) + if (yoyoVelocityAgain < 20f) { - num7 = num8 - 8f; - flag = false; + chainWidth = yoyoVelocityAgain - 8f; + isActive = false; } - num8 = 12f / num8; - num2 *= num8; - num3 *= num8; - vector.X += num2; - vector.Y += num3; - num2 = Projectile.position.X + (float)Projectile.width * 0.5f - vector.X; - num3 = Projectile.position.Y + (float)Projectile.height * 0.1f - vector.Y; - if (num9 > 12f) + yoyoVelocityAgain = 12f / yoyoVelocityAgain; + yoyoXVel *= yoyoVelocityAgain; + yoyoYVel *= yoyoVelocityAgain; + vector.X += yoyoXVel; + vector.Y += yoyoYVel; + yoyoXVel = Projectile.position.X + (float)Projectile.width * 0.5f - vector.X; + yoyoYVel = Projectile.position.Y + (float)Projectile.height * 0.1f - vector.Y; + if (yoyoVelocityCopy > 12f) { - float num10 = 0.3f; - float num11 = Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y); - if (num11 > 16f) - num11 = 16f; + float absVelocityCheck = 0.3f; + float absVelocity = Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y); + if (absVelocity > 16f) + absVelocity = 16f; - num11 = 1f - num11 / 16f; - num10 *= num11; - num11 = num9 / 80f; - if (num11 > 1f) - num11 = 1f; + absVelocity = 1f - absVelocity / 16f; + absVelocityCheck *= absVelocity; + absVelocity = yoyoVelocityCopy / 80f; + if (absVelocity > 1f) + absVelocity = 1f; - num10 *= num11; - if (num10 < 0f) - num10 = 0f; + absVelocityCheck *= absVelocity; + if (absVelocityCheck < 0f) + absVelocityCheck = 0f; - num10 *= num11; - num10 *= 0.5f; - if (num3 > 0f) + absVelocityCheck *= absVelocity; + absVelocityCheck *= 0.5f; + if (yoyoYVel > 0f) { - num3 *= 1f + num10; - num2 *= 1f - num10; + yoyoYVel *= 1f + absVelocityCheck; + yoyoXVel *= 1f - absVelocityCheck; } else { - num11 = Math.Abs(Projectile.velocity.X) / 3f; - if (num11 > 1f) - num11 = 1f; + absVelocity = Math.Abs(Projectile.velocity.X) / 3f; + if (absVelocity > 1f) + absVelocity = 1f; - num11 -= 0.5f; - num10 *= num11; - if (num10 > 0f) - num10 *= 2f; + absVelocity -= 0.5f; + absVelocityCheck *= absVelocity; + if (absVelocityCheck > 0f) + absVelocityCheck *= 2f; - num3 *= 1f + num10; - num2 *= 1f - num10; + yoyoYVel *= 1f + absVelocityCheck; + yoyoXVel *= 1f - absVelocityCheck; } } - float num4 = (float)Math.Atan2(num3, num2) - MathHelper.PiOver2; + float stringHelper = (float)Math.Atan2(yoyoYVel, yoyoXVel) - MathHelper.PiOver2; Texture2D stringTexture = ModContent.Request("CalamityMod/Projectiles/Melee/Yoyos/SmokingCometChain").Value; - Main.spriteBatch.Draw(stringTexture, new Vector2(vector.X - Main.screenPosition.X + (float)ModContent.Request("CalamityMod/Projectiles/Melee/Yoyos/SmokingCometChain").Width() * 0.5f, vector.Y - Main.screenPosition.Y + (float)ModContent.Request("CalamityMod/Projectiles/Melee/Yoyos/SmokingCometChain").Height() * 0.5f) - new Vector2(6f, 0f), new Rectangle(0, 0, ModContent.Request("CalamityMod/Projectiles/Melee/Yoyos/SmokingCometChain").Width(), (int)num7), Color.White, num4, new Vector2((float)ModContent.Request("CalamityMod/Projectiles/Melee/Yoyos/SmokingCometChain").Width() * 0.5f, 0f), 1f, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(stringTexture, new Vector2(vector.X - Main.screenPosition.X + (float)ModContent.Request("CalamityMod/Projectiles/Melee/Yoyos/SmokingCometChain").Width() * 0.5f, vector.Y - Main.screenPosition.Y + (float)ModContent.Request("CalamityMod/Projectiles/Melee/Yoyos/SmokingCometChain").Height() * 0.5f) - new Vector2(6f, 0f), new Rectangle(0, 0, ModContent.Request("CalamityMod/Projectiles/Melee/Yoyos/SmokingCometChain").Width(), (int)chainWidth), Color.White, stringHelper, new Vector2((float)ModContent.Request("CalamityMod/Projectiles/Melee/Yoyos/SmokingCometChain").Width() * 0.5f, 0f), 1f, SpriteEffects.None, 0f); } CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); diff --git a/Projectiles/Pets/Astrophage.cs b/Projectiles/Pets/Astrophage.cs index 368fdb67aa..92606b0c88 100644 --- a/Projectiles/Pets/Astrophage.cs +++ b/Projectiles/Pets/Astrophage.cs @@ -29,9 +29,9 @@ namespace CalamityMod.Projectiles.Pets public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) { Player player = Main.player[Projectile.owner]; - Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2; - float playerDistance = vector48.Length(); + Vector2 projCenter = Projectile.Center; + Vector2 playerDirection = player.Center - projCenter; + float playerDistance = playerDirection.Length(); fallThrough = playerDistance > 200f; return true; } @@ -79,9 +79,9 @@ namespace CalamityMod.Projectiles.Pets if (!fly) { Projectile.rotation = 0; - Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2; - float playerDistance = vector48.Length(); + Vector2 projCenter = Projectile.Center; + Vector2 playerDirection = player.Center - projCenter; + float playerDistance = playerDirection.Length(); if (Projectile.velocity.Y == 0 && (HoleBelow() || (playerDistance > 110f && Projectile.position.X == Projectile.oldPosition.X))) { Projectile.velocity.Y = -5f; diff --git a/Projectiles/Pets/Bear.cs b/Projectiles/Pets/Bear.cs index 9202a2c4b0..5577af726f 100644 --- a/Projectiles/Pets/Bear.cs +++ b/Projectiles/Pets/Bear.cs @@ -34,9 +34,9 @@ namespace CalamityMod.Projectiles.Pets public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) { Player player = Main.player[Projectile.owner]; - Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2; - float playerDistance = vector48.Length(); + Vector2 projCenter = Projectile.Center; + Vector2 playerDirection = player.Center - projCenter; + float playerDistance = playerDirection.Length(); fallThrough = playerDistance > 200f; return true; } @@ -67,9 +67,9 @@ namespace CalamityMod.Projectiles.Pets if (!fly) { Projectile.rotation = 0; - Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2; - float playerDistance = vector48.Length(); + Vector2 projCenter = Projectile.Center; + Vector2 playerDirection = player.Center - projCenter; + float playerDistance = playerDirection.Length(); if (Projectile.velocity.Y == 0 && (HoleBelow() || (playerDistance > 110f && Projectile.position.X == Projectile.oldPosition.X))) { Projectile.velocity.Y = -5f; @@ -233,18 +233,16 @@ namespace CalamityMod.Projectiles.Pets } else if (fly) { - float num16 = 0.3f; + float flyingSpeed = 0.3f; Projectile.tileCollide = false; - Vector2 vector3 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float horiPos = Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2) - vector3.X; - float vertiPos = Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2) - vector3.Y; + Vector2 flyDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float horiPos = Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2) - flyDirection.X; + float vertiPos = Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2) - flyDirection.Y; vertiPos += (float)Main.rand.Next(-10, 21); horiPos += (float)Main.rand.Next(-10, 21); horiPos += (float)(60 * -(float)Main.player[Projectile.owner].direction); vertiPos -= 60f; float playerDistance = (float)Math.Sqrt((double)(horiPos * horiPos + vertiPos * vertiPos)); - float num21 = 18f; - float num27 = (float)Math.Sqrt((double)(horiPos * horiPos + vertiPos * vertiPos)); if (playerDistance > 2000f) { @@ -254,7 +252,7 @@ namespace CalamityMod.Projectiles.Pets } if (playerDistance < 100f) { - num16 = 0.1f; + flyingSpeed = 0.1f; if (player.velocity.Y == 0f) { ++playerStill; @@ -275,53 +273,53 @@ namespace CalamityMod.Projectiles.Pets { Projectile.velocity *= 0.90f; } - num16 = 0.01f; + flyingSpeed = 0.01f; } else { if (playerDistance < 100f) { - num16 = 0.1f; + flyingSpeed = 0.1f; } if (playerDistance > 300f) { - num16 = 1f; + flyingSpeed = 1f; } - playerDistance = num21 / playerDistance; + playerDistance = 18f / playerDistance; horiPos *= playerDistance; vertiPos *= playerDistance; } if (Projectile.velocity.X <= horiPos) { - Projectile.velocity.X = Projectile.velocity.X + num16; - if (num16 > 0.05f && Projectile.velocity.X < 0f) + Projectile.velocity.X = Projectile.velocity.X + flyingSpeed; + if (flyingSpeed > 0.05f && Projectile.velocity.X < 0f) { - Projectile.velocity.X = Projectile.velocity.X + num16; + Projectile.velocity.X = Projectile.velocity.X + flyingSpeed; } } if (Projectile.velocity.X > horiPos) { - Projectile.velocity.X = Projectile.velocity.X - num16; - if (num16 > 0.05f && Projectile.velocity.X > 0f) + Projectile.velocity.X = Projectile.velocity.X - flyingSpeed; + if (flyingSpeed > 0.05f && Projectile.velocity.X > 0f) { - Projectile.velocity.X = Projectile.velocity.X - num16; + Projectile.velocity.X = Projectile.velocity.X - flyingSpeed; } } if (Projectile.velocity.Y <= vertiPos) { - Projectile.velocity.Y = Projectile.velocity.Y + num16; - if (num16 > 0.05f && Projectile.velocity.Y < 0f) + Projectile.velocity.Y = Projectile.velocity.Y + flyingSpeed; + if (flyingSpeed > 0.05f && Projectile.velocity.Y < 0f) { - Projectile.velocity.Y = Projectile.velocity.Y + num16 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y + flyingSpeed * 2f; } } if (Projectile.velocity.Y > vertiPos) { - Projectile.velocity.Y = Projectile.velocity.Y - num16; - if (num16 > 0.05f && Projectile.velocity.Y > 0f) + Projectile.velocity.Y = Projectile.velocity.Y - flyingSpeed; + if (flyingSpeed > 0.05f && Projectile.velocity.Y > 0f) { - Projectile.velocity.Y = Projectile.velocity.Y - num16 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y - flyingSpeed * 2f; } } diff --git a/Projectiles/Pets/BrimlingPet.cs b/Projectiles/Pets/BrimlingPet.cs index d2a5c420fd..039b854234 100644 --- a/Projectiles/Pets/BrimlingPet.cs +++ b/Projectiles/Pets/BrimlingPet.cs @@ -42,33 +42,30 @@ namespace CalamityMod.Projectiles.Pets { Projectile.timeLeft = 4; } - float num16 = 0.5f; + float flySpeed = 0.5f; Projectile.tileCollide = false; - int num17 = 100; - Vector2 vector3 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num18 = Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2) - vector3.X; - float num19 = Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2) - vector3.Y; - num19 += (float)Main.rand.Next(-10, 21); - num18 += (float)Main.rand.Next(-10, 21); - num18 += (float)(60 * -(float)Main.player[Projectile.owner].direction); - num19 -= 60f; - float num20 = (float)Math.Sqrt((double)(num18 * num18 + num19 * num19)); - float num21 = 18f; + Vector2 flyDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float horiPos = Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2) - flyDirection.X; + float vertPos = Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2) - flyDirection.Y; + vertPos += (float)Main.rand.Next(-10, 21); + horiPos += (float)Main.rand.Next(-10, 21); + horiPos += (float)(60 * -(float)Main.player[Projectile.owner].direction); + vertPos -= 60f; + float playerDistance = (float)Math.Sqrt((double)(horiPos * horiPos + vertPos * vertPos)); //Limites de mouvement ici - float num27 = (float)Math.Sqrt((double)(num18 * num18 + num19 * num19)); - if (num27 > 1000f) + if (playerDistance > 1000f) { - Projectile.position.X = Projectile.position.X + num18; - Projectile.position.Y = Projectile.position.Y + num19; + Projectile.position.X = Projectile.position.X + horiPos; + Projectile.position.Y = Projectile.position.Y + vertPos; for (int k = 0; k < 10; k++) { Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0, -1f, 0, default, 1f); } } - if (num20 < (float)num17 && Main.player[Projectile.owner].velocity.Y == 0f && + if (playerDistance < 100f && Main.player[Projectile.owner].velocity.Y == 0f && Projectile.position.Y + (float)Projectile.height <= Main.player[Projectile.owner].position.Y + (float)Main.player[Projectile.owner].height && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) { @@ -78,60 +75,60 @@ namespace CalamityMod.Projectiles.Pets Projectile.velocity.Y = -6f; } } - if (num20 < 50f) + if (playerDistance < 50f) { if (Math.Abs(Projectile.velocity.X) > 2f || Math.Abs(Projectile.velocity.Y) > 2f) { Projectile.velocity *= 0.90f; } - num16 = 0.01f; + flySpeed = 0.01f; } else { - if (num20 < 100f) + if (playerDistance < 100f) { - num16 = 0.1f; + flySpeed = 0.1f; } - if (num20 > 300f) + if (playerDistance > 300f) { - num16 = 1f; + flySpeed = 1f; } - num20 = num21 / num20; - num18 *= num20; - num19 *= num20; + playerDistance = 18f / playerDistance; + horiPos *= playerDistance; + vertPos *= playerDistance; } //Les changements de velocité ici - if (Projectile.velocity.X < num18) + if (Projectile.velocity.X < horiPos) { - Projectile.velocity.X = Projectile.velocity.X + num16; - if (num16 > 0.05f && Projectile.velocity.X < 0f) + Projectile.velocity.X = Projectile.velocity.X + flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.X < 0f) { - Projectile.velocity.X = Projectile.velocity.X + num16; + Projectile.velocity.X = Projectile.velocity.X + flySpeed; } } - if (Projectile.velocity.X > num18) + if (Projectile.velocity.X > horiPos) { - Projectile.velocity.X = Projectile.velocity.X - num16; - if (num16 > 0.05f && Projectile.velocity.X > 0f) + Projectile.velocity.X = Projectile.velocity.X - flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.X > 0f) { - Projectile.velocity.X = Projectile.velocity.X - num16; + Projectile.velocity.X = Projectile.velocity.X - flySpeed; } } - if (Projectile.velocity.Y < num19) + if (Projectile.velocity.Y < vertPos) { - Projectile.velocity.Y = Projectile.velocity.Y + num16; - if (num16 > 0.05f && Projectile.velocity.Y < 0f) + Projectile.velocity.Y = Projectile.velocity.Y + flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.Y < 0f) { - Projectile.velocity.Y = Projectile.velocity.Y + num16 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y + flySpeed * 2f; } } - if (Projectile.velocity.Y > num19) + if (Projectile.velocity.Y > vertPos) { - Projectile.velocity.Y = Projectile.velocity.Y - num16; - if (num16 > 0.05f && Projectile.velocity.Y > 0f) + Projectile.velocity.Y = Projectile.velocity.Y - flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.Y > 0f) { - Projectile.velocity.Y = Projectile.velocity.Y - num16 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y - flySpeed * 2f; } } if ((double)Projectile.velocity.X > 0.25) diff --git a/Projectiles/Pets/ChibiiDoggo.cs b/Projectiles/Pets/ChibiiDoggo.cs index 4f0304c20f..c158fe7771 100644 --- a/Projectiles/Pets/ChibiiDoggo.cs +++ b/Projectiles/Pets/ChibiiDoggo.cs @@ -49,40 +49,38 @@ namespace CalamityMod.Projectiles.Pets SpriteEffects spriteEffects = SpriteEffects.None; if (Projectile.spriteDirection == -1) spriteEffects = SpriteEffects.FlipHorizontally; - Color color25 = Lighting.GetColor((int)(Projectile.Center.X / 16), (int)(Projectile.Center.Y / 16)); + Color colorArea = Lighting.GetColor((int)(Projectile.Center.X / 16), (int)(Projectile.Center.Y / 16)); Texture2D texture2D3 = ModContent.Request("CalamityMod/Projectiles/Pets/ChibiiDoggoMonochrome").Value; - int num156 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y3 = num156 * Projectile.frame; - Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, num156); - Vector2 origin2 = rectangle.Size() / 2f; - int num157 = 8; - int num158 = 2; - int num159 = 1; - float num160 = 0f; + int textureArea = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y3 = textureArea * Projectile.frame; + Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, textureArea); + Vector2 halfRect = rectangle.Size() / 2f; + int eightCompare = 8; + int twoConst = 2; - int num161 = num159; - while ((num158 > 0 && num161 < num157) || (num158 < 0 && num161 > num157)) + int counter = 1; + while ((twoConst > 0 && counter < eightCompare) || (twoConst < 0 && counter > eightCompare)) { - Color color26 = color25; - color26 = Projectile.GetAlpha(color26); + Color colorAlpha = colorArea; + colorAlpha = Projectile.GetAlpha(colorAlpha); goto IL_6899; IL_6881: - num161 += num158; + counter += twoConst; continue; IL_6899: - float num164 = (float)(num157 - num161); - if (num158 < 0) + float trailColorChange = (float)(eightCompare - counter); + if (twoConst < 0) { - num164 = (float)(num159 - num161); + trailColorChange = (float)(1 - counter); } - color26 *= num164 / ((float)ProjectileID.Sets.TrailCacheLength[Projectile.type] * 1.5f); - Vector2 value4 = Projectile.oldPos[num161]; - float num165 = Projectile.rotation; + colorAlpha *= trailColorChange / ((float)ProjectileID.Sets.TrailCacheLength[Projectile.type] * 1.5f); + Vector2 oldDrawPos = Projectile.oldPos[counter]; + float projRotate = Projectile.rotation; SpriteEffects effects = spriteEffects; - Main.spriteBatch.Draw(texture2D3, value4 + Projectile.Size / 2f - Main.screenPosition + new Vector2(0, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, num165 + Projectile.rotation * num160 * (float)(num161 - 1) * Projectile.spriteDirection, origin2, Projectile.scale, effects, 0f); + Main.spriteBatch.Draw(texture2D3, oldDrawPos + Projectile.Size / 2f - Main.screenPosition + new Vector2(0, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), colorAlpha, projRotate + Projectile.rotation * 0f * (float)(counter - 1) * Projectile.spriteDirection, halfRect, Projectile.scale, effects, 0f); goto IL_6881; } - Main.spriteBatch.Draw(ModContent.Request(Texture).Value, Projectile.position + Projectile.Size / 2f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), lightColor, Projectile.rotation, origin2, Projectile.scale, spriteEffects, 0); + Main.spriteBatch.Draw(ModContent.Request(Texture).Value, Projectile.position + Projectile.Size / 2f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), lightColor, Projectile.rotation, halfRect, Projectile.scale, spriteEffects, 0); return false; } diff --git a/Projectiles/Pets/ChibiiDoggoFly.cs b/Projectiles/Pets/ChibiiDoggoFly.cs index c2240aea2b..c46dd04893 100644 --- a/Projectiles/Pets/ChibiiDoggoFly.cs +++ b/Projectiles/Pets/ChibiiDoggoFly.cs @@ -35,36 +35,34 @@ namespace CalamityMod.Projectiles.Pets SpriteEffects spriteEffects = SpriteEffects.None; if (Projectile.spriteDirection == -1) spriteEffects = SpriteEffects.FlipHorizontally; - Color color25 = Lighting.GetColor((int)(Projectile.Center.X / 16), (int)(Projectile.Center.Y / 16)); + Color colorArea = Lighting.GetColor((int)(Projectile.Center.X / 16), (int)(Projectile.Center.Y / 16)); Texture2D texture2D3 = ModContent.Request("CalamityMod/Projectiles/Pets/ChibiiDoggoFlyMonochrome").Value; - int num156 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y3 = num156 * Projectile.frame; - Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, num156); + int textureArea = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y3 = textureArea * Projectile.frame; + Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, textureArea); Vector2 origin2 = rectangle.Size() / 2f; - int num157 = 12; - int num158 = 2; - int num159 = 1; - float num160 = 0f; - int num161 = num159; - while ((num158 > 0 && num161 < num157) || (num158 < 0 && num161 > num157)) + int twelveCompare = 12; + int twoConst = 2; + int counter = 1; + while ((twoConst > 0 && counter < twelveCompare) || (twoConst < 0 && counter > twelveCompare)) { - Color color26 = color25; - color26 = Projectile.GetAlpha(color26); + Color colorAlpha = colorArea; + colorAlpha = Projectile.GetAlpha(colorAlpha); goto IL_6899; IL_6881: - num161 += num158; + counter += twoConst; continue; IL_6899: - float num164 = (float)(num157 - num161); - if (num158 < 0) + float trailColorChange = (float)(twelveCompare - counter); + if (twoConst < 0) { - num164 = (float)(num159 - num161); + trailColorChange = (float)(1 - counter); } - color26 *= num164 / ((float)ProjectileID.Sets.TrailCacheLength[Projectile.type] * 1.5f); - Vector2 value4 = Projectile.oldPos[num161]; - float num165 = Projectile.rotation; + colorAlpha *= trailColorChange / ((float)ProjectileID.Sets.TrailCacheLength[Projectile.type] * 1.5f); + Vector2 oldDrawPos = Projectile.oldPos[counter]; + float projRotate = Projectile.rotation; SpriteEffects effects = spriteEffects; - Main.spriteBatch.Draw(texture2D3, value4 + Projectile.Size / 2f - Main.screenPosition + new Vector2(0, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, num165 + Projectile.rotation * num160 * (float)(num161 - 1) * Projectile.spriteDirection, origin2, Projectile.scale, effects, 0f); + Main.spriteBatch.Draw(texture2D3, oldDrawPos + Projectile.Size / 2f - Main.screenPosition + new Vector2(0, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), colorAlpha, projRotate + Projectile.rotation * 0f * (float)(counter - 1) * Projectile.spriteDirection, origin2, Projectile.scale, effects, 0f); goto IL_6881; } Main.spriteBatch.Draw(ModContent.Request(Texture).Value, Projectile.position + Projectile.Size / 2f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), lightColor, Projectile.rotation, origin2, Projectile.scale, spriteEffects, 0); diff --git a/Projectiles/Pets/DannyDevitoPet.cs b/Projectiles/Pets/DannyDevitoPet.cs index 6b5740d9c6..caf6efc850 100644 --- a/Projectiles/Pets/DannyDevitoPet.cs +++ b/Projectiles/Pets/DannyDevitoPet.cs @@ -31,9 +31,9 @@ namespace CalamityMod.Projectiles.Pets public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) { Player player = Main.player[Projectile.owner]; - Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2; - float playerDistance = vector48.Length(); + Vector2 projCenter = Projectile.Center; + Vector2 playerDirection = player.Center - projCenter; + float playerDistance = playerDirection.Length(); fallThrough = playerDistance > 200f; return true; } @@ -59,9 +59,9 @@ namespace CalamityMod.Projectiles.Pets if (!fly) { Projectile.rotation = 0; - Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2; - float playerDistance = vector48.Length(); + Vector2 projCenter = Projectile.Center; + Vector2 playerDirection = player.Center - projCenter; + float playerDistance = playerDirection.Length(); if (Projectile.velocity.Y == 0 && (HoleBelow() || (playerDistance > 110f && Projectile.position.X == Projectile.oldPosition.X))) { Projectile.velocity.Y = -5f; @@ -144,18 +144,16 @@ namespace CalamityMod.Projectiles.Pets } else if (fly) { - float num16 = 0.3f; + float flySpeed = 0.3f; Projectile.tileCollide = false; - Vector2 vector3 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float horiPos = Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2) - vector3.X; - float vertiPos = Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2) - vector3.Y; + Vector2 flyDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float horiPos = Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2) - flyDirection.X; + float vertiPos = Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2) - flyDirection.Y; vertiPos += (float)Main.rand.Next(-10, 21); horiPos += (float)Main.rand.Next(-10, 21); horiPos += (float)(60 * -(float)Main.player[Projectile.owner].direction); vertiPos -= 60f; float playerDistance = (float)Math.Sqrt((double)(horiPos * horiPos + vertiPos * vertiPos)); - float num21 = 18f; - float num27 = (float)Math.Sqrt((double)(horiPos * horiPos + vertiPos * vertiPos)); if (playerDistance > 1200f) { Projectile.position.X = Main.player[Projectile.owner].Center.X - (float)(Projectile.width / 2); @@ -164,7 +162,7 @@ namespace CalamityMod.Projectiles.Pets } if (playerDistance < 100f) { - num16 = 0.1f; + flySpeed = 0.1f; if (player.velocity.Y == 0f) { ++playerStill; @@ -185,52 +183,52 @@ namespace CalamityMod.Projectiles.Pets { Projectile.velocity *= 0.90f; } - num16 = 0.01f; + flySpeed = 0.01f; } else { if (playerDistance < 100f) { - num16 = 0.1f; + flySpeed = 0.1f; } if (playerDistance > 300f) { - num16 = 1f; + flySpeed = 1f; } - playerDistance = num21 / playerDistance; + playerDistance = 18f / playerDistance; horiPos *= playerDistance; vertiPos *= playerDistance; } if (Projectile.velocity.X <= horiPos) { - Projectile.velocity.X = Projectile.velocity.X + num16; - if (num16 > 0.05f && Projectile.velocity.X < 0f) + Projectile.velocity.X = Projectile.velocity.X + flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.X < 0f) { - Projectile.velocity.X = Projectile.velocity.X + num16; + Projectile.velocity.X = Projectile.velocity.X + flySpeed; } } if (Projectile.velocity.X > horiPos) { - Projectile.velocity.X = Projectile.velocity.X - num16; - if (num16 > 0.05f && Projectile.velocity.X > 0f) + Projectile.velocity.X = Projectile.velocity.X - flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.X > 0f) { - Projectile.velocity.X = Projectile.velocity.X - num16; + Projectile.velocity.X = Projectile.velocity.X - flySpeed; } } if (Projectile.velocity.Y <= vertiPos) { - Projectile.velocity.Y = Projectile.velocity.Y + num16; - if (num16 > 0.05f && Projectile.velocity.Y < 0f) + Projectile.velocity.Y = Projectile.velocity.Y + flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.Y < 0f) { - Projectile.velocity.Y = Projectile.velocity.Y + num16 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y + flySpeed * 2f; } } if (Projectile.velocity.Y > vertiPos) { - Projectile.velocity.Y = Projectile.velocity.Y - num16; - if (num16 > 0.05f && Projectile.velocity.Y > 0f) + Projectile.velocity.Y = Projectile.velocity.Y - flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.Y > 0f) { - Projectile.velocity.Y = Projectile.velocity.Y - num16 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y - flySpeed * 2f; } } Projectile.rotation = Projectile.velocity.X * 0.03f; @@ -250,16 +248,16 @@ namespace CalamityMod.Projectiles.Pets { if (!Main.gamePaused || Main.gameMenu) { - Vector2 vector69 = projectile.position - Main.screenPosition; - if ((float)Main.mouseX > vector69.X && (float)Main.mouseX < vector69.X + (float)projectile.width && (float)Main.mouseY > vector69.Y && (float)Main.mouseY < vector69.Y + (float)projectile.height) + Vector2 projDirect = projectile.position - Main.screenPosition; + if ((float)Main.mouseX > projDirect.X && (float)Main.mouseX < projDirect.X + (float)projectile.width && (float)Main.mouseY > projDirect.Y && (float)Main.mouseY < projDirect.Y + (float)projectile.height) { - int num345 = (int)(Main.player[projectile.owner].Center.X / 16f); - int num346 = (int)(Main.player[projectile.owner].Center.Y / 16f); - int num347 = (int)projectile.Center.X / 16; - int num348 = (int)projectile.Center.Y / 16; + int playerTileX = (int)(Main.player[projectile.owner].Center.X / 16f); + int playerTileY = (int)(Main.player[projectile.owner].Center.Y / 16f); + int projTileX = (int)projectile.Center.X / 16; + int projTileY = (int)projectile.Center.Y / 16; int lastTileRangeX = Main.player[projectile.owner].lastTileRangeX; int lastTileRangeY = Main.player[projectile.owner].lastTileRangeY; - if (num345 >= num347 - lastTileRangeX && num345 <= num347 + lastTileRangeX + 1 && num346 >= num348 - lastTileRangeY && num346 <= num348 + lastTileRangeY + 1) + if (playerTileX >= projTileX - lastTileRangeX && playerTileX <= projTileX + lastTileRangeX + 1 && playerTileY >= projTileY - lastTileRangeY && playerTileY <= projTileY + lastTileRangeY + 1) { Main.player[projectile.owner].noThrow = 2; Main.player[projectile.owner].cursorItemIconEnabled = true; diff --git a/Projectiles/Pets/EidolonSnail.cs b/Projectiles/Pets/EidolonSnail.cs index 43eca6fac7..1cb931d241 100644 --- a/Projectiles/Pets/EidolonSnail.cs +++ b/Projectiles/Pets/EidolonSnail.cs @@ -62,9 +62,9 @@ namespace CalamityMod.Projectiles.Pets public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) { Player player = Main.player[Projectile.owner]; - Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2; - float playerDistance = vector48.Length(); + Vector2 projCenter = Projectile.Center; + Vector2 playerDirection = player.Center - projCenter; + float playerDistance = playerDirection.Length(); fallThrough = playerDistance > 200f; return true; } @@ -87,13 +87,13 @@ namespace CalamityMod.Projectiles.Pets Projectile.timeLeft = 2; } - Vector2 vector46 = Projectile.position; + Vector2 projPos = Projectile.position; if (!fly) { Projectile.rotation = 0; - Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2; - float playerDistance = vector48.Length(); + Vector2 projCenter = Projectile.Center; + Vector2 playerDirection = player.Center - projCenter; + float playerDistance = playerDirection.Length(); if (Projectile.velocity.Y == 0 && ((HoleBelow() && playerDistance > 150f) || (playerDistance > 150f && Projectile.position.X == Projectile.oldPosition.X))) { Projectile.velocity.Y = -8f; @@ -189,18 +189,16 @@ namespace CalamityMod.Projectiles.Pets } else if (fly) { - float num16 = 0.5f; + float flySpeed = 0.5f; Projectile.tileCollide = false; - Vector2 vector3 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float horiPos = Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2) - vector3.X; - float vertiPos = Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2) - vector3.Y; + Vector2 flyDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float horiPos = Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2) - flyDirection.X; + float vertiPos = Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2) - flyDirection.Y; vertiPos += (float)Main.rand.Next(-10, 21); horiPos += (float)Main.rand.Next(-10, 21); horiPos += (float)(60 * -(float)player.direction); vertiPos -= 60f; float playerDistance = (float)Math.Sqrt((double)(horiPos * horiPos + vertiPos * vertiPos)); - float num21 = 18f; - float num27 = (float)Math.Sqrt((double)(horiPos * horiPos + vertiPos * vertiPos)); if (playerDistance > 1200f) { Projectile.position.X = player.Center.X - (float)(Projectile.width / 2); @@ -209,7 +207,7 @@ namespace CalamityMod.Projectiles.Pets } if (playerDistance < 100f) { - num16 = 0.5f; + flySpeed = 0.5f; if (player.velocity.Y == 0f) { ++playerStill; @@ -231,52 +229,52 @@ namespace CalamityMod.Projectiles.Pets { Projectile.velocity *= 0.90f; } - num16 = 0.02f; + flySpeed = 0.02f; } else { if (playerDistance < 100f) { - num16 = 0.35f; + flySpeed = 0.35f; } if (playerDistance > 300f) { - num16 = 1f; + flySpeed = 1f; } - playerDistance = num21 / playerDistance; + playerDistance = 18f / playerDistance; horiPos *= playerDistance; vertiPos *= playerDistance; } if (Projectile.velocity.X <= horiPos) { - Projectile.velocity.X = Projectile.velocity.X + num16; - if (num16 > 0.05f && Projectile.velocity.X < 0f) + Projectile.velocity.X = Projectile.velocity.X + flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.X < 0f) { - Projectile.velocity.X = Projectile.velocity.X + num16; + Projectile.velocity.X = Projectile.velocity.X + flySpeed; } } if (Projectile.velocity.X > horiPos) { - Projectile.velocity.X = Projectile.velocity.X - num16; - if (num16 > 0.05f && Projectile.velocity.X > 0f) + Projectile.velocity.X = Projectile.velocity.X - flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.X > 0f) { - Projectile.velocity.X = Projectile.velocity.X - num16; + Projectile.velocity.X = Projectile.velocity.X - flySpeed; } } if (Projectile.velocity.Y <= vertiPos) { - Projectile.velocity.Y = Projectile.velocity.Y + num16; - if (num16 > 0.05f && Projectile.velocity.Y < 0f) + Projectile.velocity.Y = Projectile.velocity.Y + flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.Y < 0f) { - Projectile.velocity.Y = Projectile.velocity.Y + num16 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y + flySpeed * 2f; } } if (Projectile.velocity.Y > vertiPos) { - Projectile.velocity.Y = Projectile.velocity.Y - num16; - if (num16 > 0.05f && Projectile.velocity.Y > 0f) + Projectile.velocity.Y = Projectile.velocity.Y - flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.Y > 0f) { - Projectile.velocity.Y = Projectile.velocity.Y - num16 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y - flySpeed * 2f; } } diff --git a/Projectiles/Pets/FlakPet.cs b/Projectiles/Pets/FlakPet.cs index 898b6a38eb..ae63ae54d8 100644 --- a/Projectiles/Pets/FlakPet.cs +++ b/Projectiles/Pets/FlakPet.cs @@ -33,9 +33,9 @@ namespace CalamityMod.Projectiles.Pets public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) { Player player = Main.player[Projectile.owner]; - Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2; - float playerDistance = vector48.Length(); + Vector2 projCenter = Projectile.Center; + Vector2 playerDirection = player.Center - projCenter; + float playerDistance = playerDirection.Length(); fallThrough = playerDistance > 200f; return true; } @@ -61,9 +61,9 @@ namespace CalamityMod.Projectiles.Pets if (!fly) { Projectile.rotation = 0; - Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2; - float playerDistance = vector48.Length(); + Vector2 projCenter = Projectile.Center; + Vector2 playerDirection = player.Center - projCenter; + float playerDistance = playerDirection.Length(); if (Projectile.velocity.Y == 0 && (HoleBelow() || (playerDistance > 110f && Projectile.position.X == Projectile.oldPosition.X))) { Projectile.velocity.Y = -5f; @@ -166,18 +166,16 @@ namespace CalamityMod.Projectiles.Pets } else if (fly) { - float num16 = 0.3f; + float flySpeed = 0.3f; Projectile.tileCollide = false; - Vector2 vector3 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float horiPos = Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2) - vector3.X; - float vertiPos = Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2) - vector3.Y; + Vector2 flyDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float horiPos = Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2) - flyDirection.X; + float vertiPos = Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2) - flyDirection.Y; vertiPos += (float)Main.rand.Next(-10, 21); horiPos += (float)Main.rand.Next(-10, 21); horiPos += (float)(60 * -(float)player.direction); vertiPos -= 60f; float playerDistance = (float)Math.Sqrt((double)(horiPos * horiPos + vertiPos * vertiPos)); - float num21 = 18f; - float num27 = (float)Math.Sqrt((double)(horiPos * horiPos + vertiPos * vertiPos)); if (playerDistance > 1200f) { Projectile.position.X = player.Center.X - (float)(Projectile.width / 2); @@ -186,7 +184,7 @@ namespace CalamityMod.Projectiles.Pets } if (playerDistance < 100f) { - num16 = 0.1f; + flySpeed = 0.1f; if (player.velocity.Y == 0f) { ++playerStill; @@ -207,52 +205,52 @@ namespace CalamityMod.Projectiles.Pets { Projectile.velocity *= 0.90f; } - num16 = 0.01f; + flySpeed = 0.01f; } else { if (playerDistance < 100f) { - num16 = 0.1f; + flySpeed = 0.1f; } if (playerDistance > 300f) { - num16 = 1f; + flySpeed = 1f; } - playerDistance = num21 / playerDistance; + playerDistance = 18f / playerDistance; horiPos *= playerDistance; vertiPos *= playerDistance; } if (Projectile.velocity.X <= horiPos) { - Projectile.velocity.X = Projectile.velocity.X + num16; - if (num16 > 0.05f && Projectile.velocity.X < 0f) + Projectile.velocity.X = Projectile.velocity.X + flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.X < 0f) { - Projectile.velocity.X = Projectile.velocity.X + num16; + Projectile.velocity.X = Projectile.velocity.X + flySpeed; } } if (Projectile.velocity.X > horiPos) { - Projectile.velocity.X = Projectile.velocity.X - num16; - if (num16 > 0.05f && Projectile.velocity.X > 0f) + Projectile.velocity.X = Projectile.velocity.X - flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.X > 0f) { - Projectile.velocity.X = Projectile.velocity.X - num16; + Projectile.velocity.X = Projectile.velocity.X - flySpeed; } } if (Projectile.velocity.Y <= vertiPos) { - Projectile.velocity.Y = Projectile.velocity.Y + num16; - if (num16 > 0.05f && Projectile.velocity.Y < 0f) + Projectile.velocity.Y = Projectile.velocity.Y + flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.Y < 0f) { - Projectile.velocity.Y = Projectile.velocity.Y + num16 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y + flySpeed * 2f; } } if (Projectile.velocity.Y > vertiPos) { - Projectile.velocity.Y = Projectile.velocity.Y - num16; - if (num16 > 0.05f && Projectile.velocity.Y > 0f) + Projectile.velocity.Y = Projectile.velocity.Y - flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.Y > 0f) { - Projectile.velocity.Y = Projectile.velocity.Y - num16 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y - flySpeed * 2f; } } Projectile.rotation += (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y)) * 0.01f * Projectile.direction; diff --git a/Projectiles/Pets/KendraPet.cs b/Projectiles/Pets/KendraPet.cs index ccfe64890e..2dfbb656b9 100644 --- a/Projectiles/Pets/KendraPet.cs +++ b/Projectiles/Pets/KendraPet.cs @@ -38,9 +38,9 @@ namespace CalamityMod.Projectiles.Pets public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) { Player player = Main.player[Projectile.owner]; - Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2; - float playerDistance = vector48.Length(); + Vector2 projCenter = Projectile.Center; + Vector2 playerDirection = player.Center - projCenter; + float playerDistance = playerDirection.Length(); fallThrough = playerDistance > 200f; return true; } @@ -66,9 +66,9 @@ namespace CalamityMod.Projectiles.Pets if (!fly) { Projectile.rotation = 0; - Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2; - float playerDistance = vector48.Length(); + Vector2 projCenter = Projectile.Center; + Vector2 playerDirection = player.Center - projCenter; + float playerDistance = playerDirection.Length(); if (Projectile.velocity.Y == 0f && (HoleBelow() || (playerDistance > 110f && Projectile.position.X == Projectile.oldPosition.X))) { Projectile.velocity.Y = -5f; @@ -233,18 +233,16 @@ namespace CalamityMod.Projectiles.Pets } else if (fly) { - float num16 = 0.3f; + float flySpeed = 0.3f; Projectile.tileCollide = false; - Vector2 vector3 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float horiPos = Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2) - vector3.X; - float vertiPos = Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2) - vector3.Y; + Vector2 flyDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float horiPos = Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2) - flyDirection.X; + float vertiPos = Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2) - flyDirection.Y; vertiPos += (float)Main.rand.Next(-10, 21); horiPos += (float)Main.rand.Next(-10, 21); horiPos += (float)(60 * -(float)Main.player[Projectile.owner].direction); vertiPos -= 60f; float playerDistance = (float)Math.Sqrt((double)(horiPos * horiPos + vertiPos * vertiPos)); - float num21 = 18.5f; - float num27 = (float)Math.Sqrt((double)(horiPos * horiPos + vertiPos * vertiPos)); if (playerDistance > 2000f) { Projectile.position.X = Main.player[Projectile.owner].Center.X - (float)(Projectile.width / 2); @@ -253,7 +251,7 @@ namespace CalamityMod.Projectiles.Pets } if (playerDistance < 100f) { - num16 = 0.1f; + flySpeed = 0.1f; if (player.velocity.Y == 0f) { playerStill++; @@ -274,52 +272,52 @@ namespace CalamityMod.Projectiles.Pets { Projectile.velocity *= 0.9f; } - num16 = 0.01f; + flySpeed = 0.01f; } else { if (playerDistance < 100f) { - num16 = 0.1f; + flySpeed = 0.1f; } if (playerDistance > 300f) { - num16 = 1f; + flySpeed = 1f; } - playerDistance = num21 / playerDistance; + playerDistance = 18.5f / playerDistance; horiPos *= playerDistance; vertiPos *= playerDistance; } if (Projectile.velocity.X <= horiPos) { - Projectile.velocity.X = Projectile.velocity.X + num16; - if (num16 > 0.05f && Projectile.velocity.X < 0f) + Projectile.velocity.X = Projectile.velocity.X + flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.X < 0f) { - Projectile.velocity.X = Projectile.velocity.X + num16; + Projectile.velocity.X = Projectile.velocity.X + flySpeed; } } if (Projectile.velocity.X > horiPos) { - Projectile.velocity.X = Projectile.velocity.X - num16; - if (num16 > 0.05f && Projectile.velocity.X > 0f) + Projectile.velocity.X = Projectile.velocity.X - flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.X > 0f) { - Projectile.velocity.X = Projectile.velocity.X - num16; + Projectile.velocity.X = Projectile.velocity.X - flySpeed; } } if (Projectile.velocity.Y <= vertiPos) { - Projectile.velocity.Y = Projectile.velocity.Y + num16; - if (num16 > 0.05f && Projectile.velocity.Y < 0f) + Projectile.velocity.Y = Projectile.velocity.Y + flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.Y < 0f) { - Projectile.velocity.Y = Projectile.velocity.Y + num16 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y + flySpeed * 2f; } } if (Projectile.velocity.Y > vertiPos) { - Projectile.velocity.Y = Projectile.velocity.Y - num16; - if (num16 > 0.05f && Projectile.velocity.Y > 0f) + Projectile.velocity.Y = Projectile.velocity.Y - flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.Y > 0f) { - Projectile.velocity.Y = Projectile.velocity.Y - num16 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y - flySpeed * 2f; } } Projectile.rotation = Projectile.velocity.X * 0.015f; @@ -352,9 +350,9 @@ namespace CalamityMod.Projectiles.Pets { SpriteEffects spriteEffects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, spriteEffects, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, spriteEffects, 0); return false; } diff --git a/Projectiles/Pets/MiniHiveMind.cs b/Projectiles/Pets/MiniHiveMind.cs index 4bbd6b6d68..e039784ddd 100644 --- a/Projectiles/Pets/MiniHiveMind.cs +++ b/Projectiles/Pets/MiniHiveMind.cs @@ -1,10 +1,12 @@ using CalamityMod.Buffs.Pets; using CalamityMod.CalPlayer; +using CalamityMod.NPCs.HiveMind; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; + namespace CalamityMod.Projectiles.Pets { public class MiniHiveMind : ModProjectile, ILocalizedModType @@ -76,7 +78,7 @@ namespace CalamityMod.Projectiles.Pets playerVec.Normalize(); Projectile.velocity = playerVec * 8f; charging = 50; - SoundEngine.PlaySound(SoundID.ForceRoar with { Volume = SoundID.ForceRoar.Volume * 0.5f }, Projectile.Center); + SoundEngine.PlaySound(HiveMind.FastRoarSound with { Volume = SoundID.ForceRoar.Volume * 0.5f }, Projectile.Center); Projectile.netUpdate = true; } } diff --git a/Projectiles/Pets/RadiatorPet.cs b/Projectiles/Pets/RadiatorPet.cs index 575f2bfbe4..701e26229d 100644 --- a/Projectiles/Pets/RadiatorPet.cs +++ b/Projectiles/Pets/RadiatorPet.cs @@ -31,9 +31,9 @@ namespace CalamityMod.Projectiles.Pets public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) { Player player = Main.player[Projectile.owner]; - Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2; - float playerDistance = vector48.Length(); + Vector2 projCenter = Projectile.Center; + Vector2 playerDirection = player.Center - projCenter; + float playerDistance = playerDirection.Length(); fallThrough = playerDistance > 200f; return true; } @@ -82,9 +82,9 @@ namespace CalamityMod.Projectiles.Pets if (!fly) { Projectile.rotation = 0; - Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2; - float playerDistance = vector48.Length(); + Vector2 projCenter = Projectile.Center; + Vector2 playerDirection = player.Center - projCenter; + float playerDistance = playerDirection.Length(); if (Projectile.velocity.Y == 0 && (HoleBelow() || (playerDistance > 110f && Projectile.position.X == Projectile.oldPosition.X))) { Projectile.velocity.Y = -5f; diff --git a/Projectiles/Pets/Sparks.cs b/Projectiles/Pets/Sparks.cs index 4b7711a883..0de8b7de5c 100644 --- a/Projectiles/Pets/Sparks.cs +++ b/Projectiles/Pets/Sparks.cs @@ -42,8 +42,6 @@ namespace CalamityMod.Projectiles.Pets Item item = Main.item[itemIndex]; if (item.active && item.noGrabDelay == 0 && item.playerIndexTheItemIsReservedFor == Projectile.owner && ItemLoader.CanPickup(item, player)) { - int num = defaultItemGrabRange;//Player.defaultItemGrabRange; - if (new Rectangle((int)Projectile.position.X, (int)Projectile.position.Y, Projectile.width, Projectile.height).Intersects(new Rectangle((int)item.position.X, (int)item.position.Y, item.width, item.height))) { if (Projectile.owner == Main.myPlayer && (player.ActiveItem().type != ItemID.None || player.itemAnimation <= 0)) @@ -63,16 +61,16 @@ namespace CalamityMod.Projectiles.Pets { continue; //Main.PlaySound(7, (int)player.position.X, (int)player.position.Y, 1); - //int num2 = item.buffType; + //int nebulaBuff = item.buffType; //Main.item[itemIndex] = new Item(); //if (Main.netMode == 1) //{ - // NetMessage.SendData(102, -1, -1, "", projectile.owner, (float)num2, player.Center.X, player.Center.Y, 0, 0, 0); + // NetMessage.SendData(102, -1, -1, "", projectile.owner, (float)nebulaBuff, player.Center.X, player.Center.Y, 0, 0, 0); // NetMessage.SendData(21, -1, -1, "", itemIndex, 0f, 0f, 0f, 0, 0, 0); //} //else //{ - // player.NebulaLevelup(num2); + // player.NebulaLevelup(nebulaBuff); //} } if (item.type == ItemID.Heart || item.type == ItemID.CandyApple || item.type == ItemID.CandyCane) @@ -149,8 +147,8 @@ namespace CalamityMod.Projectiles.Pets for (int index = 0; index < Main.projectile.Length; index++) { Projectile proj = Main.projectile[index]; - bool flag23 = Main.projPet[proj.type]; - if (index != Projectile.whoAmI && proj.active && proj.owner == Projectile.owner && flag23 && Math.Abs(Projectile.position.X - proj.position.X) + Math.Abs(Projectile.position.Y - proj.position.Y) < (float)Projectile.width) + bool isPet = Main.projPet[proj.type]; + if (index != Projectile.whoAmI && proj.active && proj.owner == Projectile.owner && isPet && Math.Abs(Projectile.position.X - proj.position.X) + Math.Abs(Projectile.position.Y - proj.position.Y) < (float)Projectile.width) { if (Projectile.position.X < proj.position.X) { @@ -170,17 +168,16 @@ namespace CalamityMod.Projectiles.Pets } } } - float num16 = 0.5f; + float flySpeed = 0.5f; Projectile.tileCollide = false; - Vector2 vector3 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float xDist = player.position.X + (float)(player.width / 2) - vector3.X; - float yDist = player.position.Y + (float)(player.height / 2) - vector3.Y; + Vector2 flyDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float xDist = player.position.X + (float)(player.width / 2) - flyDirection.X; + float yDist = player.position.Y + (float)(player.height / 2) - flyDirection.Y; yDist += (float)Main.rand.Next(-10, 21); xDist += (float)Main.rand.Next(-10, 21); xDist += (float)(60 * (float)player.direction); yDist -= 60f; float playerDist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); - float num21 = 18f; if (playerDist < 160f) Projectile.ai[0] = 0f; if (playerDist < 100f && player.velocity.Y == 0f && @@ -204,52 +201,52 @@ namespace CalamityMod.Projectiles.Pets { Projectile.velocity *= 0.99f; } - num16 = 0.01f; + flySpeed = 0.01f; } else { if (playerDist < 100f) { - num16 = 0.1f; + flySpeed = 0.1f; } if (playerDist > 300f) { - num16 = 1f; + flySpeed = 1f; } - playerDist = num21 / playerDist; + playerDist = 18f / playerDist; xDist *= playerDist; yDist *= playerDist; } if (Projectile.velocity.X < xDist) { - Projectile.velocity.X = Projectile.velocity.X + num16; - if (num16 > 0.05f && Projectile.velocity.X < 0f) + Projectile.velocity.X = Projectile.velocity.X + flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.X < 0f) { - Projectile.velocity.X = Projectile.velocity.X + num16; + Projectile.velocity.X = Projectile.velocity.X + flySpeed; } } if (Projectile.velocity.X > xDist) { - Projectile.velocity.X = Projectile.velocity.X - num16; - if (num16 > 0.05f && Projectile.velocity.X > 0f) + Projectile.velocity.X = Projectile.velocity.X - flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.X > 0f) { - Projectile.velocity.X = Projectile.velocity.X - num16; + Projectile.velocity.X = Projectile.velocity.X - flySpeed; } } if (Projectile.velocity.Y < yDist) { - Projectile.velocity.Y = Projectile.velocity.Y + num16; - if (num16 > 0.05f && Projectile.velocity.Y < 0f) + Projectile.velocity.Y = Projectile.velocity.Y + flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.Y < 0f) { - Projectile.velocity.Y = Projectile.velocity.Y + num16 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y + flySpeed * 2f; } } if (Projectile.velocity.Y > yDist) { - Projectile.velocity.Y = Projectile.velocity.Y - num16; - if (num16 > 0.05f && Projectile.velocity.Y > 0f) + Projectile.velocity.Y = Projectile.velocity.Y - flySpeed; + if (flySpeed > 0.05f && Projectile.velocity.Y > 0f) { - Projectile.velocity.Y = Projectile.velocity.Y - num16 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y - flySpeed * 2f; } } } @@ -334,7 +331,7 @@ namespace CalamityMod.Projectiles.Pets Pickup(); //pickup items - bool flag24 = false; + bool decelerate = false; if (Projectile.ai[0] == 2f) { Projectile.ai[1] += 1f; @@ -347,10 +344,10 @@ namespace CalamityMod.Projectiles.Pets } else { - flag24 = true; + decelerate = true; } } - if (flag24) + if (decelerate) { return; } @@ -406,32 +403,31 @@ namespace CalamityMod.Projectiles.Pets } } - float num647 = 100f; + float separationAnxietyDist = 100f; if (foundFood) { - num647 = 200f; + separationAnxietyDist = 200f; } - if (Vector2.Distance(player.Center, Projectile.Center) > num647) + if (Vector2.Distance(player.Center, Projectile.Center) > separationAnxietyDist) { Projectile.ai[0] = 1f; Projectile.netUpdate = true; } if (foundFood && Projectile.ai[0] == 0f) { - Vector2 vector47 = targetLocation - Projectile.Center; - float num648 = vector47.Length(); - vector47.Normalize(); - if (num648 > 200f) + Vector2 targetDirection = targetLocation - Projectile.Center; + float targetDist = targetDirection.Length(); + targetDirection.Normalize(); + if (targetDist > 200f) { float scaleFactor2 = 18f; - vector47 *= scaleFactor2; - Projectile.velocity = (Projectile.velocity * 40f + vector47) / 41f; + targetDirection *= scaleFactor2; + Projectile.velocity = (Projectile.velocity * 40f + targetDirection) / 41f; } else { - float num649 = 9f; - vector47 *= -num649; - Projectile.velocity = (Projectile.velocity * 40f + vector47) / 41f; + targetDirection *= -9f; + Projectile.velocity = (Projectile.velocity * 40f + targetDirection) / 41f; } } else @@ -455,9 +451,9 @@ namespace CalamityMod.Projectiles.Pets if (Main.myPlayer == Projectile.owner) { Projectile.ai[0] = 2f; - Vector2 value20 = targetLocation - Projectile.Center; - value20.Normalize(); - Projectile.velocity = value20 * 12f; + Vector2 targetDest = targetLocation - Projectile.Center; + targetDest.Normalize(); + Projectile.velocity = targetDest * 12f; Projectile.netUpdate = true; } } diff --git a/Projectiles/Ranged/AMRShot.cs b/Projectiles/Ranged/AMRShot.cs index d5b358291a..335f608c0c 100644 --- a/Projectiles/Ranged/AMRShot.cs +++ b/Projectiles/Ranged/AMRShot.cs @@ -82,7 +82,7 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.owner == Main.myPlayer) { fromRight = x > 3; - CalamityUtils.ProjectileBarrage(source, Projectile.Center, targetPos, fromRight, 500f, 500f, 0f, 500f, 10f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.14), Projectile.knockBack * 0.1f, Projectile.owner); + CalamityUtils.ProjectileBarrage(source, Projectile.Center, targetPos, fromRight, 500f, 500f, 0f, 500f, 10f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.15), Projectile.knockBack * 0.1f, Projectile.owner); } } } @@ -95,7 +95,7 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.owner == Main.myPlayer) { fromRight = x > 0; - CalamityUtils.ProjectileBarrage(source, Projectile.Center, targetPos, fromRight, 500f, 500f, 0f, 500f, 10f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.14), Projectile.knockBack * 0.1f, Projectile.owner); + CalamityUtils.ProjectileBarrage(source, Projectile.Center, targetPos, fromRight, 500f, 500f, 0f, 500f, 10f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.15), Projectile.knockBack * 0.1f, Projectile.owner); } } } diff --git a/Projectiles/Ranged/AquaBlast.cs b/Projectiles/Ranged/AquaBlast.cs index a08e4093ee..3121ce368d 100644 --- a/Projectiles/Ranged/AquaBlast.cs +++ b/Projectiles/Ranged/AquaBlast.cs @@ -44,12 +44,12 @@ namespace CalamityMod.Projectiles.Ranged Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.75f / 255f); - for (int num457 = 0; num457 < 2; num457++) + for (int i = 0; i < 2; i++) { Vector2 dspeed = -Projectile.velocity * Main.rand.NextFloat(0.5f * 0.8f); - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 1f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity = dspeed; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity = dspeed; } } diff --git a/Projectiles/Ranged/AquaBlastToxic.cs b/Projectiles/Ranged/AquaBlastToxic.cs index c328cf36a3..02c421e595 100644 --- a/Projectiles/Ranged/AquaBlastToxic.cs +++ b/Projectiles/Ranged/AquaBlastToxic.cs @@ -45,12 +45,12 @@ namespace CalamityMod.Projectiles.Ranged Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) + MathHelper.ToRadians(90) * Projectile.direction; Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.35f / 255f, (255 - Projectile.alpha) * 0.4f / 255f); - for (int num457 = 0; num457 < 2; num457++) + for (int i = 0; i < 2; i++) { Vector2 dspeed = -Projectile.velocity * Main.rand.NextFloat(0.5f * 0.8f); - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 1f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity = dspeed; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity = dspeed; } } diff --git a/Projectiles/Ranged/ArcNovaDiffuserHoldout.cs b/Projectiles/Ranged/ArcNovaDiffuserHoldout.cs index 31d8f315ea..61d070848e 100644 --- a/Projectiles/Ranged/ArcNovaDiffuserHoldout.cs +++ b/Projectiles/Ranged/ArcNovaDiffuserHoldout.cs @@ -19,6 +19,7 @@ namespace CalamityMod.Projectiles.Ranged public static int FramesPerLoad = 13; public static int MaxLoadableShots = 15; public static float BulletSpeed = 12f; + public int Time = 0; private Player Owner => Main.player[Projectile.owner]; public SlotId NovaChargeSlot; @@ -43,6 +44,12 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { + Time++; + if (Time == 1) + Projectile.alpha = 255; + else + Projectile.alpha = 0; + if (Owner.dead) // destroy the holdout if the player dies { Projectile.Kill(); @@ -74,9 +81,9 @@ namespace CalamityMod.Projectiles.Ranged float charge2KB = Projectile.knockBack * 3f; Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, shootVelocity, ModContent.ProjectileType(), charge2Damage, charge2KB, Projectile.owner); Owner.Calamity().GeneralScreenShakePower = 6.5f; - for (int i = 0; i <= 20; i++) + for (int i = 0; i <= 25; i++) { - Dust dust = Dust.NewDustPerfect(tipPosition, 107, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.2f, 1.2f), 0, default, Main.rand.NextFloat(1.5f, 2.3f)); + Dust dust = Dust.NewDustPerfect(tipPosition - Projectile.velocity * 15, 107, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.2f, 1.2f), 0, default, Main.rand.NextFloat(1f, 2.3f)); dust.noGravity = true; } @@ -106,9 +113,9 @@ namespace CalamityMod.Projectiles.Ranged Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed; Vector2 fireVec = shootVelocity.RotatedByRandom(MathHelper.ToRadians(2f)); Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, fireVec, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - for (int i = 0; i <= 3; i++) + for (int i = 0; i <= 4; i++) { - Dust dust = Dust.NewDustPerfect(tipPosition, 107, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.9f, 1.2f), 0, default, Main.rand.NextFloat(1.3f, 1.7f)); + Dust dust = Dust.NewDustPerfect(tipPosition - Projectile.velocity * 15, 107, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.9f, 1.2f), 0, default, Main.rand.NextFloat(0.8f, 1.8f)); dust.noGravity = true; } @@ -214,11 +221,17 @@ namespace CalamityMod.Projectiles.Ranged { if (Main.myPlayer == Projectile.owner) { - float interpolant = Utils.GetLerpValue(5f, 25f, Projectile.Distance(Main.MouseWorld), true); + 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); + if (Projectile.velocity != oldVelocity) + { + Projectile.netSpam = 0; + Projectile.netUpdate = true; + } } - Projectile.Center = armPosition + Projectile.velocity * MathHelper.Clamp(30f - ShootRecoilTimer, 0f, 30f) + new Vector2 (0, 7); + Vector2 shootOffset = Projectile.velocity * MathHelper.Clamp(30f - ShootRecoilTimer, 0f, 30f) + new Vector2(0, 7); + Projectile.Center = armPosition + shootOffset; Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); Projectile.spriteDirection = Projectile.direction; diff --git a/Projectiles/Ranged/ArcticArrowProj.cs b/Projectiles/Ranged/ArcticArrowProj.cs index dae3dd6cf6..4b97875411 100644 --- a/Projectiles/Ranged/ArcticArrowProj.cs +++ b/Projectiles/Ranged/ArcticArrowProj.cs @@ -51,14 +51,14 @@ namespace CalamityMod.Projectiles.Ranged Projectile.height = 20; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 67, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } } diff --git a/Projectiles/Ranged/AstralCannonProjectile.cs b/Projectiles/Ranged/AstralCannonProjectile.cs index 9cf4d1e46c..78acadcba9 100644 --- a/Projectiles/Ranged/AstralCannonProjectile.cs +++ b/Projectiles/Ranged/AstralCannonProjectile.cs @@ -92,18 +92,18 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localNPCHitCooldown = 10; Projectile.Damage(); SoundEngine.PlaySound(SoundID.Zombie103, Projectile.Center); - for (int num193 = 0; num193 < 2; num193++) + for (int i = 0; i < 2; i++) { Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 50, default, 1f); } - for (int num194 = 0; num194 < 20; num194++) + for (int j = 0; j < 20; j++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 0, default, 1.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 50, default, 1f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int orangeDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 0, default, 1.5f); + Main.dust[orangeDust].noGravity = true; + Main.dust[orangeDust].velocity *= 3f; + orangeDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 50, default, 1f); + Main.dust[orangeDust].velocity *= 2f; + Main.dust[orangeDust].noGravity = true; } } } diff --git a/Projectiles/Ranged/AstrealFlame.cs b/Projectiles/Ranged/AstrealFlame.cs index 415b2bef37..e51c266659 100644 --- a/Projectiles/Ranged/AstrealFlame.cs +++ b/Projectiles/Ranged/AstrealFlame.cs @@ -53,23 +53,23 @@ namespace CalamityMod.Projectiles.Ranged Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); SoundEngine.PlaySound(SoundID.Item74, Projectile.Center); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 15; num623++) + for (int j = 0; j < 15; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 3f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); + Main.dust[dust2].velocity *= 2f; } } } diff --git a/Projectiles/Ranged/AuricBullet.cs b/Projectiles/Ranged/AuricBullet.cs new file mode 100644 index 0000000000..d7244c4a6c --- /dev/null +++ b/Projectiles/Ranged/AuricBullet.cs @@ -0,0 +1,105 @@ +using CalamityMod.Particles; +using CalamityMod.Items.Weapons.Ranged; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.WorldBuilding; + +namespace CalamityMod.Projectiles.Ranged +{ + public class AuricBullet : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public int Heat = 2; + public static readonly SoundStyle HitSound = new("CalamityMod/Sounds/Item/AuricBulletHit") { Volume = 0.7f }; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 9; + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + } + + public override void SetDefaults() + { + Projectile.width = 5; + Projectile.height = 5; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = 1; + Projectile.timeLeft = 600; + Projectile.extraUpdates = 15; + Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; + Projectile.tileCollide = false; + Projectile.ArmorPenetration = 50; + Projectile.alpha = 255; + } + + public override bool PreDraw(ref Color lightColor) + { + CalamityUtils.DrawAfterimagesFromEdge(Projectile, 0, lightColor); + return false; + } + + public override void AI() + { + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + + Vector3 DustLight = new Vector3(0.255f, 0.230f, 0.000f); + Lighting.AddLight(Projectile.Center, DustLight * 2); + + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(90f); + Projectile.spriteDirection = Projectile.direction; + if (Projectile.timeLeft < 595) + CalamityUtils.HomeInOnNPC(Projectile, true, 250f, 7.5f, 10f); + if (targetDist < 1400f && Projectile.timeLeft < 599 && Projectile.timeLeft % 2 == 0) + { + if (Projectile.timeLeft < 585) + Heat = 5; + if (Projectile.timeLeft < 580) + Heat = 10; + if (Projectile.timeLeft < 575) + Heat = 20; + int positionVariation = Projectile.timeLeft < 590 ? 17 : 7; + LineParticle spark = new LineParticle(Projectile.Center + Main.rand.NextVector2Circular(positionVariation, positionVariation), -Projectile.velocity * Main.rand.NextFloat(0.3f, 1.1f), false, 4, 1.45f, Main.rand.NextBool(Heat) ? Projectile.timeLeft < 570 ? Color.Goldenrod : Color.OrangeRed : Projectile.timeLeft > 590 ? Color.Red : Color.DarkGoldenrod); + GeneralParticleHandler.SpawnParticle(spark); + } + if (Main.rand.NextBool(7)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(10, 10), Main.rand.NextBool() ? 311 : 292, -Projectile.velocity.RotatedByRandom(0.4f) * Main.rand.NextFloat(0.1f, 0.6f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.7f, 1.1f); + } + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(BuffID.Electrified, 300); + SoundEngine.PlaySound(HitSound with { PitchVariance = 0.15f}, Projectile.Center); + GenericSparkle sparker = new GenericSparkle(Projectile.Center, Vector2.Zero, Color.Gold, Color.Cyan, Main.rand.NextFloat(1.8f, 2.5f), 5, Main.rand.NextFloat(-0.01f, 0.01f), 1.68f); + GeneralParticleHandler.SpawnParticle(sparker); + + Vector2 bloodSpawnPosition = target.Center + Main.rand.NextVector2Circular(target.width, target.height) * 0.04f; + Vector2 splatterDirection = (Projectile.Center - bloodSpawnPosition).SafeNormalize(Vector2.UnitY); + + int sparkLifetime = Main.rand.Next(9, 12); + float sparkScale = Main.rand.NextFloat(0.9f, 1.3f) * 0.85f; + Color sparkColor = Color.Lerp(Color.DarkGoldenrod, Color.Gold, Main.rand.NextFloat(0.7f)); + Vector2 sparkVelocity = splatterDirection.RotatedByRandom(0.6f) * Main.rand.NextFloat(22f, 45f); + sparkVelocity.Y -= 6f; + if (Main.rand.NextBool()) + { + SparkParticle spark = new SparkParticle(target.Center, sparkVelocity, false, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); + } + + for (int i = 0; i <= 6; i++) + { + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 226, new Vector2(2, 2).RotatedByRandom(100f) * Main.rand.NextFloat(0.1f, 2.9f)); + dust2.noGravity = false; + dust2.scale = Main.rand.NextFloat(0.3f, 0.9f); + } + } + } +} diff --git a/Projectiles/Ranged/AuricBullet.png b/Projectiles/Ranged/AuricBullet.png new file mode 100644 index 0000000000..76bc973262 Binary files /dev/null and b/Projectiles/Ranged/AuricBullet.png differ diff --git a/Projectiles/Ranged/AuroraFire.cs b/Projectiles/Ranged/AuroraFire.cs index 5c5018021a..43f815e0af 100644 --- a/Projectiles/Ranged/AuroraFire.cs +++ b/Projectiles/Ranged/AuroraFire.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.ModLoader; @@ -10,77 +11,110 @@ namespace CalamityMod.Projectiles.Ranged public class AuroraFire : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override string Texture => "CalamityMod/Projectiles/Magic/RancorFog"; - private const int framesBeforeTurning = 70; - private bool initialized = false; - private int radianAmt = 0; + public static int Lifetime => 450; + public static int Fadetime => 420; + public ref float Time => ref Projectile.ai[0]; + public ref float LightPower => ref Projectile.ai[1]; + + // The Fog is Coming + public Color OrangeFogColor = new Color(255, 160, 100); + public float OrangeFogRot = 0f; + public float OrangeFogScale = 1f; + public Color BlueFogColor = new Color(150, 120, 255); + public float BlueFogRot = 0f; + public float BlueFogScale = 1f; public override void SetDefaults() { - Projectile.width = 12; - Projectile.height = 12; + Projectile.width = Projectile.height = 64; Projectile.friendly = true; Projectile.ignoreWater = true; + Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = -1; - Projectile.extraUpdates = 3; - Projectile.tileCollide = false; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 20; + Projectile.MaxUpdates = 3; + Projectile.timeLeft = Lifetime; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 6; } public override void AI() { - if (Projectile.ai[0] % 2 == 0) - Projectile.ai[0]++; - - if (!initialized) + // Initialize random fog scale/rotation/color + if (Time == 0f) { - int pointCount = (int)Projectile.ai[0]; - radianAmt = 180 + (int)(360 / (pointCount * 2)); - Projectile.timeLeft = framesBeforeTurning * pointCount - 1; - initialized = true; + OrangeFogColor.B = (byte)Main.rand.Next(100, 180 + 1); + OrangeFogScale = Main.rand.NextFloat(0.8f, 1f); + OrangeFogRot = Main.rand.NextFloat(MathHelper.TwoPi); + BlueFogColor.G = (byte)Main.rand.Next(120, 250 + 1); + BlueFogScale = OrangeFogScale * Main.rand.NextFloat(0.9f, 1.1f); + BlueFogRot = OrangeFogRot + MathHelper.ToRadians(Main.rand.NextFloat(30f, 330f)); + } + Time++; + + // Turns around every once in a while + int TurnRate = Lifetime / 5; + if (Time % TurnRate == TurnRate - 1) + Projectile.velocity = Projectile.velocity.RotatedBy(MathHelper.ToRadians(-216f)); + Projectile.rotation = Projectile.velocity.ToRotation(); + + // Determines particle size as well as hitbox + if (Time >= Fadetime) + { + Projectile.scale = Utils.GetLerpValue(MathHelper.Lerp(Fadetime, Lifetime, 0.5f), Fadetime, Time, true); + if (Projectile.scale <= 0.01f) + Projectile.Kill(); + } + else if (Time >= 6f) + Projectile.scale = Utils.GetLerpValue(6f, 36f, Time, true); + else + return; // Helps position it at the tip + + // Draw smokes over the whole thing + float smokeRot = MathHelper.ToRadians(3f); // *Rate of rotation per frame, not a constant rotation + Color smokeColor = Color.Lerp(OrangeFogColor, BlueFogColor, 0.6f + 0.4f * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f)); + Particle smoke = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, smokeColor, 8, Projectile.scale * Main.rand.NextFloat(0.6f, 1.2f), 0.8f, smokeRot, required: true); + GeneralParticleHandler.SpawnParticle(smoke); + + // Overlay the glow on top, which is on the brighter side + if (Main.rand.NextBool(8)) + { + Color glowColor = Color.Lerp(smokeColor, Color.White, 0.25f); + Particle smokeGlow = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, glowColor, 6, Projectile.scale * Main.rand.NextFloat(0.4f, 0.7f), 0.6f, smokeRot, true, 0.005f, true); + GeneralParticleHandler.SpawnParticle(smokeGlow); } - //Velocity movement - Projectile.localAI[1]++; - if (Projectile.localAI[1] % framesBeforeTurning == 0) - { - Projectile.velocity = Projectile.velocity.RotatedBy(MathHelper.ToRadians(radianAmt)); - } - - //Dust behavior - Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] > 4f) - { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.DustType(), - ModContent.DustType() - }); - for (int i = 0; i < 5; i++) - { - int astral = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 0.8f); - Dust dust = Main.dust[astral]; - dust.noGravity = true; - dust.velocity *= 0f; - dust.scale *= Main.rand.NextFloat(); - } - } - - //rotation code for when sproot - Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) + 1.57f; + // Lighting and fog + Lighting.AddLight(Projectile.Center, smokeColor.ToVector3() * Projectile.scale); + OrangeFogRot += MathHelper.ToRadians(1f); + BlueFogRot -= MathHelper.ToRadians(1f); + Projectile.Opacity = Utils.GetLerpValue(0f, 15f, Time, true) * Utils.GetLerpValue(450f, 360f, Time, true); + + // Calculate light power. This checks below the position of the fog to check if this fog is underground. + // Without this, it may render over the fullblack that the game renders for obscured tiles. + float lightPowerBelow = Lighting.GetColor((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16 + 6).ToVector3().Length() / (float)Math.Sqrt(3D); + LightPower = MathHelper.Lerp(LightPower, lightPowerBelow, 0.15f); } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 240); - } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 240); - public override void OnHitPlayer(Player target, Player.HurtInfo info) + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 240); + + // Circular hitbox adjusted for the size of the smoke particles (rough estimate minimally accounting for fog) + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.width * Projectile.scale * 0.5f, targetHitbox); + + public override bool PreDraw(ref Color lightColor) { - target.AddBuff(ModContent.BuffType(), 240); + Main.spriteBatch.SetBlendState(BlendState.Additive); + Texture2D fog = ModContent.Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float opacity = Utils.GetLerpValue(0f, 0.08f, LightPower, true) * Projectile.Opacity * 0.3f; + Main.EntitySpriteDraw(fog, drawPosition, null, OrangeFogColor * opacity, Projectile.rotation + OrangeFogRot, fog.Size() * 0.5f, Projectile.scale * OrangeFogScale, SpriteEffects.None); + Main.EntitySpriteDraw(fog, drawPosition, null, BlueFogColor * opacity, Projectile.rotation + BlueFogRot, fog.Size() * 0.5f, Projectile.scale * BlueFogScale, SpriteEffects.None); + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + return false; } } } diff --git a/Projectiles/Ranged/BarinadeArrow.cs b/Projectiles/Ranged/BarinadeArrow.cs new file mode 100644 index 0000000000..6a02e9a23d --- /dev/null +++ b/Projectiles/Ranged/BarinadeArrow.cs @@ -0,0 +1,73 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; +using Terraria.Audio; +using CalamityMod.Particles; + +namespace CalamityMod.Projectiles.Ranged +{ + public class BarinadeArrow : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 12; + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + } + public override void SetDefaults() + { + Projectile.width = 20; + Projectile.height = 20; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.arrow = true; + Projectile.penetrate = 1; + Projectile.timeLeft = 300; + Projectile.extraUpdates = 2; + Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; + } + public override void AI() + { + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + + Vector3 DustLight = new Vector3(0.171f, 0.124f, 0.086f); + Lighting.AddLight(Projectile.Center, DustLight * 3); + + Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) + 1.57f; + + if (Projectile.timeLeft == 300) + { + for (int i = 0; i <= 5; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 216 : 207, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.1f, 0.6f), 0, default, Main.rand.NextFloat(1.2f, 1.6f)); + dust.noGravity = true; + } + } + + if (Projectile.timeLeft % 2 == 0 && Projectile.timeLeft < 295 && targetDist < 1400f) + { + SparkParticle spark = new SparkParticle(Projectile.Center - Projectile.velocity * 2f, -Projectile.velocity * 0.1f, false, 9, 1.5f, Color.White * 0.2f); + GeneralParticleHandler.SpawnParticle(spark); + } + + } + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(SoundID.Dig, Projectile.Center); + + for (int i = 0; i <= 5; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 32 : 216, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(8f)) * Main.rand.NextFloat(0.1f, 0.6f), 0, default, Main.rand.NextFloat(0.9f, 1.2f)); + dust.noGravity = false; + } + } + public override bool PreDraw(ref Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor * 2, 1); + return true; + } + } +} diff --git a/Projectiles/Ranged/BarinadeArrow.png b/Projectiles/Ranged/BarinadeArrow.png new file mode 100644 index 0000000000..d4720a0d0e Binary files /dev/null and b/Projectiles/Ranged/BarinadeArrow.png differ diff --git a/Projectiles/Ranged/BeeRPG.cs b/Projectiles/Ranged/BeeRPG.cs index e9bdde16b5..19fa84d005 100644 --- a/Projectiles/Ranged/BeeRPG.cs +++ b/Projectiles/Ranged/BeeRPG.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Projectiles.Ranged public class BeeRPG : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public static Item FalseLauncher = null; + private ref float RocketType => ref Projectile.ai[0]; public override void SetDefaults() { @@ -24,33 +24,26 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; } - private static void DefineFalseLauncher() - { - int rocketID = ItemID.RocketLauncher; - FalseLauncher = new Item(); - FalseLauncher.SetDefaults(rocketID, true); - } - public override void AI() { if (Math.Abs(Projectile.velocity.X) >= 8f || Math.Abs(Projectile.velocity.Y) >= 8f) { - for (int num246 = 0; num246 < 2; num246++) + for (int i = 0; i < 2; i++) { - float num247 = 0f; - float num248 = 0f; - if (num246 == 1) + float halfX = 0f; + float halfY = 0f; + if (i == 1) { - num247 = Projectile.velocity.X * 0.5f; - num248 = Projectile.velocity.Y * 0.5f; + halfX = Projectile.velocity.X * 0.5f; + halfY = Projectile.velocity.Y * 0.5f; } - int num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 6, 0f, 0f, 100, default, 1f); - Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 31, 0f, 0f, 100, default, 0.5f); - Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num249].velocity *= 0.05f; + int dusty = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 6, 0f, 0f, 100, default, 1f); + Main.dust[dusty].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dusty].velocity *= 0.2f; + Main.dust[dusty].noGravity = true; + dusty = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 31, 0f, 0f, 100, default, 0.5f); + Main.dust[dusty].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dusty].velocity *= 0.05f; } } if (Math.Abs(Projectile.velocity.X) < 15f && Math.Abs(Projectile.velocity.Y) < 15f) @@ -59,33 +52,24 @@ namespace CalamityMod.Projectiles.Ranged } else if (Main.rand.NextBool()) { - int num252 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 1f); - Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2)).RotatedBy((double)Projectile.rotation, default) * 1.1f; + int dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 1f); + Main.dust[dust2].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dust2].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dust2].noGravity = true; + Main.dust[dust2].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2)).RotatedBy((double)Projectile.rotation, default) * 1.1f; Main.rand.Next(2); - num252 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 1f); - Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2 - 6)).RotatedBy((double)Projectile.rotation, default) * 1.1f; + dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 1f); + Main.dust[dust2].scale = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dust2].noGravity = true; + Main.dust[dust2].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2 - 6)).RotatedBy((double)Projectile.rotation, default) * 1.1f; } Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(90); - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - Player player = Main.player[Projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); - if (projID == ProjectileID.DryRocket || projID == ProjectileID.WetRocket || projID == ProjectileID.LavaRocket || projID == ProjectileID.HoneyRocket) - { - if (Projectile.wet) - Projectile.timeLeft = 1; - } + if (RocketType == ItemID.DryRocket || RocketType == ItemID.WetRocket || RocketType == ItemID.LavaRocket || RocketType == ItemID.HoneyRocket) + { + if (Projectile.wet) + Projectile.timeLeft = 1; + } } public override bool OnTileCollide(Vector2 oldVelocity) @@ -97,29 +81,27 @@ namespace CalamityMod.Projectiles.Ranged public override void OnKill(int timeLeft) { + var info = new CalamityUtils.RocketBehaviorInfo((int)RocketType); + int blastRadius = Projectile.RocketBehavior(info); Projectile.ExpandHitboxBy(32); - Projectile.maxPenetrate = -1; - Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; Projectile.Damage(); + if (Projectile.owner == Main.myPlayer) { - int num516 = 12; - for (int num517 = 0; num517 < num516; num517++) + for (int j = 0; j < 12; j++) { - if (num517 % 2 != 1 || Main.rand.NextBool(3)) + if (j % 2 != 1 || Main.rand.NextBool(3)) { - Vector2 value20 = Projectile.position; - Vector2 value21 = Projectile.oldVelocity; - value21.Normalize(); - value21 *= 8f; - float num518 = (float)Main.rand.Next(-35, 36) * 0.01f; - float num519 = (float)Main.rand.Next(-35, 36) * 0.01f; - value20 -= value21 * (float)num517; - num518 += Projectile.oldVelocity.X / 6f; - num519 += Projectile.oldVelocity.Y / 6f; - int bee = Projectile.NewProjectile(Projectile.GetSource_FromThis(), value20.X, value20.Y, num518, num519, Main.player[Projectile.owner].beeType(), Main.player[Projectile.owner].beeDamage(Projectile.damage / 4), Main.player[Projectile.owner].beeKB(0f), Main.myPlayer); + Vector2 projPos = Projectile.position; + Vector2 projVel = Projectile.oldVelocity; + projVel.Normalize(); + projVel *= 8f; + float beeVelX = (float)Main.rand.Next(-35, 36) * 0.01f; + float beeVelY = (float)Main.rand.Next(-35, 36) * 0.01f; + projPos -= projVel * (float)j; + beeVelX += Projectile.oldVelocity.X / 6f; + beeVelY += Projectile.oldVelocity.Y / 6f; + int bee = Projectile.NewProjectile(Projectile.GetSource_FromThis(), projPos.X, projPos.Y, beeVelX, beeVelY, Main.player[Projectile.owner].beeType(), Main.player[Projectile.owner].beeDamage(Projectile.damage / 4), Main.player[Projectile.owner].beeKB(0f), Main.myPlayer); if (bee.WithinBounds(Main.maxProjectiles)) { Main.projectile[bee].penetrate = 2; @@ -128,24 +110,28 @@ namespace CalamityMod.Projectiles.Ranged } } } + + if (Main.dedServ) + return; + SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 3f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 2f); + Main.dust[dust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) @@ -191,53 +177,6 @@ namespace CalamityMod.Projectiles.Ranged gore.velocity.Y -= 1f; } } - - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - Player player = Main.player[Projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); - int blastRadius = 0; - if (projID == ProjectileID.RocketII || projID == ProjectileID.ClusterRocketII) // Not adding the actual shrapnel tho - blastRadius = 3; - else if (projID == ProjectileID.RocketIV) - blastRadius = 6; - else if (projID == ProjectileID.MiniNukeRocketII) - blastRadius = 9; - - Projectile.ExpandHitboxBy(14); - - if (Projectile.owner == Main.myPlayer && blastRadius > 0) - { - CalamityUtils.ExplodeandDestroyTiles(Projectile, blastRadius, true, new List() { }, new List() { }); - } - if (Projectile.owner == Main.myPlayer) - { - Point center = Projectile.Center.ToTileCoordinates(); - DelegateMethods.v2_1 = center.ToVector2(); - DelegateMethods.f_1 = 3f; - if (projID == ProjectileID.DryRocket) - { - DelegateMethods.f_1 = 3.5f; - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadDry); - } - else if (projID == ProjectileID.WetRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadWater); - } - else if (projID == ProjectileID.LavaRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadLava); - } - else if (projID == ProjectileID.HoneyRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadHoney); - } - } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) diff --git a/Projectiles/Ranged/BigCoral.cs b/Projectiles/Ranged/BigCoral.cs index 0b3fa19b43..e9594f0189 100644 --- a/Projectiles/Ranged/BigCoral.cs +++ b/Projectiles/Ranged/BigCoral.cs @@ -39,11 +39,11 @@ namespace CalamityMod.Projectiles.Ranged Projectile.height = 32; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 51, Projectile.oldVelocity.X / 4, Projectile.oldVelocity.Y / 4, 0, new Color(234, 183, 100), 1.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 51, Projectile.oldVelocity.X / 4, Projectile.oldVelocity.Y / 4, 0, new Color(234, 183, 100), 1.5f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 3f; } } diff --git a/Projectiles/Ranged/BigNuke.cs b/Projectiles/Ranged/BigNuke.cs index 1be7eab5e3..fc35291fbd 100644 --- a/Projectiles/Ranged/BigNuke.cs +++ b/Projectiles/Ranged/BigNuke.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Projectiles.Ranged public class BigNuke : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public static Item FalseLauncher = null; + private ref float RocketType => ref Projectile.ai[0]; public override void SetStaticDefaults() { @@ -26,23 +26,10 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; } - private static void DefineFalseLauncher() - { - int rocketID = ItemID.RocketLauncher; - FalseLauncher = new Item(); - FalseLauncher.SetDefaults(rocketID, true); - } - public override void AI() { Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(90); - if (Projectile.ai[0] == 0f) - { - SoundEngine.PlaySound(SoundID.Item11, Projectile.Center); - Projectile.ai[0] = 1f; - } - //Animation Projectile.frameCounter++; if (Projectile.frameCounter > 7) @@ -57,40 +44,31 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.velocity.Length() >= 8f) { - for (int num246 = 0; num246 < 2; num246++) + for (int i = 0; i < 2; i++) { - float num247 = 0f; - float num248 = 0f; - if (num246 == 1) + float halfX = 0f; + float halfY = 0f; + if (i == 1) { - num247 = Projectile.velocity.X * 0.5f; - num248 = Projectile.velocity.Y * 0.5f; + halfX = Projectile.velocity.X * 0.5f; + halfY = Projectile.velocity.Y * 0.5f; } - int num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 6, 0f, 0f, 100, default, 1f); - Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 31, 0f, 0f, 100, default, 0.5f); - Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num249].velocity *= 0.05f; + int dusty = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 6, 0f, 0f, 100, default, 1f); + Main.dust[dusty].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dusty].velocity *= 0.2f; + Main.dust[dusty].noGravity = true; + dusty = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 31, 0f, 0f, 100, default, 0.5f); + Main.dust[dusty].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dusty].velocity *= 0.05f; } } CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, 12f, 20f); - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - Player player = Main.player[Projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); - if (projID == ProjectileID.DryRocket || projID == ProjectileID.WetRocket || projID == ProjectileID.LavaRocket || projID == ProjectileID.HoneyRocket) - { - if (Projectile.wet) - Projectile.timeLeft = 1; - } + if (RocketType == ItemID.DryRocket || RocketType == ItemID.WetRocket || RocketType == ItemID.LavaRocket || RocketType == ItemID.HoneyRocket) + { + if (Projectile.wet) + Projectile.timeLeft = 1; + } } public override bool OnTileCollide(Vector2 oldVelocity) @@ -109,23 +87,23 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localNPCHitCooldown = 10; Projectile.Damage(); SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - for (int num621 = 0; num621 < 90; num621++) + for (int i = 0; i < 90; i++) { - int num622 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 180; num623++) + for (int j = 0; j < 180; j++) { - int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 3f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 2f); + Main.dust[dust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) @@ -172,45 +150,42 @@ namespace CalamityMod.Projectiles.Ranged } } - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - Player player = Main.player[Projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); + // Only do rocket effects for the owner client side + if (Projectile.owner != Main.myPlayer) + return; + int blastRadius = 0; + if (RocketType == ItemID.RocketII) + blastRadius = 17; + else if (RocketType == ItemID.RocketIV) + blastRadius = 20; + else if (RocketType == ItemID.MiniNukeII) + blastRadius = 23; Projectile.ExpandHitboxBy(16); - if (Projectile.owner == Main.myPlayer && (projID == ProjectileID.RocketII || projID == ProjectileID.RocketIV || projID == ProjectileID.MiniNukeRocketII || projID == ProjectileID.ClusterRocketII)) + if (blastRadius > 0) + Projectile.ExplodeTiles(blastRadius); + + Point center = Projectile.Center.ToTileCoordinates(); + DelegateMethods.v2_1 = center.ToVector2(); + DelegateMethods.f_1 = 5f; + if (RocketType == ItemID.DryRocket) { - CalamityUtils.ExplodeandDestroyTiles(Projectile, 23, true, new List() { }, new List() { }); + DelegateMethods.f_1 = 5.5f; + Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadDry); + } + else if (RocketType == ItemID.WetRocket) + { + Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadWater); + } + else if (RocketType == ItemID.LavaRocket) + { + Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadLava); + } + else if (RocketType == ItemID.HoneyRocket) + { + Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadHoney); } - if (Projectile.owner == Main.myPlayer) - { - Point center = Projectile.Center.ToTileCoordinates(); - DelegateMethods.v2_1 = center.ToVector2(); - DelegateMethods.f_1 = 5f; - if (projID == ProjectileID.DryRocket) - { - DelegateMethods.f_1 = 5.5f; - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadDry); - } - else if (projID == ProjectileID.WetRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadWater); - } - else if (projID == ProjectileID.LavaRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadLava); - } - else if (projID == ProjectileID.HoneyRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadHoney); - } - } } } } diff --git a/Projectiles/Ranged/BlightFlames.cs b/Projectiles/Ranged/BlightFlames.cs new file mode 100644 index 0000000000..14c1a94771 --- /dev/null +++ b/Projectiles/Ranged/BlightFlames.cs @@ -0,0 +1,173 @@ +using System; +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using CalamityMod.Particles; +using Terraria.ModLoader; +using Terraria.ID; +using CalamityMod.Items.Weapons.Ranged; +using Terraria.Audio; + +namespace CalamityMod.Projectiles.Ranged +{ + public class BlightFlames : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/Ranged/BlightFlames"; + + public ref float ScaleFactor => ref Projectile.ai[0]; + public ref float LightPower => ref Projectile.ai[1]; + + public int Time = 0; + public bool postTileHit = false; + public bool postEnemyHit = false; + + public Color FogColor = new Color(30, 255, 30); + public override void SetDefaults() + { + Projectile.width = 14; + Projectile.height = 14; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = -1; + Projectile.extraUpdates = 5; + Projectile.timeLeft = 400; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 55; + } + public override void AI() + { + Time++; + Projectile.rotation += Main.rand.NextFloat(0.2f, 0.9f); + if (Time > 6 && Time < 540 && Main.rand.NextBool(2 + Time / 7)) + { + DirectionalPulseRing pulse = new DirectionalPulseRing(Projectile.Center + Main.rand.NextVector2Circular(10 + Time * 0.5f, 10 + Time * 0.5f), Vector2.Zero, Main.rand.NextBool(3) ? Color.LimeGreen : Color.Green, new Vector2(1, 1), 0, Main.rand.NextFloat(0.03f, 0.09f) + Time * 0.00055f, 0f, 25); + GeneralParticleHandler.SpawnParticle(pulse); + } + if (Time > 6 && Time < 150 && !postTileHit && !postEnemyHit && Main.rand.NextBool(3 + Time / 7)) + { + MediumMistParticle smoke = new MediumMistParticle(Projectile.Center + Main.rand.NextVector2Circular(5 + Time * 0.2f, 5 + Time * 0.2f), -Projectile.velocity * 0.05f, Main.rand.NextBool(3) ? Color.LimeGreen : Color.Lime, Color.Black, Main.rand.NextFloat(0.3f, 0.8f) + Time * 0.013f, 160); + GeneralParticleHandler.SpawnParticle(smoke); + } + if (Time == 8) + { + for (int i = 0; i <= 8; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, 91, Projectile.velocity * 0.6f); + dust.scale = Main.rand.NextFloat(1.1f, 1.9f); + dust.velocity = Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.3f, 2.1f); + dust.noGravity = true; + dust.color = Main.rand.NextBool() ? Color.Chartreuse : Color.LimeGreen; + dust.noLight = true; + dust.alpha = 90; + } + } + if (Time == 10) + { + for (int i = 0; i <= 3; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, 220, Projectile.velocity * 0.6f); + dust.scale = Main.rand.NextFloat(0.4f, 1.2f); + dust.velocity = Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.3f, 2.1f); + dust.noGravity = false; + } + } + if (Main.rand.NextBool(4) && Time > 135 && !postTileHit && !postEnemyHit) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(145, 145), 220, Vector2.Zero); + dust.scale = Main.rand.NextFloat(0.2f, 0.4f); + dust.noGravity = true; + } + if (Main.rand.NextBool(20) && (postTileHit || postEnemyHit)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(145, 145), 220, Vector2.Zero); + dust.scale = Main.rand.NextFloat(0.4f, 1.2f); + dust.noGravity = true; + } + // Add some degree of variation to the fog with rotation/color + + if (Main.rand.NextBool(3)) + FogColor.G = (byte)Main.rand.Next(160, 230 + 1); + ScaleFactor += 0.0061f; + ScaleFactor = MathHelper.Clamp(ScaleFactor, 0f, Projectile.scale); + Lighting.AddLight(Projectile.Center, new Vector3(1f, 1f, 0.25f) * ScaleFactor); + + Projectile.velocity *= 0.99f; + Projectile.Opacity = Utils.GetLerpValue(30f, 50f, Projectile.timeLeft, true) * Utils.GetLerpValue(0f, 130f, Projectile.timeLeft, true); + + // Calculate light power. This checks below the position of the fog to check if this fog is underground. + // Without this, it may render over the fullblack that the game renders for obscured tiles. + float lightPowerBelow = Lighting.GetColor((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16 + 6).ToVector3().Length() / (float)Math.Sqrt(3D); + LightPower = MathHelper.Lerp(LightPower, lightPowerBelow, 0.15f); + + if (postEnemyHit && !postTileHit) + { + CalamityUtils.HomeInOnNPC(Projectile, true, 300f, 25f, 35f); + } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (!postTileHit) + Projectile.Center = Projectile.Center + Main.rand.NextVector2Circular(20, 20); + target.AddBuff(ModContent.BuffType(), 420); + + for (int i = 0; i <= 3; i++) + { + MediumMistParticle smoke = new MediumMistParticle(Projectile.Center + Main.rand.NextVector2Circular(5 + Time * 0.2f, 5 + Time * 0.2f), new Vector2(Main.rand.NextFloat(2, 6), Main.rand.NextFloat(2, 6)).RotatedByRandom(60), Main.rand.NextBool(3) ? Color.LimeGreen : Color.Lime, Color.Black, Main.rand.NextFloat(1.2f, 2.3f), 140); + GeneralParticleHandler.SpawnParticle(smoke); + } + if (!postTileHit && !postEnemyHit) + { + SoundEngine.PlaySound(BlightSpewer.Nanomachines, Projectile.Center); + Projectile.velocity = Vector2.Zero; + Projectile.timeLeft = 300; + postEnemyHit = true; + } + + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.95f); + if (Projectile.damage < 1) + Projectile.damage = 1; + } + public override bool OnTileCollide(Vector2 oldVelocity) + { + if (!postEnemyHit) + { + Projectile.velocity = oldVelocity * 0.95f; + Projectile.position -= Projectile.velocity; + if (!postTileHit) + { + Projectile.timeLeft = 800; + postTileHit = true; + } + } + return false; + } + + // Expanding hitbox + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + int size = (int)Utils.Remap(Time, 0f, 90, 10f, 95f); + hitbox.Inflate(size, size); + } + public override bool PreDraw(ref Color lightColor) + { + Main.spriteBatch.SetBlendState(BlendState.Additive); + + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float opacity = Utils.GetLerpValue(0f, 0.08f, LightPower, true) * Projectile.Opacity * 0.65f; + Color drawColor = FogColor * opacity; + Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, Projectile.rotation, texture.Size() * 0.5f, ScaleFactor, SpriteEffects.None); + + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + return false; + } + } +} diff --git a/Projectiles/Ranged/BlightFlames.png b/Projectiles/Ranged/BlightFlames.png new file mode 100644 index 0000000000..5bdf23b09a Binary files /dev/null and b/Projectiles/Ranged/BlightFlames.png differ diff --git a/Projectiles/Ranged/BlissfulBombardierDustProjectile.cs b/Projectiles/Ranged/BlissfulBombardierDustProjectile.cs index 4c9a819ded..bb7d5149be 100644 --- a/Projectiles/Ranged/BlissfulBombardierDustProjectile.cs +++ b/Projectiles/Ranged/BlissfulBombardierDustProjectile.cs @@ -24,60 +24,60 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0f / 255f); - bool flag15 = false; - bool flag16 = false; + bool xflag = false; + bool yflag = false; if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) { - flag16 = true; + yflag = true; } if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) { - flag16 = true; + yflag = true; } - if (flag15 && flag16) + if (xflag && yflag) { Projectile.Kill(); } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 60f) { - num461 -= (Projectile.ai[0] - 60f) / 2f; + projTimer -= (Projectile.ai[0] - 60f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-8, 9); - float num464 = (float)Main.rand.Next(-8, 9); - float num465 = (float)Main.rand.Next(2, 7); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 1.5f); - Dust dust = Main.dust[num467]; + float rand1 = (float)Main.rand.Next(-8, 9); + float rand2 = (float)Main.rand.Next(-8, 9); + float rand3 = (float)Main.rand.Next(2, 7); + float randAdjust = (float)Math.Sqrt((double)(rand1 * rand1 + rand2 * rand2)); + randAdjust = rand3 / randAdjust; + rand1 *= randAdjust; + rand2 *= randAdjust; + int dusty = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 1.5f); + Dust dust = Main.dust[dusty]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = rand1; + dust.velocity.Y = rand2; + timerCounter++; } } diff --git a/Projectiles/Ranged/BloodBoilerFire.cs b/Projectiles/Ranged/BloodBoilerFire.cs index 3616ee50d4..0092de9a4b 100644 --- a/Projectiles/Ranged/BloodBoilerFire.cs +++ b/Projectiles/Ranged/BloodBoilerFire.cs @@ -1,10 +1,12 @@ -using CalamityMod.Buffs.DamageOverTime; +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Graphics.Metaballs; +using CalamityMod.Particles; using Microsoft.Xna.Framework; -using System; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace CalamityMod.Projectiles.Ranged { @@ -14,94 +16,117 @@ namespace CalamityMod.Projectiles.Ranged public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; private bool playedSound = false; - + public int Time = 0; + public float particleSize = 15; + public Vector2 bloodCloudReturn; + public bool improvedHeal = false; + public bool setHomingVelocity = false; + public float HomingVelocity = 0.18f; public override void SetDefaults() { - Projectile.width = 6; - Projectile.height = 6; - Projectile.scale = 2f; + Projectile.width = 43; + Projectile.height = 43; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; + Projectile.tileCollide = false; Projectile.penetrate = -1; - Projectile.extraUpdates = 1; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 5; + Projectile.extraUpdates = 4; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; Projectile.timeLeft = 300; } - public override void AI() { + if (Projectile.timeLeft > 220) // Main visual size changes + particleSize += 0.5f; + else + particleSize -= 1f; + + Time++; + + if (Projectile.timeLeft == 295) // Blood produced from the muzzle when firing the weapon + { + int bloodLifetime = Main.rand.Next(22, 36); + float bloodScale = Main.rand.NextFloat(0.6f, 0.8f); + Color bloodColor = Main.rand.NextBool() ? Color.Firebrick : Color.Red; + + float randomSpeedMultiplier = Main.rand.NextFloat(0.8f, 1.55f); + Vector2 bloodVelocity = Projectile.velocity.RotatedByRandom(0.5) * randomSpeedMultiplier + new Vector2 (0, -3); + BloodParticle blood = new BloodParticle(Projectile.Center, bloodVelocity, bloodLifetime, bloodScale, bloodColor); + GeneralParticleHandler.SpawnParticle(blood); + } + if (Projectile.timeLeft < 296) // The main visual of the projectile and the blood mist it produces before turning around + { + BloodBoilerMetaball2.SpawnParticle(Projectile.Center, particleSize * 2.3f); + BloodBoilerMetaball.SpawnParticle(Projectile.Center, particleSize * 1.7f); + + if (Main.rand.NextBool(6) && Projectile.ai[1] == 0f) + { + Color smokeColor = Main.rand.NextBool() ? Color.Red : Color.Firebrick; + Vector2 smokePosition = Projectile.Center + Main.rand.NextVector2Circular(5 + Time * 0.3f, 5 + Time * 0.3f); + float smokeScale = Main.rand.NextFloat(0.5f, 1.6f); + float smokeOpacity = 170 + -Time * 0.6f; + Particle smoke = new MediumMistParticle(smokePosition, Vector2.Zero, smokeColor, Color.Black, smokeScale, smokeOpacity, Main.rand.NextFloat(0.2f, -0.2f)); + GeneralParticleHandler.SpawnParticle(smoke); + } + } + + if (Projectile.ai[1] == 0f) // Blood pulses on the projectile before it turns around + { + if (Main.rand.NextBool(9)) + { + DirectionalPulseRing pulse = new DirectionalPulseRing(Projectile.Center + Main.rand.NextVector2Circular(7 + Time * 0.4f, 7 + Time * 0.4f), Vector2.Zero, Main.rand.NextBool(3) ? Color.Red : Color.Firebrick, new Vector2(1, 1), 0, Main.rand.NextFloat(0.02f, 0.07f) + Time * 0.0006f, 0f, 35); + GeneralParticleHandler.SpawnParticle(pulse); + } + } if (!playedSound) { SoundEngine.PlaySound(SoundID.Item34, Projectile.position); playedSound = true; } - if (Projectile.scale <= 3f) - Projectile.scale *= 1.01f; - Lighting.AddLight(Projectile.Center, 1f, 0f, 0f); - if (Projectile.ai[0] > 7f) + // A bunch of small things mostly for visuals when the projectile starts turning around before it homes on the player + if (Projectile.timeLeft == 235) + bloodCloudReturn = Projectile.velocity; + if (Projectile.timeLeft <= 235 && Projectile.ai[1] == 0f) + Projectile.velocity *= 0.98f; + if (Projectile.timeLeft == 220) { - float num296 = 1f; - if (Projectile.ai[0] == 8f) + Projectile.velocity = -bloodCloudReturn.RotatedBy(Projectile.ai[2] == 5 ? -0.7f : 0.7f) * 1.2f; + for (int i = 0; i <= 5; i++) { - num296 = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - num296 = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - num296 = 0.75f; - } - Projectile.ai[0] += 1f; - int num297 = 5; - if (Main.rand.NextBool()) - { - for (int num298 = 0; num298 < 1; num298++) - { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 3f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 1.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= num296; - dust.velocity += Projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } - } + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity * 2 + Main.rand.NextVector2Circular(35, 35), Main.rand.NextBool(3) ? 60 : 296, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(0.5f)) * Main.rand.NextFloat(1.7f, 3.2f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.2f, 2f); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity * 2 + Main.rand.NextVector2Circular(35, 35), Main.rand.NextBool(3) ? 60 : 296, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.1f, 1.7f)); + dust2.noGravity = true; + dust2.scale = Main.rand.NextFloat(1.2f, 2f); } } - else + if (Projectile.timeLeft == 209) // Begin returning to player { - Projectile.ai[0] += 1f; - } - Projectile.rotation += 0.3f * (float)Projectile.direction; - - if (Projectile.timeLeft == 160) Projectile.ai[1] = 1f; + } - if (Projectile.ai[1] == 1f) + if (Projectile.ai[1] == 1f) // Dusts as the projectile homes back in on the player { - Projectile.tileCollide = false; - - Projectile.extraUpdates = 2; + if (!setHomingVelocity) + { + HomingVelocity = Main.rand.NextFloat(0.29f, 0.32f); + setHomingVelocity = true; + } + Projectile.extraUpdates = 5; + bool dustEffect = Main.rand.NextBool(3) ? false : true; + int dustColor = dustEffect ? 296 : 60; + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(dustEffect ? 0 : 5, dustEffect ? 0 : 5), dustColor); + dust.scale = dustEffect ? Main.rand.NextFloat(1.1f, 1.45f) : Main.rand.NextFloat(0.9f, 1.2f); + dust.velocity = dustEffect ? Projectile.velocity * Main.rand.NextFloat(0.2f, 0.4f) : Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(0.7f, 1.2f); + dust.alpha = 100; + dust.noLight = true; + dust.noGravity = true; Player player = Main.player[Projectile.owner]; @@ -120,38 +145,40 @@ namespace CalamityMod.Projectiles.Ranged // Home back in on the player. if (Projectile.velocity.X < xDist) { - Projectile.velocity.X = Projectile.velocity.X + 5f; + Projectile.velocity.X = Projectile.velocity.X + HomingVelocity; if (Projectile.velocity.X < 0f && xDist > 0f) - Projectile.velocity.X += 5f; + Projectile.velocity.X += HomingVelocity; } else if (Projectile.velocity.X > xDist) { - Projectile.velocity.X = Projectile.velocity.X - 5f; + Projectile.velocity.X = Projectile.velocity.X - HomingVelocity; if (Projectile.velocity.X > 0f && xDist < 0f) - Projectile.velocity.X -= 5f; + Projectile.velocity.X -= HomingVelocity; } if (Projectile.velocity.Y < yDist) { - Projectile.velocity.Y = Projectile.velocity.Y + 5f; + Projectile.velocity.Y = Projectile.velocity.Y + HomingVelocity; if (Projectile.velocity.Y < 0f && yDist > 0f) - Projectile.velocity.Y += 5f; + Projectile.velocity.Y += HomingVelocity; } else if (Projectile.velocity.Y > yDist) { - Projectile.velocity.Y = Projectile.velocity.Y - 5f; + Projectile.velocity.Y = Projectile.velocity.Y - HomingVelocity; if (Projectile.velocity.Y > 0f && yDist < 0f) - Projectile.velocity.Y -= 5f; + Projectile.velocity.Y -= HomingVelocity; } - + if (Projectile.timeLeft == 5) // Absolutely make sure the player gets the chance to heal + Projectile.Center = playerCenter; // Delete the projectile if it touches its owner. Has a chance to heal the player again if (Main.myPlayer == Projectile.owner) { if (Projectile.Hitbox.Intersects(player.Hitbox)) { - if (Main.rand.NextBool(3) && !Main.player[Projectile.owner].moonLeech) + if (Main.rand.NextBool(4) && !Main.player[Projectile.owner].moonLeech) { - player.statLife += 1; - player.HealEffect(1); + int bonusHeal = Main.rand.NextBool(3) ? 3 : 2; + player.statLife += improvedHeal ? bonusHeal : 1; + player.HealEffect(improvedHeal ? bonusHeal : 1); } Projectile.Kill(); } @@ -161,18 +188,15 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 240); - - if (!target.canGhostHeal || Main.player[Projectile.owner].moonLeech) - return; - - Player player = Main.player[Projectile.owner]; - if (Main.rand.NextBool()) - { - int healAmt = Main.rand.Next(1, 4); - player.statLife += healAmt; - player.HealEffect(healAmt); - } + target.AddBuff(ModContent.BuffType(), 600); + improvedHeal = true; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.85f); // 15% damage nerf for every enemy hit + if (Projectile.damage < 1) + Projectile.damage = 1; } } } diff --git a/Projectiles/Ranged/BloodClotFriendly.cs b/Projectiles/Ranged/BloodClotFriendly.cs index 634f40f203..dea29f8651 100644 --- a/Projectiles/Ranged/BloodClotFriendly.cs +++ b/Projectiles/Ranged/BloodClotFriendly.cs @@ -34,11 +34,11 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { - for (int num468 = 0; num468 < 2; num468++) + for (int i = 0; i < 2; i++) { Vector2 dspeed = -Projectile.velocity * 0.7f; - int num469 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 5, dspeed.X, dspeed.Y, 100, default, 2f); - Main.dust[num469].noGravity = true; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 5, dspeed.X, dspeed.Y, 100, default, 2f); + Main.dust[dust].noGravity = true; } } } diff --git a/Projectiles/Ranged/BloodfireArrowProj.cs b/Projectiles/Ranged/BloodfireArrowProj.cs index defacb8d8e..75e2311ff5 100644 --- a/Projectiles/Ranged/BloodfireArrowProj.cs +++ b/Projectiles/Ranged/BloodfireArrowProj.cs @@ -48,15 +48,15 @@ namespace CalamityMod.Projectiles.Ranged { for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); - int num9 = Dust.NewDust(Projectile.Center, 0, 0, (int)CalamityDusts.Brimstone, 0f, 0f, 160, default, 1f); - Main.dust[num9].scale = 1.1f; - Main.dust[num9].noGravity = true; - Main.dust[num9].position = Projectile.Center + vector3; - Main.dust[num9].velocity = Projectile.velocity * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; + Vector2 rotate = Vector2.UnitX * (float)-(float)Projectile.width / 2f; + rotate += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); + rotate = rotate.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); + int bloodDust = Dust.NewDust(Projectile.Center, 0, 0, (int)CalamityDusts.Brimstone, 0f, 0f, 160, default, 1f); + Main.dust[bloodDust].scale = 1.1f; + Main.dust[bloodDust].noGravity = true; + Main.dust[bloodDust].position = Projectile.Center + rotate; + Main.dust[bloodDust].velocity = Projectile.velocity * 0.1f; + Main.dust[bloodDust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[bloodDust].position) * 1.25f; } } } @@ -69,14 +69,14 @@ namespace CalamityMod.Projectiles.Ranged Projectile.height = 20; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 0.5f; + int brimDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimDust].velocity *= 0.5f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[brimDust].scale = 0.5f; + Main.dust[brimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } } diff --git a/Projectiles/Ranged/BloodflareSoul.cs b/Projectiles/Ranged/BloodflareSoul.cs index 6a15020a8d..4d4bf282de 100644 --- a/Projectiles/Ranged/BloodflareSoul.cs +++ b/Projectiles/Ranged/BloodflareSoul.cs @@ -43,22 +43,21 @@ namespace CalamityMod.Projectiles.Ranged { Projectile.frame = 0; } - int num822 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 60, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num822]; + int redDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 60, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[redDust]; dust.velocity *= 0.1f; - Main.dust[num822].scale = 1.3f; - Main.dust[num822].noGravity = true; - float num953 = 30f * Projectile.ai[1]; //100 + Main.dust[redDust].scale = 1.3f; + Main.dust[redDust].noGravity = true; + float velocityModifier = 30f * Projectile.ai[1]; //100 float scaleFactor12 = 6f * Projectile.ai[1]; //5 - float num954 = 600f; Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(90); Lighting.AddLight(Projectile.Center, 0.5f, 0.2f, 0.9f); if (Main.player[Projectile.owner].active && !Main.player[Projectile.owner].dead) { - if (Projectile.Distance(Main.player[Projectile.owner].Center) > num954) + if (Projectile.Distance(Main.player[Projectile.owner].Center) > 600f) { Vector2 moveDirection = Projectile.SafeDirectionTo(Main.player[Projectile.owner].Center, Vector2.UnitY); - Projectile.velocity = (Projectile.velocity * (num953 - 1f) + moveDirection * scaleFactor12) / num953; + Projectile.velocity = (Projectile.velocity * (velocityModifier - 1f) + moveDirection * scaleFactor12) / velocityModifier; return; } CalamityUtils.HomeInOnNPC(Projectile, true, 200f, 11f, 20f); @@ -96,16 +95,16 @@ namespace CalamityMod.Projectiles.Ranged Projectile.width = Projectile.height = 110; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int constant = 36; + for (int i = 0; i < constant; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 60, vector7.X * 1.5f, vector7.Y * 1.5f, 100, default, 2f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(i - (constant / 2 - 1)) * 6.28318548f / (float)constant), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int dust = Dust.NewDust(rotate + faceDirection, 0, 0, 60, faceDirection.X * 1.5f, faceDirection.Y * 1.5f, 100, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + Main.dust[dust].velocity = faceDirection; } Projectile.Damage(); } diff --git a/Projectiles/Ranged/Bolt.cs b/Projectiles/Ranged/Bolt.cs index 483d0db5df..e228920f58 100644 --- a/Projectiles/Ranged/Bolt.cs +++ b/Projectiles/Ranged/Bolt.cs @@ -35,15 +35,15 @@ namespace CalamityMod.Projectiles.Ranged { for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); - int num9 = Dust.NewDust(Projectile.Center, 0, 0, 221, 0f, 0f, 160, default, 1f); - Main.dust[num9].scale = 1.1f; - Main.dust[num9].noGravity = true; - Main.dust[num9].position = Projectile.Center + vector3; - Main.dust[num9].velocity = Projectile.velocity * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; + Vector2 rotate = Vector2.UnitX * (float)-(float)Projectile.width / 2f; + rotate += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); + rotate = rotate.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); + int blueDust = Dust.NewDust(Projectile.Center, 0, 0, 221, 0f, 0f, 160, default, 1f); + Main.dust[blueDust].scale = 1.1f; + Main.dust[blueDust].noGravity = true; + Main.dust[blueDust].position = Projectile.Center + rotate; + Main.dust[blueDust].velocity = Projectile.velocity * 0.1f; + Main.dust[blueDust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[blueDust].position) * 1.25f; } } } @@ -76,12 +76,12 @@ namespace CalamityMod.Projectiles.Ranged Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; Projectile.Damage(); - int num212 = Main.rand.Next(4, 8); - for (int num213 = 0; num213 < num212; num213++) + int rando = Main.rand.Next(4, 8); + for (int i = 0; i < rando; i++) { - int num214 = Dust.NewDust(Projectile.Center - Projectile.velocity / 2f, 0, 0, 135, 0f, 0f, 100, default, 2f); - Main.dust[num214].velocity *= 2f; - Main.dust[num214].noGravity = true; + int dust = Dust.NewDust(Projectile.Center - Projectile.velocity / 2f, 0, 0, 135, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 2f; + Main.dust[dust].noGravity = true; } } } diff --git a/Projectiles/Ranged/BoltArrow.cs b/Projectiles/Ranged/BoltArrow.cs index 020a3ec33e..a9c313d4d6 100644 --- a/Projectiles/Ranged/BoltArrow.cs +++ b/Projectiles/Ranged/BoltArrow.cs @@ -33,15 +33,15 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localAI[0] = 0f; for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); - int num9 = Dust.NewDust(Projectile.Center, 0, 0, 221, 0f, 0f, 160, default, 1f); - Main.dust[num9].scale = 1.1f; - Main.dust[num9].noGravity = true; - Main.dust[num9].position = Projectile.Center + vector3; - Main.dust[num9].velocity = Projectile.velocity * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; + Vector2 rotate = Vector2.UnitX * (float)-(float)Projectile.width / 2f; + rotate += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); + rotate = rotate.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); + int blueDust = Dust.NewDust(Projectile.Center, 0, 0, 221, 0f, 0f, 160, default, 1f); + Main.dust[blueDust].scale = 1.1f; + Main.dust[blueDust].noGravity = true; + Main.dust[blueDust].position = Projectile.Center + rotate; + Main.dust[blueDust].velocity = Projectile.velocity * 0.1f; + Main.dust[blueDust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[blueDust].position) * 1.25f; } } } @@ -66,12 +66,12 @@ namespace CalamityMod.Projectiles.Ranged Projectile.damage = (int)(Projectile.damage * 0.6f); Projectile.Damage(); SoundEngine.PlaySound(SoundID.Item92, Projectile.Center); - int num212 = Main.rand.Next(10, 20); - for (int num213 = 0; num213 < num212; num213++) + int rando = Main.rand.Next(10, 20); + for (int i = 0; i < rando; i++) { - int num214 = Dust.NewDust(Projectile.Center - Projectile.velocity / 2f, 0, 0, 135, 0f, 0f, 100, default, 2f); - Main.dust[num214].velocity *= 2f; - Main.dust[num214].noGravity = true; + int dust = Dust.NewDust(Projectile.Center - Projectile.velocity / 2f, 0, 0, 135, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 2f; + Main.dust[dust].noGravity = true; } } } diff --git a/Projectiles/Ranged/BrimstoneBolt.cs b/Projectiles/Ranged/BrimstoneBolt.cs index 3c9e2a61bf..83e6d99bff 100644 --- a/Projectiles/Ranged/BrimstoneBolt.cs +++ b/Projectiles/Ranged/BrimstoneBolt.cs @@ -47,14 +47,14 @@ namespace CalamityMod.Projectiles.Ranged Lighting.AddLight(Projectile.Center, 0.7f, 0f, 0f); if (Projectile.localAI[0] > 2f) { - for (int num121 = 0; num121 < 5; num121++) + for (int i = 0; i < 5; i++) { - Dust dust4 = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f)]; - dust4.velocity = Vector2.Zero; - dust4.position -= Projectile.velocity / 5f * (float)num121; - dust4.noGravity = true; - dust4.scale = 0.8f; - dust4.noLight = true; + Dust dusty = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f)]; + dusty.velocity = Vector2.Zero; + dusty.position -= Projectile.velocity / 5f * (float)i; + dusty.noGravity = true; + dusty.scale = 0.8f; + dusty.noLight = true; } } else diff --git a/Projectiles/Ranged/BrimstoneFireFriendly.cs b/Projectiles/Ranged/BrimstoneFireFriendly.cs index 5944635129..8271e32a81 100644 --- a/Projectiles/Ranged/BrimstoneFireFriendly.cs +++ b/Projectiles/Ranged/BrimstoneFireFriendly.cs @@ -1,87 +1,153 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Ranged { public class BrimstoneFireFriendly : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override string Texture => "CalamityMod/Projectiles/FireProj"; + + public static int Lifetime => 60; + public static int Fadetime => 80; + public ref float Time => ref Projectile.ai[0]; + public int MistType = -1; public override void SetDefaults() { - Projectile.width = 6; - Projectile.height = 6; + Projectile.width = Projectile.height = 10; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = -1; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 90; + Projectile.MaxUpdates = 3; + Projectile.timeLeft = Lifetime; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 6; } public override void AI() { - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0.05f / 255f, (255 - Projectile.alpha) * 0.05f / 255f); - if (Projectile.timeLeft > 90) + Time++; + if (Time < Fadetime && Main.rand.NextBool(6)) { - Projectile.timeLeft = 90; + Vector2 cinderPos = Projectile.Center + Main.rand.NextVector2Circular(60f, 60f) * Utils.Remap(Time, 0f, Lifetime, 0.5f, 1f); + float cinderSize = Utils.GetLerpValue(6f, 12f, Time, true); + Dust cinder = Dust.NewDustDirect(cinderPos, 4, 4, ModContent.DustType(), Projectile.velocity.X * 0.25f, Projectile.velocity.Y * 0.25f); + if (Main.rand.NextBool(3)) + { + cinder.scale *= 2f; + cinder.velocity *= 2f; + } + cinder.noGravity = true; + cinder.scale *= cinderSize * 1.2f; + cinder.velocity += Projectile.velocity * Utils.Remap(Time, 0f, Fadetime * 0.75f, 1f, 0.1f) * Utils.Remap(Time, 0f, Fadetime * 0.1f, 0.1f, 1f); } - if (Projectile.ai[0] > 7f) - { - float num296 = 1f; - if (Projectile.ai[0] == 8f) - { - num296 = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - num296 = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - num296 = 0.75f; - } - Projectile.ai[0] += 1f; - int num297 = 235; - if (Main.rand.NextBool()) - { - for (int num298 = 0; num298 < 1; num298++) - { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - if (Main.rand.NextBool(3)) - { - Main.dust[num299].noGravity = true; - Main.dust[num299].scale *= 3f; - Dust expr_DBEF_cp_0 = Main.dust[num299]; - expr_DBEF_cp_0.velocity.X *= 2f; - Dust expr_DC0F_cp_0 = Main.dust[num299]; - expr_DC0F_cp_0.velocity.Y *= 2f; - } - else - { - Main.dust[num299].scale *= 1.5f; - } - Dust expr_DC74_cp_0 = Main.dust[num299]; - expr_DC74_cp_0.velocity.X *= 1.2f; - Dust expr_DC94_cp_0 = Main.dust[num299]; - expr_DC94_cp_0.velocity.Y *= 1.2f; - Main.dust[num299].scale *= num296; - } - } - } - else - { - Projectile.ai[0] += 1f; - } - Projectile.rotation += 0.3f * (float)Projectile.direction; + + if (MistType == -1) + MistType = Main.rand.Next(3); + + Lighting.AddLight(Projectile.Center, 0.75f, 0.15f, 0.15f); } + // Keeping the flames in place when hitting a block + public override bool OnTileCollide(Vector2 oldVelocity) + { + Projectile.velocity = oldVelocity * 0.95f; + Projectile.position -= Projectile.velocity; + Time++; + Projectile.timeLeft--; + return false; + } + + // Expanding hitbox + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + int size = (int)Utils.Remap(Time, 0f, Fadetime, 10f, 40f); + + // Shrinks again after fading + if (Time > Fadetime) + size = (int)Utils.Remap(Time, Fadetime, Lifetime, 40f, 0f); + hitbox.Inflate(size, size); + } + + // Anti-wall hacking checks + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => projHitbox.Intersects(targetHitbox) && Collision.CanHit(Projectile.Center, 0, 0, targetHitbox.Center.ToVector2(), 0, 0) ? null : false; + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.immune[Projectile.owner] = 7; target.AddBuff(ModContent.BuffType(), 240); + + // Gas up the enemy + int smokeCount = 3 + (int)MathHelper.Clamp(target.width * 0.1f, 0f, 20f); + for (int i = 0; i < smokeCount; i++) + { + bool Smoketype = Main.rand.NextBool(); + Vector2 smokePos = target.Center + Main.rand.NextVector2Circular(target.width * 0.5f, target.height * 0.5f); + Vector2 smokeVel = Vector2.UnitY * (Smoketype ? Main.rand.NextFloat(-0.8f, -2f) : Main.rand.NextFloat(-1.2f, -0.2f)) * MathHelper.Clamp(target.height * 0.1f, 1f, 10f); + Particle smoke = new MediumMistParticle(smokePos, smokeVel, new Color(255, 50, 50), Color.DimGray, Smoketype ? Main.rand.NextFloat(0.4f, 0.75f) : Main.rand.NextFloat(1.5f, 2f), 220 - Main.rand.Next(50), 0.1f); + GeneralParticleHandler.SpawnParticle(smoke); + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D fire = ModContent.Request(Texture).Value; + Texture2D mist = ModContent.Request("CalamityMod/Particles/MediumMist").Value; + + // The conga line of colors to sift through + Color color1 = new Color(255, 110, 100, 200); + Color color2 = new Color(255, 50, 50, 70); + Color color3 = new Color(255, 100, 100, 100); + Color color4 = new Color(200, 35, 30, 100); + float length = ((Time > Fadetime - 10f) ? 0.1f : 0.15f); + float vOffset = Math.Min(Time, 20f); + float timeRatio = Utils.GetLerpValue(0f, Lifetime, Time); + float fireSize = Utils.Remap(timeRatio, 0.2f, 0.5f, 0.25f, 1f); + + if (timeRatio >= 1f) + return false; + + for (float j = 1f; j >= 0f; j -= length) + { + // Color + Color fireColor = ((timeRatio < 0.1f) ? Color.Lerp(Color.Transparent, color1, Utils.GetLerpValue(0f, 0.1f, timeRatio)) : + ((timeRatio < 0.2f) ? Color.Lerp(color1, color2, Utils.GetLerpValue(0.1f, 0.2f, timeRatio)) : + ((timeRatio < 0.35f) ? color2 : + ((timeRatio < 0.7f) ? Color.Lerp(color2, color3, Utils.GetLerpValue(0.35f, 0.7f, timeRatio)) : + ((timeRatio < 0.85f) ? Color.Lerp(color3, color4, Utils.GetLerpValue(0.7f, 0.85f, timeRatio)) : + Color.Lerp(color4, Color.Transparent, Utils.GetLerpValue(0.85f, 1f, timeRatio))))))); + fireColor *= (1f - j) * Utils.GetLerpValue(0f, 0.2f, timeRatio, true); + Color innerColor = Color.Lerp(fireColor, Color.Black, 0.3f); + + // Positions and rotations + Vector2 firePos = Projectile.Center - Main.screenPosition - Projectile.velocity * vOffset * j; + float mainRot = -j * MathHelper.PiOver2 - Main.GlobalTimeWrappedHourly * (j + 1f) * 2f / length; + float trailRot = MathHelper.PiOver4 - mainRot; + + // Draw one backtrail + Vector2 trailOffset = Projectile.velocity * vOffset * length * 0.5f; + Main.EntitySpriteDraw(fire, firePos - trailOffset, null, innerColor * 0.25f, trailRot, fire.Size() * 0.5f, fireSize, SpriteEffects.None); + + // Draw the main fire + Main.EntitySpriteDraw(fire, firePos, null, innerColor, mainRot, fire.Size() * 0.5f, fireSize, SpriteEffects.None); + + // Draw the masking smoke + if (MistType > 2 || MistType < 0) + return false; + Main.spriteBatch.SetBlendState(BlendState.Additive); + Rectangle frame = mist.Frame(1, 3, 0, MistType); + Main.EntitySpriteDraw(mist, firePos, frame, Color.Lerp(fireColor, Color.White, 0.3f), mainRot, frame.Size() * 0.5f, fireSize, SpriteEffects.None); + Main.EntitySpriteDraw(mist, firePos, frame, fireColor, mainRot, frame.Size() * 0.5f, fireSize * 3f, SpriteEffects.None); + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + } + return false; } } } diff --git a/Projectiles/Ranged/BubonicRoundProj.cs b/Projectiles/Ranged/BubonicRoundProj.cs index 3f12c64f31..ee35e71365 100644 --- a/Projectiles/Ranged/BubonicRoundProj.cs +++ b/Projectiles/Ranged/BubonicRoundProj.cs @@ -39,10 +39,10 @@ namespace CalamityMod.Projectiles.Ranged { if (Main.rand.NextBool()) { - int num137 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, 107, 0f, 0f, 0, default, 0.5f); - Main.dust[num137].alpha = Projectile.alpha; - Main.dust[num137].velocity *= 0f; - Main.dust[num137].noGravity = true; + int greenDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, 107, 0f, 0f, 0, default, 0.5f); + Main.dust[greenDust].alpha = Projectile.alpha; + Main.dust[greenDust].velocity *= 0f; + Main.dust[greenDust].noGravity = true; } } } diff --git a/Projectiles/Ranged/ButcherGun.cs b/Projectiles/Ranged/ButcherGun.cs index 8f191fa560..f6282c1b7d 100644 --- a/Projectiles/Ranged/ButcherGun.cs +++ b/Projectiles/Ranged/ButcherGun.cs @@ -133,9 +133,9 @@ namespace CalamityMod.Projectiles.Ranged source += Utils.RandomVector2(Main.rand, -5f, 5f); bulletVel.X += (float)Main.rand.Next(-15, 16) * spreadMult; bulletVel.Y += (float)Main.rand.Next(-15, 16) * spreadMult; - int num44 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), source, bulletVel, projType, damage, kback, Projectile.owner, 0f, 0f); - Main.projectile[num44].noDropItem = true; - Main.projectile[num44].extraUpdates += incrementAmt / 2; //0 to 4 + int bullet = Projectile.NewProjectile(Projectile.GetSource_FromThis(), source, bulletVel, projType, damage, kback, Projectile.owner, 0f, 0f); + Main.projectile[bullet].noDropItem = true; + Main.projectile[bullet].extraUpdates += incrementAmt / 2; //0 to 4 } } else diff --git a/Projectiles/Ranged/CardClub.cs b/Projectiles/Ranged/CardClub.cs index d0a9ce3438..8bda06015e 100644 --- a/Projectiles/Ranged/CardClub.cs +++ b/Projectiles/Ranged/CardClub.cs @@ -36,9 +36,9 @@ namespace CalamityMod.Projectiles.Ranged Projectile.spriteDirection = Projectile.direction; if (Main.rand.NextBool()) { - int num137 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, 30, 0f, 0f, 0, default, 0.5f); - Main.dust[num137].velocity *= 0f; - Main.dust[num137].noGravity = true; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, 30, 0f, 0f, 0, default, 0.5f); + Main.dust[dust].velocity *= 0f; + Main.dust[dust].noGravity = true; } } diff --git a/Projectiles/Ranged/CardClubSplit.cs b/Projectiles/Ranged/CardClubSplit.cs index 425dc24493..7d840945f6 100644 --- a/Projectiles/Ranged/CardClubSplit.cs +++ b/Projectiles/Ranged/CardClubSplit.cs @@ -36,9 +36,9 @@ namespace CalamityMod.Projectiles.Ranged Projectile.spriteDirection = Projectile.direction; if (Main.rand.NextBool()) { - int num137 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, 30, 0f, 0f, 0, default, 0.5f); - Main.dust[num137].velocity *= 0f; - Main.dust[num137].noGravity = true; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, 30, 0f, 0f, 0, default, 0.5f); + Main.dust[dust].velocity *= 0f; + Main.dust[dust].noGravity = true; } if (Projectile.alpha < 128) diff --git a/Projectiles/Ranged/CardDiamond.cs b/Projectiles/Ranged/CardDiamond.cs index 5e581805d8..74c85383fe 100644 --- a/Projectiles/Ranged/CardDiamond.cs +++ b/Projectiles/Ranged/CardDiamond.cs @@ -36,9 +36,9 @@ namespace CalamityMod.Projectiles.Ranged Projectile.spriteDirection = Projectile.direction; if (Main.rand.NextBool()) { - int num137 = Dust.NewDust(Projectile.position, 1, 1, 30, 0f, 0f, 0, default, 0.5f); - Main.dust[num137].velocity *= 0f; - Main.dust[num137].noGravity = true; + int dust = Dust.NewDust(Projectile.position, 1, 1, 30, 0f, 0f, 0, default, 0.5f); + Main.dust[dust].velocity *= 0f; + Main.dust[dust].noGravity = true; } } diff --git a/Projectiles/Ranged/CardHeart.cs b/Projectiles/Ranged/CardHeart.cs index f28588438a..b0fcd02d3e 100644 --- a/Projectiles/Ranged/CardHeart.cs +++ b/Projectiles/Ranged/CardHeart.cs @@ -36,9 +36,9 @@ namespace CalamityMod.Projectiles.Ranged Projectile.spriteDirection = Projectile.direction; if (Main.rand.NextBool()) { - int num137 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, 30, 0f, 0f, 0, default, 0.5f); - Main.dust[num137].velocity *= 0f; - Main.dust[num137].noGravity = true; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, 30, 0f, 0f, 0, default, 0.5f); + Main.dust[dust].velocity *= 0f; + Main.dust[dust].noGravity = true; } } diff --git a/Projectiles/Ranged/CardSpade.cs b/Projectiles/Ranged/CardSpade.cs index 2129d1be98..d3599f3ee4 100644 --- a/Projectiles/Ranged/CardSpade.cs +++ b/Projectiles/Ranged/CardSpade.cs @@ -38,9 +38,9 @@ namespace CalamityMod.Projectiles.Ranged Projectile.spriteDirection = Projectile.direction; if (Main.rand.NextBool()) { - int num137 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, 30, 0f, 0f, 0, default, 0.5f); - Main.dust[num137].velocity *= 0f; - Main.dust[num137].noGravity = true; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, 30, 0f, 0f, 0, default, 0.5f); + Main.dust[dust].velocity *= 0f; + Main.dust[dust].noGravity = true; } } diff --git a/Projectiles/Ranged/ChargedBlast2.cs b/Projectiles/Ranged/ChargedBlast2.cs index 21833c2fe9..4ba6bf958b 100644 --- a/Projectiles/Ranged/ChargedBlast2.cs +++ b/Projectiles/Ranged/ChargedBlast2.cs @@ -33,19 +33,19 @@ namespace CalamityMod.Projectiles.Ranged Projectile.alpha = 0; } Lighting.AddLight((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16, 0f, 0.3f, 0.7f); - float num55 = 30f; - float num56 = 1f; + float thirty = 30f; + float inc = 1f; if (Projectile.ai[1] == 0f) { - Projectile.localAI[0] += num56; - if (Projectile.localAI[0] > num55) + Projectile.localAI[0] += inc; + if (Projectile.localAI[0] > thirty) { - Projectile.localAI[0] = num55; + Projectile.localAI[0] = thirty; } } else { - Projectile.localAI[0] -= num56; + Projectile.localAI[0] -= inc; if (Projectile.localAI[0] <= 0f) { Projectile.Kill(); diff --git a/Projectiles/Ranged/ClamorRifleProj.cs b/Projectiles/Ranged/ClamorRifleProj.cs index 19840c0be1..d584a075d5 100644 --- a/Projectiles/Ranged/ClamorRifleProj.cs +++ b/Projectiles/Ranged/ClamorRifleProj.cs @@ -29,13 +29,12 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.localAI[0] > 3f) { Lighting.AddLight(Projectile.Center, new Vector3(44, 191, 232) * (1.3f / 255)); - for (int num151 = 0; num151 < 2; num151++) + for (int i = 0; i < 2; i++) { - int num154 = 14; - int num155 = Dust.NewDust(new Vector2(Projectile.Center.X, Projectile.Center.Y), Projectile.width - num154 * 2, Projectile.height - num154 * 2, 68, 0f, 0f, 100, default, 1f); - Main.dust[num155].noGravity = true; - Main.dust[num155].velocity *= 0.1f; - Main.dust[num155].velocity += Projectile.velocity * 0.5f; + int blueDust = Dust.NewDust(new Vector2(Projectile.Center.X, Projectile.Center.Y), Projectile.width - 28, Projectile.height - 28, 68, 0f, 0f, 100, default, 1f); + Main.dust[blueDust].noGravity = true; + Main.dust[blueDust].velocity *= 0.1f; + Main.dust[blueDust].velocity += Projectile.velocity * 0.5f; } } CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 150f, 12f, 25f); diff --git a/Projectiles/Ranged/ClamorRifleProjSplit.cs b/Projectiles/Ranged/ClamorRifleProjSplit.cs index d8f5d21bb1..28c36bb2d7 100644 --- a/Projectiles/Ranged/ClamorRifleProjSplit.cs +++ b/Projectiles/Ranged/ClamorRifleProjSplit.cs @@ -30,11 +30,10 @@ namespace CalamityMod.Projectiles.Ranged for (int num151 = 0; num151 < 2; num151++) { - int num154 = 14; - int num155 = Dust.NewDust(new Vector2(Projectile.Center.X, Projectile.Center.Y), Projectile.width - num154 * 2, Projectile.height - num154 * 2, 68, 0f, 0f, 100, default, 1f); - Main.dust[num155].noGravity = true; - Main.dust[num155].velocity *= 0.1f; - Main.dust[num155].velocity += Projectile.velocity * 0.5f; + int blueDust = Dust.NewDust(new Vector2(Projectile.Center.X, Projectile.Center.Y), Projectile.width - 28, Projectile.height - 28, 68, 0f, 0f, 100, default, 1f); + Main.dust[blueDust].noGravity = true; + Main.dust[blueDust].velocity *= 0.1f; + Main.dust[blueDust].velocity += Projectile.velocity * 0.5f; } if (Projectile.timeLeft < 150) diff --git a/Projectiles/Ranged/ContagionBall.cs b/Projectiles/Ranged/ContagionBall.cs index 2570376153..243f195079 100644 --- a/Projectiles/Ranged/ContagionBall.cs +++ b/Projectiles/Ranged/ContagionBall.cs @@ -31,11 +31,11 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localNPCHitCooldown = 10; Projectile.Damage(); SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 44, 0f, 0f, 100, default, 0.15f); - Main.dust[num622].velocity *= 1.2f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 44, 0f, 0f, 100, default, 0.15f); + Main.dust[dust].velocity *= 1.2f; if (Main.rand.NextBool()) { - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } } diff --git a/Projectiles/Ranged/ContagionBow.cs b/Projectiles/Ranged/ContagionBow.cs index b8a30c38d7..9f3338c2ef 100644 --- a/Projectiles/Ranged/ContagionBow.cs +++ b/Projectiles/Ranged/ContagionBow.cs @@ -32,29 +32,29 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.type == ModContent.ProjectileType()) { Projectile.ai[0] += 1f; - int num2 = 0; + int fireSpeed = 0; if (Projectile.ai[0] >= 40f) { - num2++; + fireSpeed++; } if (Projectile.ai[0] >= 80f) { - num2++; + fireSpeed++; } if (Projectile.ai[0] >= 120f) { - num2++; + fireSpeed++; } - int num3 = 24; - int num4 = 6; + int delayCompare = 24; + int fireSpeedCompare = 6; Projectile.ai[1] += 1f; - bool flag = false; - if (Projectile.ai[1] >= (float)(num3 - num4 * num2)) + bool fullSpeed = false; + if (Projectile.ai[1] >= (float)(delayCompare - fireSpeedCompare * fireSpeed)) { Projectile.ai[1] = 0f; - flag = true; + fullSpeed = true; } - Projectile.frameCounter += 1 + num2; + Projectile.frameCounter += 1 + fireSpeed; if (Projectile.frameCounter >= 4) { Projectile.frameCounter = 0; @@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Ranged } if (Projectile.soundDelay <= 0) { - Projectile.soundDelay = num3 - num4 * num2; + Projectile.soundDelay = delayCompare - fireSpeedCompare * fireSpeed; if (Projectile.ai[0] != 1f) { SoundEngine.PlaySound(SoundID.Item5, Projectile.Center); @@ -74,21 +74,21 @@ namespace CalamityMod.Projectiles.Ranged } if (Projectile.ai[1] == 1f && Projectile.ai[0] != 1f) { - Vector2 vector2 = Vector2.UnitX * 24f; - vector2 = vector2.RotatedBy((double)(Projectile.rotation - MathHelper.PiOver2), default); - Vector2 value = Projectile.Center + vector2; + Vector2 rotate = Vector2.UnitX * 24f; + rotate = rotate.RotatedBy((double)(Projectile.rotation - MathHelper.PiOver2), default); + Vector2 value = Projectile.Center + rotate; for (int i = 0; i < 2; i++) { - int num5 = Dust.NewDust(value - Vector2.One * 8f, 16, 16, 44, Projectile.velocity.X / 2f, Projectile.velocity.Y / 2f, 100, default, 0.25f); - Main.dust[num5].velocity *= 0.66f; - Main.dust[num5].noGravity = true; - Main.dust[num5].scale = 1.4f; + int dust = Dust.NewDust(value - Vector2.One * 8f, 16, 16, 44, Projectile.velocity.X / 2f, Projectile.velocity.Y / 2f, 100, default, 0.25f); + Main.dust[dust].velocity *= 0.66f; + Main.dust[dust].noGravity = true; + Main.dust[dust].scale = 1.4f; } } - if (flag && Main.myPlayer == Projectile.owner) + if (fullSpeed && Main.myPlayer == Projectile.owner) { - bool flag2 = player.channel && !player.noItems && !player.CCed; - if (flag2) + bool canUseItem = player.channel && !player.noItems && !player.CCed; + if (canUseItem) { float speed = player.ActiveItem().shootSpeed * Projectile.scale; Vector2 spawnPos = vector; diff --git a/Projectiles/Ranged/CorinthPrimeAirburstGrenade.cs b/Projectiles/Ranged/CorinthPrimeAirburstGrenade.cs index 0f3d45ecdc..b77d4e0bec 100644 --- a/Projectiles/Ranged/CorinthPrimeAirburstGrenade.cs +++ b/Projectiles/Ranged/CorinthPrimeAirburstGrenade.cs @@ -1,10 +1,10 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; -using Terraria.Audio; +using System; using CalamityMod.Items.Weapons.DraedonsArsenal; using CalamityMod.NPCs.ExoMechs.Ares; -using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { @@ -142,34 +142,34 @@ namespace CalamityMod.Projectiles.Ranged // Dust circles int totalDust = weakExplosion ? 100 : 400; - for (int num640 = 0; num640 < totalDust; num640++) + for (int i = 0; i < totalDust; i++) { int dustType = 206; - float num641 = 32f; - if (num640 < 300) + float circleSize = 32f; + if (i < 300) { dustType = 187; - num641 = 16f; + circleSize = 16f; } - if (num640 < 200) - num641 = 8f; - if (num640 < 100) - num641 = 4f; + if (i < 200) + circleSize = 8f; + if (i < 100) + circleSize = 4f; - int num643 = Dust.NewDust(Projectile.Center, 6, 6, dustType, 0f, 0f, 100, default, 1f); - float num644 = Main.dust[num643].velocity.X; - float num645 = Main.dust[num643].velocity.Y; + int circleDustID = Dust.NewDust(Projectile.Center, 6, 6, dustType, 0f, 0f, 100, default, 1f); + float dustX = Main.dust[circleDustID].velocity.X; + float dustY = Main.dust[circleDustID].velocity.Y; - if (num644 == 0f && num645 == 0f) - num644 = 1f; + if (dustX == 0f && dustY == 0f) + dustX = 1f; - float num646 = (float)Math.Sqrt(num644 * num644 + num645 * num645); - num646 = num641 / num646; - num644 *= num646; - num645 *= num646; + float dustCircle = (float)Math.Sqrt(dustX * dustX + dustY * dustY); + dustCircle = circleSize / dustCircle; + dustX *= dustCircle; + dustY *= dustCircle; float scale = 1f; - switch ((int)num641) + switch ((int)circleSize) { case 4: scale = 1.1f; @@ -187,10 +187,10 @@ namespace CalamityMod.Projectiles.Ranged break; } - Dust dust = Main.dust[num643]; + Dust dust = Main.dust[circleDustID]; dust.velocity *= 0.5f; - dust.velocity.X += num644; - dust.velocity.Y += num645; + dust.velocity.X += dustX; + dust.velocity.Y += dustY; dust.scale = scale; dust.noGravity = true; } diff --git a/Projectiles/Ranged/CorossiveFlames.cs b/Projectiles/Ranged/CorossiveFlames.cs deleted file mode 100644 index ce12110be3..0000000000 --- a/Projectiles/Ranged/CorossiveFlames.cs +++ /dev/null @@ -1,87 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Ranged -{ - public class CorossiveFlames : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetDefaults() - { - Projectile.width = 12; - Projectile.height = 12; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = -1; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 90; - } - - public override void AI() - { - Lighting.AddLight(Projectile.Center, 0f, 0.25f, 0f); - if (Projectile.ai[0] > 7f) - { - float num296 = 1f; - if (Projectile.ai[0] == 8f) - { - num296 = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - num296 = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - num296 = 0.75f; - } - Projectile.ai[0] += 1f; - int num297 = 89; - if (Main.rand.NextBool()) - { - for (int num298 = 0; num298 < 1; num298++) - { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 2.5f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - if (Main.rand.NextBool(6)) - { - dust.noGravity = true; - dust.scale *= 3f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 2f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= num296; - } - } - } - else - { - Projectile.ai[0] += 1f; - } - Projectile.rotation += 0.3f * (float)Projectile.direction; - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.immune[Projectile.owner] = 4; - target.AddBuff(ModContent.BuffType(), 240); - } - } -} diff --git a/Projectiles/Ranged/CosmicFire.cs b/Projectiles/Ranged/CosmicFire.cs index 7b9ca8f127..e5274abfb1 100644 --- a/Projectiles/Ranged/CosmicFire.cs +++ b/Projectiles/Ranged/CosmicFire.cs @@ -1,5 +1,11 @@ -using Terraria; +using CalamityMod.Buffs.DamageOverTime; +using Terraria; using Terraria.ModLoader; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria.Audio; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Projectiles.Typeless; namespace CalamityMod.Projectiles.Ranged { @@ -7,78 +13,129 @@ namespace CalamityMod.Projectiles.Ranged { public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public ref int HitCount => ref Main.player[Projectile.owner].Calamity().deadSunCounter; + public ref float Time => ref Projectile.ai[0]; + public ref float BounceHits => ref Projectile.ai[1]; + + public Color InnerColor = Color.LightGreen; public override void SetDefaults() { - Projectile.width = 10; - Projectile.height = 10; + Projectile.width = Projectile.height = 16; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = -1; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 100; + Projectile.penetrate = 1; + Projectile.MaxUpdates = 10; + Projectile.timeLeft = 27 * Projectile.MaxUpdates; } public override void AI() { - if (Projectile.scale <= 1.5f) + Time++; + Lighting.AddLight(Projectile.Center, InnerColor.ToVector3() * 0.2f); + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); //used for some drawing prevention for when it's offscreen since it makes a fuck load of particles + if (Projectile.timeLeft % 3 == 0 && Time > 12f && targetDist < 1400f) { - Projectile.scale *= 1.01f; + AltSparkParticle spark = new AltSparkParticle(Projectile.Center, -Projectile.velocity * 0.05f, false, 17, 2.3f, Color.Black); + GeneralParticleHandler.SpawnParticle(spark); } - Lighting.AddLight(Projectile.Center, 0.25f, 0f, 0.1f); - if (Projectile.ai[0] > 7f) + if (Main.rand.NextBool(3) && Time > 12f && targetDist < 1400f) { - float scalar = 1f; - if (Projectile.ai[0] == 8f) + Particle orb = new GenericBloom(Projectile.Center + Main.rand.NextVector2Circular(10, 10), Projectile.velocity * Main.rand.NextFloat(0.05f, 0.5f), Color.Black, Main.rand.NextFloat(0.2f, 0.45f), Main.rand.Next(9, 12), true, false); + GeneralParticleHandler.SpawnParticle(orb); + } + + if (Projectile.timeLeft % 3 == 0 && Time > 12f && targetDist < 1400f) + { + LineParticle spark2 = new LineParticle(Projectile.Center, -Projectile.velocity * 0.05f, false, 17, 1.7f, InnerColor); + GeneralParticleHandler.SpawnParticle(spark2); + } + if (Main.rand.NextBool(3) && Time > 12f && targetDist < 1400f) + { + Particle orb2 = new GenericBloom(Projectile.Center + Main.rand.NextVector2Circular(5, 5), Projectile.velocity * Main.rand.NextFloat(0.05f, 0.5f), InnerColor, Main.rand.NextFloat(0.05f, 0.3f), Main.rand.Next(9, 12), true); + GeneralParticleHandler.SpawnParticle(orb2); + } + + if (Time == 7f) + { + for (int i = 0; i <= 18; i++) { - scalar = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - scalar = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - scalar = 0.75f; - } - Projectile.ai[0] += 1f; - int dustType = Main.rand.NextBool(4) ? 61 : 62; - if (Main.rand.NextBool()) - { - int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[fire]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 3f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 1.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= scalar; - dust.velocity += Projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } + int dustStyle = Main.rand.NextBool() ? 66 : 263; + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 191 : dustStyle, Projectile.velocity); + dust.scale = Main.rand.NextFloat(1.5f, 2.3f); + dust.velocity = Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.3f, 2.1f); + dust.noGravity = true; + dust.color = dust.type == dustStyle ? InnerColor : default; } } - else + if (BounceHits > 0f) { - Projectile.ai[0] += 1f; + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(6) ? 278 : 263, -Projectile.velocity); + dust.scale = dust.type == 278 ? Main.rand.NextFloat(0.3f, 0.6f) : Main.rand.NextFloat(0.6f, 1.4f); + dust.velocity = -Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.3f, 1.7f); + dust.noGravity = true; + dust.color = InnerColor; + + CalamityUtils.HomeInOnNPC(Projectile, false, 600f, 12f, 20f); } - Projectile.rotation += 0.3f * (float)Projectile.direction; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.immune[Projectile.owner] = 3; + SoundEngine.PlaySound(DeadSunsWind.Explosion with { Pitch = HitCount * 0.05f }, Projectile.Center); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 1.5f), 4f, Projectile.owner, HitCount * 10, BounceHits > 0f ? 5 : 0); + if (HitCount >= 15) + HitCount = 6; + else + HitCount++; + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + Projectile.timeLeft = 27 * Projectile.MaxUpdates; + float numberOflines = 5; + float rotFactorlines = 360f / numberOflines; + for (int i = 0; i < numberOflines; i++) + { + float rot = MathHelper.ToRadians(i * rotFactorlines); + Vector2 offset = new Vector2(Main.rand.NextFloat(1, 3.1f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + Vector2 velOffset = new Vector2(Main.rand.NextFloat(1, 3.1f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + AltSparkParticle spark = new AltSparkParticle(Projectile.Center + offset, velOffset, false, 20, Main.rand.NextFloat(1.9f, 2.3f), Color.Black); + GeneralParticleHandler.SpawnParticle(spark); + } + float numberOfDusts = 12; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) + { + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 offset = new Vector2(Main.rand.NextFloat(1, 3.1f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + Vector2 velOffset = new Vector2(Main.rand.NextFloat(1, 3.1f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, 66, new Vector2(velOffset.X, velOffset.Y)); + dust.noGravity = true; + dust.velocity = velOffset; + dust.scale = Main.rand.NextFloat(1.6f, 2.2f); + dust.color = InnerColor; + } + Particle pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, InnerColor, new Vector2(1f, 1f), Main.rand.NextFloat(5, -5), 0.1f, 0.9f - (BounceHits * 0.25f), 25); + GeneralParticleHandler.SpawnParticle(pulse); + + if (BounceHits == 0f) + SoundEngine.PlaySound(DeadSunsWind.Ricochet, Projectile.Center); + + BounceHits++; + if (Projectile.velocity.X != oldVelocity.X) + { + Projectile.velocity.X = -oldVelocity.X; + } + if (Projectile.velocity.Y != oldVelocity.Y) + { + Projectile.velocity.Y = -oldVelocity.Y; + } + if (BounceHits >= 4f) + Projectile.Kill(); + return false; } } } diff --git a/Projectiles/Ranged/DWArrow.cs b/Projectiles/Ranged/DWArrow.cs index 5c33a84398..6889561097 100644 --- a/Projectiles/Ranged/DWArrow.cs +++ b/Projectiles/Ranged/DWArrow.cs @@ -1,10 +1,10 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; -using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Ranged { @@ -38,14 +38,14 @@ namespace CalamityMod.Projectiles.Ranged } Lighting.AddLight(Projectile.Center, 0.4f, 0.2f, 0.4f); - for (int num121 = 0; num121 < 2; num121++) + for (int i = 0; i < 2; i++) { - Dust dust4 = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, Main.rand.NextBool(3) ? 56 : 242, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f)]; - dust4.velocity = Vector2.Zero; - dust4.position -= Projectile.velocity / 5f * (float)num121; - dust4.noGravity = true; - dust4.scale = 0.8f; - dust4.noLight = true; + Dust dusty = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, Main.rand.NextBool(3) ? 56 : 242, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f)]; + dusty.velocity = Vector2.Zero; + dusty.position -= Projectile.velocity / 5f * (float)i; + dusty.noGravity = true; + dusty.scale = 0.8f; + dusty.noLight = true; } } diff --git a/Projectiles/Ranged/DaemonsFlameArrow.cs b/Projectiles/Ranged/DaemonsFlameArrow.cs index 2191065834..29ee506641 100644 --- a/Projectiles/Ranged/DaemonsFlameArrow.cs +++ b/Projectiles/Ranged/DaemonsFlameArrow.cs @@ -34,20 +34,18 @@ namespace CalamityMod.Projectiles.Ranged { Projectile.velocity.Y = (float)(((double)Projectile.ai[1]) * Math.Sin(x / 4)); } - for (int num151 = 0; num151 < 2; num151++) + for (int i = 0; i < 2; i++) { - int num154 = 14; - int num155 = Dust.NewDust(new Vector2(Projectile.Center.X, Projectile.Center.Y), Projectile.width - num154 * 2, Projectile.height - num154 * 2, 60, 0f, 0f, 100, default, 1.6f); - Main.dust[num155].noGravity = true; - Main.dust[num155].velocity *= 0.1f; - Main.dust[num155].velocity += Projectile.velocity * 0.5f; + int dusty = Dust.NewDust(new Vector2(Projectile.Center.X, Projectile.Center.Y), Projectile.width - 28, Projectile.height - 28, 60, 0f, 0f, 100, default, 1.6f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].velocity *= 0.1f; + Main.dust[dusty].velocity += Projectile.velocity * 0.5f; } if (Main.rand.NextBool(13)) { - int num156 = 16; - int num157 = Dust.NewDust(new Vector2(Projectile.Center.X, Projectile.Center.Y), Projectile.width - num156 * 2, Projectile.height - num156 * 2, 60, 0f, 0f, 100, default, 1f); - Main.dust[num157].velocity *= 0.25f; - Main.dust[num157].velocity += Projectile.velocity * 0.5f; + int dusty2 = Dust.NewDust(new Vector2(Projectile.Center.X, Projectile.Center.Y), Projectile.width - 32, Projectile.height - 32, 60, 0f, 0f, 100, default, 1f); + Main.dust[dusty2].velocity *= 0.25f; + Main.dust[dusty2].velocity += Projectile.velocity * 0.5f; } } @@ -69,23 +67,23 @@ namespace CalamityMod.Projectiles.Ranged Projectile.idStaticNPCHitCooldown = 0; Projectile.Damage(); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.7f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1f); + Main.dust[dust2].velocity *= 2f; } } } diff --git a/Projectiles/Ranged/DaemonsFlameBow.cs b/Projectiles/Ranged/DaemonsFlameBow.cs index c322c7fabe..1a2fd7c368 100644 --- a/Projectiles/Ranged/DaemonsFlameBow.cs +++ b/Projectiles/Ranged/DaemonsFlameBow.cs @@ -1,7 +1,7 @@ -using CalamityMod.Items.Weapons.Ranged; +using System; +using CalamityMod.Items.Weapons.Ranged; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -33,11 +33,11 @@ namespace CalamityMod.Projectiles.Ranged { Lighting.AddLight(Projectile.Center, 0f, 0.7f, 0.5f); Player player = Main.player[Projectile.owner]; - float num = 0f; - Vector2 vector = player.RotatedRelativePoint(player.MountedCenter, true); + float pi = 0f; + Vector2 playerRotate = player.RotatedRelativePoint(player.MountedCenter, true); if (Projectile.spriteDirection == -1) { - num = 3.14159274f; + pi = 3.14159274f; } Projectile.frameCounter++; if (Projectile.frameCounter > 4) @@ -50,94 +50,93 @@ namespace CalamityMod.Projectiles.Ranged Projectile.frame = 0; } Projectile.ai[0] += 1f; - int num39 = 0; + int fireSpeed = 0; if (Projectile.ai[0] >= 30f) { - num39++; + fireSpeed++; } if (Projectile.ai[0] >= 60f) { - num39++; + fireSpeed++; } if (Projectile.ai[0] >= 90f) { - num39++; + fireSpeed++; } if (Projectile.ai[0] >= 120f) { - num39++; + fireSpeed++; } - int num40 = 24; - int num41 = 2; + int delayCompare = 24; + int fireSpeedCompare = 2; Projectile.ai[1] -= 1f; - bool flag15 = false; + bool fullSpeed = false; if (Projectile.ai[1] <= 0f) { - Projectile.ai[1] = (float)(num40 - num41 * num39); - flag15 = true; - int arg_1EF4_0 = (int)Projectile.ai[0] / (num40 - num41 * num39); + Projectile.ai[1] = (float)(delayCompare - fireSpeedCompare * fireSpeed); + fullSpeed = true; + int arg_1EF4_0 = (int)Projectile.ai[0] / (delayCompare - fireSpeedCompare * fireSpeed); } - bool flag16 = player.channel && player.HasAmmo(player.ActiveItem()) && !player.noItems && !player.CCed; + bool canUseItem = player.channel && player.HasAmmo(player.ActiveItem()) && !player.noItems && !player.CCed; if (Projectile.localAI[0] > 0f) { Projectile.localAI[0] -= 1f; } - if (Projectile.soundDelay <= 0 && flag16) + if (Projectile.soundDelay <= 0 && canUseItem) { - Projectile.soundDelay = num40 - num41 * num39; + Projectile.soundDelay = delayCompare - fireSpeedCompare * fireSpeed; if (Projectile.ai[0] != 1f) { SoundEngine.PlaySound(SoundID.Item5, Projectile.position); } Projectile.localAI[0] = 12f; } - if (flag15 && Main.myPlayer == Projectile.owner) + if (fullSpeed && Main.myPlayer == Projectile.owner) { - int num42 = ProjectileID.WoodenArrowFriendly; + int ammoType = ProjectileID.WoodenArrowFriendly; float scaleFactor11 = 14f; int weaponDamage2 = player.GetWeaponDamage(player.ActiveItem()); float weaponKnockback2 = player.ActiveItem().knockBack; - if (flag16) + if (canUseItem) { - player.PickAmmo(player.ActiveItem(), out num42, out scaleFactor11, out weaponDamage2, out weaponKnockback2, out _); + player.PickAmmo(player.ActiveItem(), out ammoType, out scaleFactor11, out weaponDamage2, out weaponKnockback2, out _); weaponKnockback2 = player.GetWeaponKnockback(player.ActiveItem(), weaponKnockback2); float scaleFactor12 = player.ActiveItem().shootSpeed * Projectile.scale; - Vector2 vector19 = vector; - Vector2 value18 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - vector19; + Vector2 shootDirection = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - playerRotate; if (player.gravDir == -1f) { - value18.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - vector19.Y; + shootDirection.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - playerRotate.Y; } - Vector2 value19 = Vector2.Normalize(value18); - if (float.IsNaN(value19.X) || float.IsNaN(value19.Y)) + Vector2 normalizeShoot = Vector2.Normalize(shootDirection); + if (float.IsNaN(normalizeShoot.X) || float.IsNaN(normalizeShoot.Y)) { - value19 = -Vector2.UnitY; + normalizeShoot = -Vector2.UnitY; } - value19 *= scaleFactor12; - if (value19.X != Projectile.velocity.X || value19.Y != Projectile.velocity.Y) + normalizeShoot *= scaleFactor12; + if (normalizeShoot.X != Projectile.velocity.X || normalizeShoot.Y != Projectile.velocity.Y) { Projectile.netUpdate = true; } - Projectile.velocity = value19 * 0.55f; - for (int num43 = 0; num43 < 4; num43++) + Projectile.velocity = normalizeShoot * 0.55f; + for (int i = 0; i < 4; i++) { - Vector2 vector20 = Vector2.Normalize(Projectile.velocity) * scaleFactor11 * (0.6f + Main.rand.NextFloat() * 0.8f); - if (float.IsNaN(vector20.X) || float.IsNaN(vector20.Y)) + Vector2 randNormalize = Vector2.Normalize(Projectile.velocity) * scaleFactor11 * (0.6f + Main.rand.NextFloat() * 0.8f); + if (float.IsNaN(randNormalize.X) || float.IsNaN(randNormalize.Y)) { - vector20 = -Vector2.UnitY; + randNormalize = -Vector2.UnitY; } - Vector2 vector21 = vector19 + Utils.RandomVector2(Main.rand, -15f, 15f); - int num44 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), vector21.X, vector21.Y, vector20.X, vector20.Y, num42, weaponDamage2, weaponKnockback2, Projectile.owner, 0f, 0f); - Main.projectile[num44].noDropItem = true; + Vector2 projRandomPos = playerRotate + Utils.RandomVector2(Main.rand, -15f, 15f); + int proj = Projectile.NewProjectile(Projectile.GetSource_FromThis(), projRandomPos.X, projRandomPos.Y, randNormalize.X, randNormalize.Y, ammoType, weaponDamage2, weaponKnockback2, Projectile.owner, 0f, 0f); + Main.projectile[proj].noDropItem = true; } - Vector2 vector2 = Vector2.Normalize(Projectile.velocity) * scaleFactor11 * (0.6f + Main.rand.NextFloat() * 0.8f); - if (float.IsNaN(vector2.X) || float.IsNaN(vector2.Y)) + Vector2 daemonNormalize = Vector2.Normalize(Projectile.velocity) * scaleFactor11 * (0.6f + Main.rand.NextFloat() * 0.8f); + if (float.IsNaN(daemonNormalize.X) || float.IsNaN(daemonNormalize.Y)) { - vector2 = -Vector2.UnitY; + daemonNormalize = -Vector2.UnitY; } - float speedY = vector2.Y; - Vector2 vector3 = vector19 + Utils.RandomVector2(Main.rand, -15f, 15f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), vector3.X, vector3.Y, vector2.X, vector2.Y, ModContent.ProjectileType(), weaponDamage2, weaponKnockback2, Projectile.owner, 0.0f, speedY); + float speedY = daemonNormalize.Y; + Vector2 daemonRandomPos = playerRotate + Utils.RandomVector2(Main.rand, -15f, 15f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), daemonRandomPos.X, daemonRandomPos.Y, daemonNormalize.X, daemonNormalize.Y, ModContent.ProjectileType(), weaponDamage2, weaponKnockback2, Projectile.owner, 0.0f, speedY); } else { @@ -145,7 +144,7 @@ namespace CalamityMod.Projectiles.Ranged } } Projectile.position = player.RotatedRelativePoint(player.MountedCenter, true) - Projectile.Size / 2f; - Projectile.rotation = Projectile.velocity.ToRotation() + num; + Projectile.rotation = Projectile.velocity.ToRotation() + pi; Projectile.spriteDirection = Projectile.direction; Projectile.timeLeft = 2; player.ChangeDir(Projectile.direction); @@ -158,14 +157,14 @@ namespace CalamityMod.Projectiles.Ranged public override void PostDraw(Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; Vector2 origin = new Vector2(27f, 58f); SpriteEffects spriteEffects = SpriteEffects.None; if (Projectile.spriteDirection == -1) spriteEffects = SpriteEffects.FlipHorizontally; - Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Ranged/DaemonsFlameBowGlow").Value, Projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Color.White, Projectile.rotation, origin, Projectile.scale, spriteEffects, 0); + Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Ranged/DaemonsFlameBowGlow").Value, Projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Color.White, Projectile.rotation, origin, Projectile.scale, spriteEffects, 0); } public override bool? CanDamage() => false; diff --git a/Projectiles/Ranged/DeadSunExplosion.cs b/Projectiles/Ranged/DeadSunExplosion.cs new file mode 100644 index 0000000000..9b8f99b9ea --- /dev/null +++ b/Projectiles/Ranged/DeadSunExplosion.cs @@ -0,0 +1,63 @@ +using System; +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.Ranged +{ + public class DeadSunExplosion : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Player Owner => Main.player[Projectile.owner]; + public ref float ExplosionRadius => ref Projectile.ai[0]; + public Color color1 = Color.LightGreen; + public Color color2 = Color.Black; + public override void SetDefaults() + { + //These shouldn't matter because its circular + Projectile.width = 100; + Projectile.height = 100; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 2; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + } + public override void AI() + { + Particle explosion = new DetailedExplosion(Projectile.Center, Vector2.Zero, color1, Vector2.One, Main.rand.NextFloat(-5, 5), 0f, ExplosionRadius * 0.0065f + 0.1f, Main.rand.Next(15, 22)); + GeneralParticleHandler.SpawnParticle(explosion); + Particle explosion2 = new DetailedExplosion(Projectile.Center, Vector2.Zero, Color.Black, Vector2.One, Main.rand.NextFloat(-5, 5), 0f, ExplosionRadius * 0.0045f + 0.1f, Main.rand.Next(15, 22), false); + GeneralParticleHandler.SpawnParticle(explosion2); + Particle explosion3 = new DetailedExplosion(Projectile.Center, Vector2.Zero, Color.Black, Vector2.One, Main.rand.NextFloat(-5, 5), 0f, ExplosionRadius * 0.0030f + 0.1f, Main.rand.Next(15, 22), false); + GeneralParticleHandler.SpawnParticle(explosion3); + Particle orb = new GenericBloom(Projectile.Center, Projectile.velocity, color1, ExplosionRadius * 0.0085f + 0.05f, 10, true); + GeneralParticleHandler.SpawnParticle(orb); + Particle orb2 = new GenericBloom(Projectile.Center, Projectile.velocity, color2, ExplosionRadius * 0.006f + 0.05f, 10, true, true); + GeneralParticleHandler.SpawnParticle(orb2); + float numberOfDusts = ExplosionRadius * 0.1f + 10; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) + { + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 offset = (Vector2.UnitX * Main.rand.NextFloat(ExplosionRadius * 0.2f, 3.1f)).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + Vector2 velOffset = (Vector2.UnitX * Main.rand.NextFloat(ExplosionRadius * 0.2f, 3.1f)).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, Main.rand.NextBool(4) ? 263 : Projectile.ai[1] == 5 ? 278 : 66, velOffset); + dust.noGravity = dust.type == 278? false : true; + dust.color = color1; + dust.velocity = velOffset; + dust.scale = dust.type == 278 ? Main.rand.NextFloat(0.7f, 1.3f) : Main.rand.NextFloat(1.6f, 2.2f); + } + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, ExplosionRadius + 20, targetHitbox); + } +} diff --git a/Projectiles/Ranged/DragonsBreathFlames.cs b/Projectiles/Ranged/DragonsBreathFlames.cs new file mode 100644 index 0000000000..430e8d8285 --- /dev/null +++ b/Projectiles/Ranged/DragonsBreathFlames.cs @@ -0,0 +1,195 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Graphics.Metaballs; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class DragonsBreathFlames : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public int Time = 0; + public float beamWidth = 1.1f; + public bool beamsize = false; + public float bbbBONUSbeamSizeWOAHH = 50; + public bool postHit = false; + public int beamWeldBloomReduction = 0; + public ref int audioCooldown => ref Main.player[Projectile.owner].Calamity().DragonsBreathAudioCooldown; + + public override void SetDefaults() + { + Projectile.width = 10; + Projectile.height = 10; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.extraUpdates = 6; + Projectile.penetrate = -1; + Projectile.timeLeft = 500; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + public override void AI() + { + Vector3 Light = Projectile.ai[0] == 1 ? new Vector3(0.255f, 0.080f, 0.080f) : new Vector3(0.255f, 0.060f, 0.000f); + Lighting.AddLight(Projectile.Center, Light * (Projectile.ai[0] == 1 ? 5 : 3)); + + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); //used for some drawing prevention for when it's offscreen + if (beamWidth <= 0.9f) + { + beamsize = true; + } + if (beamWidth >= 1.1f) + { + beamsize = false; + } + beamWidth += (beamsize ? 0.02f : -0.02f); + Time++; + if (Projectile.ai[0] == 0) //Fireball Mode + { + if (Time == 16) + { + for (int i = 0; i <= 7; i++) + { + int DustType1 = 259; + Vector2 dustyVelocity = Projectile.velocity * 4f; + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? DustType1 : 174); + dust.scale = dust.type == DustType1 ? Main.rand.NextFloat(0.9f, 1.9f) : Main.rand.NextFloat(0.8f, 1.7f); + dust.velocity = dustyVelocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.3f, 0.8f); + dust.noGravity = true; + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? DustType1 : 174); + dust2.scale = dust.type == DustType1 ? Main.rand.NextFloat(0.85f, 1.8f) : Main.rand.NextFloat(0.75f, 1.6f); + dust2.velocity = dustyVelocity.RotatedByRandom(0.15f) * Main.rand.NextFloat(0.8f, 2.1f); + dust2.noGravity = true; + } + for (int i = 0; i <= 5; i++) + { + Vector2 smokeVel = Projectile.velocity * 4.2f; + float rotationAngle = Main.rand.NextFloat(-0.15f, 0.15f); + smokeVel = smokeVel.RotatedBy(rotationAngle) * Main.rand.NextFloat(0.45f, 1.3f); + + float smokeScale = Main.rand.NextFloat(0.4f, 1.2f); + + SmallSmokeParticle smoke = new SmallSmokeParticle(Projectile.Center, smokeVel, Color.DimGray, Main.rand.NextBool() ? Color.SlateGray : Color.Black, smokeScale, 100); + GeneralParticleHandler.SpawnParticle(smoke); + } + } + if (Time % 5 == 0 && Time > 35f && targetDist < 1400f) + { + SparkParticle spark = new SparkParticle(Projectile.Center + Main.rand.NextVector2Circular(1 + (Time * 0.3f), 1 + (Time * 0.3f)), -Projectile.velocity * 0.5f, false, 15, Main.rand.NextFloat(0.4f, 0.7f), Main.rand.NextBool() ? Color.DarkOrange : Color.OrangeRed); + GeneralParticleHandler.SpawnParticle(spark); + } + if (targetDist < 1400f) + { + ModContent.GetInstance().SpawnParticle(Projectile.Center, Time * 0.9f); + ModContent.GetInstance().SpawnParticle(Projectile.Center + Projectile.velocity, Time * 0.85f); + } + Projectile.velocity *= 1.01f; + } + if (Projectile.ai[0] == 1) //Welding Mode + { + if (bbbBONUSbeamSizeWOAHH > 0) + bbbBONUSbeamSizeWOAHH -= 0.65f; + Projectile.extraUpdates = 170; + + if (Time > 13) + { + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(8, 8), Main.rand.NextBool(3) ? 162 : 259); + dust2.scale = Main.rand.NextFloat(0.3f, 0.5f); + dust2.noGravity = true; + if (Main.rand.NextBool(6)) + { + dust2.velocity = new Vector2(0, Main.rand.NextFloat(-1, -13)); + } + if (targetDist < 1400f) + { + ModContent.GetInstance().SpawnParticle(Projectile.Center, beamWidth * 46 + bbbBONUSbeamSizeWOAHH); + ModContent.GetInstance().SpawnParticle(Projectile.Center, beamWidth * 45 + bbbBONUSbeamSizeWOAHH); + } + } + if (Time == 13) + { + for (int i = 0; i <= 4; i++) + { + Vector2 sparkVelocity = Projectile.velocity * 6; + + float sparkScale1 = Main.rand.NextFloat(0.3f, 0.8f); + Vector2 sparkvelocity1 = sparkVelocity.RotatedByRandom(0.45f) * Main.rand.NextFloat(0.4f, 0.95f); + SparkParticle spark1 = new SparkParticle(Projectile.Center, sparkvelocity1, false, 6, sparkScale1, Main.rand.NextBool() ? Color.DarkOrange : Color.OrangeRed); + GeneralParticleHandler.SpawnParticle(spark1); + + float sparkScale2 = Main.rand.NextFloat(0.4f, 1f); + Vector2 sparkvelocity2 = sparkVelocity.RotatedByRandom(0.2f) * Main.rand.NextFloat(1.1f, 3.1f); + SparkParticle spark2 = new SparkParticle(Projectile.Center, sparkvelocity2, false, 6, sparkScale2, Main.rand.NextBool() ? Color.DarkOrange : Color.OrangeRed); + GeneralParticleHandler.SpawnParticle(spark2); + } + } + } + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (Projectile.ai[0] == 1) + { + if (beamWeldBloomReduction < 3) + { + if (audioCooldown == 0) + { + SoundEngine.PlaySound(DragonsBreath.WeldingBurn, Projectile.Center); + audioCooldown = 12; + } + float OrbSize = Main.rand.NextFloat(0.5f, 0.8f) - beamWeldBloomReduction * 0.14f; + Particle orb = new GenericBloom(target.Center, Vector2.Zero, Color.OrangeRed, OrbSize + 0.6f, 8, true); + GeneralParticleHandler.SpawnParticle(orb); + Particle orb2 = new GenericBloom(target.Center, Vector2.Zero, Color.White, OrbSize + 0.2f, 8, true); + GeneralParticleHandler.SpawnParticle(orb2); + if (!postHit) + { + for (int i = 0; i < 3; i++) + { + Vector2 SpawnPosition = target.Center + Main.rand.NextVector2Circular(target.width, target.height) * 0.04f; + Vector2 splatterDirection = (Projectile.Center - SpawnPosition).SafeNormalize(Vector2.UnitY); + int sparkLifetime = Main.rand.Next(22, 36); + float sparkScale = Main.rand.NextFloat(0.8f, 1.3f); + Color sparkColor = Main.rand.NextBool(4) ? Color.OrangeRed : Color.Orange; + Vector2 sparkVelocity = splatterDirection.RotatedByRandom(0.6f) * Main.rand.NextFloat(12f, 25f); + SparkParticle spark = new SparkParticle(target.Center, sparkVelocity, true, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); + } + postHit = true; + } + beamWeldBloomReduction++; + } + target.AddBuff(ModContent.BuffType(), 420); + } + else if (!postHit) + { + for (int i = 0; i <= 6; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.position - Projectile.velocity * 0.5f, Main.rand.NextBool(3) ? 293 : 174, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.5f, 3.5f), 0, default, Main.rand.NextFloat(1.6f, 2.3f)); + dust.noGravity = true; + Dust dust2 = Dust.NewDustPerfect(Projectile.position - Projectile.velocity * 0.5f, Main.rand.NextBool(3) ? 293 : 174, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(5f)) * Main.rand.NextFloat(0.8f, 5.8f), 0, default, Main.rand.NextFloat(1.6f, 2.3f)); + dust2.noGravity = true; + } + postHit = true; + } + target.AddBuff(ModContent.BuffType(), 240); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.ai[1] == 1 ? 4 : Projectile.width + Time * 0.1f, targetHitbox); + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.80f); // 20% damage nerf for every enemy hit + if (Projectile.damage < 1) + Projectile.damage = 1; + } + } +} diff --git a/Projectiles/Ranged/DragonsBreathMag.cs b/Projectiles/Ranged/DragonsBreathMag.cs new file mode 100644 index 0000000000..0908d58da1 --- /dev/null +++ b/Projectiles/Ranged/DragonsBreathMag.cs @@ -0,0 +1,81 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using static Humanizer.In; + +namespace CalamityMod.Projectiles.Ranged +{ + public class DragonsBreathMag : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/Ranged/DragonsBreathMag"; + public int Time = 0; + public bool TouchedGrass = false; + + public override void SetDefaults() + { + Projectile.width = 16; + Projectile.height = 10; + Projectile.friendly = true; + Projectile.ignoreWater = false; + Projectile.DamageType = DamageClass.Ranged; + Projectile.aiStyle = ProjAIStyleID.GroundProjectile; + Projectile.penetrate = -1; + Projectile.timeLeft = 700; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + public override void SetStaticDefaults() + { + // Unsure if it will look good with these + //ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8; + //ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + } + public override bool PreDraw(ref Color lightColor) + { + //CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1, ModContent.Request("CalamityMod/Projectiles/Ranged/DragonsBreathMag").Value); + return true; + } + public override void AI() + { + Projectile.extraUpdates = 0; + Time++; + Player Owner = Main.player[Projectile.owner]; + if (!TouchedGrass) + { + Projectile.rotation += 0.5f * (float)Projectile.direction; + } + Projectile.velocity.Y -= 0.055f; + Projectile.velocity.X *= 0.992f; + } + public override bool OnTileCollide(Vector2 oldVelocity) + { + Projectile.damage = 0; + TouchedGrass = true; + Projectile.velocity *= 0.98f; + return false; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (Main.zenithWorld) + { + for (int i = 0; i <= 30; i++) + { + SparkParticle spark1 = new SparkParticle(Projectile.Center, new Vector2(4, 4).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 2.8f), false, 45, 1.4f, Main.rand.NextBool(4) ? Color.Orange : Color.OrangeRed); + GeneralParticleHandler.SpawnParticle(spark1); + } + Particle explosion = new DetailedExplosion(Projectile.Center, Vector2.Zero, Color.DarkOrange, Vector2.One, Main.rand.NextFloat(-5, 5), 0f, 2.8f, 33); + GeneralParticleHandler.SpawnParticle(explosion); + Particle explosion2 = new DetailedExplosion(Projectile.Center, Vector2.Zero, Color.OrangeRed, Vector2.One, Main.rand.NextFloat(-5, 5), 0f, 3f, 33, false); + GeneralParticleHandler.SpawnParticle(explosion2); + } + target.AddBuff(ModContent.BuffType(), 20); + } + } +} diff --git a/Projectiles/Ranged/DragonsBreathMag.png b/Projectiles/Ranged/DragonsBreathMag.png new file mode 100644 index 0000000000..e17cb6edf4 Binary files /dev/null and b/Projectiles/Ranged/DragonsBreathMag.png differ diff --git a/Projectiles/Ranged/DragonsBreathRound.cs b/Projectiles/Ranged/DragonsBreathRound.cs deleted file mode 100644 index 7f1b358ae6..0000000000 --- a/Projectiles/Ranged/DragonsBreathRound.cs +++ /dev/null @@ -1,82 +0,0 @@ -using CalamityMod.Projectiles.Typeless; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -using CalamityMod.Buffs.DamageOverTime; - -namespace CalamityMod.Projectiles.Ranged -{ - public class DragonsBreathRound : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10; - ProjectileID.Sets.TrailingMode[Projectile.type] = 0; - } - - public override void SetDefaults() - { - Projectile.width = 4; - Projectile.height = 4; - Projectile.friendly = true; - Projectile.extraUpdates = 10; - Projectile.penetrate = 1; - Projectile.timeLeft = 180; - Projectile.DamageType = DamageClass.Ranged; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; - } - - public override void AI() - { - //Rotation - Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); - Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) +MathHelper.ToRadians(90) * Projectile.direction; - - Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] > 4f) - { - float num93 = Projectile.velocity.X / 3f; - float num94 = Projectile.velocity.Y / 3f; - int num95 = 4; - int idx = Dust.NewDust(new Vector2(Projectile.position.X + (float)num95, Projectile.position.Y + (float)num95), Projectile.width - num95 * 2, Projectile.height - num95 * 2, 127, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[idx]; - dust.noGravity = true; - dust.velocity *= 0.1f; - dust.velocity += Projectile.velocity * 0.1f; - dust.position.X -= num93; - dust.position.Y -= num94; - - if (Main.rand.NextBool(20)) - { - int num97 = 4; - int num98 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num97, Projectile.position.Y + (float)num97), Projectile.width - num97 * 2, Projectile.height - num97 * 2, 127, 0f, 0f, 100, default, 0.6f); - Main.dust[num98].velocity *= 0.25f; - Main.dust[num98].velocity += Projectile.velocity * 0.5f; - } - } - } - - public override void OnKill(int timeLeft) - { - if (Projectile.owner == Main.myPlayer) - { - int proj = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].DamageType = DamageClass.Ranged; - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 300); - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor); - return false; - } - } -} diff --git a/Projectiles/Ranged/DragonsBreathRound.png b/Projectiles/Ranged/DragonsBreathRound.png deleted file mode 100644 index 2599eb14ac..0000000000 Binary files a/Projectiles/Ranged/DragonsBreathRound.png and /dev/null differ diff --git a/Projectiles/Ranged/DrataliornusBow.cs b/Projectiles/Ranged/DrataliornusBow.cs index a2d518423c..1f636193d9 100644 --- a/Projectiles/Ranged/DrataliornusBow.cs +++ b/Projectiles/Ranged/DrataliornusBow.cs @@ -54,15 +54,15 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localAI[0]++; Projectile.ai[0] = -1f; //fully spun up, don't need timer anymore - const int num226 = 36; //dusts indicate fully spun up - for (int num227 = 0; num227 < num226; num227++) + const int constant = 36; //dusts indicate fully spun up + for (int i = 0; i < constant; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * 9f; - vector6 = vector6.RotatedBy((num227 - (num226 / 2 - 1)) * 6.28318548f / num226, default) + player.Center; - Vector2 vector7 = vector6 - player.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 127, 0f, 0f, 0, default, 4f); - Main.dust[num228].noGravity = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * 9f; + rotate = rotate.RotatedBy((i - (constant / 2 - 1)) * 6.28318548f / constant, default) + player.Center; + Vector2 faceDirection = rotate - player.Center; + int dust = Dust.NewDust(rotate + faceDirection, 0, 0, 127, 0f, 0f, 0, default, 4f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity = faceDirection; } break; } diff --git a/Projectiles/Ranged/DrataliornusExoArrow.cs b/Projectiles/Ranged/DrataliornusExoArrow.cs index 44e73ce968..97ec9ede47 100644 --- a/Projectiles/Ranged/DrataliornusExoArrow.cs +++ b/Projectiles/Ranged/DrataliornusExoArrow.cs @@ -35,19 +35,18 @@ namespace CalamityMod.Projectiles.Ranged { Projectile.alpha = 0; } - float num55 = 100f; - float num56 = 3f; + float inc = 3f; if (Projectile.ai[1] == 0f) { - Projectile.localAI[0] += num56; - if (Projectile.localAI[0] > num55) + Projectile.localAI[0] += inc; + if (Projectile.localAI[0] > 100f) { - Projectile.localAI[0] = num55; + Projectile.localAI[0] = 100f; } } else { - Projectile.localAI[0] -= num56; + Projectile.localAI[0] -= inc; if (Projectile.localAI[0] <= 0f) { Projectile.Kill(); diff --git a/Projectiles/Ranged/DrataliornusFlame.cs b/Projectiles/Ranged/DrataliornusFlame.cs index 43a8581e8e..c80e073847 100644 --- a/Projectiles/Ranged/DrataliornusFlame.cs +++ b/Projectiles/Ranged/DrataliornusFlame.cs @@ -158,10 +158,10 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.ai[0] != 0f && Projectile.owner == Main.myPlayer) //if empowered, make exo arrow and dragon dust { - Vector2 vector3 = Projectile.Center + new Vector2(600, 0).RotatedBy(MathHelper.ToRadians(Main.rand.Next(360))); - Vector2 speed = Projectile.Center - vector3; + Vector2 randomAngle = Projectile.Center + new Vector2(600, 0).RotatedBy(MathHelper.ToRadians(Main.rand.Next(360))); + Vector2 speed = Projectile.Center - randomAngle; speed /= 30f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), vector3.X, vector3.Y, speed.X, speed.Y, ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), randomAngle.X, randomAngle.Y, speed.X, speed.Y, ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack, Projectile.owner); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage / 3, Projectile.knockBack * 2f, Projectile.owner); } @@ -173,30 +173,30 @@ namespace CalamityMod.Projectiles.Ranged Projectile.position.Y = Projectile.position.Y - 90; //just dusts - const int num226 = 24; + const int constant = 24; float modifier = 4f + 8f * Main.rand.NextFloat(); - for (int num227 = 0; num227 < num226; num227++) + for (int i = 0; i < constant; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * modifier; - vector6 = vector6.RotatedBy((num227 - (num226 / 2 - 1)) * 6.28318548f / num226, default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 174, 0f, 0f, 45, default, 2f); - Main.dust[num228].noGravity = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * modifier; + rotate = rotate.RotatedBy((i - (constant / 2 - 1)) * 6.28318548f / constant, default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int dust = Dust.NewDust(rotate + faceDirection, 0, 0, 174, 0f, 0f, 45, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity = faceDirection; } - for (int num193 = 0; num193 < 4; num193++) + for (int j = 0; j < 4; j++) { Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 174, 0f, 0f, 50, default, 1.5f); - int num195 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 174, 0f, 0f, 50, default, 1f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 2f; + int fieryDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 174, 0f, 0f, 50, default, 1f); + Main.dust[fieryDust].noGravity = true; + Main.dust[fieryDust].velocity *= 2f; } - for (int num194 = 0; num194 < 12; num194++) + for (int k = 0; k < 12; k++) { - int num195 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 127, 0f, 0f, 0, default, 3f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; + int fieryDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 127, 0f, 0f, 0, default, 3f); + Main.dust[fieryDust].noGravity = true; + Main.dust[fieryDust].velocity *= 3f; } Projectile.timeLeft = 0; //should avoid infinite loop if a hit npc calls proj.Kill() @@ -217,10 +217,10 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.timeLeft != 0) //will not be called on npcs hit by explosion (only direct hits) { //make exo arrow, make meteor - Vector2 vector3 = target.Center + new Vector2(600, 0).RotatedBy(MathHelper.ToRadians(Main.rand.Next(360))); - Vector2 speed = target.Center - vector3; + Vector2 randomAngle = target.Center + new Vector2(600, 0).RotatedBy(MathHelper.ToRadians(Main.rand.Next(360))); + Vector2 speed = target.Center - randomAngle; speed /= 30f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), vector3.X, vector3.Y, speed.X, speed.Y, ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), randomAngle.X, randomAngle.Y, speed.X, speed.Y, ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack, Projectile.owner); Vector2 vel = new Vector2(Main.rand.Next(-400, 401), Main.rand.Next(500, 801)); Vector2 pos = target.Center - vel; @@ -243,10 +243,10 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.timeLeft != 0) //will not be called on npcs hit by explosion (only direct hits) { //make exo arrow, make meteor - Vector2 vector3 = target.Center + new Vector2(600, 0).RotatedBy(MathHelper.ToRadians(Main.rand.Next(360))); - Vector2 speed = target.Center - vector3; + Vector2 randomAngle = target.Center + new Vector2(600, 0).RotatedBy(MathHelper.ToRadians(Main.rand.Next(360))); + Vector2 speed = target.Center - randomAngle; speed /= 30f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), vector3.X, vector3.Y, speed.X, speed.Y, ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), randomAngle.X, randomAngle.Y, speed.X, speed.Y, ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack, Projectile.owner); Vector2 vel = new Vector2(Main.rand.Next(-400, 401), Main.rand.Next(500, 801)); Vector2 pos = target.Center - vel; diff --git a/Projectiles/Ranged/DrizzlefishFire.cs b/Projectiles/Ranged/DrizzlefishFire.cs index 74defbd5af..f86cce2045 100644 --- a/Projectiles/Ranged/DrizzlefishFire.cs +++ b/Projectiles/Ranged/DrizzlefishFire.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Fishing.BrimstoneCragCatches; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -9,7 +10,8 @@ namespace CalamityMod.Projectiles.Ranged public class DrizzlefishFire : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - private int splitTimer = 30; + private int splitTimer = 45; + public int Time = 0; public override void SetDefaults() { @@ -18,15 +20,28 @@ namespace CalamityMod.Projectiles.Ranged Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 5; + Projectile.penetrate = -1; Projectile.extraUpdates = 1; Projectile.timeLeft = 90; Projectile.usesIDStaticNPCImmunity = true; Projectile.idStaticNPCHitCooldown = 10; } - + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8; + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + } public override bool PreDraw(ref Color lightColor) { + if (Time < 7) + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1, ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value); + else + { + if (Projectile.ai[1] == 1f) + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1, ModContent.Request("CalamityMod/Projectiles/Ranged/DrizzlefishFire2").Value); + else + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1, ModContent.Request("CalamityMod/Projectiles/Ranged/DrizzlefishFire").Value); + } //Changes the texture of the projectile if (Projectile.ai[1] == 1f) { @@ -39,21 +54,79 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { + Time++; + Player Owner = Main.player[Projectile.owner]; + if (Main.zenithWorld && Time == 1 && Owner.Calamity().dragoonDrizzlefishGelBoost > 1) + Projectile.damage = (int)(Projectile.damage * Owner.Calamity().dragoonDrizzlefishGelBoost); + Projectile.scale = 1.5f; int dustType = 235; + int dustType2 = 235; if (Projectile.ai[1] == 1f) { if (Main.rand.NextBool()) { - dustType = 35; + dustType = 174; } else { - dustType = 55; + dustType = 162; } } else { - dustType = 235; + if (Main.rand.NextBool()) + { + dustType = 183; + } + else + { + dustType = 90; + } + } + if (Time > 7) + { + Projectile.alpha = 0; + for (int i = 0; i < 5; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(9, 9) - Projectile.velocity * 1.5f, dustType, -Projectile.velocity); + dust.noGravity = true; + dust.velocity *= 0f; + dust.scale = Owner.Calamity().dragoonDrizzlefishGelBoost > 1 ? Main.rand.NextFloat(0.7f + Owner.Calamity().dragoonDrizzlefishGelBoost * 0.5f, 1.4f + Owner.Calamity().dragoonDrizzlefishGelBoost * 0.5f) : Main.rand.NextFloat(1.2f, 1.9f); + } + } + else + Projectile.alpha = 255; + if (Time == 4) + { + for (int i = 0; i <= 16; i++) + { + if (Projectile.ai[1] == 1f) + { + if (Main.rand.NextBool()) + { + dustType2 = 174; + } + else + { + dustType2 = 162; + } + } + else + { + if (Main.rand.NextBool()) + { + dustType2 = 183; + } + else + { + dustType2 = 90; + } + } + Dust dust = Dust.NewDustPerfect(Projectile.Center, dustType2, Projectile.velocity); + dust.scale = Main.rand.NextFloat(1.8f, 2.3f); + dust.velocity = Projectile.velocity.RotatedByRandom(1.1f) * Main.rand.NextFloat(0.6f, 1.9f); + dust.noGravity = true; + } } splitTimer--; if (splitTimer <= 0) @@ -86,57 +159,14 @@ namespace CalamityMod.Projectiles.Ranged { Projectile.timeLeft = 90; } - if (Projectile.ai[0] > 7f) - { - float num296 = 1f; - if (Projectile.ai[0] == 8f) - { - num296 = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - num296 = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - num296 = 0.75f; - } - Projectile.ai[0] += 1f; - for (int num298 = 0; num298 < 2; num298++) - { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - if (Main.rand.NextBool(3)) - { - Main.dust[num299].noGravity = true; - Main.dust[num299].scale *= 2.5f; - Dust expr_DBEF_cp_0 = Main.dust[num299]; - expr_DBEF_cp_0.velocity.X *= 2f; - Dust expr_DC0F_cp_0 = Main.dust[num299]; - expr_DC0F_cp_0.velocity.Y *= 2f; - } - else - { - Main.dust[num299].scale *= 2f; - } - Dust expr_DC74_cp_0 = Main.dust[num299]; - expr_DC74_cp_0.velocity.X *= 1.2f; - Dust expr_DC94_cp_0 = Main.dust[num299]; - expr_DC94_cp_0.velocity.Y *= 1.2f; - Main.dust[num299].scale *= num296; - } - } - else - { - Projectile.ai[0] += 1f; - } - Projectile.rotation += 0.3f * (float)Projectile.direction; + Projectile.rotation += 0.5f * (float)Projectile.direction; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { if (Projectile.ai[1] == 1f) { - target.AddBuff(BuffID.OnFire, 180); + target.AddBuff(BuffID.OnFire3, 120); } else { diff --git a/Projectiles/Ranged/DrizzlefishFireSplit.cs b/Projectiles/Ranged/DrizzlefishFireSplit.cs index 1cdd80e6ed..8ab731eafa 100644 --- a/Projectiles/Ranged/DrizzlefishFireSplit.cs +++ b/Projectiles/Ranged/DrizzlefishFireSplit.cs @@ -1,15 +1,20 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; +using static Humanizer.In; + namespace CalamityMod.Projectiles.Ranged { public class DrizzlefishFireSplit : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/Ranged/DrizzlefishFire"; + public int Time = 0; public override void SetDefaults() { @@ -18,14 +23,20 @@ namespace CalamityMod.Projectiles.Ranged Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 5; + Projectile.penetrate = 1; Projectile.timeLeft = 90; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 15; } - + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8; + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + } public override bool PreDraw(ref Color lightColor) { + if (Projectile.ai[1] == 1f) + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1, ModContent.Request("CalamityMod/Projectiles/Ranged/DrizzlefishFire2").Value); + else + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1, ModContent.Request("CalamityMod/Projectiles/Ranged/DrizzlefishFire").Value); //Changes the texture of the projectile if (Projectile.ai[1] == 1f) { @@ -38,70 +49,47 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { + Time++; + Player Owner = Main.player[Projectile.owner]; + if (Main.zenithWorld && Time == 1 && Owner.Calamity().dragoonDrizzlefishGelBoost > 1) + Projectile.damage = (int)(Projectile.damage * Owner.Calamity().dragoonDrizzlefishGelBoost); + Projectile.velocity.X *= 0.98f; + Projectile.velocity.Y += 0.5f; int dustType = 235; if (Projectile.ai[1] == 1f) { if (Main.rand.NextBool()) { - dustType = 35; + dustType = 174; } else { - dustType = 55; + dustType = 162; } } else { - dustType = 235; + if (Main.rand.NextBool()) + { + dustType = 183; + } + else + { + dustType = 90; + } + } + for (int i = 0; i < 2; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(4, 4) - Projectile.velocity * 1.5f, dustType, -Projectile.velocity); + dust.noGravity = true; + dust.velocity *= 0f; + dust.scale = Owner.Calamity().dragoonDrizzlefishGelBoost > 1 ? Main.rand.NextFloat(0f + Owner.Calamity().dragoonDrizzlefishGelBoost * 0.5f, 0.3f + Owner.Calamity().dragoonDrizzlefishGelBoost * 0.5f) : Main.rand.NextFloat(0.4f, 0.8f); } Lighting.AddLight(Projectile.Center, 0.25f, 0f, 0f); if (Projectile.timeLeft > 90) { Projectile.timeLeft = 90; } - if (Projectile.ai[0] > 7f) - { - float num296 = 1f; - if (Projectile.ai[0] == 8f) - { - num296 = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - num296 = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - num296 = 0.75f; - } - Projectile.ai[0] += 1f; - for (int num298 = 0; num298 < 2; num298++) - { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - if (Main.rand.NextBool(3)) - { - Main.dust[num299].noGravity = true; - Main.dust[num299].scale *= 2.5f; - Dust expr_DBEF_cp_0 = Main.dust[num299]; - expr_DBEF_cp_0.velocity.X *= 2f; - Dust expr_DC0F_cp_0 = Main.dust[num299]; - expr_DC0F_cp_0.velocity.Y *= 2f; - } - else - { - Main.dust[num299].scale *= 2f; - } - Dust expr_DC74_cp_0 = Main.dust[num299]; - expr_DC74_cp_0.velocity.X *= 1.2f; - Dust expr_DC94_cp_0 = Main.dust[num299]; - expr_DC94_cp_0.velocity.Y *= 1.2f; - Main.dust[num299].scale *= num296; - } - } - else - { - Projectile.ai[0] += 1f; - } Projectile.rotation += 0.3f * (float)Projectile.direction; } @@ -109,12 +97,48 @@ namespace CalamityMod.Projectiles.Ranged { if (Projectile.ai[1] == 1f) { - target.AddBuff(BuffID.OnFire, 120); + target.AddBuff(BuffID.OnFire3, 60); } else { target.AddBuff(ModContent.BuffType(), 30); } } + public override void OnKill(int timeLeft) + { + Player Owner = Main.player[Projectile.owner]; + int dustType = 235; + for (int i = 0; i <= 9; i++) + { + if (Projectile.ai[1] == 1f) + { + if (Main.rand.NextBool()) + { + dustType = 174; + } + else + { + dustType = 162; + } + } + else + { + if (Main.rand.NextBool()) + { + dustType = 183; + } + else + { + dustType = 90; + } + } + Dust dust = Dust.NewDustPerfect(Projectile.Center, dustType, new Vector2(0, -5).RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.1f, 1.9f)); + dust.noGravity = false; + dust.scale = Owner.Calamity().dragoonDrizzlefishGelBoost > 1 ? Main.rand.NextFloat(0f + Owner.Calamity().dragoonDrizzlefishGelBoost * 0.5f, 0.6f + Owner.Calamity().dragoonDrizzlefishGelBoost * 0.5f) : Main.rand.NextFloat(0.4f, 1.1f); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, dustType, new Vector2(0, -3).RotatedByRandom(MathHelper.ToRadians(25f)) * Main.rand.NextFloat(0.1f, 1.9f)); + dust2.noGravity = false; + dust2.scale = Owner.Calamity().dragoonDrizzlefishGelBoost > 1 ? Main.rand.NextFloat(0f + Owner.Calamity().dragoonDrizzlefishGelBoost * 0.5f, 0.6f + Owner.Calamity().dragoonDrizzlefishGelBoost * 0.5f) : Main.rand.NextFloat(0.4f, 1.1f); + } + } } } diff --git a/Projectiles/Ranged/DrizzlefishFireball.cs b/Projectiles/Ranged/DrizzlefishFireball.cs index 60f9d30381..864bcdaa33 100644 --- a/Projectiles/Ranged/DrizzlefishFireball.cs +++ b/Projectiles/Ranged/DrizzlefishFireball.cs @@ -1,5 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,8 +9,8 @@ namespace CalamityMod.Projectiles.Ranged public class DrizzlefishFireball : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - + public override string Texture => "CalamityMod/Projectiles/Ranged/DrizzlefishFire"; + public int Time = 0; public override void SetDefaults() { Projectile.width = 10; @@ -22,34 +23,87 @@ namespace CalamityMod.Projectiles.Ranged Projectile.usesIDStaticNPCImmunity = true; Projectile.idStaticNPCHitCooldown = 10; } - + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8; + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + } public override void AI() { + Time++; + Player Owner = Main.player[Projectile.owner]; + if (Main.zenithWorld && Time == 1 && Owner.Calamity().dragoonDrizzlefishGelBoost > 1) + Projectile.damage = (int)(Projectile.damage * Owner.Calamity().dragoonDrizzlefishGelBoost); + Projectile.velocity.X *= 0.995f; + Projectile.velocity.Y -= 0.065f; Lighting.AddLight(Projectile.Center, 0.25f, 0f, 0f); int dustType = 235; + int dustType2 = 235; if (Projectile.ai[1] == 1f) { if (Main.rand.NextBool()) { - dustType = 35; + dustType = 174; } else { - dustType = 55; + dustType = 162; } } else { - dustType = 235; - } - Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] > 4f) - { - for (int num468 = 0; num468 < 5; num468++) + if (Main.rand.NextBool()) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + dustType = 183; + } + else + { + dustType = 90; + } + } + if (Time > 7) + { + Projectile.alpha = 0; + for (int i = 0; i < 2; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(5, 5) - Projectile.velocity * 1.5f, dustType, -Projectile.velocity); + dust.noGravity = true; + dust.velocity *= 0f; + dust.scale = Owner.Calamity().dragoonDrizzlefishGelBoost > 1 ? Main.rand.NextFloat(0.4f + Owner.Calamity().dragoonDrizzlefishGelBoost * 0.5f, 1f + Owner.Calamity().dragoonDrizzlefishGelBoost * 0.5f) : Main.rand.NextFloat(0.9f, 1.5f); + } + } + else + Projectile.alpha = 255; + if (Time == 4) + { + for (int i = 0; i <= 8; i++) + { + if (Projectile.ai[1] == 1f) + { + if (Main.rand.NextBool()) + { + dustType2 = 174; + } + else + { + dustType2 = 162; + } + } + else + { + if (Main.rand.NextBool()) + { + dustType2 = 183; + } + else + { + dustType2 = 90; + } + } + Dust dust = Dust.NewDustPerfect(Projectile.Center, dustType2, Projectile.velocity); + dust.scale = Main.rand.NextFloat(1.1f, 1.9f); + dust.velocity = Projectile.velocity.RotatedByRandom(0.8f) * Main.rand.NextFloat(0.3f, 1.3f); + dust.noGravity = true; } } } @@ -60,15 +114,35 @@ namespace CalamityMod.Projectiles.Ranged return false; } + public override bool PreDraw(ref Color lightColor) + { + if (Time < 7) + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1, ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value); + else + { + if (Projectile.ai[1] == 1f) + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1, ModContent.Request("CalamityMod/Projectiles/Ranged/DrizzlefishFire2").Value); + else + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1, ModContent.Request("CalamityMod/Projectiles/Ranged/DrizzlefishFire").Value); + } + //Changes the texture of the projectile + if (Projectile.ai[1] == 1f) + { + Texture2D texture = ModContent.Request("CalamityMod/Projectiles/Ranged/DrizzlefishFire2").Value; + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, 16, 16)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, 20 / 2f), Projectile.scale, SpriteEffects.None, 0); + return false; + } + return true; + } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { if (Projectile.ai[1] == 1f) { - target.AddBuff(BuffID.OnFire, 180); + target.AddBuff(BuffID.OnFire3, 40); } else { - target.AddBuff(ModContent.BuffType(), 60); + target.AddBuff(ModContent.BuffType(), 20); } } } diff --git a/Projectiles/Ranged/ElementalEruptionHouldout.cs b/Projectiles/Ranged/ElementalEruptionHouldout.cs new file mode 100644 index 0000000000..d3e8ed59cc --- /dev/null +++ b/Projectiles/Ranged/ElementalEruptionHouldout.cs @@ -0,0 +1,153 @@ +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using log4net.Core; +using Microsoft.Xna.Framework; +using Mono.Cecil; +using ReLogic.Utilities; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class ElementalEruptionHoldout : ModProjectile + { + // Take the name and texture from the weapon + public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + public override string Texture => "CalamityMod/Items/Weapons/Ranged/ElementalEruption"; + private Player Owner => Main.player[Projectile.owner]; + private ref float ShotsFired => ref Projectile.ai[1]; + private ref float ShootTimer => ref Projectile.ai[2]; + private ref int ShotDelay => ref Owner.ActiveItem().useTime; // 6 + public int ShotCooldown; + public int FireBlobs = 0; + public int Time = 0; + private bool OwnerCanShoot => Owner.channel && !Owner.noItems && !Owner.CCed; + + public override void SetDefaults() + { + Projectile.width = 64; + Projectile.height = 34; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.DamageType = DamageClass.Ranged; + Projectile.ignoreWater = true; + } + + public override void AI() + { + Time++; + if (Time == 1) + Projectile.alpha = 255; + else + Projectile.alpha = 0; + + if (Owner.dead || ShotsFired >= 24) // destroy the holdout if the player dies or is out of shots + { + Projectile.Kill(); + return; + } + + Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); + Vector2 tipPosition = armPosition + Projectile.velocity * Projectile.width * 0.8f; + + // Kill if the owner stops channeling or otherwise cannot use the weapon. + if (!OwnerCanShoot) + { + Projectile.Kill(); + } + else + { + var effectcolor = Main.rand.Next(4) switch + { + 0 => Color.DeepSkyBlue, + 1 => Color.MediumSpringGreen, + 2 => Color.DarkOrange, + _ => Color.Violet, + }; + + // While channeled, keep refreshing the projectile lifespan + Projectile.timeLeft = 2; + + ShootTimer++; + if (ShootTimer >= 60) + { + if (ShotCooldown == 0) + { + SoundEngine.PlaySound(SoundID.Item34, Projectile.Center); + Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _, Main.rand.NextFloat() < 0.70f); + for (int i = 0; i < 2; i++) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, (Projectile.velocity * 10).RotatedByRandom(0.12f), ModContent.ProjectileType(), damage, knockback, Projectile.owner); + } + ShotsFired++; + ShotCooldown = ShotDelay; + if (FireBlobs == 0) + { + Vector2 newVel = (Projectile.velocity * 9); + Vector2 newPos = tipPosition + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 36f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), newPos, newVel, ModContent.ProjectileType(), damage, knockback, Projectile.owner, newVel.Length(), -1f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), newPos, newVel, ModContent.ProjectileType(), damage, knockback, Projectile.owner, newVel.Length(), 1f); + FireBlobs = 3; + } + else + FireBlobs--; + } + else + ShotCooldown--; + } + else + { + if (ShootTimer == 1) + SoundEngine.PlaySound(SoundID.Item73 with { Volume = 0.7f}, Projectile.Center); + ShotsFired = 0; + for (int i = 0; i < 2; i++) + { + int dustType = Main.rand.NextBool() ? 66 : 247; + float rotMulti = Main.rand.NextFloat(0.3f, 1f); + Dust dust = Dust.NewDustPerfect(tipPosition, dustType); + dust.scale = Main.rand.NextFloat(1.2f, 1.8f) * (ShootTimer * 0.025f) - rotMulti * 0.1f; + dust.noGravity = true; + dust.velocity = new Vector2(0, -2).RotatedByRandom(rotMulti * 0.3f) * (Main.rand.NextFloat(1f, 3.2f) - rotMulti) * (ShootTimer * 0.025f); + dust.alpha = Main.rand.Next(90, 150); + dust.color = effectcolor; + } + } + + } + UpdateProjectileHeldVariables(armPosition); + ManipulatePlayerVariables(); + } + + private void UpdateProjectileHeldVariables(Vector2 armPosition) + { + if (Main.myPlayer == Projectile.owner) + { + float interpolant = Utils.GetLerpValue(5f, 35f, 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.Center = armPosition + Projectile.velocity * 20; + Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Projectile.spriteDirection = Projectile.direction; + } + + private void ManipulatePlayerVariables() + { + Owner.ChangeDir(Projectile.direction); + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); + } + public override bool? CanDamage() => false; + } +} diff --git a/Projectiles/Ranged/ElementalFire.cs b/Projectiles/Ranged/ElementalFire.cs index 456c13fcfc..3e99af8777 100644 --- a/Projectiles/Ranged/ElementalFire.cs +++ b/Projectiles/Ranged/ElementalFire.cs @@ -1,8 +1,11 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Ranged { public class ElementalFire : ModProjectile, ILocalizedModType @@ -10,70 +13,90 @@ namespace CalamityMod.Projectiles.Ranged public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public static int Lifetime => 96; + public ref float ColorType => ref Projectile.ai[0]; + public ref float Time => ref Projectile.ai[1]; + public override void SetDefaults() { - Projectile.width = 12; - Projectile.height = 12; + Projectile.width = Projectile.height = 12; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 2; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 90; + Projectile.penetrate = 5; + Projectile.MaxUpdates = 4; + Projectile.timeLeft = Lifetime; // 24 effectively Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 9; + Projectile.localNPCHitCooldown = -1; } public override void AI() { - Lighting.AddLight(Projectile.Center, 0.15f, 0.45f, 0f); - if (Projectile.ai[0] > 7f) + var effectcolor = Main.rand.Next(4) switch { - float num296 = 1f; - if (Projectile.ai[0] == 8f) - { - num296 = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - num296 = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - num296 = 0.75f; - } - Projectile.ai[0] += 1f; - int num297 = 66; - if (Main.rand.NextBool()) - { - for (int num298 = 0; num298 < 2; num298++) - { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.75f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 1.75f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.noGravity = true; - dust.scale *= 0.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= num296; - dust.velocity += Projectile.velocity; - } - } - } + 0 => Color.DeepSkyBlue, + 1 => Color.MediumSpringGreen, + 2 => Color.DarkOrange, + _ => Color.Violet, + }; + + Time++; + ColorType += 0.02f; + + // Determines particle size as well as hitbox + if (Time >= 1f) + Projectile.scale = 1.8f * Utils.GetLerpValue(5f, 30f, Time, true); else + return; // Helps position it at the tip + + if (Time == 1) { - Projectile.ai[0] += 1f; + for (int i = 0; i < 12; i++) + { + float rotMulti = Main.rand.NextFloat(0.7f, 1.1f); + int dustType = Main.rand.NextBool() ? 66 : 247; + Dust dust = Dust.NewDustPerfect(Projectile.Center, dustType); + dust.scale = Main.rand.NextFloat(1.8f, 2.5f) - rotMulti; + dust.noGravity = true; + dust.velocity = Projectile.velocity.RotatedByRandom(0.5f * rotMulti) * Main.rand.NextFloat(0.5f, 1.8f) * rotMulti; + dust.alpha = Main.rand.Next(90, 150); + dust.color = effectcolor; + } } - Projectile.rotation += 0.3f * (float)Projectile.direction; + + if (Time > 9) + { + float dustArea = Main.rand.NextFloat(0.1f, 1.7f); + int dustType = Main.rand.NextBool() ? 66 : 247; + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(9, 9) + Projectile.velocity * Main.rand.NextFloat(-1.8f, 1.8f), dustType); + dust.scale = (1.8f - dustArea) * 0.65f; + dust.noGravity = true; + dust.velocity = new Vector2(4, 4).RotatedByRandom(100) * dustArea; + dust.alpha = Main.rand.Next(90, 150); + dust.color = effectcolor; + } + + // Rainbow smokes of increasing opacity + float smokeRot = MathHelper.ToRadians(3f); // *Rate of rotation per frame, not a constant rotation + float hue = 0.5f * (ColorType % 1f) + 0.5f * Utils.GetLerpValue(30f, Lifetime, Time, true) * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f); + Color smokeColor = Main.hslToRgb(hue, 1f, 0.7f); + Particle smoke = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, smokeColor, 12, Projectile.scale * Main.rand.NextFloat(0.6f, 1.2f), 0.45f, smokeRot, true, required: true); + GeneralParticleHandler.SpawnParticle(smoke); + + // Overlay the glow on top, which is on the brighter side + if (Main.rand.NextBool(5)) + { + Color glowColor = Color.Lerp(smokeColor, Color.White, 0.3f); + Particle smokeGlow = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, glowColor, 9, Projectile.scale * Main.rand.NextFloat(0.4f, 0.7f), 0.2f, smokeRot, true, 0.005f); + GeneralParticleHandler.SpawnParticle(smokeGlow); + } + + Lighting.AddLight(Projectile.Center, smokeColor.ToVector3() * Projectile.scale * 0.3f); } + + // Circular hitbox adjusted for the size of the smoke particles (which is 52 here) + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 52 * Projectile.scale * 0.5f, targetHitbox); + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 540); } } diff --git a/Projectiles/Ranged/ElementalFlare.cs b/Projectiles/Ranged/ElementalFlare.cs new file mode 100644 index 0000000000..f77c689562 --- /dev/null +++ b/Projectiles/Ranged/ElementalFlare.cs @@ -0,0 +1,153 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class ElementalFlare : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/ExtraTextures/SmallGreyscaleCircle"; + + // Stats for both + public static int Lifetime = 90; // effective, 1.5 seconds + + // Homing Flare stats + public static float MinimumSpeed => 4f; + public static float MaximumSpeed => 24f; + public static float HomingRange => 720f; // 45 tiles + public static float HomingSpeedMult => 1.6f; + + // Sticky Flare stats + public static int StickDuration => 2; // already in seconds + public static int MaxStick => 6; + public static float StickyDamageFalloff => 0.5f; + + public bool StickToEnemies => Projectile.ai[2] == 1f; + public bool StickToTiles => Projectile.ai[2] == 2f; + public ref float StoredVelocity => ref Projectile.ai[0]; + public ref float Direction => ref Projectile.ai[1]; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 18; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 40; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.penetrate = 1; + Projectile.MaxUpdates = 2; + Projectile.timeLeft = Lifetime * Projectile.MaxUpdates; + Projectile.DamageType = DamageClass.Ranged; + Projectile.tileCollide = false; + } + + public override void AI() + { + if (StickToTiles) + return; + + if (StickToEnemies) + { + Projectile.ai[2] = 1f; + Projectile.StickyProjAI(StickDuration * Projectile.MaxUpdates); + return; + } + + float effectiveVelocity = MathHelper.Clamp(StoredVelocity, MinimumSpeed, MaximumSpeed); + int targetNPC = Projectile.FindTargetWithLineOfSight(HomingRange); + if (targetNPC != -1 && Projectile.timeLeft < (Lifetime - 20) * Projectile.MaxUpdates) + { + Vector2 destination = Main.npc[targetNPC].Center; + Projectile.velocity = Projectile.SafeDirectionTo(destination) * effectiveVelocity * HomingSpeedMult; + + // If close enough, don't do the sine movement + if (Projectile.Distance(destination) <= 160f) + return; + } + + // Sine-like movement + Projectile.position += (Vector2.UnitY * MathF.Sin(Projectile.timeLeft * MathHelper.Pi * 0.05f) * effectiveVelocity * Direction).RotatedBy(Projectile.velocity.ToRotation()); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 540); + + // Lose a bit of damage from repeated hits + if ((StickToEnemies || StickToTiles) && Projectile.damage > 1) + Projectile.damage = (int)(Projectile.damage * StickyDamageFalloff); + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (StickToEnemies) + Projectile.ModifyHitNPCSticky(MaxStick); + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + if (StickToTiles || StickToEnemies) + { + Projectile.velocity = oldVelocity * 0.95f; + Projectile.position -= Projectile.velocity; + + // No more enemy sticking + reset duration + if (StickToEnemies) + { + Projectile.ai[2] = 2f; + Projectile.timeLeft = StickDuration * 60 * Projectile.MaxUpdates; + } + return false; + } + return true; + } + + public override void OnKill(int timeLeft) + { + // Circular spread of clouds + for (int i = 0; i < 8; i++) + { + Vector2 smokeVel = Main.rand.NextVector2Circular(16f, 16f); + Color smokeColor = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.8f); + Particle smoke = new MediumMistParticle(Projectile.Center, smokeVel, smokeColor, Color.Black, Main.rand.NextFloat(0.6f, 1.6f), 200 - Main.rand.Next(60), 0.1f); + GeneralParticleHandler.SpawnParticle(smoke); + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D lightTexture = ModContent.Request(Texture).Value; + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + float hue = 0.5f + 0.5f * i / (float)Projectile.oldPos.Length * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f); + Color color = Main.hslToRgb(hue, 1f, 0.6f); + Vector2 drawPosition = Projectile.oldPos[i] + lightTexture.Size() * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY) + new Vector2(-15f, -15f); + Color outerColor = color * 2f; + Color innerColor = Color.Lerp(color, Color.White, 0.2f) * 0.5f; + float intensity = 0.9f + 0.15f * MathF.Cos(Main.GlobalTimeWrappedHourly % 60f * MathHelper.TwoPi); + + // Become smaller the futher along the old positions we are. + intensity *= MathHelper.Lerp(0.15f, 1f, 1f - i / (float)Projectile.oldPos.Length); + + Vector2 outerScale = new Vector2(1.25f) * intensity; + Vector2 innerScale = new Vector2(1.25f) * intensity * 0.7f; + outerColor *= intensity * Projectile.scale; + innerColor *= intensity * Projectile.scale; + Main.EntitySpriteDraw(lightTexture, drawPosition, null, outerColor, 0f, lightTexture.Size() * 0.5f, outerScale * 0.6f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(lightTexture, drawPosition, null, innerColor, 0f, lightTexture.Size() * 0.5f, innerScale * 0.6f, SpriteEffects.None, 0); + } + return false; + } + } +} diff --git a/Projectiles/Ranged/ElysianArrowProj.cs b/Projectiles/Ranged/ElysianArrowProj.cs index 98c25f1290..f62deb3def 100644 --- a/Projectiles/Ranged/ElysianArrowProj.cs +++ b/Projectiles/Ranged/ElysianArrowProj.cs @@ -52,23 +52,23 @@ namespace CalamityMod.Projectiles.Ranged Projectile.position.X = Projectile.position.X - (Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (Projectile.height / 2); SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - for (int num621 = 0; num621 < 2; num621++) + for (int i = 0; i < 2; i++) { - int num622 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 6; num623++) + for (int j = 0; j < 6; j++) { - int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 3f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[dust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) @@ -117,19 +117,18 @@ namespace CalamityMod.Projectiles.Ranged float x = Projectile.position.X + Main.rand.Next(-400, 400); float y = Projectile.position.Y - Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num15 = Projectile.position.X + (Projectile.width / 2) - vector.X; - float num16 = Projectile.position.Y + (Projectile.height / 2) - vector.Y; - num15 += Main.rand.Next(-100, 101); - int num17 = 25; - float num18 = (float)Math.Sqrt(num15 * num15 + num16 * num16); - num18 = num17 / num18; - num15 *= num18; - num16 *= num18; + Vector2 landSpot = new Vector2(x, y); + float meteorSpawnX = Projectile.position.X + (Projectile.width / 2) - landSpot.X; + float meteorSpawnY = Projectile.position.Y + (Projectile.height / 2) - landSpot.Y; + meteorSpawnX += Main.rand.Next(-100, 101); + float meteorSpawnAdjust = (float)Math.Sqrt(meteorSpawnX * meteorSpawnX + meteorSpawnY * meteorSpawnY); + meteorSpawnAdjust = 25 / meteorSpawnAdjust; + meteorSpawnX *= meteorSpawnAdjust; + meteorSpawnY *= meteorSpawnAdjust; if (Projectile.owner == Main.myPlayer) { - int num19 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), x, y, num15, num16, ModContent.ProjectileType(), Projectile.damage / 2, 5f, Projectile.owner, 0f, 0f); - Main.projectile[num19].ai[1] = Projectile.position.Y; + int meteor = Projectile.NewProjectile(Projectile.GetSource_FromThis(), x, y, meteorSpawnX, meteorSpawnY, ModContent.ProjectileType(), Projectile.damage / 2, 5f, Projectile.owner, 0f, 0f); + Main.projectile[meteor].ai[1] = Projectile.position.Y; } } diff --git a/Projectiles/Ranged/EnhancedNanoRoundProj.cs b/Projectiles/Ranged/EnhancedNanoRoundProj.cs index 77d4baf300..6b4ba1b81a 100644 --- a/Projectiles/Ranged/EnhancedNanoRoundProj.cs +++ b/Projectiles/Ranged/EnhancedNanoRoundProj.cs @@ -39,10 +39,10 @@ namespace CalamityMod.Projectiles.Ranged { if (Main.rand.NextBool(3)) { - int num137 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, 229, 0f, 0f, 0, default, 0.5f); - Main.dust[num137].alpha = Projectile.alpha; - Main.dust[num137].velocity *= 0f; - Main.dust[num137].noGravity = true; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, 229, 0f, 0f, 0, default, 0.5f); + Main.dust[dust].alpha = Projectile.alpha; + Main.dust[dust].velocity *= 0f; + Main.dust[dust].noGravity = true; } } } @@ -78,12 +78,12 @@ namespace CalamityMod.Projectiles.Ranged public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item93, Projectile.position); - int num212 = Main.rand.Next(5, 10); - for (int num213 = 0; num213 < num212; num213++) + int rando = Main.rand.Next(5, 10); + for (int i = 0; i < rando; i++) { - int num214 = Dust.NewDust(Projectile.Center - Projectile.velocity / 2f, 0, 0, 229, 0f, 0f, 100, default, 2f); - Main.dust[num214].velocity *= 2f; - Main.dust[num214].noGravity = true; + int dusty = Dust.NewDust(Projectile.Center - Projectile.velocity / 2f, 0, 0, 229, 0f, 0f, 100, default, 2f); + Main.dust[dusty].velocity *= 2f; + Main.dust[dusty].noGravity = true; } } } diff --git a/Projectiles/Ranged/EssenceFire.cs b/Projectiles/Ranged/EssenceFire.cs index 42b2bf6bde..21f345afd3 100644 --- a/Projectiles/Ranged/EssenceFire.cs +++ b/Projectiles/Ranged/EssenceFire.cs @@ -1,93 +1,149 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Ranged { public class EssenceFire : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override string Texture => "CalamityMod/Projectiles/FireProj"; + + public static int Lifetime => 96; + public static int Fadetime => 80; + public ref float Time => ref Projectile.ai[0]; + public int MistType = -1; public override void SetDefaults() { - Projectile.width = 6; - Projectile.height = 6; + Projectile.width = Projectile.height = 10; Projectile.friendly = true; Projectile.ignoreWater = true; + Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = -1; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 65; + Projectile.penetrate = 7; + Projectile.MaxUpdates = 4; + Projectile.timeLeft = Lifetime; // 24 effectively + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 3; } public override void AI() { - if (Projectile.scale <= 1.5f) - { - Projectile.scale *= 1.01f; - } - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.35f / 255f, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.45f / 255f); - if (Projectile.timeLeft > 65) - Projectile.timeLeft = 65; + Time++; - if (Projectile.ai[0] > 5f) + if (MistType == -1) + MistType = Main.rand.Next(3); + + if (Time > Fadetime) + Projectile.velocity *= 0.95f; + + if (Time > 6f && Time < Fadetime) { - float num296 = 1f; - if (Projectile.ai[0] == 6f) + if (Main.rand.NextBool(16)) { - num296 = 0.25f; - } - else if (Projectile.ai[0] == 7f) - { - num296 = 0.5f; - } - else if (Projectile.ai[0] == 8f) - { - num296 = 0.75f; - } - Projectile.ai[0] += 1f; - int dustType = (int)CalamityDusts.PurpleCosmilite; - if (Main.rand.NextBool()) - { - for (int num298 = 0; num298 < 1; num298++) + Dust dust = Dust.NewDustDirect(Projectile.Center + Main.rand.NextVector2Circular(60f, 60f) * Utils.Remap(Time, 0f, Fadetime, 0.5f, 1f), 4, 4, 295, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100); + if (Main.rand.NextBool(5)) { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 1.75f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 0.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= num296; - dust.velocity += Projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } + dust.noGravity = true; + dust.scale *= 2f; + dust.velocity *= 0.8f; } + dust.velocity *= 1.1f; + dust.velocity += Projectile.velocity * Utils.Remap(Time, 0f, Fadetime * 0.75f, 1f, 0.1f) * Utils.Remap(Time, 0f, Fadetime * 0.1f, 0.1f, 1f); + } + + if (Main.rand.NextBool(17)) + { + bool LowVel = Main.rand.NextBool() ? false : true; + FlameParticle fire = new FlameParticle(Projectile.Center, 20, MathHelper.Clamp(Time * 0.05f, 0.15f, 1.75f), 0.05f, Color.BlueViolet * (LowVel ? 1.2f : 0.5f), Color.DarkBlue * (LowVel ? 1.2f : 0.5f)); + fire.Velocity = new Vector2(Projectile.velocity.X * 0.8f, -10).RotatedByRandom(0.005f) * (LowVel ? Main.rand.NextFloat(0.4f, 0.65f) : Main.rand.NextFloat(0.8f, 1f)); + GeneralParticleHandler.SpawnParticle(fire); } } - else + else if (Time == 5f) { - Projectile.ai[0] += 1f; + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 295 : 181, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(0.5f, 1f)); + dust.scale = Main.rand.NextFloat(0.8f, 1.8f); + dust.noGravity = true; + dust.fadeIn = 0.5f; } - Projectile.rotation += 0.3f * Projectile.direction; } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + // Expanding hitbox + public override void ModifyDamageHitbox(ref Rectangle hitbox) { - target.AddBuff(ModContent.BuffType(), 240); - target.immune[Projectile.owner] = 1; + int size = (int)Utils.Remap(Time, 0f, Fadetime, 10f, 40f); + + // Shrinks again after fading + if (Time > Fadetime) + size = (int)Utils.Remap(Time, Fadetime, Lifetime, 40f, 0f); + hitbox.Inflate(size, size); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 360); + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.75f); + if (Projectile.damage < 1) + Projectile.damage = 1; + } + public override bool PreDraw(ref Color lightColor) + { + Texture2D fire = ModContent.Request(Texture).Value; + Texture2D mist = ModContent.Request("CalamityMod/Particles/MediumMist").Value; + + // The conga line of colors to sift through + Color color1 = new Color(160, 100, 255, 200); + Color color2 = new Color(160, 50, 255, 70); + Color color3 = new Color(120, 100, 255, 100); + Color color4 = new Color(30, 50, 200, 100); + float length = ((Time > Fadetime - 10f) ? 0.1f : 0.15f); + float vOffset = Math.Min(Time, 20f); + float timeRatio = Utils.GetLerpValue(0f, Lifetime, Time); + float fireSize = Utils.Remap(timeRatio, 0.2f, 0.5f, 0.25f, 1f); + + if (timeRatio >= 1f) + return false; + + for (float j = 1f; j >= 0f; j -= length) + { + // Color + Color fireColor = ((timeRatio < 0.1f) ? Color.Lerp(Color.Transparent, color1, Utils.GetLerpValue(0f, 0.1f, timeRatio)) : + ((timeRatio < 0.2f) ? Color.Lerp(color1, color2, Utils.GetLerpValue(0.1f, 0.2f, timeRatio)) : + ((timeRatio < 0.35f) ? color2 : + ((timeRatio < 0.7f) ? Color.Lerp(color2, color3, Utils.GetLerpValue(0.35f, 0.7f, timeRatio)) : + ((timeRatio < 0.85f) ? Color.Lerp(color3, color4, Utils.GetLerpValue(0.7f, 0.85f, timeRatio)) : + Color.Lerp(color4, Color.Transparent, Utils.GetLerpValue(0.85f, 1f, timeRatio))))))); + fireColor *= (1f - j) * Utils.GetLerpValue(0f, 0.2f, timeRatio, true); + + // Positions and rotations + Vector2 firePos = Projectile.Center - Main.screenPosition - Projectile.velocity * vOffset * j; + float mainRot = (-j * MathHelper.PiOver2 - Main.GlobalTimeWrappedHourly * (j + 1f) * 2f / length) * Math.Sign(Projectile.velocity.X); + float trailRot = MathHelper.PiOver4 - mainRot; + + // Draw one backtrail + Vector2 trailOffset = Projectile.velocity * vOffset * length * 0.5f; + Main.EntitySpriteDraw(fire, firePos - trailOffset, null, fireColor * 0.25f, trailRot, fire.Size() * 0.5f, fireSize, SpriteEffects.None); + + // Draw the main fire + Main.EntitySpriteDraw(fire, firePos, null, fireColor, mainRot, fire.Size() * 0.5f, fireSize, SpriteEffects.None); + + // Draw the masking smoke + if (MistType > 2 || MistType < 0) + return false; + Main.spriteBatch.SetBlendState(BlendState.Additive); + Rectangle frame = mist.Frame(1, 3, 0, MistType); + Main.EntitySpriteDraw(mist, firePos, frame, Color.Lerp(fireColor, Color.White, 0.3f), mainRot, frame.Size() * 0.5f, fireSize, SpriteEffects.None); + Main.EntitySpriteDraw(mist, firePos, frame, fireColor, mainRot, frame.Size() * 0.5f, fireSize * 3f, SpriteEffects.None); + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + } + return false; } } } diff --git a/Projectiles/Ranged/ExoFire.cs b/Projectiles/Ranged/ExoFire.cs index 10224416b8..fcfb45d239 100644 --- a/Projectiles/Ranged/ExoFire.cs +++ b/Projectiles/Ranged/ExoFire.cs @@ -1,5 +1,12 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Graphics.Metaballs; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; +using Terraria.Audio; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -9,72 +16,68 @@ namespace CalamityMod.Projectiles.Ranged { public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public ref float LightPower => ref Projectile.ai[2]; - public bool ProducedAcceleration = false; + public Color sparkColor; + public int Time = 0; + public ref int audioCooldown => ref Main.player[Projectile.owner].Calamity().PhotoAudioCooldown; + public ref int PhotoTimer => ref Main.player[Projectile.owner].Calamity().PhotoTimer; public override void SetDefaults() { - Projectile.width = 24; - Projectile.height = 24; + Projectile.width = Projectile.height = 30; Projectile.friendly = true; Projectile.ignoreWater = true; + Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = -1; - Projectile.MaxUpdates = 3; + Projectile.MaxUpdates = 180; + Projectile.timeLeft = 240; Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 5; - Projectile.timeLeft = 180; + Projectile.idStaticNPCHitCooldown = 6; } public override void AI() { - Projectile.ai[0] += 1f; - if (Projectile.ai[0] <= 3f) - return; - - float dustScale = 1f; - if (Projectile.ai[0] == 8f) + sparkColor = Main.rand.Next(4) switch { - dustScale = 0.25f; + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + Time++; + Lighting.AddLight(Projectile.Center, Color.White.ToVector3() * 0.2f); + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); //used for some drawing prevention for when it's offscreen since it makes a fuck load of particles + if (targetDist < 1400f) + { + if (PhotoTimer == 0) + PhotoMetaball3.SpawnParticle(Projectile.Center + Owner.velocity, 42 - Time * 0.165f); + if (PhotoTimer == 1) + PhotoMetaball3.SpawnParticle(Projectile.Center + Owner.velocity, (37 - Time * (PhotoTimer == 0 ? 0.165f : 0.088f)) - PhotoTimer * 0.2f + (PhotoTimer == 1 ? 20 : 0)); ; + + PhotoMetaball4.SpawnParticle(Projectile.Center + Owner.velocity, (37 - Time * (PhotoTimer == 0 ? 0.165f : 0.088f)) - PhotoTimer * 0.2f + (PhotoTimer == 1 ? 20 : 0)); } - else if (Projectile.ai[0] == 9f) + if ( Main.rand.NextBool(35) && targetDist < 1400f && Time > 5) { - dustScale = 0.5f; + Dust dust = Dust.NewDustPerfect(Projectile.Center, 263, new Vector2(0, -5).RotatedByRandom(0.05f) * Main.rand.NextFloat(0.3f, 1.6f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.3f, 1f); + dust.color = sparkColor; } - else if (Projectile.ai[0] == 10f) + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 300); + if (audioCooldown == 0) { - dustScale = 0.75f; - } - - int dustID = Main.rand.NextBool() ? 107 : 234; - if (Main.rand.NextBool(4)) - dustID = 269; - - if (Main.rand.NextBool()) - { - for (int i = 0; i < 2; i++) - { - Dust d = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, dustID, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 0.6f); - if (Main.rand.NextBool(3)) - { - d.scale *= 1.5f; - d.velocity.X *= 1.2f; - d.velocity.Y *= 1.2f; - } - else - d.scale *= 0.75f; - - d.noGravity = true; - d.velocity.X *= 0.8f; - d.velocity.Y *= 0.8f; - d.scale *= dustScale; - d.velocity += Projectile.velocity; - } + SoundEngine.PlaySound(Photoviscerator.HitSound, target.Center); + audioCooldown = 16; } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 300); - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 300); + } } diff --git a/Projectiles/Ranged/ExoFlare.cs b/Projectiles/Ranged/ExoFlare.cs deleted file mode 100644 index cc2ada2684..0000000000 --- a/Projectiles/Ranged/ExoFlare.cs +++ /dev/null @@ -1,103 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Ranged -{ - // Photoviscerator right click split projectile (attached flares to the flare cluster) - public class ExoFlare : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public float OffsetSpeed - { - get => Projectile.ai[0]; - set => Projectile.ai[0] = value; - } - public float OffsetRotation - { - get => Projectile.ai[1]; - set => Projectile.ai[1] = value; - } - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailingMode[Projectile.type] = 0; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 20; - } - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 24; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.tileCollide = false; - Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 16; - Projectile.timeLeft = 160; - } - public override void AI() - { - if (Projectile.localAI[0] == 0f) - { - OffsetRotation = Main.rand.NextFloat(MathHelper.TwoPi); - OffsetSpeed = Main.rand.NextFloat(MathHelper.ToRadians(2.5f), MathHelper.ToRadians(4f)) * Main.rand.NextBool().ToDirectionInt(); - Projectile.localAI[0] = 1f; - } - - // Ensure that the owner projectile index is a valid one. - if (!Main.projectile.IndexInRange((int)Projectile.localAI[1])) - { - Projectile.Kill(); - return; - } - - Projectile owner = Main.projectile[(int)Projectile.localAI[1]]; - - // Ensure the owner is the correct projectile. - if (owner.type != ModContent.ProjectileType()) - Projectile.Kill(); - - // Movement around the owner. - Projectile.Center = owner.Center + OffsetRotation.ToRotationVector2() * (float)Math.Cos(OffsetRotation * 0.3f) * owner.Size * 0.5f; - Projectile.rotation = (Projectile.position - Projectile.oldPos[1]).ToRotation(); - OffsetRotation += OffsetSpeed; - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D lightTexture = ModContent.Request("CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value; - for (int i = 0; i < Projectile.oldPos.Length; i++) - { - float colorInterpolation = (float)Math.Cos(Projectile.timeLeft / 16f + Main.GlobalTimeWrappedHourly / 20f + i / (float)Projectile.oldPos.Length * MathHelper.Pi) * 0.5f + 0.5f; - Color color = Color.Lerp(Color.LightGreen, Color.LightPink, colorInterpolation) * 0.4f; - color.A = 0; - Vector2 drawPosition = Projectile.oldPos[i] + lightTexture.Size() * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY) + new Vector2(-25f, -25f); - Color outerColor = color; - Color innerColor = color * 0.5f; - float intensity = 0.9f + 0.15f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 60f * MathHelper.TwoPi); - - // Become smaller the futher along the old positions we are. - intensity *= MathHelper.Lerp(0.15f, 1f, 1f - i / (float)Projectile.oldPos.Length); - - Vector2 outerScale = new Vector2(1.65f) * intensity; - Vector2 innerScale = new Vector2(1.65f) * intensity * 0.7f; - outerColor *= intensity; - innerColor *= intensity; - Main.EntitySpriteDraw(lightTexture, drawPosition, null, outerColor, 0f, lightTexture.Size() * 0.5f, outerScale * 0.6f, SpriteEffects.None, 0); - Main.EntitySpriteDraw(lightTexture, drawPosition, null, innerColor, 0f, lightTexture.Size() * 0.5f, innerScale * 0.6f, SpriteEffects.None, 0); - } - return false; - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 600); - - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 600); - } -} diff --git a/Projectiles/Ranged/ExoFlareCluster.cs b/Projectiles/Ranged/ExoFlareCluster.cs index c6489e9582..ec64d7a017 100644 --- a/Projectiles/Ranged/ExoFlareCluster.cs +++ b/Projectiles/Ranged/ExoFlareCluster.cs @@ -1,7 +1,10 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Graphics.Metaballs; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; +using Terraria.Audio; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -12,71 +15,103 @@ namespace CalamityMod.Projectiles.Ranged public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public const float MinDistanceFromTarget = 45f; - public const float MaxDistanceFromTarget = 350f; - public override void SetStaticDefaults() - { - ProjectileID.Sets.NeedsUUID[Projectile.type] = true; - } + public int Time = 0; + public Color sparkColor; + public bool PostTileHit = false; + public ref int audioCooldown => ref Main.player[Projectile.owner].Calamity().PhotoAudioCooldown; public override void SetDefaults() { Projectile.width = Projectile.height = 50; Projectile.friendly = true; Projectile.ignoreWater = true; - Projectile.tileCollide = false; + Projectile.tileCollide = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = -1; + Projectile.penetrate = 5; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - Projectile.timeLeft = 180; + Projectile.localNPCHitCooldown = 22; + Projectile.extraUpdates = 1; + Projectile.timeLeft = 420; } public override void AI() { - // localAI[0] is used by the sticky AI method, so use localAI[1] to spawn the flares. - if (Projectile.localAI[1] == 0f) + Time++; + sparkColor = Main.rand.Next(4) switch { - if (Main.netMode != NetmodeID.Server) - { - int projID = ModContent.ProjectileType(); - int flareDamage = (int)(0.6f * Projectile.damage); - float flareKB = Projectile.knockBack; - for (int i = 0; i < 4; i++) - { - Projectile p = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, projID, flareDamage, flareKB, Projectile.owner); - p.localAI[1] = Projectile.GetByUUID(Projectile.owner, Projectile.whoAmI); - } - } - Projectile.localAI[1] = 1f; - } - - if (Projectile.ai[0] == 0f) - { - NPC potentialTarget = Projectile.Center.ClosestNPCAt(MaxDistanceFromTarget, true, true); - if (potentialTarget != null) - { - if (Projectile.Distance(potentialTarget.Center) > MinDistanceFromTarget) - { - float angleOffset = Projectile.AngleTo(potentialTarget.Center) - Projectile.velocity.ToRotation(); - angleOffset = MathHelper.WrapAngle(angleOffset); - Projectile.velocity = Projectile.velocity.RotatedBy(MathHelper.Clamp(angleOffset, -0.1f, 0.1f)); - } - } - } - Projectile.StickyProjAI(5); + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + PhotoMetaball.SpawnParticle(Projectile.Center, 90); + PhotoMetaball2.SpawnParticle(Projectile.Center, 85); + CalamityUtils.HomeInOnNPC(Projectile, true, 600f, 12f, 20f); } - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => Projectile.ModifyHitNPCSticky(4); public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - if (Projectile.width == 50) - { - int width = (int)MathHelper.Min(target.Hitbox.Width, 60); - int height = (int)MathHelper.Min(target.Hitbox.Height, 60); - Projectile.ExpandHitboxBy(width, height); - } target.AddBuff(ModContent.BuffType(), 600); + float numberOflines = 5; + float rotFactorlines = 360f / numberOflines; + for (int i = 0; i < numberOflines; i++) + { + float rot = MathHelper.ToRadians(i * rotFactorlines); + Vector2 offset = (Vector2.UnitX * Main.rand.NextFloat(0.2f, 3.1f)).RotatedBy(rot + Main.rand.NextFloat(0.1f, 5.1f)); + Vector2 velOffset = (Vector2.UnitX * Main.rand.NextFloat(0.2f, 3.1f)).RotatedBy(rot + Main.rand.NextFloat(0.1f, 5.1f)); + SparkParticle spark = new SparkParticle(Projectile.Center + offset, velOffset * Main.rand.NextFloat(3.5f, 6.5f), true, 95, Main.rand.NextFloat(0.3f, 0.8f), Color.White); + GeneralParticleHandler.SpawnParticle(spark); + + float rot2 = MathHelper.ToRadians(i * rotFactorlines); + Vector2 offset2 = (Vector2.UnitX * Main.rand.NextFloat(0.2f, 3.1f)).RotatedBy(rot2 + Main.rand.NextFloat(0.1f, 5.1f)); + Vector2 velOffset2 = (Vector2.UnitX * Main.rand.NextFloat(0.2f, 3.1f)).RotatedBy(rot2 + Main.rand.NextFloat(0.1f, 5.1f)); + + SquishyLightParticle exoEnergy = new(Projectile.Center + offset2, velOffset2 * Main.rand.NextFloat(0.5f, 2.5f), 0.5f, sparkColor, 35); + GeneralParticleHandler.SpawnParticle(exoEnergy); + } + if (audioCooldown == 0) + { + SoundEngine.PlaySound(Photoviscerator.HitSound, target.Center); + audioCooldown = 10; + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + if (!PostTileHit) + { + SoundEngine.PlaySound(DeadSunsWind.Ricochet with { Volume = 1.2f }, Projectile.Center); + float numberOflines = 25; + float rotFactorlines = 360f / numberOflines; + for (int i = 0; i < numberOflines; i++) + { + sparkColor = Main.rand.Next(4) switch + { + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + + float rot2 = MathHelper.ToRadians(i * rotFactorlines); + Vector2 offset2 = (Vector2.UnitX * Main.rand.NextFloat(0.2f, 3.1f)).RotatedBy(rot2 * Main.rand.NextFloat(1.1f, 9.1f)); + Vector2 velOffset2 = (Vector2.UnitX * Main.rand.NextFloat(0.2f, 3.1f)).RotatedBy(rot2 * Main.rand.NextFloat(1.1f, 9.1f)); + + SquishyLightParticle exoEnergy = new(Projectile.Center + offset2, velOffset2 * Main.rand.NextFloat(0.2f, 1.9f), 0.5f, sparkColor, 40); + GeneralParticleHandler.SpawnParticle(exoEnergy); + } + PostTileHit = true; + } + + 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 OnHitPlayer(Player target, Player.HurtInfo info) diff --git a/Projectiles/Ranged/ExoLight.cs b/Projectiles/Ranged/ExoLight.cs index bf4d7586d4..25dc0f5244 100644 --- a/Projectiles/Ranged/ExoLight.cs +++ b/Projectiles/Ranged/ExoLight.cs @@ -1,12 +1,14 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; +using System; using System.IO; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Graphics.Metaballs; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; -using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Ranged { @@ -18,166 +20,132 @@ namespace CalamityMod.Projectiles.Ranged public Vector2 InitialCenter; public Vector2 Destination; + public Vector2 NPCDestination; public const float MaxRadius = 90f; - public float Time - { - get => Projectile.ai[0]; - set => Projectile.ai[0] = value; - } - public int DustType - { - get => (int)Projectile.ai[1]; - set => Projectile.ai[1] = value; - } - public float YDirection - { - get => Projectile.localAI[1]; - set => Projectile.localAI[1] = value; - } + public ref float YDirection => ref Projectile.ai[0]; + public ref float Time => ref Projectile.ai[1]; + public Color sparkColor; public override void SetStaticDefaults() { ProjectileID.Sets.TrailingMode[Projectile.type] = 0; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 15; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 36; } public override void SetDefaults() { - Projectile.width = Projectile.height = 40; + Projectile.width = Projectile.height = 20; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = 1; - Projectile.timeLeft = 300; + Projectile.timeLeft = 210; Projectile.alpha = 127; + Projectile.extraUpdates = 1; + Projectile.tileCollide = false; } public override void SendExtraAI(BinaryWriter writer) { - writer.Write(YDirection); writer.WriteVector2(Destination); } + public override void ReceiveExtraAI(BinaryReader reader) { - YDirection = reader.ReadSingle(); Destination = reader.ReadVector2(); } public override void AI() { + PhotoMetaball.SpawnParticle(Projectile.Center, 54); + PhotoMetaball2.SpawnParticle(Projectile.Center, 50); + + sparkColor = Main.rand.Next(4) switch + { + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + Lighting.AddLight(Projectile.Center, Color.DarkSlateGray.ToVector3()); - Projectile.alpha = (int)MathHelper.Lerp(255, 127, Utils.GetLerpValue(0f, 25f, Time, true)); Projectile.scale = MathHelper.Lerp(0.001f, 1f, Utils.GetLerpValue(0f, 25f, Time, true)); if (Projectile.localAI[0] == 0f) { + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].CanBeChasedBy(Projectile.GetSource_FromThis(), false)) + NPCDestination = Main.npc[i].Center + Main.npc[i].velocity * 5f; + } InitialCenter = Projectile.Center; + Projectile.localAI[0] = 1f; if (Main.myPlayer == Projectile.owner) { - Destination = Main.MouseWorld; + Destination = NPCDestination; Projectile.netUpdate = true; } - DustType = Main.rand.NextBool() ? 107 : 234; - if (Main.rand.NextBool(4)) - { - DustType = 269; - } - Projectile.localAI[0] = 1f; } if (Destination == Vector2.Zero) return; - if (Time <= 90f) + if (Time <= 60f) { - Projectile.position = Vector2.Lerp(InitialCenter, Destination, Time / 90f); - Projectile.position.Y += (float)Math.Sin(Time / 90f * MathHelper.TwoPi) * 75f; + Projectile.Center = Vector2.Lerp(InitialCenter, Destination, Time / 60f); + Projectile.Center += (Vector2.UnitY * MathF.Sin(Time / 70f * MathHelper.TwoPi) * 75f * YDirection).RotatedBy(Projectile.velocity.ToRotation()); } - else if (Time < 180f) + else if (Time < 120f) { // For those who haven't seen this yet (namely in the 1.4 source), this allows you to achieve a // fade-in and fade-out effect with relative ease. At 90, multiply by 0, and somewhere in-between until 115, where you multiply by 1. // And then do the same for the fade-out effect of 180f-165. These inverse linear interpolations cannot overlap by definition because // their ranges do not overlap. Overall a really cool trick. - float radius = MaxRadius * Utils.GetLerpValue(90f, 115f, Time, true) * Utils.GetLerpValue(180f, 165f, Time, true); - radius *= 1f + (float)Math.Cos(Main.GlobalTimeWrappedHourly / 24f) * 0.25f; + float radius = MaxRadius * Utils.GetLerpValue(60f, 75f, Time, true) * Utils.GetLerpValue(120f, 105f, Time, true); + radius *= 1f + MathF.Cos(Main.GlobalTimeWrappedHourly / 24f) * 0.25f; if (radius < 5f) radius = 5f; - Projectile.Center = Destination + ((Time - 90) / 90f * MathHelper.ToRadians(720f) + (YDirection == -1).ToInt() * MathHelper.Pi).ToRotationVector2() * radius; + Projectile.Center = Destination + ((Time - 60) / 60f * MathHelper.ToRadians(720f) + (YDirection == -1).ToInt() * MathHelper.Pi).ToRotationVector2() * radius; } - else if (Time == 180f) + else if (Time == 120f) Projectile.Kill(); Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; Time++; } - public void GenerateRotationalDust() - { - for (int i = 0; i < 9; i++) - { - float angle = Time / 45f + i / 9f * MathHelper.TwoPi; - Vector2 offsetSpan = angle.ToRotationVector2() * Projectile.Size * 0.65f * Projectile.scale; - Vector2 edgePosition = Projectile.Center + offsetSpan.RotatedBy(Projectile.rotation); - Dust dust = Dust.NewDustPerfect(edgePosition + Main.rand.NextVector2Circular(4f, 4f), DustType); - dust.velocity = Vector2.Zero; - dust.noGravity = true; - dust.scale = 0.65f; - } - } - - public override Color? GetAlpha(Color lightColor) - { - return CalamityUtils.MulticolorLerp(Time / 60f % 1f, new Color[] - { - Color.PaleGreen, - Color.Violet, - Color.SlateGray - }) * Projectile.Opacity; - } - public override bool PreDraw(ref Color lightColor) - { - Texture2D lightTexture = ModContent.Request("CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value; - for (int i = 0; i < Projectile.oldPos.Length; i++) - { - float colorInterpolation = (float)Math.Cos(Projectile.timeLeft / 16f + Main.GlobalTimeWrappedHourly / 20f + i / (float)Projectile.oldPos.Length * MathHelper.Pi) * 0.5f + 0.5f; - Color color = CalamityUtils.MulticolorLerp(MathHelper.Clamp(colorInterpolation, 0f, 0.99f), new Color[] - { - Color.PaleGreen, - Color.Violet, - Color.SlateGray - }) * Projectile.Opacity; - color.A = 0; - Vector2 drawPosition = Projectile.oldPos[i] + lightTexture.Size() * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY) + new Vector2(-15f, -15f); - Color outerColor = color; - Color innerColor = color * 0.5f; - float intensity = 0.9f + 0.15f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 60f * MathHelper.TwoPi); - - // Become smaller the futher along the old positions we are. - intensity *= MathHelper.Lerp(0.15f, 1f, 1f - i / (float)Projectile.oldPos.Length); - - Vector2 outerScale = new Vector2(1.25f) * intensity; - Vector2 innerScale = new Vector2(1.25f) * intensity * 0.7f; - outerColor *= intensity * Projectile.scale; - innerColor *= intensity * Projectile.scale; - Main.EntitySpriteDraw(lightTexture, drawPosition, null, outerColor, 0f, lightTexture.Size() * 0.5f, outerScale * 0.6f, SpriteEffects.None, 0); - Main.EntitySpriteDraw(lightTexture, drawPosition, null, innerColor, 0f, lightTexture.Size() * 0.5f, innerScale * 0.6f, SpriteEffects.None, 0); - } - return false; - } - public override void OnKill(int timeLeft) { - SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) + float scaleBonus = Time >= 120f ? Main.rand.NextFloat(3.4f, 4.2f) : Main.rand.NextFloat(0.8f, 1.6f); + SoundEngine.PlaySound(DeadSunsWind.Explosion with { Volume = 0.7f}, Projectile.Center); + float numberOfDusts = Time >= 120f ? 30 : 20; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) { - int projID = ModContent.ProjectileType(); - for (int i = 0; i < 3; i++) + sparkColor = Main.rand.Next(4) switch { - Vector2 vel = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * 16f; - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, vel, projID, Projectile.damage, Projectile.knockBack * 0.3f, Projectile.owner); - } + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 offset = (Vector2.UnitX * Main.rand.NextFloat(0.2f, 3.1f)).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + Vector2 velOffset = (Vector2.UnitX * Main.rand.NextFloat(0.2f, 3.1f)).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + + SquishyLightParticle exoEnergy = new(Projectile.Center + offset, velOffset * (Main.rand.NextFloat(0.5f, 3.5f) + scaleBonus * 0.65f), Time >= 120f ? 0.7f : 0.5f, sparkColor, Time >= 120f ? 50 : 35); + GeneralParticleHandler.SpawnParticle(exoEnergy); } + Projectile.scale = 6.5f * scaleBonus; + // we should probably have a generic util to do this whole thing + Projectile.maxPenetrate = -1; + Projectile.penetrate = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + Projectile.Damage(); } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.width * Projectile.scale * 0.5f, targetHitbox); + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 360); public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 360); diff --git a/Projectiles/Ranged/ExoSpark.cs b/Projectiles/Ranged/ExoSpark.cs deleted file mode 100644 index 7abdaa0efe..0000000000 --- a/Projectiles/Ranged/ExoSpark.cs +++ /dev/null @@ -1,72 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Ranged -{ - // Photoviscerator left click splitting homing projectile - public class ExoSpark : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public static readonly int[] FrameToDustIDTable = new int[] - { - 107, - 234, - 269, - }; - public const float HomingInertia = 10f; - public const float MaxTargetDistance = 750f; - public override void SetStaticDefaults() - { - Main.projFrames[Projectile.type] = 3; - } - - public override void SetDefaults() - { - Projectile.width = 28; - Projectile.height = 14; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 1; - Projectile.timeLeft = 600; - } - - public override void AI() - { - if (Projectile.localAI[0] == 0f) - { - Projectile.frame = Main.rand.Next(3); - Projectile.localAI[0] = 1f; - Projectile.netUpdate = true; - } - NPC potentialTarget = Projectile.Center.ClosestNPCAt(MaxTargetDistance); - if (potentialTarget != null) - Projectile.velocity = (Projectile.velocity * (HomingInertia - 1) + Projectile.SafeDirectionTo(potentialTarget.Center) * 16f) / HomingInertia; - - Projectile.rotation = Projectile.velocity.ToRotation(); - if (!Main.dedServ) - { - GenerateCircularDust(); - } - } - - public void GenerateCircularDust() - { - for (int i = 0; i < 12; i++) - { - float angle = i / 12f * MathHelper.TwoPi; - Vector2 spawnPosition = Projectile.Center + angle.ToRotationVector2().RotatedBy(Projectile.rotation) * new Vector2(10f, 6f); - Dust dust = Dust.NewDustPerfect(spawnPosition, FrameToDustIDTable[Projectile.frame]); - dust.velocity = Vector2.Zero; - dust.scale = 0.5f; - dust.noGravity = true; - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 180); - - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 180); - } -} diff --git a/Projectiles/Ranged/ExoSpark.png b/Projectiles/Ranged/ExoSpark.png deleted file mode 100644 index eb696c6909..0000000000 Binary files a/Projectiles/Ranged/ExoSpark.png and /dev/null differ diff --git a/Projectiles/Ranged/FeatherLarge.cs b/Projectiles/Ranged/FeatherLarge.cs index 44a114e1b7..0adfc6a767 100644 --- a/Projectiles/Ranged/FeatherLarge.cs +++ b/Projectiles/Ranged/FeatherLarge.cs @@ -47,11 +47,11 @@ namespace CalamityMod.Projectiles.Ranged public override void OnKill(int timeLeft) { - int num3; - for (int num611 = 0; num611 < 10; num611 = num3 + 1) + int inc; + for (int i = 0; i < 10; i = inc + 1) { Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 42, Projectile.velocity.X * 0.1f, Projectile.velocity.Y * 0.1f, 0, default, 1f); - num3 = num611; + inc = i; } } } diff --git a/Projectiles/Ranged/FishronRPG.cs b/Projectiles/Ranged/FishronRPG.cs index de3baac4e7..9efdf73da1 100644 --- a/Projectiles/Ranged/FishronRPG.cs +++ b/Projectiles/Ranged/FishronRPG.cs @@ -23,14 +23,14 @@ namespace CalamityMod.Projectiles.Ranged { if (Projectile.ai[1] == 0f) { - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } Projectile.ai[1] = 1f; @@ -54,22 +54,22 @@ namespace CalamityMod.Projectiles.Ranged { if (Math.Abs(Projectile.velocity.X) >= 8f || Math.Abs(Projectile.velocity.Y) >= 8f) { - for (int num246 = 0; num246 < 2; num246++) + for (int j = 0; j < 2; j++) { - float num247 = 0f; - float num248 = 0f; - if (num246 == 1) + float halfX = 0f; + float halfY = 0f; + if (j == 1) { - num247 = Projectile.velocity.X * 0.5f; - num248 = Projectile.velocity.Y * 0.5f; + halfX = Projectile.velocity.X * 0.5f; + halfY = Projectile.velocity.Y * 0.5f; } - int num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 33, 0f, 0f, 100, default, 1f); - Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 33, 0f, 0f, 100, default, 0.5f); - Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num249].velocity *= 0.05f; + int fishDust = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 33, 0f, 0f, 100, default, 1f); + Main.dust[fishDust].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[fishDust].velocity *= 0.2f; + Main.dust[fishDust].noGravity = true; + fishDust = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 33, 0f, 0f, 100, default, 0.5f); + Main.dust[fishDust].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[fishDust].velocity *= 0.05f; } } } @@ -95,23 +95,23 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localNPCHitCooldown = 10; Projectile.Damage(); SoundEngine.PlaySound(SoundID.Item92, Projectile.position); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 20; num623++) + for (int i = 0; i < 20; i++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dusty = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 3f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].velocity *= 5f; + dusty = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 2f); + Main.dust[dusty].velocity *= 2f; } } } diff --git a/Projectiles/Ranged/FlakKrakenGun.cs b/Projectiles/Ranged/FlakKrakenGun.cs index 4ce596ec78..88c4b779db 100644 --- a/Projectiles/Ranged/FlakKrakenGun.cs +++ b/Projectiles/Ranged/FlakKrakenGun.cs @@ -1,6 +1,6 @@ -using CalamityMod.Items.Weapons.Ranged; +using System; +using CalamityMod.Items.Weapons.Ranged; using Microsoft.Xna.Framework; -using System; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -28,88 +28,85 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { Player player = Main.player[Projectile.owner]; - float num = 0f; - Vector2 vector = player.RotatedRelativePoint(player.MountedCenter, true); + float pi = 0f; + Vector2 playerRotation = player.RotatedRelativePoint(player.MountedCenter, true); if (Projectile.spriteDirection == -1) { - num = 3.14159274f; + pi = 3.14159274f; } - float num26 = 30f; + float hitRate = 30f; if (Projectile.ai[0] > 90f) { - num26 = 15f; + hitRate = 15f; } if (Projectile.ai[0] > 120f) { - num26 = 5f; + hitRate = 5f; } Projectile.damage = player.ActiveItem() is null ? 0 : player.GetWeaponDamage(player.ActiveItem()); Projectile.ai[0] += 1f; Projectile.ai[1] += 1f; - int num27 = 10; - bool flag10 = false; - if (Projectile.ai[0] % num26 == 0f) + bool isUsing = false; + if (Projectile.ai[0] % hitRate == 0f) { - flag10 = true; + isUsing = true; } if (Projectile.ai[1] >= 1f) { Projectile.ai[1] = 0f; - flag10 = true; + isUsing = true; if (Main.myPlayer == Projectile.owner) { float scaleFactor5 = player.ActiveItem().shootSpeed * Projectile.scale; - Vector2 value12 = vector; - Vector2 value13 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - value12; + Vector2 shootDirection = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - playerRotation; if (player.gravDir == -1f) { - value13.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - value12.Y; + shootDirection.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - playerRotation.Y; } - Vector2 vector11 = Vector2.Normalize(value13); - if (float.IsNaN(vector11.X) || float.IsNaN(vector11.Y)) + Vector2 normalizeShoot = Vector2.Normalize(shootDirection); + if (float.IsNaN(normalizeShoot.X) || float.IsNaN(normalizeShoot.Y)) { - vector11 = -Vector2.UnitY; + normalizeShoot = -Vector2.UnitY; } - vector11 = Vector2.Normalize(Vector2.Lerp(vector11, Vector2.Normalize(Projectile.velocity), 0.92f)); //0.92 - vector11 *= scaleFactor5; - if (vector11.X != Projectile.velocity.X || vector11.Y != Projectile.velocity.Y) + normalizeShoot = Vector2.Normalize(Vector2.Lerp(normalizeShoot, Vector2.Normalize(Projectile.velocity), 0.92f)); //0.92 + normalizeShoot *= scaleFactor5; + if (normalizeShoot.X != Projectile.velocity.X || normalizeShoot.Y != Projectile.velocity.Y) { Projectile.netUpdate = true; } - Projectile.velocity = vector11; + Projectile.velocity = normalizeShoot; } } if (Projectile.soundDelay <= 0) { - Projectile.soundDelay = num27; + Projectile.soundDelay = 10; Projectile.soundDelay *= 2; if (Projectile.ai[0] != 1f && Projectile.ai[0] <= 500f) { SoundEngine.PlaySound(SoundID.Item15, Projectile.position); } } - if (flag10 && Main.myPlayer == Projectile.owner) + if (isUsing && Main.myPlayer == Projectile.owner) { - bool flag12 = player.channel && !player.noItems && !player.CCed; - if (flag12) + bool canUseItem = player.channel && !player.noItems && !player.CCed; + if (canUseItem) { if (Projectile.ai[0] == 1f) { - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 projPos = player.RotatedRelativePoint(player.MountedCenter, true); + float projX = (float)Main.mouseX + Main.screenPosition.X - projPos.X; + float projY = (float)Main.mouseY + Main.screenPosition.Y - projPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + projY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - projPos.Y; } - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + if ((float.IsNaN(projX) && float.IsNaN(projY)) || (projX == 0f && projY == 0f)) { - num78 = (float)player.direction; - num79 = 0f; + projX = (float)player.direction; + projY = 0f; } - vector2 += new Vector2(num78, num79); - int num29 = Projectile.damage; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), vector2.X, vector2.Y, 0f, 0f, ModContent.ProjectileType(), num29, Projectile.knockBack, Projectile.owner, 0f, (float)Projectile.whoAmI); + projPos += new Vector2(projX, projY); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), projPos.X, projPos.Y, 0f, 0f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, (float)Projectile.whoAmI); Projectile.netUpdate = true; } } @@ -119,7 +116,7 @@ namespace CalamityMod.Projectiles.Ranged } } Projectile.position = player.RotatedRelativePoint(player.MountedCenter, true) - Projectile.Size / 2f; - Projectile.rotation = Projectile.velocity.ToRotation() + num; + Projectile.rotation = Projectile.velocity.ToRotation() + pi; Projectile.spriteDirection = Projectile.direction; Projectile.timeLeft = 2; player.ChangeDir(Projectile.direction); diff --git a/Projectiles/Ranged/FlakKrakenProj.cs b/Projectiles/Ranged/FlakKrakenProj.cs index ced93ffe25..f2e3b7084b 100644 --- a/Projectiles/Ranged/FlakKrakenProj.cs +++ b/Projectiles/Ranged/FlakKrakenProj.cs @@ -61,71 +61,71 @@ namespace CalamityMod.Projectiles.Ranged Projectile.width = Projectile.height = 50; } Player player = Main.player[Projectile.owner]; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 projPos = player.RotatedRelativePoint(player.MountedCenter, true); + float projX = (float)Main.mouseX + Main.screenPosition.X - projPos.X; + float projY = (float)Main.mouseY + Main.screenPosition.Y - projPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + projY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - projPos.Y; } - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + if ((float.IsNaN(projX) && float.IsNaN(projY)) || (projX == 0f && projY == 0f)) { - num78 = (float)player.direction; - num79 = 0f; + projX = (float)player.direction; + projY = 0f; } - vector2 += new Vector2(num78, num79); + projPos += new Vector2(projX, projY); float speed = 30f; float speedScale = 3f; Vector2 vectorPos = Projectile.Center; - if (Vector2.Distance(vector2, vectorPos) < 90f) + if (Vector2.Distance(projPos, vectorPos) < 90f) { speed = 10f; speedScale = 1f; } - if (Vector2.Distance(vector2, vectorPos) < 30f) + if (Vector2.Distance(projPos, vectorPos) < 30f) { speed = 3f; speedScale = 0.3f; } - if (Vector2.Distance(vector2, vectorPos) < 10f) + if (Vector2.Distance(projPos, vectorPos) < 10f) { speed = 1f; speedScale = 0.1f; } - float num678 = vector2.X - vectorPos.X; - float num679 = vector2.Y - vectorPos.Y; - float num680 = (float)Math.Sqrt((double)(num678 * num678 + num679 * num679)); - num680 = speed / num680; - num678 *= num680; - num679 *= num680; - if (Projectile.velocity.X < num678) + float projectileX = projPos.X - vectorPos.X; + float projectileY = projPos.Y - vectorPos.Y; + float projectileAdjust = (float)Math.Sqrt((double)(projectileX * projectileX + projectileY * projectileY)); + projectileAdjust = speed / projectileAdjust; + projectileX *= projectileAdjust; + projectileY *= projectileAdjust; + if (Projectile.velocity.X < projectileX) { Projectile.velocity.X = Projectile.velocity.X + speedScale; - if (Projectile.velocity.X < 0f && num678 > 0f) + if (Projectile.velocity.X < 0f && projectileX > 0f) { Projectile.velocity.X = Projectile.velocity.X + speedScale; } } - else if (Projectile.velocity.X > num678) + else if (Projectile.velocity.X > projectileX) { Projectile.velocity.X = Projectile.velocity.X - speedScale; - if (Projectile.velocity.X > 0f && num678 < 0f) + if (Projectile.velocity.X > 0f && projectileX < 0f) { Projectile.velocity.X = Projectile.velocity.X - speedScale; } } - if (Projectile.velocity.Y < num679) + if (Projectile.velocity.Y < projectileY) { Projectile.velocity.Y = Projectile.velocity.Y + speedScale; - if (Projectile.velocity.Y < 0f && num679 > 0f) + if (Projectile.velocity.Y < 0f && projectileY > 0f) { Projectile.velocity.Y = Projectile.velocity.Y + speedScale; } } - else if (Projectile.velocity.Y > num679) + else if (Projectile.velocity.Y > projectileY) { Projectile.velocity.Y = Projectile.velocity.Y - speedScale; - if (Projectile.velocity.Y > 0f && num679 < 0f) + if (Projectile.velocity.Y > 0f && projectileY < 0f) { Projectile.velocity.Y = Projectile.velocity.Y - speedScale; } diff --git a/Projectiles/Ranged/FlareBat.cs b/Projectiles/Ranged/FlareBat.cs index ca77612cc8..60fea41a64 100644 --- a/Projectiles/Ranged/FlareBat.cs +++ b/Projectiles/Ranged/FlareBat.cs @@ -29,15 +29,15 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { - int num103 = (int)Player.FindClosest(Projectile.Center, 1, 1); + int originPlayer = (int)Player.FindClosest(Projectile.Center, 1, 1); Projectile.ai[1] += 1f; if (Projectile.ai[1] < 110f && Projectile.ai[1] > 30f) { float scaleFactor2 = Projectile.velocity.Length(); - Vector2 vector11 = Main.player[num103].Center - Projectile.Center; - vector11.Normalize(); - vector11 *= scaleFactor2; - Projectile.velocity = (Projectile.velocity * 24f + vector11) / 25f; + Vector2 projDirection = Main.player[originPlayer].Center - Projectile.Center; + projDirection.Normalize(); + projDirection *= scaleFactor2; + Projectile.velocity = (Projectile.velocity * 24f + projDirection) / 25f; Projectile.velocity.Normalize(); Projectile.velocity *= scaleFactor2; } @@ -48,10 +48,10 @@ namespace CalamityMod.Projectiles.Ranged Projectile.velocity *= 1.02f; } } - int num192 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 0, default, 1f); - Main.dust[num192].noGravity = true; - Main.dust[num192].velocity *= 0.2f; - Main.dust[num192].position = (Main.dust[num192].position + Projectile.Center) / 2f; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 0, default, 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0.2f; + Main.dust[dust].position = (Main.dust[dust].position + Projectile.Center) / 2f; Projectile.frameCounter++; if (Projectile.frameCounter >= 2) { diff --git a/Projectiles/Ranged/Flash.cs b/Projectiles/Ranged/Flash.cs index e07c0729ea..923c04e53a 100644 --- a/Projectiles/Ranged/Flash.cs +++ b/Projectiles/Ranged/Flash.cs @@ -28,60 +28,60 @@ namespace CalamityMod.Projectiles.Ranged { Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.5f / 255f); Color dustColor = Projectile.ai[1] == 1f ? CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f) : default; - bool flag15 = false; - bool flag16 = false; + bool xflag = false; + bool yflag = false; if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) { - flag16 = true; + yflag = true; } if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) { - flag16 = true; + yflag = true; } - if (flag15 && flag16) + if (xflag && yflag) { Projectile.Kill(); } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-30, 31); - float num464 = (float)Main.rand.Next(-30, 31); - float num465 = (float)Main.rand.Next(9, 27); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 264, 0f, 0f, 100, dustColor, 2f); - Dust dust = Main.dust[num467]; + float rand1 = (float)Main.rand.Next(-30, 31); + float rand2 = (float)Main.rand.Next(-30, 31); + float rand3 = (float)Main.rand.Next(9, 27); + float randAdjust = (float)Math.Sqrt((double)(rand1 * rand1 + rand2 * rand2)); + randAdjust = rand3 / randAdjust; + rand1 *= randAdjust; + rand2 *= randAdjust; + int flashDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 264, 0f, 0f, 100, dustColor, 2f); + Dust dust = Main.dust[flashDust]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = rand1; + dust.velocity.Y = rand2; + timerCounter++; } } diff --git a/Projectiles/Ranged/FlashRoundProj.cs b/Projectiles/Ranged/FlashRoundProj.cs index 969c30540b..970e73351d 100644 --- a/Projectiles/Ranged/FlashRoundProj.cs +++ b/Projectiles/Ranged/FlashRoundProj.cs @@ -38,10 +38,10 @@ namespace CalamityMod.Projectiles.Ranged { if (Main.rand.NextBool(3)) { - int num137 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, 264, 0f, 0f, 0, default, 0.5f); - Main.dust[num137].alpha = Projectile.alpha; - Main.dust[num137].velocity *= 0f; - Main.dust[num137].noGravity = true; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, 264, 0f, 0f, 0, default, 0.5f); + Main.dust[dust].alpha = Projectile.alpha; + Main.dust[dust].velocity *= 0f; + Main.dust[dust].noGravity = true; } } } diff --git a/Projectiles/Ranged/FreedomStarHoldout.cs b/Projectiles/Ranged/FreedomStarHoldout.cs index 367ce796af..c742913a0e 100644 --- a/Projectiles/Ranged/FreedomStarHoldout.cs +++ b/Projectiles/Ranged/FreedomStarHoldout.cs @@ -63,20 +63,20 @@ namespace CalamityMod.Projectiles.Ranged Projectile.ai[1] = 0f; shootThisFrame = true; - float num21 = player.inventory[player.selectedItem].shootSpeed * Projectile.scale; - Vector2 value11 = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - Projectile.Center; + float speedScale = player.inventory[player.selectedItem].shootSpeed * Projectile.scale; + Vector2 shootDirection = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - Projectile.Center; if (player.gravDir == -1f) - value11.Y = Main.screenHeight - Main.mouseY + Main.screenPosition.Y - Projectile.Center.Y; + shootDirection.Y = Main.screenHeight - Main.mouseY + Main.screenPosition.Y - Projectile.Center.Y; - Vector2 velocity2 = Vector2.Normalize(value11); - if (float.IsNaN(velocity2.X) || float.IsNaN(velocity2.Y)) - velocity2 = -Vector2.UnitY; + Vector2 shootVel = Vector2.Normalize(shootDirection); + if (float.IsNaN(shootVel.X) || float.IsNaN(shootVel.Y)) + shootVel = -Vector2.UnitY; - velocity2 *= num21; - if (velocity2.X != Projectile.velocity.X || velocity2.Y != Projectile.velocity.Y) + shootVel *= speedScale; + if (shootVel.X != Projectile.velocity.X || shootVel.Y != Projectile.velocity.Y) Projectile.netUpdate = true; - Projectile.velocity = velocity2; + Projectile.velocity = shootVel; } // Emit sounds. @@ -93,24 +93,20 @@ namespace CalamityMod.Projectiles.Ranged { Vector2 spinningpoint3 = Vector2.UnitX * 32f; spinningpoint3 = spinningpoint3.RotatedBy(Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f)); - Vector2 value12 = Projectile.Center + spinningpoint3; + Vector2 dustSpawn = Projectile.Center + spinningpoint3; for (int k = 0; k < chargeAmt + 1; k++) { - int num22 = 226; - float num23 = 0.4f; + float dustScale = 0.4f; if (k % 2 == 1) - { - num22 = 226; - num23 = 0.65f; - } + dustScale = 0.65f; - Vector2 vector3 = value12 + ((float)Main.rand.NextDouble() * ((float)Math.PI * 2f)).ToRotationVector2() * (12f - chargeAmt * 2); - int num24 = Dust.NewDust(vector3 - Vector2.One * 8f, 16, 16, num22, Projectile.velocity.X / 2f, Projectile.velocity.Y / 2f); - Main.dust[num24].velocity = Vector2.Normalize(value12 - vector3) * 1.5f * (10f - chargeAmt * 2f) / 10f; - Main.dust[num24].noGravity = true; - Main.dust[num24].scale = num23; - Main.dust[num24].customData = player; + Vector2 randDustSpawn = dustSpawn + ((float)Main.rand.NextDouble() * ((float)Math.PI * 2f)).ToRotationVector2() * (12f - chargeAmt * 2); + int electricDust = Dust.NewDust(randDustSpawn - Vector2.One * 8f, 16, 16, 226, Projectile.velocity.X / 2f, Projectile.velocity.Y / 2f); + Main.dust[electricDust].velocity = Vector2.Normalize(dustSpawn - randDustSpawn) * 1.5f * (10f - chargeAmt * 2f) / 10f; + Main.dust[electricDust].noGravity = true; + Main.dust[electricDust].scale = dustScale; + Main.dust[electricDust].customData = player; } } @@ -119,28 +115,23 @@ namespace CalamityMod.Projectiles.Ranged { Vector2 spinningpoint4 = Vector2.UnitX * 32f; spinningpoint4 = spinningpoint4.RotatedBy(Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f)); - Vector2 vector4 = Projectile.Center + spinningpoint4; + Vector2 dustSpawnLaser = Projectile.Center + spinningpoint4; for (int l = 0; l < 2; l++) { - int num25 = 226; - float num26 = 0.35f; + float dustScale = 0.35f; if (l % 2 == 1) - { - num25 = 226; - num26 = 0.45f; - } - num26 *= MathHelper.Lerp(1f, 3f, lerpAmtForCharge); + dustScale = 0.45f; + dustScale *= MathHelper.Lerp(1f, 3f, lerpAmtForCharge); - float num27 = Main.rand.NextFloatDirection(); - Vector2 value13 = vector4 + (Projectile.rotation + (Projectile.spriteDirection == -1 ? -MathHelper.PiOver2 : MathHelper.PiOver2) + num27 * ((float)Math.PI / 4f) * 0.8f - (float)Math.PI / 2f).ToRotationVector2() * 6f; - int num28 = 24; - int num29 = Dust.NewDust(value13 - Vector2.One * (num28 / 2), num28, num28, num25, Projectile.velocity.X / 2f, Projectile.velocity.Y / 2f); - Main.dust[num29].velocity = (value13 - vector4).SafeNormalize(Vector2.Zero) * MathHelper.Lerp(1.5f, 9f, Utils.GetLerpValue(1f, 0f, Math.Abs(num27), clamped: true)); - Main.dust[num29].noGravity = true; - Main.dust[num29].scale = num26; - Main.dust[num29].customData = player; - Main.dust[num29].fadeIn = 0.5f; + float randFloat = Main.rand.NextFloatDirection(); + Vector2 randDustSpawnLaser = dustSpawnLaser + (Projectile.rotation + (Projectile.spriteDirection == -1 ? -MathHelper.PiOver2 : MathHelper.PiOver2) + randFloat * ((float)Math.PI / 4f) * 0.8f - (float)Math.PI / 2f).ToRotationVector2() * 6f; + int electric2 = Dust.NewDust(randDustSpawnLaser - Vector2.One * 12, 24, 24, 226, Projectile.velocity.X / 2f, Projectile.velocity.Y / 2f); + Main.dust[electric2].velocity = (randDustSpawnLaser - dustSpawnLaser).SafeNormalize(Vector2.Zero) * MathHelper.Lerp(1.5f, 9f, Utils.GetLerpValue(1f, 0f, Math.Abs(randFloat), clamped: true)); + Main.dust[electric2].noGravity = true; + Main.dust[electric2].scale = dustScale; + Main.dust[electric2].customData = player; + Main.dust[electric2].fadeIn = 0.5f; } } diff --git a/Projectiles/Ranged/FungiOrb.cs b/Projectiles/Ranged/FungiOrb.cs index e1eafaceba..0f5fdf1a72 100644 --- a/Projectiles/Ranged/FungiOrb.cs +++ b/Projectiles/Ranged/FungiOrb.cs @@ -33,9 +33,9 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.localAI[0] > 4f) { Vector2 dspeed = -Projectile.velocity * 0.5f; - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 1f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity = dspeed; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity = dspeed; } } diff --git a/Projectiles/Ranged/FungiOrb2.cs b/Projectiles/Ranged/FungiOrb2.cs index 477700d940..3a0ee56cec 100644 --- a/Projectiles/Ranged/FungiOrb2.cs +++ b/Projectiles/Ranged/FungiOrb2.cs @@ -38,9 +38,9 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.localAI[0] > 4f) { Vector2 dspeed = -Projectile.velocity * 0.5f; - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 1f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity = dspeed; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity = dspeed; } if (Projectile.timeLeft < 150) diff --git a/Projectiles/Ranged/GoliathRocket.cs b/Projectiles/Ranged/GoliathRocket.cs index bdad0012c0..3d6b96b187 100644 --- a/Projectiles/Ranged/GoliathRocket.cs +++ b/Projectiles/Ranged/GoliathRocket.cs @@ -1,18 +1,17 @@ -using CalamityMod.Buffs.DamageOverTime; +using System; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; -using System.Collections.Generic; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace CalamityMod.Projectiles.Ranged { public class GoliathRocket : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public static Item FalseLauncher = null; + private ref float RocketType => ref Projectile.ai[0]; public override void SetDefaults() { @@ -24,33 +23,26 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; } - private static void DefineFalseLauncher() - { - int rocketID = ItemID.RocketLauncher; - FalseLauncher = new Item(); - FalseLauncher.SetDefaults(rocketID, true); - } - public override void AI() { if (Math.Abs(Projectile.velocity.X) >= 8f || Math.Abs(Projectile.velocity.Y) >= 8f) { - for (int num246 = 0; num246 < 2; num246++) + for (int i = 0; i < 2; i++) { - float num247 = 0f; - float num248 = 0f; - if (num246 == 1) + float halfX = 0f; + float halfY = 0f; + if (i == 1) { - num247 = Projectile.velocity.X * 0.5f; - num248 = Projectile.velocity.Y * 0.5f; + halfX = Projectile.velocity.X * 0.5f; + halfY = Projectile.velocity.Y * 0.5f; } - int num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 6, 0f, 0f, 100, default, 1f); - Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 31, 0f, 0f, 100, default, 0.5f); - Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num249].velocity *= 0.05f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 6, 0f, 0f, 100, default, 1f); + Main.dust[dust].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].velocity *= 0.2f; + Main.dust[dust].noGravity = true; + dust = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 31, 0f, 0f, 100, default, 0.5f); + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dust].velocity *= 0.05f; } } if (Math.Abs(Projectile.velocity.X) < 15f && Math.Abs(Projectile.velocity.Y) < 15f) @@ -59,33 +51,24 @@ namespace CalamityMod.Projectiles.Ranged } else if (Main.rand.NextBool()) { - int num252 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 1f); - Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2)).RotatedBy((double)Projectile.rotation, default) * 1.1f; + int dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 1f); + Main.dust[dust2].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dust2].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dust2].noGravity = true; + Main.dust[dust2].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2)).RotatedBy((double)Projectile.rotation, default) * 1.1f; Main.rand.Next(2); - num252 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 1f); - Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2 - 6)).RotatedBy((double)Projectile.rotation, default) * 1.1f; + dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 1f); + Main.dust[dust2].scale = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dust2].noGravity = true; + Main.dust[dust2].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2 - 6)).RotatedBy((double)Projectile.rotation, default) * 1.1f; } Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(90); - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - Player player = Main.player[Projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); - if (projID == ProjectileID.DryRocket || projID == ProjectileID.WetRocket || projID == ProjectileID.LavaRocket || projID == ProjectileID.HoneyRocket) - { - if (Projectile.wet) - Projectile.timeLeft = 1; - } + if (RocketType == ItemID.DryRocket || RocketType == ItemID.WetRocket || RocketType == ItemID.LavaRocket || RocketType == ItemID.HoneyRocket) + { + if (Projectile.wet) + Projectile.timeLeft = 1; + } } public override bool PreDraw(ref Color lightColor) @@ -97,29 +80,32 @@ namespace CalamityMod.Projectiles.Ranged public override void OnKill(int timeLeft) { + var info = new CalamityUtils.RocketBehaviorInfo((int)RocketType) + { + smallRadius = 6, + mediumRadius = 9, + largeRadius = 12 + }; + int blastRadius = Projectile.RocketBehavior(info); Projectile.ExpandHitboxBy(160); - Projectile.maxPenetrate = -1; - Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; Projectile.Damage(); + if (Projectile.owner == Main.myPlayer) { - int num516 = 2; - for (int num517 = 0; num517 < num516; num517++) + for (int j = 0; j < 2; j++) { - if (num517 % 2 != 1 || Main.rand.NextBool(3)) + if (j % 2 != 1 || Main.rand.NextBool(3)) { - Vector2 value20 = Projectile.position; - Vector2 value21 = Projectile.oldVelocity; - value21.Normalize(); - value21 *= 8f; - float num518 = (float)Main.rand.Next(-35, 36) * 0.01f; - float num519 = (float)Main.rand.Next(-35, 36) * 0.01f; - value20 -= value21 * (float)num517; - num518 += Projectile.oldVelocity.X / 6f; - num519 += Projectile.oldVelocity.Y / 6f; - int bee = Projectile.NewProjectile(Projectile.GetSource_FromThis(), value20.X, value20.Y, num518, num519, Main.player[Projectile.owner].beeType(), Main.player[Projectile.owner].beeDamage(Projectile.damage), Main.player[Projectile.owner].beeKB(0f), Main.myPlayer); + Vector2 projPos = Projectile.position; + Vector2 projVel = Projectile.oldVelocity; + projVel.Normalize(); + projVel *= 8f; + float beeVelX = (float)Main.rand.Next(-35, 36) * 0.01f; + float beeVelY = (float)Main.rand.Next(-35, 36) * 0.01f; + projPos -= projVel * (float)j; + beeVelX += Projectile.oldVelocity.X / 6f; + beeVelY += Projectile.oldVelocity.Y / 6f; + int bee = Projectile.NewProjectile(Projectile.GetSource_FromThis(), projPos.X, projPos.Y, beeVelX, beeVelY, Main.player[Projectile.owner].beeType(), Main.player[Projectile.owner].beeDamage(Projectile.damage), Main.player[Projectile.owner].beeKB(0f), Main.myPlayer); if (bee.WithinBounds(Main.maxProjectiles)) { Main.projectile[bee].penetrate = 2; @@ -128,121 +114,77 @@ namespace CalamityMod.Projectiles.Ranged } } } - SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - for (int num621 = 0; num621 < 20; num621++) + + if (!Main.dedServ) { - int num622 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool()) + for (int i = 0; i < 20; i++) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Dust dusty = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 31, Alpha: 100, Scale: 2f); + dusty.velocity *= 3f; + if (Main.rand.NextBool()) + { + dusty.scale = 0.5f; + dusty.fadeIn = Main.rand.NextFloat(1f, 2f); + } } - } - for (int num623 = 0; num623 < 30; num623++) - { - int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - if (Main.netMode != NetmodeID.Server) - { - Vector2 goreSource = Projectile.Center; - int goreAmt = 3; - Vector2 source = new Vector2(goreSource.X - 24f, goreSource.Y - 24f); - for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++) + for (int j = 0; j < 30; j++) { - float velocityMult = 0.33f; - if (goreIndex < (goreAmt / 3)) - { - velocityMult = 0.66f; - } - if (goreIndex >= (2 * goreAmt / 3)) - { - velocityMult = 1f; - } - Mod mod = ModContent.GetInstance(); - int type = Main.rand.Next(61, 64); - int smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - Gore gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y -= 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y -= 1f; + Dust flameDust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 6, Alpha: 100, Scale: 3f); + flameDust.noGravity = true; + flameDust.velocity *= 5f; + + flameDust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 6, Alpha: 100, Scale: 2f); + flameDust.velocity *= 2f; } + + if (Main.netMode != NetmodeID.Server) + { + Vector2 goreSource = Projectile.Center; + int goreAmt = 3; + Vector2 source = new Vector2(goreSource.X - 24f, goreSource.Y - 24f); + for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++) + { + float velocityMult = 0.33f; + if (goreIndex < (goreAmt / 3)) + { + velocityMult = 0.66f; + } + if (goreIndex >= (2 * goreAmt / 3)) + { + velocityMult = 1f; + } + int type = Main.rand.Next(61, 64); + int smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); + Gore gore = Main.gore[smoke]; + gore.velocity *= velocityMult; + gore.velocity.X += 1f; + gore.velocity.Y += 1f; + type = Main.rand.Next(61, 64); + smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); + gore = Main.gore[smoke]; + gore.velocity *= velocityMult; + gore.velocity.X -= 1f; + gore.velocity.Y += 1f; + type = Main.rand.Next(61, 64); + smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); + gore = Main.gore[smoke]; + gore.velocity *= velocityMult; + gore.velocity.X += 1f; + gore.velocity.Y -= 1f; + type = Main.rand.Next(61, 64); + smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); + gore = Main.gore[smoke]; + gore.velocity *= velocityMult; + gore.velocity.X -= 1f; + gore.velocity.Y -= 1f; + } + } + + SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); } - - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - Player player = Main.player[Projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); - int blastRadius = 0; - if (projID == ProjectileID.RocketII || projID == ProjectileID.ClusterRocketII) - blastRadius = 6; - else if (projID == ProjectileID.RocketIV) - blastRadius = 9; - else if (projID == ProjectileID.MiniNukeRocketII) - blastRadius = 12; - - Projectile.ExpandHitboxBy(14); - - if (Projectile.owner == Main.myPlayer && blastRadius > 0) - { - CalamityUtils.ExplodeandDestroyTiles(Projectile, blastRadius, true, new List() { }, new List() { }); - } - if (Projectile.owner == Main.myPlayer) - { - Point center = Projectile.Center.ToTileCoordinates(); - DelegateMethods.v2_1 = center.ToVector2(); - DelegateMethods.f_1 = 3f; - if (projID == ProjectileID.DryRocket) - { - DelegateMethods.f_1 = 3.5f; - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadDry); - } - else if (projID == ProjectileID.WetRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadWater); - } - else if (projID == ProjectileID.LavaRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadLava); - } - else if (projID == ProjectileID.HoneyRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadHoney); - } - } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 180); } } diff --git a/Projectiles/Ranged/HalleysComet.cs b/Projectiles/Ranged/HalleysComet.cs index bdb9e589ee..59a8e105f5 100644 --- a/Projectiles/Ranged/HalleysComet.cs +++ b/Projectiles/Ranged/HalleysComet.cs @@ -1,6 +1,11 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Terraria; using Terraria.ModLoader; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria.Audio; +using CalamityMod.Items.Weapons.Ranged; + namespace CalamityMod.Projectiles.Ranged { public class HalleysComet : ModProjectile, ILocalizedModType @@ -8,80 +13,96 @@ namespace CalamityMod.Projectiles.Ranged public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public ref float Time => ref Projectile.ai[0]; + public override void SetDefaults() { - Projectile.width = Projectile.height = 12; + Projectile.width = Projectile.height = 32; Projectile.friendly = true; + Projectile.tileCollide = false; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 4; - Projectile.extraUpdates = 10; - Projectile.timeLeft = 600; + Projectile.penetrate = 5; + Projectile.MaxUpdates = 15; + Projectile.timeLeft = 20 * Projectile.MaxUpdates; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; } public override void AI() { - if (Projectile.scale <= 1.5f) + Projectile.rotation = Projectile.velocity.ToRotation(); + Time++; + + // Render the needle beam as a pair of severely stretched spark particles. + // This has to be done only on specific extra updates or it'll instantly overload the particle limit. + bool isDrawingUpdate = Projectile.numUpdates % 3 == 0; + if (Time > 6f && isDrawingUpdate) { - Projectile.scale *= 1.01f; + Color outerSparkColor = new Color(8, 35, 156); + float scaleBoost = MathHelper.Clamp(Time * 0.005f, 0f, 2f); + float outerSparkScale = 3.2f + scaleBoost; + SparkParticle spark = new SparkParticle(Projectile.Center, Projectile.velocity, false, 7, outerSparkScale, outerSparkColor); + GeneralParticleHandler.SpawnParticle(spark); + + Color innerSparkColor = new Color(184, 215, 245); + float innerSparkScale = 1.6f + scaleBoost; + SparkParticle spark2 = new SparkParticle(Projectile.Center, Projectile.velocity, false, 7, innerSparkScale, innerSparkColor); + GeneralParticleHandler.SpawnParticle(spark2); } - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.35f / 255f, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.45f / 255f); - - if (Projectile.ai[0]++ > 5f) + // 5th update: Spawn two pulse rings and some dust as firing vfx + else if (Time == 5f) { - float dustScaleSize = 1f; - if (Projectile.ai[0] == 6f) + Particle pulse = new DirectionalPulseRing(Projectile.Center, Projectile.velocity * 0.75f, Color.Aqua, new Vector2(1f, 2.5f), Projectile.rotation, 0.2f, 0.03f, 20); + GeneralParticleHandler.SpawnParticle(pulse); + Particle pulse2 = new DirectionalPulseRing(Projectile.Center, Projectile.velocity * 0.4f, Color.DodgerBlue, new Vector2(1f, 2.5f), Projectile.rotation, 0.1f, 0.025f, 35); + GeneralParticleHandler.SpawnParticle(pulse2); + for (int i = 0; i <= 25; i++) { - dustScaleSize = 0.25f; - } - else if (Projectile.ai[0] == 7f) - { - dustScaleSize = 0.5f; - } - else if (Projectile.ai[0] == 8f) - { - dustScaleSize = 0.75f; - } - Projectile.ai[0] += 1f; - int dustType = 176; - for (int i = 0; i < 3; i++) - { - int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 1, default, 1f); - Dust dust = Main.dust[fire]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 1.75f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 0.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= dustScaleSize; - dust.velocity += Projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 172 : 206, Projectile.velocity); + dust.scale = Main.rand.NextFloat(1.6f, 2.5f); + dust.velocity = Projectile.velocity.RotatedByRandom(0.4f) * Main.rand.NextFloat(0.3f, 1.6f); + dust.noGravity = true; + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 172 : 206, Projectile.velocity); + dust2.scale = Main.rand.NextFloat(1.35f, 2.1f); + dust2.velocity = Projectile.velocity.RotatedByRandom(0.06f) * Main.rand.NextFloat(0.8f, 3.1f); + dust2.noGravity = true; } } - Projectile.rotation += 0.3f * (float)Projectile.direction; + if (Projectile.FinalExtraUpdate()) + Lighting.AddLight(Projectile.Center, Color.MediumBlue.ToVector3() * 0.4f); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 240); + target.AddBuff(ModContent.BuffType(), 450); + SoundEngine.PlaySound(HalleysInferno.Hit, Projectile.Center); + + // Dust emission on hit + for (int i = 0; i < 14; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 172 : 206, Projectile.velocity); + dust.scale = Main.rand.NextFloat(1.1f, 1.9f); + dust.velocity = Projectile.velocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.2f, 2.1f); + dust.noGravity = true; + } } public override void OnHitPlayer(Player target, Player.HurtInfo info) { - target.AddBuff(ModContent.BuffType(), 240); + target.AddBuff(ModContent.BuffType(), 450); + SoundEngine.PlaySound(HalleysInferno.Hit, Projectile.Center); + + // Dust emission on hit + for (int i = 0; i < 14; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 172 : 206, Projectile.velocity); + dust.scale = Main.rand.NextFloat(1.1f, 1.9f); + dust.velocity = Projectile.velocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.2f, 2.1f); + dust.noGravity = true; + } } } } diff --git a/Projectiles/Ranged/HiveBomb.cs b/Projectiles/Ranged/HiveBomb.cs index c2dfd66bd3..bf257aca05 100644 --- a/Projectiles/Ranged/HiveBomb.cs +++ b/Projectiles/Ranged/HiveBomb.cs @@ -1,18 +1,17 @@ -using CalamityMod.Buffs.DamageOverTime; +using System; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; -using System.Collections.Generic; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace CalamityMod.Projectiles.Ranged { public class HiveBomb : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public static Item FalseLauncher = null; + private ref float RocketType => ref Projectile.ai[0]; public override void SetDefaults() { @@ -24,33 +23,26 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; } - private static void DefineFalseLauncher() - { - int rocketID = ItemID.RocketLauncher; - FalseLauncher = new Item(); - FalseLauncher.SetDefaults(rocketID, true); - } - public override void AI() { if (Math.Abs(Projectile.velocity.X) >= 8f || Math.Abs(Projectile.velocity.Y) >= 8f) { - for (int num246 = 0; num246 < 2; num246++) + for (int i = 0; i < 2; i++) { - float num247 = 0f; - float num248 = 0f; - if (num246 == 1) + float halfX = 0f; + float halfY = 0f; + if (i == 1) { - num247 = Projectile.velocity.X * 0.5f; - num248 = Projectile.velocity.Y * 0.5f; + halfX = Projectile.velocity.X * 0.5f; + halfY = Projectile.velocity.Y * 0.5f; } - int num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 6, 0f, 0f, 100, default, 1f); - Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 31, 0f, 0f, 100, default, 0.5f); - Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num249].velocity *= 0.05f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 6, 0f, 0f, 100, default, 1f); + Main.dust[dust].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].velocity *= 0.2f; + Main.dust[dust].noGravity = true; + dust = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 31, 0f, 0f, 100, default, 0.5f); + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dust].velocity *= 0.05f; } } if (Math.Abs(Projectile.velocity.X) < 15f && Math.Abs(Projectile.velocity.Y) < 15f) @@ -59,33 +51,24 @@ namespace CalamityMod.Projectiles.Ranged } else if (Main.rand.NextBool()) { - int num252 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 1f); - Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2)).RotatedBy((double)Projectile.rotation, default) * 1.1f; + int dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 1f); + Main.dust[dust2].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dust2].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dust2].noGravity = true; + Main.dust[dust2].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2)).RotatedBy((double)Projectile.rotation, default) * 1.1f; Main.rand.Next(2); - num252 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 1f); - Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2 - 6)).RotatedBy((double)Projectile.rotation, default) * 1.1f; + dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 1f); + Main.dust[dust2].scale = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dust2].noGravity = true; + Main.dust[dust2].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2 - 6)).RotatedBy((double)Projectile.rotation, default) * 1.1f; } Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(90); - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - Player player = Main.player[Projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); - if (projID == ProjectileID.DryRocket || projID == ProjectileID.WetRocket || projID == ProjectileID.LavaRocket || projID == ProjectileID.HoneyRocket) - { - if (Projectile.wet) - Projectile.timeLeft = 1; - } + if (RocketType == ItemID.DryRocket || RocketType == ItemID.WetRocket || RocketType == ItemID.LavaRocket || RocketType == ItemID.HoneyRocket) + { + if (Projectile.wet) + Projectile.timeLeft = 1; + } } public override bool PreDraw(ref Color lightColor) @@ -97,29 +80,32 @@ namespace CalamityMod.Projectiles.Ranged public override void OnKill(int timeLeft) { + var info = new CalamityUtils.RocketBehaviorInfo((int)RocketType) + { + smallRadius = 4, + mediumRadius = 7, + largeRadius = 10 + }; + int blastRadius = Projectile.RocketBehavior(info); Projectile.ExpandHitboxBy(64); - Projectile.maxPenetrate = -1; - Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; Projectile.Damage(); + if (Projectile.owner == Main.myPlayer) { - int num516 = 6; - for (int num517 = 0; num517 < num516; num517++) + for (int j = 0; j < 6; j++) { - if (num517 % 2 != 1 || Main.rand.NextBool(3)) + if (j % 2 != 1 || Main.rand.NextBool(3)) { - Vector2 value20 = Projectile.position; - Vector2 value21 = Projectile.oldVelocity; - value21.Normalize(); - value21 *= 8f; - float num518 = (float)Main.rand.Next(-35, 36) * 0.01f; - float num519 = (float)Main.rand.Next(-35, 36) * 0.01f; - value20 -= value21 * (float)num517; - num518 += Projectile.oldVelocity.X / 6f; - num519 += Projectile.oldVelocity.Y / 6f; - int bee = Projectile.NewProjectile(Projectile.GetSource_FromThis(), value20.X, value20.Y, num518, num519, Main.player[Projectile.owner].beeType(), Main.player[Projectile.owner].beeDamage(Projectile.damage / 3), Main.player[Projectile.owner].beeKB(0f), Main.myPlayer); + Vector2 projPos = Projectile.position; + Vector2 projVel = Projectile.oldVelocity; + projVel.Normalize(); + projVel *= 8f; + float beeVelX = (float)Main.rand.Next(-35, 36) * 0.01f; + float beeVelY = (float)Main.rand.Next(-35, 36) * 0.01f; + projPos -= projVel * (float)j; + beeVelX += Projectile.oldVelocity.X / 6f; + beeVelY += Projectile.oldVelocity.Y / 6f; + int bee = Projectile.NewProjectile(Projectile.GetSource_FromThis(), projPos.X, projPos.Y, beeVelX, beeVelY, Main.player[Projectile.owner].beeType(), Main.player[Projectile.owner].beeDamage(Projectile.damage / 3), Main.player[Projectile.owner].beeKB(0f), Main.myPlayer); if (bee.WithinBounds(Main.maxProjectiles)) { Main.projectile[bee].penetrate = 2; @@ -128,24 +114,28 @@ namespace CalamityMod.Projectiles.Ranged } } } + + if (Main.dedServ) + return; + SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - for (int num621 = 0; num621 < 20; num621++) + for (int i = 0; i < 20; i++) { - int num622 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dusty = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 2f); + Main.dust[dusty].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dusty].scale = 0.5f; + Main.dust[dusty].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dusty2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 3f); + Main.dust[dusty2].noGravity = true; + Main.dust[dusty2].velocity *= 5f; + dusty2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 2f); + Main.dust[dusty2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) @@ -191,53 +181,6 @@ namespace CalamityMod.Projectiles.Ranged gore.velocity.Y -= 1f; } } - - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - Player player = Main.player[Projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); - int blastRadius = 0; - if (projID == ProjectileID.RocketII || projID == ProjectileID.ClusterRocketII) - blastRadius = 4; - else if (projID == ProjectileID.RocketIV) - blastRadius = 7; - else if (projID == ProjectileID.MiniNukeRocketII) - blastRadius = 10; - - Projectile.ExpandHitboxBy(14); - - if (Projectile.owner == Main.myPlayer && blastRadius > 0) - { - CalamityUtils.ExplodeandDestroyTiles(Projectile, blastRadius, true, new List() { }, new List() { }); - } - if (Projectile.owner == Main.myPlayer) - { - Point center = Projectile.Center.ToTileCoordinates(); - DelegateMethods.v2_1 = center.ToVector2(); - DelegateMethods.f_1 = 3f; - if (projID == ProjectileID.DryRocket) - { - DelegateMethods.f_1 = 3.5f; - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadDry); - } - else if (projID == ProjectileID.WetRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadWater); - } - else if (projID == ProjectileID.LavaRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadLava); - } - else if (projID == ProjectileID.HoneyRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadHoney); - } - } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) diff --git a/Projectiles/Ranged/HiveMissile.cs b/Projectiles/Ranged/HiveMissile.cs index c6eeb3995b..0d987f93e3 100644 --- a/Projectiles/Ranged/HiveMissile.cs +++ b/Projectiles/Ranged/HiveMissile.cs @@ -1,17 +1,16 @@ -using Microsoft.Xna.Framework; +using System; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; -using System.Collections.Generic; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace CalamityMod.Projectiles.Ranged { public class HiveMissile : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public static Item FalseLauncher = null; + private ref float RocketType => ref Projectile.ai[0]; public override void SetDefaults() { @@ -24,33 +23,26 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; } - private static void DefineFalseLauncher() - { - int rocketID = ItemID.RocketLauncher; - FalseLauncher = new Item(); - FalseLauncher.SetDefaults(rocketID, true); - } - public override void AI() { if (Math.Abs(Projectile.velocity.X) >= 8f || Math.Abs(Projectile.velocity.Y) >= 8f) { - for (int num246 = 0; num246 < 2; num246++) + for (int i = 0; i < 2; i++) { - float num247 = 0f; - float num248 = 0f; - if (num246 == 1) + float halfX = 0f; + float halfY = 0f; + if (i == 1) { - num247 = Projectile.velocity.X * 0.5f; - num248 = Projectile.velocity.Y * 0.5f; + halfX = Projectile.velocity.X * 0.5f; + halfY = Projectile.velocity.Y * 0.5f; } - int num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 6, 0f, 0f, 100, default, 1f); - Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 31, 0f, 0f, 100, default, 0.5f); - Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num249].velocity *= 0.05f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 6, 0f, 0f, 100, default, 1f); + Main.dust[dust].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].velocity *= 0.2f; + Main.dust[dust].noGravity = true; + dust = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 31, 0f, 0f, 100, default, 0.5f); + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dust].velocity *= 0.05f; } } if (Math.Abs(Projectile.velocity.X) < 15f && Math.Abs(Projectile.velocity.Y) < 15f) @@ -59,33 +51,24 @@ namespace CalamityMod.Projectiles.Ranged } else if (Main.rand.NextBool()) { - int num252 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 1f); - Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2)).RotatedBy((double)Projectile.rotation, default) * 1.1f; + int dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 1f); + Main.dust[dust2].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dust2].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dust2].noGravity = true; + Main.dust[dust2].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2)).RotatedBy((double)Projectile.rotation, default) * 1.1f; Main.rand.Next(2); - num252 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 1f); - Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2 - 6)).RotatedBy((double)Projectile.rotation, default) * 1.1f; + dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 1f); + Main.dust[dust2].scale = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dust2].noGravity = true; + Main.dust[dust2].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2 - 6)).RotatedBy((double)Projectile.rotation, default) * 1.1f; } Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(90); - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - Player player = Main.player[Projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); - if (projID == ProjectileID.DryRocket || projID == ProjectileID.WetRocket || projID == ProjectileID.LavaRocket || projID == ProjectileID.HoneyRocket) - { - if (Projectile.wet) - Projectile.timeLeft = 1; - } + if (RocketType == ItemID.DryRocket || RocketType == ItemID.WetRocket || RocketType == ItemID.LavaRocket || RocketType == ItemID.HoneyRocket) + { + if (Projectile.wet) + Projectile.timeLeft = 1; + } } public override bool PreDraw(ref Color lightColor) @@ -97,29 +80,32 @@ namespace CalamityMod.Projectiles.Ranged public override void OnKill(int timeLeft) { + var info = new CalamityUtils.RocketBehaviorInfo((int)RocketType) + { + smallRadius = 5, + mediumRadius = 8, + largeRadius = 11 + }; + int blastRadius = Projectile.RocketBehavior(info); Projectile.ExpandHitboxBy(80); - Projectile.maxPenetrate = -1; - Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; Projectile.Damage(); + if (Projectile.owner == Main.myPlayer) { - int num516 = 3; - for (int num517 = 0; num517 < num516; num517++) + for (int j = 0; j < 3; j++) { - if (num517 % 2 != 1 || Main.rand.NextBool(3)) + if (j % 2 != 1 || Main.rand.NextBool(3)) { - Vector2 value20 = Projectile.position; - Vector2 value21 = Projectile.oldVelocity; - value21.Normalize(); - value21 *= 8f; - float num518 = (float)Main.rand.Next(-35, 36) * 0.01f; - float num519 = (float)Main.rand.Next(-35, 36) * 0.01f; - value20 -= value21 * (float)num517; - num518 += Projectile.oldVelocity.X / 6f; - num519 += Projectile.oldVelocity.Y / 6f; - int bee = Projectile.NewProjectile(Projectile.GetSource_FromThis(), value20.X, value20.Y, num518, num519, Main.player[Projectile.owner].beeType(), Main.player[Projectile.owner].beeDamage(Projectile.damage / 2), Main.player[Projectile.owner].beeKB(0f), Main.myPlayer); + Vector2 projPos = Projectile.position; + Vector2 projVel = Projectile.oldVelocity; + projVel.Normalize(); + projVel *= 8f; + float beeVelX = (float)Main.rand.Next(-35, 36) * 0.01f; + float beeVelY = (float)Main.rand.Next(-35, 36) * 0.01f; + projPos -= projVel * (float)j; + beeVelX += Projectile.oldVelocity.X / 6f; + beeVelY += Projectile.oldVelocity.Y / 6f; + int bee = Projectile.NewProjectile(Projectile.GetSource_FromThis(), projPos.X, projPos.Y, beeVelX, beeVelY, Main.player[Projectile.owner].beeType(), Main.player[Projectile.owner].beeDamage(Projectile.damage / 2), Main.player[Projectile.owner].beeKB(0f), Main.myPlayer); if (bee.WithinBounds(Main.maxProjectiles)) { Main.projectile[bee].penetrate = 2; @@ -128,24 +114,28 @@ namespace CalamityMod.Projectiles.Ranged } } } + + if (Main.dedServ) + return; + SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - for (int num621 = 0; num621 < 20; num621++) + for (int i = 0; i < 20; i++) { - int num622 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 90, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dusty = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 90, 0f, 0f, 100, default, 2f); + Main.dust[dusty].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dusty].scale = 0.5f; + Main.dust[dusty].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 90, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 90, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dusty2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 90, 0f, 0f, 100, default, 3f); + Main.dust[dusty2].noGravity = true; + Main.dust[dusty2].velocity *= 5f; + dusty2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 90, 0f, 0f, 100, default, 2f); + Main.dust[dusty2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) @@ -191,53 +181,6 @@ namespace CalamityMod.Projectiles.Ranged gore.velocity.Y -= 1f; } } - - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - Player player = Main.player[Projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); - int blastRadius = 0; - if (projID == ProjectileID.RocketII || projID == ProjectileID.ClusterRocketII) - blastRadius = 5; - else if (projID == ProjectileID.RocketIV) - blastRadius = 8; - else if (projID == ProjectileID.MiniNukeRocketII) - blastRadius = 11; - - Projectile.ExpandHitboxBy(14); - - if (Projectile.owner == Main.myPlayer && blastRadius > 0) - { - CalamityUtils.ExplodeandDestroyTiles(Projectile, blastRadius, true, new List() { }, new List() { }); - } - if (Projectile.owner == Main.myPlayer) - { - Point center = Projectile.Center.ToTileCoordinates(); - DelegateMethods.v2_1 = center.ToVector2(); - DelegateMethods.f_1 = 3f; - if (projID == ProjectileID.DryRocket) - { - DelegateMethods.f_1 = 3.5f; - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadDry); - } - else if (projID == ProjectileID.WetRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadWater); - } - else if (projID == ProjectileID.LavaRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadLava); - } - else if (projID == ProjectileID.HoneyRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadHoney); - } - } } } } diff --git a/Projectiles/Ranged/KarasawaShot.cs b/Projectiles/Ranged/KarasawaShot.cs index bdcaf53edd..d3e9248584 100644 --- a/Projectiles/Ranged/KarasawaShot.cs +++ b/Projectiles/Ranged/KarasawaShot.cs @@ -38,16 +38,16 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 15f) { - for (int num447 = 0; num447 < 2; num447++) + for (int i = 0; i < 2; i++) { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * ((float)num447 * 0.25f); + Vector2 dustPos = Projectile.position; + dustPos -= Projectile.velocity * ((float)i * 0.25f); Projectile.alpha = 255; - int num448 = Dust.NewDust(vector33, 1, 1, dustTypeOnTimer, 0f, 0f, 0, default, 1f); - Main.dust[num448].noGravity = true; - Main.dust[num448].position = vector33; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.2f; + int dusty = Dust.NewDust(dustPos, 1, 1, dustTypeOnTimer, 0f, 0f, 0, default, 1f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].position = dustPos; + Main.dust[dusty].scale = (float)Main.rand.Next(70, 110) * 0.013f; + Main.dust[dusty].velocity *= 0.2f; } Projectile.ai[0] += 1f; if (Projectile.ai[0] == 48f) @@ -61,18 +61,18 @@ namespace CalamityMod.Projectiles.Ranged } else { - Vector2 value7 = new Vector2(5f, 10f); + Vector2 randVector = new Vector2(5f, 10f); - for (int num41 = 0; num41 < 2; num41++) + for (int j = 0; j < 2; j++) { - int dustType = num41 == 0 ? dust1 : dust2; - Vector2 value8 = Vector2.UnitX * -12f; - value8 = -Vector2.UnitY.RotatedBy((double)(Projectile.ai[0] * 0.1308997f + (float)num41 * 3.14159274f), default) * value7 * 1.5f; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, dustType, 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = 0.75f; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8; - Main.dust[num42].velocity = Projectile.velocity; + int dustType = j == 0 ? dust1 : dust2; + Vector2 randDustPos = Vector2.UnitX * -12f; + randDustPos = -Vector2.UnitY.RotatedBy((double)(Projectile.ai[0] * 0.1308997f + (float)j * 3.14159274f), default) * randVector * 1.5f; + int dusty2 = Dust.NewDust(Projectile.Center, 0, 0, dustType, 0f, 0f, 160, default, 1f); + Main.dust[dusty2].scale = 0.75f; + Main.dust[dusty2].noGravity = true; + Main.dust[dusty2].position = Projectile.Center + randDustPos; + Main.dust[dusty2].velocity = Projectile.velocity; } } } @@ -81,7 +81,7 @@ namespace CalamityMod.Projectiles.Ranged { float angleRandom = 0.1f; - for (int num53 = 0; num53 < 40; num53++) + for (int k = 0; k < 40; k++) { float dustSpeed = Main.rand.NextFloat(6.0f, 12.0f); Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation()); @@ -89,14 +89,14 @@ namespace CalamityMod.Projectiles.Ranged dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); int randomDustType = Main.rand.NextBool() ? dust1 : dust2; - int num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 1.7f); - Dust dust = Main.dust[num54]; + int newDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 1.7f); + Dust dust = Main.dust[newDust]; dust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; dust.noGravity = true; dust.velocity *= randomDustType == dust2 ? 2f : 4f; - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 0.8f); + newDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 0.8f); dust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; dust.velocity *= randomDustType == dust2 ? 1.33f : 2.66f; @@ -105,7 +105,7 @@ namespace CalamityMod.Projectiles.Ranged dust.fadeIn = 1f; dust.color = Color.Blue * 0.5f; } - for (int num55 = 0; num55 < 20; num55++) + for (int l = 0; l < 20; l++) { float dustSpeed = Main.rand.NextFloat(6.0f, 12.0f); Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation()); @@ -113,8 +113,8 @@ namespace CalamityMod.Projectiles.Ranged dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); int randomDustType = Main.rand.NextBool() ? dust1 : dust2; - int num56 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 2f); - Dust dust = Main.dust[num56]; + int newDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 2f); + Dust dust = Main.dust[newDust2]; dust.position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 3f; dust.noGravity = true; @@ -138,21 +138,21 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localNPCHitCooldown = 10; Projectile.Damage(); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) // 108 dusts + int constant = 36; + for (int i = 0; i < constant; i++) // 108 dusts { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.3f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.3f; + rotate = rotate.RotatedBy((double)((float)(i - (constant / 2 - 1)) * 6.28318548f / (float)constant), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, Main.rand.NextBool() ? dust1 : dust2, vector7.X * 0.3f, vector7.Y * 0.3f, 100, default, 2f); - Main.dust[num228].noGravity = true; + int killDust = Dust.NewDust(rotate + faceDirection, 0, 0, Main.rand.NextBool() ? dust1 : dust2, faceDirection.X * 0.3f, faceDirection.Y * 0.3f, 100, default, 2f); + Main.dust[killDust].noGravity = true; - int num229 = Dust.NewDust(vector6 + vector7, 0, 0, Main.rand.NextBool() ? dust1 : dust2, vector7.X * 0.2f, vector7.Y * 0.2f, 100, default, 2f); - Main.dust[num229].noGravity = true; + int killDust2 = Dust.NewDust(rotate + faceDirection, 0, 0, Main.rand.NextBool() ? dust1 : dust2, faceDirection.X * 0.2f, faceDirection.Y * 0.2f, 100, default, 2f); + Main.dust[killDust2].noGravity = true; - int num230 = Dust.NewDust(vector6 + vector7, 0, 0, Main.rand.NextBool() ? dust1 : dust2, vector7.X * 0.1f, vector7.Y * 0.1f, 100, default, 2f); - Main.dust[num230].noGravity = true; + int killDust3 = Dust.NewDust(rotate + faceDirection, 0, 0, Main.rand.NextBool() ? dust1 : dust2, faceDirection.X * 0.1f, faceDirection.Y * 0.1f, 100, default, 2f); + Main.dust[killDust3].noGravity = true; } bool random = Main.rand.NextBool(); diff --git a/Projectiles/Ranged/KingsbaneHoldout.cs b/Projectiles/Ranged/KingsbaneHoldout.cs new file mode 100644 index 0000000000..f51f3a7772 --- /dev/null +++ b/Projectiles/Ranged/KingsbaneHoldout.cs @@ -0,0 +1,174 @@ +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using ReLogic.Utilities; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class KingsbaneHoldout : ModProjectile + { + // Take the name and texture from the weapon + public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + private bool OwnerCanShoot => Owner.channel && !Owner.noItems && !Owner.CCed; + public override string Texture => "CalamityMod/Projectiles/Ranged/KingsbaneWindUp"; + private Player Owner => Main.player[Projectile.owner]; + + public int Time = 0; + public int revTimer = 0; //revving timer + public int framesBetweenShots = 0; + public bool fullRev = false; + public int fullRevShots = 50; + public int windupAnim = 11; + public int soundTimer = 0; + + public override void SetDefaults() + { + Projectile.width = 112; + Projectile.height = 44; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.DamageType = DamageClass.Ranged; + Projectile.ignoreWater = true; + } + public override void SetStaticDefaults() + { + Main.projFrames[Projectile.type] = 10; + } + public override void AI() + { + Time++; + if (Time % 2 == 0) + soundTimer++; + Projectile.frameCounter++; + + if (Projectile.frameCounter > windupAnim && OwnerCanShoot) + { + if (Projectile.frame == 1 && Time < 85) + { + Projectile.frame = 0; + } + else + Projectile.frame++; + if (windupAnim > 0) + windupAnim--; + Projectile.frameCounter = 0; + } + else if (!OwnerCanShoot) + { + Projectile.frame++; + } + if (Projectile.frame >= Main.projFrames[Projectile.type]) + { + Projectile.frame = 2; + } + 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 + new Vector2 (0, 3.8f); + Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 15; + + int bulletAMMO = ProjectileID.Bullet; + Owner.PickAmmo(Owner.ActiveItem(), out bulletAMMO, out float SpeedNoUse, out int bulletDamage, out float kBackNoUse, out int _); + + // Fire Auric Bullets if the owner stops channeling or otherwise cannot use the weapon. + if (!OwnerCanShoot) + { + if (fullRev && fullRevShots > 0) + { + Projectile.timeLeft = 2; + Dust dust2 = Dust.NewDustPerfect(tipPosition - Projectile.velocity * 68, 87, Projectile.velocity.RotatedBy((8.6f * Main.rand.NextFloat(0.975f, 1.025f)) * -Projectile.direction) * Main.rand.NextFloat(5.5f, 7f) + Owner.velocity * 0.5f); + dust2.noGravity = false; + dust2.scale = Main.rand.NextFloat(0.8f, 0.9f); + Dust dust3 = Dust.NewDustPerfect(tipPosition - Projectile.velocity * 5, Main.rand.NextBool(4) ? 169 : 162, (Projectile.velocity * Main.rand.NextFloat(4f, 15.5f)).RotatedByRandom(0.3f)); + dust3.noGravity = true; + dust3.scale = Main.rand.NextFloat(1.3f, 2.2f); + Owner.Calamity().GeneralScreenShakePower = 1.85f; + //recoil + Owner.velocity += -Projectile.velocity * fullRevShots * (Main.zenithWorld ? 0.028f : 0.013f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition + Projectile.velocity * 5 + Main.rand.NextVector2Circular(7, 7), shootVelocity.RotatedByRandom(MathHelper.ToRadians(4f)), ModContent.ProjectileType(), (int)(Projectile.damage * 0.9f), Projectile.knockBack, Projectile.owner); + SoundEngine.PlaySound(SoundID.Item40 with { PitchVariance = 0.4f }, Projectile.Center); + //SoundEngine.PlaySound(Kingsbane.AuricFire with { PitchVariance = 0.4f }, Projectile.Center); + fullRevShots--; + } + } + else + { + if (Time < 90 && soundTimer > (windupAnim + 2)) + { + SoundEngine.PlaySound(SoundID.Item23 with { Pitch = (8 - windupAnim) * 0.15f }, Projectile.Center); + soundTimer = 0; + } + // While channeled, keep refreshing the projectile lifespan + Projectile.timeLeft = 2; + if (Time > 90) + { + fullRev = true; + if (framesBetweenShots == 0) + { + Dust dust2 = Dust.NewDustPerfect(tipPosition - Projectile.velocity * 68, 87, Projectile.velocity.RotatedBy((8.6f * Main.rand.NextFloat(0.985f, 1.015f)) * -Projectile.direction) * Main.rand.NextFloat(4, 5) + Owner.velocity * 0.5f); + dust2.noGravity = false; + dust2.scale = Main.rand.NextFloat(0.8f, 0.9f); + for (int i = 0; i <= 2; i++) + { + Dust dust3 = Dust.NewDustPerfect(tipPosition - Projectile.velocity * 6, Main.rand.NextBool(3) ? 263 : 247, (Projectile.velocity * Main.rand.NextFloat(4f, 15.5f)).RotatedByRandom(0.2f)); + dust3.noGravity = true; + dust3.scale = Main.rand.NextFloat(0.9f, 1.6f); + } + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.Center, shootVelocity.RotatedByRandom(MathHelper.ToRadians(1.5f)), bulletAMMO, Projectile.damage, Projectile.knockBack, Projectile.owner); + SoundEngine.PlaySound(SoundID.Item41 with { Volume = 0.75f}, Projectile.Center); + framesBetweenShots = 3; + } + if (framesBetweenShots > 0) + framesBetweenShots--; + } + + } + UpdateProjectileHeldVariables(armPosition); + ManipulatePlayerVariables(); + } + + private void UpdateProjectileHeldVariables(Vector2 armPosition) + { + if (Main.myPlayer == Projectile.owner) + { + float interpolant = Utils.GetLerpValue(5f, 55f, 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.Center = armPosition + Projectile.velocity * MathHelper.Clamp(47f - (framesBetweenShots * 2), 0f, 47f) + new Vector2 (0, 5); + Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Projectile.spriteDirection = Projectile.direction; + + // Rumble + if (!OwnerCanShoot) + { + Projectile.position += Main.rand.NextVector2Circular(4.5f, 4.5f); + } + } + + private void ManipulatePlayerVariables() + { + Owner.ChangeDir(Projectile.direction); + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); + } + public override bool? CanDamage() => false; + } +} diff --git a/Projectiles/Ranged/KingsbaneWindUp.png b/Projectiles/Ranged/KingsbaneWindUp.png new file mode 100644 index 0000000000..9fa2e0347d Binary files /dev/null and b/Projectiles/Ranged/KingsbaneWindUp.png differ diff --git a/Projectiles/Ranged/LeafArrow.cs b/Projectiles/Ranged/LeafArrow.cs index 04a6fe0a54..9208340d8e 100644 --- a/Projectiles/Ranged/LeafArrow.cs +++ b/Projectiles/Ranged/LeafArrow.cs @@ -84,12 +84,12 @@ namespace CalamityMod.Projectiles.Ranged { SoundEngine.PlaySound(SoundID.Grass, Projectile.position); Projectile.localAI[1] += 1f; - for (int num407 = 0; num407 < 5; num407++) + for (int i = 0; i < 5; i++) { - int num408 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 157, 0f, 0f, 0, new Color(Main.DiscoR, 203, 103), 1f); - Main.dust[num408].noGravity = true; - Main.dust[num408].velocity *= 3f; - Main.dust[num408].scale = 1.5f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 157, 0f, 0f, 0, new Color(Main.DiscoR, 203, 103), 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 3f; + Main.dust[dust].scale = 1.5f; } } } diff --git a/Projectiles/Ranged/MagnaCannonHoldout.cs b/Projectiles/Ranged/MagnaCannonHoldout.cs index 19782f9774..47ddf75246 100644 --- a/Projectiles/Ranged/MagnaCannonHoldout.cs +++ b/Projectiles/Ranged/MagnaCannonHoldout.cs @@ -27,6 +27,7 @@ namespace CalamityMod.Projectiles.Ranged 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; private bool OwnerCanShoot => Owner.channel && !Owner.noItems && !Owner.CCed; @@ -42,6 +43,12 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { + Time++; + if (Time == 1) + Projectile.alpha = 255; + else + Projectile.alpha = 0; + if (Owner.dead) // destroy the holdout if the player dies { Projectile.Kill(); @@ -141,7 +148,7 @@ namespace CalamityMod.Projectiles.Ranged { if (Main.myPlayer == Projectile.owner) { - float interpolant = Utils.GetLerpValue(5f, 25f, Projectile.Distance(Main.MouseWorld), true); + 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); } diff --git a/Projectiles/Ranged/MagnomalyBeam.cs b/Projectiles/Ranged/MagnomalyBeam.cs index c42ae9746f..b8896edfe1 100644 --- a/Projectiles/Ranged/MagnomalyBeam.cs +++ b/Projectiles/Ranged/MagnomalyBeam.cs @@ -39,19 +39,18 @@ namespace CalamityMod.Projectiles.Ranged Projectile.alpha = 0; } Lighting.AddLight(Projectile.Center, Main.DiscoR * 0.25f / 255f, Main.DiscoG * 0.25f / 255f, Main.DiscoB * 0.25f / 255f); - float num55 = 100f; - float num56 = 2f; //3 + float inc = 2f; //3 if (Projectile.ai[1] == 0f) { - Projectile.localAI[0] += num56; - if (Projectile.localAI[0] > num55) + Projectile.localAI[0] += inc; + if (Projectile.localAI[0] > 100f) { - Projectile.localAI[0] = num55; + Projectile.localAI[0] = 100f; } } else { - Projectile.localAI[0] -= num56; + Projectile.localAI[0] -= inc; if (Projectile.localAI[0] <= 0f) { Projectile.Kill(); diff --git a/Projectiles/Ranged/MeowCreature.cs b/Projectiles/Ranged/MeowCreature.cs new file mode 100644 index 0000000000..94a6ac41c4 --- /dev/null +++ b/Projectiles/Ranged/MeowCreature.cs @@ -0,0 +1,75 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Linq; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class MeowCreature : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + + internal PrimitiveTrail TrailDrawer; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 36; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 24; + Projectile.friendly = true; + Projectile.penetrate = 1; + Projectile.MaxUpdates = 2; + Projectile.timeLeft = 90 * Projectile.MaxUpdates; + Projectile.DamageType = DamageClass.Ranged; + } + + public override void AI() + { + CalamityUtils.HomeInOnNPC(Projectile, false, 400f, 15f, 20f); + Projectile.rotation = Projectile.velocity.ToRotation(); + } + + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(Main.rand.NextBool() ? SoundID.Item58 : SoundID.Item57, Projectile.Center); + + // Circular spread of clouds + for (int i = 0; i < 12; i++) + { + Vector2 smokeVel = Main.rand.NextVector2Circular(16f, 16f); + Color smokeColor = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.8f); + Particle smoke = new MediumMistParticle(Projectile.Center, smokeVel, smokeColor, Color.Black, Main.rand.NextFloat(0.6f, 1.6f), 220 - Main.rand.Next(60), 0.1f); + GeneralParticleHandler.SpawnParticle(smoke); + } + } + + internal float WidthFunction(float completionRatio) => (1f - completionRatio) * Projectile.scale * 9f; + internal Color ColorFunction(float completionRatio) + { + float hue = 0.5f + 0.5f * completionRatio * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f); + Color trailColor = Main.hslToRgb(hue, 1f, 0.8f); + return trailColor * Projectile.Opacity; + } + + // The creature glows + public override void PostDraw(Color lightColor) + { + if (TrailDrawer is null) + TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction); + + TrailDrawer.Draw(Projectile.oldPos.Where(oldPos => oldPos != Vector2.Zero), Projectile.Size * 0.5f - Main.screenPosition, 30); + + Texture2D glow = ModContent.Request(Texture).Value; + Main.EntitySpriteDraw(glow, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, glow.Size() * 0.5f, Projectile.scale, SpriteEffects.None); + } + } +} diff --git a/Projectiles/Ranged/MeowCreature.png b/Projectiles/Ranged/MeowCreature.png new file mode 100644 index 0000000000..a6634592f8 Binary files /dev/null and b/Projectiles/Ranged/MeowCreature.png differ diff --git a/Projectiles/Ranged/MeowFire.cs b/Projectiles/Ranged/MeowFire.cs index 7871c8fe72..aaa65e9600 100644 --- a/Projectiles/Ranged/MeowFire.cs +++ b/Projectiles/Ranged/MeowFire.cs @@ -1,8 +1,10 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using System; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace CalamityMod.Projectiles.Ranged { @@ -11,97 +13,51 @@ namespace CalamityMod.Projectiles.Ranged public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public static int Lifetime => 72; + public bool PinkFire => Projectile.ai[0] == 1f; + public ref float Time => ref Projectile.ai[1]; + public override void SetDefaults() { - Projectile.width = 6; - Projectile.height = 6; + Projectile.width = Projectile.height = 6; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 5; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 95; + Projectile.penetrate = 3; + Projectile.MaxUpdates = 3; + Projectile.timeLeft = Lifetime; // 24 effectively Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 10; + Projectile.idStaticNPCHitCooldown = 8; } public override void AI() { - if (Projectile.ai[0] > 7f) - { - float dustScale = 1f; - if (Projectile.ai[0] == 8f) - { - dustScale = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - dustScale = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - dustScale = 0.75f; - } - Projectile.ai[0] += 1f; - for (int i = 0; i < 2; i++) - { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 1.75f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 0.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= dustScale; - dust.velocity += Projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } - } - } + Time++; + + // Determines particle size as well as hitbox + if (Time >= 6f) + Projectile.scale = 1.5f * Utils.GetLerpValue(6f, 30f, Time, true); else + return; // Helps position it at the tip + + // Main smokes composing of blue or pink + float smokeRot = MathHelper.ToRadians(3f); // *Rate of rotation per frame, not a constant rotation + Color smokeColor = Color.Lerp(PinkFire ? Color.DeepPink : Color.DodgerBlue, PinkFire ? Color.Pink : Color.PowderBlue, 0.5f + 0.3f * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f)); + Particle smoke = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, smokeColor, 12, Projectile.scale * Main.rand.NextFloat(0.6f, 1.2f), 0.25f, smokeRot, true, required: true); + GeneralParticleHandler.SpawnParticle(smoke); + + // Overlay the glow on top, a bit brighter + if (Main.rand.NextBool(8)) { - Projectile.ai[0] += 1f; + Color glowColor = Color.Lerp(smokeColor, Color.White, 0.2f); + Particle smokeGlow = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, glowColor, 8, Projectile.scale * Main.rand.NextFloat(0.4f, 0.7f), 0.15f, smokeRot, true, 0.005f); + GeneralParticleHandler.SpawnParticle(smokeGlow); } - Projectile.rotation += 0.3f * (float)Projectile.direction; + + Lighting.AddLight(Projectile.Center, smokeColor.ToVector3() * Projectile.scale * 0.2f); } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - SoundEngine.PlaySound(SoundID.Item57, Projectile.position); - Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y + (float)(Projectile.height / 2); - Projectile.width = 10; - Projectile.height = 10; - Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int j = 0; j < 10; j++) - { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 1f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int k = 0; k < 20; k++) - { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 1.5f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; - } - } + // Circular hitbox adjusted for the size of the smoke particles (which is 52 here) + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 52 * Projectile.scale * 0.5f, targetHitbox); } } diff --git a/Projectiles/Ranged/MeowFire2.cs b/Projectiles/Ranged/MeowFire2.cs deleted file mode 100644 index eca174f82f..0000000000 --- a/Projectiles/Ranged/MeowFire2.cs +++ /dev/null @@ -1,107 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.Audio; - -namespace CalamityMod.Projectiles.Ranged -{ - public class MeowFire2 : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetDefaults() - { - Projectile.width = 6; - Projectile.height = 6; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 5; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 95; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 10; - } - - public override void AI() - { - if (Projectile.ai[0] > 7f) - { - float dustScale = 1f; - if (Projectile.ai[0] == 8f) - { - dustScale = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - dustScale = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - dustScale = 0.75f; - } - Projectile.ai[0] += 1f; - for (int i = 0; i < 2; i++) - { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 73, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 1.75f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 0.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= dustScale; - dust.velocity += Projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } - } - } - else - { - Projectile.ai[0] += 1f; - } - Projectile.rotation += 0.3f * (float)Projectile.direction; - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - SoundEngine.PlaySound(SoundID.Item58, Projectile.position); - Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y + (float)(Projectile.height / 2); - Projectile.width = 10; - Projectile.height = 10; - Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int j = 0; j < 10; j++) - { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 73, 0f, 0f, 100, default, 1f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int k = 0; k < 20; k++) - { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 73, 0f, 0f, 100, default, 1.5f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 73, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; - } - } - } -} diff --git a/Projectiles/Ranged/MineralMortarHoldout.cs b/Projectiles/Ranged/MineralMortarHoldout.cs new file mode 100644 index 0000000000..6b0d1999db --- /dev/null +++ b/Projectiles/Ranged/MineralMortarHoldout.cs @@ -0,0 +1,147 @@ +using System; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class MineralMortarHoldout : ModProjectile, ILocalizedModType + { + public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + public override string Texture => "CalamityMod/Items/Weapons/Ranged/MineralMortar"; + + public Player Owner { get; set; } + public ref float Time => ref Projectile.ai[0]; + public ref float OffsetLength => ref Projectile.localAI[0]; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 68; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.netImportant = true; + } + + public override void AI() + { + bool cantUse = Owner == null || !Owner.active || Owner.dead || !Owner.channel || Owner.CCed || Owner.noItems; + if (cantUse) + Projectile.Kill(); + + Vector2 mouse = Owner.Calamity().mouseWorld; + + Time++; + + // If the time reaches Item.useTime, it'll shoot the projectile, consume ammo and reset the timer. + if (Time >= Owner.itemTimeMax) + { + Owner.PickAmmo(Owner.ActiveItem(), out _, out float speed, out int damage, out float knockback, out int usedItemAmmoId); + + Vector2 position = Projectile.Center + Vector2.UnitX.RotatedBy(Projectile.rotation) * Projectile.Size.Length() * 0.5f; + + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), position, Owner.SafeDirectionTo(mouse) * speed, ModContent.ProjectileType(), damage, knockback, Projectile.owner, usedItemAmmoId); + + // Doesn't sync this to the server, it's just effects. + if (!Main.dedServ) + { + for (int i = 0; i < 20; i++) + { + Vector2 randomDirectionToMouse = Owner.SafeDirectionTo(mouse).RotatedByRandom(MathHelper.PiOver2) * Main.rand.NextFloat(8f, 10f); + Dust shootDust = Dust.NewDustPerfect(position, DustID.Torch, randomDirectionToMouse, Scale: Main.rand.NextFloat(1.5f, 2.5f)); + shootDust.noGravity = true; + shootDust.noLight = true; + shootDust.noLightEmittence = true; + } + + for (int i = 0; i < 8; i++) + { + Vector2 randomDirectionToMouse = Owner.SafeDirectionTo(mouse).RotatedByRandom(MathHelper.PiOver2) * Main.rand.NextFloat(8f, 10f); + Particle shootMist = new MediumMistParticle(position, randomDirectionToMouse, new Color(255, 100, 0), Color.Transparent, Main.rand.NextFloat(.3f, 1f), Main.rand.NextFloat(200f, 400f)); + GeneralParticleHandler.SpawnParticle(shootMist); + } + + for (int i = 0; i < 6; i++) + { + Vector2 randomDirectionToMouse = Owner.SafeDirectionTo(mouse).RotatedByRandom(MathHelper.PiOver2) * Main.rand.NextFloat(2f, 6f); + Particle shootDebri = new StoneDebrisParticle(position, randomDirectionToMouse, Color.Lerp(Color.White, Color.LightGray, Main.rand.NextFloat()), Main.rand.NextFloat(.6f, .8f), Main.rand.Next(30, 45 + 1)); + GeneralParticleHandler.SpawnParticle(shootDebri); + } + + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/ScorchedEarthShot", 3) with { Volume = .2f, Pitch = 1.2f, PitchVariance = 1.1f }, Projectile.Center); + } + + // Makes the distance between the projectile and the player 0, this gives a recoil effect. + OffsetLength = 0f; + + Time = 0f; + } + + // If the recoil happened, reset smoothly to default position. + if (OffsetLength != 15f) + OffsetLength = MathHelper.SmoothStep(OffsetLength, 15f, .2f); + + Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); + Vector2 offset = Projectile.rotation.ToRotationVector2() * OffsetLength; + Vector2 armOffset = -Vector2.UnitY.RotatedBy(Projectile.rotation) * Utils.Remap(Vector2.Dot(Projectile.rotation.ToRotationVector2(), -Vector2.UnitY), 0f, -1f, 10f, 3f) * Projectile.direction; + Projectile.Center = armPosition + offset + armOffset; + + Projectile.velocity = Vector2.SmoothStep(Projectile.velocity, (mouse - Owner.MountedCenter).SafeNormalize(Vector2.Zero) * Projectile.Size.Length(), .4f); + Projectile.rotation = Projectile.velocity.ToRotation(); + Projectile.timeLeft = 2; + + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = Owner.itemAnimation = 2; + Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); + + int direction = MathF.Sign(mouse.X - Owner.MountedCenter.X); + Projectile.spriteDirection = Projectile.direction = direction; + Owner.ChangeDir(direction); + + float armRotation = Projectile.rotation - MathHelper.PiOver2; + Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, armRotation); + Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, armRotation); + + // Multiplayer syncing every second. + if (Time % 60 == 0) + { + Projectile.netUpdate = true; + if (Projectile.netSpam >= 10) + Projectile.netSpam = 9; + } + } + + public override void OnSpawn(IEntitySource source) + { + Owner = Main.player[Projectile.owner]; + OffsetLength = 15f; + } + + public override bool ShouldUpdatePosition() => false; + + public override bool? CanDamage() => false; + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 position = Projectile.Center - Main.screenPosition; + float rotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 origin = texture.Size() * 0.5f; + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + float shake = Utils.Remap(Time, Owner.itemTimeMax * 0.33f, Owner.itemTimeMax, 0f, 3f); + position += Main.rand.NextVector2Circular(shake, shake); + + Main.EntitySpriteDraw(texture, position, null, Projectile.GetAlpha(lightColor), rotation, origin, Projectile.scale, effects); + + return false; + } + } +} diff --git a/Projectiles/Ranged/MineralMortarProjectile.cs b/Projectiles/Ranged/MineralMortarProjectile.cs new file mode 100644 index 0000000000..77b5756a05 --- /dev/null +++ b/Projectiles/Ranged/MineralMortarProjectile.cs @@ -0,0 +1,198 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class MineralMortarProjectile : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + + public Color FrontTrailColor; + public Color BackTrailColor; + public ref float RocketType => ref Projectile.ai[0]; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailingMode[Type] = 2; + ProjectileID.Sets.TrailCacheLength[Type] = 12; + } + + public override void SetDefaults() + { + Projectile.DamageType = DamageClass.Ranged; + Projectile.width = Projectile.height = 42; + Projectile.friendly = true; + Projectile.ignoreWater = true; + } + + public override void AI() + { + if (Projectile.velocity.Y < 25f) + Projectile.velocity.Y += 0.3f; + + Projectile.rotation = Projectile.velocity.ToRotation(); + + // Effects; no server syncing. + if (!Main.dedServ) + { + bool randomDust = Main.rand.NextBool(); + Dust trailDust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, randomDust ? 109 : DustID.Torch, Main.rand.NextFloat(3f), Main.rand.NextFloat(3f), Scale: randomDust ? Main.rand.NextFloat(1f, 1.5f) : Main.rand.NextFloat(1.5f, 2.5f)); + trailDust.noGravity = true; + trailDust.noLight = true; + trailDust.noLightEmittence = true; + + Particle smoke = new MediumMistParticle(Projectile.Center, Main.rand.NextVector2Circular(5f, 5f), new Color(255, 100, 0, 100), Color.Transparent, Main.rand.NextFloat(.3f, 1f), Main.rand.NextFloat(300f, 500f)); + GeneralParticleHandler.SpawnParticle(smoke); + } + + // Multiplayer syncing every second. + if (Projectile.timeLeft % 60 == 0) + { + Projectile.netUpdate = true; + if (Projectile.netSpam >= 10) + Projectile.netSpam = 9; + } + } + + public override void OnSpawn(IEntitySource source) + { + switch (RocketType) + { + case ItemID.DryRocket: + FrontTrailColor = Color.Transparent; + BackTrailColor = Color.Transparent; + break; + + case ItemID.WetRocket: + FrontTrailColor = Color.DarkCyan; + BackTrailColor = Color.Blue; + break; + + case ItemID.LavaRocket: + FrontTrailColor = Color.Red; + BackTrailColor = Color.DarkRed; + break; + + case ItemID.HoneyRocket: + FrontTrailColor = Color.Yellow; + BackTrailColor = Color.Orange; + break; + + default: + FrontTrailColor = Color.Orange; + BackTrailColor = Color.DarkOrange; + break; + } + } + + public override void OnKill(int timeLeft) + { + const int SmallRadius = 4; + const int MediumRadius = 7; + const int BigRadius = 10; + + var info = new CalamityUtils.RocketBehaviorInfo((int)RocketType) + { + smallRadius = SmallRadius, + mediumRadius = MediumRadius, + largeRadius = BigRadius + }; + int blastRadius = Projectile.RocketBehavior(info); + Projectile.ExpandHitboxBy((float)blastRadius); + Projectile.Damage(); + + // Effects; no server syncing. + if (!Main.dedServ) + { + float radius(float smallBoomRadius, float mediumBoomRadius, float bigBoomRadius) + { + if (blastRadius == SmallRadius) + return smallBoomRadius; + + if (blastRadius == MediumRadius) + return mediumBoomRadius; + + if (blastRadius == BigRadius) + return bigBoomRadius; + + return 0f; + } + + Particle boom = new DetailedExplosion(Projectile.Center, Vector2.Zero, Color.Orange, Vector2.One, Main.rand.NextFloat(MathHelper.Pi), 0.1f, radius(0.37f, 0.65f, 0.93f), 15); + GeneralParticleHandler.SpawnParticle(boom); + + for (int i = 1; i < 3; i++) + { + Particle boomRing = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, Color.DarkOrange, Vector2.One, 0f, radius(0.06f, 0.1f, 0.14f) * i, radius(0.57f, 1f, 1.43f) * i, 20); + GeneralParticleHandler.SpawnParticle(boomRing); + } + + for (int i = 0; i < 30; i++) + { + bool randomDust = Main.rand.NextBool(); + Dust boomDust = Dust.NewDustPerfect(Projectile.Center, randomDust ? 109 : DustID.Torch, Main.rand.NextVector2Circular(10f, 10f), Scale: randomDust ? Main.rand.NextFloat(1f, 2f) : Main.rand.NextFloat(2.5f, 3f)); + boomDust.noGravity = true; + boomDust.noLight = true; + boomDust.noLightEmittence = true; + } + + int debriAmount = Main.rand.Next(10, 15 + 1); + for (int debriIndex = 0; debriIndex < debriAmount; debriIndex++) + { + float angle = MathHelper.TwoPi / debriAmount * debriIndex; + Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(2f, 8f); + Particle debri = new StoneDebrisParticle(Projectile.Center, velocity, Color.Lerp(Color.White, Color.LightGray, Main.rand.NextFloat()), Main.rand.NextFloat(0.4f, 0.6f), Main.rand.Next(30, 45 + 1), Main.rand.NextFloat(MathHelper.Pi)); + GeneralParticleHandler.SpawnParticle(debri); + } + + int mistAmount = Main.rand.Next(5, 8 + 1); + for (int mistIndex = 0; mistIndex < mistAmount; mistIndex++) + { + float angle = MathHelper.TwoPi / mistAmount * mistIndex; + Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(5f, 15f); + Particle boomMist = new MediumMistParticle(Projectile.Center, velocity, new Color(255, 100, 0), Color.Transparent, Main.rand.NextFloat(.6f, 1.4f), Main.rand.NextFloat(200f, 400f)); + GeneralParticleHandler.SpawnParticle(boomMist); + } + + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/MineralMortarExplode") { PitchVariance = 0.2f }, Projectile.Center); + } + } + + public static float TrailWidthFunction(float completionRatio) => MathHelper.Lerp(20f, 0f, completionRatio); + + public Color ColorTrailFunction(float completionRatio) => Color.Lerp(BackTrailColor, FrontTrailColor, completionRatio); + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 position = Projectile.Center - Main.screenPosition; + float rotation = Projectile.rotation + MathHelper.PiOver2; + Vector2 origin = texture.Size() * 0.5f; + + PrimitiveTrail trail = new PrimitiveTrail(TrailWidthFunction, ColorTrailFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]); + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SwordSlashTexture")); + trail.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 50); + + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 0; i < 3; i++) + { + Color afterimageDrawColor = Color.DarkOrange with { A = 75 } * (1f - i / (float)Projectile.oldPos.Length); + Vector2 afterimageDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition; + Main.EntitySpriteDraw(texture, afterimageDrawPosition, null, afterimageDrawColor, Projectile.oldRot[i] - MathHelper.PiOver2, origin, Projectile.scale, SpriteEffects.None, 0); + } + } + + Main.EntitySpriteDraw(texture, position, null, Projectile.GetAlpha(lightColor), rotation, origin, Projectile.scale, SpriteEffects.None); + + return false; + } + } +} diff --git a/Projectiles/Ranged/OnyxSharkBomb.png b/Projectiles/Ranged/MineralMortarProjectile.png similarity index 100% rename from Projectiles/Ranged/OnyxSharkBomb.png rename to Projectiles/Ranged/MineralMortarProjectile.png diff --git a/Projectiles/Ranged/MiniRocket.cs b/Projectiles/Ranged/MiniRocket.cs index 8001b01127..6e31d88847 100644 --- a/Projectiles/Ranged/MiniRocket.cs +++ b/Projectiles/Ranged/MiniRocket.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Projectiles.Ranged public class MiniRocket : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public static Item FalseLauncher = null; + private ref float RocketType => ref Projectile.ai[0]; public override void SetStaticDefaults() { @@ -26,23 +26,10 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; } - private static void DefineFalseLauncher() - { - int rocketID = ItemID.RocketLauncher; - FalseLauncher = new Item(); - FalseLauncher.SetDefaults(rocketID, true); - } - public override void AI() { Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(90); - if (Projectile.ai[0] == 0f) - { - SoundEngine.PlaySound(SoundID.Item11, Projectile.Center); - Projectile.ai[0] = 1f; - } - //Animation Projectile.frameCounter++; if (Projectile.frameCounter > 7) @@ -57,40 +44,31 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.velocity.Length() >= 8f) { - for (int num246 = 0; num246 < 2; num246++) + for (int i = 0; i < 2; i++) { - float num247 = 0f; - float num248 = 0f; - if (num246 == 1) + float halfX = 0f; + float halfY = 0f; + if (i == 1) { - num247 = Projectile.velocity.X * 0.5f; - num248 = Projectile.velocity.Y * 0.5f; + halfX = Projectile.velocity.X * 0.5f; + halfY = Projectile.velocity.Y * 0.5f; } - int num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 6, 0f, 0f, 100, default, 1f); - Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 31, 0f, 0f, 100, default, 0.5f); - Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num249].velocity *= 0.05f; + int dusty = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 6, 0f, 0f, 100, default, 1f); + Main.dust[dusty].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dusty].velocity *= 0.2f; + Main.dust[dusty].noGravity = true; + dusty = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 31, 0f, 0f, 100, default, 0.5f); + Main.dust[dusty].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dusty].velocity *= 0.05f; } } CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, 12f, 20f); - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - Player player = Main.player[Projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); - if (projID == ProjectileID.DryRocket || projID == ProjectileID.WetRocket || projID == ProjectileID.LavaRocket || projID == ProjectileID.HoneyRocket) - { - if (Projectile.wet) - Projectile.timeLeft = 1; - } + if (RocketType == ItemID.DryRocket || RocketType == ItemID.WetRocket || RocketType == ItemID.LavaRocket || RocketType == ItemID.HoneyRocket) + { + if (Projectile.wet) + Projectile.timeLeft = 1; + } } public override void OnKill(int timeLeft) @@ -102,23 +80,23 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localNPCHitCooldown = 10; Projectile.Damage(); SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - for (int num621 = 0; num621 < 20; num621++) + for (int j = 0; j < 20; j++) { - int num622 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int k = 0; k < 30; k++) { - int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 3f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 2f); + Main.dust[dust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) @@ -165,52 +143,42 @@ namespace CalamityMod.Projectiles.Ranged } } - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - Player player = Main.player[Projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); - int blastRadius = 0; - if (projID == ProjectileID.RocketII || projID == ProjectileID.ClusterRocketII) - blastRadius = 3; - else if (projID == ProjectileID.RocketIV) - blastRadius = 6; - else if (projID == ProjectileID.MiniNukeRocketII) - blastRadius = 9; + // Only do rocket effects for the owner client side + if (Projectile.owner != Main.myPlayer) + return; + int blastRadius = 0; + if (RocketType == ItemID.RocketII) + blastRadius = 3; + else if (RocketType == ItemID.RocketIV) + blastRadius = 6; + else if (RocketType == ItemID.MiniNukeII) + blastRadius = 9; Projectile.ExpandHitboxBy(14); - if (Projectile.owner == Main.myPlayer && blastRadius > 0) + if (blastRadius > 0) + Projectile.ExplodeTiles(blastRadius); + + Point center = Projectile.Center.ToTileCoordinates(); + DelegateMethods.v2_1 = center.ToVector2(); + DelegateMethods.f_1 = 3f; + if (RocketType == ItemID.DryRocket) { - CalamityUtils.ExplodeandDestroyTiles(Projectile, blastRadius, true, new List() { }, new List() { }); + DelegateMethods.f_1 = 3.5f; + Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadDry); + } + else if (RocketType == ItemID.WetRocket) + { + Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadWater); + } + else if (RocketType == ItemID.LavaRocket) + { + Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadLava); + } + else if (RocketType == ItemID.HoneyRocket) + { + Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadHoney); } - if (Projectile.owner == Main.myPlayer) - { - Point center = Projectile.Center.ToTileCoordinates(); - DelegateMethods.v2_1 = center.ToVector2(); - DelegateMethods.f_1 = 3f; - if (projID == ProjectileID.DryRocket) - { - DelegateMethods.f_1 = 3.5f; - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadDry); - } - else if (projID == ProjectileID.WetRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadWater); - } - else if (projID == ProjectileID.LavaRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadLava); - } - else if (projID == ProjectileID.HoneyRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadHoney); - } - } } } } diff --git a/Projectiles/Ranged/MistArrow.cs b/Projectiles/Ranged/MistArrow.cs index a61118564e..27a6539751 100644 --- a/Projectiles/Ranged/MistArrow.cs +++ b/Projectiles/Ranged/MistArrow.cs @@ -57,9 +57,9 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.localAI[0] > 4f) { Vector2 dspeed = -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.6f); - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 31, 0f, 0f, 100, new Color(237, 242, 242, 200), 1.2f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity = dspeed; + int whiteDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 31, 0f, 0f, 100, new Color(237, 242, 242, 200), 1.2f); + Main.dust[whiteDust].noGravity = true; + Main.dust[whiteDust].velocity = dspeed; } } diff --git a/Projectiles/Ranged/MortarRoundProj.cs b/Projectiles/Ranged/MortarRoundProj.cs index 3b010f0f09..686aaf62c3 100644 --- a/Projectiles/Ranged/MortarRoundProj.cs +++ b/Projectiles/Ranged/MortarRoundProj.cs @@ -1,12 +1,10 @@ -using CalamityMod.Tiles.Abyss; -using CalamityMod.Walls; +using CalamityMod.Items.Ammo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System.Collections.Generic; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace CalamityMod.Projectiles.Ranged { @@ -28,6 +26,8 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + + // If moving fast enough, produce dust. Since it's a bullet, it should always be moving fast enough. if (Projectile.velocity.Length() >= 8f) { for (int d = 0; d < 2; d++) @@ -57,19 +57,37 @@ namespace CalamityMod.Projectiles.Ranged return false; } - public override void OnKill(int timeLeft) + public override void OnKill(int timeLeft) => Explode(); + + private void Explode() { - Projectile.ExpandHitboxBy(200); + // Apply damage a second time on explosion. This explosion also has double knockback. + Projectile.ExpandHitboxBy(MortarRound.HitboxBlastRadius); Projectile.maxPenetrate = Projectile.penetrate = -1; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; - Projectile.knockBack *= 5f; + Projectile.knockBack *= 2f; Projectile.Damage(); + + // Actually destroy tiles. Blast radius is significantly increased in GFB. + if (Projectile.owner == Main.myPlayer) + Projectile.ExplodeTiles(MortarRound.TileBlastRadius, true); + + // Play standard explosion sound. SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); + // Spawn standard explosion dust and gores. + SpawnDust(Projectile); + SpawnExplosionGores(Projectile); + } + + // Spawn explosion dust (smoke and fire). + // Reused by Rubber Mortar Rounds. + internal static void SpawnDust(Projectile p) + { for (int d = 0; d < 40; d++) { - int smoke = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Smoke, 0f, 0f, 100, default, 2f); + int smoke = Dust.NewDust(p.position, p.width, p.height, DustID.Smoke, 0f, 0f, 100, default, 2f); Main.dust[smoke].velocity *= 3f; if (Main.rand.NextBool()) { @@ -79,71 +97,59 @@ namespace CalamityMod.Projectiles.Ranged } for (int d = 0; d < 70; d++) { - int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 3f); + int fire = Dust.NewDust(p.position, p.width, p.height, 6, 0f, 0f, 100, default, 3f); Main.dust[fire].noGravity = true; Main.dust[fire].velocity *= 5f; - fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 2f); + fire = Dust.NewDust(p.position, p.width, p.height, 6, 0f, 0f, 100, default, 2f); Main.dust[fire].velocity *= 2f; } + } - if (Main.netMode != NetmodeID.Server) + // Spawn explosion gores (smoke puffs). + // Reused by Rubber Mortar Rounds. + internal static void SpawnExplosionGores(Projectile p) + { + if (Main.netMode == NetmodeID.Server) + return; + + Vector2 goreSource = p.Center; + int goreAmt = 3; + Vector2 source = new Vector2(goreSource.X - 24f, goreSource.Y - 24f); + for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++) { - Vector2 goreSource = Projectile.Center; - int goreAmt = 3; - Vector2 source = new Vector2(goreSource.X - 24f, goreSource.Y - 24f); - for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++) + float velocityMult = 0.33f; + if (goreIndex < (goreAmt / 3)) { - float velocityMult = 0.33f; - if (goreIndex < (goreAmt / 3)) - { - velocityMult = 0.66f; - } - if (goreIndex >= (2 * goreAmt / 3)) - { - velocityMult = 1f; - } - Mod mod = ModContent.GetInstance(); - int type = Main.rand.Next(61, 64); - int smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - Gore gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y -= 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y -= 1f; + velocityMult = 0.66f; } - } - - Projectile.ExpandHitboxBy(14); - - if (Projectile.owner == Main.myPlayer) - { - CalamityUtils.ExplodeandDestroyTiles(Projectile, 5, false, new List() + if (goreIndex >= (2 * goreAmt / 3)) { - ModContent.TileType(), - ModContent.TileType() - }, - new List() - { - ModContent.WallType(), - ModContent.WallType() - }); + velocityMult = 1f; + } + int type = Main.rand.Next(61, 64); + int smoke = Gore.NewGore(p.GetSource_FromAI(), source, default, type, 1f); + Gore gore = Main.gore[smoke]; + gore.velocity *= velocityMult; + gore.velocity.X += 1f; + gore.velocity.Y += 1f; + type = Main.rand.Next(61, 64); + smoke = Gore.NewGore(p.GetSource_FromAI(), source, default, type, 1f); + gore = Main.gore[smoke]; + gore.velocity *= velocityMult; + gore.velocity.X -= 1f; + gore.velocity.Y += 1f; + type = Main.rand.Next(61, 64); + smoke = Gore.NewGore(p.GetSource_FromAI(), source, default, type, 1f); + gore = Main.gore[smoke]; + gore.velocity *= velocityMult; + gore.velocity.X += 1f; + gore.velocity.Y -= 1f; + type = Main.rand.Next(61, 64); + smoke = Gore.NewGore(p.GetSource_FromAI(), source, default, type, 1f); + gore = Main.gore[smoke]; + gore.velocity *= velocityMult; + gore.velocity.X -= 1f; + gore.velocity.Y -= 1f; } } } diff --git a/Projectiles/Ranged/Nanomachine.cs b/Projectiles/Ranged/Nanomachine.cs index 9cd1ec45bf..75f9d5c6a7 100644 --- a/Projectiles/Ranged/Nanomachine.cs +++ b/Projectiles/Ranged/Nanomachine.cs @@ -63,63 +63,63 @@ namespace CalamityMod.Projectiles.Ranged Vector2 dspeed = -Projectile.velocity * Main.rand.NextFloat(0.5f, 0.8f); float x2 = Projectile.Center.X - Projectile.velocity.X / 10f; float y2 = Projectile.Center.Y - Projectile.velocity.Y / 10f; - int num137 = Dust.NewDust(new Vector2(x2, y2), 1, 1, 229, 0f, 0f, 0, default, 0.8f); - Main.dust[num137].alpha = Projectile.alpha; - Main.dust[num137].position.X = x2; - Main.dust[num137].position.Y = y2; - Main.dust[num137].velocity = dspeed; - Main.dust[num137].noGravity = true; + int nanoDust = Dust.NewDust(new Vector2(x2, y2), 1, 1, 229, 0f, 0f, 0, default, 0.8f); + Main.dust[nanoDust].alpha = Projectile.alpha; + Main.dust[nanoDust].position.X = x2; + Main.dust[nanoDust].position.Y = y2; + Main.dust[nanoDust].velocity = dspeed; + Main.dust[nanoDust].noGravity = true; - float num138 = (float)Math.Sqrt((double)(Projectile.velocity.X * Projectile.velocity.X + Projectile.velocity.Y * Projectile.velocity.Y)); - float num139 = Projectile.localAI[0]; - if (num139 == 0f) + float velocityAdjust = (float)Math.Sqrt((double)(Projectile.velocity.X * Projectile.velocity.X + Projectile.velocity.Y * Projectile.velocity.Y)); + float aiTracker = Projectile.localAI[0]; + if (aiTracker == 0f) { - Projectile.localAI[0] = num138; - num139 = num138; + Projectile.localAI[0] = velocityAdjust; + aiTracker = velocityAdjust; } - float num140 = Projectile.position.X; - float num141 = Projectile.position.Y; - float num142 = 800f; - bool flag4 = false; - int num143 = 0; + float projX = Projectile.position.X; + float projY = Projectile.position.Y; + float constant = 800f; + bool canHit = false; + int targetID = 0; if (Projectile.ai[1] == 0f) { - for (int num144 = 0; num144 < Main.maxNPCs; num144++) + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num144].CanBeChasedBy(Projectile, false) && (Projectile.ai[1] == 0f || Projectile.ai[1] == (float)(num144 + 1))) + if (Main.npc[i].CanBeChasedBy(Projectile, false) && (Projectile.ai[1] == 0f || Projectile.ai[1] == (float)(i + 1))) { - float num145 = Main.npc[num144].position.X + (float)(Main.npc[num144].width / 2); - float num146 = Main.npc[num144].position.Y + (float)(Main.npc[num144].height / 2); - float num147 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num145) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num146); - if (num147 < num142 && Collision.CanHit(new Vector2(Projectile.position.X + (float)(Projectile.width / 2), Projectile.position.Y + (float)(Projectile.height / 2)), 1, 1, Main.npc[num144].position, Main.npc[num144].width, Main.npc[num144].height)) + float targetX = Main.npc[i].position.X + (float)(Main.npc[i].width / 2); + float targetY = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2); + float targetDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - targetX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - targetY); + if (targetDist < constant && Collision.CanHit(new Vector2(Projectile.position.X + (float)(Projectile.width / 2), Projectile.position.Y + (float)(Projectile.height / 2)), 1, 1, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height)) { - num142 = num147; - num140 = num145; - num141 = num146; - flag4 = true; - num143 = num144; + constant = targetDist; + projX = targetX; + projY = targetY; + canHit = true; + targetID = i; } } } - if (flag4) + if (canHit) { - Projectile.ai[1] = (float)(num143 + 1); + Projectile.ai[1] = (float)(targetID + 1); } - flag4 = false; + canHit = false; } if (Projectile.ai[1] > 0f) { - int num148 = (int)(Projectile.ai[1] - 1f); - if (Main.npc[num148].active && Main.npc[num148].CanBeChasedBy(Projectile, true) && !Main.npc[num148].dontTakeDamage) + int secondTargetID = (int)(Projectile.ai[1] - 1f); + if (Main.npc[secondTargetID].active && Main.npc[secondTargetID].CanBeChasedBy(Projectile, true) && !Main.npc[secondTargetID].dontTakeDamage) { - float num149 = Main.npc[num148].position.X + (float)(Main.npc[num148].width / 2); - float num150 = Main.npc[num148].position.Y + (float)(Main.npc[num148].height / 2); - float num151 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num149) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num150); - if (num151 < 1000f) + float secondTargetX = Main.npc[secondTargetID].position.X + (float)(Main.npc[secondTargetID].width / 2); + float secondTargetY = Main.npc[secondTargetID].position.Y + (float)(Main.npc[secondTargetID].height / 2); + float secondTargetDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - secondTargetX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - secondTargetY); + if (secondTargetDist < 1000f) { - flag4 = true; - num140 = Main.npc[num148].position.X + (float)(Main.npc[num148].width / 2); - num141 = Main.npc[num148].position.Y + (float)(Main.npc[num148].height / 2); + canHit = true; + projX = Main.npc[secondTargetID].position.X + (float)(Main.npc[secondTargetID].width / 2); + projY = Main.npc[secondTargetID].position.Y + (float)(Main.npc[secondTargetID].height / 2); } } else @@ -129,21 +129,20 @@ namespace CalamityMod.Projectiles.Ranged } if (!Projectile.friendly) { - flag4 = false; + canHit = false; } - if (flag4) + if (canHit) { - float num152 = num139; - Vector2 vector13 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num153 = num140 - vector13.X; - float num154 = num141 - vector13.Y; - float num155 = (float)Math.Sqrt((double)(num153 * num153 + num154 * num154)); - num155 = num152 / num155; - num153 *= num155; - num154 *= num155; - int num156 = 12; - Projectile.velocity.X = (Projectile.velocity.X * (float)(num156 - 1) + num153) / (float)num156; - Projectile.velocity.Y = (Projectile.velocity.Y * (float)(num156 - 1) + num154) / (float)num156; + Vector2 projPos = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float projXSpeed = projX - projPos.X; + float projYSpeed = projY - projPos.Y; + float projSpeedAdjust = (float)Math.Sqrt((double)(projXSpeed * projXSpeed + projYSpeed * projYSpeed)); + projSpeedAdjust = aiTracker / projSpeedAdjust; + projXSpeed *= projSpeedAdjust; + projYSpeed *= projSpeedAdjust; + int projVelAdjust = 12; + Projectile.velocity.X = (Projectile.velocity.X * (float)(projVelAdjust - 1) + projXSpeed) / (float)projVelAdjust; + Projectile.velocity.Y = (Projectile.velocity.Y * (float)(projVelAdjust - 1) + projYSpeed) / (float)projVelAdjust; } } diff --git a/Projectiles/Ranged/NeedlerProj.cs b/Projectiles/Ranged/NeedlerProj.cs index 01ebd823a5..d01ef19e08 100644 --- a/Projectiles/Ranged/NeedlerProj.cs +++ b/Projectiles/Ranged/NeedlerProj.cs @@ -35,11 +35,11 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localAI[1] += 1f; if (Projectile.localAI[1] > 4f) { - for (int num468 = 0; num468 < 2; num468++) + for (int i = 0; i < 2; i++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 46, 0f, 0f, 100, default, 0.75f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int dusty = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 46, 0f, 0f, 100, default, 0.75f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].velocity *= 0f; } } } @@ -54,23 +54,23 @@ namespace CalamityMod.Projectiles.Ranged Projectile.width = Projectile.height = 48; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 3; num621++) + for (int j = 0; j < 3; j++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 46, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 46, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 5; num623++) + for (int k = 0; k < 5; k++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 39, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 44, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 39, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 44, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); + Main.dust[dust2].velocity *= 2f; } } } diff --git a/Projectiles/Ranged/NovaChargedShot.png b/Projectiles/Ranged/NovaChargedShot.png index a88840b773..3856109fa3 100644 Binary files a/Projectiles/Ranged/NovaChargedShot.png and b/Projectiles/Ranged/NovaChargedShot.png differ diff --git a/Projectiles/Ranged/NovaShot.cs b/Projectiles/Ranged/NovaShot.cs index ef7fdc8dc3..01f16f0119 100644 --- a/Projectiles/Ranged/NovaShot.cs +++ b/Projectiles/Ranged/NovaShot.cs @@ -38,21 +38,12 @@ namespace CalamityMod.Projectiles.Ranged //Dust dust = Dust.NewDustPerfect(Projectile.Center, 107); // + Main.rand.NextVector2Circular(-3, 3) //dust.noGravity = true; //dust.scale = 0.5f; - if (Main.rand.NextBool(4)) + if (Projectile.timeLeft % 2 == 0 && Projectile.timeLeft < 290) { - Vector2 SparkVelocity1 = Projectile.velocity.RotatedBy(-3, default) * 0.1f - Projectile.velocity / 2f; - Vector2 SparkPosition1 = Projectile.velocity.RotatedBy(-0.8, default); - SparkParticle spark = new SparkParticle(Projectile.Center + SparkPosition1, SparkVelocity1, false, Main.rand.Next(4, 5), Main.rand.NextFloat(0.4f, 0.6f), Color.Lime); + SparkParticle spark = new SparkParticle(Projectile.Center - Projectile.velocity * 0.5f, Projectile.velocity * 0.01f, false, 5, 1f, Color.Lime * 0.6f); GeneralParticleHandler.SpawnParticle(spark); } - if (Main.rand.NextBool(4)) - { - Vector2 SparkVelocity2 = Projectile.velocity.RotatedBy(3, default) * 0.1f - Projectile.velocity / 2f; - Vector2 SparkPosition2 = Projectile.velocity.RotatedBy(0.8, default); - SparkParticle spark2 = new SparkParticle(Projectile.Center + SparkPosition2, SparkVelocity2, false, Main.rand.Next(4, 5), Main.rand.NextFloat(0.4f, 0.6f), Main.rand.NextBool(4) ? Color.Chartreuse : Color.Lime); - GeneralParticleHandler.SpawnParticle(spark2); - } } public override bool PreDraw(ref Color lightColor) { @@ -69,7 +60,8 @@ namespace CalamityMod.Projectiles.Ranged } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - Projectile.damage = (int)(Projectile.damage * 0.88f); + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.88f); if (Projectile.damage < 1) Projectile.damage = 1; } diff --git a/Projectiles/Ranged/NovaShot.png b/Projectiles/Ranged/NovaShot.png index 4bcbe3130b..b2e768f137 100644 Binary files a/Projectiles/Ranged/NovaShot.png and b/Projectiles/Ranged/NovaShot.png differ diff --git a/Projectiles/Ranged/Nuke.cs b/Projectiles/Ranged/Nuke.cs index 453b307c53..a9a12d7939 100644 --- a/Projectiles/Ranged/Nuke.cs +++ b/Projectiles/Ranged/Nuke.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Projectiles.Ranged { public new string LocalizationCategory => "Projectiles.Ranged"; public int flarePowderTimer = 12; - public static Item FalseLauncher = null; + private ref float RocketType => ref Projectile.ai[0]; public override void SetStaticDefaults() { @@ -34,13 +34,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; } - private static void DefineFalseLauncher() - { - int rocketID = ItemID.RocketLauncher; - FalseLauncher = new Item(); - FalseLauncher.SetDefaults(rocketID, true); - } - public override void AI() { //Animation @@ -71,33 +64,23 @@ namespace CalamityMod.Projectiles.Ranged if (Math.Abs(Projectile.velocity.X) >= 8f || Math.Abs(Projectile.velocity.Y) >= 8f) { - float num247 = Projectile.velocity.X * 0.5f; - float num248 = Projectile.velocity.Y * 0.5f; - int num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 244, 0f, 0f, 100, default, 1f); - Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 244, 0f, 0f, 100, default, 0.5f); - Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num249].velocity *= 0.05f; + float halfX = Projectile.velocity.X * 0.5f; + float halfY = Projectile.velocity.Y * 0.5f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 244, 0f, 0f, 100, default, 1f); + Main.dust[dust].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].velocity *= 0.2f; + Main.dust[dust].noGravity = true; + dust = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 244, 0f, 0f, 100, default, 0.5f); + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dust].velocity *= 0.05f; } - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - - Player player = Main.player[Projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); - if (projID == ProjectileID.DryRocket || projID == ProjectileID.WetRocket || projID == ProjectileID.LavaRocket || projID == ProjectileID.HoneyRocket) - { - Projectile.ignoreWater = false; - if (Projectile.wet) - Projectile.timeLeft = 1; - } + if (RocketType == ItemID.DryRocket || RocketType == ItemID.WetRocket || RocketType == ItemID.LavaRocket || RocketType == ItemID.HoneyRocket) + { + Projectile.ignoreWater = false; + if (Projectile.wet) + Projectile.timeLeft = 1; + } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) @@ -182,52 +165,43 @@ namespace CalamityMod.Projectiles.Ranged } } - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - Player player = Main.player[Projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); + // Only do rocket effects for the owner client side + if (Projectile.owner != Main.myPlayer) + return; + int blastRadius = 0; - if (projID == ProjectileID.RocketII || projID == ProjectileID.ClusterRocketII) + if (RocketType == ItemID.RocketII) blastRadius = 6; - else if (projID == ProjectileID.RocketIV) + else if (RocketType == ItemID.RocketIV) blastRadius = 12; - else if (projID == ProjectileID.MiniNukeRocketII) + else if (RocketType == ItemID.MiniNukeII) blastRadius = 18; Projectile.ExpandHitboxBy(22); - if (Projectile.owner == Main.myPlayer && blastRadius > 0) + if (blastRadius > 0) + Projectile.ExplodeTiles(blastRadius); + + Point center = Projectile.Center.ToTileCoordinates(); + DelegateMethods.v2_1 = center.ToVector2(); + DelegateMethods.f_1 = 4f; + if (RocketType == ItemID.DryRocket) { - CalamityUtils.ExplodeandDestroyTiles(Projectile, blastRadius, true, new List() { }, new List() { }); + DelegateMethods.f_1 = 4.5f; + Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadDry); + } + else if (RocketType == ItemID.WetRocket) + { + Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadWater); + } + else if (RocketType == ItemID.LavaRocket) + { + Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadLava); + } + else if (RocketType == ItemID.HoneyRocket) + { + Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadHoney); } - if (Projectile.owner == Main.myPlayer) - { - Point center = Projectile.Center.ToTileCoordinates(); - DelegateMethods.v2_1 = center.ToVector2(); - DelegateMethods.f_1 = 4f; - if (projID == ProjectileID.DryRocket) - { - DelegateMethods.f_1 = 4.5f; - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadDry); - } - else if (projID == ProjectileID.WetRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadWater); - } - else if (projID == ProjectileID.LavaRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadLava); - } - else if (projID == ProjectileID.HoneyRocket) - { - Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadHoney); - } - } } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Ranged/NullShot.cs b/Projectiles/Ranged/NullShot.cs index bb6596ff6d..13a6960350 100644 --- a/Projectiles/Ranged/NullShot.cs +++ b/Projectiles/Ranged/NullShot.cs @@ -31,12 +31,12 @@ namespace CalamityMod.Projectiles.Ranged { float x = Projectile.position.X - Projectile.velocity.X / 10f * (float)num134; float y = Projectile.position.Y - Projectile.velocity.Y / 10f * (float)num134; - int num135 = Dust.NewDust(new Vector2(x, y), 1, 1, 160, 0f, 0f, 0, default, 2f); - Main.dust[num135].alpha = Projectile.alpha; - Main.dust[num135].position.X = x; - Main.dust[num135].position.Y = y; - Main.dust[num135].velocity *= 0f; - Main.dust[num135].noGravity = true; + int dust = Dust.NewDust(new Vector2(x, y), 1, 1, 160, 0f, 0f, 0, default, 2f); + Main.dust[dust].alpha = Projectile.alpha; + Main.dust[dust].position.X = x; + Main.dust[dust].position.Y = y; + Main.dust[dust].velocity *= 0f; + Main.dust[dust].noGravity = true; } } } diff --git a/Projectiles/Ranged/NullShot2.cs b/Projectiles/Ranged/NullShot2.cs index b644ec8077..caad64455d 100644 --- a/Projectiles/Ranged/NullShot2.cs +++ b/Projectiles/Ranged/NullShot2.cs @@ -32,12 +32,12 @@ namespace CalamityMod.Projectiles.Ranged { float x = Projectile.position.X - Projectile.velocity.X / 10f * (float)num134; float y = Projectile.position.Y - Projectile.velocity.Y / 10f * (float)num134; - int num135 = Dust.NewDust(new Vector2(x, y), 1, 1, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[num135].alpha = Projectile.alpha; - Main.dust[num135].position.X = x; - Main.dust[num135].position.Y = y; - Main.dust[num135].velocity *= 0f; - Main.dust[num135].noGravity = true; + int dust = Dust.NewDust(new Vector2(x, y), 1, 1, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Main.dust[dust].alpha = Projectile.alpha; + Main.dust[dust].position.X = x; + Main.dust[dust].position.Y = y; + Main.dust[dust].velocity *= 0f; + Main.dust[dust].noGravity = true; } } } diff --git a/Projectiles/Ranged/OnyxSharkBomb.cs b/Projectiles/Ranged/OnyxSharkBomb.cs deleted file mode 100644 index 8980962e22..0000000000 --- a/Projectiles/Ranged/OnyxSharkBomb.cs +++ /dev/null @@ -1,99 +0,0 @@ -using Microsoft.Xna.Framework; -using System; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.Audio; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; - -namespace CalamityMod.Projectiles.Ranged -{ - public class OnyxSharkBomb : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8; - ProjectileID.Sets.TrailingMode[Projectile.type] = 0; - } - - public override void SetDefaults() - { - Projectile.width = 30; - Projectile.height = 30; - Projectile.friendly = true; - Projectile.penetrate = 1; - Projectile.timeLeft = 300; - Projectile.DamageType = DamageClass.Ranged; - } - - public override void AI() - { - Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) + 1.57f; - if (Math.Abs(Projectile.velocity.X) >= 8f || Math.Abs(Projectile.velocity.Y) >= 8f) - { - for (int num246 = 0; num246 < 2; num246++) - { - float num247 = 0f; - float num248 = 0f; - if (num246 == 1) - { - num247 = Projectile.velocity.X * 0.5f; - num248 = Projectile.velocity.Y * 0.5f; - } - int num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 109, 0f, 0f, 100, default, 0.5f); - Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 159, 0f, 0f, 100, default, 0.25f); - Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num249].velocity *= 0.05f; - } - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 180); - - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 180); - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); - return false; - } - - public override void OnKill(int timeLeft) - { - Projectile.position = Projectile.Center; - Projectile.width = Projectile.height = 32; - Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - Projectile.maxPenetrate = -1; - Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - Projectile.Damage(); - for (int k = 0; k < 10; k++) - { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 109, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f); - } - SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - for (int k = 0; k < 5; k++) - { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 159, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f); - } - float spread = 45f * 0.0174f; - double startAngle = Math.Atan2(Projectile.velocity.X, Projectile.velocity.Y) - spread / 2; - double deltaAngle = spread / 8f; - double offsetAngle; - int i; - for (i = 0; i < 2; i++) - { - offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), (int)(Projectile.damage * 0.4), Projectile.knockBack, Projectile.owner, 0f, 0f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), (int)(Projectile.damage * 0.4), Projectile.knockBack, Projectile.owner, 0f, 0f); - } - } - } -} diff --git a/Projectiles/Ranged/OpalChargedStrike.cs b/Projectiles/Ranged/OpalChargedStrike.cs index 4fd1285820..3276acb60c 100644 --- a/Projectiles/Ranged/OpalChargedStrike.cs +++ b/Projectiles/Ranged/OpalChargedStrike.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; @@ -31,21 +32,19 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { - if (Main.rand.NextBool()) + if (Main.rand.NextBool(3)) { - Vector2 position = Projectile.Center + Vector2.Normalize(Projectile.velocity); - Dust dust = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 162, 0f, 0f, 0, default, Main.rand.NextFloat(1.2f, 1.5f))]; - dust.position = position; - dust.velocity = Projectile.velocity.RotatedBy(0.2, default) * 0.1f + Projectile.velocity / 8f; - dust.position += Projectile.velocity.RotatedBy(0.2, default); - dust.fadeIn = 0.5f; - dust.noGravity = true; - dust = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 162, 0f, 0f, 0, default, Main.rand.NextFloat(1.2f, 1.5f))]; - dust.position = position; - dust.velocity = Projectile.velocity.RotatedBy(-0.2, default) * 0.1f + Projectile.velocity / 8f; - dust.position += Projectile.velocity.RotatedBy(-0.2, default); - dust.fadeIn = 0.5f; - dust.noGravity = true; + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(7, 7), 162); + dust.scale = 1.3f; + dust.velocity = -Projectile.velocity * 0.4f; + } + + Player Owner = Main.player[Projectile.owner]; + float playerDist = Vector2.Distance(Owner.Center, Projectile.Center); + if (Projectile.timeLeft % 2 == 0 && playerDist < 1400f && Projectile.timeLeft < 290) + { + SparkParticle spark = new SparkParticle(Projectile.Center - Projectile.velocity * 3f, -Projectile.velocity * 0.05f, false, 9, 2f, Color.OrangeRed * 0.25f); + GeneralParticleHandler.SpawnParticle(spark); } Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; } @@ -61,7 +60,8 @@ namespace CalamityMod.Projectiles.Ranged } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - Projectile.damage = (int)(Projectile.damage * 0.80f); + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.80f); if (Projectile.damage < 1) Projectile.damage = 1; } diff --git a/Projectiles/Ranged/OpalStrikerHoldout.cs b/Projectiles/Ranged/OpalStrikerHoldout.cs index ca1e28c2df..c43141bd89 100644 --- a/Projectiles/Ranged/OpalStrikerHoldout.cs +++ b/Projectiles/Ranged/OpalStrikerHoldout.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Projectiles.Ranged public override LocalizedText DisplayName => CalamityUtils.GetItemName(); public override string Texture => "CalamityMod/Items/Weapons/Ranged/OpalStriker"; - public static float ChargedDamageMult = 6f; + public static float ChargedDamageMult = 4.3f; public static float ChargedKBMult = 3f; public static float BulletSpeed = 12f; @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Ranged private ref float CurrentChargingFrames => ref Projectile.ai[0]; private bool FullyCharged => CurrentChargingFrames >= OpalStriker.FullChargeFrames; - + public int Time = 0; private bool OwnerCanShoot => Owner.channel && !Owner.noItems && !Owner.CCed; public override void SetDefaults() @@ -40,6 +40,12 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { + Time++; + if (Time == 1) + Projectile.alpha = 255; + else + Projectile.alpha = 0; + if (Owner.dead) // destroy the holdout if the player dies { Projectile.Kill(); @@ -47,7 +53,7 @@ namespace CalamityMod.Projectiles.Ranged } Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); - Vector2 tipPosition = armPosition + Projectile.velocity * Projectile.width * 0.85f; + 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; @@ -130,7 +136,7 @@ namespace CalamityMod.Projectiles.Ranged { if (Main.myPlayer == Projectile.owner) { - float interpolant = Utils.GetLerpValue(5f, 25f, Projectile.Distance(Main.MouseWorld), true); + 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); } diff --git a/Projectiles/Ranged/P90Round.cs b/Projectiles/Ranged/P90Round.cs new file mode 100644 index 0000000000..9c29e5bb1f --- /dev/null +++ b/Projectiles/Ranged/P90Round.cs @@ -0,0 +1,70 @@ +using CalamityMod.Particles; +using CalamityMod.Items.Weapons.Ranged; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.WorldBuilding; + +namespace CalamityMod.Projectiles.Ranged +{ + public class P90Round : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override void SetDefaults() + { + Projectile.width = 35; + Projectile.height = 35; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = 1; + Projectile.timeLeft = 600; + Projectile.extraUpdates = 5; + Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; + Projectile.tileCollide = true; + Projectile.ArmorPenetration = 15; + } + public override void AI() + { + if (Projectile.timeLeft == 598) + { + for (int i = 0; i <= 3; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 303 : 244, (Projectile.velocity * Main.rand.NextFloat(0.2f, 1.1f)).RotatedByRandom(0.2f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.8f, 1.4f); + } + } + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + + Vector3 DustLight = new Vector3(0.190f, 0.190f, 0.190f); + Lighting.AddLight(Projectile.Center, DustLight * 2); + + if (targetDist < 1400f && Projectile.timeLeft < 596 && Projectile.timeLeft % 2 == 0) + { + int positionVariation = Projectile.timeLeft < 565 ? 25 : Projectile.timeLeft < 585 ? 12 : 5; + LineParticle spark = new LineParticle(Projectile.Center - Projectile.velocity * 0.75f + Main.rand.NextVector2Circular(positionVariation, positionVariation), -Projectile.velocity * Main.rand.NextFloat(0.003f, 0.001f), false, 4, 1.45f, Color.Chocolate); + GeneralParticleHandler.SpawnParticle(spark); + } + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + GenericSparkle sparker = new GenericSparkle(Projectile.Center + Projectile.velocity.RotatedByRandom(0.3f), Vector2.Zero, Color.White, Color.Chocolate, Main.rand.NextFloat(0.7f, 1.5f), Main.rand.Next(9, 17), Main.rand.NextFloat(-0.01f, 0.01f), 2.5f); + GeneralParticleHandler.SpawnParticle(sparker); + } + public override void OnKill(int timeLeft) + { + for (int i = 0; i <= 4; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity * 1.5f + Main.rand.NextVector2Circular(9, 9), Main.rand.NextBool(3) ? 303 : 244, (-Projectile.velocity * Main.rand.NextFloat(0.2f, 3f)).RotatedByRandom(MathHelper.ToRadians(20f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default); + dust.noGravity = true; + dust.scale = dust.type == 244 ? Main.rand.NextFloat(1.8f, 2.5f) : Main.rand.NextFloat(1.4f, 1.8f); + dust.fadeIn = dust.type == 244 ? 1.2f : 0; + } + } + } +} diff --git a/Projectiles/Ranged/PhangasmBow.cs b/Projectiles/Ranged/PhangasmBow.cs index 124758cf18..22be884ad1 100644 --- a/Projectiles/Ranged/PhangasmBow.cs +++ b/Projectiles/Ranged/PhangasmBow.cs @@ -1,7 +1,7 @@ -using CalamityMod.Items.Weapons.Ranged; +using System; +using CalamityMod.Items.Weapons.Ranged; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -30,44 +30,44 @@ namespace CalamityMod.Projectiles.Ranged { Lighting.AddLight(Projectile.Center, 0f, 0.7f, 0.5f); Player player = Main.player[Projectile.owner]; - float num = 0f; - Vector2 vector = player.RotatedRelativePoint(player.MountedCenter, true); + float pi = 0f; + Vector2 playerRotation = player.RotatedRelativePoint(player.MountedCenter, true); if (Projectile.spriteDirection == -1) { - num = MathHelper.Pi; + pi = MathHelper.Pi; } Projectile.ai[0] += 1f; - int num39 = 0; + int fireSpeed = 0; if (Projectile.ai[0] >= 90f) { - num39++; + fireSpeed++; } if (Projectile.ai[0] >= 180f) { - num39++; + fireSpeed++; } if (Projectile.ai[0] >= 270f) { - num39++; + fireSpeed++; } - int num40 = 24; - int num41 = 2; + int delayCompare = 24; + int fireSpeedCompare = 2; Projectile.ai[1] -= 1f; - bool flag15 = false; + bool fullSpeed = false; if (Projectile.ai[1] <= 0f) { - Projectile.ai[1] = (float)(num40 - num41 * num39); - flag15 = true; - int arg_1EF4_0 = (int)Projectile.ai[0] / (num40 - num41 * num39); + Projectile.ai[1] = (float)(delayCompare - fireSpeedCompare * fireSpeed); + fullSpeed = true; + int arg_1EF4_0 = (int)Projectile.ai[0] / (delayCompare - fireSpeedCompare * fireSpeed); } - bool flag16 = player.channel && player.HasAmmo(player.ActiveItem()) && !player.noItems && !player.CCed; + bool canUseItem = player.channel && player.HasAmmo(player.ActiveItem()) && !player.noItems && !player.CCed; if (Projectile.localAI[0] > 0f) { Projectile.localAI[0] -= 1f; } - if (Projectile.soundDelay <= 0 && flag16) + if (Projectile.soundDelay <= 0 && canUseItem) { - Projectile.soundDelay = num40 - num41 * num39; + Projectile.soundDelay = delayCompare - fireSpeedCompare * fireSpeed; if (Projectile.ai[0] != 1f) { SoundEngine.PlaySound(SoundID.Item5, Projectile.position); @@ -75,44 +75,43 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localAI[0] = 12f; } player.phantasmTime = 2; - if (flag15 && Main.myPlayer == Projectile.owner) + if (fullSpeed && Main.myPlayer == Projectile.owner) { - int num42 = ProjectileID.WoodenArrowFriendly; + int ammoType = ProjectileID.WoodenArrowFriendly; float scaleFactor11 = 14f; int weaponDamage2 = player.GetWeaponDamage(player.ActiveItem()); float weaponKnockback2 = player.ActiveItem().knockBack; - if (flag16) + if (canUseItem) { - player.PickAmmo(player.ActiveItem(), out num42, out scaleFactor11, out weaponDamage2, out weaponKnockback2, out _); + player.PickAmmo(player.ActiveItem(), out ammoType, out scaleFactor11, out weaponDamage2, out weaponKnockback2, out _); weaponKnockback2 = player.GetWeaponKnockback(player.ActiveItem(), weaponKnockback2); float scaleFactor12 = player.ActiveItem().shootSpeed * Projectile.scale; - Vector2 vector19 = vector; - Vector2 value18 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - vector19; + Vector2 shootDirection = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - playerRotation; if (player.gravDir == -1f) { - value18.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - vector19.Y; + shootDirection.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - playerRotation.Y; } - Vector2 value19 = Vector2.Normalize(value18); - if (float.IsNaN(value19.X) || float.IsNaN(value19.Y)) + Vector2 normalizeShoot = Vector2.Normalize(shootDirection); + if (float.IsNaN(normalizeShoot.X) || float.IsNaN(normalizeShoot.Y)) { - value19 = -Vector2.UnitY; + normalizeShoot = -Vector2.UnitY; } - value19 *= scaleFactor12; - if (value19.X != Projectile.velocity.X || value19.Y != Projectile.velocity.Y) + normalizeShoot *= scaleFactor12; + if (normalizeShoot.X != Projectile.velocity.X || normalizeShoot.Y != Projectile.velocity.Y) { Projectile.netUpdate = true; } - Projectile.velocity = value19 * 0.55f; - for (int num43 = 0; num43 < 5; num43++) + Projectile.velocity = normalizeShoot * 0.55f; + for (int i = 0; i < 5; i++) { - Vector2 vector20 = Vector2.Normalize(Projectile.velocity) * scaleFactor11 * (0.6f + Main.rand.NextFloat() * 0.8f); - if (float.IsNaN(vector20.X) || float.IsNaN(vector20.Y)) + Vector2 randNormalize = Vector2.Normalize(Projectile.velocity) * scaleFactor11 * (0.6f + Main.rand.NextFloat() * 0.8f); + if (float.IsNaN(randNormalize.X) || float.IsNaN(randNormalize.Y)) { - vector20 = -Vector2.UnitY; + randNormalize = -Vector2.UnitY; } - Vector2 vector21 = vector19 + Utils.RandomVector2(Main.rand, -15f, 15f); - int num44 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), vector21, vector20, num42, weaponDamage2, weaponKnockback2, Projectile.owner); - Main.projectile[num44].noDropItem = true; + Vector2 projRandomPos = playerRotation + Utils.RandomVector2(Main.rand, -15f, 15f); + int proj = Projectile.NewProjectile(Projectile.GetSource_FromThis(), projRandomPos, randNormalize, ammoType, weaponDamage2, weaponKnockback2, Projectile.owner); + Main.projectile[proj].noDropItem = true; } } else @@ -121,7 +120,7 @@ namespace CalamityMod.Projectiles.Ranged } } Projectile.position = player.RotatedRelativePoint(player.MountedCenter, true) - Projectile.Size / 2f; - Projectile.rotation = Projectile.velocity.ToRotation() + num; + Projectile.rotation = Projectile.velocity.ToRotation() + pi; Projectile.spriteDirection = Projectile.direction; Projectile.timeLeft = 2; player.ChangeDir(Projectile.direction); @@ -133,7 +132,7 @@ namespace CalamityMod.Projectiles.Ranged public override void PostDraw(Color lightColor) { - Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Ranged/PhangasmGlow").Value; + Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Ranged/PhangasmGlow").Value; SpriteEffects spriteEffects = SpriteEffects.None; if (Projectile.spriteDirection == -1) spriteEffects = SpriteEffects.FlipHorizontally; diff --git a/Projectiles/Ranged/PhotovisceratorHoldout.cs b/Projectiles/Ranged/PhotovisceratorHoldout.cs new file mode 100644 index 0000000000..ef4667fc2e --- /dev/null +++ b/Projectiles/Ranged/PhotovisceratorHoldout.cs @@ -0,0 +1,273 @@ +using System; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.Localization; +using Terraria.ModLoader; +using static CalamityMod.Items.Weapons.Ranged.Photoviscerator; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Ranged +{ + public class PhotovisceratorHoldout : ModProjectile + { + public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + public Player Owner => Main.player[Projectile.owner]; + public bool OwnerCanShoot => (Owner.channel || Owner.Calamity().mouseRight) && !Owner.noItems && !Owner.CCed; + public ref float ShootTimer => ref Projectile.ai[0]; + public ref float ForcedLifespan => ref Projectile.ai[1]; + public Color sparkColor; + public int Time = 0; + public ref int PhotoTimer => ref Main.player[Projectile.owner].Calamity().PhotoTimer; + public SlotId PhotoUseSound; + + public override void SetDefaults() + { + Projectile.width = 170; + Projectile.height = 66; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.DamageType = DamageClass.Ranged; + } + + public override void AI() + { + Time++; + if (PhotoTimer > 0) + PhotoTimer--; + + if (Time == 1) + Projectile.alpha = 255; + else + Projectile.alpha = 0; + + sparkColor = Main.rand.Next(4) switch + { + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + + if (Owner.Calamity().mouseRight) + { + if (SoundEngine.TryGetActiveSound(PhotoUseSound, out var Sound2)) + Sound2?.Stop(); + } + + if (SoundEngine.TryGetActiveSound(PhotoUseSound, out var Sound) && Sound.IsPlaying) + Sound.Position = Projectile.Center; + + Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); + UpdateProjectileHeldVariables(armPosition); + ManipulatePlayerVariables(); + + // Orange exo energy as the back "flames" + Color energyColor = Color.Orange; + Vector2 flamePosition = armPosition + Projectile.velocity * Projectile.width * 0.12f; + Vector2 verticalOffset = Vector2.UnitY.RotatedBy(Projectile.rotation); + if (Math.Cos(Projectile.rotation) < 0f) + verticalOffset *= -1f; + + if (Main.rand.NextBool(4)) + { + Vector2 flameAngle = -Vector2.UnitY.RotatedBy(Projectile.rotation + MathHelper.ToRadians(Main.rand.NextFloat(270f, 300f) * Projectile.spriteDirection)); + SquishyLightParticle exoEnergy = new(flamePosition - verticalOffset * 26f, flameAngle * Main.rand.NextFloat(0.8f, 3.6f), 0.25f, energyColor, 20); + GeneralParticleHandler.SpawnParticle(exoEnergy); + SquishyLightParticle exoEnergy2 = new(armPosition - verticalOffset * 22f, flameAngle * Main.rand.NextFloat(0.7f, 3.2f), 0.2f, energyColor, 12); + GeneralParticleHandler.SpawnParticle(exoEnergy2); + } + + // Create light around the crystal + Lighting.AddLight(armPosition + Projectile.velocity * 42f - verticalOffset * 10f, 0.8f, 0.8f, 0.8f); + Lighting.AddLight(armPosition + Projectile.velocity * 96f + verticalOffset * 6f, 0.4f, 0.4f, 0.4f); + + // Despawn the projectile if the player can't shoot + // Any forced lifespan (triggered by attacking right click to prevent click spamming) will have priority + if (!OwnerCanShoot) + { + ForcedLifespan--; + if (ForcedLifespan <= 0f) + Projectile.Kill(); + return; + } + + // Don't try to perform attacks if it's not the holder + if (Projectile.owner != Main.myPlayer) + return; + + // Immediately killed if ammo is out + if (!Owner.HasAmmo(Owner.ActiveItem())) + { + Projectile.Kill(); + return; + } + + // Right-click attacks + if (Owner.Calamity().mouseRight && !Owner.channel) + { + // Can't shoot on frame 1 as it can't use ammo yet + if (ShootTimer < 0f) + RightClickAttack(armPosition, verticalOffset); + + ShootTimer--; + } + else if (!Owner.Calamity().mouseRight && Owner.channel) + { + ShootTimer++; + LeftClickAttack(armPosition, verticalOffset); + } + } + + public void LeftClickAttack(Vector2 armPosition, Vector2 verticalOffset) + { + if (Time == 1 || Time % 55 == 0) + { + PhotoUseSound = SoundEngine.PlaySound(Photoviscerator.UseSound, Projectile.Center); + } + + if (SoundEngine.TryGetActiveSound(PhotoUseSound, out var Sound3)) + Sound3.Pitch = 0 - (PhotoTimer * 0.002f); + + // Consume ammo and retrieve projectile stats; has a chance to not consume ammo + Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _, Main.rand.NextFloat() <= AmmoNotConsumeChance); + + var source = Projectile.GetSource_FromThis(); + Vector2 position = armPosition + Projectile.velocity * 55f - verticalOffset * 10f; + Vector2 velocity = Projectile.velocity * shootSpeed; + + if (PhotoTimer == 1) + { + for (int i = 0; i < 30; i++) + { + sparkColor = Main.rand.Next(4) switch + { + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + SquishyLightParticle exoEnergy = new(position, (Projectile.velocity * 3).RotatedByRandom(0.4f) * Main.rand.NextFloat(0.3f, 1.6f), 0.9f, sparkColor, 60); + GeneralParticleHandler.SpawnParticle(exoEnergy); + } + SoundEngine.PlaySound(DeadSunsWind.Shoot with { Volume = 1.9f}, Owner.MountedCenter); + } + + Dust dust = Dust.NewDustPerfect(position, 263, (Projectile.velocity * 10).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.3f, 1.6f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.3f, 1.8f) - PhotoTimer * 0.02f; + dust.color = sparkColor; + Dust dust2 = Dust.NewDustPerfect(position, 263, (Projectile.velocity * 15).RotatedByRandom(0.25f) * Main.rand.NextFloat(0.3f, 1.6f)); + dust2.noGravity = true; + dust2.scale = Main.rand.NextFloat(1.3f, 1.8f) - PhotoTimer * 0.02f; + dust2.color = sparkColor; + if (Main.rand.NextBool()) + { + MediumMistParticle smoke = new MediumMistParticle(position + Main.rand.NextVector2Circular(5, 5), (Projectile.velocity * 15).RotatedByRandom(0.15f) * Main.rand.NextFloat(0.5f, 2.1f), sparkColor, Color.White, Main.rand.NextFloat(1.8f, 2.9f) - PhotoTimer * 0.026f, 160, Main.rand.NextFloat(-3f, 3f)); + GeneralParticleHandler.SpawnParticle(smoke); + MediumMistParticle smoke2 = new MediumMistParticle(position + Main.rand.NextVector2Circular(5, 5), (Projectile.velocity * 18).RotatedByRandom(0.05f) * Main.rand.NextFloat(1.8f, 3.1f), sparkColor, Color.White, Main.rand.NextFloat(0.8f, 1.9f) - PhotoTimer * 0.02f, 160, Main.rand.NextFloat(-3f, 3f)); + GeneralParticleHandler.SpawnParticle(smoke2); + } + + // Main fire stream + Projectile.NewProjectile(source, position, velocity.RotatedByRandom(0.005f), ProjectileType(), (int)(damage * (1 - PhotoTimer / 59.9f)), knockback, Projectile.owner, Main.rand.NextFloat(0f, 3f)); + + // Shoots light bombs every once in a while, rate of which equals to the item's use time + if (ShootTimer >= Owner.ActiveItem().useTime * 10 && PhotoTimer == 0) + { + ShootTimer = 0f; + + for (int i = 0; i < 2; i++) + { + Vector2 bombPos = armPosition + Projectile.velocity * 108f + verticalOffset * 6f; + int yDirection = (i == 0).ToDirectionInt(); + Vector2 bombVel = velocity.RotatedBy(0.2f * yDirection); + + Projectile.NewProjectile(source, bombPos, bombVel, ProjectileType(), damage, knockback, Projectile.owner, yDirection); + } + SoundEngine.PlaySound(HalleysInferno.Hit, Owner.MountedCenter); + } + } + + public void RightClickAttack(Vector2 armPosition, Vector2 verticalOffset) + { + // Multiplied by the ratio of attack speed gained from modifiers + ShootTimer = (RightClickCooldown * Owner.ActiveItem().useTime / (float)LightBombCooldown) - 1f; + ForcedLifespan = ShootTimer; + + // Consume ammo and retrieve projectile stats + Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _); + + var source = Projectile.GetSource_FromThis(); + Vector2 position = armPosition + Projectile.velocity * 55f - verticalOffset * 10f; + Vector2 velocity = Projectile.velocity * shootSpeed * RightClickVelocityMult; + for (int i = 0; i <= 15; i++) + { + sparkColor = Main.rand.Next(4) switch + { + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + DirectionalPulseRing pulse = new DirectionalPulseRing(position, (Projectile.velocity * 10).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.3f, 1.6f), sparkColor, new Vector2(1, 1), 0, Main.rand.NextFloat(0.2f, 0.35f), 0f, 40); + GeneralParticleHandler.SpawnParticle(pulse); + DirectionalPulseRing pulse2 = new DirectionalPulseRing(position, (Projectile.velocity * 10).RotatedByRandom(0.1f) * Main.rand.NextFloat(0.8f, 3.1f), sparkColor, new Vector2(1, 1), 0, Main.rand.NextFloat(0.2f, 0.35f), 0f, 40); + GeneralParticleHandler.SpawnParticle(pulse2); + Dust dust = Dust.NewDustPerfect(position, 263, (Projectile.velocity * 10).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.3f, 1.6f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.3f, 1.8f); + dust.color = sparkColor; + } + SoundEngine.PlaySound(HalleysInferno.Shoot, Owner.MountedCenter); + + int rightClickDamage = (int)(0.5f * damage); + Projectile.NewProjectile(source, position, velocity, ProjectileType(), rightClickDamage, knockback, Projectile.owner); + } + + public void UpdateProjectileHeldVariables(Vector2 armPosition) + { + if (Main.myPlayer == Projectile.owner) + { + float interpolant = Utils.GetLerpValue(5f, 90f, 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.velocity.SafeNormalize(Vector2.UnitY) * 28f; + Projectile.rotation = Projectile.velocity.ToRotation(); + if (Projectile.spriteDirection == -1) + Projectile.rotation += MathHelper.Pi; + Projectile.spriteDirection = Projectile.direction; + Projectile.timeLeft = 2; + } + + public void ManipulatePlayerVariables() + { + Owner.ChangeDir(Projectile.direction); + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); + } + + public override bool ShouldUpdatePosition() => false; + + public override bool? CanDamage() => false; + public override void OnKill(int timeLeft) + { + if (SoundEngine.TryGetActiveSound(PhotoUseSound, out var Sound)) + Sound?.Stop(); + PhotoTimer = 90; + } + } +} diff --git a/Projectiles/Ranged/PhotovisceratorHoldout.png b/Projectiles/Ranged/PhotovisceratorHoldout.png new file mode 100644 index 0000000000..403e234758 Binary files /dev/null and b/Projectiles/Ranged/PhotovisceratorHoldout.png differ diff --git a/Projectiles/Ranged/PiercingBullet.cs b/Projectiles/Ranged/PiercingBullet.cs index ec441597ac..24ed7d84ba 100644 --- a/Projectiles/Ranged/PiercingBullet.cs +++ b/Projectiles/Ranged/PiercingBullet.cs @@ -69,7 +69,7 @@ namespace CalamityMod.Projectiles.Ranged { if (Projectile.owner == Main.myPlayer) { - CalamityUtils.ProjectileBarrage(source, Projectile.Center, targetPos, x < bulletCount / 2, 500f, 500f, 0f, 500f, 12f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.125), Projectile.knockBack, Projectile.owner); + CalamityUtils.ProjectileBarrage(source, Projectile.Center, targetPos, x < bulletCount / 2, 500f, 500f, 0f, 500f, 12f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.175), Projectile.knockBack, Projectile.owner); } } } diff --git a/Projectiles/Ranged/PlagueArrow.cs b/Projectiles/Ranged/PlagueArrow.cs index 5f40b8d1b0..b9dfbbeb65 100644 --- a/Projectiles/Ranged/PlagueArrow.cs +++ b/Projectiles/Ranged/PlagueArrow.cs @@ -35,21 +35,20 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.owner == Main.myPlayer) { Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); - int num516 = 6; - for (int num517 = 0; num517 < num516; num517++) + for (int i = 0; i < 6; i++) { - if (num517 % 2 != 1 || Main.rand.NextBool(3)) + if (i % 2 != 1 || Main.rand.NextBool(3)) { - Vector2 value20 = Projectile.position; - Vector2 value21 = Projectile.oldVelocity; - value21.Normalize(); - value21 *= 8f; - float num518 = (float)Main.rand.Next(-35, 36) * 0.01f; - float num519 = (float)Main.rand.Next(-35, 36) * 0.01f; - value20 -= value21 * (float)num517; - num518 += Projectile.oldVelocity.X / 6f; - num519 += Projectile.oldVelocity.Y / 6f; - int bee = Projectile.NewProjectile(Projectile.GetSource_FromThis(), value20.X, value20.Y, num518, num519, Main.player[Projectile.owner].beeType(), Main.player[Projectile.owner].beeDamage(Projectile.damage / 2), Main.player[Projectile.owner].beeKB(0f), Main.myPlayer); + Vector2 projPos = Projectile.position; + Vector2 projVel = Projectile.oldVelocity; + projVel.Normalize(); + projVel *= 8f; + float beeVelX = (float)Main.rand.Next(-35, 36) * 0.01f; + float beeVelY = (float)Main.rand.Next(-35, 36) * 0.01f; + projPos -= projVel * (float)i; + beeVelX += Projectile.oldVelocity.X / 6f; + beeVelY += Projectile.oldVelocity.Y / 6f; + int bee = Projectile.NewProjectile(Projectile.GetSource_FromThis(), projPos.X, projPos.Y, beeVelX, beeVelY, Main.player[Projectile.owner].beeType(), Main.player[Projectile.owner].beeDamage(Projectile.damage / 2), Main.player[Projectile.owner].beeKB(0f), Main.myPlayer); if (bee.WithinBounds(Main.maxProjectiles)) { Main.projectile[bee].penetrate = 2; diff --git a/Projectiles/Ranged/PlagueExplosionFriendly.cs b/Projectiles/Ranged/PlagueExplosionFriendly.cs index efd63aca51..90976dae42 100644 --- a/Projectiles/Ranged/PlagueExplosionFriendly.cs +++ b/Projectiles/Ranged/PlagueExplosionFriendly.cs @@ -25,60 +25,60 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.01f / 255f, (255 - Projectile.alpha) * 0.15f / 255f, (255 - Projectile.alpha) * 0.05f / 255f); - bool flag15 = false; - bool flag16 = false; + bool xflag = false; + bool yflag = false; if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) { - flag16 = true; + yflag = true; } if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) { - flag16 = true; + yflag = true; } - if (flag15 && flag16) + if (xflag && yflag) { Projectile.Kill(); } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-10, 11); - float num464 = (float)Main.rand.Next(-10, 11); - float num465 = (float)Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 0.5f); - Dust dust = Main.dust[num467]; + float rand1 = (float)Main.rand.Next(-10, 11); + float rand2 = (float)Main.rand.Next(-10, 11); + float rand3 = (float)Main.rand.Next(3, 9); + float randAdjust = (float)Math.Sqrt((double)(rand1 * rand1 + rand2 * rand2)); + randAdjust = rand3 / randAdjust; + rand1 *= randAdjust; + rand2 *= randAdjust; + int greenDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 0.5f); + Dust dust = Main.dust[greenDust]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = rand1; + dust.velocity.Y = rand2; + timerCounter++; } } diff --git a/Projectiles/Ranged/PlagueTaintedDrone.cs b/Projectiles/Ranged/PlagueTaintedDrone.cs index b66b0b3767..5e48467eee 100644 --- a/Projectiles/Ranged/PlagueTaintedDrone.cs +++ b/Projectiles/Ranged/PlagueTaintedDrone.cs @@ -138,23 +138,23 @@ namespace CalamityMod.Projectiles.Ranged Projectile.damage = (int)(Projectile.damage * 0.4f); Projectile.Damage(); SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - for (int num621 = 0; num621 < 20; num621++) + for (int i = 0; i < 20; i++) { - int num622 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 40; num623++) + for (int j = 0; j < 40; j++) { - int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 3f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 2f); + Main.dust[dust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) diff --git a/Projectiles/Ranged/PlanarRipperBolt.cs b/Projectiles/Ranged/PlanarRipperBolt.cs index d93e3f6d75..0b09ff859b 100644 --- a/Projectiles/Ranged/PlanarRipperBolt.cs +++ b/Projectiles/Ranged/PlanarRipperBolt.cs @@ -113,12 +113,12 @@ namespace CalamityMod.Projectiles.Ranged int dust = Dust.NewDust(Projectile.Center, 1, 1, 132, Projectile.velocity.X, Projectile.velocity.Y, 0, default, 0.5f); Main.dust[dust].noGravity = true; } - int num212 = Main.rand.Next(10, 20); - for (int num213 = 0; num213 < num212; num213++) + int rando = Main.rand.Next(10, 20); + for (int i = 0; i < rando; i++) { - int num214 = Dust.NewDust(Projectile.Center - Projectile.velocity / 2f, 0, 0, 135, 0f, 0f, 100, default, 2f); - Main.dust[num214].velocity *= 2f; - Main.dust[num214].noGravity = true; + int dusty = Dust.NewDust(Projectile.Center - Projectile.velocity / 2f, 0, 0, 135, 0f, 0f, 100, default, 2f); + Main.dust[dusty].velocity *= 2f; + Main.dust[dusty].noGravity = true; } } } diff --git a/Projectiles/Ranged/PlanarRipperExplosion.cs b/Projectiles/Ranged/PlanarRipperExplosion.cs index 7fdf54b981..bec0f941ad 100644 --- a/Projectiles/Ranged/PlanarRipperExplosion.cs +++ b/Projectiles/Ranged/PlanarRipperExplosion.cs @@ -1,5 +1,5 @@ +using System; using Microsoft.Xna.Framework; -using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -27,38 +27,38 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.01f / 255f, (255 - Projectile.alpha) * 0.05f / 255f, (255 - Projectile.alpha) * 0.15f / 255f); - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-10, 11); - float num464 = (float)Main.rand.Next(-10, 11); - float num465 = (float)Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 132, 0f, 0f, 100, default, 0.5f); - Dust dust = Main.dust[num467]; + float rand1 = (float)Main.rand.Next(-10, 11); + float rand2 = (float)Main.rand.Next(-10, 11); + float rand3 = (float)Main.rand.Next(3, 9); + float randAdjust = (float)Math.Sqrt((double)(rand1 * rand1 + rand2 * rand2)); + randAdjust = rand3 / randAdjust; + rand1 *= randAdjust; + rand2 *= randAdjust; + int boomDustID = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 132, 0f, 0f, 100, default, 0.5f); + Dust dust = Main.dust[boomDustID]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = rand1; + dust.velocity.Y = rand2; + timerCounter++; } } diff --git a/Projectiles/Ranged/PlanetaryAnnihilationProj.cs b/Projectiles/Ranged/PlanetaryAnnihilationProj.cs index 43f7f360fc..67bb1e6dd9 100644 --- a/Projectiles/Ranged/PlanetaryAnnihilationProj.cs +++ b/Projectiles/Ranged/PlanetaryAnnihilationProj.cs @@ -1,8 +1,9 @@ +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace CalamityMod.Projectiles.Ranged { @@ -23,6 +24,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.extraUpdates = 1; Projectile.timeLeft = 600; Projectile.arrow = true; + Projectile.tileCollide = false; } public override void AI() @@ -51,21 +53,21 @@ namespace CalamityMod.Projectiles.Ranged dustType = 57; break; } - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2.2f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int addedDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2.2f); + Main.dust[addedDust].noGravity = true; + Main.dust[addedDust].velocity *= 0f; CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, 12f, 20f); } - + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 60); + } public override void OnKill(int timeLeft) { int height = 40; - float num50 = 2.1f; - float num51 = 1.1f; - float num52 = 2.5f; - Vector2 value3 = (Projectile.rotation - 1.57079637f).ToRotationVector2(); - Vector2 value4 = value3 * Projectile.velocity.Length() * (float)Projectile.MaxUpdates; + Vector2 dustRotation = (Projectile.rotation - 1.57079637f).ToRotationVector2(); + Vector2 dustVel = dustRotation * Projectile.velocity.Length() * (float)Projectile.MaxUpdates; SoundEngine.PlaySound(SoundID.Item14, Projectile.position); Projectile.position = Projectile.Center; Projectile.width = Projectile.height = height; @@ -76,36 +78,36 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localNPCHitCooldown = 10; Projectile.damage /= 2; Projectile.Damage(); - int num3; - for (int num53 = 0; num53 < 20; num53 = num3 + 1) + int inc; + for (int i = 0; i < 20; i = inc + 1) { - int num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 200, default, num50); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; - Main.dust[num54].noGravity = true; - Dust dust = Main.dust[num54]; + int dustID = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 200, default, 2.1f); + Main.dust[dustID].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + Main.dust[dustID].noGravity = true; + Dust dust = Main.dust[dustID]; dust.velocity *= 3f; - dust = Main.dust[num54]; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, num51); - Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; - dust = Main.dust[num54]; + dust = Main.dust[dustID]; + dust.velocity += dustVel * Main.rand.NextFloat(); + dustID = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 1.1f); + Main.dust[dustID].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + dust = Main.dust[dustID]; dust.velocity *= 2f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - dust = Main.dust[num54]; - dust.velocity += value4 * Main.rand.NextFloat(); - num3 = num53; + Main.dust[dustID].noGravity = true; + Main.dust[dustID].fadeIn = 1f; + dust = Main.dust[dustID]; + dust.velocity += dustVel * Main.rand.NextFloat(); + inc = i; } - for (int num55 = 0; num55 < 10; num55 = num3 + 1) + for (int j = 0; j < 10; j = inc + 1) { - int num56 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, num52); - Main.dust[num56].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 3f; - Main.dust[num56].noGravity = true; - Dust dust = Main.dust[num56]; + int dustID = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 2.5f); + Main.dust[dustID].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 3f; + Main.dust[dustID].noGravity = true; + Dust dust = Main.dust[dustID]; dust.velocity *= 0.5f; - dust = Main.dust[num56]; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); - num3 = num55; + dust = Main.dust[dustID]; + dust.velocity += dustVel * (0.6f + 0.6f * Main.rand.NextFloat()); + inc = j; } } } diff --git a/Projectiles/Ranged/PlasmaBlast.cs b/Projectiles/Ranged/PlasmaBlast.cs index 3fefe6e390..555c142e65 100644 --- a/Projectiles/Ranged/PlasmaBlast.cs +++ b/Projectiles/Ranged/PlasmaBlast.cs @@ -42,39 +42,39 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localAI[0] = 0f; for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * MathHelper.Pi / 6f), default) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy((double)(Projectile.rotation - MathHelper.PiOver2), default); - int num9 = Dust.NewDust(Projectile.Center, 0, 0, 221, 0f, 0f, 160, default, 1f); - Main.dust[num9].noGravity = true; - Main.dust[num9].position = Projectile.Center + vector3; - Main.dust[num9].velocity = Projectile.velocity * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; + Vector2 dustVel = Vector2.UnitX * (float)-(float)Projectile.width / 2f; + dustVel += -Vector2.UnitY.RotatedBy((double)((float)l * MathHelper.Pi / 6f), default) * new Vector2(8f, 16f); + dustVel = dustVel.RotatedBy((double)(Projectile.rotation - MathHelper.PiOver2), default); + int dust = Dust.NewDust(Projectile.Center, 0, 0, 221, 0f, 0f, 160, default, 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].position = Projectile.Center + dustVel; + Main.dust[dust].velocity = Projectile.velocity * 0.1f; + Main.dust[dust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[dust].position) * 1.25f; } } Projectile.alpha -= 15; - int num58 = 150; + int alphaControl = 150; if (Projectile.Center.Y >= Projectile.ai[1]) - num58 = 0; - if (Projectile.alpha < num58) - Projectile.alpha = num58; + alphaControl = 0; + if (Projectile.alpha < alphaControl) + Projectile.alpha = alphaControl; Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; if (Main.rand.NextBool(16)) { - Vector2 value3 = Vector2.UnitX.RotatedByRandom(MathHelper.PiOver2).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num59 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 221, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1f); - Main.dust[num59].velocity = value3 * 0.66f; - Main.dust[num59].position = Projectile.Center + value3 * 12f; + Vector2 extraDustVel = Vector2.UnitX.RotatedByRandom(MathHelper.PiOver2).RotatedBy((double)Projectile.velocity.ToRotation(), default); + int extraDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 221, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1f); + Main.dust[extraDust].velocity = extraDustVel * 0.66f; + Main.dust[extraDust].position = Projectile.Center + extraDustVel * 12f; } if (Main.rand.NextBool(48) && Main.netMode != NetmodeID.Server) { - int num60 = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), 16, 1f); - Main.gore[num60].velocity *= 0.66f; - Main.gore[num60].velocity += Projectile.velocity * 0.3f; + int gore = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), 16, 1f); + Main.gore[gore].velocity *= 0.66f; + Main.gore[gore].velocity += Projectile.velocity * 0.3f; } if (Projectile.ai[1] == 1f) diff --git a/Projectiles/Ranged/PlasmaExplosion.cs b/Projectiles/Ranged/PlasmaExplosion.cs index 26dfc349c6..13b04f4e6a 100644 --- a/Projectiles/Ranged/PlasmaExplosion.cs +++ b/Projectiles/Ranged/PlasmaExplosion.cs @@ -1,9 +1,10 @@ -using Microsoft.Xna.Framework; -using System; +using System; +using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; + namespace CalamityMod.Projectiles.Ranged { public class PlasmaExplosion : ModProjectile, ILocalizedModType @@ -33,61 +34,60 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(SoundID.Item93, Projectile.position); Projectile.localAI[0] += 1f; } - bool flag15 = false; - bool flag16 = false; + bool xflag = false; + bool yflag = false; if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) { - flag16 = true; + yflag = true; } if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) { - flag16 = true; + yflag = true; } - if (flag15 && flag16) + if (xflag && yflag) { Projectile.Kill(); } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-40, 41); - float num464 = (float)Main.rand.Next(-40, 41); - float num465 = (float)Main.rand.Next(12, 36); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, - Projectile.ai[1] == 1f ? 173 : 221, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[num467]; + float rand1 = (float)Main.rand.Next(-40, 41); + float rand2 = (float)Main.rand.Next(-40, 41); + float rand3 = (float)Main.rand.Next(12, 36); + float randAdjust = (float)Math.Sqrt((double)(rand1 * rand1 + rand2 * rand2)); + randAdjust = rand3 / randAdjust; + rand1 *= randAdjust; + rand2 *= randAdjust; + int dustID = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, Projectile.ai[1] == 1f ? 173 : 221, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[dustID]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = rand1; + dust.velocity.Y = rand2; + timerCounter++; } return; } diff --git a/Projectiles/Ranged/PolarStar.cs b/Projectiles/Ranged/PolarStar.cs index 0ad3d75f32..7de53d1c2e 100644 --- a/Projectiles/Ranged/PolarStar.cs +++ b/Projectiles/Ranged/PolarStar.cs @@ -45,16 +45,16 @@ namespace CalamityMod.Projectiles.Ranged for (int d = 0; d < 2; d++) { int dustType = d == 0 ? dust1 : dust2; - Vector2 value8 = Vector2.UnitX * -12f; - value8 = -Vector2.UnitY.RotatedBy((double)(Projectile.localAI[0] * 0.1308997f + (float)d * MathHelper.Pi), default) * value7; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, dustType, 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = dustType == dust1 ? 1.5f : 1f; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8; - Main.dust[num42].velocity = Projectile.velocity; - int num458 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 0.8f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0f; + Vector2 dustVel = Vector2.UnitX * -12f; + dustVel = -Vector2.UnitY.RotatedBy((double)(Projectile.localAI[0] * 0.1308997f + (float)d * MathHelper.Pi), default) * value7; + int typeDust = Dust.NewDust(Projectile.Center, 0, 0, dustType, 0f, 0f, 160, default, 1f); + Main.dust[typeDust].scale = dustType == dust1 ? 1.5f : 1f; + Main.dust[typeDust].noGravity = true; + Main.dust[typeDust].position = Projectile.Center + dustVel; + Main.dust[typeDust].velocity = Projectile.velocity; + int extraDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 0.8f); + Main.dust[extraDust].noGravity = true; + Main.dust[extraDust].velocity *= 0f; } } } @@ -72,19 +72,19 @@ namespace CalamityMod.Projectiles.Ranged { Projectile.alpha = 0; } - float num55 = 30f; - float num56 = 1f; + float boostLevel = 30f; + float inc = 1f; if (Projectile.ai[1] == 1f) { - Projectile.localAI[0] += num56; - if (Projectile.localAI[0] > num55) + Projectile.localAI[0] += inc; + if (Projectile.localAI[0] > boostLevel) { - Projectile.localAI[0] = num55; + Projectile.localAI[0] = boostLevel; } } else { - Projectile.localAI[0] -= num56; + Projectile.localAI[0] -= inc; if (Projectile.localAI[0] <= 0f) { Projectile.Kill(); @@ -101,19 +101,19 @@ namespace CalamityMod.Projectiles.Ranged { Projectile.alpha = 0; } - float num55 = 40f; - float num56 = 1.5f; + float boostLevel = 40f; + float inc = 1.5f; if (Projectile.ai[1] == 0f) { - Projectile.localAI[0] += num56; - if (Projectile.localAI[0] > num55) + Projectile.localAI[0] += inc; + if (Projectile.localAI[0] > boostLevel) { - Projectile.localAI[0] = num55; + Projectile.localAI[0] = boostLevel; } } else { - Projectile.localAI[0] -= num56; + Projectile.localAI[0] -= inc; if (Projectile.localAI[0] <= 0f) { Projectile.Kill(); diff --git a/Projectiles/Ranged/PrismaticEnergyBlast.png b/Projectiles/Ranged/PrismaticEnergyBlast.png deleted file mode 100644 index 8e2d2a871c..0000000000 Binary files a/Projectiles/Ranged/PrismaticEnergyBlast.png and /dev/null differ diff --git a/Projectiles/Ranged/PristineFire.cs b/Projectiles/Ranged/PristineFire.cs index a12e433ba6..66e34181a0 100644 --- a/Projectiles/Ranged/PristineFire.cs +++ b/Projectiles/Ranged/PristineFire.cs @@ -1,7 +1,12 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -9,137 +14,104 @@ namespace CalamityMod.Projectiles.Ranged public class PristineFire : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override string Texture => "CalamityMod/Particles/MediumMist"; - private int dust1 = (int)CalamityDusts.ProfanedFire; - private int dust2 = ModContent.DustType(); + // Helix trail thing + public PrimitiveTrail HelixTrail = null; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 20; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + + public float smokeOpa = 0.25f; public override void SetDefaults() { - Projectile.width = 6; - Projectile.height = 6; + Projectile.width = Projectile.height = 6; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = 1; - Projectile.extraUpdates = 3; + Projectile.MaxUpdates = 4; Projectile.timeLeft = 120; } public override void AI() { - if (Projectile.scale <= 1.5f) + if (Projectile.timeLeft < 118) { - Projectile.scale *= 1.01f; - } - Lighting.AddLight(Projectile.Center, 1f, 1f, 0.25f); - if (Projectile.timeLeft > 90) - { - Projectile.timeLeft = 120; - } + if (smokeOpa > 0) + smokeOpa -= 0.02f; - int dustTypeOnTimer = dust1; + Lighting.AddLight(Projectile.Center, 1f, 1f, 0.25f); - Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] > 5f) - { - for (int num447 = 0; num447 < 2; num447++) - { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * ((float)num447 * 0.25f); - Projectile.alpha = 255; - int num448 = Dust.NewDust(vector33, 1, 1, dustTypeOnTimer, 0f, 0f, 0, default, 1f); - Main.dust[num448].noGravity = true; - Main.dust[num448].position = vector33; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.2f; - Main.dust[num448].noLight = true; - Main.dust[num448].color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); - } - Projectile.ai[0] += 1f; - if (Projectile.ai[0] == 48f) - { - Projectile.ai[0] = 0f; - - if (dustTypeOnTimer == dust1) - dustTypeOnTimer = dust2; - else - dustTypeOnTimer = dust1; - } - else - { - Vector2 value7 = new Vector2(5f, 10f); - - for (int num41 = 0; num41 < 2; num41++) - { - int dustType = num41 == 0 ? dust1 : dust2; - Vector2 value8 = Vector2.UnitX * -12f; - value8 = -Vector2.UnitY.RotatedBy((double)(Projectile.ai[0] * 0.1308997f + (float)num41 * 3.14159274f), default) * value7 * 1.5f; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, dustType, 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = 0.75f; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8; - Main.dust[num42].velocity = Projectile.velocity; - Main.dust[num42].noLight = true; - Main.dust[num42].color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); - } - } + // Light smoke + Color smokeColor = new Color(255, Main.rand.Next(160, 230 + 1), 100, 100); + Particle smoke = new HeavySmokeParticle(Projectile.Center, Projectile.velocity.RotatedByRandom(smokeOpa * 10) * (Main.rand.NextFloat(0.4f, 0.65f) - smokeOpa), smokeColor, 16, Main.rand.NextFloat(0.6f, 1.2f), 0.2f + smokeOpa, glowing: true); + GeneralParticleHandler.SpawnParticle(smoke); } + Projectile.rotation = Projectile.velocity.ToRotation(); } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 240); - } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 240); public override void OnKill(int timeLeft) { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - dust1, - dust2 - }); - int height = 50; - float num50 = 1.7f; - float num51 = 0.8f; - float num52 = 2f; - Vector2 value3 = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2(); - Vector2 value4 = value3 * Projectile.velocity.Length() * (float)Projectile.MaxUpdates; - Projectile.position = Projectile.Center; - Projectile.width = Projectile.height = height; - Projectile.Center = Projectile.position; + Projectile.ExpandHitboxBy(50); Projectile.maxPenetrate = -1; Projectile.penetrate = -1; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; Projectile.Damage(); - for (int num53 = 0; num53 < 40; num53++) + + LineParticle spark = new LineParticle(Projectile.Center, -Projectile.velocity.RotatedBy(Main.rand.NextFloat(0.23f, 0.56f)) * Main.rand.NextFloat(0.4f, 2.5f), false, 8, 1.2f, Main.rand.NextBool() ? Color.Orange : Color.DarkOrange); + GeneralParticleHandler.SpawnParticle(spark); + LineParticle spark2 = new LineParticle(Projectile.Center, -Projectile.velocity.RotatedBy(Main.rand.NextFloat(-0.23f, -0.56f)) * Main.rand.NextFloat(0.4f, 2.5f), false, 8, 1.2f, Main.rand.NextBool() ? Color.Orange : Color.DarkOrange); + GeneralParticleHandler.SpawnParticle(spark2); + + for (int i = 0; i <= 3; i++) { - int num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 200, default, num50); - Dust dust = Main.dust[num54]; - dust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool() ? 169 : 158, new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1.5f), 0, default, Main.rand.NextFloat(1.6f, 2.2f)); dust.noGravity = true; - dust.velocity *= 3f; - dust.velocity += value4 * Main.rand.NextFloat(); - dust.color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, num51); - dust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; - dust.velocity *= 2f; - dust.noGravity = true; - dust.fadeIn = 1f; - dust.velocity += value4 * Main.rand.NextFloat(); - dust.color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); + dust.fadeIn = 0.5f; } - for (int num55 = 0; num55 < 20; num55++) + // Big poofy column + for (int i = 0; i < 7; i++) { - int num56 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, num52); - Dust dust = Main.dust[num56]; - dust.position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 3f; - dust.noGravity = true; - dust.velocity *= 0.5f; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); - dust.color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); + float velMulti = Main.rand.NextFloat(0.1f, 1.8f); + Vector2 smokePos = Projectile.Center + Main.rand.NextVector2Circular(32f, 32f); + Vector2 smokeVel = Vector2.UnitY * Main.rand.NextFloat(-12f, -8f) * velMulti; + Particle smoke = new MediumMistParticle(smokePos, smokeVel, Main.rand.NextBool() ? Color.Orange : Color.DarkOrange, Color.Black, Main.rand.NextFloat(0.7f, 1.9f) - velMulti, 225 - Main.rand.Next(60), 0.1f); + GeneralParticleHandler.SpawnParticle(smoke); } } + + public float HelixTrailWidthFunction(float completionRatio) => Utils.GetLerpValue(1f, 0.4f, completionRatio, true) * 1.5f; + public Color HelixTrailColorFunction(float completionRatio) => Projectile.timeLeft < 105 ? Projectile.ai[0] == 1 ? Color.DarkOrange * (1f - completionRatio) : Color.Orange * (1f - completionRatio) : Color.Transparent; + + public override bool PreDraw(ref Color lightColor) + { + if (HelixTrail is null) + HelixTrail = new PrimitiveTrail(HelixTrailWidthFunction, HelixTrailColorFunction); + + // Draw a double helix trail + for (int direction = -1; direction <= 1; direction += 2) + { + List trailPositions = new List(); + int trailPoints = ProjectileID.Sets.TrailCacheLength[Type]; + // Add points adjusted for sine + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + if (Projectile.oldPos[i] == Vector2.Zero) + break; + + Vector2 sinOffset = (Vector2.UnitY * direction * MathF.Sin(i * MathHelper.Pi * 0.125f) * 24f).RotatedBy(Projectile.oldRot[i]); + trailPositions.Add(Projectile.oldPos[i] + sinOffset); + } + HelixTrail.Draw(trailPositions, Projectile.Size * 0.5f- Main.screenPosition, 60); + } + return false; + } } } diff --git a/Projectiles/Ranged/PristineSecondary.cs b/Projectiles/Ranged/PristineSecondary.cs index 8aa6e000ea..809e855a17 100644 --- a/Projectiles/Ranged/PristineSecondary.cs +++ b/Projectiles/Ranged/PristineSecondary.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.ModLoader; @@ -9,92 +10,65 @@ namespace CalamityMod.Projectiles.Ranged public class PristineSecondary : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override string Texture => "CalamityMod/Projectiles/Magic/RancorFog"; - private int dust1 = (int)CalamityDusts.ProfanedFire; - private int dust2 = ModContent.DustType(); + public ref float ScaleFactor => ref Projectile.ai[0]; + public ref float LightPower => ref Projectile.ai[1]; + + public Color FogColor = new Color(255, 220, 100); public override void SetDefaults() { - Projectile.width = 50; - Projectile.height = 50; + Projectile.width = Projectile.height = 150; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = -1; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 3; Projectile.timeLeft = 150; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 2; } public override void AI() { + // Add some degree of variation to the fog with scale/rotation/color + if (Projectile.ai[2] == 0f) + { + Projectile.scale = Main.rand.NextFloat(0.15f, 0.75f); + Projectile.ai[2] = Main.rand.NextFloat(MathHelper.TwoPi); + FogColor.G = (byte)Main.rand.Next(160, 230 + 1); + } + ScaleFactor += 0.01f; + ScaleFactor = MathHelper.Clamp(ScaleFactor, 0f, Projectile.scale); + Lighting.AddLight(Projectile.Center, new Vector3(1f, 1f, 0.25f) * ScaleFactor); + Projectile.rotation = Projectile.velocity.ToRotation() + Projectile.ai[2]; + Projectile.velocity *= 0.98f; - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - dust1, - dust2 - }); - Lighting.AddLight(Projectile.Center, 1f, 1f, 0.25f); - if (Projectile.ai[0] > 7f) - { - float num296 = 1f; - if (Projectile.ai[0] == 8f) - { - num296 = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - num296 = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - num296 = 0.75f; - } - Projectile.ai[0] += 1f; - if (Main.rand.NextBool()) - { - for (int num298 = 0; num298 < 1; num298++) - { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 1.25f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - if (Main.rand.NextBool(6)) - { - dust.noGravity = true; - dust.scale *= 1.5f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 1f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= num296; - dust.noLight = true; - dust.color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); - } - } - } - else - { - Projectile.ai[0] += 1f; - } - Projectile.rotation += 0.3f * (float)Projectile.direction; + Projectile.Opacity = Utils.GetLerpValue(150f, 135f, Projectile.timeLeft, true) * Utils.GetLerpValue(0f, 90f, Projectile.timeLeft, true); + + // Calculate light power. This checks below the position of the fog to check if this fog is underground. + // Without this, it may render over the fullblack that the game renders for obscured tiles. + float lightPowerBelow = Lighting.GetColor((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16 + 6).ToVector3().Length() / (float)Math.Sqrt(3D); + LightPower = MathHelper.Lerp(LightPower, lightPowerBelow, 0.15f); } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.width * ScaleFactor * 0.5f, targetHitbox); + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 240); + + public override bool PreDraw(ref Color lightColor) { - target.AddBuff(ModContent.BuffType(), 240); + Main.spriteBatch.SetBlendState(BlendState.Additive); + + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float opacity = Utils.GetLerpValue(0f, 0.08f, LightPower, true) * Projectile.Opacity * 0.5f; + Color drawColor = FogColor * opacity; + Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, Projectile.rotation, texture.Size() * 0.5f, ScaleFactor, SpriteEffects.None); + + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + return false; } } } diff --git a/Projectiles/Ranged/RainbowBlast.cs b/Projectiles/Ranged/RainbowBlast.cs index f8dfd6446b..7891a7d5cf 100644 --- a/Projectiles/Ranged/RainbowBlast.cs +++ b/Projectiles/Ranged/RainbowBlast.cs @@ -1,3 +1,4 @@ +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -36,9 +37,9 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.localAI[0] > 5f) { Vector2 dspeed = -Projectile.velocity * 0.5f; - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, dspeed.X, dspeed.Y, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.1f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity = dspeed; + int rainbowDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, dspeed.X, dspeed.Y, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.1f); + Main.dust[rainbowDust].noGravity = true; + Main.dust[rainbowDust].velocity = dspeed; } CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, 12f, 20f); @@ -55,5 +56,9 @@ namespace CalamityMod.Projectiles.Ranged CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); return false; } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 60); + } } } diff --git a/Projectiles/Ranged/RainbowFront.cs b/Projectiles/Ranged/RainbowFront.cs index 4d92dcf146..66c383c5ff 100644 --- a/Projectiles/Ranged/RainbowFront.cs +++ b/Projectiles/Ranged/RainbowFront.cs @@ -20,7 +20,6 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { - int num1 = 1200; if (Projectile.owner == Main.myPlayer) { Projectile.localAI[0] += 1f; @@ -29,13 +28,13 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localAI[0] = 3f; Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, Projectile.velocity.X * (1f / 1000f), Projectile.velocity.Y * (1f / 1000f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); } - if (Projectile.timeLeft > num1) - Projectile.timeLeft = num1; + if (Projectile.timeLeft > 1200) + Projectile.timeLeft = 1200; } - float num2 = 1f; + float gravityControl = 1f; if (Projectile.velocity.Y < 0f) - num2 -= Projectile.velocity.Y / 3f; - Projectile.ai[0] += num2; + gravityControl -= Projectile.velocity.Y / 3f; + Projectile.ai[0] += gravityControl; if (Projectile.ai[0] > 30f) { Projectile.velocity.Y += 0.5f; @@ -50,11 +49,11 @@ namespace CalamityMod.Projectiles.Ranged } float x = Projectile.velocity.X; float y = Projectile.velocity.Y; - float num3 = 15.95f * Projectile.scale / (float)Math.Sqrt((double)x * (double)x + (double)y * (double)y); - float num4 = x * num3; - float num5 = y * num3; - Projectile.velocity.X = num4; - Projectile.velocity.Y = num5; + float velocityMult = 15.95f * Projectile.scale / (float)Math.Sqrt((double)x * (double)x + (double)y * (double)y); + float xVel = x * velocityMult; + float yVel = y * velocityMult; + Projectile.velocity.X = xVel; + Projectile.velocity.Y = yVel; Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) - MathHelper.PiOver2; } diff --git a/Projectiles/Ranged/RubberMortarRoundProj.cs b/Projectiles/Ranged/RubberMortarRoundProj.cs index 0aff4b89e0..cf92e098f3 100644 --- a/Projectiles/Ranged/RubberMortarRoundProj.cs +++ b/Projectiles/Ranged/RubberMortarRoundProj.cs @@ -1,12 +1,10 @@ -using CalamityMod.Tiles.Abyss; -using CalamityMod.Walls; +using CalamityMod.Items.Ammo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System.Collections.Generic; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace CalamityMod.Projectiles.Ranged { @@ -30,6 +28,8 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + + // If moving fast enough, produce dust. Since it's a bullet, it should always be moving fast enough. if (Projectile.velocity.Length() >= 8f) { for (int d = 0; d < 2; d++) @@ -59,189 +59,65 @@ namespace CalamityMod.Projectiles.Ranged return false; } - public override bool OnTileCollide(Vector2 oldVelocity) + private void Explode() { - int penetrateAmt = Projectile.penetrate; - Projectile.ExpandHitboxBy(200); + // Apply damage a second time on explosion. This explosion also has double knockback. + Projectile.ExpandHitboxBy(MortarRound.HitboxBlastRadius); Projectile.maxPenetrate = Projectile.penetrate = -1; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; + Projectile.knockBack *= 2f; Projectile.Damage(); - SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - Projectile.penetrate = penetrateAmt; - - SpawnDust(); - - if (Main.netMode != NetmodeID.Server) - { - Vector2 goreSource = Projectile.Center; - int goreAmt = 3; - Vector2 source = new Vector2(goreSource.X - 24f, goreSource.Y - 24f); - for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++) - { - float velocityMult = 0.33f; - if (goreIndex < (goreAmt / 3)) - { - velocityMult = 0.66f; - } - if (goreIndex >= (2 * goreAmt / 3)) - { - velocityMult = 1f; - } - Mod mod = ModContent.GetInstance(); - int type = Main.rand.Next(61, 64); - int smoke = Gore.NewGore(Projectile.GetSource_FromAI(), source, default, type, 1f); - Gore gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_FromAI(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_FromAI(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y -= 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_FromAI(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y -= 1f; - } - } - - Projectile.ExpandHitboxBy(14); + // Actually destroy tiles. Blast radius is significantly increased in GFB. if (Projectile.owner == Main.myPlayer) - { - DestroyTiles(); - } + Projectile.ExplodeTiles(MortarRound.TileBlastRadius, true); - Projectile.penetrate--; - if (Projectile.penetrate <= 0) + // Play standard explosion sound. + SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); + + // Spawn standard explosion dust and gores. + MortarRoundProj.SpawnDust(Projectile); + MortarRoundProj.SpawnExplosionGores(Projectile); + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + // If there are no bounces left, just explode with no other effects. + if (Projectile.penetrate <= 1) { Projectile.Kill(); Projectile.active = false; + return false; } - else + + // Otherwise, the Rubber Mortar Round will explode AND bounce, in that order. + + // Explosions change both the penetrate value and hitbox, so the previous values have to be stored. + Rectangle origHitbox = Projectile.Hitbox; + int origPen = Projectile.penetrate; + Explode(); + Projectile.Hitbox = origHitbox; + Projectile.penetrate = origPen; + + // Each bounce consumes a penetrate value. + --Projectile.penetrate; + + // If bounces are still left, bounce. + if (Projectile.velocity.X != oldVelocity.X) { - if (Projectile.velocity.X != oldVelocity.X) - { - Projectile.velocity.X = -oldVelocity.X; - } - if (Projectile.velocity.Y != oldVelocity.Y) - { - Projectile.velocity.Y = -oldVelocity.Y; - } - Projectile.velocity *= 1.25f; + Projectile.velocity.X = -oldVelocity.X; } + if (Projectile.velocity.Y != oldVelocity.Y) + { + Projectile.velocity.Y = -oldVelocity.Y; + } + Projectile.velocity *= 1.25f; + + // Do not use vanilla tile collide logic. return false; } - public override void OnKill(int timeLeft) - { - Projectile.ExpandHitboxBy(200); - Projectile.maxPenetrate = Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - Projectile.knockBack *= 5f; - Projectile.Damage(); - SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - - SpawnDust(); - - if (Main.netMode != NetmodeID.Server) - { - Vector2 goreSource = Projectile.Center; - int goreAmt = 3; - Vector2 source = new Vector2(goreSource.X - 24f, goreSource.Y - 24f); - for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++) - { - float velocityMult = 0.33f; - if (goreIndex < (goreAmt / 3)) - { - velocityMult = 0.66f; - } - if (goreIndex >= (2 * goreAmt / 3)) - { - velocityMult = 1f; - } - Mod mod = ModContent.GetInstance(); - int type = Main.rand.Next(61, 64); - int smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - Gore gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y -= 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y -= 1f; - } - } - - Projectile.ExpandHitboxBy(14); - - if (Projectile.owner == Main.myPlayer) - { - DestroyTiles(); - } - } - - private void SpawnDust() - { - for (int d = 0; d < 40; d++) - { - int smoke = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Smoke, 0f, 0f, 100, default, 2f); - Main.dust[smoke].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[smoke].scale = 0.5f; - Main.dust[smoke].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int d = 0; d < 70; d++) - { - int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 3f); - Main.dust[fire].noGravity = true; - Main.dust[fire].velocity *= 5f; - fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 2f); - Main.dust[fire].velocity *= 2f; - } - } - - private void DestroyTiles() - { - CalamityUtils.ExplodeandDestroyTiles(Projectile, 5, false, new List() - { - ModContent.TileType(), - ModContent.TileType() - }, - new List() - { - ModContent.WallType(), - ModContent.WallType() - }); - } + public override void OnKill(int timeLeft) => Explode(); } } diff --git a/Projectiles/Ranged/SandstormBullet.cs b/Projectiles/Ranged/SandstormBullet.cs index bc25c7e9d2..76664ec6b3 100644 --- a/Projectiles/Ranged/SandstormBullet.cs +++ b/Projectiles/Ranged/SandstormBullet.cs @@ -43,9 +43,9 @@ namespace CalamityMod.Projectiles.Ranged { Projectile.alpha = 0; } - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 85, 0f, 0f, 100, default, 1f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 85, 0f, 0f, 100, default, 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0f; } } @@ -56,16 +56,16 @@ namespace CalamityMod.Projectiles.Ranged Projectile.width = Projectile.height = 32; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int constant = 36; + for (int i = 0; i < constant; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 85, vector7.X * 1.5f, vector7.Y * 1.5f, 100, default, 1.2f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(i - (constant / 2 - 1)) * 6.28318548f / (float)constant), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int dusty = Dust.NewDust(rotate + faceDirection, 0, 0, 85, faceDirection.X * 1.5f, faceDirection.Y * 1.5f, 100, default, 1.2f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].noLight = true; + Main.dust[dusty].velocity = faceDirection; } Projectile.maxPenetrate = -1; Projectile.penetrate = -1; diff --git a/Projectiles/Ranged/SandyWaifuShark.cs b/Projectiles/Ranged/SandyWaifuShark.cs deleted file mode 100644 index d6f862ecb0..0000000000 --- a/Projectiles/Ranged/SandyWaifuShark.cs +++ /dev/null @@ -1,76 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Ranged -{ - public class SandyWaifuShark : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override void SetStaticDefaults() - { - Main.projFrames[Projectile.type] = 8; - } - - public override void SetDefaults() - { - Projectile.width = 60; - Projectile.height = 60; - Projectile.scale = 0.75f; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.tileCollide = false; - Projectile.penetrate = 1; - Projectile.timeLeft = 240; - } - - public override bool? CanHitNPC(NPC target) => Projectile.timeLeft < 210 && target.CanBeChasedBy(Projectile); - - public override void AI() - { - int num192 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 32, 0f, 0f, 0, default, 0.5f); - Main.dust[num192].noGravity = true; - Main.dust[num192].velocity *= 0.2f; - Main.dust[num192].position = (Main.dust[num192].position + Projectile.Center) / 2f; - - Projectile.frameCounter++; - if (Projectile.frameCounter > 6) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame > 7) - Projectile.frame = 0; - - Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); - Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); - - if (Projectile.timeLeft < 210) - CalamityUtils.HomeInOnNPC(Projectile, true, 600f, 8f, 20f); - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 180); - - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 180); - - public override bool PreDraw(ref Color lightColor) - { - SpriteEffects spriteEffects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, spriteEffects, 0); - return false; - } - - public override void OnKill(int timeLeft) - { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 159, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f); - } - } - } -} diff --git a/Projectiles/Ranged/SeaDragonRocket.cs b/Projectiles/Ranged/SeaDragonRocket.cs index 5df6e719b8..df62ddf822 100644 --- a/Projectiles/Ranged/SeaDragonRocket.cs +++ b/Projectiles/Ranged/SeaDragonRocket.cs @@ -55,18 +55,18 @@ namespace CalamityMod.Projectiles.Ranged { for (int j = 0; j < 2; j++) { - float num247 = 0f; - float num248 = 0f; + float halfX = 0f; + float halfY = 0f; if (j == 1) { - num247 = Projectile.velocity.X * 0.5f; - num248 = Projectile.velocity.Y * 0.5f; + halfX = Projectile.velocity.X * 0.5f; + halfY = Projectile.velocity.Y * 0.5f; } - int explosion = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 6, 0f, 0f, 100, default, 1f); + int explosion = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 6, 0f, 0f, 100, default, 1f); Main.dust[explosion].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; Main.dust[explosion].velocity *= 0.2f; Main.dust[explosion].noGravity = true; - explosion = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 33, 0f, 0f, 100, default, 0.5f); + explosion = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 33, 0f, 0f, 100, default, 0.5f); Main.dust[explosion].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; Main.dust[explosion].velocity *= 0.05f; } diff --git a/Projectiles/Ranged/SeasSearingBubble.cs b/Projectiles/Ranged/SeasSearingBubble.cs index a2bfb0b4b8..b70e45ecf5 100644 --- a/Projectiles/Ranged/SeasSearingBubble.cs +++ b/Projectiles/Ranged/SeasSearingBubble.cs @@ -1,8 +1,8 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace CalamityMod.Projectiles.Ranged { @@ -38,25 +38,25 @@ namespace CalamityMod.Projectiles.Ranged } if (Projectile.timeLeft < 475) { - for (int num105 = 0; num105 < 2; num105++) + for (int i = 0; i < 2; i++) { - float num99 = Projectile.velocity.X / 3f * (float)num105; - float num100 = Projectile.velocity.Y / 3f * (float)num105; - int num101 = 4; - int num102 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num101, Projectile.position.Y + (float)num101), Projectile.width - num101 * 2, Projectile.height - num101 * 2, 202, 0f, 0f, 150, new Color(60, Main.DiscoG, 190), 1.2f); - Dust dust = Main.dust[num102]; + float dustVelX = Projectile.velocity.X / 3f * (float)i; + float dustVelY = Projectile.velocity.Y / 3f * (float)i; + int four = 4; + int dustID = Dust.NewDust(new Vector2(Projectile.position.X + (float)four, Projectile.position.Y + (float)four), Projectile.width - four * 2, Projectile.height - four * 2, 202, 0f, 0f, 150, new Color(60, Main.DiscoG, 190), 1.2f); + Dust dust = Main.dust[dustID]; dust.noGravity = true; dust.velocity *= 0.1f; dust.velocity += Projectile.velocity * 0.1f; - dust.position.X -= num99; - dust.position.Y -= num100; + dust.position.X -= dustVelX; + dust.position.Y -= dustVelY; } if (Main.rand.NextBool(10)) { - int num103 = 4; - int num104 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num103, Projectile.position.Y + (float)num103), Projectile.width - num103 * 2, Projectile.height - num103 * 2, 202, 0f, 0f, 150, new Color(60, Main.DiscoG, 190), 0.6f); - Main.dust[num104].velocity *= 0.25f; - Main.dust[num104].velocity += Projectile.velocity * 0.5f; + int otherFour = 4; + int otherDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)otherFour, Projectile.position.Y + (float)otherFour), Projectile.width - otherFour * 2, Projectile.height - otherFour * 2, 202, 0f, 0f, 150, new Color(60, Main.DiscoG, 190), 0.6f); + Main.dust[otherDust].velocity *= 0.25f; + Main.dust[otherDust].velocity += Projectile.velocity * 0.5f; } } } diff --git a/Projectiles/Ranged/SeasSearingSecondary.cs b/Projectiles/Ranged/SeasSearingSecondary.cs index 48571fb3d9..dfe4fc6006 100644 --- a/Projectiles/Ranged/SeasSearingSecondary.cs +++ b/Projectiles/Ranged/SeasSearingSecondary.cs @@ -32,14 +32,14 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { - for (int num468 = 0; num468 < 3; num468++) + for (int i = 0; i < 3; i++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 217, 0f, 0f, 100, new Color(60, Main.DiscoG, 190), Projectile.scale); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; - int num470 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 202, 0f, 0f, 100, new Color(60, Main.DiscoG, 190), Projectile.scale); - Main.dust[num470].noGravity = true; - Main.dust[num470].velocity *= 0f; + int aquaDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 217, 0f, 0f, 100, new Color(60, Main.DiscoG, 190), Projectile.scale); + Main.dust[aquaDust].noGravity = true; + Main.dust[aquaDust].velocity *= 0f; + int waterDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 202, 0f, 0f, 100, new Color(60, Main.DiscoG, 190), Projectile.scale); + Main.dust[waterDust].noGravity = true; + Main.dust[waterDust].velocity *= 0f; } } } diff --git a/Projectiles/Ranged/SeasSearingSpout.cs b/Projectiles/Ranged/SeasSearingSpout.cs index bf6cd5e195..8e2d8310d5 100644 --- a/Projectiles/Ranged/SeasSearingSpout.cs +++ b/Projectiles/Ranged/SeasSearingSpout.cs @@ -32,11 +32,11 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { - int num613 = 10; - int num614 = 15; - float num615 = 1f; - int num616 = 150; - int num617 = 42; + int projScale1 = 10; + int projScale2 = 15; + float thirdProjScale = 1f; + int projWidthScale = 150; + int projHeightScale = 42; if (Projectile.velocity.X != 0f) { Projectile.direction = Projectile.spriteDirection = -Math.Sign(Projectile.velocity.X); @@ -56,18 +56,18 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localAI[0] = 1f; Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y + (float)(Projectile.height / 2); - Projectile.scale = ((float)(num613 + num614) - Projectile.ai[1]) * num615 / (float)(num614 + num613); - Projectile.width = (int)((float)num616 * Projectile.scale); - Projectile.height = (int)((float)num617 * Projectile.scale); + Projectile.scale = ((float)(projScale1 + projScale2) - Projectile.ai[1]) * thirdProjScale / (float)(projScale2 + projScale1); + Projectile.width = (int)((float)projWidthScale * Projectile.scale); + Projectile.height = (int)((float)projHeightScale * Projectile.scale); Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); Projectile.netUpdate = true; } if (Projectile.ai[1] != -1f) { - Projectile.scale = ((float)(num613 + num614) - Projectile.ai[1]) * num615 / (float)(num614 + num613); - Projectile.width = (int)((float)num616 * Projectile.scale); - Projectile.height = (int)((float)num617 * Projectile.scale); + Projectile.scale = ((float)(projScale1 + projScale2) - Projectile.ai[1]) * thirdProjScale / (float)(projScale2 + projScale1); + Projectile.width = (int)((float)projWidthScale * Projectile.scale); + Projectile.height = (int)((float)projHeightScale * Projectile.scale); } if (!Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) { @@ -93,21 +93,21 @@ namespace CalamityMod.Projectiles.Ranged { Projectile.netUpdate = true; Vector2 center = Projectile.Center; - center.Y -= (float)num617 * Projectile.scale / 2f; - float num618 = ((float)(num613 + num614) - Projectile.ai[1] + 1f) * num615 / (float)(num614 + num613); - center.Y -= (float)num617 * num618 / 2f; + center.Y -= (float)projHeightScale * Projectile.scale / 2f; + float projSpawn = ((float)(projScale1 + projScale2) - Projectile.ai[1] + 1f) * thirdProjScale / (float)(projScale2 + projScale1); + center.Y -= (float)projHeightScale * projSpawn / 2f; center.Y += 2f; Projectile.NewProjectile(Projectile.GetSource_FromThis(), center.X, center.Y, Projectile.velocity.X, Projectile.velocity.Y, Projectile.type, Projectile.damage, Projectile.knockBack, Projectile.owner, 10f, Projectile.ai[1] - 1f); } if (Projectile.ai[0] <= 0f) { - float num622 = 0.104719758f; - float num623 = (float)Projectile.width / 5f; - float num624 = (float)(Math.Cos((double)(num622 * -(double)Projectile.ai[0])) - 0.5) * num623; - Projectile.position.X = Projectile.position.X - num624 * (float)-(float)Projectile.direction; + float swaySize = 0.104719758f; + float smolWidth = (float)Projectile.width / 5f; + float projXChange = (float)(Math.Cos((double)(swaySize * -(double)Projectile.ai[0])) - 0.5) * smolWidth; + Projectile.position.X = Projectile.position.X - projXChange * (float)-(float)Projectile.direction; Projectile.ai[0] -= 1f; - num624 = (float)(Math.Cos((double)(num622 * -(double)Projectile.ai[0])) - 0.5) * num623; - Projectile.position.X = Projectile.position.X + num624 * (float)-(float)Projectile.direction; + projXChange = (float)(Math.Cos((double)(swaySize * -(double)Projectile.ai[0])) - 0.5) * smolWidth; + Projectile.position.X = Projectile.position.X + projXChange * (float)-(float)Projectile.direction; } } @@ -119,9 +119,9 @@ namespace CalamityMod.Projectiles.Ranged public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } diff --git a/Projectiles/Ranged/SepticSkewerBacteria.cs b/Projectiles/Ranged/SepticSkewerBacteria.cs index ba79346b10..4986e8367c 100644 --- a/Projectiles/Ranged/SepticSkewerBacteria.cs +++ b/Projectiles/Ranged/SepticSkewerBacteria.cs @@ -26,15 +26,15 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { - int num297 = 171; + int dustType = 171; if (Main.rand.Next(3) == 0) { - num297 = 46; + dustType = 46; } - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, 0f, 0f, 100, default, 2f); - Main.dust[num469].noGravity = true; - float num944 = 1f - (float)Projectile.alpha / 255f; - num944 *= Projectile.scale; + int toxicDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); + Main.dust[toxicDust].noGravity = true; + float scaleAlpha = 1f - (float)Projectile.alpha / 255f; + scaleAlpha *= Projectile.scale; Projectile.localAI[0] += 1f; if (Projectile.localAI[0] >= 90f) { @@ -49,28 +49,28 @@ namespace CalamityMod.Projectiles.Ranged Projectile.scale -= 0.003f; } Projectile.rotation += 0.0025f * Projectile.scale; - float num945 = 1f; - float num946 = 1f; + float yVelControl = 1f; + float xVelControl = 1f; if (Projectile.identity % 6 == 0) { - num946 *= -1f; + xVelControl *= -1f; } if (Projectile.identity % 6 == 1) { - num945 *= -1f; + yVelControl *= -1f; } if (Projectile.identity % 6 == 2) { - num946 *= -1f; - num945 *= -1f; + xVelControl *= -1f; + yVelControl *= -1f; } if (Projectile.identity % 6 == 3) { - num946 = 0f; + xVelControl = 0f; } if (Projectile.identity % 6 == 4) { - num945 = 0f; + yVelControl = 0f; } Projectile.localAI[1] += 1f; if (Projectile.localAI[1] > 60f) @@ -79,13 +79,13 @@ namespace CalamityMod.Projectiles.Ranged } if (Projectile.localAI[1] >= -60f) { - Projectile.velocity.X = Projectile.velocity.X + 0.002f * num946; - Projectile.velocity.Y = Projectile.velocity.Y + 0.002f * num945; + Projectile.velocity.X = Projectile.velocity.X + 0.002f * xVelControl; + Projectile.velocity.Y = Projectile.velocity.Y + 0.002f * yVelControl; } else { - Projectile.velocity.X = Projectile.velocity.X - 0.002f * num946; - Projectile.velocity.Y = Projectile.velocity.Y - 0.002f * num945; + Projectile.velocity.X = Projectile.velocity.X - 0.002f * xVelControl; + Projectile.velocity.Y = Projectile.velocity.Y - 0.002f * yVelControl; } Projectile.ai[0] += 1f; if (Projectile.ai[0] > 5400f) @@ -107,36 +107,36 @@ namespace CalamityMod.Projectiles.Ranged } else { - float num947 = (Projectile.Center - Main.player[Projectile.owner].Center).Length() / 100f; - if (num947 > 4f) + float playerDist = (Projectile.Center - Main.player[Projectile.owner].Center).Length() / 100f; + if (playerDist > 4f) { - num947 *= 1.1f; + playerDist *= 1.1f; } - if (num947 > 5f) + if (playerDist > 5f) { - num947 *= 1.2f; + playerDist *= 1.2f; } - if (num947 > 6f) + if (playerDist > 6f) { - num947 *= 1.3f; + playerDist *= 1.3f; } - if (num947 > 7f) + if (playerDist > 7f) { - num947 *= 1.4f; + playerDist *= 1.4f; } - if (num947 > 8f) + if (playerDist > 8f) { - num947 *= 1.5f; + playerDist *= 1.5f; } - if (num947 > 9f) + if (playerDist > 9f) { - num947 *= 1.6f; + playerDist *= 1.6f; } - if (num947 > 10f) + if (playerDist > 10f) { - num947 *= 1.7f; + playerDist *= 1.7f; } - Projectile.ai[0] += num947; + Projectile.ai[0] += playerDist; if (Projectile.alpha > 50) { Projectile.alpha -= 10; @@ -163,16 +163,16 @@ namespace CalamityMod.Projectiles.Ranged Projectile.width = Projectile.height = 56; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int constant = 36; + for (int i = 0; i < constant; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 171, vector7.X, vector7.Y, 100, default, 0.5f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(i - (constant / 2 - 1)) * 6.28318548f / (float)constant), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int dust = Dust.NewDust(rotate + faceDirection, 0, 0, 171, faceDirection.X, faceDirection.Y, 100, default, 0.5f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + Main.dust[dust].velocity = faceDirection; } } } diff --git a/Projectiles/Ranged/SepticSkewerHarpoon.cs b/Projectiles/Ranged/SepticSkewerHarpoon.cs index 059a36a043..26a209a962 100644 --- a/Projectiles/Ranged/SepticSkewerHarpoon.cs +++ b/Projectiles/Ranged/SepticSkewerHarpoon.cs @@ -1,8 +1,9 @@ -using Microsoft.Xna.Framework; -using System; +using System; +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; -using CalamityMod.Buffs.DamageOverTime; + namespace CalamityMod.Projectiles.Ranged { public class SepticSkewerHarpoon : ModProjectile, ILocalizedModType @@ -31,7 +32,7 @@ namespace CalamityMod.Projectiles.Ranged { Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 171, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); } - Vector2 vector62 = player.Center - Projectile.Center; + Vector2 playerDist = player.Center - Projectile.Center; Projectile.ai[1] += 1f; if (Projectile.ai[1] > 5f) { @@ -39,11 +40,11 @@ namespace CalamityMod.Projectiles.Ranged } if (Projectile.ai[1] % 8f == 0f && Projectile.owner == Main.myPlayer && Main.rand.NextBool(5)) { - Vector2 vector63 = vector62 * -1f; - vector63.Normalize(); - vector63 *= Main.rand.Next(45, 65) * 0.1f; - vector63 = vector63.RotatedBy((Main.rand.NextDouble() - 0.5) * MathHelper.PiOver2); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, vector63.X, vector63.Y, ModContent.ProjectileType(), (int)(Projectile.damage * 0.175), Projectile.knockBack * 0.2f, Projectile.owner, -10f, 0f); + Vector2 harpoonPos = playerDist * -1f; + harpoonPos.Normalize(); + harpoonPos *= Main.rand.Next(45, 65) * 0.1f; + harpoonPos = harpoonPos.RotatedBy((Main.rand.NextDouble() - 0.5) * MathHelper.PiOver2); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, harpoonPos.X, harpoonPos.Y, ModContent.ProjectileType(), (int)(Projectile.damage * 0.175), Projectile.knockBack * 0.2f, Projectile.owner, -10f, 0f); } if (player.dead) { @@ -69,13 +70,13 @@ namespace CalamityMod.Projectiles.Ranged { Projectile.extraUpdates = 3; } - Vector2 vector14 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float xDist = player.position.X + (float)(player.width / 2) - vector14.X; - float yDist = player.position.Y + (float)(player.height / 2) - vector14.Y; - float playerDist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); + Vector2 halfDist = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float xDist = player.position.X + (float)(player.width / 2) - halfDist.X; + float yDist = player.position.Y + (float)(player.height / 2) - halfDist.Y; + float playerDistance = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); if (Projectile.ai[0] == 0f) { - if (playerDist > 2000f) + if (playerDistance > 2000f) { Projectile.ai[0] = 1f; } @@ -100,13 +101,13 @@ namespace CalamityMod.Projectiles.Ranged Projectile.tileCollide = false; Projectile.rotation = (float)Math.Atan2((double)yDist, (double)xDist) - 1.57f; float returnSpeed = 20f; - if (playerDist < 50f) + if (playerDistance < 50f) { Projectile.Kill(); } - playerDist = returnSpeed / playerDist; - xDist *= playerDist; - yDist *= playerDist; + playerDistance = returnSpeed / playerDistance; + xDist *= playerDistance; + yDist *= playerDistance; Projectile.velocity.X = xDist; Projectile.velocity.Y = yDist; } diff --git a/Projectiles/Ranged/SevensStrikerBrick.cs b/Projectiles/Ranged/SevensStrikerBrick.cs index 72aa47781d..bdd61e84c8 100644 --- a/Projectiles/Ranged/SevensStrikerBrick.cs +++ b/Projectiles/Ranged/SevensStrikerBrick.cs @@ -12,10 +12,11 @@ namespace CalamityMod.Projectiles.Ranged public override void SetDefaults() { - Projectile.width = 19; - Projectile.height = 19; + Projectile.width = 20; + Projectile.height = 20; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; + Projectile.timeLeft = 300; } public override void AI() diff --git a/Projectiles/Ranged/SevensStrikerCherry.cs b/Projectiles/Ranged/SevensStrikerCherry.cs index d7370a9f72..ca6218d69f 100644 --- a/Projectiles/Ranged/SevensStrikerCherry.cs +++ b/Projectiles/Ranged/SevensStrikerCherry.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Items.Weapons.Ranged; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -15,7 +16,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.height = 20; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.timeLeft = 480; + Projectile.timeLeft = 300; } public override void AI() @@ -27,10 +28,10 @@ namespace CalamityMod.Projectiles.Ranged { if (Projectile.owner == Main.myPlayer) { - for (int f = 0; f < 3; f++) + for (int f = 0; f < 2; f++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.4), 0f, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * TheSevensStriker.TriplesCherrySplitMultiplier), 0f, Projectile.owner); } } SoundEngine.PlaySound(SoundID.NPCDeath1, Projectile.position); diff --git a/Projectiles/Ranged/SevensStrikerCherrySplit.cs b/Projectiles/Ranged/SevensStrikerCherrySplit.cs index 76fea4bb43..aca24b229d 100644 --- a/Projectiles/Ranged/SevensStrikerCherrySplit.cs +++ b/Projectiles/Ranged/SevensStrikerCherrySplit.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.height = 20; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.timeLeft = 240; + Projectile.timeLeft = 150; } public override void AI() diff --git a/Projectiles/Ranged/SevensStrikerGrape.cs b/Projectiles/Ranged/SevensStrikerGrape.cs index c87862a53e..42a3db8d65 100644 --- a/Projectiles/Ranged/SevensStrikerGrape.cs +++ b/Projectiles/Ranged/SevensStrikerGrape.cs @@ -12,9 +12,9 @@ namespace CalamityMod.Projectiles.Ranged Projectile.height = 20; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.timeLeft = 480; + Projectile.timeLeft = 300; - Projectile.penetrate = -1; + Projectile.penetrate = 3; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; } diff --git a/Projectiles/Ranged/SevensStrikerHoldout.cs b/Projectiles/Ranged/SevensStrikerHoldout.cs index 8237a023c8..5996cb2eb8 100644 --- a/Projectiles/Ranged/SevensStrikerHoldout.cs +++ b/Projectiles/Ranged/SevensStrikerHoldout.cs @@ -137,15 +137,15 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(TheSevensStriker.JackpotSound, Projectile.Center); CombatText.NewText(player.getRect(), Color.Gold, CalamityUtils.GetTextValue("Misc.SevensJackpot"), true); } - // Every 5 frames, shoot 7 coins. The first 5 frames are excluded for timing purposes - if (shottimer % 5 == 0 && shottimer > 5) + // Every 7 frames, shoot 7 coins. The first 7 frames are excluded for timing purposes + if (shottimer % 7 == 0 && shottimer > 7) { int jackpotDamage = (int)(weaponDamage * TheSevensStriker.JackpotMultiplier); Shoot(7, ModContent.ProjectileType(), jackpotDamage, weaponKnockback, (int)scaleFactor * 2f, 0.2f); SoundEngine.PlaySound(TheSevensStriker.CoinSound, Projectile.Center); } // After 7 waves have been shot, reset the gun and roll again - if (shottimer > 40) + if (shottimer > 56) { soundtimer = 0; rolling = true; @@ -168,7 +168,7 @@ namespace CalamityMod.Projectiles.Ranged CombatText.NewText(player.getRect(), Color.Gray, CalamityUtils.GetTextValue("Misc.SevensBust"), true); SoundEngine.PlaySound(TheSevensStriker.BustSound, Projectile.Center); break; - // 7 exploding oranges with 200% damage + // 7 exploding oranges with 100% damage case 2: int doublesDamage = (int)(weaponDamage * TheSevensStriker.DoublesMultiplier); Shoot(7, ModContent.ProjectileType(), doublesDamage, weaponKnockback, 2f, 0.1f); @@ -223,7 +223,7 @@ namespace CalamityMod.Projectiles.Ranged } // Holdout stuff - Projectile.position = player.RotatedRelativePoint(player.MountedCenter, true) - Projectile.Size / 2f; + Projectile.position = (player.RotatedRelativePoint(player.MountedCenter, true) - Projectile.Size / 2f ) + Projectile.velocity * 95; Projectile.rotation = Projectile.velocity.ToRotation(); Projectile.spriteDirection = Projectile.direction; Projectile.timeLeft = 2; diff --git a/Projectiles/Ranged/SevensStrikerOrange.cs b/Projectiles/Ranged/SevensStrikerOrange.cs index bb269227be..4d5939a889 100644 --- a/Projectiles/Ranged/SevensStrikerOrange.cs +++ b/Projectiles/Ranged/SevensStrikerOrange.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.height = 20; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.timeLeft = 480; + Projectile.timeLeft = 300; } public override void AI() diff --git a/Projectiles/Ranged/ShadeFire.cs b/Projectiles/Ranged/ShadeFire.cs index 92d0297eb4..027b90d925 100644 --- a/Projectiles/Ranged/ShadeFire.cs +++ b/Projectiles/Ranged/ShadeFire.cs @@ -1,8 +1,11 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Ranged { public class ShadeFire : ModProjectile, ILocalizedModType @@ -10,79 +13,50 @@ namespace CalamityMod.Projectiles.Ranged public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public static int Lifetime => 60; + public ref float Time => ref Projectile.ai[0]; + public override void SetDefaults() { - Projectile.width = 6; - Projectile.height = 6; + Projectile.width = Projectile.height = 6; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = -1; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 80; + Projectile.MaxUpdates = 3; + Projectile.timeLeft = Lifetime; // 20 effectively + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() { - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.35f / 255f); - if (Projectile.timeLeft > 80) - { - Projectile.timeLeft = 80; - } - if (Projectile.ai[0] > 7f) - { - float num296 = 1f; - if (Projectile.ai[0] == 8f) - { - num296 = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - num296 = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - num296 = 0.75f; - } - Projectile.ai[0] += 1f; - int num297 = 14; - if (Main.rand.NextBool()) - { - for (int num298 = 0; num298 < 3; num298++) - { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 1.75f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 0.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= num296; - dust.velocity += Projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } - } - } - } + Time++; + + // Determines particle size as well as hitbox + if (Time >= 6f) + Projectile.scale = 1.5f * Utils.GetLerpValue(6f, 36f, Time, true); else + return; // Helps position it at the tip + + // Draw shadow smokes over the whole thing + float smokeRot = MathHelper.ToRadians(3f); // *Rate of rotation per frame, not a constant rotation + Color smokeColor = Color.Lerp(Color.BlueViolet, Color.Black, 0.7f + 0.2f * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f)); + Particle smoke = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, smokeColor, 20, Projectile.scale * Main.rand.NextFloat(0.6f, 1.2f), 0.8f, smokeRot, required: true); + GeneralParticleHandler.SpawnParticle(smoke); + + // Overlay the glow on top, which is on the brighter side + if (Main.rand.NextBool(5)) { - Projectile.ai[0] += 1f; + Color glowColor = Color.Lerp(smokeColor, Color.MidnightBlue, 0.25f); + Particle smokeGlow = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, glowColor, 15, Projectile.scale * Main.rand.NextFloat(0.4f, 0.7f), 0.8f, smokeRot, true, 0.005f); + GeneralParticleHandler.SpawnParticle(smokeGlow); } - Projectile.rotation += 0.3f * (float)Projectile.direction; - } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 300); } + + // Circular hitbox adjusted for the size of the smoke particles (which is 52 here) + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 52 * Projectile.scale * 0.5f, targetHitbox); + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 300); } } diff --git a/Projectiles/Ranged/Shell.cs b/Projectiles/Ranged/Shell.cs index bdb264fb45..bafa88139a 100644 --- a/Projectiles/Ranged/Shell.cs +++ b/Projectiles/Ranged/Shell.cs @@ -36,11 +36,11 @@ namespace CalamityMod.Projectiles.Ranged Projectile.height = 18; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 14, Projectile.oldVelocity.X / 4, Projectile.oldVelocity.Y / 4, 0, new Color(0, 255, 255), 1.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 14, Projectile.oldVelocity.X / 4, Projectile.oldVelocity.Y / 4, 0, new Color(0, 255, 255), 1.5f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 3f; } } } diff --git a/Projectiles/Ranged/Shockblast.cs b/Projectiles/Ranged/Shockblast.cs index 1b30da272c..1650910281 100644 --- a/Projectiles/Ranged/Shockblast.cs +++ b/Projectiles/Ranged/Shockblast.cs @@ -26,40 +26,40 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { Lighting.AddLight(Projectile.Center, 0f, 0f, 0.25f); - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while (num462 < num461) + int timerCounter = 0; + while (timerCounter < projTimer) { float sizeMultiplier = (Projectile.ai[1] * 0.5f) + 1f; - float num463 = Main.rand.Next(-10, 11) * sizeMultiplier; - float num464 = Main.rand.Next(-10, 11) * sizeMultiplier; - float num465 = Main.rand.Next(3, 9) * sizeMultiplier; - float num466 = (float)Math.Sqrt(num463 * num463 + num464 * num464); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 185); - Dust dust = Main.dust[num467]; + float rand1 = Main.rand.Next(-10, 11) * sizeMultiplier; + float rand2 = Main.rand.Next(-10, 11) * sizeMultiplier; + float rand3 = Main.rand.Next(3, 9) * sizeMultiplier; + float randAdjust = (float)Math.Sqrt(rand1 * rand1 + rand2 * rand2); + randAdjust = rand3 / randAdjust; + rand1 *= randAdjust; + rand2 *= randAdjust; + int shockDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 185); + Dust dust = Main.dust[shockDust]; dust.scale = sizeMultiplier; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += Main.rand.Next(-10, 11); dust.position.Y += Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = rand1; + dust.velocity.Y = rand2; + timerCounter++; } } } diff --git a/Projectiles/Ranged/ShockblastRound.cs b/Projectiles/Ranged/ShockblastRound.cs index b42fa38849..53c778ac36 100644 --- a/Projectiles/Ranged/ShockblastRound.cs +++ b/Projectiles/Ranged/ShockblastRound.cs @@ -55,17 +55,17 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { - for (int num136 = 0; num136 < 2; num136++) + for (int i = 0; i < 2; i++) { Vector2 dspeed = -Projectile.velocity * Main.rand.NextFloat(0.5f, 0.7f); - float x2 = Projectile.Center.X - Projectile.velocity.X / 10f * num136; - float y2 = Projectile.Center.Y - Projectile.velocity.Y / 10f * num136; - int num137 = Dust.NewDust(new Vector2(x2, y2), 1, 1, 185, 0f, 0f, 0, default, 1f); - Main.dust[num137].alpha = Projectile.alpha; - Main.dust[num137].position.X = x2; - Main.dust[num137].position.Y = y2; - Main.dust[num137].velocity = dspeed; - Main.dust[num137].noGravity = true; + float x2 = Projectile.Center.X - Projectile.velocity.X / 10f * i; + float y2 = Projectile.Center.Y - Projectile.velocity.Y / 10f * i; + int dust = Dust.NewDust(new Vector2(x2, y2), 1, 1, 185, 0f, 0f, 0, default, 1f); + Main.dust[dust].alpha = Projectile.alpha; + Main.dust[dust].position.X = x2; + Main.dust[dust].position.Y = y2; + Main.dust[dust].velocity = dspeed; + Main.dust[dust].noGravity = true; } } diff --git a/Projectiles/Ranged/Sickness.cs b/Projectiles/Ranged/Sickness.cs index 487edd4241..a0ef406d36 100644 --- a/Projectiles/Ranged/Sickness.cs +++ b/Projectiles/Ranged/Sickness.cs @@ -1,8 +1,9 @@ +using System; using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; -using System; using Terraria; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Ranged { public class Sickness : ModProjectile, ILocalizedModType @@ -27,60 +28,60 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.01f / 255f, (255 - Projectile.alpha) * 0.15f / 255f, (255 - Projectile.alpha) * 0.05f / 255f); - bool flag15 = false; - bool flag16 = false; + bool xflag = false; + bool yflag = false; if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) { - flag16 = true; + yflag = true; } if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) { - flag16 = true; + yflag = true; } - if (flag15 && flag16) + if (xflag && yflag) { Projectile.Kill(); } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-10, 11); - float num464 = (float)Main.rand.Next(-10, 11); - float num465 = (float)Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, default, 0.5f); - Dust dust = Main.dust[num467]; + float rand1 = (float)Main.rand.Next(-10, 11); + float rand2 = (float)Main.rand.Next(-10, 11); + float rand3 = (float)Main.rand.Next(3, 9); + float randAdjust = (float)Math.Sqrt((double)(rand1 * rand1 + rand2 * rand2)); + randAdjust = rand3 / randAdjust; + rand1 *= randAdjust; + rand2 *= randAdjust; + int dustID = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, default, 0.5f); + Dust dust = Main.dust[dustID]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = rand1; + dust.velocity.Y = rand2; + timerCounter++; } } diff --git a/Projectiles/Ranged/SicknessRound.cs b/Projectiles/Ranged/SicknessRound.cs index 95847ac1c4..db2e6c3e55 100644 --- a/Projectiles/Ranged/SicknessRound.cs +++ b/Projectiles/Ranged/SicknessRound.cs @@ -43,12 +43,12 @@ namespace CalamityMod.Projectiles.Ranged Vector2 dspeed = -Projectile.velocity * 0.5f; float x2 = Projectile.Center.X - Projectile.velocity.X / 10f; float y2 = Projectile.Center.Y - Projectile.velocity.Y / 10f; - int num137 = Dust.NewDust(new Vector2(x2, y2), 1, 1, 107, dspeed.X, dspeed.Y, 0, default, 1f); - Main.dust[num137].alpha = Projectile.alpha; - Main.dust[num137].position.X = x2; - Main.dust[num137].position.Y = y2; - Main.dust[num137].velocity = dspeed; - Main.dust[num137].noGravity = true; + int dust = Dust.NewDust(new Vector2(x2, y2), 1, 1, 107, dspeed.X, dspeed.Y, 0, default, 1f); + Main.dust[dust].alpha = Projectile.alpha; + Main.dust[dust].position.X = x2; + Main.dust[dust].position.Y = y2; + Main.dust[dust].velocity = dspeed; + Main.dust[dust].noGravity = true; } //Rotation diff --git a/Projectiles/Ranged/SicknessRound2.cs b/Projectiles/Ranged/SicknessRound2.cs index 0eafc78361..a37f5e7ca3 100644 --- a/Projectiles/Ranged/SicknessRound2.cs +++ b/Projectiles/Ranged/SicknessRound2.cs @@ -41,12 +41,12 @@ namespace CalamityMod.Projectiles.Ranged Vector2 dspeed = -Projectile.velocity * 0.5f; float x2 = Projectile.Center.X - Projectile.velocity.X / 10f; float y2 = Projectile.Center.Y - Projectile.velocity.Y / 10f; - int num137 = Dust.NewDust(new Vector2(x2, y2), 1, 1, 107, 0f, 0f, 0, default, 1f); - Main.dust[num137].alpha = Projectile.alpha; - Main.dust[num137].position.X = x2; - Main.dust[num137].position.Y = y2; - Main.dust[num137].velocity = dspeed; - Main.dust[num137].noGravity = true; + int dust = Dust.NewDust(new Vector2(x2, y2), 1, 1, 107, 0f, 0f, 0, default, 1f); + Main.dust[dust].alpha = Projectile.alpha; + Main.dust[dust].position.X = x2; + Main.dust[dust].position.Y = y2; + Main.dust[dust].velocity = dspeed; + Main.dust[dust].noGravity = true; //Rotation Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); diff --git a/Projectiles/Ranged/SlagRound.cs b/Projectiles/Ranged/SlagRound.cs index 70988f3cd6..692159f391 100644 --- a/Projectiles/Ranged/SlagRound.cs +++ b/Projectiles/Ranged/SlagRound.cs @@ -35,9 +35,9 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.localAI[0] > 4f) { Vector2 dspeed = -Projectile.velocity * 0.7f; - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 32, 0f, 0f, 100, default, 1f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity = dspeed; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 32, 0f, 0f, 100, default, 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity = dspeed; } } diff --git a/Projectiles/Ranged/SlimeBolt.cs b/Projectiles/Ranged/SlimeBolt.cs index 01542fa863..bb1125def5 100644 --- a/Projectiles/Ranged/SlimeBolt.cs +++ b/Projectiles/Ranged/SlimeBolt.cs @@ -1,4 +1,7 @@ +using CalamityMod.Particles; +using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,59 +11,155 @@ namespace CalamityMod.Projectiles.Ranged public class SlimeBolt : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/ExtraTextures/TinyGreyscaleCircle"; + + public static int Lifetime => 270; + public static float Fadetime => 225f; + public static float EmpowerTime => 135f; + public static Color SlimeColor => new Color (133, 133, 224); + + public ref float Time => ref Projectile.ai[0]; + public bool Empowered => Projectile.ai[0] >= EmpowerTime; + public ref float BloomPower => ref Projectile.ai[1]; + public bool Bounced => Projectile.ai[2] >= 1f; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + public override void SetDefaults() { - Projectile.width = 6; - Projectile.height = 6; - Projectile.aiStyle = ProjAIStyleID.Beam; + Projectile.width = Projectile.height = 20; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 2; - Projectile.timeLeft = 400; + Projectile.penetrate = -1; + Projectile.MaxUpdates = 3; + Projectile.timeLeft = Lifetime; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 15 * Projectile.MaxUpdates; } public override void AI() { - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.01f / 255f, (255 - Projectile.alpha) * 0.05f / 255f, (255 - Projectile.alpha) * 0.25f / 255f); - if (Main.rand.NextBool(5)) + Time++; + if (Time == EmpowerTime) { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 20, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); + Projectile.penetrate = 1; + Projectile.damage *= 2; + Projectile.velocity *= 0f; + Projectile.rotation = Main.rand.NextFloat(0f, MathHelper.TwoPi); + + float numberOfDusts = 10; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) + { + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 offset = new Vector2(Main.rand.NextFloat(3, 3.1f), 0).RotatedBy(rot); + Vector2 velOffset = new Vector2(Main.rand.NextFloat(3, 3.1f), 0).RotatedBy(rot); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, Main.rand.NextBool(3) ? 59 : 20, new Vector2(velOffset.X, velOffset.Y)); + dust.noGravity = true; + dust.velocity = velOffset; + dust.scale = Main.rand.NextFloat(1.2f, 1.9f); + } } + else if (Time >= 90f) + Projectile.velocity *= 0.97f; + + if (Empowered) + { + Projectile.rotation += MathHelper.ToRadians(2f); + if (Time >= Fadetime) + BloomPower = Utils.Remap(Time, Fadetime, Lifetime, 1.5f, 0f); + else + BloomPower = Utils.Remap(Time, EmpowerTime, Fadetime, 0f, 1.5f); + } + else if (Main.rand.NextBool(Bounced ? 2 : 7)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(10, 10), Main.rand.NextBool(3) ? 16 : 20); + dust.scale = Main.rand.NextFloat(0.3f, 0.7f); + dust.velocity = -Projectile.velocity * 0.7f; + } + + Lighting.AddLight(Projectile.Center, 0.3f, 0.3f, 0.5f); } public override bool OnTileCollide(Vector2 oldVelocity) { - Projectile.penetrate--; - if (Projectile.penetrate <= 0) + if (Projectile.velocity.X != oldVelocity.X) { - Projectile.Kill(); + Projectile.velocity.X = -oldVelocity.X * (Bounced ? 1f : Utils.Remap(Time, 0f, EmpowerTime, 1.5f, 4f)); } - else + if (Projectile.velocity.Y != oldVelocity.Y) { - if (Projectile.velocity.X != oldVelocity.X) - { - Projectile.velocity.X = -oldVelocity.X; - } - if (Projectile.velocity.Y != oldVelocity.Y) - { - Projectile.velocity.Y = -oldVelocity.Y; - } - Projectile.velocity *= 0.75f; + Projectile.velocity.Y = -oldVelocity.Y * (Bounced ? 1f : Utils.Remap(Time, 0f, EmpowerTime, 1.5f, 4f)); } + Projectile.ai[2]++; return false; } public override void OnKill(int timeLeft) { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 20, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f); - } + Particle pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, SlimeColor, Vector2.One, 0f, 0f, 0.4f, 25); + GeneralParticleHandler.SpawnParticle(pulse); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(BuffID.Slimed, 180); + target.AddBuff(BuffID.Slimed, Empowered ? 480 : 180); + if (Empowered) + { + Particle pulse2 = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, SlimeColor, Vector2.One, 0f, 0f, 0.65f, 35); + GeneralParticleHandler.SpawnParticle(pulse2); + float numberOfDusts = 12; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) + { + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 offset = new Vector2(Main.rand.NextFloat(1, 3.1f), 0).RotatedBy(rot); + Vector2 velOffset = new Vector2(Main.rand.NextFloat(1, 3.1f), 0).RotatedBy(rot); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, Main.rand.NextBool(3) ? 34 : 59, velOffset); + dust.noGravity = false; + dust.alpha = 130; + dust.velocity = velOffset; + dust.scale = dust.type == 20 ? Main.rand.NextFloat(0.9f, 1.9f) : Main.rand.NextFloat(1.6f, 2.2f); + } + } + } + + public override bool PreDraw(ref Color lightColor) + { + Main.spriteBatch.SetBlendState(BlendState.Additive); + + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Main.EntitySpriteDraw(texture, drawPosition, null, SlimeColor, Projectile.rotation, texture.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0); + + if (Empowered) + { + Texture2D shineTex = ModContent.Request("CalamityMod/Particles/Sparkle").Value; + Texture2D bloomTex = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + Main.EntitySpriteDraw(bloomTex, drawPosition, null, SlimeColor * 0.5f, Projectile.rotation, bloomTex.Size() * 0.5f, BloomPower * Projectile.scale * 0.3f, SpriteEffects.None); + Main.EntitySpriteDraw(shineTex, drawPosition, null, SlimeColor, Projectile.rotation, shineTex.Size() * 0.5f, BloomPower * Projectile.scale, SpriteEffects.None); + } + else + { + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + float completionRatio = i / (float)Projectile.oldPos.Length; + Vector2 trailPos = Projectile.oldPos[i] + texture.Size() * 0.5f - Main.screenPosition; + + // The further the smaller + Color trailColor = Color.Lerp(SlimeColor, Color.Black, completionRatio); + float trailScale = MathHelper.Lerp(0.15f, 1f, 1f - completionRatio); + + Main.EntitySpriteDraw(texture, trailPos, null, trailColor, 0f, texture.Size() * 0.5f, Projectile.scale * trailScale, SpriteEffects.None, 0); + } + } + + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + return false; } } } diff --git a/Projectiles/Ranged/SlimeBolt.png b/Projectiles/Ranged/SlimeBolt.png deleted file mode 100644 index f603916ffa..0000000000 Binary files a/Projectiles/Ranged/SlimeBolt.png and /dev/null differ diff --git a/Projectiles/Ranged/SmallCoral.cs b/Projectiles/Ranged/SmallCoral.cs index fa84464d40..9d41b75d69 100644 --- a/Projectiles/Ranged/SmallCoral.cs +++ b/Projectiles/Ranged/SmallCoral.cs @@ -37,11 +37,11 @@ namespace CalamityMod.Projectiles.Ranged Projectile.height = 16; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 51, Projectile.oldVelocity.X / 4, Projectile.oldVelocity.Y / 4, 0, new Color(234, 183, 100), 1f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 2f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 51, Projectile.oldVelocity.X / 4, Projectile.oldVelocity.Y / 4, 0, new Color(234, 183, 100), 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 2f; } } } diff --git a/Projectiles/Ranged/SparkSpreaderFire.cs b/Projectiles/Ranged/SparkSpreaderFire.cs index 473a849407..fa7385a9ee 100644 --- a/Projectiles/Ranged/SparkSpreaderFire.cs +++ b/Projectiles/Ranged/SparkSpreaderFire.cs @@ -1,4 +1,7 @@ -using Terraria; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,78 +12,83 @@ namespace CalamityMod.Projectiles.Ranged public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public ref float Time => ref Projectile.ai[0]; + public override void SetDefaults() { Projectile.width = Projectile.height = 12; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = 3; - Projectile.extraUpdates = 1; - Projectile.timeLeft = 60; + Projectile.MaxUpdates = 2; + Projectile.timeLeft = 42 * Projectile.MaxUpdates; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 30; + Projectile.localNPCHitCooldown = -1; } public override void AI() { - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.05f / 255f, (255 - Projectile.alpha) * 0.45f / 255f, (255 - Projectile.alpha) * 0.05f / 255f); - + // Krill the fire when the water if (Projectile.wet && !Projectile.lavaWet) { Projectile.Kill(); return; } - if (Main.rand.NextBool(3)) + Time++; + Projectile.rotation = Projectile.velocity.ToRotation(); + if (Time >= 8f) { - Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 35, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 80, default, 0.75f); - Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 55, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 50, default, 0.75f); + float cinderSize = Utils.GetLerpValue(6f, 12f, Time, true); + Dust cinder = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, ModContent.DustType(), Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 10, default, 0.75f); + if (Main.rand.NextBool(3)) + { + cinder.scale *= 3f; + cinder.velocity *= 1.5f; + } + cinder.noGravity = true; + cinder.scale *= cinderSize * 0.8f; + cinder.velocity += Projectile.velocity; } - - if (Projectile.ai[0]++ > 7f) - { - float dustScaleSize = 1f; - if (Projectile.ai[0] == 8f) - { - dustScaleSize = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - dustScaleSize = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - dustScaleSize = 0.75f; - } - Projectile.ai[0] += 1f; - int dustType = 6; - for (int i = 0; i < 2; i++) - { - int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 10, default, 0.75f); - Dust dust = Main.dust[fire]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 1.75f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.noGravity = true; - dust.scale *= 0.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= dustScaleSize; - dust.velocity += Projectile.velocity; - } - } - - Projectile.rotation += 0.3f * Projectile.direction; + else if (Time == 7f && !Main.rand.NextBool(4)) // Create short sparks around the tip at a pretty high chance + SpawnSparks(3, true); } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(1, 4)); - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(1, 4)); + // On-impact sparks + public override bool OnTileCollide(Vector2 oldVelocity) + { + SpawnSparks(8); + return true; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(1, 4)); + SpawnSparks(5); + } + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(1, 4)); + SpawnSparks(5); + } + + public void SpawnSparks(int count, bool shorts = false) + { + for (int i = 0; i < count; i++) + { + int sparkLifetime = Main.rand.Next(9, 16); + float sparkScale = Main.rand.NextFloat(0.2f, 0.4f); + Color sparkColor = Color.Lerp(Color.Gold, Color.OrangeRed, Main.rand.NextFloat(0.1f, 1f)); + + if (Main.rand.NextBool(6)) + sparkScale *= 1.5f; + + Vector2 sparkVelocity = Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(1.5f, 3f); + sparkVelocity.Y -= Main.rand.NextFloat(6f, 8f); + SparkParticle spark = new SparkParticle(Projectile.Center, (sparkVelocity * (shorts ? 0.75f : 1f)), true, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); + } + } } } diff --git a/Projectiles/Ranged/SpeedBlasterShot.cs b/Projectiles/Ranged/SpeedBlasterShot.cs index 712f695693..40755b24cf 100644 --- a/Projectiles/Ranged/SpeedBlasterShot.cs +++ b/Projectiles/Ranged/SpeedBlasterShot.cs @@ -1,9 +1,6 @@ -using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Graphics.Metaballs; using CalamityMod.Particles; -using CalamityMod.Particles.Metaballs; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; using System.Linq; using Terraria; using Terraria.Audio; @@ -140,7 +137,7 @@ namespace CalamityMod.Projectiles.Ranged { if (!DashShot) SoundEngine.PlaySound(ShotImpact, Projectile.position); - + for (int i = 0; i <= 8; i++) { Dust dust = Dust.NewDustPerfect(Projectile.position, 192, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(20f)) * Main.rand.NextFloat(0.05f, 0.3f), 0, default, Main.rand.NextFloat(0.6f, 1.2f)); @@ -154,23 +151,23 @@ namespace CalamityMod.Projectiles.Ranged { Vector2 paintPos = Projectile.Center + Main.rand.NextVector2Circular(12f, 12f) + (Projectile.velocity.SafeNormalize(Vector2.UnitY)).RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(4f, 20f); float paintSize = Main.rand.NextFloat(60f, 100f); - switch(Projectile.ai[0]) + switch (Projectile.ai[0]) { case 0: default: - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(paintPos, paintSize); + ModContent.GetInstance().SpawnParticle(paintPos, paintSize); break; case 1: - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(paintPos, paintSize); + ModContent.GetInstance().SpawnParticle(paintPos, paintSize); break; case 2: - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(paintPos, paintSize); + ModContent.GetInstance().SpawnParticle(paintPos, paintSize); break; case 3: - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(paintPos, paintSize); + ModContent.GetInstance().SpawnParticle(paintPos, paintSize); break; case 4: - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(paintPos, paintSize); + ModContent.GetInstance().SpawnParticle(paintPos, paintSize); break; } } diff --git a/Projectiles/Ranged/SputterComet.cs b/Projectiles/Ranged/SputterComet.cs index 7721de79eb..079b157173 100644 --- a/Projectiles/Ranged/SputterComet.cs +++ b/Projectiles/Ranged/SputterComet.cs @@ -35,10 +35,10 @@ namespace CalamityMod.Projectiles.Ranged Lighting.AddLight(Projectile.Center, 0.1f, 0.3f, 0.8f); if (Main.rand.NextBool(3)) { - int num137 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, ModContent.DustType(), 0f, 0f, 0, default, 0.5f); - Main.dust[num137].alpha = Projectile.alpha; - Main.dust[num137].velocity *= 0f; - Main.dust[num137].noGravity = true; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, ModContent.DustType(), 0f, 0f, 0, default, 0.5f); + Main.dust[dust].alpha = Projectile.alpha; + Main.dust[dust].velocity *= 0f; + Main.dust[dust].noGravity = true; } if (Projectile.soundDelay == 0) { @@ -69,7 +69,7 @@ namespace CalamityMod.Projectiles.Ranged } if (Main.netMode != NetmodeID.Server) { - for (int num480 = 0; num480 < 3; num480++) + for (int i = 0; i < 3; i++) { Gore.NewGore(Projectile.GetSource_Death(), Projectile.position, new Vector2(Projectile.velocity.X * 0.05f, Projectile.velocity.Y * 0.05f), Main.rand.Next(16, 18), 1f); } diff --git a/Projectiles/Ranged/SputterCometBig.cs b/Projectiles/Ranged/SputterCometBig.cs index 8346322bad..6a6b18f70c 100644 --- a/Projectiles/Ranged/SputterCometBig.cs +++ b/Projectiles/Ranged/SputterCometBig.cs @@ -35,10 +35,10 @@ namespace CalamityMod.Projectiles.Ranged Lighting.AddLight(Projectile.Center, 0.3f, 0.5f, 0.1f); if (Main.rand.NextBool(3)) { - int num137 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, ModContent.DustType(), 0f, 0f, 0, default, 0.5f); - Main.dust[num137].alpha = Projectile.alpha; - Main.dust[num137].velocity *= 0f; - Main.dust[num137].noGravity = true; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, ModContent.DustType(), 0f, 0f, 0, default, 0.5f); + Main.dust[dust].alpha = Projectile.alpha; + Main.dust[dust].velocity *= 0f; + Main.dust[dust].noGravity = true; } if (Projectile.soundDelay == 0) { @@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Ranged } if (Main.netMode != NetmodeID.Server) { - for (int num480 = 0; num480 < 3; num480++) + for (int i = 0; i < 3; i++) { Gore.NewGore(Projectile.GetSource_Death(), Projectile.position, new Vector2(Projectile.velocity.X * 0.05f, Projectile.velocity.Y * 0.05f), Main.rand.Next(16, 18), 1f); } diff --git a/Projectiles/Ranged/SpykerProj.cs b/Projectiles/Ranged/SpykerProj.cs index 80bb0fc9c0..4e9c7f5c90 100644 --- a/Projectiles/Ranged/SpykerProj.cs +++ b/Projectiles/Ranged/SpykerProj.cs @@ -42,11 +42,11 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localAI[1] += 1f; if (Projectile.localAI[1] > 4f) { - for (int num468 = 0; num468 < 2; num468++) + for (int i = 0; i < 2; i++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 46, 0f, 0f, 100, default, 0.75f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int poisonDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 46, 0f, 0f, 100, default, 0.75f); + Main.dust[poisonDust].noGravity = true; + Main.dust[poisonDust].velocity *= 0f; } } } @@ -75,23 +75,23 @@ namespace CalamityMod.Projectiles.Ranged Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5), 0f, Projectile.owner); } } - for (int num621 = 0; num621 < 3; num621++) + for (int j = 0; j < 3; j++) { - int num622 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 46, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 46, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 5; num623++) + for (int k = 0; k < 5; k++) { - int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 39, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 44, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 39, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 44, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); + Main.dust[dust2].velocity *= 2f; } } } diff --git a/Projectiles/Ranged/StarmageddonBinaryStarCenter.cs b/Projectiles/Ranged/StarmageddonBinaryStarCenter.cs index 9c443cdf87..ad559d9775 100644 --- a/Projectiles/Ranged/StarmageddonBinaryStarCenter.cs +++ b/Projectiles/Ranged/StarmageddonBinaryStarCenter.cs @@ -154,11 +154,11 @@ namespace CalamityMod.Projectiles.Ranged if (npc.type == NPCID.SolarCrawltipedeTail) { Rectangle rect = npc.Hitbox; - int num5 = 8; - rect.X -= num5; - rect.Y -= num5; - rect.Width += num5 * 2; - rect.Height += num5 * 2; + int rectSizeChange = 8; + rect.X -= rectSizeChange; + rect.Y -= rectSizeChange; + rect.Width += rectSizeChange * 2; + rect.Height += rectSizeChange * 2; stickingToNPC = Projectile.Colliding(myRect, rect); } else @@ -194,13 +194,13 @@ namespace CalamityMod.Projectiles.Ranged if (projCount >= array2.Length) { - int num30 = 0; + int maxProj = 0; for (int m = 1; m < array2.Length; m++) { - if (array2[m].Y < array2[num30].Y) - num30 = m; + if (array2[m].Y < array2[maxProj].Y) + maxProj = m; } - Main.projectile[array2[num30].X].Kill(); + Main.projectile[array2[maxProj].X].Kill(); } } } diff --git a/Projectiles/Ranged/StarmageddonStar.cs b/Projectiles/Ranged/StarmageddonStar.cs index 659416dca9..def82187f8 100644 --- a/Projectiles/Ranged/StarmageddonStar.cs +++ b/Projectiles/Ranged/StarmageddonStar.cs @@ -101,7 +101,7 @@ namespace CalamityMod.Projectiles.Ranged float dustVelocityX = Main.rand.NextFloat(-StarmageddonBinaryStarCenter.ParticleSpreadMax, StarmageddonBinaryStarCenter.ParticleSpreadMax); float dustVelocityY = top ? -StarmageddonBinaryStarCenter.ParticleVelocityMax : StarmageddonBinaryStarCenter.ParticleVelocityMax; Vector2 dustVelocity = new Vector2(dustVelocityX, dustVelocityY); - GeneralParticleHandler.SpawnParticle(new SparkParticle(Projectile.Center + Vector2.Normalize(dustVelocity) * StarmageddonBinaryStarCenter.ParticleSpawnOffset, dustVelocity, false, 180, 1f, Color.Orange)); + GeneralParticleHandler.SpawnParticle(new SparkParticle(Projectile.Center + Vector2.Normalize(dustVelocity) * StarmageddonBinaryStarCenter.ParticleSpawnOffset, dustVelocity, false, 60, 1.2f, Color.Orange)); } } @@ -123,14 +123,14 @@ namespace CalamityMod.Projectiles.Ranged for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * MathHelper.Pi / 6f), default) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy((double)(speed.ToRotation()), default); - int num9 = Dust.NewDust(position, 0, 0, 221, 0f, 0f, 0, default, 1f); - Main.dust[num9].noGravity = true; - Main.dust[num9].position = position + vector3; - Main.dust[num9].velocity = speed * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(position - speed * 3f - Main.dust[num9].position) * 1.25f; + Vector2 dustVel = Vector2.UnitX * (float)-(float)Projectile.width / 2f; + dustVel += -Vector2.UnitY.RotatedBy((double)((float)l * MathHelper.Pi / 6f), default) * new Vector2(8f, 16f); + dustVel = dustVel.RotatedBy((double)(speed.ToRotation()), default); + int starDust = Dust.NewDust(position, 0, 0, 221, 0f, 0f, 0, default, 1f); + Main.dust[starDust].noGravity = true; + Main.dust[starDust].position = position + dustVel; + Main.dust[starDust].velocity = speed * 0.1f; + Main.dust[starDust].velocity = Vector2.Normalize(position - speed * 3f - Main.dust[starDust].position) * 1.25f; } int type = Utils.SelectRandom(Main.rand, new int[] @@ -183,7 +183,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 4; i++) { - int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 31, 0f, 0f, 100, default(Color), 1.5f); + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, default(Color), 1.5f); Main.dust[dust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; } @@ -213,7 +213,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 10; i++) { - int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 31, 0f, 0f, 0, default(Color), 1.5f); + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 303, 0f, 0f, 0, default(Color), 1.5f); Main.dust[dust].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 2f; Main.dust[dust].noGravity = true; Dust dust2 = Main.dust[dust]; diff --git a/Projectiles/Ranged/StarmageddonStar2.cs b/Projectiles/Ranged/StarmageddonStar2.cs index b3c47abd6e..67713d636b 100644 --- a/Projectiles/Ranged/StarmageddonStar2.cs +++ b/Projectiles/Ranged/StarmageddonStar2.cs @@ -101,7 +101,7 @@ namespace CalamityMod.Projectiles.Ranged float dustVelocityX = Main.rand.NextFloat(-StarmageddonBinaryStarCenter.ParticleSpreadMax, StarmageddonBinaryStarCenter.ParticleSpreadMax); float dustVelocityY = top ? -StarmageddonBinaryStarCenter.ParticleVelocityMax : StarmageddonBinaryStarCenter.ParticleVelocityMax; Vector2 dustVelocity = new Vector2(dustVelocityX, dustVelocityY); - GeneralParticleHandler.SpawnParticle(new SparkParticle(Projectile.Center + Vector2.Normalize(dustVelocity) * StarmageddonBinaryStarCenter.ParticleSpawnOffset, dustVelocity, false, 180, 1f, Color.Cyan)); + GeneralParticleHandler.SpawnParticle(new SparkParticle(Projectile.Center + Vector2.Normalize(dustVelocity) * StarmageddonBinaryStarCenter.ParticleSpawnOffset, dustVelocity, false, 60, 1.2f, Color.Cyan)); } } @@ -123,14 +123,14 @@ namespace CalamityMod.Projectiles.Ranged for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * MathHelper.Pi / 6f), default) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy((double)(speed.ToRotation()), default); - int num9 = Dust.NewDust(position, 0, 0, 221, 0f, 0f, 0, default, 1f); - Main.dust[num9].noGravity = true; - Main.dust[num9].position = position + vector3; - Main.dust[num9].velocity = speed * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(position - speed * 3f - Main.dust[num9].position) * 1.25f; + Vector2 dustVel = Vector2.UnitX * (float)-(float)Projectile.width / 2f; + dustVel += -Vector2.UnitY.RotatedBy((double)((float)l * MathHelper.Pi / 6f), default) * new Vector2(8f, 16f); + dustVel = dustVel.RotatedBy((double)(speed.ToRotation()), default); + int starDust = Dust.NewDust(position, 0, 0, 221, 0f, 0f, 0, default, 1f); + Main.dust[starDust].noGravity = true; + Main.dust[starDust].position = position + dustVel; + Main.dust[starDust].velocity = speed * 0.1f; + Main.dust[starDust].velocity = Vector2.Normalize(position - speed * 3f - Main.dust[starDust].position) * 1.25f; } int type = Utils.SelectRandom(Main.rand, new int[] @@ -183,18 +183,18 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 4; i++) { - int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 160, 0f, 0f, 100, default(Color), 1.5f); + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 135, 0f, 0f, 100, default(Color), 1.5f); Main.dust[dust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; } for (int i = 0; i < 30; i++) { - int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 229, 0f, 0f, 200, default(Color), 3.7f); + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 135, 0f, 0f, 200, default(Color), 3.7f); Main.dust[dust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; Main.dust[dust].noGravity = true; Dust dust2 = Main.dust[dust]; dust2.velocity *= 3f; - dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 229, 0f, 0f, 100, default(Color), 1.5f); + dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 135, 0f, 0f, 100, default(Color), 1.5f); Main.dust[dust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; dust2 = Main.dust[dust]; dust2.velocity *= 2f; @@ -204,7 +204,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 10; i++) { - int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 229, 0f, 0f, 0, default(Color), 2.7f); + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 135, 0f, 0f, 0, default(Color), 2.7f); Main.dust[dust].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 2f; Main.dust[dust].noGravity = true; Dust dust2 = Main.dust[dust]; @@ -213,7 +213,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 10; i++) { - int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 160, 0f, 0f, 0, default(Color), 1.5f); + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 303, 0f, 0f, 0, default(Color), 1.5f); Main.dust[dust].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 2f; Main.dust[dust].noGravity = true; Dust dust2 = Main.dust[dust]; diff --git a/Projectiles/Ranged/StormSurgeTornado.cs b/Projectiles/Ranged/StormSurgeTornado.cs index cef40679e6..5fb3d959db 100644 --- a/Projectiles/Ranged/StormSurgeTornado.cs +++ b/Projectiles/Ranged/StormSurgeTornado.cs @@ -52,9 +52,9 @@ namespace CalamityMod.Projectiles.Ranged public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } } diff --git a/Projectiles/Ranged/SuperballBulletProj.cs b/Projectiles/Ranged/SuperballBulletProj.cs index 70cf6abf54..c64b5b19d4 100644 --- a/Projectiles/Ranged/SuperballBulletProj.cs +++ b/Projectiles/Ranged/SuperballBulletProj.cs @@ -36,10 +36,10 @@ namespace CalamityMod.Projectiles.Ranged { if (Main.rand.NextBool(3)) { - int num137 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, 87, 0f, 0f, 0, default, 0.5f); - Main.dust[num137].alpha = Projectile.alpha; - Main.dust[num137].velocity *= 0f; - Main.dust[num137].noGravity = true; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, 87, 0f, 0f, 0, default, 0.5f); + Main.dust[dust].alpha = Projectile.alpha; + Main.dust[dust].velocity *= 0f; + Main.dust[dust].noGravity = true; } } } diff --git a/Projectiles/Ranged/TerraFire.cs b/Projectiles/Ranged/TerraFire.cs new file mode 100644 index 0000000000..ea49e162a7 --- /dev/null +++ b/Projectiles/Ranged/TerraFire.cs @@ -0,0 +1,89 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class TerraFire : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public static int Lifetime => 96; + public bool BlueFire => Projectile.ai[0] == 1f; + public ref float Time => ref Projectile.ai[1]; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 12; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = 4; + Projectile.MaxUpdates = 5; + Projectile.timeLeft = Lifetime; // 24 effectively + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void AI() + { + Time++; + + if (Time == 1) + { + MediumMistParticle smoke2 = new MediumMistParticle(Projectile.Center + Main.rand.NextVector2Circular(5, 5), (Projectile.velocity * 1f).RotatedByRandom(0.15f) * Main.rand.NextFloat(0.2f, 2.1f), Color.Lime, Color.Turquoise, Main.rand.NextFloat(0.8f, 1.9f), 180, Main.rand.NextFloat(-3f, 3f)); + GeneralParticleHandler.SpawnParticle(smoke2); + MediumMistParticle smoke3 = new MediumMistParticle(Projectile.Center + Main.rand.NextVector2Circular(5, 5), (Projectile.velocity * 2).RotatedByRandom(0.05f) * Main.rand.NextFloat(0.2f, 2.1f), Color.Lime, Color.Turquoise, Main.rand.NextFloat(0.4f, 1.1f), 180, Main.rand.NextFloat(-3f, 3f)); + GeneralParticleHandler.SpawnParticle(smoke3); + for (int i = 0; i < 9; i++) + { + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(5) ? 135 : 107); + dust2.noGravity = true; + dust2.velocity = Projectile.velocity.RotatedByRandom(0.7f) * Main.rand.NextFloat(0.3f, 2.9f); + dust2.scale = Main.rand.NextFloat(1.3f, 2.1f); + } + } + // Determines particle size as well as hitbox + if (Time >= 1f) + Projectile.scale = 1.8f * Utils.GetLerpValue(6f, 30f, Time, true); + else + return; // Helps position it at the tip + + // Main smokes shifting between green to green-blue and back + float smokeRot = MathHelper.ToRadians(3f); // *Rate of rotation per frame, not a constant rotation + float colorValue = CalamityUtils.Convert01To010(Utils.GetLerpValue(30f, Lifetime, Time, true)); + Color smokeColor = Color.Lerp(Color.Lime, Color.Turquoise, colorValue); + Particle smoke = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, smokeColor, 18, Projectile.scale * Main.rand.NextFloat(0.6f, 1.2f), 0.4f, smokeRot, true, required: true); + GeneralParticleHandler.SpawnParticle(smoke); + + if (Time > 4) + { + for (int i = 0; i < 2; i++) + { + float dustArea = Main.rand.NextFloat(0.1f, 1.7f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(9, 9) + Projectile.velocity * Main.rand.NextFloat(-1.8f, 1.8f), Main.rand.NextBool(5) ? 135 : 107); + dust.noGravity = true; + dust.velocity = new Vector2(6, 6).RotatedByRandom(100) * dustArea; + dust.scale = (1.8f - dustArea) * 0.65f; + } + } + + // Overlay a gold glow on top + if (Main.rand.NextBool(5)) + { + Color glowColor = Color.Gold; + Particle smokeGlow = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, glowColor, 9, Projectile.scale * Main.rand.NextFloat(0.4f, 0.7f), 0.2f, smokeRot, true, 0.005f); + GeneralParticleHandler.SpawnParticle(smokeGlow); + } + + Lighting.AddLight(Projectile.Center, smokeColor.ToVector3() * Projectile.scale * 0.3f); + } + + // Circular hitbox adjusted for the size of the smoke particles (which is 52 here) + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 52 * Projectile.scale * 0.5f, targetHitbox); + } +} diff --git a/Projectiles/Ranged/TerraFireGreen.cs b/Projectiles/Ranged/TerraFireGreen.cs deleted file mode 100644 index cd8c65b926..0000000000 --- a/Projectiles/Ranged/TerraFireGreen.cs +++ /dev/null @@ -1,90 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Ranged -{ - public class TerraFireGreen : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetDefaults() - { - Projectile.width = 12; - Projectile.height = 12; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = -1; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 120; - } - - public override void AI() - { - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.15f / 255f, (255 - Projectile.alpha) * 0.45f / 255f, (255 - Projectile.alpha) * 0.05f / 255f); - if (Projectile.timeLeft > 120) - { - Projectile.timeLeft = 120; - } - if (Projectile.ai[0] > 7f) - { - float num296 = 1f; - if (Projectile.ai[0] == 8f) - { - num296 = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - num296 = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - num296 = 0.75f; - } - Projectile.ai[0] += 1f; - int num297 = 107; - if (Main.rand.NextBool()) - { - for (int num298 = 0; num298 < 3; num298++) - { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 0.75f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 2f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 0.75f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= num296; - dust.velocity += Projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } - } - } - } - else - { - Projectile.ai[0] += 1f; - } - Projectile.rotation += 0.3f * (float)Projectile.direction; - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.immune[Projectile.owner] = 5; - target.AddBuff(BuffID.CursedInferno, 90); - } - } -} diff --git a/Projectiles/Ranged/TerraFlamebursterHouldout.cs b/Projectiles/Ranged/TerraFlamebursterHouldout.cs new file mode 100644 index 0000000000..9481b8c9ea --- /dev/null +++ b/Projectiles/Ranged/TerraFlamebursterHouldout.cs @@ -0,0 +1,135 @@ +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using log4net.Core; +using Microsoft.Xna.Framework; +using Mono.Cecil; +using ReLogic.Utilities; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class TerraFlamebursterHoldout : ModProjectile + { + // Take the name and texture from the weapon + public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + public override string Texture => "CalamityMod/Items/Weapons/Ranged/TerraFlameburster"; + private Player Owner => Main.player[Projectile.owner]; + private ref float ShotsFired => ref Projectile.ai[1]; + private ref float ShootTimer => ref Projectile.ai[2]; + private ref int ShotDelay => ref Owner.ActiveItem().useTime; // 8 + public int ShotCooldown; + public int FireBlobs = 0; + public int Time = 0; + private bool OwnerCanShoot => Owner.channel && !Owner.noItems && !Owner.CCed; + + public override void SetDefaults() + { + Projectile.width = 68; + Projectile.height = 26; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.DamageType = DamageClass.Ranged; + Projectile.ignoreWater = true; + } + + public override void AI() + { + Time++; + if (Time == 1) + Projectile.alpha = 255; + else + Projectile.alpha = 0; + + if (Owner.dead || ShotsFired >= 16) // destroy the holdout if the player dies or is out of shots + { + Projectile.Kill(); + return; + } + + Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); + Vector2 tipPosition = armPosition + Projectile.velocity * Projectile.width * 0.8f; + + // Kill if the owner stops channeling or otherwise cannot use the weapon. + if (!OwnerCanShoot) + { + Projectile.Kill(); + } + else + { + // While channeled, keep refreshing the projectile lifespan + Projectile.timeLeft = 2; + + ShootTimer++; + if (ShootTimer >= 60) + { + if (ShotCooldown == 0) + { + SoundEngine.PlaySound(SoundID.Item34, Projectile.Center); + Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _, Main.rand.NextBool(2) ? true : false); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, (Projectile.velocity * 9).RotatedByRandom(0.08f), ModContent.ProjectileType(), damage, knockback, Projectile.owner); + ShotsFired++; + ShotCooldown = ShotDelay; + if (FireBlobs == 0) + { + float randAngle = Main.rand.NextFloat(8f, 15f); + Vector2 newVel = (Projectile.velocity * 9).RotatedBy(MathHelper.ToRadians(randAngle)) * 2f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, newVel, ModContent.ProjectileType(), damage, knockback, Projectile.owner); + newVel = (Projectile.velocity * 9).RotatedBy(MathHelper.ToRadians(-randAngle)) * 2f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, newVel, ModContent.ProjectileType(), damage, knockback, Projectile.owner); + FireBlobs = 3; + } + else + FireBlobs--; + } + else + ShotCooldown--; + } + else + { + if (ShootTimer == 1) + SoundEngine.PlaySound(SoundID.Item73 with { Volume = 0.7f}, Projectile.Center); + ShotsFired = 0; + for (int i = 0; i < 2; i++) + { + float rotMulti = Main.rand.NextFloat(0.3f, 1f); + Dust dust2 = Dust.NewDustPerfect(tipPosition, Main.rand.NextBool(5) ? 135 : 107); + dust2.noGravity = true; + dust2.velocity = new Vector2(0, -2).RotatedByRandom(rotMulti * 0.3f) * (Main.rand.NextFloat(1f, 2.9f) - rotMulti); + dust2.scale = Main.rand.NextFloat(1.2f, 1.8f) * (ShootTimer * 0.015f); + } + } + + } + UpdateProjectileHeldVariables(armPosition); + ManipulatePlayerVariables(); + } + + private void UpdateProjectileHeldVariables(Vector2 armPosition) + { + if (Main.myPlayer == Projectile.owner) + { + float interpolant = Utils.GetLerpValue(5f, 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; + } + + private void ManipulatePlayerVariables() + { + Owner.ChangeDir(Projectile.direction); + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); + } + public override bool? CanDamage() => false; + } +} diff --git a/Projectiles/Ranged/TerraFlare.cs b/Projectiles/Ranged/TerraFlare.cs new file mode 100644 index 0000000000..9bbfe20c28 --- /dev/null +++ b/Projectiles/Ranged/TerraFlare.cs @@ -0,0 +1,74 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class TerraFlare : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/ExtraTextures/SmallGreyscaleCircle"; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 18; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 40; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.penetrate = 1; + Projectile.MaxUpdates = 2; + Projectile.timeLeft = 90 * Projectile.MaxUpdates; + Projectile.DamageType = DamageClass.Ranged; + Projectile.tileCollide = false; + } + + public override void AI() => CalamityUtils.HomeInOnNPC(Projectile, true, 640f, 15f, 20f); + + public override void OnKill(int timeLeft) + { + // Circular spread of clouds + for (int i = 0; i < 8; i++) + { + Vector2 smokeVel = Main.rand.NextVector2Circular(8f, 8f); + Color smokeColor = Main.rand.NextBool() ? Color.Lime : Color.Turquoise; + Particle smoke = new MediumMistParticle(Projectile.Center, smokeVel, smokeColor, Color.Black, Main.rand.NextFloat(0.4f, 0.8f), 200 - Main.rand.Next(60), 0.1f); + GeneralParticleHandler.SpawnParticle(smoke); + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D lightTexture = ModContent.Request(Texture).Value; + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + float colorInterpolation = MathF.Cos(Projectile.timeLeft / 16f + Main.GlobalTimeWrappedHourly / 20f + i / (float)Projectile.oldPos.Length * MathHelper.Pi) * 0.5f + 0.5f; + Color color = Color.Lerp(Color.Lime, Color.Turquoise, colorInterpolation); + Vector2 drawPosition = Projectile.oldPos[i] + lightTexture.Size() * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY) + new Vector2(-15f, -15f); + Color outerColor = color; + Color innerColor = Color.Lerp(color, Color.Gold, 0.8f) * 0.5f; + float intensity = 0.9f + 0.15f * MathF.Cos(Main.GlobalTimeWrappedHourly % 60f * MathHelper.TwoPi); + + // Become smaller the futher along the old positions we are. + intensity *= MathHelper.Lerp(0.15f, 1f, 1f - i / (float)Projectile.oldPos.Length); + + Vector2 outerScale = new Vector2(1.25f) * intensity; + Vector2 innerScale = new Vector2(1.25f) * intensity * 0.7f; + outerColor *= intensity * Projectile.scale; + innerColor *= intensity * Projectile.scale; + Main.EntitySpriteDraw(lightTexture, drawPosition, null, outerColor, 0f, lightTexture.Size() * 0.5f, outerScale * 0.6f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(lightTexture, drawPosition, null, innerColor, 0f, lightTexture.Size() * 0.5f, innerScale * 0.6f, SpriteEffects.None, 0); + } + return false; + } + } +} diff --git a/Projectiles/Ranged/TheMaelstromExplosion.cs b/Projectiles/Ranged/TheMaelstromExplosion.cs index 1c19bf8c20..a55b68bdd5 100644 --- a/Projectiles/Ranged/TheMaelstromExplosion.cs +++ b/Projectiles/Ranged/TheMaelstromExplosion.cs @@ -11,6 +11,8 @@ namespace CalamityMod.Projectiles.Ranged public class TheMaelstromExplosion : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/ExtraTextures/SmallGreyscaleCircle"; + public override void SetStaticDefaults() { ProjectileID.Sets.TrailingMode[Projectile.type] = 0; diff --git a/Projectiles/Ranged/TheMaelstromExplosion.png b/Projectiles/Ranged/TheMaelstromExplosion.png deleted file mode 100644 index c6b3592c9f..0000000000 Binary files a/Projectiles/Ranged/TheMaelstromExplosion.png and /dev/null differ diff --git a/Projectiles/Ranged/ThePackMinissile.cs b/Projectiles/Ranged/ThePackMinissile.cs index a6ed7c8af7..b4a5346673 100644 --- a/Projectiles/Ranged/ThePackMinissile.cs +++ b/Projectiles/Ranged/ThePackMinissile.cs @@ -46,7 +46,7 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(SoundID.Item14, Projectile.position); for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 255, 0f, 0f, 0, default, 1f); + int DUST = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 255, 0f, 0f, 0, default, 1f); } } diff --git a/Projectiles/Ranged/ThePackMissile.cs b/Projectiles/Ranged/ThePackMissile.cs index 537db21772..4275d0a5f7 100644 --- a/Projectiles/Ranged/ThePackMissile.cs +++ b/Projectiles/Ranged/ThePackMissile.cs @@ -89,23 +89,23 @@ namespace CalamityMod.Projectiles.Ranged Projectile.height = 400; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 255, 0f, 0f, 0, default, 1.5f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 255, 0f, 0f, 0, default, 1.5f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 60; num623++) + for (int j = 0; j < 60; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 255, 0f, 0f, 0, default, 2f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 255, 0f, 0f, 0, default, 1.5f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 255, 0f, 0f, 0, default, 2f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 255, 0f, 0f, 0, default, 1.5f); + Main.dust[dust2].velocity *= 2f; } Projectile.Damage(); } diff --git a/Projectiles/Ranged/TorrentialArrow.cs b/Projectiles/Ranged/TorrentialArrow.cs index ef1d951cee..5dcced44bc 100644 --- a/Projectiles/Ranged/TorrentialArrow.cs +++ b/Projectiles/Ranged/TorrentialArrow.cs @@ -34,19 +34,18 @@ namespace CalamityMod.Projectiles.Ranged { Projectile.alpha = 0; } - float num55 = 40f; - float num56 = 1.5f; + float inc = 1.5f; if (Projectile.ai[1] == 0f) { - Projectile.localAI[0] += num56; - if (Projectile.localAI[0] > num55) + Projectile.localAI[0] += inc; + if (Projectile.localAI[0] > 40f) { - Projectile.localAI[0] = num55; + Projectile.localAI[0] = 40f; } } else { - Projectile.localAI[0] -= num56; + Projectile.localAI[0] -= inc; if (Projectile.localAI[0] <= 0f) { Projectile.Kill(); diff --git a/Projectiles/Ranged/TyphoonBubble.cs b/Projectiles/Ranged/TyphoonBubble.cs index 7cadb2c430..9eda039def 100644 --- a/Projectiles/Ranged/TyphoonBubble.cs +++ b/Projectiles/Ranged/TyphoonBubble.cs @@ -31,23 +31,23 @@ namespace CalamityMod.Projectiles.Ranged { if (Projectile.ai[1] > 0f) { - int num625 = (int)Projectile.ai[1] - 1; - if (num625 < 255) + int playerOwner = (int)Projectile.ai[1] - 1; + if (playerOwner < 255) { Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 10f) { - int num626 = 6; - for (int num627 = 0; num627 < num626; num627++) + int six = 6; + for (int i = 0; i < six; i++) { - Vector2 vector45 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector45 = vector45.RotatedBy((double)(num627 - (num626 / 2 - 1)) * 3.1415926535897931 / (double)(float)num626, default) + Projectile.Center; - Vector2 value15 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); - int num628 = Dust.NewDust(vector45 + value15, 0, 0, 172, value15.X * 2f, value15.Y * 2f, 100, default, 1.4f); - Main.dust[num628].noGravity = true; - Main.dust[num628].noLight = true; - Main.dust[num628].velocity /= 4f; - Main.dust[num628].velocity -= Projectile.velocity; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)(i - (six / 2 - 1)) * 3.1415926535897931 / (double)(float)six, default) + Projectile.Center; + Vector2 dustPos = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + int typhoonDust = Dust.NewDust(rotate + dustPos, 0, 0, 172, dustPos.X * 2f, dustPos.Y * 2f, 100, default, 1.4f); + Main.dust[typhoonDust].noGravity = true; + Main.dust[typhoonDust].noLight = true; + Main.dust[typhoonDust].velocity /= 4f; + Main.dust[typhoonDust].velocity -= Projectile.velocity; } Projectile.alpha -= 5; if (Projectile.alpha < 100) @@ -57,11 +57,11 @@ namespace CalamityMod.Projectiles.Ranged Projectile.rotation += Projectile.velocity.X * 0.1f; Projectile.frame = (int)(Projectile.localAI[0] / 3f) % 3; } - Vector2 value16 = Main.player[num625].Center - Projectile.Center; - float num629 = 4f; - num629 += Projectile.localAI[0] / 20f; - Projectile.velocity = Vector2.Normalize(value16) * num629; - if (value16.Length() < 50f) + Vector2 playerDist = Main.player[playerOwner].Center - Projectile.Center; + float velocityMult = 4f; + velocityMult += Projectile.localAI[0] / 20f; + Projectile.velocity = Vector2.Normalize(playerDist) * velocityMult; + if (playerDist.Length() < 50f) { Projectile.Kill(); } @@ -69,13 +69,13 @@ namespace CalamityMod.Projectiles.Ranged } else { - float num630 = 0.209439516f; - float num631 = 4f; - float num632 = (float)(Math.Cos((double)(num630 * Projectile.ai[0])) - 0.5) * num631; - Projectile.velocity.Y = Projectile.velocity.Y - num632; + float swaySize = 0.209439516f; + float smolWidth = 4f; + float projXChange = (float)(Math.Cos((double)(swaySize * Projectile.ai[0])) - 0.5) * smolWidth; + Projectile.velocity.Y = Projectile.velocity.Y - projXChange; Projectile.ai[0] += 1f; - num632 = (float)(Math.Cos((double)(num630 * Projectile.ai[0])) - 0.5) * num631; - Projectile.velocity.Y = Projectile.velocity.Y + num632; + projXChange = (float)(Math.Cos((double)(swaySize * Projectile.ai[0])) - 0.5) * smolWidth; + Projectile.velocity.Y = Projectile.velocity.Y + projXChange; Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 10f) { @@ -98,16 +98,16 @@ namespace CalamityMod.Projectiles.Ranged public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.NPCDeath19, Projectile.position); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int constant = 36; + for (int j = 0; j < constant; j++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 172, vector7.X * 2f, vector7.Y * 2f, 100, default, 1.4f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(j - (constant / 2 - 1)) * 6.28318548f / (float)constant), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int waterDust = Dust.NewDust(rotate + faceDirection, 0, 0, 172, faceDirection.X * 2f, faceDirection.Y * 2f, 100, default, 1.4f); + Main.dust[waterDust].noGravity = true; + Main.dust[waterDust].noLight = true; + Main.dust[waterDust].velocity = faceDirection; } if (Projectile.owner == Main.myPlayer) { @@ -115,13 +115,13 @@ namespace CalamityMod.Projectiles.Ranged { if (Projectile.localAI[1] == 1f) { - int num230 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X - (float)(Projectile.direction * 30), Projectile.Center.Y - 4f, (float)-(float)Projectile.direction * 0.01f, 0f, ModContent.ProjectileType(), Projectile.damage, 3f, Projectile.owner, 16f, 8f); - Main.projectile[num230].netUpdate = true; + int nextSegment = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X - (float)(Projectile.direction * 30), Projectile.Center.Y - 4f, (float)-(float)Projectile.direction * 0.01f, 0f, ModContent.ProjectileType(), Projectile.damage, 3f, Projectile.owner, 16f, 8f); + Main.projectile[nextSegment].netUpdate = true; } else { - int num230 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X - (float)(Projectile.direction * 30), Projectile.Center.Y - 4f, (float)-(float)Projectile.direction * 0.01f, 0f, ModContent.ProjectileType(), Projectile.damage, 3f, Projectile.owner, 16f, 8f); - Main.projectile[num230].netUpdate = true; + int nextSegment = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X - (float)(Projectile.direction * 30), Projectile.Center.Y - 4f, (float)-(float)Projectile.direction * 0.01f, 0f, ModContent.ProjectileType(), Projectile.damage, 3f, Projectile.owner, 16f, 8f); + Main.projectile[nextSegment].netUpdate = true; } } } diff --git a/Projectiles/Ranged/Voidragon.cs b/Projectiles/Ranged/Voidragon.cs index 8fbd68856a..9deeeba52c 100644 --- a/Projectiles/Ranged/Voidragon.cs +++ b/Projectiles/Ranged/Voidragon.cs @@ -41,40 +41,40 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localAI[0] = 0f; for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); - int num9 = Dust.NewDust(Projectile.Center, 0, 0, 173, 0f, 0f, 160, default, 1f); - Main.dust[num9].scale = 1.1f; - Main.dust[num9].noGravity = true; - Main.dust[num9].position = Projectile.Center + vector3; - Main.dust[num9].velocity = Projectile.velocity * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; + Vector2 dustVel = Vector2.UnitX * (float)-(float)Projectile.width / 2f; + dustVel += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); + dustVel = dustVel.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); + int shadowDust = Dust.NewDust(Projectile.Center, 0, 0, 173, 0f, 0f, 160, default, 1f); + Main.dust[shadowDust].scale = 1.1f; + Main.dust[shadowDust].noGravity = true; + Main.dust[shadowDust].position = Projectile.Center + dustVel; + Main.dust[shadowDust].velocity = Projectile.velocity * 0.1f; + Main.dust[shadowDust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[shadowDust].position) * 1.25f; } } Projectile.alpha -= 15; - int num58 = 150; + int alphaControl = 150; if (Projectile.Center.Y >= Projectile.ai[1]) { - num58 = 0; + alphaControl = 0; } - if (Projectile.alpha < num58) + if (Projectile.alpha < alphaControl) { - Projectile.alpha = num58; + Projectile.alpha = alphaControl; } Projectile.rotation = Projectile.velocity.ToRotation() - 1.57079637f; if (Main.rand.NextBool(16)) { Vector2 value3 = Vector2.UnitX.RotatedByRandom(1.5707963705062866).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num59 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1.2f); - Main.dust[num59].velocity = value3 * 0.66f; - Main.dust[num59].position = Projectile.Center + value3 * 12f; + int extraDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1.2f); + Main.dust[extraDust].velocity = value3 * 0.66f; + Main.dust[extraDust].position = Projectile.Center + value3 * 12f; } if (Main.rand.NextBool(48) && Main.netMode != NetmodeID.Server) { - int num60 = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), 16, 1f); - Main.gore[num60].velocity *= 0.66f; - Main.gore[num60].velocity += Projectile.velocity * 0.3f; + int voidGore = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), 16, 1f); + Main.gore[voidGore].velocity *= 0.66f; + Main.gore[voidGore].velocity += Projectile.velocity * 0.3f; } if (Projectile.ai[1] == 1f) { diff --git a/Projectiles/Ranged/WaterSpout.cs b/Projectiles/Ranged/WaterSpout.cs index 58de50fb19..64606cf8f3 100644 --- a/Projectiles/Ranged/WaterSpout.cs +++ b/Projectiles/Ranged/WaterSpout.cs @@ -31,11 +31,11 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { - int num613 = 10; - int num614 = 15; - float num615 = 1f; - int num616 = 150; - int num617 = 42; + int projScale1 = 10; + int projScale2 = 15; + float thirdProjScale = 1f; + int projWidthScale = 150; + int projHeightScale = 42; if (Projectile.velocity.X != 0f) { Projectile.direction = Projectile.spriteDirection = -Math.Sign(Projectile.velocity.X); @@ -55,18 +55,18 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localAI[0] = 1f; Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y + (float)(Projectile.height / 2); - Projectile.scale = ((float)(num613 + num614) - Projectile.ai[1]) * num615 / (float)(num614 + num613); - Projectile.width = (int)((float)num616 * Projectile.scale); - Projectile.height = (int)((float)num617 * Projectile.scale); + Projectile.scale = ((float)(projScale1 + projScale2) - Projectile.ai[1]) * thirdProjScale / (float)(projScale2 + projScale1); + Projectile.width = (int)((float)projWidthScale * Projectile.scale); + Projectile.height = (int)((float)projHeightScale * Projectile.scale); Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); Projectile.netUpdate = true; } if (Projectile.ai[1] != -1f) { - Projectile.scale = ((float)(num613 + num614) - Projectile.ai[1]) * num615 / (float)(num614 + num613); - Projectile.width = (int)((float)num616 * Projectile.scale); - Projectile.height = (int)((float)num617 * Projectile.scale); + Projectile.scale = ((float)(projScale1 + projScale2) - Projectile.ai[1]) * thirdProjScale / (float)(projScale2 + projScale1); + Projectile.width = (int)((float)projWidthScale * Projectile.scale); + Projectile.height = (int)((float)projHeightScale * Projectile.scale); } if (!Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) { @@ -92,30 +92,30 @@ namespace CalamityMod.Projectiles.Ranged { Projectile.netUpdate = true; Vector2 center = Projectile.Center; - center.Y -= (float)num617 * Projectile.scale / 2f; - float num618 = ((float)(num613 + num614) - Projectile.ai[1] + 1f) * num615 / (float)(num614 + num613); - center.Y -= (float)num617 * num618 / 2f; + center.Y -= (float)projHeightScale * Projectile.scale / 2f; + float projSpawn = ((float)(projScale1 + projScale2) - Projectile.ai[1] + 1f) * thirdProjScale / (float)(projScale2 + projScale1); + center.Y -= (float)projHeightScale * projSpawn / 2f; center.Y += 2f; Projectile.NewProjectile(Projectile.GetSource_FromThis(), center.X, center.Y, Projectile.velocity.X, Projectile.velocity.Y, Projectile.type, Projectile.damage, Projectile.knockBack, Projectile.owner, 10f, Projectile.ai[1] - 1f); } if (Projectile.ai[0] <= 0f) { - float num622 = 0.104719758f; - float num623 = (float)Projectile.width / 5f; - float num624 = (float)(Math.Cos((double)(num622 * -(double)Projectile.ai[0])) - 0.5) * num623; - Projectile.position.X = Projectile.position.X - num624 * (float)-(float)Projectile.direction; + float swaySize = 0.104719758f; + float smolWidth = (float)Projectile.width / 5f; + float projXChange = (float)(Math.Cos((double)(swaySize * -(double)Projectile.ai[0])) - 0.5) * smolWidth; + Projectile.position.X = Projectile.position.X - projXChange * (float)-(float)Projectile.direction; Projectile.ai[0] -= 1f; - num624 = (float)(Math.Cos((double)(num622 * -(double)Projectile.ai[0])) - 0.5) * num623; - Projectile.position.X = Projectile.position.X + num624 * (float)-(float)Projectile.direction; + projXChange = (float)(Math.Cos((double)(swaySize * -(double)Projectile.ai[0])) - 0.5) * smolWidth; + Projectile.position.X = Projectile.position.X + projXChange * (float)-(float)Projectile.direction; } } public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } } diff --git a/Projectiles/Rogue/AntumbraShardProjectile.cs b/Projectiles/Rogue/AntumbraShardProjectile.cs index ca9105c47e..e7230604a2 100644 --- a/Projectiles/Rogue/AntumbraShardProjectile.cs +++ b/Projectiles/Rogue/AntumbraShardProjectile.cs @@ -65,7 +65,8 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - Projectile.damage = (int)(Projectile.damage * 0.8f); + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.9f); if (Projectile.damage < 1) { Projectile.damage = 1; diff --git a/Projectiles/Rogue/BallisticPoisonBombSpike.cs b/Projectiles/Rogue/BallisticPoisonBombSpike.cs index 5b33a8d45d..cf4b7624e4 100644 --- a/Projectiles/Rogue/BallisticPoisonBombSpike.cs +++ b/Projectiles/Rogue/BallisticPoisonBombSpike.cs @@ -34,9 +34,9 @@ namespace CalamityMod.Projectiles.Rogue Projectile.localAI[1] += 1f; if (Projectile.localAI[1] > 4f) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 14, 0f, 0f, 100, default, 0.75f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int dustt = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 14, 0f, 0f, 100, default, 0.75f); + Main.dust[dustt].noGravity = true; + Main.dust[dustt].velocity *= 0f; } } @@ -56,23 +56,23 @@ namespace CalamityMod.Projectiles.Rogue Projectile.width = Projectile.height = 32; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 2; num621++) + for (int i = 0; i < 2; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 14, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); - Main.dust[num622].velocity *= 3f; + int smoke = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 14, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); + Main.dust[smoke].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[smoke].scale = 0.5f; + Main.dust[smoke].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 2; num623++) + for (int j = 0; j < 2; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); - Main.dust[num624].velocity *= 2f; + int fire = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); + Main.dust[fire].noGravity = true; + Main.dust[fire].velocity *= 5f; + fire = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); + Main.dust[fire].velocity *= 2f; } } } diff --git a/Projectiles/Rogue/BrackishSpear.cs b/Projectiles/Rogue/BrackishSpear.cs index 90d9d9b520..67c0fec4a6 100644 --- a/Projectiles/Rogue/BrackishSpear.cs +++ b/Projectiles/Rogue/BrackishSpear.cs @@ -90,7 +90,7 @@ namespace CalamityMod.Projectiles.Rogue } // Prevent recursion: the segments that are being spawned here will deliberately be set higher than total segments - if (Projectile.ai[0] > TotalSegments) + if (Projectile.ai[0] > TotalSegments || Main.myPlayer != Projectile.owner) return; // Spawn two ungrowing segments to either side on death diff --git a/Projectiles/Rogue/BrackishWaterBlast.cs b/Projectiles/Rogue/BrackishWaterBlast.cs index 036b32049c..7ffe7c14ff 100644 --- a/Projectiles/Rogue/BrackishWaterBlast.cs +++ b/Projectiles/Rogue/BrackishWaterBlast.cs @@ -37,60 +37,60 @@ namespace CalamityMod.Projectiles.Rogue SoundEngine.PlaySound(SoundID.Item21, Projectile.position); Projectile.localAI[0] += 1f; } - bool flag15 = false; - bool flag16 = false; + bool xflag = false; + bool yflag = false; if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) { - flag16 = true; + yflag = true; } if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) { - flag16 = true; + yflag = true; } - if (flag15 && flag16) + if (xflag && yflag) { Projectile.Kill(); } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - float num462 = 0f; - while (num462 < num461) + float timerCompare = 0f; + while (timerCompare < projTimer) { - float num463 = (float)Main.rand.Next(-10, 11); - float num464 = (float)Main.rand.Next(-10, 11); - float num465 = (float)Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDust, 0f, 0f, 100, default, 0.5f); - Dust dust = Main.dust[num467]; + float random1 = (float)Main.rand.Next(-10, 11); + float random2 = (float)Main.rand.Next(-10, 11); + float random3 = (float)Main.rand.Next(3, 9); + float randomAdjust = (float)Math.Sqrt((double)(random1 * random1 + random2 * random2)); + randomAdjust = random3 / randomAdjust; + random1 *= randomAdjust; + random2 *= randomAdjust; + int water = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDust, 0f, 0f, 100, default, 0.5f); + Dust dust = Main.dust[water]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = random1; + dust.velocity.Y = random2; + timerCompare++; } } diff --git a/Projectiles/Rogue/CircletMark.cs b/Projectiles/Rogue/CircletMark.cs index 534532edc5..8e5e9bbaa9 100644 --- a/Projectiles/Rogue/CircletMark.cs +++ b/Projectiles/Rogue/CircletMark.cs @@ -1,9 +1,9 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ModLoader; -using Terraria.ID; using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { @@ -37,34 +37,34 @@ namespace CalamityMod.Projectiles.Rogue } if (Projectile.localAI[1] < 30f) { - for (int num1134 = 0; num1134 < 1; num1134++) + for (int i = 0; i < 1; i++) { - float value79 = -0.5f; - float value80 = 0.9f; - float amount4 = Main.rand.NextFloat(); - Vector2 value81 = new Vector2(MathHelper.Lerp(0.1f, 1f, Main.rand.NextFloat()), MathHelper.Lerp(value79, value80, amount4)); - value81.X *= MathHelper.Lerp(2.2f, 0.6f, amount4); - value81.X *= -1f; - Vector2 value82 = new Vector2(2f, 10f); - Vector2 position4 = Projectile.Center + new Vector2(60f, 200f) * value81 * 0.5f + value82; - Dust dust34 = Main.dust[Dust.NewDust(position4, 0, 0, 269, 0f, 0f, 0, default, 0.5f)]; - dust34.position = position4; - dust34.customData = Projectile.Center + value82; - dust34.fadeIn = 1f; - dust34.scale = 0.3f; - if (value81.X > -1.2f) + float lerpvalue1 = -0.5f; + float lerpvalue2 = 0.9f; + float randomLerp = Main.rand.NextFloat(); + Vector2 dustMovement = new Vector2(MathHelper.Lerp(0.1f, 1f, Main.rand.NextFloat()), MathHelper.Lerp(lerpvalue1, lerpvalue2, randomLerp)); + dustMovement.X *= MathHelper.Lerp(2.2f, 0.6f, randomLerp); + dustMovement.X *= -1f; + Vector2 dustMovement2 = new Vector2(2f, 10f); + Vector2 position4 = Projectile.Center + new Vector2(60f, 200f) * dustMovement * 0.5f + dustMovement2; + Dust dust = Main.dust[Dust.NewDust(position4, 0, 0, 269, 0f, 0f, 0, default, 0.5f)]; + dust.position = position4; + dust.customData = Projectile.Center + dustMovement2; + dust.fadeIn = 1f; + dust.scale = 0.3f; + if (dustMovement.X > -1.2f) { - dust34.velocity.X = 1f + Main.rand.NextFloat(); + dust.velocity.X = 1f + Main.rand.NextFloat(); } - dust34.velocity.Y = Main.rand.NextFloat() * -0.5f - 1f; + dust.velocity.Y = Main.rand.NextFloat() * -0.5f - 1f; } } if (Projectile.localAI[0] == 0f) { Projectile.localAI[0] = 0.8f; Projectile.direction = 1; - Point point9 = Projectile.Center.ToTileCoordinates(); - Projectile.Center = new Vector2((float)(point9.X * 16 + 8), (float)(point9.Y * 16 + 8)); + Point projCenter = Projectile.Center.ToTileCoordinates(); + Projectile.Center = new Vector2((float)(projCenter.X * 16 + 8), (float)(projCenter.Y * 16 + 8)); } Projectile.rotation = Projectile.localAI[1] / 40f * 6.28318548f * (float)Projectile.direction; if (Projectile.localAI[1] < 33f) @@ -93,30 +93,30 @@ namespace CalamityMod.Projectiles.Rogue { Lighting.AddLight(Projectile.Center, newColor3.ToVector3() * 0.5f); } - for (int num1135 = 0; num1135 < 2; num1135++) + for (int j = 0; j < 2; j++) { if (Main.rand.NextBool(10)) { - Vector2 value83 = Vector2.UnitY.RotatedBy((double)((float)num1135 * 3.14159274f), default).RotatedBy((double)Projectile.rotation, default); - Dust dust35 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 269, 0f, 0f, 225, newColor3, 1f)]; - dust35.noGravity = true; - dust35.noLight = true; - dust35.scale = Projectile.Opacity * Projectile.localAI[0]; - dust35.position = Projectile.Center; - dust35.velocity = value83 * 2.5f; + Vector2 dustVel = Vector2.UnitY.RotatedBy((double)((float)j * 3.14159274f), default).RotatedBy((double)Projectile.rotation, default); + Dust dusty = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 269, 0f, 0f, 225, newColor3, 1f)]; + dusty.noGravity = true; + dusty.noLight = true; + dusty.scale = Projectile.Opacity * Projectile.localAI[0]; + dusty.position = Projectile.Center; + dusty.velocity = dustVel * 2.5f; } } - for (int num1136 = 0; num1136 < 2; num1136++) + for (int k = 0; k < 2; k++) { if (Main.rand.NextBool(10)) { - Vector2 value84 = Vector2.UnitY.RotatedBy((double)((float)num1136 * 3.14159274f), default); - Dust dust36 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 269, 0f, 0f, 225, newColor3, 1.5f)]; - dust36.noGravity = true; - dust36.noLight = true; - dust36.scale = Projectile.Opacity * Projectile.localAI[0]; - dust36.position = Projectile.Center; - dust36.velocity = value84 * 2.5f; + Vector2 dustVel2 = Vector2.UnitY.RotatedBy((double)((float)k * 3.14159274f), default); + Dust dustier = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 269, 0f, 0f, 225, newColor3, 1.5f)]; + dustier.noGravity = true; + dustier.noLight = true; + dustier.scale = Projectile.Opacity * Projectile.localAI[0]; + dustier.position = Projectile.Center; + dustier.velocity = dustVel2 * 2.5f; } } if (Projectile.localAI[1] < 33f || Projectile.localAI[1] > 87f) @@ -138,21 +138,21 @@ namespace CalamityMod.Projectiles.Rogue public override bool PreDraw(ref Color lightColor) { - Color color25 = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); + Color originalColor = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); SpriteEffects spriteEffects = SpriteEffects.None; if (Projectile.spriteDirection == -1) { spriteEffects = SpriteEffects.FlipHorizontally; } - Vector2 vector38 = Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; + Vector2 drawPos = Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; Texture2D texture2D27 = ModContent.Request(Texture).Value; - Rectangle rectangle11 = texture2D27.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); - Color alpha5 = Projectile.GetAlpha(color25); - Vector2 origin7 = rectangle11.Size() / 2f; - Color color47 = Main.hslToRgb(0.25f, 1f, 1f).MultiplyRGBA(new Color(255, 255, 255, 0)); - Main.spriteBatch.Draw(texture2D27, vector38, new Microsoft.Xna.Framework.Rectangle?(rectangle11), color47, 0f, origin7, new Vector2(1f, 5f) * Projectile.scale * 2f, spriteEffects, 0); - Main.spriteBatch.Draw(texture2D27, vector38, new Microsoft.Xna.Framework.Rectangle?(rectangle11), alpha5, Projectile.rotation, origin7, Projectile.scale, spriteEffects, 0); - Main.spriteBatch.Draw(texture2D27, vector38, new Microsoft.Xna.Framework.Rectangle?(rectangle11), alpha5, 0f, origin7, new Vector2(1f, 8f) * Projectile.scale, spriteEffects, 0); + Rectangle rectangle = texture2D27.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); + Color alphaColor = Projectile.GetAlpha(originalColor); + Vector2 origin7 = rectangle.Size() / 2f; + Color sandyColor = Main.hslToRgb(0.25f, 1f, 1f).MultiplyRGBA(new Color(255, 255, 255, 0)); + Main.spriteBatch.Draw(texture2D27, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangle), sandyColor, 0f, origin7, new Vector2(1f, 5f) * Projectile.scale * 2f, spriteEffects, 0); + Main.spriteBatch.Draw(texture2D27, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangle), alphaColor, Projectile.rotation, origin7, Projectile.scale, spriteEffects, 0); + Main.spriteBatch.Draw(texture2D27, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangle), alphaColor, 0f, origin7, new Vector2(1f, 8f) * Projectile.scale, spriteEffects, 0); return false; } } diff --git a/Projectiles/Rogue/CircletTornado.cs b/Projectiles/Rogue/CircletTornado.cs index 7eac411e9b..b094a596d1 100644 --- a/Projectiles/Rogue/CircletTornado.cs +++ b/Projectiles/Rogue/CircletTornado.cs @@ -1,9 +1,9 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ModLoader; -using Terraria.ID; using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { @@ -73,45 +73,43 @@ namespace CalamityMod.Projectiles.Rogue Projectile.damage = 0; if (Projectile.ai[0] < lifeSpan - 120f) { - float num1126 = Projectile.ai[0] % 60f; - Projectile.ai[0] = lifeSpan - 120f + num1126; + float aiDecrement = Projectile.ai[0] % 60f; + Projectile.ai[0] = lifeSpan - 120f + aiDecrement; Projectile.netUpdate = true; } } - float num1127 = 15f; - float num1128 = 15f; Point point8 = Projectile.Center.ToTileCoordinates(); - int num1129; - int num1130; - Collision.ExpandVertically(point8.X, point8.Y, out num1129, out num1130, (int)num1127, (int)num1128); - num1129++; - num1130--; - Vector2 value72 = new Vector2((float)point8.X, (float)num1129) * 16f + new Vector2(8f); - Vector2 value73 = new Vector2((float)point8.X, (float)num1130) * 16f + new Vector2(8f); - Vector2 vector146 = Vector2.Lerp(value72, value73, 0.5f); - Vector2 value74 = new Vector2(0f, value73.Y - value72.Y); - value74.X = value74.Y * 0.2f; - Projectile.width = (int)(value74.X * 0.65f); - Projectile.height = (int)value74.Y; - Projectile.Center = vector146; + int sizeMod; + int sizeMod2; + Collision.ExpandVertically(point8.X, point8.Y, out sizeMod, out sizeMod2, 15, 15); + sizeMod++; + sizeMod2--; + Vector2 sizeModVector = new Vector2((float)point8.X, (float)sizeMod) * 16f + new Vector2(8f); + Vector2 sizeModVector2 = new Vector2((float)point8.X, (float)sizeMod2) * 16f + new Vector2(8f); + Vector2 centering = Vector2.Lerp(sizeModVector, sizeModVector2, 0.5f); + Vector2 sizeModPos = new Vector2(0f, sizeModVector2.Y - sizeModVector.Y); + sizeModPos.X = sizeModPos.Y * 0.2f; + Projectile.width = (int)(sizeModPos.X * 0.65f); + Projectile.height = (int)sizeModPos.Y; + Projectile.Center = centering; if (Projectile.owner == Main.myPlayer) { - bool flag74 = false; - Vector2 center16 = Main.player[Projectile.owner].Center; + bool breakFlag = false; + Vector2 playerCenter = Main.player[Projectile.owner].Center; Vector2 top = Main.player[Projectile.owner].Top; - for (float num1131 = 0f; num1131 < 1f; num1131 += 0.05f) + for (float i = 0f; i < 1f; i += 0.05f) { - Vector2 position2 = Vector2.Lerp(value72, value73, num1131); - if (Collision.CanHitLine(position2, 0, 0, center16, 0, 0) || Collision.CanHitLine(position2, 0, 0, top, 0, 0)) + Vector2 position2 = Vector2.Lerp(sizeModVector, sizeModVector2, i); + if (Collision.CanHitLine(position2, 0, 0, playerCenter, 0, 0) || Collision.CanHitLine(position2, 0, 0, top, 0, 0)) { - flag74 = true; + breakFlag = true; break; } } - if (!flag74 && Projectile.ai[0] < lifeSpan - 120f) + if (!breakFlag && Projectile.ai[0] < lifeSpan - 120f) { - float num1132 = Projectile.ai[0] % 60f; - Projectile.ai[0] = lifeSpan - 120f + num1132; + float aiDecrement2 = Projectile.ai[0] % 60f; + Projectile.ai[0] = lifeSpan - 120f + aiDecrement2; Projectile.netUpdate = true; } } @@ -123,57 +121,54 @@ namespace CalamityMod.Projectiles.Rogue public override bool PreDraw(ref Color lightColor) { - float num226 = 600f; - float num227 = 15f; - float num228 = 15f; - float num229 = Projectile.ai[0]; - float scale5 = MathHelper.Clamp(num229 / 30f, 0f, 1f); - if (num229 > num226 - 60f) + float aiTracker = Projectile.ai[0]; + float trackerClamp = MathHelper.Clamp(aiTracker / 30f, 0f, 1f); + if (aiTracker > 540f) { - scale5 = MathHelper.Lerp(1f, 0f, (num229 - (num226 - 60f)) / 60f); + trackerClamp = MathHelper.Lerp(1f, 0f, (aiTracker - 540f) / 60f); } - Point point5 = Projectile.Center.ToTileCoordinates(); - int num230; - int num231; - Collision.ExpandVertically(point5.X, point5.Y, out num230, out num231, (int)num227, (int)num228); - num230++; - num231--; - float num232 = 0.2f; - Vector2 value32 = new Vector2((float)point5.X, (float)num230) * 16f + new Vector2(8f); - Vector2 value33 = new Vector2((float)point5.X, (float)num231) * 16f + new Vector2(8f); - Vector2.Lerp(value32, value33, 0.5f); - Vector2 vector33 = new Vector2(0f, value33.Y - value32.Y); - vector33.X = vector33.Y * num232; - new Vector2(value32.X - vector33.X / 2f, value32.Y); + Point centerPoint = Projectile.Center.ToTileCoordinates(); + int sizeModding; + int sizeModding2; + Collision.ExpandVertically(centerPoint.X, centerPoint.Y, out sizeModding, out sizeModding2, 15, 15); + sizeModding++; + sizeModding2--; + float vectorMult = 0.2f; + Vector2 sizeModdingVector = new Vector2((float)centerPoint.X, (float)sizeModding) * 16f + new Vector2(8f); + Vector2 sizeModdingVector2 = new Vector2((float)centerPoint.X, (float)sizeModding2) * 16f + new Vector2(8f); + Vector2.Lerp(sizeModdingVector, sizeModdingVector2, 0.5f); + Vector2 sizeModdingPos = new Vector2(0f, sizeModdingVector2.Y - sizeModdingVector.Y); + sizeModdingPos.X = sizeModdingPos.Y * vectorMult; + new Vector2(sizeModdingVector.X - sizeModdingPos.X / 2f, sizeModdingVector.Y); Texture2D texture2D23 = ModContent.Request(Texture).Value; - Rectangle rectangle9 = texture2D23.Frame(1, 1, 0, 0); - Vector2 origin3 = rectangle9.Size() / 2f; - float num233 = -0.06283186f * num229; - Vector2 spinningpoint2 = Vector2.UnitY.RotatedBy((double)(num229 * 0.1f), default); - float num234 = 0f; - float num235 = 5.1f; - Color value34 = new Color(225, 225, 100); - for (float num236 = (float)(int)value33.Y; num236 > (float)(int)value32.Y; num236 -= num235) + Rectangle drawRectangle = texture2D23.Frame(1, 1, 0, 0); + Vector2 smallRect = drawRectangle.Size() / 2f; + float aiTrackMult = -0.06283186f * aiTracker; + Vector2 spinningpoint = Vector2.UnitY.RotatedBy((double)(aiTracker * 0.1f), default); + float incrementStorage = 0f; + float increment = 5.1f; + Color sandYellow = new Color(225, 225, 100); + for (float k = (float)(int)sizeModdingVector2.Y; k > (float)(int)sizeModdingVector.Y; k -= increment) { - num234 += num235; - float num237 = num234 / vector33.Y; - float num238 = num234 * 6.28318548f / -20f; - float num239 = num237 - 0.15f; - Vector2 vector34 = spinningpoint2.RotatedBy((double)num238, default); - Vector2 value35 = new Vector2(0f, num237 + 1f); - value35.X = value35.Y * num232; - Color color39 = Microsoft.Xna.Framework.Color.Lerp(Microsoft.Xna.Framework.Color.Transparent, value34, num237 * 2f); - if (num237 > 0.5f) + incrementStorage += increment; + float colorChanger = incrementStorage / sizeModdingPos.Y; + float incStorageMult = incrementStorage * 6.28318548f / -20f; + float lowerColorChanger = colorChanger - 0.15f; + Vector2 spinArea = spinningpoint.RotatedBy((double)incStorageMult, default); + Vector2 colorChangeVector = new Vector2(0f, colorChanger + 1f); + colorChangeVector.X = colorChangeVector.Y * vectorMult; + Color newSandYellow = Microsoft.Xna.Framework.Color.Lerp(Microsoft.Xna.Framework.Color.Transparent, sandYellow, colorChanger * 2f); + if (colorChanger > 0.5f) { - color39 = Microsoft.Xna.Framework.Color.Lerp(Microsoft.Xna.Framework.Color.Transparent, value34, 2f - num237 * 2f); + newSandYellow = Microsoft.Xna.Framework.Color.Lerp(Microsoft.Xna.Framework.Color.Transparent, sandYellow, 2f - colorChanger * 2f); } - color39.A = (byte)((float)color39.A * 0.5f); - color39 *= scale5; - vector34 *= value35 * 100f; - vector34.Y = 0f; - vector34.X = 0f; - vector34 += new Vector2(value33.X, num236) - Main.screenPosition; - Main.spriteBatch.Draw(texture2D23, vector34, new Microsoft.Xna.Framework.Rectangle?(rectangle9), color39, num233 + num238, origin3, 1f + num239, SpriteEffects.None, 0); + newSandYellow.A = (byte)((float)newSandYellow.A * 0.5f); + newSandYellow *= trackerClamp; + spinArea *= colorChangeVector * 100f; + spinArea.Y = 0f; + spinArea.X = 0f; + spinArea += new Vector2(sizeModdingVector2.X, k) - Main.screenPosition; + Main.spriteBatch.Draw(texture2D23, spinArea, new Microsoft.Xna.Framework.Rectangle?(drawRectangle), newSandYellow, aiTrackMult + incStorageMult, smallRect, 1f + lowerColorChanger, SpriteEffects.None, 0); } return false; } diff --git a/Projectiles/Rogue/CraniumSMASH.cs b/Projectiles/Rogue/CraniumSMASH.cs index f6c9f383e0..da28ef4f0f 100644 --- a/Projectiles/Rogue/CraniumSMASH.cs +++ b/Projectiles/Rogue/CraniumSMASH.cs @@ -81,11 +81,11 @@ namespace CalamityMod.Projectiles.Rogue } } - for (int num194 = 0; num194 < 25; num194++) + for (int i = 0; i < 25; i++) { - int num195 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100, default, 2f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 0f; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0f; } } } diff --git a/Projectiles/Rogue/CraniumSmasherExplosive.cs b/Projectiles/Rogue/CraniumSmasherExplosive.cs index 5b94edae9a..674eda9595 100644 --- a/Projectiles/Rogue/CraniumSmasherExplosive.cs +++ b/Projectiles/Rogue/CraniumSmasherExplosive.cs @@ -91,11 +91,11 @@ namespace CalamityMod.Projectiles.Rogue } } - for (int num194 = 0; num194 < 25; num194++) + for (int i = 0; i < 25; i++) { - int num195 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100, default, 2f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 0f; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0f; } } } diff --git a/Projectiles/Rogue/CraniumSmasherStealth.cs b/Projectiles/Rogue/CraniumSmasherStealth.cs index de8bc689b0..1eedabc6b5 100644 --- a/Projectiles/Rogue/CraniumSmasherStealth.cs +++ b/Projectiles/Rogue/CraniumSmasherStealth.cs @@ -113,11 +113,11 @@ namespace CalamityMod.Projectiles.Rogue } } - for (int num194 = 0; num194 < 25; num194++) + for (int i = 0; i < 25; i++) { - int num195 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100, default, 2f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 0f; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0f; } } diff --git a/Projectiles/Rogue/CursedDaggerProj.cs b/Projectiles/Rogue/CursedDaggerProj.cs index 9b2e6d5121..7c03608f65 100644 --- a/Projectiles/Rogue/CursedDaggerProj.cs +++ b/Projectiles/Rogue/CursedDaggerProj.cs @@ -81,7 +81,8 @@ namespace CalamityMod.Projectiles.Rogue public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - Projectile.damage = (int)(Projectile.damage * 0.8f); + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.8f); if (Projectile.damage < 1) Projectile.damage = 1; } diff --git a/Projectiles/Rogue/DeepSeaDumbbell1.cs b/Projectiles/Rogue/DeepSeaDumbbell1.cs index 31fb423a65..d90453c278 100644 --- a/Projectiles/Rogue/DeepSeaDumbbell1.cs +++ b/Projectiles/Rogue/DeepSeaDumbbell1.cs @@ -42,26 +42,26 @@ namespace CalamityMod.Projectiles.Rogue Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, Projectile.velocity.X, Projectile.velocity.Y, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.75), Projectile.knockBack * 0.75f, Main.myPlayer, 0f, 0f); - float num628 = (float)Main.rand.Next(-35, 36) * 0.01f; - float num629 = (float)Main.rand.Next(-35, 36) * 0.01f; - int num3; - for (int num627 = 0; num627 < 2; num627 = num3 + 1) + float randVel = (float)Main.rand.Next(-35, 36) * 0.01f; + float randVel2 = (float)Main.rand.Next(-35, 36) * 0.01f; + int inc; + for (int i = 0; i < 2; i = inc + 1) { - if (num627 == 1) + if (i == 1) { - num628 *= 10f; - num629 *= 10f; + randVel *= 10f; + randVel2 *= 10f; } else { - num628 *= -10f; - num629 *= -10f; + randVel *= -10f; + randVel2 *= -10f; } - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, num628, num629, ModContent.ProjectileType(), + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, randVel, randVel2, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.25), Projectile.knockBack * 0.25f, Main.myPlayer, 0f, 0f); - num3 = num627; + inc = i; } } @@ -84,26 +84,26 @@ namespace CalamityMod.Projectiles.Rogue Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, Projectile.velocity.X, Projectile.velocity.Y, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.75), Projectile.knockBack * 0.75f, Main.myPlayer, 0f, 0f); - float num628 = (float)Main.rand.Next(-35, 36) * 0.01f; - float num629 = (float)Main.rand.Next(-35, 36) * 0.01f; - int num3; - for (int num627 = 0; num627 < 2; num627 = num3 + 1) + float randVel = (float)Main.rand.Next(-35, 36) * 0.01f; + float randVel2 = (float)Main.rand.Next(-35, 36) * 0.01f; + int inc; + for (int i = 0; i < 2; i = inc + 1) { - if (num627 == 1) + if (i == 1) { - num628 *= 10f; - num629 *= 10f; + randVel *= 10f; + randVel2 *= 10f; } else { - num628 *= -10f; - num629 *= -10f; + randVel *= -10f; + randVel2 *= -10f; } - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, num628, num629, ModContent.ProjectileType(), + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, randVel, randVel2, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.25), Projectile.knockBack * 0.25f, Main.myPlayer, 0f, 0f); - num3 = num627; + inc = i; } } @@ -124,26 +124,26 @@ namespace CalamityMod.Projectiles.Rogue Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, Projectile.velocity.X, Projectile.velocity.Y, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.75), Projectile.knockBack * 0.75f, Main.myPlayer, 0f, 0f); - float num628 = (float)Main.rand.Next(-35, 36) * 0.01f; - float num629 = (float)Main.rand.Next(-35, 36) * 0.01f; - int num3; - for (int num627 = 0; num627 < 2; num627 = num3 + 1) + float randVel = (float)Main.rand.Next(-35, 36) * 0.01f; + float randVel2 = (float)Main.rand.Next(-35, 36) * 0.01f; + int inc; + for (int i = 0; i < 2; i = inc + 1) { - if (num627 == 1) + if (i == 1) { - num628 *= 10f; - num629 *= 10f; + randVel *= 10f; + randVel2 *= 10f; } else { - num628 *= -10f; - num629 *= -10f; + randVel *= -10f; + randVel2 *= -10f; } - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, num628, num629, ModContent.ProjectileType(), + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, randVel, randVel2, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.25), Projectile.knockBack * 0.25f, Main.myPlayer, 0f, 0f); - num3 = num627; + inc = i; } } diff --git a/Projectiles/Rogue/DeepSeaDumbbell2.cs b/Projectiles/Rogue/DeepSeaDumbbell2.cs index c554f2f5b7..9922b73806 100644 --- a/Projectiles/Rogue/DeepSeaDumbbell2.cs +++ b/Projectiles/Rogue/DeepSeaDumbbell2.cs @@ -49,26 +49,26 @@ namespace CalamityMod.Projectiles.Rogue Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, Projectile.velocity.X, Projectile.velocity.Y, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.75), Projectile.knockBack * 0.75f, Main.myPlayer, 0f, 0f); - float num628 = (float)Main.rand.Next(-35, 36) * 0.01f; - float num629 = (float)Main.rand.Next(-35, 36) * 0.01f; - int num3; - for (int num627 = 0; num627 < 2; num627 = num3 + 1) + float randVel = (float)Main.rand.Next(-35, 36) * 0.01f; + float randVel2 = (float)Main.rand.Next(-35, 36) * 0.01f; + int inc; + for (int i = 0; i < 2; i = inc + 1) { - if (num627 == 1) + if (i == 1) { - num628 *= 10f; - num629 *= 10f; + randVel *= 10f; + randVel2 *= 10f; } else { - num628 *= -10f; - num629 *= -10f; + randVel *= -10f; + randVel2 *= -10f; } - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, num628, num629, ModContent.ProjectileType(), + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, randVel, randVel2, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.25), Projectile.knockBack * 0.25f, Main.myPlayer, 0f, 0f); - num3 = num627; + inc = i; } } @@ -91,26 +91,26 @@ namespace CalamityMod.Projectiles.Rogue Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, Projectile.velocity.X, Projectile.velocity.Y, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.75), Projectile.knockBack * 0.75f, Main.myPlayer, 0f, 0f); - float num628 = (float)Main.rand.Next(-35, 36) * 0.01f; - float num629 = (float)Main.rand.Next(-35, 36) * 0.01f; - int num3; - for (int num627 = 0; num627 < 2; num627 = num3 + 1) + float randVel = (float)Main.rand.Next(-35, 36) * 0.01f; + float randVel2 = (float)Main.rand.Next(-35, 36) * 0.01f; + int inc; + for (int i = 0; i < 2; i = inc + 1) { - if (num627 == 1) + if (i == 1) { - num628 *= 10f; - num629 *= 10f; + randVel *= 10f; + randVel2 *= 10f; } else { - num628 *= -10f; - num629 *= -10f; + randVel *= -10f; + randVel2 *= -10f; } - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, num628, num629, ModContent.ProjectileType(), + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, randVel, randVel2, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.25), Projectile.knockBack * 0.25f, Main.myPlayer, 0f, 0f); - num3 = num627; + inc = i; } } @@ -131,26 +131,26 @@ namespace CalamityMod.Projectiles.Rogue Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, Projectile.velocity.X, Projectile.velocity.Y, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.75), Projectile.knockBack * 0.75f, Main.myPlayer, 0f, 0f); - float num628 = (float)Main.rand.Next(-35, 36) * 0.01f; - float num629 = (float)Main.rand.Next(-35, 36) * 0.01f; - int num3; - for (int num627 = 0; num627 < 2; num627 = num3 + 1) + float randVel = (float)Main.rand.Next(-35, 36) * 0.01f; + float randVel2 = (float)Main.rand.Next(-35, 36) * 0.01f; + int inc; + for (int i = 0; i < 2; i = inc + 1) { - if (num627 == 1) + if (i == 1) { - num628 *= 10f; - num629 *= 10f; + randVel *= 10f; + randVel2 *= 10f; } else { - num628 *= -10f; - num629 *= -10f; + randVel *= -10f; + randVel2 *= -10f; } - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, num628, num629, ModContent.ProjectileType(), + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, randVel, randVel2, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.25), Projectile.knockBack * 0.25f, Main.myPlayer, 0f, 0f); - num3 = num627; + inc = i; } } diff --git a/Projectiles/Rogue/DeepSeaDumbbell3.cs b/Projectiles/Rogue/DeepSeaDumbbell3.cs index 407fdb2b9f..35e4a9e04f 100644 --- a/Projectiles/Rogue/DeepSeaDumbbell3.cs +++ b/Projectiles/Rogue/DeepSeaDumbbell3.cs @@ -41,26 +41,26 @@ namespace CalamityMod.Projectiles.Rogue if (Projectile.owner == Main.myPlayer) { - float num628 = (float)Main.rand.Next(-35, 36) * 0.01f; - float num629 = (float)Main.rand.Next(-35, 36) * 0.01f; - int num3; - for (int num627 = 0; num627 < 2; num627 = num3 + 1) + float randVel = (float)Main.rand.Next(-35, 36) * 0.01f; + float randVel2 = (float)Main.rand.Next(-35, 36) * 0.01f; + int inc; + for (int i = 0; i < 2; i = inc + 1) { - if (num627 == 1) + if (i == 1) { - num628 *= 10f; - num629 *= 10f; + randVel *= 10f; + randVel2 *= 10f; } else { - num628 *= -10f; - num629 *= -10f; + randVel *= -10f; + randVel2 *= -10f; } - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, num628, num629, ModContent.ProjectileType(), + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, randVel, randVel2, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.25), Projectile.knockBack * 0.25f, Main.myPlayer, 0f, 0f); - num3 = num627; + inc = i; } } @@ -77,26 +77,26 @@ namespace CalamityMod.Projectiles.Rogue if (Projectile.owner == Main.myPlayer) { - float num628 = (float)Main.rand.Next(-35, 36) * 0.01f; - float num629 = (float)Main.rand.Next(-35, 36) * 0.01f; - int num3; - for (int num627 = 0; num627 < 2; num627 = num3 + 1) + float randVel = (float)Main.rand.Next(-35, 36) * 0.01f; + float randVel2 = (float)Main.rand.Next(-35, 36) * 0.01f; + int inc; + for (int i = 0; i < 2; i = inc + 1) { - if (num627 == 1) + if (i == 1) { - num628 *= 10f; - num629 *= 10f; + randVel *= 10f; + randVel2 *= 10f; } else { - num628 *= -10f; - num629 *= -10f; + randVel *= -10f; + randVel2 *= -10f; } - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, num628, num629, ModContent.ProjectileType(), + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, randVel, randVel2, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.25), Projectile.knockBack * 0.25f, Main.myPlayer, 0f, 0f); - num3 = num627; + inc = i; } } @@ -111,26 +111,26 @@ namespace CalamityMod.Projectiles.Rogue if (Projectile.owner == Main.myPlayer) { - float num628 = (float)Main.rand.Next(-35, 36) * 0.01f; - float num629 = (float)Main.rand.Next(-35, 36) * 0.01f; - int num3; - for (int num627 = 0; num627 < 2; num627 = num3 + 1) + float randVel = (float)Main.rand.Next(-35, 36) * 0.01f; + float randVel2 = (float)Main.rand.Next(-35, 36) * 0.01f; + int inc; + for (int i = 0; i < 2; i = inc + 1) { - if (num627 == 1) + if (i == 1) { - num628 *= 10f; - num629 *= 10f; + randVel *= 10f; + randVel2 *= 10f; } else { - num628 *= -10f; - num629 *= -10f; + randVel *= -10f; + randVel2 *= -10f; } - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, num628, num629, ModContent.ProjectileType(), + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, randVel, randVel2, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.25), Projectile.knockBack * 0.25f, Main.myPlayer, 0f, 0f); - num3 = num627; + inc = i; } } diff --git a/Projectiles/Rogue/DeepSeaDumbbellWeight.cs b/Projectiles/Rogue/DeepSeaDumbbellWeight.cs index 77d97c492f..3e872c44db 100644 --- a/Projectiles/Rogue/DeepSeaDumbbellWeight.cs +++ b/Projectiles/Rogue/DeepSeaDumbbellWeight.cs @@ -41,15 +41,15 @@ namespace CalamityMod.Projectiles.Rogue Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int constant = 36; + for (int i = 0; i < constant; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.25f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 33, vector7.X, vector7.Y, 100, default, 1f); - Main.dust[num228].noGravity = true; - Main.dust[num228].velocity = vector7; + Vector2 weightVel = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.25f; + weightVel = weightVel.RotatedBy((double)((float)(i - (constant / 2 - 1)) * 6.28318548f / (float)constant), default) + Projectile.Center; + Vector2 dustVel = weightVel - Projectile.Center; + int dusty = Dust.NewDust(weightVel + dustVel, 0, 0, 33, dustVel.X, dustVel.Y, 100, default, 1f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].velocity = dustVel; } Projectile.Damage(); diff --git a/Projectiles/Rogue/DesecratedBubble.cs b/Projectiles/Rogue/DesecratedBubble.cs index c6c4d82789..aebcc9749a 100644 --- a/Projectiles/Rogue/DesecratedBubble.cs +++ b/Projectiles/Rogue/DesecratedBubble.cs @@ -51,13 +51,13 @@ namespace CalamityMod.Projectiles.Rogue public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item54, Projectile.position); - int num190 = Main.rand.Next(5, 9); - for (int num191 = 0; num191 < num190; num191++) + int rando = Main.rand.Next(5, 9); + for (int i = 0; i < rando; i++) { - int num192 = Dust.NewDust(Projectile.Center, 0, 0, 179, 0f, 0f, 100, default, 1.4f); - Main.dust[num192].velocity *= 0.8f; - Main.dust[num192].position = Vector2.Lerp(Main.dust[num192].position, Projectile.Center, 0.5f); - Main.dust[num192].noGravity = true; + int dust = Dust.NewDust(Projectile.Center, 0, 0, 179, 0f, 0f, 100, default, 1.4f); + Main.dust[dust].velocity *= 0.8f; + Main.dust[dust].position = Vector2.Lerp(Main.dust[dust].position, Projectile.Center, 0.5f); + Main.dust[dust].noGravity = true; } } diff --git a/Projectiles/Rogue/DesecratedWaterProj.cs b/Projectiles/Rogue/DesecratedWaterProj.cs index c887049e40..31449c64a8 100644 --- a/Projectiles/Rogue/DesecratedWaterProj.cs +++ b/Projectiles/Rogue/DesecratedWaterProj.cs @@ -40,15 +40,15 @@ namespace CalamityMod.Projectiles.Rogue Dust dust2 = Main.dust[index3]; dust2.velocity = dust2.velocity * 3f; } - int num220 = (Projectile.Calamity().stealthStrike ? 12 : 5); + int numProj = (Projectile.Calamity().stealthStrike ? 12 : 5); if (Projectile.owner == Main.myPlayer) { - for (int num221 = 0; num221 < num220; num221++) + for (int j = 0; j < numProj; j++) { - Vector2 value17 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - value17.Normalize(); - value17 *= (float)Main.rand.Next(10, 201) * 0.01f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, value17.X, value17.Y, ModContent.ProjectileType(), (int)(Projectile.damage * 0.6), Projectile.knockBack * 0.6f, Projectile.owner, (Projectile.Calamity().stealthStrike ? 1f : 0f), 1f); + Vector2 bubbleVel = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + bubbleVel.Normalize(); + bubbleVel *= (float)Main.rand.Next(10, 201) * 0.01f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, bubbleVel.X, bubbleVel.Y, ModContent.ProjectileType(), (int)(Projectile.damage * 0.6), Projectile.knockBack * 0.6f, Projectile.owner, (Projectile.Calamity().stealthStrike ? 1f : 0f), 1f); } } } diff --git a/Projectiles/Rogue/DestructionBolt.cs b/Projectiles/Rogue/DestructionBolt.cs index 166756383c..d7dad8bd93 100644 --- a/Projectiles/Rogue/DestructionBolt.cs +++ b/Projectiles/Rogue/DestructionBolt.cs @@ -1,9 +1,10 @@ using System; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; + namespace CalamityMod.Projectiles.Rogue { public class DestructionBolt : ModProjectile, ILocalizedModType @@ -41,11 +42,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver2; - float num29 = 5f; - float num30 = 300f; + float constant = 5f; float scaleFactor = 6f; - Vector2 value7 = new Vector2(10f, 20f); - int num32 = 3 * Projectile.MaxUpdates; if (Projectile.ai[1] == 0f) { Projectile.ai[1] = 1f; @@ -55,39 +53,39 @@ namespace CalamityMod.Projectiles.Rogue { if (Projectile.alpha < 128) { - int num35 = -1; - float num36 = num30; - for (int num37 = 0; num37 < Main.maxNPCs; num37++) + int index = -1; + float otherConstant = 300f; + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num37].active && Main.npc[num37].CanBeChasedBy(Projectile, false)) + if (Main.npc[i].active && Main.npc[i].CanBeChasedBy(Projectile, false)) { - Vector2 center3 = Main.npc[num37].Center; - float num38 = Vector2.Distance(center3, Projectile.Center); - if (num38 < num36 && num35 == -1 && Collision.CanHitLine(Projectile.Center, 1, 1, center3, 1, 1)) + Vector2 npcCenter = Main.npc[i].Center; + float targetDist = Vector2.Distance(npcCenter, Projectile.Center); + if (targetDist < otherConstant && index == -1 && Collision.CanHitLine(Projectile.Center, 1, 1, npcCenter, 1, 1)) { - num36 = num38; - num35 = num37; + otherConstant = targetDist; + index = i; } } } - if (num36 < 4f) + if (otherConstant < 4f) { Projectile.Kill(); return; } - if (num35 != -1) + if (index != -1) { - Projectile.ai[1] = num29 + 1f; - Projectile.ai[0] = (float)num35; + Projectile.ai[1] = constant + 1f; + Projectile.ai[0] = (float)index; Projectile.netUpdate = true; } } } - else if (Projectile.ai[1] > num29) + else if (Projectile.ai[1] > constant) { Projectile.ai[1] += 1f; - int num39 = (int)Projectile.ai[0]; - if (!Main.npc[num39].active || !Main.npc[num39].CanBeChasedBy(Projectile, false)) + int otherIndex = (int)Projectile.ai[0]; + if (!Main.npc[otherIndex].active || !Main.npc[otherIndex].CanBeChasedBy(Projectile, false)) { Projectile.ai[1] = 1f; Projectile.ai[0] = 0f; @@ -96,25 +94,24 @@ namespace CalamityMod.Projectiles.Rogue else { Projectile.velocity.ToRotation(); - Vector2 vector6 = Main.npc[num39].Center - Projectile.Center; - if (vector6.Length() < 10f) + Vector2 enemyCenterDist = Main.npc[otherIndex].Center - Projectile.Center; + if (enemyCenterDist.Length() < 10f) { Projectile.Kill(); return; } - if (vector6 != Vector2.Zero) + if (enemyCenterDist != Vector2.Zero) { - vector6.Normalize(); - vector6 *= scaleFactor; + enemyCenterDist.Normalize(); + enemyCenterDist *= scaleFactor; } - float num40 = 30f; - Projectile.velocity = (Projectile.velocity * (num40 - 1f) + vector6) / num40; + Projectile.velocity = (Projectile.velocity * 29f + enemyCenterDist) / 30f; } } - if (Projectile.ai[1] >= 1f && Projectile.ai[1] < num29) + if (Projectile.ai[1] >= 1f && Projectile.ai[1] < constant) { Projectile.ai[1] += 1f; - if (Projectile.ai[1] == num29) + if (Projectile.ai[1] == constant) { Projectile.ai[1] = 1f; } @@ -149,23 +146,23 @@ namespace CalamityMod.Projectiles.Rogue Projectile.localNPCHitCooldown = 10; Projectile.Damage(); SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - for (int num621 = 0; num621 < 20; num621++) + for (int j = 0; j < 20; j++) { - int num622 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 45; num623++) + for (int k = 0; k < 45; k++) { - int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dusty = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 3f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].velocity *= 5f; + dusty = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); + Main.dust[dusty].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) diff --git a/Projectiles/Rogue/DragonScalesInfernado.cs b/Projectiles/Rogue/DragonScalesInfernado.cs index 4a85b19d33..4c81ac6148 100644 --- a/Projectiles/Rogue/DragonScalesInfernado.cs +++ b/Projectiles/Rogue/DragonScalesInfernado.cs @@ -100,8 +100,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.netUpdate = true; Vector2 center = Projectile.Center; center.Y -= baseHeight * Projectile.scale / 2f; - float num618 = (scaleBase - Projectile.ai[1] + 1f) * scaleMult / scaleBase; - center.Y -= baseHeight * num618 / 2f; + float baseChanger = (scaleBase - Projectile.ai[1] + 1f) * scaleMult / scaleBase; + center.Y -= baseHeight * baseChanger / 2f; center.Y += 2f; Projectile segment = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), center, Projectile.velocity, Projectile.type, Projectile.damage, Projectile.knockBack, Projectile.owner, 10f, Projectile.ai[1] - 1f); @@ -116,14 +116,14 @@ namespace CalamityMod.Projectiles.Rogue } if (Projectile.ai[0] <= 0f) { - float num622 = 0.104719758f; - float num623 = (float)Projectile.width / 5f; - num623 *= 2f; - float num624 = (float)(Math.Cos((double)(num622 * -(double)Projectile.ai[0])) - 0.5) * num623; - Projectile.position.X -= num624 * -Projectile.direction; + float constant = 0.104719758f; + float smallWidth = (float)Projectile.width / 5f; + smallWidth *= 2f; + float xFluctuation = (float)(Math.Cos((double)(constant * -(double)Projectile.ai[0])) - 0.5) * smallWidth; + Projectile.position.X -= xFluctuation * -Projectile.direction; Projectile.ai[0] -= 1f; - num624 = (float)(Math.Cos((double)(num622 * -(double)Projectile.ai[0])) - 0.5) * num623; - Projectile.position.X += num624 * -Projectile.direction; + xFluctuation = (float)(Math.Cos((double)(constant * -(double)Projectile.ai[0])) - 0.5) * smallWidth; + Projectile.position.X += xFluctuation * -Projectile.direction; return; } } @@ -145,9 +145,9 @@ namespace CalamityMod.Projectiles.Rogue public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int frameDraw = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = frameDraw * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, frameDraw)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)frameDraw / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } } diff --git a/Projectiles/Rogue/DragonShit.cs b/Projectiles/Rogue/DragonShit.cs index 6e91ce2090..9b19fe325c 100644 --- a/Projectiles/Rogue/DragonShit.cs +++ b/Projectiles/Rogue/DragonShit.cs @@ -28,11 +28,11 @@ namespace CalamityMod.Projectiles.Rogue Projectile.ignoreWater = true; Projectile.tileCollide = false; Projectile.penetrate = 1; - Projectile.timeLeft = 300; + Projectile.timeLeft = 450; Projectile.DamageType = RogueDamageClass.Instance; } - public override bool? CanHitNPC(NPC target) => Projectile.timeLeft < 380 && target.CanBeChasedBy(Projectile); + public override bool? CanHitNPC(NPC target) => Projectile.timeLeft < 420 && target.CanBeChasedBy(Projectile); public override void AI() { @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Rogue if (Projectile.frame >= Main.projFrames[Projectile.type]) Projectile.frame = 0; - if (Projectile.timeLeft >= 380) + if (Projectile.timeLeft >= 420) { Projectile.velocity *= 1.07f; } diff --git a/Projectiles/Rogue/DukesDecapitatorBubble.cs b/Projectiles/Rogue/DukesDecapitatorBubble.cs index e1c9ff5617..936f2a1067 100644 --- a/Projectiles/Rogue/DukesDecapitatorBubble.cs +++ b/Projectiles/Rogue/DukesDecapitatorBubble.cs @@ -66,13 +66,13 @@ namespace CalamityMod.Projectiles.Rogue public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item54, Projectile.position); - int num190 = Main.rand.Next(5, 9); - for (int num191 = 0; num191 < num190; num191++) + int rando = Main.rand.Next(5, 9); + for (int i = 0; i < rando; i++) { - int num192 = Dust.NewDust(Projectile.Center, 0, 0, 206, 0f, 0f, 100, default, 1.4f); - Main.dust[num192].velocity *= 0.8f; - Main.dust[num192].position = Vector2.Lerp(Main.dust[num192].position, Projectile.Center, 0.5f); - Main.dust[num192].noGravity = true; + int dust = Dust.NewDust(Projectile.Center, 0, 0, 206, 0f, 0f, 100, default, 1.4f); + Main.dust[dust].velocity *= 0.8f; + Main.dust[dust].position = Vector2.Lerp(Main.dust[dust].position, Projectile.Center, 0.5f); + Main.dust[dust].noGravity = true; } } } diff --git a/Projectiles/Rogue/EGloveSpark.cs b/Projectiles/Rogue/EGloveSpark.cs index a34b4fe176..6ab6183572 100644 --- a/Projectiles/Rogue/EGloveSpark.cs +++ b/Projectiles/Rogue/EGloveSpark.cs @@ -50,25 +50,25 @@ namespace CalamityMod.Projectiles.Rogue Projectile.velocity.Y = Projectile.velocity.Y + 0.2f; } Projectile.rotation += Projectile.velocity.X * 0.1f; - int num199 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 206, 0f, 0f, 100, new Color(Main.rand.Next(20, 100), 204, 250), 1f); - Dust expr_8976_cp_0 = Main.dust[num199]; + int sparky = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 206, 0f, 0f, 100, new Color(Main.rand.Next(20, 100), 204, 250), 1f); + Dust expr_8976_cp_0 = Main.dust[sparky]; expr_8976_cp_0.position.X -= 2f; - Dust expr_8994_cp_0 = Main.dust[num199]; + Dust expr_8994_cp_0 = Main.dust[sparky]; expr_8994_cp_0.position.Y += 2f; - Main.dust[num199].scale += (float)Main.rand.Next(50) * 0.01f; - Main.dust[num199].noGravity = true; - Dust expr_89E7_cp_0 = Main.dust[num199]; + Main.dust[sparky].scale += (float)Main.rand.Next(50) * 0.01f; + Main.dust[sparky].noGravity = true; + Dust expr_89E7_cp_0 = Main.dust[sparky]; expr_89E7_cp_0.velocity.Y -= 2f; if (Main.rand.NextBool()) { - int num200 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 206, 0f, 0f, 100, new Color(Main.rand.Next(20, 100), 204, 250), 1f); - Dust expr_8A4E_cp_0 = Main.dust[num200]; + int sparky2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 206, 0f, 0f, 100, new Color(Main.rand.Next(20, 100), 204, 250), 1f); + Dust expr_8A4E_cp_0 = Main.dust[sparky2]; expr_8A4E_cp_0.position.X -= 2f; - Dust expr_8A6C_cp_0 = Main.dust[num200]; + Dust expr_8A6C_cp_0 = Main.dust[sparky2]; expr_8A6C_cp_0.position.Y += 2f; - Main.dust[num200].scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; - Main.dust[num200].noGravity = true; - Main.dust[num200].velocity *= 0.1f; + Main.dust[sparky2].scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; + Main.dust[sparky2].noGravity = true; + Main.dust[sparky2].velocity *= 0.1f; } if ((double)Projectile.velocity.Y < 0.25 && (double)Projectile.velocity.Y > 0.15) { diff --git a/Projectiles/Rogue/ElementalDiskProj.cs b/Projectiles/Rogue/ElementalDiskProj.cs index 4fbfa84437..9d064a8e09 100644 --- a/Projectiles/Rogue/ElementalDiskProj.cs +++ b/Projectiles/Rogue/ElementalDiskProj.cs @@ -4,6 +4,8 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Rogue; namespace CalamityMod.Projectiles.Rogue { @@ -54,15 +56,15 @@ namespace CalamityMod.Projectiles.Rogue } // Returns after some number of frames in the air - int timeMult = Projectile.Calamity().stealthStrike ? 3 : 1; + int timeMult = Projectile.Calamity().stealthStrike ? ElementalDisk.stealthTimeMult : 1; if (Projectile.timeLeft < Lifetime * timeMult - ReboundTime * timeMult) Projectile.ai[0] = 1f; if (Projectile.ai[0] == 1f) { Player player = Main.player[Projectile.owner]; - float returnSpeed = 9f; - float acceleration = 0.4f; + float returnSpeed = 14f; + float acceleration = Projectile.Calamity().stealthStrike ? 0.45f : 0.6f; Vector2 playerVec = player.Center - Projectile.Center; float dist = playerVec.Length(); @@ -135,11 +137,11 @@ namespace CalamityMod.Projectiles.Rogue if (homeIn) { - int counter = Projectile.Calamity().stealthStrike ? 35 : 50; + int counter = Projectile.Calamity().stealthStrike ? 40 : 60; if (Main.player[Projectile.owner].miscCounter % counter == 0) { int splitProj = ModContent.ProjectileType(); - if (Projectile.owner == Main.myPlayer && Main.player[Projectile.owner].ownedProjectileCounts[splitProj] < 25) + if (Projectile.owner == Main.myPlayer && Main.player[Projectile.owner].ownedProjectileCounts[splitProj] < 16) { float spread = 45f * 0.0174f; double startAngle = Math.Atan2(Projectile.velocity.X, Projectile.velocity.Y) - spread / 2; @@ -152,9 +154,10 @@ namespace CalamityMod.Projectiles.Rogue int disk2 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), splitProj, Projectile.damage, Projectile.knockBack, Projectile.owner); if (Projectile.Calamity().stealthStrike) { - Main.projectile[disk].idStaticNPCHitCooldown = Main.projectile[disk2].idStaticNPCHitCooldown = 6; + Main.projectile[disk].idStaticNPCHitCooldown = Main.projectile[disk2].idStaticNPCHitCooldown = 8; Main.projectile[disk].usesIDStaticNPCImmunity = Main.projectile[disk2].usesIDStaticNPCImmunity = true; - Main.projectile[disk].timeLeft = Main.projectile[disk2].timeLeft = 90; + Main.projectile[disk].timeLeft = Main.projectile[disk2].timeLeft = 60; + Main.projectile[disk].Calamity().CannotProc = Main.projectile[disk2].Calamity().CannotProc = true; } } } @@ -176,6 +179,8 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { + target.AddBuff(ModContent.BuffType(), 60); + if (!Projectile.Calamity().stealthStrike) Projectile.ai[0] = 1f; } diff --git a/Projectiles/Rogue/ElementalDiskSplit.cs b/Projectiles/Rogue/ElementalDiskSplit.cs index 22f07b5c88..b4025ddb2a 100644 --- a/Projectiles/Rogue/ElementalDiskSplit.cs +++ b/Projectiles/Rogue/ElementalDiskSplit.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -35,9 +36,9 @@ namespace CalamityMod.Projectiles.Rogue { if (Main.rand.NextBool(10)) { - int num250 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, Projectile.direction * 2, 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.5f); - Main.dust[num250].noGravity = true; - Main.dust[num250].velocity *= 0f; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, Projectile.direction * 2, 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.5f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0f; } } @@ -46,5 +47,9 @@ namespace CalamityMod.Projectiles.Rogue CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 2); return false; } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 60); + } } } diff --git a/Projectiles/Rogue/ExecutionersBladeProj.cs b/Projectiles/Rogue/ExecutionersBladeProj.cs index bd12da13ba..70185db87a 100644 --- a/Projectiles/Rogue/ExecutionersBladeProj.cs +++ b/Projectiles/Rogue/ExecutionersBladeProj.cs @@ -83,23 +83,23 @@ namespace CalamityMod.Projectiles.Rogue { Projectile.ExpandHitboxBy(128); SoundEngine.PlaySound(SoundID.Item74, Projectile.position); - for (int num621 = 0; num621 < 3; num621++) + for (int i = 0; i < 3; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 5; num623++) + for (int j = 0; j < 5; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 3f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); + Main.dust[dust2].velocity *= 2f; } } diff --git a/Projectiles/Rogue/ExecutionersBladeStealthProj.cs b/Projectiles/Rogue/ExecutionersBladeStealthProj.cs index d3c564b549..edaf5de4df 100644 --- a/Projectiles/Rogue/ExecutionersBladeStealthProj.cs +++ b/Projectiles/Rogue/ExecutionersBladeStealthProj.cs @@ -53,23 +53,23 @@ namespace CalamityMod.Projectiles.Rogue { Projectile.ExpandHitboxBy(128); SoundEngine.PlaySound(SoundID.Item74, Projectile.position); - for (int num621 = 0; num621 < 3; num621++) + for (int i = 0; i < 3; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 5; num623++) + for (int j = 0; j < 5; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 3f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); + Main.dust[dust2].velocity *= 2f; } } diff --git a/Projectiles/Rogue/ExorcismStar.png b/Projectiles/Rogue/ExorcismStar.png index 732c6787ba..e31c55bba6 100644 Binary files a/Projectiles/Rogue/ExorcismStar.png and b/Projectiles/Rogue/ExorcismStar.png differ diff --git a/Projectiles/Rogue/ExplosiveSun.cs b/Projectiles/Rogue/ExplosiveSun.cs index 68d1bd2c12..d68d4e7ae8 100644 --- a/Projectiles/Rogue/ExplosiveSun.cs +++ b/Projectiles/Rogue/ExplosiveSun.cs @@ -71,23 +71,23 @@ namespace CalamityMod.Projectiles.Rogue { SoundEngine.PlaySound(SoundID.Item14 with { Volume = SoundID.Item14.Volume * 0.5f}, Projectile.Center); } - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 3f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[dust2].velocity *= 2f; } } } diff --git a/Projectiles/Rogue/FinalDawnFireSlash.cs b/Projectiles/Rogue/FinalDawnFireSlash.cs index 8cee1e8eac..fc47069d5e 100644 --- a/Projectiles/Rogue/FinalDawnFireSlash.cs +++ b/Projectiles/Rogue/FinalDawnFireSlash.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Rogue if (player is null || player.dead) Projectile.Kill(); - player.direction = Projectile.direction; + player.ChangeDir(Projectile.direction); player.heldProj = Projectile.whoAmI; AdjustPlayerPositionValues(player); diff --git a/Projectiles/Rogue/FinalDawnHorizontalSlash.cs b/Projectiles/Rogue/FinalDawnHorizontalSlash.cs index a435325174..d35540007c 100644 --- a/Projectiles/Rogue/FinalDawnHorizontalSlash.cs +++ b/Projectiles/Rogue/FinalDawnHorizontalSlash.cs @@ -67,8 +67,8 @@ namespace CalamityMod.Projectiles.Rogue if (Projectile.ai[1] < 2) player.bodyFrame.Y = 1 * player.bodyFrame.Height; else player.bodyFrame.Y = 3 * player.bodyFrame.Height; - if (Projectile.ai[1] == 4 || Projectile.ai[1] == 5) player.direction = -1 * Projectile.spriteDirection; - else player.direction = 1 * Projectile.spriteDirection; + if (Projectile.ai[1] == 4 || Projectile.ai[1] == 5) player.ChangeDir(-1 * Projectile.spriteDirection); + else player.ChangeDir(Projectile.spriteDirection); } public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Rogue/FinalDawnProjectile.cs b/Projectiles/Rogue/FinalDawnProjectile.cs index e520d9d24c..6f97f45932 100644 --- a/Projectiles/Rogue/FinalDawnProjectile.cs +++ b/Projectiles/Rogue/FinalDawnProjectile.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.velocity = Main.MouseWorld - player.Center; Projectile.velocity.Normalize(); } - player.direction = Projectile.direction; + player.ChangeDir(Projectile.direction); player.heldProj = Projectile.whoAmI; Projectile.Center = player.Center; Projectile.position.Y -= 44; @@ -107,8 +107,9 @@ namespace CalamityMod.Projectiles.Rogue Projectile.owner); Main.projectile[stealth].Calamity().stealthStrike = true; player.Calamity().ConsumeStealthByAttacking(); - Main.player[Projectile.owner].immuneNoBlink = true; - Main.player[Projectile.owner].immuneTime += 20; //Adding iframes in case they get hit before the dash so those iframes are not wasted + //This seems to have stopped working while testing somehow, even without changing Main[projectileOwner] to player + player.immuneNoBlink = true; + player.immuneTime += 20; //Adding iframes in case they get hit before the dash so those iframes are not wasted } else { diff --git a/Projectiles/Rogue/FinalDawnThrow2.cs b/Projectiles/Rogue/FinalDawnThrow2.cs index 7acb1bddfd..cfd96f4688 100644 --- a/Projectiles/Rogue/FinalDawnThrow2.cs +++ b/Projectiles/Rogue/FinalDawnThrow2.cs @@ -43,10 +43,10 @@ namespace CalamityMod.Projectiles.Rogue { Player player = Main.player[Projectile.owner]; //Give iframes to the player - if (player.immuneTime <= 10) + if (player.immuneTime <= 30) { player.immuneNoBlink = true; - player.immuneTime = 10; + player.immuneTime = 30; } // Spawn homing flames that chase the HIT enemy only. This is also limited to one burst @@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Rogue Vector2 velocity = Utils.NextVector2Circular(Main.rand, 7.2f, 7.2f); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), - (int)(Projectile.damage * 0.3), Projectile.knockBack, Projectile.owner, 0f, + (int)(Projectile.damage * 0.2), Projectile.knockBack, Projectile.owner, 0f, target.whoAmI); } HasHitEnemy = true; @@ -93,7 +93,7 @@ namespace CalamityMod.Projectiles.Rogue player.Center = Projectile.Center; player.fullRotationOrigin = player.Center - player.position; player.fullRotation = Projectile.rotation; - player.direction = Projectile.direction; + player.ChangeDir(Projectile.direction); player.heldProj = Projectile.whoAmI; player.bodyFrame.Y = player.bodyFrame.Height; diff --git a/Projectiles/Rogue/GraveGrimreaverProjectile.cs b/Projectiles/Rogue/GraveGrimreaverProjectile.cs index bfd06237b9..4c29030444 100644 --- a/Projectiles/Rogue/GraveGrimreaverProjectile.cs +++ b/Projectiles/Rogue/GraveGrimreaverProjectile.cs @@ -98,13 +98,13 @@ namespace CalamityMod.Projectiles.Rogue { for (int i = 0; i < amount; i++) { - float num463 = (float)Main.rand.Next(-spreadspeed, spreadspeed + 1); - float num464 = (float)Main.rand.Next(-spreadspeed, spreadspeed + 1); - float num465 = (float)Main.rand.Next(minspeed, maxspeed); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; + float random1 = (float)Main.rand.Next(-spreadspeed, spreadspeed + 1); + float random2 = (float)Main.rand.Next(-spreadspeed, spreadspeed + 1); + float random3 = (float)Main.rand.Next(minspeed, maxspeed); + float randomAdjust = (float)Math.Sqrt((double)(random1 * random1 + random2 * random2)); + randomAdjust = random3 / randomAdjust; + random1 *= randomAdjust; + random2 *= randomAdjust; int d = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, 75, 0, 0, 0, default, size); Dust dust = Main.dust[d]; dust.noGravity = true; @@ -112,8 +112,8 @@ namespace CalamityMod.Projectiles.Rogue dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-spreadspeed, spreadspeed + 1); dust.position.Y += (float)Main.rand.Next(-spreadspeed, spreadspeed + 1); - dust.velocity.X = num463; - dust.velocity.Y = num464; + dust.velocity.X = random1; + dust.velocity.Y = random2; } } } diff --git a/Projectiles/Rogue/HeavenfallenEnergy.cs b/Projectiles/Rogue/HeavenfallenEnergy.cs index d885ae765c..34e373a990 100644 --- a/Projectiles/Rogue/HeavenfallenEnergy.cs +++ b/Projectiles/Rogue/HeavenfallenEnergy.cs @@ -25,18 +25,18 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - int num154 = 14; + int constant = 14; int coolDust; Projectile.ai[0]++; if (Projectile.ai[0] % 2 == 0) { if (Projectile.ai[0] % 4 == 0) { - coolDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - num154 * 2, Projectile.height - num154 * 2, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); + coolDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - constant * 2, Projectile.height - constant * 2, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); } else { - coolDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - num154 * 2, Projectile.height - num154 * 2, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); + coolDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - constant * 2, Projectile.height - constant * 2, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); } Main.dust[coolDust].noGravity = true; Main.dust[coolDust].velocity *= 0.1f; diff --git a/Projectiles/Rogue/HeavenfallenStardiskBoomerang.cs b/Projectiles/Rogue/HeavenfallenStardiskBoomerang.cs index c6efe1c907..b4eefeb60e 100644 --- a/Projectiles/Rogue/HeavenfallenStardiskBoomerang.cs +++ b/Projectiles/Rogue/HeavenfallenStardiskBoomerang.cs @@ -72,68 +72,68 @@ namespace CalamityMod.Projectiles.Rogue { if (Owner.channel) { - float num115 = 20f; - float num116 = (float)Main.mouseX + Main.screenPosition.X - Projectile.Center.X; - float num117 = (float)Main.mouseY + Main.screenPosition.Y - Projectile.Center.Y; + float constant = 20f; + float xfactor = (float)Main.mouseX + Main.screenPosition.X - Projectile.Center.X; + float yfactor = (float)Main.mouseY + Main.screenPosition.Y - Projectile.Center.Y; if (Owner.gravDir == -1f) { - num117 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - Projectile.Center.Y; + yfactor = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - Projectile.Center.Y; } - float num118 = (float)Math.Sqrt((double)(num116 * num116 + num117 * num117)); - if (num118 > num115) + float factorAdjust = (float)Math.Sqrt((double)(xfactor * xfactor + yfactor * yfactor)); + if (factorAdjust > constant) { - num118 = num115 / num118; - num116 *= num118; - num117 *= num118; - int num119 = (int)(num116 * 1000f); - int num120 = (int)(Projectile.velocity.X * 1000f); - int num121 = (int)(num117 * 1000f); - int num122 = (int)(Projectile.velocity.Y * 1000f); - if (num119 != num120 || num121 != num122) + factorAdjust = constant / factorAdjust; + xfactor *= factorAdjust; + yfactor *= factorAdjust; + int scaledX = (int)(xfactor * 1000f); + int scaledXVel = (int)(Projectile.velocity.X * 1000f); + int scaledY = (int)(yfactor * 1000f); + int scaledYVel = (int)(Projectile.velocity.Y * 1000f); + if (scaledX != scaledXVel || scaledY != scaledYVel) { Projectile.netUpdate = true; } - Projectile.velocity.X = num116; - Projectile.velocity.Y = num117; + Projectile.velocity.X = xfactor; + Projectile.velocity.Y = yfactor; } else { - int num123 = (int)(num116 * 1000f); - int num124 = (int)(Projectile.velocity.X * 1000f); - int num125 = (int)(num117 * 1000f); - int num126 = (int)(Projectile.velocity.Y * 1000f); - if (num123 != num124 || num125 != num126) + int scaledX2 = (int)(xfactor * 1000f); + int scaledXVel2 = (int)(Projectile.velocity.X * 1000f); + int scaledY2 = (int)(yfactor * 1000f); + int scaledYVel2 = (int)(Projectile.velocity.Y * 1000f); + if (scaledX2 != scaledXVel2 || scaledY2 != scaledYVel2) { Projectile.netUpdate = true; } - Projectile.velocity.X = num116; - Projectile.velocity.Y = num117; + Projectile.velocity.X = xfactor; + Projectile.velocity.Y = yfactor; } } else if (Projectile.ai[0] == 20f) { Projectile.netUpdate = true; - float num127 = 20f; - Vector2 vector11 = Projectile.Center; - float num128 = (float)Main.mouseX + Main.screenPosition.X - vector11.X; - float num129 = (float)Main.mouseY + Main.screenPosition.Y - vector11.Y; + float sameConstant = 20f; + Vector2 centerPoint = Projectile.Center; + float xfactor2 = (float)Main.mouseX + Main.screenPosition.X - centerPoint.X; + float yfactor2 = (float)Main.mouseY + Main.screenPosition.Y - centerPoint.Y; if (Owner.gravDir == -1f) { - num129 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector11.Y; + yfactor2 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - centerPoint.Y; } - float num130 = (float)Math.Sqrt((double)(num128 * num128 + num129 * num129)); - if (num130 == 0f || Projectile.ai[0] < 0f) + float factorAdjust2 = (float)Math.Sqrt((double)(xfactor2 * xfactor2 + yfactor2 * yfactor2)); + if (factorAdjust2 == 0f || Projectile.ai[0] < 0f) { - vector11 = Owner.Center; - num128 = Projectile.Center.X - vector11.X; - num129 = Projectile.Center.Y - vector11.Y; - num130 = (float)Math.Sqrt((double)(num128 * num128 + num129 * num129)); + centerPoint = Owner.Center; + xfactor2 = Projectile.Center.X - centerPoint.X; + yfactor2 = Projectile.Center.Y - centerPoint.Y; + factorAdjust2 = (float)Math.Sqrt((double)(xfactor2 * xfactor2 + yfactor2 * yfactor2)); } - num130 = num127 / num130; - num128 *= num130; - num129 *= num130; - Projectile.velocity.X = num128; - Projectile.velocity.Y = num129; + factorAdjust2 = sameConstant / factorAdjust2; + xfactor2 *= factorAdjust2; + yfactor2 *= factorAdjust2; + Projectile.velocity.X = xfactor2; + Projectile.velocity.Y = yfactor2; } } } @@ -147,15 +147,15 @@ namespace CalamityMod.Projectiles.Rogue SoundEngine.PlaySound(SoundID.Item10, Projectile.position); for (int i = 0; i < 10; i++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int dusty = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].velocity *= 0f; } for (int i = 0; i < 10; i++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int dusty = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].velocity *= 0f; } if (Projectile.owner == Main.myPlayer && Projectile.ai[1] > 0) diff --git a/Projectiles/Rogue/HypothermiaShard.cs b/Projectiles/Rogue/HypothermiaShard.cs index 72f4f6dd96..2664df3b17 100644 --- a/Projectiles/Rogue/HypothermiaShard.cs +++ b/Projectiles/Rogue/HypothermiaShard.cs @@ -31,9 +31,9 @@ namespace CalamityMod.Projectiles.Rogue counter += 0.25f; if (Main.rand.NextBool(10)) { - int num300 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 318, 0f, 0f, 0, default, 0.8f); - Main.dust[num300].noGravity = true; - Main.dust[num300].velocity *= 0.2f; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 318, 0f, 0f, 0, default, 0.8f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0.2f; } Projectile.velocity *= 0.996f; if (counter > 100f) diff --git a/Projectiles/Rogue/IchorSpearProj.cs b/Projectiles/Rogue/IchorSpearProj.cs index 21132b0cf1..ffb818d70c 100644 --- a/Projectiles/Rogue/IchorSpearProj.cs +++ b/Projectiles/Rogue/IchorSpearProj.cs @@ -127,7 +127,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.ModifyHitNPCSticky(2); posthit = true; } - Projectile.damage = (int)(Projectile.damage * 0.9f); + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.9f); if (Projectile.damage < 1) Projectile.damage = 1; } diff --git a/Projectiles/Rogue/InkBombProjectile.cs b/Projectiles/Rogue/InkBombProjectile.cs index 57d0dccf0d..c7f63c6211 100644 --- a/Projectiles/Rogue/InkBombProjectile.cs +++ b/Projectiles/Rogue/InkBombProjectile.cs @@ -3,6 +3,8 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using CalamityMod.Items.Potions.Alcohol; + namespace CalamityMod.Projectiles.Rogue { public class InkBombProjectile : ModProjectile, ILocalizedModType @@ -65,6 +67,9 @@ namespace CalamityMod.Projectiles.Rogue break; } int damage = (int)player.GetTotalDamage().ApplyTo(22); + if (player.Calamity().oldFashioned) + damage = CalamityUtils.CalcOldFashionedDamage(damage); + int inkID = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-2f, 2f), inkType, damage, 7, Projectile.owner); Main.projectile[inkID].timeLeft += Main.rand.Next(-20, 25); } diff --git a/Projectiles/Rogue/LanceofDestiny.cs b/Projectiles/Rogue/LanceofDestiny.cs index 2fb8f3887c..20b150e0e5 100644 --- a/Projectiles/Rogue/LanceofDestiny.cs +++ b/Projectiles/Rogue/LanceofDestiny.cs @@ -45,16 +45,11 @@ namespace CalamityMod.Projectiles.Rogue if (!Projectile.Calamity().stealthStrike) Projectile.extraUpdates = 1; - if (Projectile.timeLeft % 5 == 0) + if (Projectile.timeLeft % 2 == 0) { - float radiusFactor = MathHelper.Lerp(0f, 1f, Utils.GetLerpValue(10f, 30f, Time, true)); for (int i = 0; i < 4; i++) { - float offsetRotationAngle = Projectile.velocity.ToRotation() + Time / 20f; - float radius = (20f + (float)Math.Cos(Time / 13f) * 6f) * radiusFactor; - Vector2 dustPosition = Projectile.Center; - dustPosition += offsetRotationAngle.ToRotationVector2().RotatedBy(i / 5f * MathHelper.TwoPi) * radius; - CritSpark spark = new CritSpark(dustPosition, -Projectile.velocity, Color.PaleGoldenrod, Color.Goldenrod, Main.rand.NextFloat(1.1f, 1.5f), Main.rand.Next(5, 8), 5f); + CritSpark spark = new CritSpark(Projectile.Center + Main.rand.NextVector2Circular(10, 10), -Projectile.velocity, Color.PaleGoldenrod, Color.Goldenrod, Main.rand.NextFloat(0.65f, 0.95f), 8, 0, 2.5f); GeneralParticleHandler.SpawnParticle(spark); } } @@ -92,9 +87,11 @@ namespace CalamityMod.Projectiles.Rogue } for (int i = 0; i <= hitsDust; i++) { - Dust dust2 = Main.dust[Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, Main.rand.NextBool(3) ? 130 : 133, Projectile.oldVelocity.X * Main.rand.NextFloat(1.1f, 1.3f), Projectile.oldVelocity.Y * Main.rand.NextFloat(1.1f, 1.3f), 0, default, 1.1f)]; + Vector2 sparkVelocity = Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.6f, 1.5f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity, Main.rand.NextBool(3) ? 130 : 133, sparkVelocity, 0, default, Main.rand.NextFloat(1.2f, 1.5f)); + dust.noGravity = true; } - SoundEngine.PlaySound(Hitsound, Projectile.position); + SoundEngine.PlaySound(Hitsound, Projectile.Center); } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { @@ -102,7 +99,8 @@ namespace CalamityMod.Projectiles.Rogue { posthit = true; } - Projectile.damage = (int)(Projectile.damage * 0.9f); + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.9f); if (Projectile.damage < 1) Projectile.damage = 1; } diff --git a/Projectiles/Rogue/LeonidProgenitorBombshell.cs b/Projectiles/Rogue/LeonidProgenitorBombshell.cs index 349934e155..49ef7bcfe8 100644 --- a/Projectiles/Rogue/LeonidProgenitorBombshell.cs +++ b/Projectiles/Rogue/LeonidProgenitorBombshell.cs @@ -107,12 +107,12 @@ namespace CalamityMod.Projectiles.Rogue return; Vector2 spinningpoint = new Vector2(0f, 6f); - float num1 = MathHelper.ToRadians(45f); + float radian45 = MathHelper.ToRadians(45f); int cometAmt = 5; - float num3 = -(num1 * 2f) / (cometAmt - 1f); + float cometSpread = -(radian45 * 2f) / (cometAmt - 1f); for (int projIndex = 0; projIndex < cometAmt; ++projIndex) { - int index2 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, spinningpoint.RotatedBy((double)num1 + (double)num3 * (double)projIndex, new Vector2()), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, -1f); + int index2 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, spinningpoint.RotatedBy((double)radian45 + (double)cometSpread * (double)projIndex, new Vector2()), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, -1f); Projectile proj = Main.projectile[index2]; for (int index3 = 0; index3 < Projectile.localNPCImmunity.Length; ++index3) { diff --git a/Projectiles/Rogue/LunarKunaiProj.cs b/Projectiles/Rogue/LunarKunaiProj.cs index 83ffc1c7dd..ce87567720 100644 --- a/Projectiles/Rogue/LunarKunaiProj.cs +++ b/Projectiles/Rogue/LunarKunaiProj.cs @@ -63,25 +63,25 @@ namespace CalamityMod.Projectiles.Rogue Projectile.damage /= 4; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; - for (int num194 = 0; num194 < 10; num194++) + for (int i = 0; i < 10; i++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 229, 0f, 0f, 0, default, 1.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 229, 0f, 0f, 100, default, 1f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 229, 0f, 0f, 0, default, 1.5f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 3f; + dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 229, 0f, 0f, 100, default, 1f); + Main.dust[dust].velocity *= 2f; + Main.dust[dust].noGravity = true; } Projectile.Damage(); } else { - for (int i = 0; i < 5; i++) + for (int j = 0; j < 5; j++) { - int num304 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 265, 0f, 0f, 100, default, 1f); - Main.dust[num304].noGravity = true; - Main.dust[num304].velocity *= 1.2f; - Main.dust[num304].velocity -= Projectile.oldVelocity * 0.3f; + int dusty = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 265, 0f, 0f, 100, default, 1f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].velocity *= 1.2f; + Main.dust[dusty].velocity -= Projectile.oldVelocity * 0.3f; } } } diff --git a/Projectiles/Rogue/LuxorsGiftRogue.cs b/Projectiles/Rogue/LuxorsGiftRogue.cs index b8e29aeb05..af4becd623 100644 --- a/Projectiles/Rogue/LuxorsGiftRogue.cs +++ b/Projectiles/Rogue/LuxorsGiftRogue.cs @@ -58,15 +58,15 @@ namespace CalamityMod.Projectiles.Rogue { for (int l = 0; l < 12; l++) { - Vector2 vector3 = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); - int num9 = Dust.NewDust(Projectile.Center, 0, 0, 173, 0f, 0f, 160, default, 1f); - Main.dust[num9].scale = 1.1f; - Main.dust[num9].noGravity = true; - Main.dust[num9].position = Projectile.Center + vector3; - Main.dust[num9].velocity = Projectile.velocity * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; + Vector2 rotation = Vector2.UnitX * (float)-(float)Projectile.width / 2f; + rotation += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); + rotation = rotation.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); + int dusty = Dust.NewDust(Projectile.Center, 0, 0, 173, 0f, 0f, 160, default, 1f); + Main.dust[dusty].scale = 1.1f; + Main.dust[dusty].noGravity = true; + Main.dust[dusty].position = Projectile.Center + rotation; + Main.dust[dusty].velocity = Projectile.velocity * 0.1f; + Main.dust[dusty].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[dusty].position) * 1.25f; } } } diff --git a/Projectiles/Rogue/MalachiteBolt.cs b/Projectiles/Rogue/MalachiteBolt.cs index bb5ec00c1c..4b2421657b 100644 --- a/Projectiles/Rogue/MalachiteBolt.cs +++ b/Projectiles/Rogue/MalachiteBolt.cs @@ -43,11 +43,11 @@ namespace CalamityMod.Projectiles.Rogue Projectile.localAI[1] += 1f; if (Projectile.localAI[1] > 4f) { - for (int num468 = 0; num468 < 3; num468++) + for (int i = 0; i < 3; i++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 0.75f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int dusty = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 0.75f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].velocity *= 0f; } } } @@ -71,23 +71,23 @@ namespace CalamityMod.Projectiles.Rogue Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; Projectile.Damage(); - for (int num621 = 0; num621 < 70; num621++) + for (int j = 0; j < 70; j++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 40; num623++) + for (int k = 0; k < 40; k++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); + Main.dust[dust2].velocity *= 2f; } } } @@ -103,23 +103,23 @@ namespace CalamityMod.Projectiles.Rogue Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; Projectile.Damage(); - for (int num621 = 0; num621 < 70; num621++) + for (int j = 0; j < 70; j++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 40; num623++) + for (int k = 0; k < 40; k++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); + Main.dust[dust2].velocity *= 2f; } } } @@ -130,23 +130,23 @@ namespace CalamityMod.Projectiles.Rogue Projectile.width = Projectile.height = 16; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 7; num621++) + for (int j = 0; j < 7; j++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 3; num623++) + for (int k = 0; k < 3; k++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); + Main.dust[dust2].velocity *= 2f; } } } diff --git a/Projectiles/Rogue/MalachiteProj.cs b/Projectiles/Rogue/MalachiteProj.cs index 948b60818c..d1d092ed6e 100644 --- a/Projectiles/Rogue/MalachiteProj.cs +++ b/Projectiles/Rogue/MalachiteProj.cs @@ -41,11 +41,11 @@ namespace CalamityMod.Projectiles.Rogue Projectile.localAI[1] += 1f; if (Projectile.localAI[1] > 4f) { - for (int num468 = 0; num468 < 3; num468++) + for (int k = 0; k < 3; k++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 0.75f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int dusty = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 0.75f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].velocity *= 0f; } } } @@ -64,23 +64,23 @@ namespace CalamityMod.Projectiles.Rogue Projectile.width = Projectile.height = 48; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 7; num621++) + for (int i = 0; i < 7; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 15; num623++) + for (int j = 0; j < 15; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); + Main.dust[dust2].velocity *= 2f; } } } diff --git a/Projectiles/Rogue/MalachiteStealth.cs b/Projectiles/Rogue/MalachiteStealth.cs index f7b4ecf6bb..871fb68e9a 100644 --- a/Projectiles/Rogue/MalachiteStealth.cs +++ b/Projectiles/Rogue/MalachiteStealth.cs @@ -42,11 +42,11 @@ namespace CalamityMod.Projectiles.Rogue Projectile.localAI[1] += 1f; if (Projectile.localAI[1] > 4f) { - for (int num468 = 0; num468 < 3; num468++) + for (int k = 0; k < 3; k++) { - int num469 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 0.75f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 0.75f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0f; } } } diff --git a/Projectiles/Rogue/MeteorFistProj.cs b/Projectiles/Rogue/MeteorFistProj.cs index 31f44f3692..a6afa5c9e5 100644 --- a/Projectiles/Rogue/MeteorFistProj.cs +++ b/Projectiles/Rogue/MeteorFistProj.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; using System; using Terraria; using Terraria.ID; @@ -80,11 +81,6 @@ namespace CalamityMod.Projectiles.Rogue public override void OnKill(int timeLeft) { - Projectile.ExpandHitboxBy(34); - Projectile.maxPenetrate = Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - Projectile.Damage(); SoundEngine.PlaySound(SoundID.Item14, Projectile.position); for (int j = 0; j < 40; j++) { @@ -150,7 +146,11 @@ namespace CalamityMod.Projectiles.Rogue } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.OnFire, 120); + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(BuffID.OnFire, 120); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + } public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.OnFire, 120); } diff --git a/Projectiles/Rogue/MeteorFistStealth.cs b/Projectiles/Rogue/MeteorFistStealth.cs index 598d1d857b..8abb17f4d8 100644 --- a/Projectiles/Rogue/MeteorFistStealth.cs +++ b/Projectiles/Rogue/MeteorFistStealth.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; using System; using System.Collections.Generic; using Terraria; @@ -81,11 +82,6 @@ namespace CalamityMod.Projectiles.Rogue public override void OnKill(int timeLeft) { - Projectile.ExpandHitboxBy(36); - Projectile.maxPenetrate = Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - Projectile.Damage(); SoundEngine.PlaySound(SoundID.Item14, Projectile.position); for (int j = 0; j < 40; j++) { @@ -154,6 +150,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(BuffID.OnFire, 120); + int boom = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); Projectile.damage /= 2; float minDist = 999f; int index = 0; diff --git a/Projectiles/Rogue/MoltenBlobThrown.cs b/Projectiles/Rogue/MoltenBlobThrown.cs index 3cd2512d44..4759c6708d 100644 --- a/Projectiles/Rogue/MoltenBlobThrown.cs +++ b/Projectiles/Rogue/MoltenBlobThrown.cs @@ -80,20 +80,20 @@ namespace CalamityMod.Projectiles.Rogue Projectile.height = 10; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 3; num621++) + for (int i = 0; i < 3; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 5; num623++) + for (int j = 0; j < 5; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 3f); + Main.dust[dust2].noGravity = true; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); } } } diff --git a/Projectiles/Rogue/PrismallineProj.cs b/Projectiles/Rogue/PrismallineProj.cs index 1250d97b01..e5f898961f 100644 --- a/Projectiles/Rogue/PrismallineProj.cs +++ b/Projectiles/Rogue/PrismallineProj.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Rogue } else //stealth strike { - for (int num252 = 0; num252 < 5; num252++) + for (int j = 0; j < 5; j++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); int shard = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage / 2, 0f, Projectile.owner); diff --git a/Projectiles/Rogue/RadiantExplosion.cs b/Projectiles/Rogue/RadiantExplosion.cs index c2edfbca07..eb5a206d36 100644 --- a/Projectiles/Rogue/RadiantExplosion.cs +++ b/Projectiles/Rogue/RadiantExplosion.cs @@ -44,47 +44,46 @@ namespace CalamityMod.Projectiles.Rogue { for (int i = 0; i < 5; i++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int dusty = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].velocity *= 0f; } for (int i = 0; i < 5; i++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int dusty = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].velocity *= 0f; } } if (Projectile.Calamity().stealthStrike) { - float num472 = Projectile.Center.X; - float num473 = Projectile.Center.Y; - float num474 = 600f; - for (int num475 = 0; num475 < Main.maxNPCs; num475++) + float projX = Projectile.Center.X; + float projY = Projectile.Center.Y; + for (int j = 0; j < Main.maxNPCs; j++) { - if (Main.npc[num475].CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) + if (Main.npc[j].CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[j].Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) { - float npcCenterX = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float npcCenterY = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - 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) + float npcCenterX = Main.npc[j].position.X + (float)(Main.npc[j].width / 2); + float npcCenterY = Main.npc[j].position.Y + (float)(Main.npc[j].height / 2); + float targetDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcCenterX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcCenterY); + if (targetDist < 600f) { - if (Main.npc[num475].position.X < num472) + if (Main.npc[j].position.X < projX) { - Main.npc[num475].velocity.X += 0.25f; + Main.npc[j].velocity.X += 0.25f; } else { - Main.npc[num475].velocity.X -= 0.25f; + Main.npc[j].velocity.X -= 0.25f; } - if (Main.npc[num475].position.Y < num473) + if (Main.npc[j].position.Y < projY) { - Main.npc[num475].velocity.Y += 0.25f; + Main.npc[j].velocity.Y += 0.25f; } else { - Main.npc[num475].velocity.Y -= 0.25f; + Main.npc[j].velocity.Y -= 0.25f; } } } diff --git a/Projectiles/Rogue/RadiantStar2.cs b/Projectiles/Rogue/RadiantStar2.cs index c1dc9e0a23..91ef243b35 100644 --- a/Projectiles/Rogue/RadiantStar2.cs +++ b/Projectiles/Rogue/RadiantStar2.cs @@ -37,34 +37,34 @@ namespace CalamityMod.Projectiles.Rogue Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(45f); if (Projectile.ai[0] == 1f) { - float num472 = Projectile.Center.X; - float num473 = Projectile.Center.Y; - float num474 = Projectile.Calamity().stealthStrike ? 1800f : 600f; + float projX = Projectile.Center.X; + float projY = Projectile.Center.Y; + float homeRange = Projectile.Calamity().stealthStrike ? 1800f : 600f; float homingSpeed = 0.25f; - for (int num475 = 0; num475 < Main.maxNPCs; num475++) + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num475].CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) + if (Main.npc[i].CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[i].Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) { - float npcCenterX = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float npcCenterY = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - 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) + float npcCenterX = Main.npc[i].position.X + (float)(Main.npc[i].width / 2); + float npcCenterY = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2); + float targetDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcCenterX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcCenterY); + if (targetDist < homeRange) { - if (Main.npc[num475].position.X < num472) + if (Main.npc[i].position.X < projX) { - Main.npc[num475].velocity.X += homingSpeed; + Main.npc[i].velocity.X += homingSpeed; } else { - Main.npc[num475].velocity.X -= homingSpeed; + Main.npc[i].velocity.X -= homingSpeed; } - if (Main.npc[num475].position.Y < num473) + if (Main.npc[i].position.Y < projY) { - Main.npc[num475].velocity.Y += homingSpeed; + Main.npc[i].velocity.Y += homingSpeed; } else { - Main.npc[num475].velocity.Y -= homingSpeed; + Main.npc[i].velocity.Y -= homingSpeed; } } } diff --git a/Projectiles/Rogue/RadiantStarKnife.cs b/Projectiles/Rogue/RadiantStarKnife.cs index 5a1c875fc8..2486e3c7eb 100644 --- a/Projectiles/Rogue/RadiantStarKnife.cs +++ b/Projectiles/Rogue/RadiantStarKnife.cs @@ -37,21 +37,21 @@ namespace CalamityMod.Projectiles.Rogue Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(45f); if (Projectile.ai[0] == 1f) { - float num472 = Projectile.Center.X; - float num473 = Projectile.Center.Y; - float num474 = Projectile.Calamity().stealthStrike ? 1800f : 600f; + float projX = Projectile.Center.X; + float projY = Projectile.Center.Y; + float homeRange = Projectile.Calamity().stealthStrike ? 1800f : 600f; float homingSpeed = 0.25f; - for (int num475 = 0; num475 < Main.npc.Length; num475++) + for (int i = 0; i < Main.npc.Length; i++) { - NPC npc = Main.npc[num475]; + NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, npc.Center, 1, 1) && !npc.boss) { - float num476 = npc.position.X + (float)(npc.width / 2); - float num477 = npc.position.Y + (float)(npc.height / 2); - float num478 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num476) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num477); - if (num478 < num474) + float npcX = npc.position.X + (float)(npc.width / 2); + float npcY = npc.position.Y + (float)(npc.height / 2); + float targetDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); + if (targetDist < homeRange) { - if (npc.position.X < num472) + if (npc.position.X < projX) { npc.velocity.X += homingSpeed; } @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Rogue { npc.velocity.X -= homingSpeed; } - if (npc.position.Y < num473) + if (npc.position.Y < projY) { npc.velocity.Y += homingSpeed; } diff --git a/Projectiles/Rogue/RealityRuptureLance.cs b/Projectiles/Rogue/RealityRuptureLance.cs index 4757615051..980e0135fb 100644 --- a/Projectiles/Rogue/RealityRuptureLance.cs +++ b/Projectiles/Rogue/RealityRuptureLance.cs @@ -69,15 +69,19 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - for (int i = 0; i <= 4; i++) + for (int i = 0; i <= 13; i++) { - Dust dust2 = Main.dust[Dust.NewDust(target.position, Projectile.width, Projectile.height, Main.rand.NextBool(4) ? 242 : 310, Projectile.oldVelocity.X * Main.rand.NextFloat(1.1f, 1.3f), Projectile.oldVelocity.Y * Main.rand.NextFloat(1.1f, 1.3f), 0, default, 1.1f)]; + Vector2 sparkVelocity = Projectile.velocity.RotatedByRandom(0.25f) * Main.rand.NextFloat(0.3f, 1.8f); + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity * 0.5f, Main.rand.NextBool(4) ? 242 : 310, sparkVelocity, 0, default, Main.rand.NextFloat(2.2f, 3.5f)); + dust.noGravity = true; + dust.fadeIn = 0.5f; } - SoundEngine.PlaySound(Hitsound, Projectile.position); + SoundEngine.PlaySound(Hitsound, Projectile.Center); } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - Projectile.damage = (int)(Projectile.damage * 0.95f); + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.95f); if (Projectile.damage < 1) Projectile.damage = 1; } diff --git a/Projectiles/Rogue/RealityRuptureMini.cs b/Projectiles/Rogue/RealityRuptureMini.cs index eae81d9309..3e7ae26d62 100644 --- a/Projectiles/Rogue/RealityRuptureMini.cs +++ b/Projectiles/Rogue/RealityRuptureMini.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Projectiles.Rogue public static readonly SoundStyle Hitsound = new("CalamityMod/Sounds/Item/WulfrumKnifeTileHit2") { PitchVariance = 0.3f, Volume = 0.5f }; public int framesInAir = 0; - public int SparkChance = 7; + public int SparkChance = 1; public override void SetDefaults() { @@ -41,20 +41,10 @@ namespace CalamityMod.Projectiles.Rogue Lighting.AddLight(Projectile.Center + Projectile.velocity * 0.6f, 0.6f, 0.2f, 0.5f); } - if (Main.rand.NextBool(SparkChance)) + if (Projectile.timeLeft % 2 == 0 && Main.rand.NextBool(SparkChance) && Projectile.numHits == 0) { - Vector2 SparkVelocity1 = Projectile.velocity.RotatedBy(-3, default) * 0.1f - Projectile.velocity / 2f; - Vector2 SparkPosition1 = Projectile.velocity.RotatedBy(-0.8, default); - SparkParticle spark = new SparkParticle(Projectile.Center + SparkPosition1, SparkVelocity1, false, Main.rand.Next(6, 8), Main.rand.NextFloat(0.6f, 0.8f), Color.Plum); + SparkParticle spark = new SparkParticle(Projectile.Center - Projectile.velocity * 0.5f, Projectile.velocity * 0.01f, false, 7, 1.3f, Color.Plum * 0.5f); GeneralParticleHandler.SpawnParticle(spark); - - } - if (Main.rand.NextBool(SparkChance)) - { - Vector2 SparkVelocity2 = Projectile.velocity.RotatedBy(3, default) * 0.1f - Projectile.velocity / 2f; - Vector2 SparkPosition2 = Projectile.velocity.RotatedBy(0.8, default); - SparkParticle spark2 = new SparkParticle(Projectile.Center + SparkPosition2, SparkVelocity2, false, Main.rand.Next(6, 8), Main.rand.NextFloat(0.6f, 0.8f), Color.Plum); - GeneralParticleHandler.SpawnParticle(spark2); } Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver4; @@ -81,7 +71,7 @@ namespace CalamityMod.Projectiles.Rogue if (homeIn) { - SparkChance = 14; + SparkChance = 2; Projectile.extraUpdates = 4; Vector2 moveDirection = Projectile.SafeDirectionTo(center, Vector2.UnitY); Projectile.velocity = (Projectile.velocity * 20f + moveDirection * 12f) / (21f); @@ -97,7 +87,8 @@ namespace CalamityMod.Projectiles.Rogue } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - Projectile.damage = (int)(Projectile.damage * 0.8f); + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.8f); if (Projectile.damage < 1) Projectile.damage = 1; } diff --git a/Projectiles/Rogue/RealityRuptureStealth.cs b/Projectiles/Rogue/RealityRuptureStealth.cs index f56fd91c05..7ba28144a7 100644 --- a/Projectiles/Rogue/RealityRuptureStealth.cs +++ b/Projectiles/Rogue/RealityRuptureStealth.cs @@ -39,28 +39,20 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { + Player Owner = Main.player[Projectile.owner]; + float playerDist = Vector2.Distance(Owner.Center, Projectile.Center); + Time++; Projectile.velocity *= 1.003f; Projectile.scale = 1.3f; Vector3 DustLight = new Vector3(0.209f, 0.140f, 0.202f); Lighting.AddLight(Projectile.Center, DustLight * 8); - //Lighting.AddLight(Projectile.Center + Projectile.velocity * 0.6f, 0.6f, 0.2f, 0.5f); - if (Time % 2 == 0) + if (Time > 10 && playerDist < 1400f) { - Vector2 SparkVelocity1 = Projectile.velocity.RotatedBy(-2.5f, default) * 0.1f - Projectile.velocity / 2f; - Vector2 SparkPosition1 = Projectile.velocity.RotatedBy(-0.8, default); - SparkParticle spark = new SparkParticle(Projectile.Center + SparkPosition1, SparkVelocity1, false, Main.rand.Next(22, 25), Main.rand.NextFloat(1.2f, 1.9f), Color.Plum); - GeneralParticleHandler.SpawnParticle(spark); - - } - if (Time % 2 == 0) - { - Vector2 SparkVelocity2 = Projectile.velocity.RotatedBy(2.5f, default) * 0.1f - Projectile.velocity / 2f; - Vector2 SparkPosition2 = Projectile.velocity.RotatedBy(0.8, default); - SparkParticle spark2 = new SparkParticle(Projectile.Center + SparkPosition2, SparkVelocity2, false, Main.rand.Next(22, 25), Main.rand.NextFloat(1.2f, 1.9f), Color.Plum); - GeneralParticleHandler.SpawnParticle(spark2); + SparkParticle spark3 = new SparkParticle(Projectile.Center - Projectile.velocity, Projectile.velocity * 0.01f, false, 18, 3.4f, Color.Plum * 0.6f); + GeneralParticleHandler.SpawnParticle(spark3); } Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver4; } @@ -101,7 +93,15 @@ namespace CalamityMod.Projectiles.Rogue { for (int i = 0; i <= 15; i++) { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 272, Projectile.oldVelocity.X * 0.3f, Projectile.oldVelocity.Y * 0.3f, 0, default, Main.rand.NextFloat(1.7f, 2.1f)); + Vector2 sparkVelocity = Projectile.velocity.RotatedByRandom(0.4f) * Main.rand.NextFloat(0.6f, 1.5f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity, 272, sparkVelocity.RotatedByRandom(0.1f), 0, default, Main.rand.NextFloat(1.2f, 1.5f)); + dust.noGravity = true; + + int sparkLifetime = Main.rand.Next(43, 48); + float sparkScale = Main.rand.NextFloat(2.2f, 3f); + Color sparkColor = Color.Plum * 0.8f; + SparkParticle spark = new SparkParticle(Projectile.Center, sparkVelocity, false, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); } Particle pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, Color.Plum, new Vector2(2f, 2f), Main.rand.NextFloat(12f, 25f), 0.1f, 1f, 13); GeneralParticleHandler.SpawnParticle(pulse); diff --git a/Projectiles/Rogue/ReaperProjectile.cs b/Projectiles/Rogue/ReaperProjectile.cs index 06c5508b15..f716ff8824 100644 --- a/Projectiles/Rogue/ReaperProjectile.cs +++ b/Projectiles/Rogue/ReaperProjectile.cs @@ -178,23 +178,23 @@ namespace CalamityMod.Projectiles.Rogue Projectile.height = 100; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 8; num623++) + for (int j = 0; j < 8; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 3f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 2f); + Main.dust[dust2].velocity *= 2f; } } } diff --git a/Projectiles/Rogue/RegulusEnergy.cs b/Projectiles/Rogue/RegulusEnergy.cs index 69444252da..abfca67bbe 100644 --- a/Projectiles/Rogue/RegulusEnergy.cs +++ b/Projectiles/Rogue/RegulusEnergy.cs @@ -24,18 +24,18 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - int num154 = 14; + int constant = 14; int coolDust; Projectile.ai[0] += 1; if (Projectile.ai[0] % 2 == 0) { if (Projectile.ai[0] % 4 == 0) { - coolDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - num154 * 2, Projectile.height - num154 * 2, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); + coolDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - constant * 2, Projectile.height - constant * 2, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); } else { - coolDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - num154 * 2, Projectile.height - num154 * 2, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); + coolDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - constant * 2, Projectile.height - constant * 2, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); } Main.dust[coolDust].noGravity = true; Main.dust[coolDust].velocity *= 0.1f; @@ -92,14 +92,14 @@ namespace CalamityMod.Projectiles.Rogue Projectile.width = Projectile.height = 24; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int otherConstant = 36; + for (int j = 0; j < otherConstant; j++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, ModContent.DustType(), vector7.X * 0.5f, vector7.Y * 0.5f, 100, default, 0.75f); - Main.dust[num228].noGravity = true; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(j - (otherConstant / 2 - 1)) * 6.28318548f / (float)otherConstant), default) + Projectile.Center; + Vector2 facingDirection = rotate - Projectile.Center; + int dusty = Dust.NewDust(rotate + facingDirection, 0, 0, ModContent.DustType(), facingDirection.X * 0.5f, facingDirection.Y * 0.5f, 100, default, 0.75f); + Main.dust[dusty].noGravity = true; } } diff --git a/Projectiles/Rogue/ScarletBlast.cs b/Projectiles/Rogue/ScarletBlast.cs index 01af47f5a2..f6d8265aef 100644 --- a/Projectiles/Rogue/ScarletBlast.cs +++ b/Projectiles/Rogue/ScarletBlast.cs @@ -33,60 +33,60 @@ namespace CalamityMod.Projectiles.Rogue SoundEngine.PlaySound(SoundID.Item20, Projectile.position); Projectile.localAI[0] += 1f; } - bool flag15 = false; - bool flag16 = false; + bool xflag = false; + bool yflag = false; if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) { - flag16 = true; + yflag = true; } if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) { - flag16 = true; + yflag = true; } - if (flag15 && flag16) + if (xflag && yflag) { Projectile.Kill(); } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCompare = 0; + while ((float)timerCompare < projTimer) { - float num463 = (float)Main.rand.Next(-30, 35); - float num464 = (float)Main.rand.Next(-30, 35); - float num465 = (float)Main.rand.Next(13, 18); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 130, 0f, 0f, 100, default, 1.25f); - Dust dust = Main.dust[num467]; + float random1 = (float)Main.rand.Next(-30, 35); + float random2 = (float)Main.rand.Next(-30, 35); + float random3 = (float)Main.rand.Next(13, 18); + float randomAdjust = (float)Math.Sqrt((double)(random1 * random1 + random2 * random2)); + randomAdjust = random3 / randomAdjust; + random1 *= randomAdjust; + random2 *= randomAdjust; + int redDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 130, 0f, 0f, 100, default, 1.25f); + Dust dust = Main.dust[redDust]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = random1; + dust.velocity.Y = random2; + timerCompare++; } } } diff --git a/Projectiles/Rogue/ScourgeoftheDesertProj.cs b/Projectiles/Rogue/ScourgeoftheDesertProj.cs index 0edba7f715..1f708cbb8c 100644 --- a/Projectiles/Rogue/ScourgeoftheDesertProj.cs +++ b/Projectiles/Rogue/ScourgeoftheDesertProj.cs @@ -1,8 +1,16 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs.DesertScourge; +using CalamityMod.NPCs.Ravager; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Magic; +using Microsoft.CodeAnalysis; +using Microsoft.Xna.Framework; using System; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; +using static Humanizer.In; namespace CalamityMod.Projectiles.Rogue { @@ -11,8 +19,14 @@ namespace CalamityMod.Projectiles.Rogue public new string LocalizationCategory => "Projectiles.Rogue"; public override string Texture => "CalamityMod/Items/Weapons/Rogue/ScourgeoftheDesert"; - private int StealthDamageCap = 0; - private int BaseDamage = 0; + public int Time = 0; + public int TimeUnderground = 0; + public bool PostExitTiles = false; + public bool InitialTileHit = false; + public bool InsideTiles = false; + public Vector2 SavedOldVelocity; + public Vector2 NPCDestination; + public bool SetPierce = false; public override void SetStaticDefaults() { @@ -22,59 +36,165 @@ namespace CalamityMod.Projectiles.Rogue public override void SetDefaults() { - Projectile.width = 26; - Projectile.height = 26; + Projectile.width = 50; + Projectile.height = 50; Projectile.friendly = true; - Projectile.aiStyle = ProjAIStyleID.StickProjectile; - AIType = ProjectileID.BoneJavelin; - Projectile.penetrate = 3; + Projectile.penetrate = 2; Projectile.DamageType = RogueDamageClass.Instance; + Projectile.tileCollide = true; + Projectile.timeLeft = 600; + Projectile.extraUpdates = 1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 50; } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - if (Projectile.Calamity().stealthStrike) - { - if (StealthDamageCap == 0) - { - BaseDamage = Projectile.damage; - } - - Projectile.damage = (int)((BaseDamage * ((StealthDamageCap > 10 ? 10 : StealthDamageCap) * 20) / 100) + BaseDamage); //20% damage boost per hit, max of 200% - StealthDamageCap++; - } - } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (Projectile.Calamity().stealthStrike) - { - if (StealthDamageCap == 0) - { - BaseDamage = Projectile.damage; - } - - Projectile.damage = (int)((BaseDamage * ((StealthDamageCap > 10 ? 10 : StealthDamageCap) * 20) / 100) + BaseDamage); //20% damage boost per hit, max of 200% - StealthDamageCap++; - } - } - public override void AI() { - if (Projectile.Calamity().stealthStrike) + if (!SetPierce) { - Projectile.penetrate = 20 - StealthDamageCap; - Projectile.velocity.Y *= 1.025f; - Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 32); + Projectile.penetrate = Projectile.Calamity().stealthStrike ? 4 : 2; + SetPierce = true; } - Projectile.velocity.X *= 1.025f; - Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) + MathHelper.PiOver4; - if (Projectile.spriteDirection == -1) + InsideTiles = Collision.SolidCollision(Projectile.Center, 50, 50); + Time++; + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver4; + Player Owner = Main.player[Projectile.owner]; + float playerDist = Vector2.Distance(Owner.Center, Projectile.Center); + + if (Main.rand.NextBool(2)) { - Projectile.rotation -= 1.57f; + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(20, 20), Main.rand.NextBool() ? 288 : 207); + dust.scale = Main.rand.NextFloat(0.3f, 0.55f); + dust.noGravity = true; + dust.velocity = -Projectile.velocity * 0.5f; + } + + if (!InitialTileHit && Time > 45) + { + if (Projectile.velocity.Y < 0) + { + Projectile.velocity.Y *= 0.95f; + } + Projectile.velocity.Y += 0.15f; + Projectile.velocity.X *= 0.98f; + } + + if (InitialTileHit && !InsideTiles && !PostExitTiles) // Emerge from ground + { + Projectile.extraUpdates = 4; + if (!Projectile.Calamity().stealthStrike) + Projectile.timeLeft = 200; + SoundEngine.PlaySound(SoundID.NPCHit11 with { Volume = 1.3f, Pitch = 1.1f }, Projectile.Center); + for (int i = 0; i <= 25; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity * 6.5f, Main.rand.NextBool() ? 207 : 216, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(0.3f, 0.9f), 0, default, Main.rand.NextFloat(1.3f, 1.8f)); + dust.noGravity = true; + } + PostExitTiles = true; + } + if (PostExitTiles) + { + if (Projectile.timeLeft % 2 == 0 && playerDist < 1400f) + { + SparkParticle spark = new SparkParticle(Projectile.Center - Projectile.velocity * 8f, -Projectile.velocity * 0.1f, false, 9, 2.3f, Color.White * 0.1f); + GeneralParticleHandler.SpawnParticle(spark); + } + } + if (InsideTiles) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].CanBeChasedBy(Projectile.GetSource_FromThis(), false)) + NPCDestination = Main.npc[i].Center + Main.npc[i].velocity * 5f; + } + + TimeUnderground++; + Vector3 DustLight = new Vector3(0.171f, 0.124f, 0.086f); + Lighting.AddLight(Projectile.Center + Projectile.velocity, DustLight * 4); + if (Time % 15 == 0 && TimeUnderground < 120) + { + SoundEngine.PlaySound(SoundID.WormDig with { Volume = 0.7f, Pitch = 0.2f }, Projectile.Center); + } + float returnSpeed = 10; + float acceleration = 0.2f; + float xDist = NPCDestination.X - Projectile.Center.X; + float yDist = NPCDestination.Y - Projectile.Center.Y; + float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); + dist = returnSpeed / dist; + xDist *= dist; + yDist *= dist; + float targetDist = Vector2.Distance(NPCDestination, Projectile.Center); + if (targetDist < 1800 && TimeUnderground > 25) + { + if (Projectile.velocity.X < xDist) + { + Projectile.velocity.X = Projectile.velocity.X + acceleration; + if (Projectile.velocity.X < 0f && xDist > 0f) + Projectile.velocity.X += acceleration; + } + else if (Projectile.velocity.X > xDist) + { + Projectile.velocity.X = Projectile.velocity.X - acceleration; + if (Projectile.velocity.X > 0f && xDist < 0f) + Projectile.velocity.X -= acceleration; + } + if (Projectile.velocity.Y < yDist) + { + Projectile.velocity.Y = Projectile.velocity.Y + acceleration; + if (Projectile.velocity.Y < 0f && yDist > 0f) + Projectile.velocity.Y += acceleration; + } + else if (Projectile.velocity.Y > yDist) + { + Projectile.velocity.Y = Projectile.velocity.Y - acceleration; + if (Projectile.velocity.Y > 0f && yDist < 0f) + Projectile.velocity.Y -= acceleration; + } + } + } + } + public override bool OnTileCollide(Vector2 oldVelocity) + { + SavedOldVelocity = oldVelocity; + Projectile.tileCollide = false; + if (!InitialTileHit) // Enter ground + { + for (int i = 0; i <= 25; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity * 3, Main.rand.NextBool() ? 207 : 216, -Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(0.3f, 0.9f), 0, default, Main.rand.NextFloat(1.3f, 1.8f)); + dust.noGravity = true; + } + Projectile.velocity = oldVelocity * 0.7f; + SoundEngine.PlaySound(SoundID.WormDig with { Volume = 1.5f, Pitch = 1.1f}, Projectile.Center); + InitialTileHit = true; + } + return false; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + for (int i = 0; i <= 5; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 32 : 216, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.1f, 0.6f), 0, default, Main.rand.NextFloat(0.4f, 0.8f)); + dust.noGravity = false; + } + if (Projectile.Calamity().stealthStrike) + { + Projectile.timeLeft = 600; + Time = 10; + TimeUnderground = 0; + PostExitTiles = false; + InitialTileHit = false; + InsideTiles = false; + Projectile.tileCollide = true; + } + } + public override void OnKill(int timeLeft) + { + for (int i = 0; i <= 25; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity, Main.rand.NextBool(3) ? 216 : 207, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.05f, 2.2f), 0, default, Main.rand.NextFloat(1.5f, 2.8f)); + dust.noGravity = true; } } - public override bool PreDraw(ref Color lightColor) { CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 2); diff --git a/Projectiles/Rogue/SeafoamBubble.cs b/Projectiles/Rogue/SeafoamBubble.cs index 32aac6aa4c..926194bd0f 100644 --- a/Projectiles/Rogue/SeafoamBubble.cs +++ b/Projectiles/Rogue/SeafoamBubble.cs @@ -50,17 +50,17 @@ namespace CalamityMod.Projectiles.Rogue Projectile.width = Projectile.height = 60; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - int num3; - for (int num246 = 0; num246 < 25; num246 = num3 + 1) + int inc; + for (int i = 0; i < 25; i = inc + 1) { - int num247 = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, 154, 0f, 0f, 0, default, 1f); - Main.dust[num247].position = (Main.dust[num247].position + Projectile.position) / 2f; - Main.dust[num247].velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - Main.dust[num247].velocity.Normalize(); - Dust dust = Main.dust[num247]; + int waterDust = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, 154, 0f, 0f, 0, default, 1f); + Main.dust[waterDust].position = (Main.dust[waterDust].position + Projectile.position) / 2f; + Main.dust[waterDust].velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + Main.dust[waterDust].velocity.Normalize(); + Dust dust = Main.dust[waterDust]; dust.velocity *= (float)Main.rand.Next(1, 30) * 0.1f; - Main.dust[num247].alpha = Projectile.alpha; - num3 = num246; + Main.dust[waterDust].alpha = Projectile.alpha; + inc = i; } } } diff --git a/Projectiles/Rogue/SearedPanProjectile.cs b/Projectiles/Rogue/SearedPanProjectile.cs index ec550b7f3a..28d7ba76c3 100644 --- a/Projectiles/Rogue/SearedPanProjectile.cs +++ b/Projectiles/Rogue/SearedPanProjectile.cs @@ -56,7 +56,8 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { // Don't increment the Seared Pan counter when hitting dummies - bool dummy = target.type != NPCID.TargetDummy && target.type != ModContent.NPCType(); + //&& target.type != ModContent.NPCType() this is here just in case its needed again + bool dummy = target.type != NPCID.TargetDummy; OnHitEffects(target.whoAmI, target.life, dummy); } diff --git a/Projectiles/Rogue/ShatteredSunKnife.cs b/Projectiles/Rogue/ShatteredSunKnife.cs index 76272ec2a9..e27b3b368d 100644 --- a/Projectiles/Rogue/ShatteredSunKnife.cs +++ b/Projectiles/Rogue/ShatteredSunKnife.cs @@ -66,55 +66,54 @@ namespace CalamityMod.Projectiles.Rogue } SoundEngine.PlaySound(SoundID.Item27, Projectile.position); Projectile.active = false; - for (int num621 = 0; num621 < 8; num621++) + for (int j = 0; j < 8; j++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dusty = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, 2f); + Main.dust[dusty].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dusty].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 16; num623++) + for (int k = 0; k < 16; k++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dusty2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, 3f); + Main.dust[dusty2].noGravity = true; + Main.dust[dusty2].velocity *= 5f; + dusty2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, 2f); + Main.dust[dusty2].velocity *= 2f; } } } if (Projectile.Calamity().stealthStrike) { - float num472 = Projectile.Center.X; - float num473 = Projectile.Center.Y; - float num474 = 600f; - for (int num475 = 0; num475 < Main.maxNPCs; num475++) + float projX = Projectile.Center.X; + float projY = Projectile.Center.Y; + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num475].CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) + if (Main.npc[i].CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[i].Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) { - float npcCenterX = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float npcCenterY = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - 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) + float npcCenterX = Main.npc[i].position.X + (float)(Main.npc[i].width / 2); + float npcCenterY = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2); + float targetDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcCenterX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcCenterY); + if (targetDist < 600f) { - if (Main.npc[num475].position.X < num472) + if (Main.npc[i].position.X < projX) { - Main.npc[num475].velocity.X += 0.25f; + Main.npc[i].velocity.X += 0.25f; } else { - Main.npc[num475].velocity.X -= 0.25f; + Main.npc[i].velocity.X -= 0.25f; } - if (Main.npc[num475].position.Y < num473) + if (Main.npc[i].position.Y < projY) { - Main.npc[num475].velocity.Y += 0.25f; + Main.npc[i].velocity.Y += 0.25f; } else { - Main.npc[num475].velocity.Y -= 0.25f; + Main.npc[i].velocity.Y -= 0.25f; } } } diff --git a/Projectiles/Rogue/ShatteredSunScorchedBlade.cs b/Projectiles/Rogue/ShatteredSunScorchedBlade.cs index e67044e5ad..36deeca44d 100644 --- a/Projectiles/Rogue/ShatteredSunScorchedBlade.cs +++ b/Projectiles/Rogue/ShatteredSunScorchedBlade.cs @@ -61,11 +61,11 @@ namespace CalamityMod.Projectiles.Rogue int timesToSpawnDust = Projectile.Calamity().stealthStrike ? 2 : 1; for (int i = 0; i < timesToSpawnDust; i++) { - int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, Projectile.Calamity().stealthStrike ? 1.8f : 1.3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, Projectile.Calamity().stealthStrike ? 1.8f : 1.3f); - Main.dust[num624].velocity *= 2f; + int dusty = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, Projectile.Calamity().stealthStrike ? 1.8f : 1.3f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].velocity *= 5f; + dusty = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, Projectile.Calamity().stealthStrike ? 1.8f : 1.3f); + Main.dust[dusty].velocity *= 2f; } } @@ -73,71 +73,69 @@ namespace CalamityMod.Projectiles.Rogue Lighting.AddLight(Projectile.Center, 0.7f, 0.3f, 0f); CalamityUtils.HomeInOnNPC(Projectile, true, 200f, 12f, 20f); - float num633; - Vector2 vector46 = Projectile.position; - bool flag25 = false; - for (int num645 = 0; num645 < Main.maxNPCs; num645++) + float targetDistStore; + Vector2 homingPos = Projectile.position; + bool isHoming = false; + for (int j = 0; j < Main.maxNPCs; j++) { - NPC nPC2 = Main.npc[num645]; + NPC nPC2 = Main.npc[j]; if (nPC2.CanBeChasedBy(Projectile, false)) { - float num646 = Vector2.Distance(nPC2.Center, Projectile.Center); - if (!flag25) + float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center); + if (!isHoming) { - num633 = num646; - vector46 = nPC2.Center; - flag25 = true; + targetDistStore = targetDist; + homingPos = nPC2.Center; + isHoming = true; } } } - if (flag25 && Projectile.ai[0] == 0f) + if (isHoming && Projectile.ai[0] == 0f) { - Vector2 vector47 = vector46 - Projectile.Center; - float num648 = vector47.Length(); - vector47.Normalize(); - if (num648 > 200f) + Vector2 homingDirection = homingPos - Projectile.Center; + float homingLength = homingDirection.Length(); + homingDirection.Normalize(); + if (homingLength > 200f) { float scaleFactor2 = 8f; - vector47 *= scaleFactor2; - Projectile.velocity = (Projectile.velocity * 40f + vector47) / 41f; + homingDirection *= scaleFactor2; + Projectile.velocity = (Projectile.velocity * 40f + homingDirection) / 41f; } else { - float num649 = 4f; - vector47 *= -num649; - Projectile.velocity = (Projectile.velocity * 40f + vector47) / 41f; + homingDirection *= -4f; + Projectile.velocity = (Projectile.velocity * 40f + homingDirection) / 41f; } } if (Projectile.Calamity().stealthStrike) { - float num472 = Projectile.Center.X; - float num473 = Projectile.Center.Y; - float num474 = 600f; - for (int num475 = 0; num475 < Main.maxNPCs; num475++) + float projX = Projectile.Center.X; + float projY = Projectile.Center.Y; + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num475].CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) + if (Main.npc[i].CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[i].Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) { - float npcCenterX = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float npcCenterY = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - 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) + float npcCenterX = Main.npc[i].position.X + (float)(Main.npc[i].width / 2); + float npcCenterY = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2); + float targetDistance = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcCenterX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcCenterY); + if (targetDistance < 600f) { - if (Main.npc[num475].position.X < num472) + if (Main.npc[i].position.X < projX) { - Main.npc[num475].velocity.X += 0.25f; + Main.npc[i].velocity.X += 0.25f; } else { - Main.npc[num475].velocity.X -= 0.25f; + Main.npc[i].velocity.X -= 0.25f; } - if (Main.npc[num475].position.Y < num473) + if (Main.npc[i].position.Y < projY) { - Main.npc[num475].velocity.Y += 0.25f; + Main.npc[i].velocity.Y += 0.25f; } else { - Main.npc[num475].velocity.Y -= 0.25f; + Main.npc[i].velocity.Y -= 0.25f; } } } @@ -213,23 +211,23 @@ namespace CalamityMod.Projectiles.Rogue Projectile.width = Projectile.height = 200; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 4; num621++) + for (int i = 0; i < 4; i++) { - int num622 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 12; num623++) + for (int j = 0; j < 12; j++) { - int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dusty = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 3f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].velocity *= 5f; + dusty = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[dusty].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) diff --git a/Projectiles/Rogue/ShroomerangSpore.cs b/Projectiles/Rogue/ShroomerangSpore.cs index d7287db62f..d60932129d 100644 --- a/Projectiles/Rogue/ShroomerangSpore.cs +++ b/Projectiles/Rogue/ShroomerangSpore.cs @@ -39,16 +39,16 @@ namespace CalamityMod.Projectiles.Rogue public override void OnKill(int timeLeft) { Projectile.ExpandHitboxBy(56); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int constant = 36; + for (int i = 0; i < constant; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 56, vector7.X, vector7.Y, 100, default, 0.5f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(i - (constant / 2 - 1)) * 6.28318548f / (float)constant), default) + Projectile.Center; + Vector2 facingDirection = rotate - Projectile.Center; + int dust = Dust.NewDust(rotate + facingDirection, 0, 0, 56, facingDirection.X, facingDirection.Y, 100, default, 0.5f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + Main.dust[dust].velocity = facingDirection; } } } diff --git a/Projectiles/Rogue/SnapClamProj.cs b/Projectiles/Rogue/SnapClamProj.cs index c82ff2cc5f..237511ddad 100644 --- a/Projectiles/Rogue/SnapClamProj.cs +++ b/Projectiles/Rogue/SnapClamProj.cs @@ -80,11 +80,11 @@ namespace CalamityMod.Projectiles.Rogue Projectile.height = 20; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num194 = 0; num194 < 20; num194++) + for (int i = 0; i < 20; i++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 14, 0f, 0f, 0, new Color(115, 124, 124), 1f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 2f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 14, 0f, 0f, 0, new Color(115, 124, 124), 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 2f; } } diff --git a/Projectiles/Rogue/SnapClamStealth.cs b/Projectiles/Rogue/SnapClamStealth.cs index bebad3c9d3..e7c64a5ca1 100644 --- a/Projectiles/Rogue/SnapClamStealth.cs +++ b/Projectiles/Rogue/SnapClamStealth.cs @@ -82,11 +82,11 @@ namespace CalamityMod.Projectiles.Rogue Projectile.height = 20; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num194 = 0; num194 < 20; num194++) + for (int i = 0; i < 20; i++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 14, 0f, 0f, 0, new Color(115, 124, 124), 1f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 2f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 14, 0f, 0f, 0, new Color(115, 124, 124), 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 2f; } } diff --git a/Projectiles/Rogue/SpearofDestinyProjectile.cs b/Projectiles/Rogue/SpearofDestinyProjectile.cs index 7515b88222..ff055dbf9b 100644 --- a/Projectiles/Rogue/SpearofDestinyProjectile.cs +++ b/Projectiles/Rogue/SpearofDestinyProjectile.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Projectiles.Rogue public int framesInAir = 0; private bool initialized = false; - public int SparkChance = 8; + public int SparkChance = 1; public override void SetDefaults() { @@ -51,20 +51,10 @@ namespace CalamityMod.Projectiles.Rogue } initialized = true; } - if (Main.rand.NextBool(SparkChance)) + if (Projectile.timeLeft % 2 == 0 && Main.rand.NextBool(SparkChance) && Projectile.numHits == 0) { - Vector2 SparkVelocity1 = Projectile.velocity.RotatedBy(-3, default) * 0.1f - Projectile.velocity / 8f; - Vector2 SparkPosition1 = Projectile.velocity.RotatedBy(-0.8, default); - SparkParticle spark = new SparkParticle(Projectile.Center + SparkPosition1, SparkVelocity1, false, Main.rand.Next(6, 8), Main.rand.NextFloat(0.7f, 1f), Color.PaleGoldenrod); + SparkParticle spark = new SparkParticle(Projectile.Center - Projectile.velocity * 0.5f, Projectile.velocity * 0.01f, false, 7, 0.7f, Color.PaleGoldenrod * 0.3f); GeneralParticleHandler.SpawnParticle(spark); - - } - if (Main.rand.NextBool(SparkChance)) - { - Vector2 SparkVelocity2 = Projectile.velocity.RotatedBy(3, default) * 0.1f - Projectile.velocity / 8f; - Vector2 SparkPosition2 = Projectile.velocity.RotatedBy(0.8, default); - SparkParticle spark2 = new SparkParticle(Projectile.Center + SparkPosition2, SparkVelocity2, false, Main.rand.Next(6, 8), Main.rand.NextFloat(0.7f, 1f), Color.PaleGoldenrod); - GeneralParticleHandler.SpawnParticle(spark2); } Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver4; @@ -91,7 +81,7 @@ namespace CalamityMod.Projectiles.Rogue if (homeIn) { - SparkChance = 16; + SparkChance = 2; Projectile.extraUpdates = 3; Vector2 moveDirection = Projectile.SafeDirectionTo(center, Vector2.UnitY); Projectile.velocity = (Projectile.velocity * 20f + moveDirection * 12f) / (21f); @@ -107,7 +97,8 @@ namespace CalamityMod.Projectiles.Rogue } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - Projectile.damage = (int)(Projectile.damage * 0.8f); + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.8f); if (Projectile.damage < 1) Projectile.damage = 1; } diff --git a/Projectiles/Rogue/SphereBladed.cs b/Projectiles/Rogue/SphereBladed.cs index de299fbf1e..586c82452a 100644 --- a/Projectiles/Rogue/SphereBladed.cs +++ b/Projectiles/Rogue/SphereBladed.cs @@ -55,56 +55,55 @@ namespace CalamityMod.Projectiles.Rogue } else { - float num42 = 16f; - float num43 = 3.2f; + float acceleration = 3.2f; Vector2 vector2 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num44 = Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2) - vector2.X; - float num45 = Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2) - vector2.Y; - float num46 = (float)Math.Sqrt((double)(num44 * num44 + num45 * num45)); - if (num46 > 3000f) + float xdistance = Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2) - vector2.X; + float ydistance = Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2) - vector2.Y; + float totalDist = (float)Math.Sqrt((double)(xdistance * xdistance + ydistance * ydistance)); + if (totalDist > 3000f) { Projectile.Kill(); } - num46 = num42 / num46; - num44 *= num46; - num45 *= num46; - if (Projectile.velocity.X < num44) + totalDist = 16f / totalDist; + xdistance *= totalDist; + ydistance *= totalDist; + if (Projectile.velocity.X < xdistance) { - Projectile.velocity.X = Projectile.velocity.X + num43; - if (Projectile.velocity.X < 0f && num44 > 0f) + Projectile.velocity.X = Projectile.velocity.X + acceleration; + if (Projectile.velocity.X < 0f && xdistance > 0f) { - Projectile.velocity.X = Projectile.velocity.X + num43; + Projectile.velocity.X = Projectile.velocity.X + acceleration; } } - else if (Projectile.velocity.X > num44) + else if (Projectile.velocity.X > xdistance) { - Projectile.velocity.X = Projectile.velocity.X - num43; - if (Projectile.velocity.X > 0f && num44 < 0f) + Projectile.velocity.X = Projectile.velocity.X - acceleration; + if (Projectile.velocity.X > 0f && xdistance < 0f) { - Projectile.velocity.X = Projectile.velocity.X - num43; + Projectile.velocity.X = Projectile.velocity.X - acceleration; } } - if (Projectile.velocity.Y < num45) + if (Projectile.velocity.Y < ydistance) { - Projectile.velocity.Y = Projectile.velocity.Y + num43; - if (Projectile.velocity.Y < 0f && num45 > 0f) + Projectile.velocity.Y = Projectile.velocity.Y + acceleration; + if (Projectile.velocity.Y < 0f && ydistance > 0f) { - Projectile.velocity.Y = Projectile.velocity.Y + num43; + Projectile.velocity.Y = Projectile.velocity.Y + acceleration; } } - else if (Projectile.velocity.Y > num45) + else if (Projectile.velocity.Y > ydistance) { - Projectile.velocity.Y = Projectile.velocity.Y - num43; - if (Projectile.velocity.Y > 0f && num45 < 0f) + Projectile.velocity.Y = Projectile.velocity.Y - acceleration; + if (Projectile.velocity.Y > 0f && ydistance < 0f) { - Projectile.velocity.Y = Projectile.velocity.Y - num43; + Projectile.velocity.Y = Projectile.velocity.Y - acceleration; } } if (Main.myPlayer == Projectile.owner) { Rectangle rectangle = new Rectangle((int)Projectile.position.X, (int)Projectile.position.Y, Projectile.width, Projectile.height); - Rectangle value2 = new Rectangle((int)Main.player[Projectile.owner].position.X, (int)Main.player[Projectile.owner].position.Y, Main.player[Projectile.owner].width, Main.player[Projectile.owner].height); - if (rectangle.Intersects(value2)) + Rectangle playerPos = new Rectangle((int)Main.player[Projectile.owner].position.X, (int)Main.player[Projectile.owner].position.Y, Main.player[Projectile.owner].width, Main.player[Projectile.owner].height); + if (rectangle.Intersects(playerPos)) { Projectile.Kill(); } diff --git a/Projectiles/Rogue/SphereBlue.cs b/Projectiles/Rogue/SphereBlue.cs index 1f648e1c91..d2b3baab45 100644 --- a/Projectiles/Rogue/SphereBlue.cs +++ b/Projectiles/Rogue/SphereBlue.cs @@ -59,14 +59,14 @@ namespace CalamityMod.Projectiles.Rogue SoundEngine.PlaySound(SoundID.NPCDeath37, Projectile.position); if (Main.netMode != NetmodeID.Server) { - for (int num625 = 0; num625 < 3; num625++) + for (int i = 0; i < 3; i++) { float scaleFactor10 = 0.33f; - if (num625 == 1) + if (i == 1) { scaleFactor10 = 0.66f; } - if (num625 == 2) + if (i == 2) { scaleFactor10 = 1f; } @@ -75,16 +75,16 @@ namespace CalamityMod.Projectiles.Rogue Main.gore[defectiveBruh].velocity += Projectile.velocity; } } - for (int num194 = 0; num194 < 25; num194++) + for (int j = 0; j < 25; j++) { int dustType = Utils.SelectRandom(Main.rand, new int[] { 226, 229 }); - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 1f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 0f; + int dusty = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 1f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].velocity *= 0f; } } diff --git a/Projectiles/Rogue/StealthNimbus.cs b/Projectiles/Rogue/StealthNimbus.cs index 6122769d21..1674c2f1f2 100644 --- a/Projectiles/Rogue/StealthNimbus.cs +++ b/Projectiles/Rogue/StealthNimbus.cs @@ -66,9 +66,9 @@ namespace CalamityMod.Projectiles.Rogue { if (Projectile.owner == Main.myPlayer) { - int num414 = (int)(Projectile.position.X + 14f + (float)Main.rand.Next(Projectile.width - 28)); - int num415 = (int)(Projectile.position.Y + (float)Projectile.height + 4f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)num414, (float)num415, 0f, 5f, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner, Projectile.ai[0], 0f); + int rainSpawnX = (int)(Projectile.position.X + 14f + (float)Main.rand.Next(Projectile.width - 28)); + int rainSpawnY = (int)(Projectile.position.Y + (float)Projectile.height + 4f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)rainSpawnX, (float)rainSpawnY, 0f, 5f, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner, Projectile.ai[0], 0f); } } } diff --git a/Projectiles/Rogue/StealthRain.cs b/Projectiles/Rogue/StealthRain.cs index 50d847212f..1e951130d1 100644 --- a/Projectiles/Rogue/StealthRain.cs +++ b/Projectiles/Rogue/StealthRain.cs @@ -46,8 +46,8 @@ namespace CalamityMod.Projectiles.Rogue { int dustType = Projectile.ai[0] == 0f ? 14 : 114; - int num310 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + (float)Projectile.height - 2f), 2, 2, dustType, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num310]; + int dusty = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + (float)Projectile.height - 2f), 2, 2, dustType, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[dusty]; dust.position.X -= 2f; dust.alpha = 38; dust.velocity *= 0.1f; diff --git a/Projectiles/Rogue/Stormfrontspark.cs b/Projectiles/Rogue/Stormfrontspark.cs index 054880e784..7ff2737dba 100644 --- a/Projectiles/Rogue/Stormfrontspark.cs +++ b/Projectiles/Rogue/Stormfrontspark.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { Projectile.rotation += Projectile.velocity.X * 0.1f; - int num199 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 226, 0f, 0f, 100, new Color(Main.rand.Next(20, 100), 204, 250), 1f); - Dust dust = Main.dust[num199]; + int dusty = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 226, 0f, 0f, 100, new Color(Main.rand.Next(20, 100), 204, 250), 1f); + Dust dust = Main.dust[dusty]; dust.position.X -= 1f; dust.position.Y -= 1f; dust.scale += (float)Main.rand.Next(50) * 0.01f; @@ -30,8 +30,8 @@ namespace CalamityMod.Projectiles.Rogue dust.velocity.Y += 1f; if (Main.rand.NextBool()) { - int num200 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 226, 0f, 0f, 100, new Color(Main.rand.Next(20, 100), 204, 250), 1f); - Dust dust2 = Main.dust[num200]; + int dusty2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 226, 0f, 0f, 100, new Color(Main.rand.Next(20, 100), 204, 250), 1f); + Dust dust2 = Main.dust[dusty2]; dust2.position.X += 1f; dust2.position.Y -= 1f; dust2.scale += 0.2f + (float)Main.rand.Next(50) * 0.01f; diff --git a/Projectiles/Rogue/SupernovaBomb.cs b/Projectiles/Rogue/SupernovaBomb.cs index 529ffe29c5..8c8905ade3 100644 --- a/Projectiles/Rogue/SupernovaBomb.cs +++ b/Projectiles/Rogue/SupernovaBomb.cs @@ -34,14 +34,14 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { //dust and lighting - int num298 = Main.rand.NextBool() ? 107 : 234; + int dustType = Main.rand.NextBool() ? 107 : 234; if (Main.rand.NextBool(4)) { - num298 = 269; + dustType = 269; } if (Main.rand.NextBool(6)) { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, num298, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); + Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); } Lighting.AddLight(Projectile.Center, Main.DiscoR * 0.5f / 255f, Main.DiscoG * 0.5f / 255f, Main.DiscoB * 0.5f / 255f); diff --git a/Projectiles/Rogue/SupernovaHoming.cs b/Projectiles/Rogue/SupernovaHoming.cs index 4b74d65aa0..a9793a17b9 100644 --- a/Projectiles/Rogue/SupernovaHoming.cs +++ b/Projectiles/Rogue/SupernovaHoming.cs @@ -22,16 +22,15 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - int num154 = 14; - int num298 = Main.rand.NextBool() ? 107 : 234; + int dustType = Main.rand.NextBool() ? 107 : 234; if (Main.rand.NextBool(4)) { - num298 = 269; + dustType = 269; } Projectile.ai[0] += 1; if (Projectile.ai[0] % 2 == 0) { - int coolDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - num154 * 2, Projectile.height - num154 * 2, num298, 0f, 0f, 100, default, 1.5f); + int coolDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - 28, Projectile.height - 28, dustType, 0f, 0f, 100, default, 1.5f); Main.dust[coolDust].noGravity = true; Main.dust[coolDust].velocity *= 0.1f; Main.dust[coolDust].velocity += Projectile.velocity * 0.5f; @@ -86,14 +85,14 @@ namespace CalamityMod.Projectiles.Rogue Projectile.width = Projectile.height = 24; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int constant = 36; + for (int i = 0; i < constant; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 234, vector7.X * 0.5f, vector7.Y * 0.5f, 100, default, 0.75f); - Main.dust[num228].noGravity = true; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(i - (constant / 2 - 1)) * 6.28318548f / (float)constant), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int dust = Dust.NewDust(rotate + faceDirection, 0, 0, 234, faceDirection.X * 0.5f, faceDirection.Y * 0.5f, 100, default, 0.75f); + Main.dust[dust].noGravity = true; } } diff --git a/Projectiles/Rogue/SupernovaSpike.cs b/Projectiles/Rogue/SupernovaSpike.cs index 9ee03b2f62..d9c403468d 100644 --- a/Projectiles/Rogue/SupernovaSpike.cs +++ b/Projectiles/Rogue/SupernovaSpike.cs @@ -37,17 +37,17 @@ namespace CalamityMod.Projectiles.Rogue { Projectile.alpha = 0; } - int num298 = Main.rand.NextBool() ? 107 : 234; + int dustType = Main.rand.NextBool() ? 107 : 234; if (Main.rand.NextBool(4)) { - num298 = 269; + dustType = 269; } Projectile.localAI[1] += 1f; if (Projectile.localAI[1] > 4f) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num298, 0f, 0f, 100, default, 0.75f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int theDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 0.75f); + Main.dust[theDust].noGravity = true; + Main.dust[theDust].velocity *= 0f; } if (currentColor == Color.Black) { @@ -94,28 +94,28 @@ namespace CalamityMod.Projectiles.Rogue Projectile.width = Projectile.height = 32; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - int num298 = Main.rand.NextBool() ? 107 : 234; + int dustType = Main.rand.NextBool() ? 107 : 234; if (Main.rand.NextBool(4)) { - num298 = 269; + dustType = 269; } - for (int num621 = 0; num621 < 2; num621++) + for (int i = 0; i < 2; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num298, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 1.2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 2; num623++) + for (int j = 0; j < 2; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); + Main.dust[dust2].velocity *= 2f; } } } diff --git a/Projectiles/Rogue/TimeBoltKnife.cs b/Projectiles/Rogue/TimeBoltKnife.cs index 5ed5f25a46..6f82034099 100644 --- a/Projectiles/Rogue/TimeBoltKnife.cs +++ b/Projectiles/Rogue/TimeBoltKnife.cs @@ -73,10 +73,10 @@ namespace CalamityMod.Projectiles.Rogue 229 }); Vector2 center = Projectile.Center; - Vector2 vector74 = new Vector2(-4f, 4f); - vector74 += new Vector2(-4f, 4f); - vector74 = vector74.RotatedBy((double)Projectile.rotation, default); - int dust = Dust.NewDust(center + vector74 + Vector2.One * -4f, 8, 8, dustType, 0f, 0f, 100, default, 1f); + Vector2 fourVector = new Vector2(-4f, 4f); + fourVector += new Vector2(-4f, 4f); + fourVector = fourVector.RotatedBy((double)Projectile.rotation, default); + int dust = Dust.NewDust(center + fourVector + Vector2.One * -4f, 8, 8, dustType, 0f, 0f, 100, default, 1f); Dust dust2 = Main.dust[dust]; dust2.velocity *= 0.1f; if (Main.rand.Next(6) != 0) @@ -166,10 +166,10 @@ namespace CalamityMod.Projectiles.Rogue 229 }); Vector2 center = Projectile.Center; - Vector2 vector75 = new Vector2(-4f, 4f); - vector75 += new Vector2(-4f, 4f); - vector75 = vector75.RotatedBy((double)Projectile.rotation, default); - int dust = Dust.NewDust(center + vector75 + Vector2.One * -4f, 8, 8, dustType, 0f, 0f, 100, default, 0.6f); + Vector2 otherFourVector = new Vector2(-4f, 4f); + otherFourVector += new Vector2(-4f, 4f); + otherFourVector = otherFourVector.RotatedBy((double)Projectile.rotation, default); + int dust = Dust.NewDust(center + otherFourVector + Vector2.One * -4f, 8, 8, dustType, 0f, 0f, 100, default, 0.6f); Dust dust2 = Main.dust[dust]; dust2.velocity *= 0.1f; dust2.noGravity = true; @@ -208,10 +208,10 @@ namespace CalamityMod.Projectiles.Rogue 229 }); Vector2 center = Projectile.Center; - Vector2 vector76 = new Vector2(-4f, 4f); - vector76 += new Vector2(-4f, 4f); - vector76 = vector76.RotatedBy((double)Projectile.rotation, default); - int dust = Dust.NewDust(center + vector76 + Vector2.One * -4f, 8, 8, dustType, 0f, 0f, 100, default, 0.6f); + Vector2 thirdFourVector = new Vector2(-4f, 4f); + thirdFourVector += new Vector2(-4f, 4f); + thirdFourVector = thirdFourVector.RotatedBy((double)Projectile.rotation, default); + int dust = Dust.NewDust(center + thirdFourVector + Vector2.One * -4f, 8, 8, dustType, 0f, 0f, 100, default, 0.6f); Dust dust2 = Main.dust[dust]; dust2.velocity *= 0.1f; dust2.noGravity = true; diff --git a/Projectiles/Rogue/TwistingThunderProj.cs b/Projectiles/Rogue/TwistingThunderProj.cs index 12c854d5a6..203938dc98 100644 --- a/Projectiles/Rogue/TwistingThunderProj.cs +++ b/Projectiles/Rogue/TwistingThunderProj.cs @@ -96,6 +96,7 @@ namespace CalamityMod.Projectiles.Rogue //Does not force to Rogue because lightning is extremely abusable with Moonstone Crown Main.projectile[proj].friendly = true; Main.projectile[proj].hostile = false; + Main.projectile[proj].tileCollide = false; Main.projectile[proj].penetrate = -1; Main.projectile[proj].usesLocalNPCImmunity = true; Main.projectile[proj].localNPCHitCooldown = -1; diff --git a/Projectiles/Rogue/ValedictionBoomerang.cs b/Projectiles/Rogue/ValedictionBoomerang.cs index c47b107e66..85aa061e64 100644 --- a/Projectiles/Rogue/ValedictionBoomerang.cs +++ b/Projectiles/Rogue/ValedictionBoomerang.cs @@ -146,7 +146,7 @@ namespace CalamityMod.Projectiles.Rogue } velocity.Normalize(); velocity *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile typhoon = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), typhoonDamage, 0f, Projectile.owner); + Projectile typhoon = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), typhoonDamage, 0f, Projectile.owner, 0f, 1f); if (typhoon.whoAmI.WithinBounds(Main.maxProjectiles)) { typhoon.DamageType = RogueDamageClass.Instance; diff --git a/Projectiles/Rogue/WrathwingSpear.cs b/Projectiles/Rogue/WrathwingSpear.cs index 8475f4a5cc..83b5a1614f 100644 --- a/Projectiles/Rogue/WrathwingSpear.cs +++ b/Projectiles/Rogue/WrathwingSpear.cs @@ -32,15 +32,15 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - // Spit fireballs constantly, but slightly randomly. Always spits one fireball immediately upon being thrown. + // Spit fireballs constantly. Always spits one fireball immediately upon being thrown. if (Projectile.owner == Main.myPlayer && Projectile.ai[0] <= 0f) { - Projectile.ai[0] = Main.rand.NextFloat(15f, 19f); + Projectile.ai[0] = 20f; int fireballID = ModContent.ProjectileType(); - int damage = (int)(Projectile.damage * 0.8f); + int damage = (int)(Projectile.damage * 0.7f); float angleDiff = Main.rand.NextFloat(-FireballAngleVariance, FireballAngleVariance); - Vector2 velocity = Projectile.velocity.RotatedBy(angleDiff) * 1.06f; + Vector2 velocity = Projectile.velocity.RotatedBy(angleDiff) * 1.04f; float kb = Projectile.knockBack * 0.6f; Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, fireballID, damage, kb, Projectile.owner); } @@ -49,7 +49,7 @@ namespace CalamityMod.Projectiles.Rogue // Homing // The item's default velocity is 28. Homing speed is intentionally a bit lower. - CalamityUtils.HomeInOnNPC(Projectile, true, 450f, 23f, 30f); + CalamityUtils.HomeInOnNPC(Projectile, true, 450f, 24f, 30f); // Animation Projectile.frameCounter++; @@ -74,8 +74,8 @@ namespace CalamityMod.Projectiles.Rogue int damage = (int)(Projectile.damage * 0.375f); float kb = 0f; - // Spawns 13 erupting fireballs in total. - for (int x = -6; x <= 6; x++) + // Spawns 11 erupting fireballs in total. + for (int x = -5; x <= 5; x++) { Vector2 pos = Projectile.Center + Vector2.UnitY * Main.rand.NextFloat(44f, 60f); pos.X += Main.rand.NextFloat(-14f, 14f); diff --git a/Projectiles/Summon/AngelBolt.cs b/Projectiles/Summon/AngelBolt.cs index 1ff209a247..aaedab1f12 100644 --- a/Projectiles/Summon/AngelBolt.cs +++ b/Projectiles/Summon/AngelBolt.cs @@ -30,14 +30,14 @@ namespace CalamityMod.Projectiles.Summon { if (Projectile.timeLeft % 2f == 0f) { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * 0.25f; - int num448 = Dust.NewDust(vector33, 1, 1, (int)CalamityDusts.ProfanedFire, 0f, 0f, 0, default, 1.25f); - Main.dust[num448].position = vector33; - Main.dust[num448].noGravity = true; - Main.dust[num448].noLight = true; - Main.dust[num448].scale = Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.1f; + Vector2 dustPos = Projectile.position; + dustPos -= Projectile.velocity * 0.25f; + int dust = Dust.NewDust(dustPos, 1, 1, (int)CalamityDusts.ProfanedFire, 0f, 0f, 0, default, 1.25f); + Main.dust[dust].position = dustPos; + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + Main.dust[dust].scale = Main.rand.Next(70, 110) * 0.013f; + Main.dust[dust].velocity *= 0.1f; } } diff --git a/Projectiles/Summon/ApexShark.cs b/Projectiles/Summon/ApexShark.cs index d0d08afa37..583c47f688 100644 --- a/Projectiles/Summon/ApexShark.cs +++ b/Projectiles/Summon/ApexShark.cs @@ -13,7 +13,6 @@ namespace CalamityMod.Projectiles.Summon public class ApexShark : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Summon"; - public override string Texture => "CalamityMod/Projectiles/Ranged/SandyWaifuShark"; private int HitCooldown = 0; public override void SetStaticDefaults() @@ -48,15 +47,15 @@ namespace CalamityMod.Projectiles.Summon Player player = Main.player[Projectile.owner]; if (Projectile.localAI[0] == 0f) { - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int constant = 36; + for (int i = 0; i < constant; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 85, vector7.X * 1.75f, vector7.Y * 1.75f, 100, default, 1.1f); - Main.dust[num228].noGravity = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(i - (constant / 2 - 1)) * 6.28318548f / (float)constant), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int ancientDust = Dust.NewDust(rotate + faceDirection, 0, 0, 85, faceDirection.X * 1.75f, faceDirection.Y * 1.75f, 100, default, 1.1f); + Main.dust[ancientDust].noGravity = true; + Main.dust[ancientDust].velocity = faceDirection; } Projectile.localAI[0]++; } @@ -70,15 +69,12 @@ namespace CalamityMod.Projectiles.Summon { Projectile.frame = 0; } - float num633 = 1200f; - float num634 = 1500f; - float num635 = 2200f; - float num636 = 150f; - bool flag64 = Projectile.type == ModContent.ProjectileType(); + float maxTargetDist = 1200f; + bool isProjectile = Projectile.type == ModContent.ProjectileType(); CalamityPlayer modPlayer = player.Calamity(); player.AddBuff(ModContent.BuffType(), 3600); - if (flag64) + if (isProjectile) { if (player.dead) { @@ -90,7 +86,7 @@ namespace CalamityMod.Projectiles.Summon } } Projectile.MinionAntiClump(); - bool flag24 = false; + bool decelerate = false; if (Projectile.ai[0] == 2f) { Projectile.ai[1] += 1f; @@ -105,109 +101,108 @@ namespace CalamityMod.Projectiles.Summon } else { - flag24 = true; + decelerate = true; } } - if (flag24) + if (decelerate) { return; } - Vector2 vector46 = Projectile.position; - bool flag25 = false; + Vector2 projPos = Projectile.position; + bool canAttack = false; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(Projectile, false)) { - float num646 = Vector2.Distance(npc.Center, Projectile.Center); - if (!flag25 && num646 < num633) + float targetDist = Vector2.Distance(npc.Center, Projectile.Center); + if (!canAttack && targetDist < maxTargetDist) { - num633 = num646; - vector46 = npc.Center; - flag25 = true; + maxTargetDist = targetDist; + projPos = npc.Center; + canAttack = true; } } } - if (!flag25) + if (!canAttack) { - for (int num645 = 0; num645 < Main.maxNPCs; num645++) + for (int i = 0; i < Main.maxNPCs; i++) { - NPC nPC2 = Main.npc[num645]; + NPC nPC2 = Main.npc[i]; if (nPC2.CanBeChasedBy(Projectile, false)) { - float num646 = Vector2.Distance(nPC2.Center, Projectile.Center); - if (!flag25 && num646 < num633) + float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center); + if (!canAttack && targetDist < maxTargetDist) { - num633 = num646; - vector46 = nPC2.Center; - flag25 = true; + maxTargetDist = targetDist; + projPos = nPC2.Center; + canAttack = true; } } } } - float num647 = num634; - if (flag25) + float separationAnxietyRange = 1500f; + if (canAttack) { - num647 = num635; + separationAnxietyRange = 2200f; } - if (Vector2.Distance(player.Center, Projectile.Center) > num647) + if (Vector2.Distance(player.Center, Projectile.Center) > separationAnxietyRange) { Projectile.ai[0] = 1f; Projectile.netUpdate = true; } - if (flag25 && Projectile.ai[0] == 0f) + if (canAttack && Projectile.ai[0] == 0f) { - Vector2 vector47 = vector46 - Projectile.Center; - float num648 = vector47.Length(); - vector47.Normalize(); - if (num648 > 200f) + Vector2 projDirection = projPos - Projectile.Center; + float projDistance = projDirection.Length(); + projDirection.Normalize(); + if (projDistance > 200f) { float scaleFactor2 = 13f; //8 - vector47 *= scaleFactor2; - Projectile.velocity = (Projectile.velocity * 40f + vector47) / 41f; + projDirection *= scaleFactor2; + Projectile.velocity = (Projectile.velocity * 40f + projDirection) / 41f; } else { - float num649 = 6f; - vector47 *= -num649; - Projectile.velocity = (Projectile.velocity * 40f + vector47) / 41f; + projDirection *= -6f; + Projectile.velocity = (Projectile.velocity * 40f + projDirection) / 41f; } } else { - bool flag26 = false; - if (!flag26) + bool isReturning = false; + if (!isReturning) { - flag26 = Projectile.ai[0] == 1f; + isReturning = Projectile.ai[0] == 1f; } - float num650 = 10f; - if (flag26) + float returnSpeed = 10f; + if (isReturning) { - num650 = 21f; + returnSpeed = 21f; } Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2 + new Vector2(0f, -60f); - float num651 = vector48.Length(); - if (num651 > 200f && num650 < 8f) + Vector2 playerDirection = player.Center - center2 + new Vector2(0f, -60f); + float playerDistance = playerDirection.Length(); + if (playerDistance > 200f && returnSpeed < 8f) { - num650 = 1f; + returnSpeed = 1f; } - if (num651 < num636 && flag26 && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + if (playerDistance < 150f && isReturning && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) { Projectile.ai[0] = 0f; Projectile.netUpdate = true; } - if (num651 > 2000f) + if (playerDistance > 2000f) { Projectile.position.X = Main.player[Projectile.owner].Center.X - (float)(Projectile.width / 2); Projectile.position.Y = Main.player[Projectile.owner].Center.Y - (float)(Projectile.height / 2); Projectile.netUpdate = true; } - if (num651 > 70f) + if (playerDistance > 70f) { - vector48.Normalize(); - vector48 *= num650; - Projectile.velocity = (Projectile.velocity * 40f + vector48) / 41f; + playerDirection.Normalize(); + playerDirection *= returnSpeed; + Projectile.velocity = (Projectile.velocity * 40f + playerDirection) / 41f; } else if (Projectile.velocity.X == 0f && Projectile.velocity.Y == 0f) { @@ -228,15 +223,15 @@ namespace CalamityMod.Projectiles.Summon } if (Projectile.ai[0] == 0f) { - if (Projectile.ai[1] == 0f && flag25 && num633 < 500f) + if (Projectile.ai[1] == 0f && canAttack && maxTargetDist < 500f) { Projectile.ai[1] += 1f; if (Main.myPlayer == Projectile.owner) { Projectile.ai[0] = 2f; - Vector2 value20 = vector46 - Projectile.Center; - value20.Normalize(); - Projectile.velocity = value20 * 13f; //8 + Vector2 npcCenter = projPos - Projectile.Center; + npcCenter.Normalize(); + Projectile.velocity = npcCenter * 13f; //8 Projectile.netUpdate = true; } } diff --git a/Projectiles/Ranged/SandyWaifuShark.png b/Projectiles/Summon/ApexShark.png similarity index 100% rename from Projectiles/Ranged/SandyWaifuShark.png rename to Projectiles/Summon/ApexShark.png diff --git a/Projectiles/Summon/AquasScepterCloud.cs b/Projectiles/Summon/AquasScepterCloud.cs index 02950e2294..29558b9a37 100644 --- a/Projectiles/Summon/AquasScepterCloud.cs +++ b/Projectiles/Summon/AquasScepterCloud.cs @@ -3,6 +3,9 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon @@ -10,20 +13,16 @@ namespace CalamityMod.Projectiles.Summon public class AquasScepterCloud : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Summon"; + Texture2D flashTex = ModContent.Request("CalamityMod/Projectiles/Summon/AquasScepterCloudFlash").Value; + Texture2D glowTex = ModContent.Request("CalamityMod/Projectiles/Summon/AquasScepterCloudGlowmask").Value; public ref float LightningTimer => ref Projectile.ai[0]; public ref float RainTimer => ref Projectile.ai[1]; public int DrawFlashTimer = 0; - public override void SetStaticDefaults() - { - // Sets the amount of frames this minion has on its spritesheet - Main.projFrames[Projectile.type] = 5; - } - public sealed override void SetDefaults() { - Projectile.width = 252; - Projectile.height = 78; + Projectile.width = 238; + Projectile.height = 98; Projectile.hide = true; Projectile.tileCollide = false; Projectile.timeLeft = Projectile.SentryLifeTime; @@ -31,7 +30,6 @@ namespace CalamityMod.Projectiles.Summon Projectile.sentry = true; Projectile.DamageType = DamageClass.Summon; Projectile.penetrate = -1; - Projectile.light = 1f; } public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) @@ -41,12 +39,7 @@ namespace CalamityMod.Projectiles.Summon } public override bool? CanDamage() => false; - - public override Color? GetAlpha(Color drawColor) - { - return Color.White; - } - + public override Color? GetAlpha(Color lightColor) => Color.White; public override void AI() { float distanceFromTarget = 700f; @@ -56,18 +49,9 @@ namespace CalamityMod.Projectiles.Summon LightningTimer++; RainTimer++; - Projectile.frameCounter++; - if (Projectile.frameCounter >= 6) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame >= Main.projFrames[Projectile.type]) - Projectile.frame = 0; - if (RainTimer >= 3f) // Spawns a raindrop every 3 frames, displaced down and randomly along the length of the cloud { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), (Projectile.Center.X + Main.rand.Next(-110, 111)), (Projectile.Center.Y + 57f), 0f, 15f, ModContent.ProjectileType(), Projectile.damage, 0, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), (Projectile.Center.X + Main.rand.Next(-100, 101)), (Projectile.Bottom.Y + 24f), 0f, 15f, ModContent.ProjectileType(), Projectile.damage, 0, Projectile.owner); RainTimer = 0f; } @@ -97,8 +81,8 @@ namespace CalamityMod.Projectiles.Summon { if (LightningTimer >= 60f) //Every 60 AI cycles, plays the lightning sound and spawns 2 projectiles: the tesla aura for dealing damage in an aoe, and the cloud flash to simulate the brightness of the main cloud changing. { - SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/LightningAura")); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(Projectile.damage * 7.2f), 16, Projectile.owner); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/LightningAura"), Projectile.Center); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Bottom.Y, 0f, 0f, ModContent.ProjectileType(), (int)(Projectile.damage * 7.2f), 16, Projectile.owner); LightningTimer = 0f; DrawFlashTimer = 27; } @@ -107,12 +91,36 @@ namespace CalamityMod.Projectiles.Summon } public override void PostDraw(Color lightColor) { - if (DrawFlashTimer > 0) + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix); + + MiscShaderData msd = GameShaders.Misc["CalamityMod:WavyOpacity"]; + msd.SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/BlobbyNoise"), 1); + msd.UseOpacity(0.7f); + DrawData dd = new() { - Texture2D texture = ModContent.Request("CalamityMod/Projectiles/Summon/AquasScepterCloudFlash").Value; - lightColor *= 1f - ((27 - DrawFlashTimer) / 27f); - Vector2 drawPosition = Projectile.position - Main.screenPosition + (texture.Size() * 0.5f); - Main.EntitySpriteDraw(texture, drawPosition, null, lightColor, 0f, texture.Size() * 0.5f, 1f, SpriteEffects.None); + texture = glowTex, + position = Projectile.position - Main.screenPosition, + sourceRect = glowTex.Bounds, + }; + msd.Apply(dd); + Vector2 glowPos = Projectile.position - Main.screenPosition + (glowTex.Size() * 0.5f); + Main.EntitySpriteDraw(glowTex, glowPos, null, dd.color, 0f, glowTex.Size() * 0.5f, 1f, SpriteEffects.None); + Main.spriteBatch.End(); + Main.spriteBatch.Begin(); + + if (Main.rand.NextBool(240)) + { + DrawFlashTimer += Main.rand.Next(15, 23); + if (DrawFlashTimer > 27) + DrawFlashTimer = 27; + } + + if (DrawFlashTimer > 0) + { + float opacity = 1f - ((27 - DrawFlashTimer) / 27f); + Vector2 drawPosition = Projectile.position - Main.screenPosition + (flashTex.Size() * 0.5f); + Main.EntitySpriteDraw(flashTex, drawPosition, null, Color.White * opacity, 0f, flashTex.Size() * 0.5f, 1f, SpriteEffects.None); DrawFlashTimer--; } } diff --git a/Projectiles/Summon/AquasScepterCloud.png b/Projectiles/Summon/AquasScepterCloud.png index f51a5db6ae..6c8b2b1a41 100644 Binary files a/Projectiles/Summon/AquasScepterCloud.png and b/Projectiles/Summon/AquasScepterCloud.png differ diff --git a/Projectiles/Summon/AquasScepterCloudFlash.png b/Projectiles/Summon/AquasScepterCloudFlash.png index d2deca9c47..00e6bdf029 100644 Binary files a/Projectiles/Summon/AquasScepterCloudFlash.png and b/Projectiles/Summon/AquasScepterCloudFlash.png differ diff --git a/Projectiles/Summon/AquasScepterCloudGlowmask.png b/Projectiles/Summon/AquasScepterCloudGlowmask.png new file mode 100644 index 0000000000..9158e5829e Binary files /dev/null and b/Projectiles/Summon/AquasScepterCloudGlowmask.png differ diff --git a/Projectiles/Summon/AquasScepterRaindrop.png b/Projectiles/Summon/AquasScepterRaindrop.png index 78df290d74..6979f00d85 100644 Binary files a/Projectiles/Summon/AquasScepterRaindrop.png and b/Projectiles/Summon/AquasScepterRaindrop.png differ diff --git a/Projectiles/Summon/AquasScepterTeslaAura.cs b/Projectiles/Summon/AquasScepterTeslaAura.cs index cf376ff9b3..5892dc33aa 100644 --- a/Projectiles/Summon/AquasScepterTeslaAura.cs +++ b/Projectiles/Summon/AquasScepterTeslaAura.cs @@ -29,9 +29,11 @@ namespace CalamityMod.Projectiles.Summon Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 28; Projectile.alpha = 0; + Projectile.spriteDirection = Main.rand.NextBool() ? -1 : 1; } public override bool? CanDamage() => ableToHit ? (bool?)null : false; + public override Color? GetAlpha(Color lightColor) => Color.White * (1 - (Projectile.alpha / 255f)); public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, (TeslaAuraScale * 96.0f), targetHitbox); @@ -46,13 +48,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.ai[0]++; Projectile.frameCounter++; - if (Projectile.frameCounter >= 4) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame >= Main.projFrames[Projectile.type]) - Projectile.frame = 0; + Projectile.frame = (int)(Projectile.frameCounter / 5.4f); if (Projectile.ai[0] > 8f) //After the Tesla Aura has been alive for 8 frames, disables it's ability to deal damage. This is done so that there is some leniency on allowing new enemies to enter the damaging range for a bit to make the sentry feel better to use. { diff --git a/Projectiles/Summon/AstrageldonSummon.cs b/Projectiles/Summon/AstrageldonSummon.cs index af0408810a..5bb58587ae 100644 --- a/Projectiles/Summon/AstrageldonSummon.cs +++ b/Projectiles/Summon/AstrageldonSummon.cs @@ -71,22 +71,22 @@ namespace CalamityMod.Projectiles.Summon int dustAmt = 16; for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(dustIndex - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int dusty = Dust.NewDust(vector6 + vector7, 0, 0, ModContent.DustType(), vector7.X * 1f, vector7.Y * 1f, 100, default, 1.1f); + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(dustIndex - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int dusty = Dust.NewDust(rotate + faceDirection, 0, 0, ModContent.DustType(), faceDirection.X * 1f, faceDirection.Y * 1f, 100, default, 1.1f); Main.dust[dusty].noGravity = true; Main.dust[dusty].noLight = true; - Main.dust[dusty].velocity = vector7; + Main.dust[dusty].velocity = faceDirection; } dust = true; } //Bool setup - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isSummon = Projectile.type == ModContent.ProjectileType(); player.AddBuff(ModContent.BuffType(), 3600); - if (flag64) + if (isSummon) { if (player.dead) { @@ -123,9 +123,9 @@ namespace CalamityMod.Projectiles.Summon } else { - for (int num645 = 0; num645 < Main.npc.Length; num645++) + for (int i = 0; i < Main.npc.Length; i++) { - NPC npc = Main.npc[num645]; + NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false)) { bool lineOfSight = Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height); @@ -151,32 +151,31 @@ namespace CalamityMod.Projectiles.Summon float scaleAddition = Projectile.scale * 5f; if (teleportCounter <= 0 && teleportRange >= 800f) { - float num461 = 50f; - int num462 = 0; - while ((float)num462 < num461) + int counter = 0; + while ((float)counter < 50f) { int dustType = Utils.SelectRandom(Main.rand, new int[] { ModContent.DustType(), ModContent.DustType() }); - float num463 = Main.rand.Next(-10, 11); - float num464 = Main.rand.Next(-10, 11); - float num465 = Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[num467]; + float rand1 = Main.rand.Next(-10, 11); + float rand2 = Main.rand.Next(-10, 11); + float rand3 = Main.rand.Next(3, 9); + float randAdjust = (float)Math.Sqrt((double)(rand1 * rand1 + rand2 * rand2)); + randAdjust = rand3 / randAdjust; + rand1 *= randAdjust; + rand2 *= randAdjust; + int astralDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[astralDust]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += Main.rand.Next(-10, 11); dust.position.Y += Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = rand1; + dust.velocity.Y = rand2; + counter++; } Projectile.position.X = objectivepos.X - (float)(Projectile.width / 2) + Main.rand.NextFloat(-100f, 100f); Projectile.position.Y = objectivepos.Y - (float)(Projectile.height / 2) - Main.rand.NextFloat(0f + scaleAddition, 200f + scaleAddition); diff --git a/Projectiles/Summon/AureusBomber.cs b/Projectiles/Summon/AureusBomber.cs index 7805e9bc61..81efca5f8b 100644 --- a/Projectiles/Summon/AureusBomber.cs +++ b/Projectiles/Summon/AureusBomber.cs @@ -47,16 +47,16 @@ namespace CalamityMod.Projectiles.Summon //on spawn effects && minion flexibility if (Projectile.localAI[0] == 0f) { - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int constant = 36; + for (int i = 0; i < constant; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, dustType, vector7.X * 1.5f, vector7.Y * 1.5f, 100, default, 1.4f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(i - (constant / 2 - 1)) * 6.28318548f / (float)constant), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int astralDust = Dust.NewDust(rotate + faceDirection, 0, 0, dustType, faceDirection.X * 1.5f, faceDirection.Y * 1.5f, 100, default, 1.4f); + Main.dust[astralDust].noGravity = true; + Main.dust[astralDust].noLight = true; + Main.dust[astralDust].velocity = faceDirection; } Projectile.localAI[0] += 1f; } @@ -234,18 +234,18 @@ namespace CalamityMod.Projectiles.Summon Projectile.localNPCHitCooldown = 10; Projectile.Damage(); SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - for (int num193 = 0; num193 < 2; num193++) + for (int j = 0; j < 2; j++) { Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 50, default, 1f); } - for (int num194 = 0; num194 < 20; num194++) + for (int k = 0; k < 20; k++) { - int num195 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 0, default, 1.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 50, default, 1f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int moreAstralDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 0, default, 1.5f); + Main.dust[moreAstralDust].noGravity = true; + Main.dust[moreAstralDust].velocity *= 3f; + moreAstralDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, ModContent.DustType(), 0f, 0f, 50, default, 1f); + Main.dust[moreAstralDust].velocity *= 2f; + Main.dust[moreAstralDust].noGravity = true; } } diff --git a/Projectiles/Summon/BabyBloodCrawler.cs b/Projectiles/Summon/BabyBloodCrawler.cs index a2a877dff9..93babecfea 100644 --- a/Projectiles/Summon/BabyBloodCrawler.cs +++ b/Projectiles/Summon/BabyBloodCrawler.cs @@ -65,22 +65,22 @@ namespace CalamityMod.Projectiles.Summon if (dust == 0f) { - int num226 = 16; - for (int num227 = 0; num227 < num226; num227++) + int constant = 16; + for (int i = 0; i < constant; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 5, vector7.X * 1f, vector7.Y * 1f, 100, default, 1.1f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(i - (constant / 2 - 1)) * 6.28318548f / (float)constant), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int bloody = Dust.NewDust(rotate + faceDirection, 0, 0, 5, faceDirection.X * 1f, faceDirection.Y * 1f, 100, default, 1.1f); + Main.dust[bloody].noGravity = true; + Main.dust[bloody].noLight = true; + Main.dust[bloody].velocity = faceDirection; } dust += 1f; } - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isMinion = Projectile.type == ModContent.ProjectileType(); player.AddBuff(ModContent.BuffType(), 3600); - if (flag64) + if (isMinion) { if (player.dead) { diff --git a/Projectiles/Summon/BabyPlaguebringer.cs b/Projectiles/Summon/BabyPlaguebringer.cs index 747465f19f..c2e73d0f19 100644 --- a/Projectiles/Summon/BabyPlaguebringer.cs +++ b/Projectiles/Summon/BabyPlaguebringer.cs @@ -43,17 +43,14 @@ namespace CalamityMod.Projectiles.Summon { Projectile.spriteDirection = -Projectile.direction; } - float num633 = 800f; - float num634 = 1200f; - float num635 = 3000f; - float num636 = 500f; + float maxTargetDist = 800f; //lighting - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight(Projectile.Center, 0f * num, 0.75f * num, 0f * num); + float lights = (float)Main.rand.Next(90, 111) * 0.01f; + lights *= Main.essScale; + Lighting.AddLight(Projectile.Center, 0f * lights, 0.75f * lights, 0f * lights); - bool flag24 = false; + bool decelerate = false; if (Projectile.ai[0] == 2f) { Projectile.ai[1] += 1f; @@ -78,109 +75,108 @@ namespace CalamityMod.Projectiles.Summon } else { - flag24 = true; + decelerate = true; } } - if (flag24) + if (decelerate) { return; } - Vector2 vector46 = Projectile.position; - bool flag25 = false; + Vector2 projPos = Projectile.position; + bool canAttack = false; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(Projectile, false)) { - float num646 = Vector2.Distance(npc.Center, Projectile.Center); - if (!flag25 && num646 < num633) + float targetDist = Vector2.Distance(npc.Center, Projectile.Center); + if (!canAttack && targetDist < maxTargetDist) { - num633 = num646; - vector46 = npc.Center; - flag25 = true; + maxTargetDist = targetDist; + projPos = npc.Center; + canAttack = true; } } } - if (!flag25) + if (!canAttack) { - for (int num645 = 0; num645 < Main.maxNPCs; num645++) + for (int i = 0; i < Main.maxNPCs; i++) { - NPC nPC2 = Main.npc[num645]; + NPC nPC2 = Main.npc[i]; if (nPC2.CanBeChasedBy(Projectile, false)) { - float num646 = Vector2.Distance(nPC2.Center, Projectile.Center); - if (!flag25 && num646 < num633) + float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center); + if (!canAttack && targetDist < maxTargetDist) { - num633 = num646; - vector46 = nPC2.Center; - flag25 = true; + maxTargetDist = targetDist; + projPos = nPC2.Center; + canAttack = true; } } } } - float num647 = num634; - if (flag25) + float separationAnxietyRange = 1200f; + if (canAttack) { - num647 = num635; + separationAnxietyRange = 3000f; } - if (Vector2.Distance(player.Center, Projectile.Center) > num647) + if (Vector2.Distance(player.Center, Projectile.Center) > separationAnxietyRange) { Projectile.ai[0] = 1f; Projectile.netUpdate = true; } - if (flag25 && Projectile.ai[0] == 0f) + if (canAttack && Projectile.ai[0] == 0f) { - Vector2 vector47 = vector46 - Projectile.Center; - float num648 = vector47.Length(); - vector47.Normalize(); - if (num648 > 200f) + Vector2 projDirection = projPos - Projectile.Center; + float projLength = projDirection.Length(); + projDirection.Normalize(); + if (projLength > 200f) { float scaleFactor2 = 8f; - vector47 *= scaleFactor2; - Projectile.velocity = (Projectile.velocity * 40f + vector47) / 41f; + projDirection *= scaleFactor2; + Projectile.velocity = (Projectile.velocity * 40f + projDirection) / 41f; } else { - float num649 = 4f; - vector47 *= -num649; - Projectile.velocity = (Projectile.velocity * 40f + vector47) / 41f; + projDirection *= -4f; + Projectile.velocity = (Projectile.velocity * 40f + projDirection) / 41f; } } else { - bool flag26 = false; - if (!flag26) + bool isReturning = false; + if (!isReturning) { - flag26 = Projectile.ai[0] == 1f; + isReturning = Projectile.ai[0] == 1f; } - float num650 = 6f; - if (flag26) + float returnSpeed = 6f; + if (isReturning) { - num650 = 15f; + returnSpeed = 15f; } Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2 + new Vector2(0f, -60f); - float num651 = vector48.Length(); - if (num651 > 200f && num650 < 8f) + Vector2 playerDirection = player.Center - center2 + new Vector2(0f, -60f); + float playerDistance = playerDirection.Length(); + if (playerDistance > 200f && returnSpeed < 8f) { - num650 = 8f; + returnSpeed = 8f; } - if (num651 < num636 && flag26 && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + if (playerDistance < 500f && isReturning && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) { Projectile.ai[0] = 0f; Projectile.netUpdate = true; } - if (num651 > 2000f) + if (playerDistance > 2000f) { Projectile.position.X = Main.player[Projectile.owner].Center.X - (float)(Projectile.width / 2); Projectile.position.Y = Main.player[Projectile.owner].Center.Y - (float)(Projectile.height / 2); Projectile.netUpdate = true; } - if (num651 > 70f) + if (playerDistance > 70f) { - vector48.Normalize(); - vector48 *= num650; - Projectile.velocity = (Projectile.velocity * 40f + vector48) / 41f; + playerDirection.Normalize(); + playerDirection *= returnSpeed; + Projectile.velocity = (Projectile.velocity * 40f + playerDirection) / 41f; } else if (Projectile.velocity.X == 0f && Projectile.velocity.Y == 0f) { @@ -209,15 +205,15 @@ namespace CalamityMod.Projectiles.Summon } if (Projectile.ai[0] == 0f) { - if (Projectile.ai[1] == 0f && flag25 && num633 < 500f) + if (Projectile.ai[1] == 0f && canAttack && maxTargetDist < 500f) { Projectile.ai[1] += 1f; if (Main.myPlayer == Projectile.owner) { Projectile.ai[0] = 2f; - Vector2 value20 = vector46 - Projectile.Center; - value20.Normalize(); - Projectile.velocity = value20 * 8f; + Vector2 npcCenter = projPos - Projectile.Center; + npcCenter.Normalize(); + Projectile.velocity = npcCenter * 8f; Projectile.netUpdate = true; } } @@ -233,10 +229,10 @@ namespace CalamityMod.Projectiles.Summon { SpriteEffects spriteEffects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Texture2D texture = ModContent.Request(Texture).Value; - int num214 = texture.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Vector2 origin = new Vector2(texture.Width / 2f, num214 / 2f); - Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Rectangle(0, y6, texture.Width, num214), Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, spriteEffects, 0); + int framing = texture.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Vector2 origin = new Vector2(texture.Width / 2f, framing / 2f); + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Rectangle(0, y6, texture.Width, framing), Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, spriteEffects, 0); return false; } diff --git a/Projectiles/Summon/BelladonnaPetal.cs b/Projectiles/Summon/BelladonnaPetal.cs index 8b14bf0a79..ad834aeacb 100644 --- a/Projectiles/Summon/BelladonnaPetal.cs +++ b/Projectiles/Summon/BelladonnaPetal.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Projectiles.Summon // A variable where the potential target will be written on. public NPC targetFound; - + public override void SetStaticDefaults() { ProjectileID.Sets.MinionShot[Projectile.type] = true; @@ -78,7 +78,7 @@ namespace CalamityMod.Projectiles.Summon } // Check for it so it doesn't update the velocity indefinetly, meaning it would be homing. - if (CheckForFiring == 0f) + if (CheckForFiring == 0f) { Projectile.velocity = CalamityUtils.CalculatePredictiveAimToTarget(Projectile.Center, targetFound, BelladonnaSpiritStaff.PetalVelocity); @@ -87,7 +87,7 @@ namespace CalamityMod.Projectiles.Summon SoundEngine.PlaySound(SoundID.Grass, Projectile.Center); CheckForFiring = 1f; - Projectile.netUpdate= true; + Projectile.netUpdate = true; } // In case the shot was about to fade out, un-fade. @@ -97,7 +97,6 @@ namespace CalamityMod.Projectiles.Summon // If there's target, but 1 second hasn't passed, rotate to point at the target, while still having gravity. else if (target != null && AITimer < BelladonnaSpiritStaff.PetalTimeBeforeTargetting) { - // "(AITimer / It's maxuimum value)" so it's a fraction between 0 and 1. Projectile.rotation = MathHelper.Lerp(Projectile.rotation, (target.Center - Projectile.Center).ToRotation() + MathHelper.PiOver2, @@ -108,7 +107,7 @@ namespace CalamityMod.Projectiles.Summon // Puts the potentialTarget on this variable that won't update constantly so the projectile doesn't become incredibly homing. targetFound = target; - + Projectile.netUpdate = true; } diff --git a/Projectiles/Summon/BelladonnaSpirit.cs b/Projectiles/Summon/BelladonnaSpirit.cs index d6f4fd1daa..ef34e10b5d 100644 --- a/Projectiles/Summon/BelladonnaSpirit.cs +++ b/Projectiles/Summon/BelladonnaSpirit.cs @@ -1,179 +1,126 @@ -using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; +using System; +using CalamityMod.Buffs.Summon; using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; -using System; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class BelladonnaSpirit : ModProjectile, ILocalizedModType + public class BelladonnaSpirit : BaseMinionProjectile { - public new string LocalizationCategory => "Projectiles.Summon"; - - public Player Owner => Main.player[Projectile.owner]; - public CalamityPlayer ModdedOwner => Owner.Calamity(); - public NPC Target => Owner.Center.MinionHoming(BelladonnaSpiritStaff.EnemyDistanceDetection, Owner, CalamityPlayer.areThereAnyDamnBosses); - public ref float PetalFireTimer => ref Projectile.ai[0]; - - public override void SetStaticDefaults() - { - Main.projFrames[Projectile.type] = 5; - ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; - ProjectileID.Sets.MinionTargettingFeature[Projectile.type] = true; - } + public override int AssociatedProjectileTypeID => ModContent.ProjectileType(); + public override int AssociatedBuffTypeID => ModContent.BuffType(); + public override ref bool AssociatedMinionBool => ref ModdedOwner.belladonaSpirit; + public override bool PreHardmodeMinionTileVision => true; + public override int AnimationFrames => 5; + public ref float ShootingTimer => ref Projectile.ai[0]; public override void SetDefaults() { - Projectile.minionSlots = 1; - Projectile.penetrate = -1; - + base.SetDefaults(); Projectile.width = 28; Projectile.height = 48; - - Projectile.DamageType = DamageClass.Summon; - Projectile.netImportant = true; - Projectile.friendly = true; - Projectile.minion = true; - Projectile.tileCollide = false; } - public override void AI() - { - // Checks if the minion can still exist. - CanMinionExist(); - - // Does the animation of the minion. - DoAnimation(Target); - - // Points in the right directions. - PointInDirection(Target); - - // Vibes around the player. + public override void MinionAI() + { FollowPlayer(); + if (Target != null) + AttackTarget(); - // The minions push eachother to not clump. Projectile.MinionAntiClump(); - - // If there's a target, it'll shoot at it. - if (Target is not null) - TargetNPC(); + Projectile.spriteDirection = Target == null ? MathF.Sign(Projectile.velocity.X) : MathF.Sign(Target.Center.X - Projectile.Center.X); Projectile.netUpdate = true; + if (Projectile.netSpam >= 10) + Projectile.netSpam = 9; } - #region Methods - - public void CanMinionExist() - { - Owner.AddBuff(ModContent.BuffType(), 1); - if (Projectile.type == ModContent.ProjectileType()) - { - if (Owner.dead) - ModdedOwner.belladonaSpirit = false; - if (ModdedOwner.belladonaSpirit) - Projectile.timeLeft = 2; - } - } - - public override void OnSpawn(IEntitySource source) - { - int dustAmount = 45; - for (int dustIndex = 0; dustIndex < dustAmount; dustIndex++) - { - float angle = MathHelper.TwoPi / 45f * dustIndex; - Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(3f, 4.5f); - Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, 39, velocity); - spawnDust.noGravity = true; - spawnDust.scale = velocity.Length() * 0.1f; - spawnDust.velocity *= 0.3f; - } - } - - public void DoAnimation(NPC target) - { - int speedModifier = (target is not null) ? 2 : 1; - - Projectile.frameCounter++; - Projectile.frame = Projectile.frameCounter / (Main.projFrames[Projectile.type] * speedModifier) % Main.projFrames[Projectile.type]; - } - - public void PointInDirection(NPC target) - { - // If there's a target look at the target. - if (target is not null) - Projectile.spriteDirection = ((target.Center.X - Projectile.Center.X) < 0).ToDirectionInt(); - - // If there's not a target, the minion just points where it's going. - else - if (Math.Abs(Projectile.velocity.X) > 0.01f) - Projectile.spriteDirection = -Math.Sign(Projectile.velocity.X); - } + #region AI Methods public void FollowPlayer() { // If the minion starts to get far, force the minion to go to you. - if (Projectile.WithinRange(Owner.Center, BelladonnaSpiritStaff.EnemyDistanceDetection) && !Projectile.WithinRange(Owner.Center, 300f)) + if (Projectile.WithinRange(Owner.Center, EnemyDistanceDetection) && !Projectile.WithinRange(Owner.Center, 300f)) Projectile.velocity = (Owner.Center - Projectile.Center) / 30f; // The minion will change directions to you if it's going away from you, meaning it'll just hover around you. - else if (!Projectile.WithinRange(Owner.Center, 160f)) + else if (!Projectile.WithinRange(Owner.Center, 160f)) Projectile.velocity = (Projectile.velocity * 37f + Projectile.SafeDirectionTo(Owner.Center) * 17f) / 40f; // Teleport to the owner if sufficiently far away. - if (!Projectile.WithinRange(Owner.Center, BelladonnaSpiritStaff.EnemyDistanceDetection)) + if (!Projectile.WithinRange(Owner.Center, EnemyDistanceDetection)) { Projectile.position = Owner.Center; Projectile.velocity *= 0.3f; } } - public void TargetNPC() + public void AttackTarget() { // The minion will slowly go up until it throws the petal. // This essentially makes the minion stay above you and trigger the "Turn back to player", it'll do this continuously, giving the effect of bouncing. // Yes, it's very wacky. You can make it better if you wish. - Projectile.velocity.Y -= MathHelper.Lerp(0, 0.005f, PetalFireTimer % BelladonnaSpiritStaff.FireRate); - - if (Main.myPlayer == Projectile.owner) - FirePetals(); + Projectile.velocity.Y -= MathHelper.Lerp(0, 0.005f, ShootingTimer % BelladonnaSpiritStaff.FireRate); - if (PetalFireTimer < BelladonnaSpiritStaff.FireRate) - PetalFireTimer++; - } - - public void FirePetals() - { - if (PetalFireTimer == BelladonnaSpiritStaff.FireRate) // Every 75 frames, throws a petal. + ShootingTimer++; + if (ShootingTimer == BelladonnaSpiritStaff.FireRate && Main.myPlayer == Projectile.owner) // Every 75 frames, throws a petal. { // Throws the petal upwards with a random force and inherits the minion's speed. Vector2 petalShootVelocity = (-Vector2.UnitY * Main.rand.NextFloat(7f, 8.5f)) + Vector2.UnitX * Projectile.velocity.X + Vector2.UnitY * Projectile.velocity.Y * 0.35f; - - int petal = Projectile.NewProjectile(Projectile.GetSource_FromThis(), + + Projectile petal = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, petalShootVelocity, - ModContent.ProjectileType(), - Projectile.damage, - Projectile.knockBack, + ModContent.ProjectileType(), + Projectile.damage, + Projectile.knockBack, Projectile.owner); - - if (Main.projectile.IndexInRange(petal)) - { - Main.projectile[petal].rotation = Main.rand.NextFloat(0, MathHelper.TwoPi); - } + petal.rotation = Main.rand.NextFloat(0, MathHelper.TwoPi); // Resets the timer. - PetalFireTimer = 0f; + ShootingTimer = 0f; + } + } + + #endregion + + public override void OnSpawn(IEntitySource source) + { + if (!Main.dedServ) + { + int dustAmount = 45; + for (int dustIndex = 0; dustIndex < dustAmount; dustIndex++) + { + float angle = MathHelper.TwoPi / 45f * dustIndex; + Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(3f, 4.5f); + Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, 39, velocity); + spawnDust.noGravity = true; + spawnDust.scale = velocity.Length() * 0.1f; + spawnDust.velocity *= 0.3f; + } } } public override bool? CanDamage() => false; - #endregion + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 position = Projectile.Center - Main.screenPosition; + Rectangle sourceRectangle = texture.Frame(verticalFrames: AnimationFrames, frameY: Projectile.frame); + Vector2 origin = sourceRectangle.Size() * 0.5f; + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Main.EntitySpriteDraw(texture, position, sourceRectangle, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, effects); + + return false; + } } } diff --git a/Projectiles/Summon/BelladonnaSpirit.png b/Projectiles/Summon/BelladonnaSpirit.png index 3f62956805..5063d8c384 100644 Binary files a/Projectiles/Summon/BelladonnaSpirit.png and b/Projectiles/Summon/BelladonnaSpirit.png differ diff --git a/Projectiles/Summon/BetterHornetStinger.cs b/Projectiles/Summon/BetterHornetStinger.cs new file mode 100644 index 0000000000..5bfcc24c13 --- /dev/null +++ b/Projectiles/Summon/BetterHornetStinger.cs @@ -0,0 +1,74 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class BetterHornetStinger : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + + public override void SetDefaults() + { + Projectile.DamageType = DamageClass.Summon; + Projectile.timeLeft = 180; + Projectile.width = Projectile.height = 32; + + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + } + + public override void AI() + { + Projectile.rotation = Projectile.velocity.ToRotation(); + + if (!Main.dedServ) + { + if (Main.rand.NextBool(3)) + { + Dust trailDust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.JungleGrass); + trailDust.noGravity = true; + trailDust.noLight = true; + trailDust.noLightEmittence = true; + } + + Projectile.alpha = (int)Utils.Remap(Projectile.timeLeft, 30, 0, 0, 255); + } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(BuffID.PotionSickness, 180); + + if (!Main.dedServ) + { + for (int i = 0; i < 15; i++) + { + Dust impactDust = Dust.NewDustPerfect(target.Center, DustID.JungleGrass, Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(3f, 6f)); + impactDust.noGravity = true; + impactDust.noLight = true; + impactDust.noLightEmittence = true; + } + } + + Projectile.netUpdate = true; + if (Projectile.netSpam >= 10) + Projectile.netSpam = 9; + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Rectangle frame = texture.Frame(); + Vector2 origin = frame.Size() * 0.5f; + + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation + MathHelper.PiOver2, origin, Projectile.scale, SpriteEffects.None); + + return false; + } + } +} diff --git a/Projectiles/Summon/BetterHornetStinger.png b/Projectiles/Summon/BetterHornetStinger.png new file mode 100644 index 0000000000..b628deb43f Binary files /dev/null and b/Projectiles/Summon/BetterHornetStinger.png differ diff --git a/Projectiles/Summon/BrimstoneElementalMinion.cs b/Projectiles/Summon/BrimstoneElementalMinion.cs index e45fc3458b..26c28e707c 100644 --- a/Projectiles/Summon/BrimstoneElementalMinion.cs +++ b/Projectiles/Summon/BrimstoneElementalMinion.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isActive = Projectile.type == ModContent.ProjectileType(); Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); if (!modPlayer.brimstoneWaifu && !modPlayer.allWaifus && !modPlayer.brimstoneWaifuVanity && !modPlayer.allWaifusVanity) @@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.active = false; return; } - if (flag64) + if (isActive) { if (player.dead) { @@ -62,12 +62,11 @@ namespace CalamityMod.Projectiles.Summon dust--; if (dust >= 0) { - int num501 = 50; - for (int num502 = 0; num502 < num501; num502++) + for (int i = 0; i < 50; i++) { - int num503 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, (int)CalamityDusts.Brimstone, 0f, 0f, 0, default, 1f); - Main.dust[num503].velocity *= 2f; - Main.dust[num503].scale *= 1.15f; + int brimDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, (int)CalamityDusts.Brimstone, 0f, 0f, 0, default, 1f); + Main.dust[brimDust].velocity *= 2f; + Main.dust[brimDust].scale *= 1.15f; } } bool passive = modPlayer.brimstoneWaifuVanity || modPlayer.allWaifusVanity; @@ -83,19 +82,18 @@ namespace CalamityMod.Projectiles.Summon } if (!passive) { - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight(Projectile.Center, 1.25f * num, 0f * num, 0.5f * num); + float lights = (float)Main.rand.Next(90, 111) * 0.01f; + lights *= Main.essScale; + Lighting.AddLight(Projectile.Center, 1.25f * lights, 0f * lights, 0.5f * lights); } if (Math.Abs(Projectile.velocity.X) > 0.2f) { Projectile.spriteDirection = -Projectile.direction; } - float num633 = 700f; - float num636 = 400f; //150 + float maxTargetDist = 700f; Projectile.MinionAntiClump(); Vector2 targetCenter = Projectile.position; - bool flag25 = false; + bool canAttack = false; if (Projectile.ai[0] != 1f) { Projectile.tileCollide = false; @@ -109,27 +107,27 @@ namespace CalamityMod.Projectiles.Summon NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(Projectile, false)) { - float num646 = Vector2.Distance(npc.Center, Projectile.Center); - if ((!flag25 && num646 < num633) && Collision.CanHitLine(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) + float targetDist = Vector2.Distance(npc.Center, Projectile.Center); + if ((!canAttack && targetDist < maxTargetDist) && Collision.CanHitLine(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) { targetCenter = npc.Center; - flag25 = true; + canAttack = true; } } } - if (!flag25 && !passive) + if (!canAttack && !passive) { - for (int num645 = 0; num645 < Main.maxNPCs; num645++) + for (int i = 0; i < Main.maxNPCs; i++) { - NPC nPC2 = Main.npc[num645]; + NPC nPC2 = Main.npc[i]; if (nPC2.CanBeChasedBy(Projectile, false)) { - float num646 = Vector2.Distance(nPC2.Center, Projectile.Center); - if ((!flag25 && num646 < num633) && Collision.CanHitLine(Projectile.position, Projectile.width, Projectile.height, nPC2.position, nPC2.width, nPC2.height)) + float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center); + if ((!canAttack && targetDist < maxTargetDist) && Collision.CanHitLine(Projectile.position, Projectile.width, Projectile.height, nPC2.position, nPC2.width, nPC2.height)) { - num633 = num646; + maxTargetDist = targetDist; targetCenter = nPC2.Center; - flag25 = true; + canAttack = true; } } } @@ -140,39 +138,39 @@ namespace CalamityMod.Projectiles.Summon Projectile.tileCollide = false; Projectile.netUpdate = true; } - bool flag26 = false; - if (!flag26) + bool isReturning = false; + if (!isReturning) { - flag26 = Projectile.ai[0] == 1f; + isReturning = Projectile.ai[0] == 1f; } - float num650 = 5f; //6 - if (flag26) + float returnSpeed = 5f; //6 + if (isReturning) { - num650 = 12f; //15 + returnSpeed = 12f; //15 } Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2 + new Vector2(-500f, -60f); //-60 - float num651 = vector48.Length(); - if (num651 > 200f && num650 < 6.5f) //200 and 8 + Vector2 playerDirection = player.Center - center2 + new Vector2(-500f, -60f); //-60 + float playerDistance = playerDirection.Length(); + if (playerDistance > 200f && returnSpeed < 6.5f) //200 and 8 { - num650 = 6.5f; //8 + returnSpeed = 6.5f; //8 } - if (num651 < num636 && flag26 && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + if (playerDistance < 400f && isReturning && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) { Projectile.ai[0] = 0f; Projectile.netUpdate = true; } - if (num651 > 2000f) + if (playerDistance > 2000f) { Projectile.position.X = Main.player[Projectile.owner].Center.X - (float)(Projectile.width / 2); Projectile.position.Y = Main.player[Projectile.owner].Center.Y - (float)(Projectile.height / 2); Projectile.netUpdate = true; } - if (num651 > 70f) + if (playerDistance > 70f) { - vector48.Normalize(); - vector48 *= num650; - Projectile.velocity = (Projectile.velocity * 40f + vector48) / 41f; + playerDirection.Normalize(); + playerDirection *= returnSpeed; + Projectile.velocity = (Projectile.velocity * 40f + playerDirection) / 41f; } else if (Projectile.velocity.X == 0f && Projectile.velocity.Y == 0f) { @@ -197,7 +195,7 @@ namespace CalamityMod.Projectiles.Summon { float fireballShootSpeed = 14f; int projID = ModContent.ProjectileType(); - if (flag25 && Projectile.ai[1] == 0f && Projectile.localAI[0] >= 120f) + if (canAttack && Projectile.ai[1] == 0f && Projectile.localAI[0] >= 120f) { Projectile.ai[1] += 1f; if (Main.myPlayer == Projectile.owner && Collision.CanHitLine(Projectile.position, Projectile.width, Projectile.height, targetCenter, 0, 0)) diff --git a/Projectiles/Summon/BrimstoneExplosionMinion.cs b/Projectiles/Summon/BrimstoneExplosionMinion.cs index f16306933e..cd75afbbeb 100644 --- a/Projectiles/Summon/BrimstoneExplosionMinion.cs +++ b/Projectiles/Summon/BrimstoneExplosionMinion.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.penetrate = -1; Projectile.timeLeft = 180; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; + Projectile.localNPCHitCooldown = 20; Projectile.DamageType = DamageClass.Summon; } @@ -40,38 +40,38 @@ namespace CalamityMod.Projectiles.Summon SoundEngine.PlaySound(SoundID.Item20, Projectile.position); Projectile.localAI[0] += 1f; } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-10, 11); - float num464 = (float)Main.rand.Next(-10, 11); - float num465 = (float)Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); - Dust dust = Main.dust[num467]; + float rand1 = (float)Main.rand.Next(-10, 11); + float rand2 = (float)Main.rand.Next(-10, 11); + float rand3 = (float)Main.rand.Next(3, 9); + float randAdjust = (float)Math.Sqrt((double)(rand1 * rand1 + rand2 * rand2)); + randAdjust = rand3 / randAdjust; + rand1 *= randAdjust; + rand2 *= randAdjust; + int brimDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); + Dust dust = Main.dust[brimDust]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = rand1; + dust.velocity.Y = rand2; + timerCounter++; } } diff --git a/Projectiles/Summon/BrimstoneFireballMinion.cs b/Projectiles/Summon/BrimstoneFireballMinion.cs index 738c294645..02cdb7dca2 100644 --- a/Projectiles/Summon/BrimstoneFireballMinion.cs +++ b/Projectiles/Summon/BrimstoneFireballMinion.cs @@ -58,10 +58,10 @@ namespace CalamityMod.Projectiles.Summon Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) - MathHelper.ToRadians(90) * Projectile.direction; - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 170, default, 1.1f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int brimDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 170, default, 1.1f); + Main.dust[brimDust].noGravity = true; + Main.dust[brimDust].velocity *= 0.5f; + Main.dust[brimDust].velocity += Projectile.velocity * 0.1f; Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.05f / 255f, (255 - Projectile.alpha) * 0.05f / 255f); if (Projectile.localAI[0] == 0f) @@ -71,13 +71,13 @@ namespace CalamityMod.Projectiles.Summon } } - public override void OnKill(int timeLeft) - { - if (Projectile.owner == Main.myPlayer) - { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - } - } + //public override void OnKill(int timeLeft) + //{ + //if (Projectile.owner == Main.myPlayer) + //{ + //Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + //} + //} public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { diff --git a/Projectiles/Summon/BrittleStarMinion.cs b/Projectiles/Summon/BrittleStarMinion.cs index a2c039a584..52cfae8e3e 100644 --- a/Projectiles/Summon/BrittleStarMinion.cs +++ b/Projectiles/Summon/BrittleStarMinion.cs @@ -1,61 +1,211 @@ -using CalamityMod.Buffs.Summon; +using System; +using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class BrittleStarMinion : ModProjectile, ILocalizedModType + public class BrittleStarMinion : BaseMinionProjectile { - public new string LocalizationCategory => "Projectiles.Summon"; - public Player Owner => Main.player[Projectile.owner]; - public CalamityPlayer ModdedOwner => Owner.Calamity(); - public float EnemyDistanceDetection = 1200f; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; - ProjectileID.Sets.MinionTargettingFeature[Projectile.type] = true; - } + public override int AssociatedBuffTypeID => ModContent.BuffType(); + public override ref bool AssociatedMinionBool => ref ModdedOwner.brittleStar; + public override int AssociatedProjectileTypeID => ModContent.ProjectileType(); + public override bool PreHardmodeMinionTileVision => true; + public int HitCounter = 0; + public int BuffModeBuffer = 30; + public ref bool MinionBuffMode => ref Main.player[Projectile.owner].Calamity().brittleStarBuffMode; + public ref float AITimer => ref Projectile.ai[0]; + public ref float StarIndex => ref Projectile.ai[1]; + public float MoveWidth = 1.3f; + public bool MoveSize = false; + public int ReformingTimer = 25; + public bool Reforming = false; + public int Time = 0; + public float ProjKnock; public override void SetDefaults() { Projectile.width = 30; Projectile.height = 28; - Projectile.netImportant = true; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.minionSlots = 1; - Projectile.penetrate = -1; - Projectile.minion = true; - Projectile.tileCollide = false; - Projectile.DamageType = DamageClass.Summon; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 35; + Projectile.localNPCHitCooldown = 15; + base.SetDefaults(); } - - public override void AI() + public float StarPositionAngle // Calculates where each minion should be placed. { - Owner.AddBuff(ModContent.BuffType(), 1); - if (Projectile.type == ModContent.ProjectileType()) + get { - if (Owner.dead) + float starCount = Owner.ownedProjectileCounts[Type]; + if (starCount <= 1f) + starCount = 1f; + + return MathHelper.TwoPi * StarIndex / starCount + AITimer * 0.018f; + // "MathHelper.TwoPi / ProbeIndex * probeCount"s the position itself. + // "AITimer * [Modifier]"s how fast it spins. + } + } + public override void MinionAI() + { + Time++; + if (Time == 1) + ProjKnock = Projectile.knockBack; + Projectile.knockBack = ProjKnock * (MinionBuffMode ? 2.5f : 1f); + if (ReformingTimer < 25) + { + Projectile.alpha = 255; + Reforming = true; + ReformingTimer++; + } + if (ReformingTimer == 24) // Dust effect and positioning after reforming + { + Reforming = false; + Projectile.Center = Owner.Center + Main.rand.NextVector2Circular(160, 160); + float numberOfDusts = 10f; + float rotFactor = 360f / numberOfDusts; + SoundEngine.PlaySound(SoundID.Dig with { Volume = 0.5f, Pitch = 0.1f }, Projectile.Center); + for (int i = 0; i < numberOfDusts; i++) { - ModdedOwner.brittleStar = false; - } - if (ModdedOwner.brittleStar) - { - Projectile.timeLeft = 2; + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 offset = new Vector2(Main.rand.NextFloat(1.5f, 4f), 0).RotatedBy(rot * Main.rand.NextFloat(3.1f, 9.1f)); + Vector2 velOffset = new Vector2(Main.rand.NextFloat(1.5f, 4f), 0).RotatedBy(rot * Main.rand.NextFloat(3.1f, 9.1f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, Main.rand.NextBool(3) ? 216 : 207, new Vector2(velOffset.X, velOffset.Y)); + dust.noGravity = true; + dust.velocity = velOffset; + dust.scale = Main.rand.NextFloat(1.3f, 1.9f); } } + if (ReformingTimer == 25) + { + Projectile.alpha = 0; + Reforming = false; + } - Projectile.rotation += Projectile.velocity.X * 0.04f; // Spins faster the faster it moves in the X-axis. + if (MoveWidth <= 0.7f) // Used for the rotation and movement of stars while circling player + { + MoveSize = true; + } + if (MoveWidth >= 1.3f) + { + MoveSize = false; + } + MoveWidth += (MoveSize ? Main.rand.NextFloat(0.02f, 0.04f) : Main.rand.NextFloat(-0.02f, -0.04f)); - Projectile.ChargingMinionAI(EnemyDistanceDetection, 1500f, 2200f, 150f, 0, 24f, 15f, 4f, new Vector2(0f, -60f), 12f, 12f, CalamityPlayer.areThereAnyDamnBosses, true, 1); + // Right click, only runs on the first minion spawned so that it functions propperly + if (Projectile.ai[2] == 0 && Owner.Calamity().mouseRight && Owner.HeldItem.type == ModContent.ItemType()) + { + if (BuffModeBuffer > 0) + { + BuffModeBuffer--; + Projectile.netUpdate = true; + } + if (BuffModeBuffer == 0) + { + MinionBuffMode = !MinionBuffMode; + BuffModeBuffer = 30; + } + } + else if (BuffModeBuffer < 30) + BuffModeBuffer = 30; + + if (MinionBuffMode) // Minion when circling + { + Projectile.localNPCHitCooldown = 25; + Reforming = false; + Projectile.alpha = 0; + HitCounter = 0; + Projectile.velocity = Vector2.Zero; + Vector2 idleDestination = Owner.Center + StarPositionAngle.ToRotationVector2() * (75f * MoveWidth); + Projectile.Center = Vector2.Lerp(Projectile.Center, idleDestination, 0.15f); + AITimer++; + + Owner.statDefense += 3; + Projectile.rotation += MoveWidth * 0.2f; + } + if (!MinionBuffMode && !Reforming) // Minion when ramming + { + Projectile.localNPCHitCooldown = 15; + Projectile.MinionAntiClump(); + + if (Target is not null) + { + Projectile.rotation += Projectile.velocity.X * 0.06f; // Spins faster the faster it moves in the X-axis. + Vector2 dashDirection = Projectile.SafeDirectionTo(Target.Center) * 30; + if (!Projectile.WithinRange(Target.Center, 160f)) + { + float inertia = 7f; + Projectile.velocity = (Projectile.velocity * inertia + dashDirection) / (inertia + 1f); + } + // But if there was the case where the minion was already inside the range, + // if the velocity's not around the dash speed, make it dash. + else if (Projectile.velocity.Length() < 25) + { + Projectile.velocity = dashDirection; + } + if (Projectile.WithinRange(Target.Center, 160f)) + { + SparkParticle spark = new SparkParticle(Projectile.Center - Projectile.velocity * 2, -Projectile.velocity * 0.05f, false, 2, 1.2f, Color.White * 0.2f); + GeneralParticleHandler.SpawnParticle(spark); + spark.Scale -= 0.1f; + } + } + else // Idle state + { + Projectile.rotation += Projectile.velocity.X * 0.06f; // Spins faster the faster it moves in the X-axis. + + if (!Projectile.WithinRange(Owner.Center, 42f)) + { + Projectile.velocity = (Projectile.velocity + Projectile.SafeDirectionTo(Owner.Center)) * 0.95f; + } + + // The minion will teleport on the owner if they get far enough. + if (!Projectile.WithinRange(Owner.Center, 1200f)) + { + Projectile.Center = Owner.Center; + } + } + } } - - public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (!MinionBuffMode) // "Break" the minion after every 3 hits if in charging + { + HitCounter++; + if (HitCounter >= 4) + { + for (int i = 0; i <= 5; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity, Main.rand.NextBool(3) ? 216 : 207, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.05f, 0.4f), 0, default, Main.rand.NextFloat(1.3f, 1.8f)); + dust.noGravity = true; + } + SoundEngine.PlaySound(SoundID.DD2_SkeletonHurt with { Pitch = 0.5f }, Projectile.Center); + Projectile.velocity = Vector2.Zero; + HitCounter = 0; + ReformingTimer = 0; + } + } + else + { + float numberOfDusts = 5f; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) + { + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 offset = new Vector2(Main.rand.NextFloat(0.5f, 2.5f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + Vector2 velOffset = new Vector2(Main.rand.NextFloat(0.5f, 2.5f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, Main.rand.NextBool(3) ? 216 : 207, new Vector2(velOffset.X, velOffset.Y)); + dust.noGravity = true; + dust.velocity = velOffset; + dust.scale = Main.rand.NextFloat(1.3f, 1.8f); + } + HitCounter = 0; + } + } + public override bool? CanDamage() => Reforming ? false : null; } } diff --git a/Projectiles/Summon/BrittleStarMinion.png b/Projectiles/Summon/BrittleStarMinion.png index b65fe96613..739f28d509 100644 Binary files a/Projectiles/Summon/BrittleStarMinion.png and b/Projectiles/Summon/BrittleStarMinion.png differ diff --git a/Projectiles/Summon/CausticStaffSummon.cs b/Projectiles/Summon/CausticStaffSummon.cs index da4c0f42c1..1824738482 100644 --- a/Projectiles/Summon/CausticStaffSummon.cs +++ b/Projectiles/Summon/CausticStaffSummon.cs @@ -45,13 +45,13 @@ namespace CalamityMod.Projectiles.Summon int dustAmt = 36; for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(dustIndex - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int dusty = Dust.NewDust(vector6 + vector7, 0, 0, 6, vector7.X * 1f, vector7.Y * 1f, 100, default, 1.1f); + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(dustIndex - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int dusty = Dust.NewDust(rotate + faceDirection, 0, 0, 6, faceDirection.X * 1f, faceDirection.Y * 1f, 100, default, 1.1f); Main.dust[dusty].noGravity = true; Main.dust[dusty].noLight = true; - Main.dust[dusty].velocity = vector7; + Main.dust[dusty].velocity = faceDirection; } initialized = true; } diff --git a/Projectiles/Summon/CorroslimeMinion.cs b/Projectiles/Summon/CorroslimeMinion.cs index 174e882f2f..42ed83d21c 100644 --- a/Projectiles/Summon/CorroslimeMinion.cs +++ b/Projectiles/Summon/CorroslimeMinion.cs @@ -52,22 +52,22 @@ namespace CalamityMod.Projectiles.Summon CalamityPlayer modPlayer = player.Calamity(); if (dust == 0f) { - int num226 = 16; - for (int num227 = 0; num227 < num226; num227++) + int constant = 16; + for (int i = 0; i < constant; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 14, vector7.X * 1f, vector7.Y * 1f, 100, default, 1.1f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(i - (constant / 2 - 1)) * 6.28318548f / (float)constant), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int dust = Dust.NewDust(rotate + faceDirection, 0, 0, 14, faceDirection.X * 1f, faceDirection.Y * 1f, 100, default, 1.1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + Main.dust[dust].velocity = faceDirection; } dust += 1f; } - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isMinion = Projectile.type == ModContent.ProjectileType(); player.AddBuff(ModContent.BuffType(), 3600); - if (flag64) + if (isMinion) { if (player.dead) { @@ -83,9 +83,9 @@ namespace CalamityMod.Projectiles.Summon public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } diff --git a/Projectiles/Summon/CorruptionSlimeGodMinion.cs b/Projectiles/Summon/CorruptionSlimeGodMinion.cs index 66fd14f3a6..53d0b49efc 100644 --- a/Projectiles/Summon/CorruptionSlimeGodMinion.cs +++ b/Projectiles/Summon/CorruptionSlimeGodMinion.cs @@ -50,27 +50,27 @@ namespace CalamityMod.Projectiles.Summon CalamityPlayer modPlayer = player.Calamity(); if (dust == 0f) { - int num226 = 16; - for (int num227 = 0; num227 < num226; num227++) + int constant = 16; + for (int i = 0; i < constant; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 173, vector7.X * 1f, vector7.Y * 1f, 100, default, 1.1f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(i - (constant / 2 - 1)) * 6.28318548f / (float)constant), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int dust = Dust.NewDust(rotate + faceDirection, 0, 0, 173, faceDirection.X * 1f, faceDirection.Y * 1f, 100, default, 1.1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + Main.dust[dust].velocity = faceDirection; } dust += 1f; } - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isMinion = Projectile.type == ModContent.ProjectileType(); player.AddBuff(ModContent.BuffType(), 3600); if (!modPlayer.slimeGod) { Projectile.active = false; return; } - if (flag64) + if (isMinion) { if (player.dead) { diff --git a/Projectiles/Summon/CosmicBlast.cs b/Projectiles/Summon/CosmicBlast.cs index 616766ef0b..4360f4fe61 100644 --- a/Projectiles/Summon/CosmicBlast.cs +++ b/Projectiles/Summon/CosmicBlast.cs @@ -44,10 +44,10 @@ namespace CalamityMod.Projectiles.Summon if (Main.rand.NextBool(8)) { Vector2 value3 = Vector2.UnitX.RotatedByRandom(1.5707963705062866).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num59 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.2f); - Main.dust[num59].noGravity = true; - Main.dust[num59].velocity = value3 * 0.66f; - Main.dust[num59].position = Projectile.Center + value3 * 12f; + int rainbowDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.2f); + Main.dust[rainbowDust].noGravity = true; + Main.dust[rainbowDust].velocity = value3 * 0.66f; + Main.dust[rainbowDust].position = Projectile.Center + value3 * 12f; } NPC potentialTarget = Projectile.Center.MinionHoming(1200f, Main.player[Projectile.owner]); if (potentialTarget != null) @@ -66,9 +66,9 @@ namespace CalamityMod.Projectiles.Summon public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } @@ -84,19 +84,19 @@ namespace CalamityMod.Projectiles.Summon Projectile.localNPCHitCooldown = 10; Projectile.Damage(); SoundEngine.PlaySound(SoundID.Zombie103, Projectile.Center); - for (int num193 = 0; num193 < 3; num193++) + for (int i = 0; i < 3; i++) { int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.5f); Main.dust[dust].noGravity = true; } - for (int num194 = 0; num194 < 30; num194++) + for (int j = 0; j < 30; j++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int rainbowDusty = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 2.5f); + Main.dust[rainbowDusty].noGravity = true; + Main.dust[rainbowDusty].velocity *= 3f; + rainbowDusty = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.5f); + Main.dust[rainbowDusty].velocity *= 2f; + Main.dust[rainbowDusty].noGravity = true; } } } diff --git a/Projectiles/Summon/CosmicBlastBig.cs b/Projectiles/Summon/CosmicBlastBig.cs index ecd3563c86..1b8d36f8e8 100644 --- a/Projectiles/Summon/CosmicBlastBig.cs +++ b/Projectiles/Summon/CosmicBlastBig.cs @@ -41,23 +41,23 @@ namespace CalamityMod.Projectiles.Summon if (Main.rand.NextBool(8)) { Vector2 value3 = Vector2.UnitX.RotatedByRandom(1.5707963705062866).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num59 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.2f); - Main.dust[num59].noGravity = true; - Main.dust[num59].velocity = value3 * 0.66f; - Main.dust[num59].position = Projectile.Center + value3 * 12f; + int rainbowDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.2f); + Main.dust[rainbowDust].noGravity = true; + Main.dust[rainbowDust].velocity = value3 * 0.66f; + Main.dust[rainbowDust].position = Projectile.Center + value3 * 12f; } if (Main.rand.NextBool(24) && Main.netMode != NetmodeID.Server) { - int num60 = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), 16, 1f); - Main.gore[num60].velocity *= 0.66f; - Main.gore[num60].velocity += Projectile.velocity * 0.3f; + int rainbowGore = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), 16, 1f); + Main.gore[rainbowGore].velocity *= 0.66f; + Main.gore[rainbowGore].velocity += Projectile.velocity * 0.3f; } if (Projectile.ai[1] == 1f) { if (Main.rand.NextBool(5)) { - int num59 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.2f); - Main.dust[num59].noGravity = true; + int rainbowDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.2f); + Main.dust[rainbowDust].noGravity = true; } if (Main.rand.NextBool(10) && Main.netMode != NetmodeID.Server) { @@ -90,19 +90,19 @@ namespace CalamityMod.Projectiles.Summon Projectile.localNPCHitCooldown = 10; Projectile.Damage(); SoundEngine.PlaySound(SoundID.Zombie103, Projectile.Center); - for (int num193 = 0; num193 < 3; num193++) + for (int i = 0; i < 3; i++) { int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.5f); Main.dust[dust].noGravity = true; } - for (int num194 = 0; num194 < 30; num194++) + for (int j = 0; j < 30; j++) { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int rainbowDusty = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 2.5f); + Main.dust[rainbowDusty].noGravity = true; + Main.dust[rainbowDusty].velocity *= 3f; + rainbowDusty = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.5f); + Main.dust[rainbowDusty].velocity *= 2f; + Main.dust[rainbowDusty].noGravity = true; } } } diff --git a/Projectiles/Summon/CosmicEnergySpiral.cs b/Projectiles/Summon/CosmicEnergySpiral.cs index 20dd58c1fd..c62e9bcf6b 100644 --- a/Projectiles/Summon/CosmicEnergySpiral.cs +++ b/Projectiles/Summon/CosmicEnergySpiral.cs @@ -42,9 +42,9 @@ namespace CalamityMod.Projectiles.Summon Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); Lighting.AddLight((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16, (float)Main.DiscoR / 255f, (float)Main.DiscoG / 255f, (float)Main.DiscoB / 255f); - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isMinion = Projectile.type == ModContent.ProjectileType(); player.AddBuff(ModContent.BuffType(), 3600); - if (flag64) + if (isMinion) { if (player.dead) { @@ -55,109 +55,105 @@ namespace CalamityMod.Projectiles.Summon Projectile.timeLeft = 2; } } - float num633 = 1400f; //700 - float num634 = 1600f; //800 - float num635 = 2400f; //1200 - float num636 = 800f; + float targetDist = 1400f; //700 Projectile.rotation += Projectile.velocity.X * 0.1f; - Vector2 vector46 = Projectile.position; - bool flag25 = false; + Vector2 projPos = Projectile.position; + bool canAttack = false; int target = 0; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(Projectile, false)) { - float num646 = Vector2.Distance(npc.Center, Projectile.Center); - if (!flag25 && num646 < num633) + float maxTargetDist = Vector2.Distance(npc.Center, Projectile.Center); + if (!canAttack && maxTargetDist < targetDist) { - vector46 = npc.Center; - flag25 = true; + projPos = npc.Center; + canAttack = true; target = npc.whoAmI; } } } else { - for (int num645 = 0; num645 < Main.maxNPCs; num645++) + for (int i = 0; i < Main.maxNPCs; i++) { - NPC nPC2 = Main.npc[num645]; + NPC nPC2 = Main.npc[i]; if (nPC2.CanBeChasedBy(Projectile, false)) { - float num646 = Vector2.Distance(nPC2.Center, Projectile.Center); - if (!flag25 && num646 < num633) + float maxTargetDist = Vector2.Distance(nPC2.Center, Projectile.Center); + if (!canAttack && maxTargetDist < targetDist) { - num633 = num646; - vector46 = nPC2.Center; - flag25 = true; - target = num645; + targetDist = maxTargetDist; + projPos = nPC2.Center; + canAttack = true; + target = i; } } } } - float num647 = num634; - if (flag25) + float separationAnxietyDist = 1600f; + if (canAttack) { - num647 = num635; + separationAnxietyDist = 2400f; } - if (Vector2.Distance(player.Center, Projectile.Center) > num647) + if (Vector2.Distance(player.Center, Projectile.Center) > separationAnxietyDist) { Projectile.ai[1] = 1f; Projectile.netUpdate = true; } - if (flag25 && Projectile.ai[1] == 0f) + if (canAttack && Projectile.ai[1] == 0f) { - Vector2 vector47 = vector46 - Projectile.Center; - float num648 = vector47.Length(); - vector47.Normalize(); - if (num648 > 200f) + Vector2 projDirection = projPos - Projectile.Center; + float projDistance = projDirection.Length(); + projDirection.Normalize(); + if (projDistance > 200f) { float scaleFactor2 = 6f; //6 - vector47 *= scaleFactor2; - Projectile.velocity = (Projectile.velocity * 40f + vector47) / 41f; + projDirection *= scaleFactor2; + Projectile.velocity = (Projectile.velocity * 40f + projDirection) / 41f; } else { - float num649 = 4f; //4 - vector47 *= -num649; - Projectile.velocity = (Projectile.velocity * 40f + vector47) / 41f; + projDirection *= -4f; + Projectile.velocity = (Projectile.velocity * 40f + projDirection) / 41f; } } else { - bool flag26 = false; - if (!flag26) + bool isReturning = false; + if (!isReturning) { - flag26 = Projectile.ai[1] == 1f; + isReturning = Projectile.ai[1] == 1f; } - float num650 = 6f; - if (flag26) + float returnSpeed = 6f; + if (isReturning) { - num650 = 15f; + returnSpeed = 15f; } Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2 + new Vector2(0f, -60f); - float num651 = vector48.Length(); - if (num651 > 200f && num650 < 8f) + Vector2 playerDirection = player.Center - center2 + new Vector2(0f, -60f); + float playerDistance = playerDirection.Length(); + if (playerDistance > 200f && returnSpeed < 8f) { - num650 = 8f; + returnSpeed = 8f; } - if (num651 < num636 && flag26 && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + if (playerDistance < 800f && isReturning && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) { Projectile.ai[1] = 0f; Projectile.netUpdate = true; } - if (num651 > 2000f) //2000 + if (playerDistance > 2000f) //2000 { Projectile.position.X = Main.player[Projectile.owner].Center.X - (float)(Projectile.width / 2); Projectile.position.Y = Main.player[Projectile.owner].Center.Y - (float)(Projectile.height / 2); Projectile.netUpdate = true; } - if (num651 > 70f) + if (playerDistance > 70f) { - vector48.Normalize(); - vector48 *= num650; - Projectile.velocity = (Projectile.velocity * 40f + vector48) / 41f; + playerDirection.Normalize(); + playerDirection *= returnSpeed; + Projectile.velocity = (Projectile.velocity * 40f + playerDirection) / 41f; } else if (Projectile.velocity.X == 0f && Projectile.velocity.Y == 0f) { @@ -165,9 +161,9 @@ namespace CalamityMod.Projectiles.Summon Projectile.velocity.Y = -0.05f; } } - float num395 = (float)Main.mouseTextColor / 200f - 0.35f; - num395 *= 0.2f; - Projectile.scale = num395 + 0.95f; + float projScale = (float)Main.mouseTextColor / 200f - 0.35f; + projScale *= 0.2f; + Projectile.scale = projScale + 0.95f; if (justSpawned) { justSpawned = false; @@ -180,27 +176,27 @@ namespace CalamityMod.Projectiles.Summon Projectile.ai[0] -= 1f; return; } - float num396 = Projectile.position.X; - float num397 = Projectile.position.Y; - float num398 = 1200f; - bool flag11 = false; - for (int num399 = 0; num399 < Main.maxNPCs; num399++) + float projX = Projectile.position.X; + float projY = Projectile.position.Y; + float homeDistance = 1200f; + bool isInRange = false; + for (int j = 0; j < Main.maxNPCs; j++) { - if (Main.npc[num399].CanBeChasedBy(Projectile, false)) + if (Main.npc[j].CanBeChasedBy(Projectile, false)) { - float num400 = Main.npc[num399].position.X + (float)(Main.npc[num399].width / 2); - float num401 = Main.npc[num399].position.Y + (float)(Main.npc[num399].height / 2); - float num402 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num400) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num401); - if (num402 < num398) + float npcX = Main.npc[j].position.X + (float)(Main.npc[j].width / 2); + float npcY = Main.npc[j].position.Y + (float)(Main.npc[j].height / 2); + float npcDistance = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); + if (npcDistance < homeDistance) { - num398 = num402; - num396 = num400; - num397 = num401; - flag11 = true; + homeDistance = npcDistance; + projX = npcX; + projY = npcY; + isInRange = true; } } } - if (flag11) + if (isInRange) { SoundEngine.PlaySound(SoundID.Item105, Projectile.position); int blastAmt = Main.rand.Next(5, 8); @@ -210,13 +206,13 @@ namespace CalamityMod.Projectiles.Summon Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5), 2f, Projectile.owner, (float)target, 0f); } float speed = 15f; - float num404 = num396 - Projectile.Center.X; - float num405 = num397 - Projectile.Center.Y; - float num406 = (float)Math.Sqrt((double)(num404 * num404 + num405 * num405)); - num406 = speed / num406; - num404 *= num406; - num405 *= num406; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, num404, num405, ModContent.ProjectileType(), Projectile.damage, 3f, Projectile.owner, (float)target, 0f); + float projXSpeed = projX - Projectile.Center.X; + float projYSpeed = projY - Projectile.Center.Y; + float velocityMult = (float)Math.Sqrt((double)(projXSpeed * projXSpeed + projYSpeed * projYSpeed)); + velocityMult = speed / velocityMult; + projXSpeed *= velocityMult; + projYSpeed *= velocityMult; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, projXSpeed, projYSpeed, ModContent.ProjectileType(), Projectile.damage, 3f, Projectile.owner, (float)target, 0f); Projectile.ai[0] = 100f; } } diff --git a/Projectiles/Summon/CosmicViperSummon.cs b/Projectiles/Summon/CosmicViperSummon.cs index 8cf9a48e96..84bf3e4ab2 100644 --- a/Projectiles/Summon/CosmicViperSummon.cs +++ b/Projectiles/Summon/CosmicViperSummon.cs @@ -69,12 +69,12 @@ namespace CalamityMod.Projectiles.Summon for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) { int dustType = Main.rand.NextBool(3) ? 56 : 242; - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(dustIndex - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int dusty = Dust.NewDust(vector6 + vector7, 0, 0, dustType, vector7.X * 1.75f, vector7.Y * 1.75f, 100, default, 1.1f); + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(dustIndex - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int dusty = Dust.NewDust(rotate + faceDirection, 0, 0, dustType, faceDirection.X * 1.75f, faceDirection.Y * 1.75f, 100, default, 1.1f); Main.dust[dusty].noGravity = true; - Main.dust[dusty].velocity = vector7; + Main.dust[dusty].velocity = faceDirection; } // Construct a fake item to use with vanilla code for the sake of firing bullets. diff --git a/Projectiles/Summon/CrimslimeMinion.cs b/Projectiles/Summon/CrimslimeMinion.cs index 91296c842d..da2f4469f8 100644 --- a/Projectiles/Summon/CrimslimeMinion.cs +++ b/Projectiles/Summon/CrimslimeMinion.cs @@ -52,22 +52,22 @@ namespace CalamityMod.Projectiles.Summon CalamityPlayer modPlayer = player.Calamity(); if (dust == 0f) { - int num226 = 16; - for (int num227 = 0; num227 < num226; num227++) + int constant = 16; + for (int i = 0; i < constant; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 5, vector7.X * 1f, vector7.Y * 1f, 100, default, 1.1f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(i - (constant / 2 - 1)) * 6.28318548f / (float)constant), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int dust = Dust.NewDust(rotate + faceDirection, 0, 0, 5, faceDirection.X * 1f, faceDirection.Y * 1f, 100, default, 1.1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + Main.dust[dust].velocity = faceDirection; } dust += 1f; } - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isMinion = Projectile.type == ModContent.ProjectileType(); player.AddBuff(ModContent.BuffType(), 3600); - if (flag64) + if (isMinion) { if (player.dead) { @@ -83,9 +83,9 @@ namespace CalamityMod.Projectiles.Summon public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = texture2D13.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = texture2D13.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } diff --git a/Projectiles/Summon/CrimsonSlimeGodMinion.cs b/Projectiles/Summon/CrimsonSlimeGodMinion.cs index c24adbb9e2..0df9749d66 100644 --- a/Projectiles/Summon/CrimsonSlimeGodMinion.cs +++ b/Projectiles/Summon/CrimsonSlimeGodMinion.cs @@ -50,27 +50,27 @@ namespace CalamityMod.Projectiles.Summon CalamityPlayer modPlayer = player.Calamity(); if (dust == 0f) { - int num226 = 16; - for (int num227 = 0; num227 < num226; num227++) + int constant = 16; + for (int i = 0; i < constant; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 5, vector7.X * 1f, vector7.Y * 1f, 100, default, 1.1f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(i - (constant / 2 - 1)) * 6.28318548f / (float)constant), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int dust = Dust.NewDust(rotate + faceDirection, 0, 0, 5, faceDirection.X * 1f, faceDirection.Y * 1f, 100, default, 1.1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + Main.dust[dust].velocity = faceDirection; } dust += 1f; } - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isMinion = Projectile.type == ModContent.ProjectileType(); player.AddBuff(ModContent.BuffType(), 3600); if (!modPlayer.slimeGod) { Projectile.active = false; return; } - if (flag64) + if (isMinion) { if (player.dead) { diff --git a/Projectiles/Summon/DaedalusCrystal.cs b/Projectiles/Summon/DaedalusCrystal.cs index ea2bbbb0d5..7e43adef7d 100644 --- a/Projectiles/Summon/DaedalusCrystal.cs +++ b/Projectiles/Summon/DaedalusCrystal.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isMinion = Projectile.type == ModContent.ProjectileType(); Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); if (!modPlayer.daedalusCrystal) @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.active = false; return; } - if (flag64) + if (isMinion) { if (player.dead) { @@ -58,12 +58,12 @@ namespace CalamityMod.Projectiles.Summon dust--; if (dust >= 0) { - int num501 = 50; - for (int num502 = 0; num502 < num501; num502++) + int constant = 50; + for (int i = 0; i < constant; i++) { - int num503 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, 173, 0f, 0f, 0, default, 1f); - Main.dust[num503].velocity *= 2f; - Main.dust[num503].scale *= 1.15f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, 173, 0f, 0f, 0, default, 1f); + Main.dust[dust].velocity *= 2f; + Main.dust[dust].scale *= 1.15f; } } Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.35f / 255f, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.75f / 255f); @@ -79,9 +79,9 @@ namespace CalamityMod.Projectiles.Summon } Projectile.position.X = (int)Projectile.position.X; Projectile.position.Y = (int)Projectile.position.Y; - float num395 = (float)Main.mouseTextColor / 200f - 0.35f; - num395 *= 0.2f; - Projectile.scale = num395 + 0.95f; + float projScale = (float)Main.mouseTextColor / 200f - 0.35f; + projScale *= 0.2f; + Projectile.scale = projScale + 0.95f; if (Projectile.owner == Main.myPlayer) { if (Projectile.ai[0] != 0f) @@ -89,61 +89,61 @@ namespace CalamityMod.Projectiles.Summon Projectile.ai[0] -= 1f; return; } - bool flag18 = false; - float num506 = Projectile.Center.X; - float num507 = Projectile.Center.Y; - float num508 = 1000f; + bool isInRange = false; + float projX = Projectile.Center.X; + float projY = Projectile.Center.Y; + float attackRange = 1000f; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(Projectile, false)) { - float num539 = npc.position.X + (float)(npc.width / 2); - float num540 = npc.position.Y + (float)(npc.height / 2); - float num541 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num539) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num540); - if (num541 < num508 && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) + float npcX = npc.position.X + (float)(npc.width / 2); + float npcY = npc.position.Y + (float)(npc.height / 2); + float npcDistance = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); + if (npcDistance < attackRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) { - num506 = num539; - num507 = num540; - flag18 = true; + projX = npcX; + projY = npcY; + isInRange = true; } } } - if (!flag18) + if (!isInRange) { - for (int num512 = 0; num512 < Main.maxNPCs; num512++) + for (int j = 0; j < Main.maxNPCs; j++) { - if (Main.npc[num512].CanBeChasedBy(Projectile, false)) + if (Main.npc[j].CanBeChasedBy(Projectile, false)) { - float num513 = Main.npc[num512].position.X + (float)(Main.npc[num512].width / 2); - float num514 = Main.npc[num512].position.Y + (float)(Main.npc[num512].height / 2); - float num515 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num513) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num514); - if (num515 < num508 && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[num512].position, Main.npc[num512].width, Main.npc[num512].height)) + float otherNPCX = Main.npc[j].position.X + (float)(Main.npc[j].width / 2); + float otherNPCY = Main.npc[j].position.Y + (float)(Main.npc[j].height / 2); + float otherNPCDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - otherNPCX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - otherNPCY); + if (otherNPCDist < attackRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[j].position, Main.npc[j].width, Main.npc[j].height)) { - num508 = num515; - num506 = num513; - num507 = num514; - flag18 = true; + attackRange = otherNPCDist; + projX = otherNPCX; + projY = otherNPCY; + isInRange = true; } } } } - if (flag18) + if (isInRange) { - float num516 = num506; - float num517 = num507; - num506 -= Projectile.Center.X; - num507 -= Projectile.Center.Y; + float projXStore = projX; + float projYStore = projY; + projX -= Projectile.Center.X; + projY -= Projectile.Center.Y; int projectileType = ModContent.ProjectileType(); - float num403 = Main.rand.Next(10, 15); //modify the speed the projectile are shot. Lower number = slower projectile. - Vector2 vector29 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num404 = num516 - vector29.X; - float num405 = num517 - vector29.Y; - float num406 = (float)Math.Sqrt((double)(num404 * num404 + num405 * num405)); - num406 = num403 / num406; - num404 *= num406; - num405 *= num406; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X - 4f, Projectile.Center.Y, num404, num405, projectileType, Projectile.damage, 5f, Projectile.owner); + float randSpeed = Main.rand.Next(10, 15); //modify the speed the projectile are shot. Lower number = slower projectile. + Vector2 firingDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float projXDirection = projXStore - firingDirection.X; + float projYDirection = projYStore - firingDirection.Y; + float projSpeed = (float)Math.Sqrt((double)(projXDirection * projXDirection + projYDirection * projYDirection)); + projSpeed = randSpeed / projSpeed; + projXDirection *= projSpeed; + projYDirection *= projSpeed; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X - 4f, Projectile.Center.Y, projXDirection, projYDirection, projectileType, Projectile.damage, 5f, Projectile.owner); Projectile.ai[0] = 50f; } } diff --git a/Projectiles/Summon/DaedalusCrystalShot.cs b/Projectiles/Summon/DaedalusCrystalShot.cs index c1be5ff133..a0b655e073 100644 --- a/Projectiles/Summon/DaedalusCrystalShot.cs +++ b/Projectiles/Summon/DaedalusCrystalShot.cs @@ -34,33 +34,33 @@ namespace CalamityMod.Projectiles.Summon } for (int num457 = 0; num457 < 5; num457++) { - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.2f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int daeDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.2f); + Main.dust[daeDust].noGravity = true; + Main.dust[daeDust].velocity *= 0.5f; + Main.dust[daeDust].velocity += Projectile.velocity * 0.1f; } } public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item74, Projectile.position); - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.7f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1f); + Main.dust[dust2].velocity *= 2f; } } diff --git a/Projectiles/Summon/DankCreeperMinion.cs b/Projectiles/Summon/DankCreeperMinion.cs index 6090d4ebf8..07c506c085 100644 --- a/Projectiles/Summon/DankCreeperMinion.cs +++ b/Projectiles/Summon/DankCreeperMinion.cs @@ -43,22 +43,22 @@ namespace CalamityMod.Projectiles.Summon CalamityPlayer modPlayer = player.Calamity(); if (Projectile.localAI[0] == 0f) { - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int constant = 36; + for (int i = 0; i < constant; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 14, vector7.X * 1.5f, vector7.Y * 1.5f, 100, default, 1.4f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(i - (constant / 2 - 1)) * 6.28318548f / (float)constant), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int dust = Dust.NewDust(rotate + faceDirection, 0, 0, 14, faceDirection.X * 1.5f, faceDirection.Y * 1.5f, 100, default, 1.4f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + Main.dust[dust].velocity = faceDirection; } Projectile.localAI[0] += 1f; } - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isMinion = Projectile.type == ModContent.ProjectileType(); player.AddBuff(ModContent.BuffType(), 3600); - if (flag64) + if (isMinion) { if (player.dead) { @@ -70,16 +70,16 @@ namespace CalamityMod.Projectiles.Summon } } Projectile.MinionAntiClump(); - float num535 = Projectile.position.X; - float num536 = Projectile.position.Y; - float num537 = 1300f; - bool flag19 = false; - int num538 = 1100; + float projX = Projectile.position.X; + float projY = Projectile.position.Y; + float attackRange = 1300f; + bool canAttack = false; + int separationAnxietyDist = 1100; if (Projectile.ai[1] != 0f) { - num538 = 1800; + separationAnxietyDist = 1800; } - if (Math.Abs(Projectile.Center.X - Main.player[Projectile.owner].Center.X) + Math.Abs(Projectile.Center.Y - Main.player[Projectile.owner].Center.Y) > (float)num538) + if (Math.Abs(Projectile.Center.X - Main.player[Projectile.owner].Center.X) + Math.Abs(Projectile.Center.Y - Main.player[Projectile.owner].Center.Y) > (float)separationAnxietyDist) { Projectile.ai[0] = 1f; } @@ -90,64 +90,64 @@ namespace CalamityMod.Projectiles.Summon NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(Projectile, false)) { - float num539 = npc.position.X + (float)(npc.width / 2); - float num540 = npc.position.Y + (float)(npc.height / 2); - float num541 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num539) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num540); - if (num541 < num537 && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) + float npcX = npc.position.X + (float)(npc.width / 2); + float npcY = npc.position.Y + (float)(npc.height / 2); + float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); + if (npcDist < attackRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) { - num535 = num539; - num536 = num540; - flag19 = true; + projX = npcX; + projY = npcY; + canAttack = true; } } } - if (!flag19) + if (!canAttack) { - for (int num542 = 0; num542 < Main.maxNPCs; num542++) + for (int j = 0; j < Main.maxNPCs; j++) { - if (Main.npc[num542].CanBeChasedBy(Projectile, false)) + if (Main.npc[j].CanBeChasedBy(Projectile, false)) { - float num543 = Main.npc[num542].position.X + (float)(Main.npc[num542].width / 2); - float num544 = Main.npc[num542].position.Y + (float)(Main.npc[num542].height / 2); - float num545 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num543) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num544); - if (num545 < num537 && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[num542].position, Main.npc[num542].width, Main.npc[num542].height)) + float otherNPCX = Main.npc[j].position.X + (float)(Main.npc[j].width / 2); + float otherNPCY = Main.npc[j].position.Y + (float)(Main.npc[j].height / 2); + float otherNPCDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - otherNPCX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - otherNPCY); + if (otherNPCDist < attackRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[j].position, Main.npc[j].width, Main.npc[j].height)) { - num537 = num545; - num535 = num543; - num536 = num544; - flag19 = true; + attackRange = otherNPCDist; + projX = otherNPCX; + projY = otherNPCY; + canAttack = true; } } } } } - if (!flag19) + if (!canAttack) { - float num546 = 8f; + float returnSpeed = 8f; if (Projectile.ai[0] == 1f) { - num546 = 12f; + returnSpeed = 12f; } - Vector2 vector42 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num547 = player.Center.X - vector42.X; - float num548 = player.Center.Y - vector42.Y - 60f; - float num549 = (float)Math.Sqrt((double)(num547 * num547 + num548 * num548)); - if (num549 < 100f && Projectile.ai[0] == 1f && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + Vector2 playerDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float playerXDist = player.Center.X - playerDirection.X; + float playerYDist = player.Center.Y - playerDirection.Y - 60f; + float playerDist = (float)Math.Sqrt((double)(playerXDist * playerXDist + playerYDist * playerYDist)); + if (playerDist < 100f && Projectile.ai[0] == 1f && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) { Projectile.ai[0] = 0f; } - if (num549 > 2000f) + if (playerDist > 2000f) { Projectile.position.X = player.Center.X - (float)(Projectile.width / 2); Projectile.position.Y = player.Center.Y - (float)(Projectile.width / 2); } - if (num549 > 70f) + if (playerDist > 70f) { - num549 = num546 / num549; - num547 *= num549; - num548 *= num549; - Projectile.velocity.X = (Projectile.velocity.X * 20f + num547) / 21f; - Projectile.velocity.Y = (Projectile.velocity.Y * 20f + num548) / 21f; + playerDist = returnSpeed / playerDist; + playerXDist *= playerDist; + playerYDist *= playerDist; + Projectile.velocity.X = (Projectile.velocity.X * 20f + playerXDist) / 21f; + Projectile.velocity.Y = (Projectile.velocity.Y * 20f + playerYDist) / 21f; } else { @@ -177,20 +177,20 @@ namespace CalamityMod.Projectiles.Summon } if (Projectile.ai[1] == 0f) { - float num550 = 8f; //12 - Vector2 vector43 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num551 = num535 - vector43.X; - float num552 = num536 - vector43.Y; - float num553 = (float)Math.Sqrt((double)(num551 * num551 + num552 * num552)); - if (num553 < 100f) + float hoverSpeed = 8f; //12 + Vector2 playerDirectionAgain = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float playerXDistAgain = projX - playerDirectionAgain.X; + float playerYDistAgain = projY - playerDirectionAgain.Y; + float playerDistAgain = (float)Math.Sqrt((double)(playerXDistAgain * playerXDistAgain + playerYDistAgain * playerYDistAgain)); + if (playerDistAgain < 100f) { - num550 = 10f; //14 + hoverSpeed = 10f; //14 } - num553 = num550 / num553; - num551 *= num553; - num552 *= num553; - Projectile.velocity.X = (Projectile.velocity.X * 40f + num551) / 41f; - Projectile.velocity.Y = (Projectile.velocity.Y * 40f + num552) / 41f; + playerDistAgain = hoverSpeed / playerDistAgain; + playerXDistAgain *= playerDistAgain; + playerYDistAgain *= playerDistAgain; + Projectile.velocity.X = (Projectile.velocity.X * 40f + playerXDistAgain) / 41f; + Projectile.velocity.Y = (Projectile.velocity.Y * 40f + playerYDistAgain) / 41f; } else { diff --git a/Projectiles/Summon/Dreadmine.cs b/Projectiles/Summon/Dreadmine.cs index eb4a1da0ac..51b9079b8c 100644 --- a/Projectiles/Summon/Dreadmine.cs +++ b/Projectiles/Summon/Dreadmine.cs @@ -27,28 +27,28 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - float num945 = 1f; - float num946 = 1f; + float xflag = 1f; + float yflag = 1f; if (Projectile.identity % 6 == 0) { - num946 *= -1f; + yflag *= -1f; } if (Projectile.identity % 6 == 1) { - num945 *= -1f; + xflag *= -1f; } if (Projectile.identity % 6 == 2) { - num946 *= -1f; - num945 *= -1f; + yflag *= -1f; + xflag *= -1f; } if (Projectile.identity % 6 == 3) { - num946 = 0f; + yflag = 0f; } if (Projectile.identity % 6 == 4) { - num945 = 0f; + xflag = 0f; } Projectile.localAI[1] += 1f; if (Projectile.localAI[1] > 60f) @@ -57,13 +57,13 @@ namespace CalamityMod.Projectiles.Summon } if (Projectile.localAI[1] >= -60f) { - Projectile.velocity.X = Projectile.velocity.X + 0.002f * num946; - Projectile.velocity.Y = Projectile.velocity.Y + 0.002f * num945; + Projectile.velocity.X = Projectile.velocity.X + 0.002f * yflag; + Projectile.velocity.Y = Projectile.velocity.Y + 0.002f * xflag; } else { - Projectile.velocity.X = Projectile.velocity.X - 0.002f * num946; - Projectile.velocity.Y = Projectile.velocity.Y - 0.002f * num945; + Projectile.velocity.X = Projectile.velocity.X - 0.002f * yflag; + Projectile.velocity.Y = Projectile.velocity.Y - 0.002f * xflag; } Projectile.ai[0] += 1f; if (Projectile.ai[0] > 5400f) @@ -80,36 +80,36 @@ namespace CalamityMod.Projectiles.Summon } else { - float num947 = (Projectile.Center - Main.player[Projectile.owner].Center).Length() / 100f; - if (num947 > 4f) + float playerDist = (Projectile.Center - Main.player[Projectile.owner].Center).Length() / 100f; + if (playerDist > 4f) { - num947 *= 1.1f; + playerDist *= 1.1f; } - if (num947 > 5f) + if (playerDist > 5f) { - num947 *= 1.2f; + playerDist *= 1.2f; } - if (num947 > 6f) + if (playerDist > 6f) { - num947 *= 1.3f; + playerDist *= 1.3f; } - if (num947 > 7f) + if (playerDist > 7f) { - num947 *= 1.4f; + playerDist *= 1.4f; } - if (num947 > 8f) + if (playerDist > 8f) { - num947 *= 1.5f; + playerDist *= 1.5f; } - if (num947 > 9f) + if (playerDist > 9f) { - num947 *= 1.6f; + playerDist *= 1.6f; } - if (num947 > 10f) + if (playerDist > 10f) { - num947 *= 1.7f; + playerDist *= 1.7f; } - Projectile.ai[0] += num947; + Projectile.ai[0] += playerDist; if (Projectile.alpha > 0) { Projectile.alpha -= 25; @@ -119,49 +119,49 @@ namespace CalamityMod.Projectiles.Summon } } } - bool flag49 = false; + bool canAttack = false; Vector2 center12 = new Vector2(0f, 0f); - float num948 = 600f; + float attackDistance = 600f; if (Main.player[Projectile.owner].HasMinionAttackTargetNPC) { NPC npc = Main.npc[Main.player[Projectile.owner].MinionAttackTargetNPC]; if (npc.CanBeChasedBy(Projectile, false)) { - float num950 = npc.position.X + (float)(npc.width / 2); - float num951 = npc.position.Y + (float)(npc.height / 2); - float num952 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num950) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num951); - if (num952 < num948) + float npcX = npc.position.X + (float)(npc.width / 2); + float npcY = npc.position.Y + (float)(npc.height / 2); + float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); + if (npcDist < attackDistance) { - num948 = num952; + attackDistance = npcDist; center12 = npc.Center; - flag49 = true; + canAttack = true; } } } - if (!flag49) + if (!canAttack) { - for (int num949 = 0; num949 < Main.npc.Length; num949++) + for (int i = 0; i < Main.npc.Length; i++) { - if (Main.npc[num949].CanBeChasedBy(Projectile, false)) + if (Main.npc[i].CanBeChasedBy(Projectile, false)) { - float num950 = Main.npc[num949].position.X + (float)(Main.npc[num949].width / 2); - float num951 = Main.npc[num949].position.Y + (float)(Main.npc[num949].height / 2); - float num952 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num950) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num951); - if (num952 < num948) + float npcX = Main.npc[i].position.X + (float)(Main.npc[i].width / 2); + float npcY = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2); + float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); + if (npcDist < attackDistance) { - num948 = num952; - center12 = Main.npc[num949].Center; - flag49 = true; + attackDistance = npcDist; + center12 = Main.npc[i].Center; + canAttack = true; } } } } - if (flag49) + if (canAttack) { - Vector2 vector101 = center12 - Projectile.Center; - vector101.Normalize(); - vector101 *= 0.75f; - Projectile.velocity = (Projectile.velocity * 10f + vector101) / 10.8f; //11 + Vector2 attackPosition = center12 - Projectile.Center; + attackPosition.Normalize(); + attackPosition *= 0.75f; + Projectile.velocity = (Projectile.velocity * 10f + attackPosition) / 10.8f; //11 return; } if ((double)Projectile.velocity.Length() > 0.2) @@ -182,23 +182,23 @@ namespace CalamityMod.Projectiles.Summon Projectile.localNPCHitCooldown = 10; Projectile.Damage(); SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - for (int num621 = 0; num621 < 20; num621++) + for (int j = 0; j < 20; j++) { - int num622 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int k = 0; k < 30; k++) { - int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 3f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 2f); + Main.dust[dust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) diff --git a/Projectiles/Summon/DreadmineTurret.cs b/Projectiles/Summon/DreadmineTurret.cs index 1302762e6f..9bcb120628 100644 --- a/Projectiles/Summon/DreadmineTurret.cs +++ b/Projectiles/Summon/DreadmineTurret.cs @@ -49,62 +49,61 @@ namespace CalamityMod.Projectiles.Summon } if (Main.rand.NextBool(15)) { - int num = 0; + int mineAmt = 0; for (int i = 0; i < Main.maxProjectiles; i++) { if (Main.projectile[i].active && Main.projectile[i].owner == Main.myPlayer && Main.projectile[i].type == ModContent.ProjectileType()) { - num++; + mineAmt++; } } - if (Main.rand.Next(15) >= num && num < 10) + if (Main.rand.Next(15) >= mineAmt && mineAmt < 10) { - int num2 = 50; - int num3 = 24; - int num4 = 90; - for (int j = 0; j < num2; j++) + int spawnVariance = 24; + int moreSpawnVariance = 90; + for (int j = 0; j < 50; j++) { - int num5 = Main.rand.Next(200 - j * 2, 400 + j * 2); + int randSpawn = Main.rand.Next(200 - j * 2, 400 + j * 2); Vector2 center = Projectile.Center; - center.X += (float)Main.rand.Next(-num5, num5 + 1); - center.Y += (float)Main.rand.Next(-num5, num5 + 1); - if (!Collision.SolidCollision(center, num3, num3)) + center.X += (float)Main.rand.Next(-randSpawn, randSpawn + 1); + center.Y += (float)Main.rand.Next(-randSpawn, randSpawn + 1); + if (!Collision.SolidCollision(center, spawnVariance, spawnVariance)) { - center.X += (float)(num3 / 2); - center.Y += (float)(num3 / 2); + center.X += (float)(spawnVariance / 2); + center.Y += (float)(spawnVariance / 2); if (Collision.CanHit(new Vector2(Projectile.Center.X, Projectile.position.Y), 1, 1, center, 1, 1) || Collision.CanHit(new Vector2(Projectile.Center.X, Projectile.position.Y - 50f), 1, 1, center, 1, 1)) { - int num6 = (int)center.X / 16; - int num7 = (int)center.Y / 16; - bool flag = false; - if (Main.rand.NextBool(3) && Main.tile[num6, num7] != null && Main.tile[num6, num7].WallType > 0) + int tileX = (int)center.X / 16; + int tileY = (int)center.Y / 16; + bool canSpawnMine = false; + if (Main.rand.NextBool(3) && Main.tile[tileX, tileY] != null && Main.tile[tileX, tileY].WallType > 0) { - flag = true; + canSpawnMine = true; } else { - center.X -= (float)(num4 / 2); - center.Y -= (float)(num4 / 2); - if (Collision.SolidCollision(center, num4, num4)) + center.X -= (float)(moreSpawnVariance / 2); + center.Y -= (float)(moreSpawnVariance / 2); + if (Collision.SolidCollision(center, moreSpawnVariance, moreSpawnVariance)) { - center.X += (float)(num4 / 2); - center.Y += (float)(num4 / 2); - flag = true; + center.X += (float)(moreSpawnVariance / 2); + center.Y += (float)(moreSpawnVariance / 2); + canSpawnMine = true; } } - if (flag) + if (canSpawnMine) { for (int k = 0; k < Main.maxProjectiles; k++) { if (Main.projectile[k].active && Main.projectile[k].owner == Main.myPlayer && Main.projectile[k].type == ModContent.ProjectileType() && (center - Main.projectile[k].Center).Length() < 48f) { - flag = false; + canSpawnMine = false; break; } } - if (flag && Main.myPlayer == Projectile.owner) + if (canSpawnMine && Main.myPlayer == Projectile.owner) { Projectile.NewProjectile(Projectile.GetSource_FromThis(), center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); } diff --git a/Projectiles/Summon/ElementalAxeMinion.cs b/Projectiles/Summon/ElementalAxeMinion.cs index fbdd2ee699..3151f632df 100644 --- a/Projectiles/Summon/ElementalAxeMinion.cs +++ b/Projectiles/Summon/ElementalAxeMinion.cs @@ -1,4 +1,5 @@ -using CalamityMod.Buffs.Summon; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -40,9 +41,9 @@ namespace CalamityMod.Projectiles.Summon { Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isMinion = Projectile.type == ModContent.ProjectileType(); player.AddBuff(ModContent.BuffType(), 3600); - if (flag64) + if (isMinion) { if (player.dead) { @@ -69,5 +70,9 @@ namespace CalamityMod.Projectiles.Summon Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); return false; } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 60); + } } } diff --git a/Projectiles/Summon/EndoCooperBody.cs b/Projectiles/Summon/EndoCooperBody.cs index 784d0ece09..259fe2c373 100644 --- a/Projectiles/Summon/EndoCooperBody.cs +++ b/Projectiles/Summon/EndoCooperBody.cs @@ -59,11 +59,11 @@ namespace CalamityMod.Projectiles.Summon } //Apply the buff - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isMinion = Projectile.type == ModContent.ProjectileType(); Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); player.AddBuff(ModContent.BuffType(), 3600); - if (flag64) + if (isMinion) { if (player.dead) { @@ -133,7 +133,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.Kill(); Projectile.MinionAntiClump(); - bool flag24 = false; + bool accelerate = false; if (Projectile.ai[0] == 2f) { Projectile.ai[1] += 1f; @@ -148,10 +148,10 @@ namespace CalamityMod.Projectiles.Summon } else { - flag24 = true; + accelerate = true; } } - if (flag24) + if (accelerate) { return; } @@ -173,9 +173,9 @@ namespace CalamityMod.Projectiles.Summon } if (!gotoenemy) { - for (int num645 = 0; num645 < Main.maxNPCs; num645++) + for (int i = 0; i < Main.maxNPCs; i++) { - NPC nPC2 = Main.npc[num645]; + NPC nPC2 = Main.npc[i]; if (nPC2.CanBeChasedBy(Projectile, false)) { float disttoobjective = Vector2.Distance(nPC2.Center, Projectile.Center); diff --git a/Projectiles/Summon/EndoCooperLimbs.cs b/Projectiles/Summon/EndoCooperLimbs.cs index 053032e9c7..da0a05859b 100644 --- a/Projectiles/Summon/EndoCooperLimbs.cs +++ b/Projectiles/Summon/EndoCooperLimbs.cs @@ -47,12 +47,12 @@ namespace CalamityMod.Projectiles.Summon { Projectile body = Main.projectile[(int)Projectile.ai[1]]; //Apply the buff - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isMinion = Projectile.type == ModContent.ProjectileType(); Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); player.AddBuff(ModContent.BuffType(), 3600); - if (flag64) + if (isMinion) { if (player.dead) { diff --git a/Projectiles/Summon/EndoFire.cs b/Projectiles/Summon/EndoFire.cs index 7575ad1540..ffb48ae5bd 100644 --- a/Projectiles/Summon/EndoFire.cs +++ b/Projectiles/Summon/EndoFire.cs @@ -52,30 +52,30 @@ namespace CalamityMod.Projectiles.Summon Projectile.velocity.X *= speedY; if (Projectile.ai[0] > 20f) { - float num296 = 1f; + float dustScale = 1f; if (Projectile.ai[0] == 21f) { - num296 = 0.25f; + dustScale = 0.25f; } else if (Projectile.ai[0] == 22f) { - num296 = 0.5f; + dustScale = 0.5f; } else if (Projectile.ai[0] == 23f) { - num296 = 0.75f; + dustScale = 0.75f; } Projectile.ai[0] += 1f; - int num297 = Main.rand.NextBool() ? 68 : 67; + int dustType = Main.rand.NextBool() ? 68 : 67; if (Main.rand.NextBool(4)) { - num297 = 80; + dustType = 80; } if (Main.rand.NextBool()) { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 0.8f); - Dust dust = Main.dust[num299]; + int endoDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 0.8f); + Dust dust = Main.dust[endoDust]; if (Main.rand.NextBool(3)) { dust.scale *= 1.5f; @@ -89,7 +89,7 @@ namespace CalamityMod.Projectiles.Summon dust.noGravity = true; dust.velocity.X *= 0.8f; dust.velocity.Y *= 0.8f; - dust.scale *= num296; + dust.scale *= dustScale; dust.velocity += Projectile.velocity; dust.noLight = true; diff --git a/Projectiles/Summon/EnergyOrb.cs b/Projectiles/Summon/EnergyOrb.cs index 0cf4e7950e..114eb15353 100644 --- a/Projectiles/Summon/EnergyOrb.cs +++ b/Projectiles/Summon/EnergyOrb.cs @@ -26,10 +26,10 @@ namespace CalamityMod.Projectiles.Summon Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { - int num469 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 132, 0f, 0f, 100, default, 1f); + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 132, 0f, 0f, 100, default, 1f); if (Main.rand.Next(6) != 0) - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0f; } NPC potentialTarget = Projectile.Center.MinionHoming(400f, Main.player[Projectile.owner]); if (potentialTarget != null) diff --git a/Projectiles/Summon/FieryDraconid.cs b/Projectiles/Summon/FieryDraconid.cs index 90d69d84fa..366d0f51f8 100644 --- a/Projectiles/Summon/FieryDraconid.cs +++ b/Projectiles/Summon/FieryDraconid.cs @@ -240,9 +240,9 @@ namespace CalamityMod.Projectiles.Summon { SpriteEffects spriteEffects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Rectangle(0, y6, texture2D13.Width, num214), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture2D13.Width / 2f, num214 / 2f), Projectile.scale, spriteEffects, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Rectangle(0, y6, texture2D13.Width, framing), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture2D13.Width / 2f, framing / 2f), Projectile.scale, spriteEffects, 0); return false; } } diff --git a/Projectiles/Summon/FlameBlast.cs b/Projectiles/Summon/FlameBlast.cs index 3cd5d56e5d..e94c7641d6 100644 --- a/Projectiles/Summon/FlameBlast.cs +++ b/Projectiles/Summon/FlameBlast.cs @@ -40,33 +40,33 @@ namespace CalamityMod.Projectiles.Summon Projectile.height = 20; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 3f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); + Main.dust[dust2].velocity *= 2f; } count += 1f; } Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { - for (int num468 = 0; num468 < 5; num468++) + for (int k = 0; k < 5; k++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 0.75f); - Main.dust[num469].velocity *= 0f; + int otherDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 0.75f); + Main.dust[otherDust].velocity *= 0f; } } NPC potentialTarget = Projectile.Center.MinionHoming(300f, Main.player[Projectile.owner]); diff --git a/Projectiles/Summon/FlameBurst.cs b/Projectiles/Summon/FlameBurst.cs index 971849ce34..6a02840309 100644 --- a/Projectiles/Summon/FlameBurst.cs +++ b/Projectiles/Summon/FlameBurst.cs @@ -40,33 +40,33 @@ namespace CalamityMod.Projectiles.Summon Projectile.height = 20; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 3f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); + Main.dust[dust2].velocity *= 2f; } count += 1f; } Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { - for (int num468 = 0; num468 < 5; num468++) + for (int k = 0; k < 5; k++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 0.75f); - Main.dust[num469].velocity *= 0f; + int otherDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 0.75f); + Main.dust[otherDust].velocity *= 0f; } } NPC potentialTarget = Projectile.Center.MinionHoming(1200f, Main.player[Projectile.owner]); diff --git a/Projectiles/Summon/FlowersOfMortalityPetal.cs b/Projectiles/Summon/FlowersOfMortalityPetal.cs index 7c8378a9bb..c5e3c22aa3 100644 --- a/Projectiles/Summon/FlowersOfMortalityPetal.cs +++ b/Projectiles/Summon/FlowersOfMortalityPetal.cs @@ -1,4 +1,5 @@ -using CalamityMod.Buffs.Summon; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -92,7 +93,10 @@ namespace CalamityMod.Projectiles.Summon return false; } - + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 30); + } public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/ForbiddenCircletEater.cs b/Projectiles/Summon/ForbiddenCircletEater.cs index ca0efa3029..6263c0dca4 100644 --- a/Projectiles/Summon/ForbiddenCircletEater.cs +++ b/Projectiles/Summon/ForbiddenCircletEater.cs @@ -1,7 +1,8 @@ -using Microsoft.Xna.Framework; -using System; +using System; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Summon { public class ForbiddenCircletEater : ModProjectile, ILocalizedModType @@ -51,23 +52,21 @@ namespace CalamityMod.Projectiles.Summon { Projectile.frame = 0; } - for (int num369 = 0; num369 < 1; num369++) - { - int dustType = 159; - float num370 = Projectile.velocity.X / 3f * (float)num369; - float num371 = Projectile.velocity.Y / 3f * (float)num369; - int num372 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num372]; - dust.position.X = Projectile.Center.X - num370; - dust.position.Y = Projectile.Center.Y - num371; - dust.velocity *= 0f; - dust.scale = 0.5f; - } + int dustType = 159; + float slowXVel = Projectile.velocity.X / 3f; + float slowYVel = Projectile.velocity.Y / 3f; + int dustID = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[dustID]; + dust.position.X = Projectile.Center.X - slowXVel; + dust.position.Y = Projectile.Center.Y - slowYVel; + dust.velocity *= 0f; + dust.scale = 0.5f; + Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) + MathHelper.PiOver2; - float num373 = Projectile.position.X; - float num374 = Projectile.position.Y; - float num375 = 100000f; - bool flag10 = false; + float projX = Projectile.position.X; + float projY = Projectile.position.Y; + float attackDistance = 100000f; + bool canAttack = false; Projectile.ai[0] += 1f; if (Projectile.ai[0] > 30f) { @@ -76,83 +75,82 @@ namespace CalamityMod.Projectiles.Summon NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(Projectile, false)) { - float num377 = npc.position.X + (float)(npc.width / 2); - float num378 = npc.position.Y + (float)(npc.height / 2); - float num379 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num377) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num378); - if (num379 < 640f && num379 < num375 && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) + float npcX = npc.position.X + (float)(npc.width / 2); + float npcY = npc.position.Y + (float)(npc.height / 2); + float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); + if (npcDist < 640f && npcDist < attackDistance && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) { - num375 = num379; - num373 = num377; - num374 = num378; - flag10 = true; + attackDistance = npcDist; + projX = npcX; + projY = npcY; + canAttack = true; } } } - if (!flag10) + if (!canAttack) { - for (int num376 = 0; num376 < Main.maxNPCs; num376++) + for (int j = 0; j < Main.maxNPCs; j++) { - NPC npc = Main.npc[num376]; + NPC npc = Main.npc[j]; if (npc.CanBeChasedBy(Projectile, false)) { - float num377 = npc.position.X + (float)(npc.width / 2); - float num378 = npc.position.Y + (float)(npc.height / 2); - float num379 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num377) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num378); - if (num379 < 640f && num379 < num375 && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) + float npcX = npc.position.X + (float)(npc.width / 2); + float npcY = npc.position.Y + (float)(npc.height / 2); + float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); + if (npcDist < 640f && npcDist < attackDistance && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) { - num375 = num379; - num373 = num377; - num374 = num378; - flag10 = true; + attackDistance = npcDist; + projX = npcX; + projY = npcY; + canAttack = true; } } } } } - if (!flag10) + if (!canAttack) { - num373 = Projectile.position.X + (float)(Projectile.width / 2) + Projectile.velocity.X * 100f; - num374 = Projectile.position.Y + (float)(Projectile.height / 2) + Projectile.velocity.Y * 100f; + projX = Projectile.position.X + (float)(Projectile.width / 2) + Projectile.velocity.X * 100f; + projY = Projectile.position.Y + (float)(Projectile.height / 2) + Projectile.velocity.Y * 100f; } - float num380 = 10f; - float num381 = 0.16f; - Vector2 vector30 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num382 = num373 - vector30.X; - float num383 = num374 - vector30.Y; - float num384 = (float)Math.Sqrt((double)(num382 * num382 + num383 * num383)); - num384 = num380 / num384; - num382 *= num384; - num383 *= num384; - if (Projectile.velocity.X < num382) + float projVel = 0.16f; + Vector2 playerDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float playerX = projX - playerDirection.X; + float playerY = projY - playerDirection.Y; + float playerDist = (float)Math.Sqrt((double)(playerX * playerX + playerY * playerY)); + playerDist = 10f / playerDist; + playerX *= playerDist; + playerY *= playerDist; + if (Projectile.velocity.X < playerX) { - Projectile.velocity.X = Projectile.velocity.X + num381; - if (Projectile.velocity.X < 0f && num382 > 0f) + Projectile.velocity.X = Projectile.velocity.X + projVel; + if (Projectile.velocity.X < 0f && playerX > 0f) { - Projectile.velocity.X = Projectile.velocity.X + num381 * 2f; + Projectile.velocity.X = Projectile.velocity.X + projVel * 2f; } } - else if (Projectile.velocity.X > num382) + else if (Projectile.velocity.X > playerX) { - Projectile.velocity.X = Projectile.velocity.X - num381; - if (Projectile.velocity.X > 0f && num382 < 0f) + Projectile.velocity.X = Projectile.velocity.X - projVel; + if (Projectile.velocity.X > 0f && playerX < 0f) { - Projectile.velocity.X = Projectile.velocity.X - num381 * 2f; + Projectile.velocity.X = Projectile.velocity.X - projVel * 2f; } } - if (Projectile.velocity.Y < num383) + if (Projectile.velocity.Y < playerY) { - Projectile.velocity.Y = Projectile.velocity.Y + num381; - if (Projectile.velocity.Y < 0f && num383 > 0f) + Projectile.velocity.Y = Projectile.velocity.Y + projVel; + if (Projectile.velocity.Y < 0f && playerY > 0f) { - Projectile.velocity.Y = Projectile.velocity.Y + num381 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y + projVel * 2f; } } - else if (Projectile.velocity.Y > num383) + else if (Projectile.velocity.Y > playerY) { - Projectile.velocity.Y = Projectile.velocity.Y - num381; - if (Projectile.velocity.Y > 0f && num383 < 0f) + Projectile.velocity.Y = Projectile.velocity.Y - projVel; + if (Projectile.velocity.Y > 0f && playerY < 0f) { - Projectile.velocity.Y = Projectile.velocity.Y - num381 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y - projVel * 2f; } } } diff --git a/Projectiles/Summon/FrostMistFriendly.cs b/Projectiles/Summon/FrostMistFriendly.cs index 5bd1922125..3c117c9f9e 100644 --- a/Projectiles/Summon/FrostMistFriendly.cs +++ b/Projectiles/Summon/FrostMistFriendly.cs @@ -40,14 +40,14 @@ namespace CalamityMod.Projectiles.Summon } if (Projectile.ai[1] == 0f) { - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 187, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 187, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } Projectile.ai[1] = 1f; @@ -73,15 +73,15 @@ namespace CalamityMod.Projectiles.Summon Projectile.localAI[0] = 0f; } } - int num103 = (int)Player.FindClosest(Projectile.Center, 1, 1); + int playerOwner = (int)Player.FindClosest(Projectile.Center, 1, 1); Projectile.ai[1] += 1f; if (Projectile.ai[1] < 110f && Projectile.ai[1] > 30f) { float scaleFactor2 = Projectile.velocity.Length(); - Vector2 vector11 = Main.player[num103].Center - Projectile.Center; - vector11.Normalize(); - vector11 *= scaleFactor2; - Projectile.velocity = (Projectile.velocity * 24f + vector11) / 25f; + Vector2 playerDist = Main.player[playerOwner].Center - Projectile.Center; + playerDist.Normalize(); + playerDist *= scaleFactor2; + Projectile.velocity = (Projectile.velocity * 24f + playerDist) / 25f; Projectile.velocity.Normalize(); Projectile.velocity *= scaleFactor2; } @@ -99,9 +99,9 @@ namespace CalamityMod.Projectiles.Summon public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = texture2D13.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = texture2D13.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } diff --git a/Projectiles/Summon/GhostlyMine.cs b/Projectiles/Summon/GhostlyMine.cs index 9eb4d9e887..274acd6d97 100644 --- a/Projectiles/Summon/GhostlyMine.cs +++ b/Projectiles/Summon/GhostlyMine.cs @@ -45,23 +45,23 @@ namespace CalamityMod.Projectiles.Summon Projectile.ai[1] += 1f; if (spawnDust) { - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 15; num623++) + for (int j = 0; j < 15; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 3f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 2f); + Main.dust[dust2].velocity *= 2f; } spawnDust = false; } @@ -85,23 +85,23 @@ namespace CalamityMod.Projectiles.Summon Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - for (int num621 = 0; num621 < 30; num621++) + for (int i = 0; i < 30; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 1.2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 60; num623++) + for (int j = 0; j < 60; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 1.7f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 180, 0f, 0f, 100, default, 1f); + Main.dust[dust2].velocity *= 2f; } } } diff --git a/Projectiles/Summon/GlacialEmbracePointyThing.cs b/Projectiles/Summon/GlacialEmbracePointyThing.cs index 856abdb1ad..c91831d4a8 100644 --- a/Projectiles/Summon/GlacialEmbracePointyThing.cs +++ b/Projectiles/Summon/GlacialEmbracePointyThing.cs @@ -32,20 +32,20 @@ namespace CalamityMod.Projectiles.Summon target = CalamityUtils.MinionHoming(Projectile.Center, 1000f, Main.player[Projectile.owner]); if (target != null) //target found { - float num550 = 40f; - Vector2 vector43 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num551 = target.Center.X - vector43.X; - float num552 = target.Center.Y - vector43.Y; - float num553 = (float)Math.Sqrt((double)(num551 * num551 + num552 * num552)); - if (num553 < 100f) + float projVel = 40f; + Vector2 targetDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float targetX = target.Center.X - targetDirection.X; + float targetY = target.Center.Y - targetDirection.Y; + float targetDist = (float)Math.Sqrt((double)(targetX * targetX + targetY * targetY)); + if (targetDist < 100f) { - num550 = 28f; //14 + projVel = 28f; //14 } - num553 = num550 / num553; - num551 *= num553; - num552 *= num553; - Projectile.velocity.X = (Projectile.velocity.X * 20f + num551) / 21f; - Projectile.velocity.Y = (Projectile.velocity.Y * 20f + num552) / 21f; + targetDist = projVel / targetDist; + targetX *= targetDist; + targetY *= targetDist; + Projectile.velocity.X = (Projectile.velocity.X * 20f + targetX) / 21f; + Projectile.velocity.Y = (Projectile.velocity.Y * 20f + targetY) / 21f; } } } diff --git a/Projectiles/Summon/HauntedDishes.cs b/Projectiles/Summon/HauntedDishes.cs index b3587b17d5..8660460405 100644 --- a/Projectiles/Summon/HauntedDishes.cs +++ b/Projectiles/Summon/HauntedDishes.cs @@ -44,15 +44,15 @@ namespace CalamityMod.Projectiles.Summon if (dust == 0f) { int dustAmt = 36; - for (int num227 = 0; num227 < dustAmt; num227++) + for (int i = 0; i < dustAmt; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int dusty = Dust.NewDust(vector6 + vector7, 0, 0, 7, vector7.X * 1.1f, vector7.Y * 1.1f, 100, default, 1.4f); + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int dusty = Dust.NewDust(rotate + faceDirection, 0, 0, 7, faceDirection.X * 1.1f, faceDirection.Y * 1.1f, 100, default, 1.4f); Main.dust[dusty].noGravity = true; Main.dust[dusty].noLight = true; - Main.dust[dusty].velocity = vector7; + Main.dust[dusty].velocity = faceDirection; } dust += 1f; } @@ -69,22 +69,20 @@ namespace CalamityMod.Projectiles.Summon Projectile.timeLeft = 2; } } - bool flag1 = false; - bool flag2 = false; - bool flag3 = false; - bool flag4 = false; - int num1 = 60 + 30 * Projectile.minionPos; + bool minionMovingLeft = false; + bool minionMovingRight = false; + bool minionBelowPlayer = false; + bool minionShouldJump = false; if (Projectile.lavaWet) { Projectile.ai[0] = 1f; Projectile.ai[1] = 0f; } - int num2 = 10; - int num3 = 40 * (Projectile.minionPos + 1) * player.direction; - if (player.position.X + (float) (player.width / 2) < Projectile.position.X + (float) (Projectile.width / 2) - (float) num2 + (float) num3) - flag1 = true; - else if (player.position.X + (float) (player.width / 2) > Projectile.position.X + (float) (Projectile.width / 2) + (float) num2 + (float) num3) - flag2 = true; + int idlePos = 40 * (Projectile.minionPos + 1) * player.direction; + if (player.position.X + (float) (player.width / 2) < Projectile.position.X + (float) (Projectile.width / 2) - 10f + (float) idlePos) + minionMovingLeft = true; + else if (player.position.X + (float) (player.width / 2) > Projectile.position.X + (float) (Projectile.width / 2) + 10f + (float) idlePos) + minionMovingRight = true; if (Projectile.ai[1] == 0f) { @@ -92,9 +90,9 @@ namespace CalamityMod.Projectiles.Summon conflict1 += 40 * Projectile.minionPos; if (Projectile.localAI[0] > 0f) conflict1 += 500; - Vector2 vector2 = new Vector2(Projectile.position.X + (float) Projectile.width * 0.5f, Projectile.position.Y + (float) Projectile.height * 0.5f); - float playerX = player.position.X + (float) (player.width / 2) - vector2.X; - float playerY = player.position.Y + (float) (player.height / 2) - vector2.Y; + Vector2 idleMinionPos = new Vector2(Projectile.position.X + (float) Projectile.width * 0.5f, Projectile.position.Y + (float) Projectile.height * 0.5f); + float playerX = player.position.X + (float) (player.width / 2) - idleMinionPos.X; + float playerY = player.position.Y + (float) (player.height / 2) - idleMinionPos.Y; float playerDist = (float)Math.Sqrt(playerX * playerX + playerY * playerY); if (playerDist > 1500f) { @@ -111,7 +109,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.tileCollide = false; float npcDetectRange = 1200f; bool npcFound = false; - int num6 = -1; + int targetIndex = -1; for (int index = 0; index < Main.maxNPCs; ++index) { NPC npc2 = Main.npc[index]; @@ -123,7 +121,7 @@ namespace CalamityMod.Projectiles.Summon if (npcDist < npcDetectRange) { if (Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc2.position, npc2.width, npc2.height)) - num6 = index; + targetIndex = index; npcFound = true; break; } @@ -131,22 +129,22 @@ namespace CalamityMod.Projectiles.Summon } //return to normal if npc found - if (npcFound && num6 >= 0) + if (npcFound && targetIndex >= 0) Projectile.ai[0] = 0f; - Vector2 vector2 = new Vector2(Projectile.position.X + (float) Projectile.width * 0.5f, Projectile.position.Y + (float) Projectile.height * 0.5f); - float xDist = player.position.X + (float) (player.width / 2) - vector2.X; + Vector2 returningMinionPos = new Vector2(Projectile.position.X + (float) Projectile.width * 0.5f, Projectile.position.Y + (float) Projectile.height * 0.5f); + float xDist = player.position.X + (float) (player.width / 2) - returningMinionPos.X; xDist -= (float) (40 * player.direction); if (!npcFound) xDist -= (float) (40 * Projectile.minionPos * player.direction); - float yDist = player.position.Y + (float) (player.height / 2) - vector2.Y; + float yDist = player.position.Y + (float) (player.height / 2) - returningMinionPos.Y; yDist -= 60f; float playerDist2 = (float) Math.Sqrt(xDist * xDist + yDist * yDist); - float num11 = 12f; - float num12 = playerDist2; - float conflict2 = 0.4f; - if (num11 < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) - num11 = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); + float currentReturnSpeed = 12f; + float minionReturnSpeed = playerDist2; + float minionReturnAccel = 0.4f; + if (currentReturnSpeed < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) + currentReturnSpeed = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); //if close enough to the player and has tile to stand on, return to normal if (playerDist2 < 100f && player.velocity.Y == 0f && (Projectile.position.Y + (float) Projectile.height <= player.position.Y + (float) player.height && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height))) @@ -167,52 +165,52 @@ namespace CalamityMod.Projectiles.Summon { Projectile.velocity *= 0.99f; } - conflict2 = 0.01f; + minionReturnAccel = 0.01f; } else { if (playerDist2 < 100f) { - conflict2 = 0.1f; + minionReturnAccel = 0.1f; } if (playerDist2 > 300f) { - conflict2 = 1f; + minionReturnAccel = 1f; } - playerDist2 = num12 / playerDist2; + playerDist2 = minionReturnSpeed / playerDist2; xDist *= playerDist2; yDist *= playerDist2; } if (Projectile.velocity.X < xDist) { - Projectile.velocity.X = Projectile.velocity.X + conflict2; - if (conflict2 > 0.05f && Projectile.velocity.X < 0f) + Projectile.velocity.X = Projectile.velocity.X + minionReturnAccel; + if (minionReturnAccel > 0.05f && Projectile.velocity.X < 0f) { - Projectile.velocity.X = Projectile.velocity.X + conflict2; + Projectile.velocity.X = Projectile.velocity.X + minionReturnAccel; } } if (Projectile.velocity.X > xDist) { - Projectile.velocity.X = Projectile.velocity.X - conflict2; - if (conflict2 > 0.05f && Projectile.velocity.X > 0f) + Projectile.velocity.X = Projectile.velocity.X - minionReturnAccel; + if (minionReturnAccel > 0.05f && Projectile.velocity.X > 0f) { - Projectile.velocity.X = Projectile.velocity.X - conflict2; + Projectile.velocity.X = Projectile.velocity.X - minionReturnAccel; } } if (Projectile.velocity.Y < yDist) { - Projectile.velocity.Y = Projectile.velocity.Y + conflict2; - if (conflict2> 0.05f && Projectile.velocity.Y < 0f) + Projectile.velocity.Y = Projectile.velocity.Y + minionReturnAccel; + if (minionReturnAccel> 0.05f && Projectile.velocity.Y < 0f) { - Projectile.velocity.Y = Projectile.velocity.Y + conflict2 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y + minionReturnAccel * 2f; } } if (Projectile.velocity.Y > yDist) { - Projectile.velocity.Y = Projectile.velocity.Y - conflict2; - if (conflict2 > 0.05f && Projectile.velocity.Y > 0f) + Projectile.velocity.Y = Projectile.velocity.Y - minionReturnAccel; + if (minionReturnAccel > 0.05f && Projectile.velocity.Y > 0f) { - Projectile.velocity.Y = Projectile.velocity.Y - conflict2 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y - minionReturnAccel * 2f; } } if (Projectile.frame < 15) @@ -240,9 +238,8 @@ namespace CalamityMod.Projectiles.Summon } else { - float conflict3 = (float) (40 * Projectile.minionPos); + float exaggeratedMinionPos = (float) (40 * Projectile.minionPos); float attackCooldown = 30f; - int num4 = 60; --Projectile.localAI[0]; if (Projectile.localAI[0] < 0f) Projectile.localAI[0] = 0f; @@ -252,113 +249,113 @@ namespace CalamityMod.Projectiles.Summon } else { - float num5 = Projectile.position.X; - float num6 = Projectile.position.Y; - float num7 = 100000f; - float num8 = num7; - int num9 = -1; + float minionXTarget = Projectile.position.X; + float minionYTarget = Projectile.position.Y; + float minionAttackMaxDist = 100000f; + float minionAttackDistance = minionAttackMaxDist; + int minionAttackIndex = -1; NPC minionAttackTargetNpc = Projectile.OwnerMinionAttackTargetNPC; if (minionAttackTargetNpc != null && minionAttackTargetNpc.CanBeChasedBy((object) Projectile, false)) { - float num10 = minionAttackTargetNpc.position.X + (float) (minionAttackTargetNpc.width / 2); - float num11 = minionAttackTargetNpc.position.Y + (float) (minionAttackTargetNpc.height / 2); - float num12 = Math.Abs(Projectile.position.X + (float) (Projectile.width / 2) - num10) + Math.Abs(Projectile.position.Y + (float) (Projectile.height / 2) - num11); - if (num12 < num7) + float minionTargetXDist = minionAttackTargetNpc.position.X + (float) (minionAttackTargetNpc.width / 2); + float minionTargetYDist = minionAttackTargetNpc.position.Y + (float) (minionAttackTargetNpc.height / 2); + float minionTargetDist = Math.Abs(Projectile.position.X + (float) (Projectile.width / 2) - minionTargetXDist) + Math.Abs(Projectile.position.Y + (float) (Projectile.height / 2) - minionTargetYDist); + if (minionTargetDist < minionAttackMaxDist) { - if (num9 == -1 && num12 <= num8) + if (minionAttackIndex == -1 && minionTargetDist <= minionAttackDistance) { - num8 = num12; - num5 = num10; - num6 = num11; + minionAttackDistance = minionTargetDist; + minionXTarget = minionTargetXDist; + minionYTarget = minionTargetYDist; } if (Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, minionAttackTargetNpc.position, minionAttackTargetNpc.width, minionAttackTargetNpc.height)) { - num7 = num12; - num5 = num10; - num6 = num11; - num9 = minionAttackTargetNpc.whoAmI; + minionAttackMaxDist = minionTargetDist; + minionXTarget = minionTargetXDist; + minionYTarget = minionTargetYDist; + minionAttackIndex = minionAttackTargetNpc.whoAmI; } } } - if (num9 == -1) + if (minionAttackIndex == -1) { for (int index = 0; index < Main.maxNPCs; ++index) { if (Main.npc[index].CanBeChasedBy((object) Projectile, false)) { - float num10 = Main.npc[index].position.X + (float) (Main.npc[index].width / 2); - float num11 = Main.npc[index].position.Y + (float) (Main.npc[index].height / 2); - float num12 = Math.Abs(Projectile.position.X + (float) (Projectile.width / 2) - num10) + Math.Abs(Projectile.position.Y + (float) (Projectile.height / 2) - num11); - if (num12 < num7) + float minionTargetXDist = Main.npc[index].position.X + (float) (Main.npc[index].width / 2); + float minionTargetYDist = Main.npc[index].position.Y + (float) (Main.npc[index].height / 2); + float minionTargetDist = Math.Abs(Projectile.position.X + (float) (Projectile.width / 2) - minionTargetXDist) + Math.Abs(Projectile.position.Y + (float) (Projectile.height / 2) - minionTargetYDist); + if (minionTargetDist < minionAttackMaxDist) { - if (num9 == -1 && num12 <= num8) + if (minionAttackIndex == -1 && minionTargetDist <= minionAttackDistance) { - num8 = num12; - num5 = num10; - num6 = num11; + minionAttackDistance = minionTargetDist; + minionXTarget = minionTargetXDist; + minionYTarget = minionTargetYDist; } if (Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[index].position, Main.npc[index].width, Main.npc[index].height)) { - num7 = num12; - num5 = num10; - num6 = num11; - num9 = index; + minionAttackMaxDist = minionTargetDist; + minionXTarget = minionTargetXDist; + minionYTarget = minionTargetYDist; + minionAttackIndex = index; } } } } } - if (num9 == -1 && num8 < num7) - num7 = num8; - float num13 = 400f; + if (minionAttackIndex == -1 && minionAttackDistance < minionAttackMaxDist) + minionAttackMaxDist = minionAttackDistance; + float yDependentTargeting = 400f; if ((double) Projectile.position.Y > Main.worldSurface * 16.0) - num13 = 200f; - if (num7 < num13 + conflict3 && num9 == -1) + yDependentTargeting = 200f; + if (minionAttackMaxDist < yDependentTargeting + exaggeratedMinionPos && minionAttackIndex == -1) { - float num10 = num5 - (Projectile.position.X + (float) (Projectile.width / 2)); - if (num10 < -5f) + float minionTargetXDist = minionXTarget - (Projectile.position.X + (float) (Projectile.width / 2)); + if (minionTargetXDist < -5f) { - flag1 = true; - flag2 = false; + minionMovingLeft = true; + minionMovingRight = false; } - else if (num10 > 5f) + else if (minionTargetXDist > 5f) { - flag2 = true; - flag1 = false; + minionMovingRight = true; + minionMovingLeft = false; } } - else if (num9 >= 0 && num7 < 800f + conflict3) + else if (minionAttackIndex >= 0 && minionAttackMaxDist < 800f + exaggeratedMinionPos) { - Projectile.localAI[0] = (float) num4; - float num10 = num5 - (Projectile.position.X + (float) (Projectile.width / 2)); - if (num10 > 300f || num10 < -300f) + Projectile.localAI[0] = 60f; + float minionTargetXDist = minionXTarget - (Projectile.position.X + (float) (Projectile.width / 2)); + if (minionTargetXDist > 300f || minionTargetXDist < -300f) { - if (num10 < -50f) + if (minionTargetXDist < -50f) { - flag1 = true; - flag2 = false; + minionMovingLeft = true; + minionMovingRight = false; } - else if (num10 > 50f) + else if (minionTargetXDist > 50f) { - flag2 = true; - flag1 = false; + minionMovingRight = true; + minionMovingLeft = false; } } else if (Projectile.owner == Main.myPlayer) { Projectile.ai[1] = attackCooldown; - double num11 = 12.0; - Vector2 vector2 = new Vector2(Projectile.Center.X, Projectile.Center.Y - 8f); - float num12 = num5 - vector2.X + Main.rand.NextFloat(-6f, 6f); - float num14 = (float) ((double) (Math.Abs(num12) * 0.1f) * (double) Main.rand.Next(0, 100) * (1.0 / 1000.0)); - float num15 = num6 - vector2.Y + Main.rand.NextFloat(-6f, 6f) - num14; - double num16 = Math.Sqrt((double) num12 * (double) num12 + (double) num15 * (double) num15); - float num17 = (float) (num11 / num16); - float SpeedX = num12 * num17; - float SpeedY = num15 * num17; + double plateSpeed = 12.0; + Vector2 projMinionPos = new Vector2(Projectile.Center.X, Projectile.Center.Y - 8f); + float plateTargetX = minionXTarget - projMinionPos.X + Main.rand.NextFloat(-6f, 6f); + float randomPlateYOffset = (float) ((double) (Math.Abs(plateTargetX) * 0.1f) * (double) Main.rand.Next(0, 100) * (1.0 / 1000.0)); + float plateTargetY = minionYTarget - projMinionPos.Y + Main.rand.NextFloat(-6f, 6f) - randomPlateYOffset; + double plateTargetDist = Math.Sqrt((double) plateTargetX * (double) plateTargetX + (double) plateTargetY * (double) plateTargetY); + float plateVelocity = (float) (plateSpeed / plateTargetDist); + float SpeedX = plateTargetX * plateVelocity; + float SpeedY = plateTargetY * plateVelocity; int damage = Projectile.damage; int Type = ModContent.ProjectileType(); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), vector2.X, vector2.Y, SpeedX * 2f, SpeedY * 2f, Type, damage, Projectile.knockBack, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), projMinionPos.X, projMinionPos.Y, SpeedX * 2f, SpeedY * 2f, Type, damage, Projectile.knockBack, Projectile.owner); if (SpeedX < 0f) Projectile.direction = -1; if (SpeedX > 0f) @@ -367,74 +364,71 @@ namespace CalamityMod.Projectiles.Summon } } } - Vector2 vector2_1 = Vector2.Zero; - bool flag7 = false; if (Projectile.ai[1] != 0f) { - flag1 = false; - flag2 = false; + minionMovingLeft = false; + minionMovingRight = false; } else if (Projectile.localAI[0] == 0f) Projectile.direction = player.direction; - if (!flag7) - Projectile.rotation = 0f; + Projectile.rotation = 0f; Projectile.tileCollide = true; - float num18 = 0.08f; - float num19 = 6.5f; - num19 = 6f; - num18 = 0.2f; - if (num19 < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) + float groundMinionAccel = 0.08f; + float groundMinionMaxVel = 6.5f; + groundMinionMaxVel = 6f; + groundMinionAccel = 0.2f; + if (groundMinionMaxVel < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) { - num19 = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); - num18 = 0.3f; + groundMinionMaxVel = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); + groundMinionAccel = 0.3f; } - if (flag1) + if (minionMovingLeft) { if (Projectile.velocity.X > -3.5f) - Projectile.velocity.X -= num18; + Projectile.velocity.X -= groundMinionAccel; else - Projectile.velocity.X -= num18 * 0.25f; + Projectile.velocity.X -= groundMinionAccel * 0.25f; } - else if (flag2) + else if (minionMovingRight) { if (Projectile.velocity.X < 3.5f) - Projectile.velocity.X += num18; + Projectile.velocity.X += groundMinionAccel; else - Projectile.velocity.X += num18 * 0.25f; + Projectile.velocity.X += groundMinionAccel * 0.25f; } else { Projectile.velocity.X *= 0.9f; - if (Projectile.velocity.X >= -num18 && Projectile.velocity.X <= num18) + if (Projectile.velocity.X >= -groundMinionAccel && Projectile.velocity.X <= groundMinionAccel) Projectile.velocity.X = 0f; } - if (flag1 | flag2) + if (minionMovingLeft | minionMovingRight) { - int conflict4 = (int) ((double) Projectile.position.X + (double) (Projectile.width / 2)) / 16; + int minionTileX = (int) ((double) Projectile.position.X + (double) (Projectile.width / 2)) / 16; int j = (int) ((double) Projectile.position.Y + (double) (Projectile.height / 2)) / 16; - if (flag1) - --conflict4; - if (flag2) - ++conflict4; - if (WorldGen.SolidTile(conflict4 + (int) Projectile.velocity.X, j)) - flag4 = true; + if (minionMovingLeft) + --minionTileX; + if (minionMovingRight) + ++minionTileX; + if (WorldGen.SolidTile(minionTileX + (int) Projectile.velocity.X, j)) + minionShouldJump = true; } if (player.position.Y + player.height - 8f > Projectile.position.Y + Projectile.height) - flag3 = true; + minionBelowPlayer = true; Collision.StepUp(ref Projectile.position, ref Projectile.velocity, Projectile.width, Projectile.height, ref Projectile.stepSpeed, ref Projectile.gfxOffY, 1, false, 0); if (Projectile.velocity.Y == 0f) { - if (!flag3 && ((double) Projectile.velocity.X < 0.0 || (double) Projectile.velocity.X > 0.0)) + if (!minionBelowPlayer && ((double) Projectile.velocity.X < 0.0 || (double) Projectile.velocity.X > 0.0)) { int i = (int) ((double) Projectile.position.X + (double) (Projectile.width / 2)) / 16; int j = (int) ((double) Projectile.position.Y + (double) (Projectile.height / 2)) / 16 + 1; - if (flag1) + if (minionMovingLeft) --i; - if (flag2) + if (minionMovingRight) ++i; WorldGen.SolidTile(i, j); } - if (flag4) + if (minionShouldJump) { int i1 = (int) ((double) Projectile.position.X + (double) (Projectile.width / 2)) / 16; int j = (int) ((double) Projectile.position.Y + (double) Projectile.height) / 16 + 1; @@ -448,20 +442,20 @@ namespace CalamityMod.Projectiles.Summon { try { - int conflict5 = (int) ((double) Projectile.position.X + (double) (Projectile.width / 2)) / 16; - int conflict7 = (int) ((double) Projectile.position.Y + (double) (Projectile.height / 2)) / 16; - if (flag1) - --conflict5; - if (flag2) - ++conflict5; - int i2 = conflict5 + (int) Projectile.velocity.X; - if (!WorldGen.SolidTile(i2, conflict7 - 1) && !WorldGen.SolidTile(i2, conflict7 - 2)) + int minionJumpTileX = (int) ((double) Projectile.position.X + (double) (Projectile.width / 2)) / 16; + int minionJumpTileY = (int) ((double) Projectile.position.Y + (double) (Projectile.height / 2)) / 16; + if (minionMovingLeft) + --minionJumpTileX; + if (minionMovingRight) + ++minionJumpTileX; + int i2 = minionJumpTileX + (int) Projectile.velocity.X; + if (!WorldGen.SolidTile(i2, minionJumpTileY - 1) && !WorldGen.SolidTile(i2, minionJumpTileY - 2)) Projectile.velocity.Y = -5.1f; - else if (!WorldGen.SolidTile(i2, conflict7 - 2)) + else if (!WorldGen.SolidTile(i2, minionJumpTileY - 2)) Projectile.velocity.Y = -7.1f; - else if (WorldGen.SolidTile(i2, conflict7 - 5)) + else if (WorldGen.SolidTile(i2, minionJumpTileY - 5)) Projectile.velocity.Y = -11.1f; - else if (WorldGen.SolidTile(i2, conflict7 - 4)) + else if (WorldGen.SolidTile(i2, minionJumpTileY - 4)) Projectile.velocity.Y = -10.1f; else Projectile.velocity.Y = -9.1f; @@ -473,20 +467,20 @@ namespace CalamityMod.Projectiles.Summon } } } - else if (Projectile.type == 266 && flag1 | flag2) + else if (Projectile.type == 266 && minionMovingLeft | minionMovingRight) Projectile.velocity.Y -= 6f; } - if (Projectile.velocity.X > num19) - Projectile.velocity.X = num19; - if (Projectile.velocity.X < -num19) - Projectile.velocity.X = -num19; + if (Projectile.velocity.X > groundMinionMaxVel) + Projectile.velocity.X = groundMinionMaxVel; + if (Projectile.velocity.X < -groundMinionMaxVel) + Projectile.velocity.X = -groundMinionMaxVel; if (Projectile.velocity.X < 0f) Projectile.direction = -1; if (Projectile.velocity.X > 0f) Projectile.direction = 1; - if (Projectile.velocity.X > num18 & flag2) + if (Projectile.velocity.X > groundMinionAccel & minionMovingRight) Projectile.direction = 1; - if (Projectile.velocity.X < -num18 & flag1) + if (Projectile.velocity.X < -groundMinionAccel & minionMovingLeft) Projectile.direction = -1; if (Projectile.direction == -1) Projectile.spriteDirection = -1; diff --git a/Projectiles/Summon/HermitCrabMinion.cs b/Projectiles/Summon/HermitCrabMinion.cs index 5af490b966..dff0a079d2 100644 --- a/Projectiles/Summon/HermitCrabMinion.cs +++ b/Projectiles/Summon/HermitCrabMinion.cs @@ -48,18 +48,17 @@ namespace CalamityMod.Projectiles.Summon CalamityPlayer modPlayer = player.Calamity(); if (spawnDust) { - int num501 = 20; - for (int num502 = 0; num502 < num501; num502++) + for (int i = 0; i < 20; i++) { - int num503 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, 33, 0f, 0f, 0, default, 1f); - Main.dust[num503].velocity *= 2f; - Main.dust[num503].scale *= 1.15f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, 33, 0f, 0f, 0, default, 1f); + Main.dust[dust].velocity *= 2f; + Main.dust[dust].scale *= 1.15f; } spawnDust = false; } - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isMinion = Projectile.type == ModContent.ProjectileType(); player.AddBuff(ModContent.BuffType(), 3600); - if (flag64) + if (isMinion) { if (player.dead) { @@ -70,12 +69,12 @@ namespace CalamityMod.Projectiles.Summon Projectile.timeLeft = 2; } } - Vector2 vector46 = Projectile.position; + Vector2 projPos = Projectile.position; if (!fly) { Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2; - float playerDistance = vector48.Length(); + Vector2 destination = player.Center - center2; + float playerDistance = destination.Length(); if (Projectile.velocity.Y == 0 && (HoleBelow() || (playerDistance > 205f && Projectile.position.X == Projectile.oldPosition.X))) { Projectile.velocity.Y = -10f; @@ -98,7 +97,7 @@ namespace CalamityMod.Projectiles.Summon { Projectile.frame = 1; } - float num633 = 600f; + float attackDistance = 600f; bool chaseNPC = false; float npcPositionX = 0f; if (player.HasMinionAttackTargetNPC) @@ -106,11 +105,11 @@ namespace CalamityMod.Projectiles.Summon NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(Projectile, false)) { - float num646 = Vector2.Distance(npc.Center, Projectile.Center); - if (!chaseNPC && num646 < num633) + float targetDist = Vector2.Distance(npc.Center, Projectile.Center); + if (!chaseNPC && targetDist < attackDistance) { - num633 = num646; - vector46 = npc.Center; + attackDistance = targetDist; + projPos = npc.Center; npcPositionX = npc.position.X; chaseNPC = true; } @@ -118,16 +117,16 @@ namespace CalamityMod.Projectiles.Summon } if (!chaseNPC) { - for (int num645 = 0; num645 < Main.maxNPCs; num645++) + for (int j = 0; j < Main.maxNPCs; j++) { - NPC npcTarget = Main.npc[num645]; + NPC npcTarget = Main.npc[j]; if (npcTarget.CanBeChasedBy(Projectile, false)) { - float num646 = Vector2.Distance(npcTarget.Center, Projectile.Center); - if (!chaseNPC && num646 < num633) + float targetDist = Vector2.Distance(npcTarget.Center, Projectile.Center); + if (!chaseNPC && targetDist < attackDistance) { - num633 = num646; - vector46 = npcTarget.Center; + attackDistance = targetDist; + projPos = npcTarget.Center; npcPositionX = npcTarget.position.X; chaseNPC = true; } @@ -288,11 +287,11 @@ namespace CalamityMod.Projectiles.Summon else if (fly) { Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2 + new Vector2(0f, 0f); - float playerDistance = vector48.Length(); - vector48.Normalize(); - vector48 *= 8f; - Projectile.velocity = (Projectile.velocity * 40f + vector48) / 41f; + Vector2 destination = player.Center - center2 + new Vector2(0f, 0f); + float playerDistance = destination.Length(); + destination.Normalize(); + destination *= 8f; + Projectile.velocity = (Projectile.velocity * 40f + destination) / 41f; Projectile.rotation = Projectile.velocity.X * 0.03f; Projectile.frameCounter++; diff --git a/Projectiles/Summon/Hive.cs b/Projectiles/Summon/Hive.cs index a3e9ed5972..609038c0ef 100644 --- a/Projectiles/Summon/Hive.cs +++ b/Projectiles/Summon/Hive.cs @@ -50,42 +50,42 @@ namespace CalamityMod.Projectiles.Summon Projectile.StickToTiles(false, false); int target = 0; - float num633 = 800f; - Vector2 vector46 = Projectile.position; - bool flag25 = false; + float attackDist = 800f; + Vector2 projPos = Projectile.position; + bool canAttack = false; if (Main.player[Projectile.owner].HasMinionAttackTargetNPC) { NPC npc = Main.npc[Main.player[Projectile.owner].MinionAttackTargetNPC]; if (npc.CanBeChasedBy(Projectile, false)) { - float num646 = Vector2.Distance(npc.Center, Projectile.Center); - if (!flag25 && num646 < num633) + float targetDist = Vector2.Distance(npc.Center, Projectile.Center); + if (!canAttack && targetDist < attackDist) { - vector46 = npc.Center; - flag25 = true; + projPos = npc.Center; + canAttack = true; target = npc.whoAmI; } } } - if (!flag25) + if (!canAttack) { - for (int num645 = 0; num645 < Main.maxNPCs; num645++) + for (int j = 0; j < Main.maxNPCs; j++) { - NPC nPC2 = Main.npc[num645]; + NPC nPC2 = Main.npc[j]; if (nPC2.CanBeChasedBy(Projectile, false)) { - float num646 = Vector2.Distance(nPC2.Center, Projectile.Center); - if (!flag25 && num646 < num633) + float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center); + if (!canAttack && targetDist < attackDist) { - num633 = num646; - vector46 = nPC2.Center; - flag25 = true; - target = num645; + attackDist = targetDist; + projPos = nPC2.Center; + canAttack = true; + target = j; } } } } - if (Projectile.owner == Main.myPlayer && flag25) + if (Projectile.owner == Main.myPlayer && canAttack) { if (Projectile.ai[0] != 0f) { diff --git a/Projectiles/Summon/HowlsHeartHowl.cs b/Projectiles/Summon/HowlsHeartHowl.cs index d713a234e3..42ca33b782 100644 --- a/Projectiles/Summon/HowlsHeartHowl.cs +++ b/Projectiles/Summon/HowlsHeartHowl.cs @@ -44,13 +44,13 @@ namespace CalamityMod.Projectiles.Summon int dustAmt = 36; for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(dustIndex - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int dusty = Dust.NewDust(vector6 + vector7, 0, 0, 191, vector7.X * 1f, vector7.Y * 1f, 100, default, 1.1f); + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(dustIndex - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int dusty = Dust.NewDust(rotate + faceDirection, 0, 0, 191, faceDirection.X * 1f, faceDirection.Y * 1f, 100, default, 1.1f); Main.dust[dusty].noGravity = true; Main.dust[dusty].noLight = true; - Main.dust[dusty].velocity = vector7; + Main.dust[dusty].velocity = faceDirection; } initialized = true; } diff --git a/Projectiles/Summon/HydrothermicVent.cs b/Projectiles/Summon/HydrothermicVent.cs index 4aa195b408..5cedf175e8 100644 --- a/Projectiles/Summon/HydrothermicVent.cs +++ b/Projectiles/Summon/HydrothermicVent.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isMinion = Projectile.type == ModContent.ProjectileType(); Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); if (!modPlayer.chaosSpirit) @@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.active = false; return; } - if (flag64) + if (isMinion) { if (player.dead) { @@ -59,12 +59,11 @@ namespace CalamityMod.Projectiles.Summon dust--; if (dust >= 0) { - int num501 = 50; - for (int num502 = 0; num502 < num501; num502++) + for (int i = 0; i < 50; i++) { - int num503 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, Main.rand.NextBool(3) ? 16 : 127, 0f, 0f, 0, default, 1f); - Main.dust[num503].velocity *= 2f; - Main.dust[num503].scale *= 1.15f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, Main.rand.NextBool(3) ? 16 : 127, 0f, 0f, 0, default, 1f); + Main.dust[dust].velocity *= 2f; + Main.dust[dust].scale *= 1.15f; } } Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 1f / 255f, (255 - Projectile.alpha) * 0.35f / 255f, (255 - Projectile.alpha) * 0f / 255f); diff --git a/Projectiles/Summon/IceClasperMinion.cs b/Projectiles/Summon/IceClasperMinion.cs index 045746ff91..bc18a45de9 100644 --- a/Projectiles/Summon/IceClasperMinion.cs +++ b/Projectiles/Summon/IceClasperMinion.cs @@ -1,248 +1,201 @@ using CalamityMod.Buffs.Summon; using CalamityMod.Items.Weapons.Summon; -using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -using Microsoft.Xna.Framework.Graphics; -using Terraria.Audio; namespace CalamityMod.Projectiles.Summon { - public class IceClasperMinion : ModProjectile, ILocalizedModType + public class IceClasperMinion : BaseMinionProjectile { - public Player Owner => Main.player[Projectile.owner]; + public override int AssociatedProjectileTypeID => ModContent.ProjectileType(); + public override int AssociatedBuffTypeID => ModContent.BuffType(); + public override ref bool AssociatedMinionBool => ref ModdedOwner.IceClasperBool; - public CalamityPlayer ModdedOwner => Owner.Calamity(); - - public enum IceClasperAIState + public enum AIState { Follow, Ram } + public AIState State { - FollowOwner, - Ram - } - - public IceClasperAIState CurrentState - { - get => (IceClasperAIState)Projectile.ai[0]; - set => Projectile.ai[0] = (int)value; + get => (AIState)Projectile.ai[0]; + set + { + Projectile.ai[0] = (int)value; + SyncVariables(); + } } public ref float TimerForShooting => ref Projectile.ai[1]; public ref float AfterimageInterpolant => ref Projectile.localAI[0]; - public bool hasSpawned = false; - - public new string LocalizationCategory => "Projectiles.Summon"; - public override void SetStaticDefaults() { - Main.projFrames[Projectile.type] = 6; - ProjectileID.Sets.TrailingMode[Projectile.type] = 2; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 6; - ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; - ProjectileID.Sets.MinionTargettingFeature[Projectile.type] = true; + base.SetStaticDefaults(); + Main.projFrames[Type] = 6; } public override void SetDefaults() { - Projectile.localNPCHitCooldown = AncientIceChunk.IFrames; - Projectile.minionSlots = 1f; - Projectile.penetrate = -1; + base.SetDefaults(); Projectile.coldDamage = true; - - Projectile.width = 62; - Projectile.height = 62; - Projectile.DamageType = DamageClass.Summon; - Projectile.usesLocalNPCImmunity = true; - Projectile.minion = true; - Projectile.netImportant = true; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.tileCollide = false; + Projectile.width = Projectile.height = 62; } - public override void AI() - { - CheckMinionExistence(); - - if (!hasSpawned) + public override void MinionAI() + { + switch (State) { - SpawnEffect(); - hasSpawned = true; - } - - // Detects a target at a given distance. - NPC potentialTarget = Projectile.Center.MinionHoming(AncientIceChunk.EnemyDistanceDetection, Owner); - switch (CurrentState) - { - case IceClasperAIState.FollowOwner: - State_FollowOwner(potentialTarget); + case AIState.Follow: + FollowState(); break; - case IceClasperAIState.Ram: - State_Ram(potentialTarget); + case AIState.Ram: + RamState(); break; } - // Flavor dust visual to show that it is ghostly. - if (Main.rand.NextBool(10)) - { - int ghostDust = Dust.NewDust(Projectile.position, 31, 62, 56, -0.5f * Projectile.rotation.ToRotationVector2().X, -0.5f * Projectile.rotation.ToRotationVector2().Y); - Main.dust[ghostDust].noLight = true; - Main.dust[ghostDust].noLightEmittence = true; - } - - DoAnimation(); - DoRotation(potentialTarget); - Lighting.AddLight(Projectile.Center, Color.Cyan.ToVector3()); Projectile.MinionAntiClump(0.5f); + + if (!Main.dedServ) + { + if (Main.rand.NextBool(10)) + { + Dust ghostDust = Dust.NewDustPerfect(Projectile.Center, 56, -Projectile.rotation.ToRotationVector2().RotatedByRandom(MathHelper.PiOver2) * Main.rand.NextFloat(2f, 3f)); + ghostDust.customData = false; + ghostDust.noLight = true; + ghostDust.noLightEmittence = true; + } + + Lighting.AddLight(Projectile.Center, Color.Cyan.ToVector3()); + } } - #region Methods + #region AI Methods - public void State_FollowOwner(NPC target) + public void FollowState() { // If the minion starts to get far, force the minion to go to you. - if (Projectile.WithinRange(Owner.Center, AncientIceChunk.EnemyDistanceDetection) && !Projectile.WithinRange(Owner.Center, AncientIceChunk.MaxDistanceFromOwner + 100f)) + if (!Projectile.WithinRange(Owner.Center, AncientIceChunk.MaxDistanceFromOwner)) { - Projectile.velocity = (Owner.Center - Projectile.Center) / 30f; - Projectile.netUpdate = true; - } - - // The minion will change directions to you if it's going away from you, meaning it'll just hover around you. - else if (!Projectile.WithinRange(Owner.Center, AncientIceChunk.MaxDistanceFromOwner)) - { - Projectile.velocity = (Projectile.velocity * 37f + Projectile.SafeDirectionTo(Owner.Center) * 17f) / 40f; - Projectile.netUpdate = true; + Projectile.velocity = (Projectile.velocity + Projectile.SafeDirectionTo(Owner.Center)) * 0.9f; + SyncVariables(); } // Teleport to the owner if sufficiently far away. - if (!Projectile.WithinRange(Owner.Center, AncientIceChunk.EnemyDistanceDetection)) + else if (!Projectile.WithinRange(Owner.Center, 1200f)) { Projectile.Center = Owner.Center; - Projectile.velocity *= .3f; - Projectile.netUpdate = true; + SyncVariables(); } // If the target is not null but not in range to dash: shoot. // If in range to dash: dash. - if (target is not null) + if (Target != null) { - if (Owner.WithinRange(target.Center, AncientIceChunk.DistanceToDash)) - { - CurrentState = IceClasperAIState.Ram; - Projectile.netUpdate = true; - } + if (Owner.WithinRange(Target.Center, AncientIceChunk.DistanceToDash)) + State = AIState.Ram; else - ShootTarget(target); + ShootTarget(); + + Projectile.rotation = Projectile.rotation.AngleTowards(Projectile.AngleTo(Target.Center), .15f); } + else + Projectile.rotation = Projectile.rotation.AngleTowards(Projectile.velocity.ToRotation(), .15f); } - public void State_Ram(NPC target) + public void RamState() { - // If there's no target while dashing or the player's gone far enough from the target: back to shooting. - if (target is null || !Owner.WithinRange(Projectile.Center, AncientIceChunk.DistanceToStopDash)) - { - CurrentState = IceClasperAIState.FollowOwner; - Projectile.netUpdate = true; - } - else if (target is not null) + if (Target is not null && Owner.WithinRange(Projectile.Center, AncientIceChunk.DistanceToStopDash)) { // The distance to the target plus a small number so it's not 0, it'd break calculations. - float distToTarget = Projectile.Distance(target.Center) + .01f; + float distanceToTarget = Projectile.Distance(Target.Center) + .01f; // The minion will head towards it's rotation. // If the target's close, the minion'll speed up, and viceversa, so it doesn't circle around the target doing nothing. - Projectile.velocity = Projectile.rotation.ToRotationVector2() * (AncientIceChunk.MinVelocity + (12f / (distToTarget * .01f))); + Projectile.velocity = Projectile.rotation.ToRotationVector2() * (AncientIceChunk.MinVelocity + (12f / (distanceToTarget * .01f))); Projectile.velocity = Vector2.Clamp(Projectile.velocity, Vector2.One * -25f, Vector2.One * 25f); - Projectile.rotation = Projectile.rotation.AngleTowards(Projectile.AngleTo(target.Center), .001f * distToTarget); + Projectile.rotation = Projectile.rotation.AngleTowards(Projectile.AngleTo(Target.Center), .001f * distanceToTarget); } + + // If there's no target while dashing or the player's gone far enough from the target: back to shooting. + else + State = AIState.Follow; } - public void ShootTarget(NPC target) + public void ShootTarget() { + ++TimerForShooting; if (TimerForShooting >= AncientIceChunk.TimeToShoot && Projectile.owner == Main.myPlayer) { - Vector2 velocity = CalamityUtils.CalculatePredictiveAimToTarget(Projectile.Center, target, 20f); + Vector2 velocity = CalamityUtils.CalculatePredictiveAimToTarget(Projectile.Center, Target, 25f); - int p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), - Projectile.Center, - velocity, - ModContent.ProjectileType(), - (int)(Projectile.damage * AncientIceChunk.ProjectileDMGMultiplier), - Projectile.knockBack, - Projectile.owner); + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), + Projectile.Center, + velocity, + ModContent.ProjectileType(), + (int)(Projectile.damage * AncientIceChunk.ProjectileDMGMultiplier), + Projectile.knockBack, + Projectile.owner); // Flavor recoil effect. Projectile.velocity -= velocity * .1f; - // For the fucking love of any god you can think of, this sound sucks but I can't find another one that fits better. - SoundEngine.PlaySound(SoundID.Item28, Projectile.Center); + if (!Main.dedServ) + { + // For the fucking love of any god you can think of, this sound sucks but I can't find another one that fits better. + SoundEngine.PlaySound(SoundID.Item28, Projectile.Center); + } TimerForShooting = 0f; - Projectile.netUpdate = true; + SyncVariables(); } - - if (TimerForShooting < AncientIceChunk.TimeToShoot) - TimerForShooting++; } - public void DoRotation(NPC target) + public void SyncVariables() { - if (target is null) - Projectile.rotation = Projectile.rotation.AngleTowards(Projectile.velocity.ToRotation(), .15f); - else if (target is not null && !Projectile.WithinRange(target.Center, AncientIceChunk.DistanceToDash)) - Projectile.rotation = Projectile.rotation.AngleTowards(Projectile.AngleTo(target.Center), .15f); + Projectile.netUpdate = true; + if (Projectile.netSpam >= 10) + Projectile.netSpam = 9; } - public void DoAnimation() - { - Projectile.frameCounter++; - if (Projectile.frameCounter % 5 == 0) - Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Projectile.type]; - } + #endregion - public void CheckMinionExistence() + public override void OnSpawn(IEntitySource source) { - Owner.AddBuff(ModContent.BuffType(), 3600); - if (Projectile.type == ModContent.ProjectileType()) + IFrames = AncientIceChunk.IFrames; + TrailingMode = 2; + TrailCacheLength = 6; + + if (!Main.dedServ) { - if (Owner.dead) - ModdedOwner.iClasper = false; - if (ModdedOwner.iClasper) - Projectile.timeLeft = 2; + int dustAmount = 45; + for (int dustIndex = 0; dustIndex < dustAmount; dustIndex++) + { + float angle = MathHelper.TwoPi / dustAmount * dustIndex; + Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(3f, 7f); + Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, 56, velocity); + spawnDust.customData = false; + spawnDust.noGravity = true; + spawnDust.velocity *= .75f; + spawnDust.scale = velocity.Length() * .2f; + } } } - public void SpawnEffect() - { - int dustAmt = 45; - for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) - { - float angle = MathHelper.TwoPi / dustAmt * dustIndex; - Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(3f, 7f); - Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, 56, velocity); - spawnDust.customData = false; - spawnDust.noGravity = true; - spawnDust.velocity *= .75f; - spawnDust.scale = velocity.Length() * .2f; - } - } - - public override bool? CanDamage() => (CurrentState == IceClasperAIState.Ram) ? null : false; + public override bool? CanDamage() => (State == AIState.Ram) ? null : false; public override bool PreDraw(ref Color lightColor) { - NPC target = Projectile.Center.MinionHoming(1200f, Owner); - Texture2D texture = ModContent.Request(Texture).Value; Vector2 drawPosition = Projectile.Center - Main.screenPosition; Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); Vector2 origin = frame.Size() * 0.5f; // Flavor fade-in-and-out for afterimages. - AfterimageInterpolant += ((target is not null && Owner.WithinRange(target.Center, 450f)) || CurrentState == IceClasperAIState.Ram) ? .05f : -.05f; + AfterimageInterpolant += ((Target is not null && Owner.WithinRange(Target.Center, 450f)) || State == AIState.Ram) ? .05f : -.05f; AfterimageInterpolant = MathHelper.Clamp(AfterimageInterpolant, 0f, 1f); float AfterimageFade = MathHelper.Lerp(0f, 1f, AfterimageInterpolant); @@ -257,10 +210,8 @@ namespace CalamityMod.Projectiles.Summon } Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation - MathHelper.PiOver2, origin, Projectile.scale, SpriteEffects.None, 0); - + return false; } - - #endregion } } diff --git a/Projectiles/Summon/IceClasperSummonProjectile.cs b/Projectiles/Summon/IceClasperSummonProjectile.cs index 5e44ade6e2..e94b205c50 100644 --- a/Projectiles/Summon/IceClasperSummonProjectile.cs +++ b/Projectiles/Summon/IceClasperSummonProjectile.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -10,45 +9,39 @@ namespace CalamityMod.Projectiles.Summon { public new string LocalizationCategory => "Projectiles.Summon"; - public Player Owner => Main.player[Projectile.owner]; - public override void SetStaticDefaults() { - ProjectileID.Sets.MinionShot[Projectile.type] = true; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 5; - ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + ProjectileID.Sets.MinionShot[Type] = true; + ProjectileID.Sets.TrailingMode[Type] = 2; + ProjectileID.Sets.TrailCacheLength[Type] = 5; } public override void SetDefaults() { - Projectile.idStaticNPCHitCooldown = 10; - Projectile.timeLeft = 300; - - Projectile.width = 28; - Projectile.height = 28; Projectile.DamageType = DamageClass.Summon; + Projectile.timeLeft = 300; + Projectile.width = Projectile.height = 28; + Projectile.friendly = true; - Projectile.tileCollide = false; - Projectile.usesIDStaticNPCImmunity = true; + Projectile.ignoreWater = true; } public override void AI() { Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - int trailDust = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, 172, Projectile.velocity.X, Projectile.velocity.Y, 0, default, 1.5f); - Main.dust[trailDust].noGravity = true; - - Lighting.AddLight(Projectile.Center, Color.Cyan.ToVector3()); + if (!Main.dedServ) + { + Dust trailDust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 172, Projectile.velocity.X, Projectile.velocity.Y, 0, default, 1.5f); + trailDust.noGravity = true; + } } - public override bool OnTileCollide(Vector2 oldVelocity) => false; - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.Frostburn, 180); public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); return true; } } diff --git a/Projectiles/Summon/IceSentryFrostBolt.cs b/Projectiles/Summon/IceSentryFrostBolt.cs index fc07f40b21..09e1850807 100644 --- a/Projectiles/Summon/IceSentryFrostBolt.cs +++ b/Projectiles/Summon/IceSentryFrostBolt.cs @@ -38,25 +38,25 @@ namespace CalamityMod.Projectiles.Summon Projectile.alpha = 0; } Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.01f / 255f, (255 - Projectile.alpha) * 0.3f / 255f, (255 - Projectile.alpha) * 0.45f / 255f); - for (int num105 = 0; num105 < 2; num105++) + for (int i = 0; i < 2; i++) { - float num99 = Projectile.velocity.X / 3f * (float)num105; - float num100 = Projectile.velocity.Y / 3f * (float)num105; - int num101 = 4; - int num102 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num101, Projectile.position.Y + (float)num101), Projectile.width - num101 * 2, Projectile.height - num101 * 2, 92, 0f, 0f, 100, default, 1.2f); - Dust dust = Main.dust[num102]; + float slowVelX = Projectile.velocity.X / 3f * (float)i; + float slowVelY = Projectile.velocity.Y / 3f * (float)i; + int four = 4; + int dusty = Dust.NewDust(new Vector2(Projectile.position.X + (float)four, Projectile.position.Y + (float)four), Projectile.width - four * 2, Projectile.height - four * 2, 92, 0f, 0f, 100, default, 1.2f); + Dust dust = Main.dust[dusty]; dust.noGravity = true; dust.velocity *= 0.1f; dust.velocity += Projectile.velocity * 0.1f; - dust.position.X -= num99; - dust.position.Y -= num100; + dust.position.X -= slowVelX; + dust.position.Y -= slowVelY; } if (Main.rand.NextBool(10)) { - int num103 = 4; - int num104 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num103, Projectile.position.Y + (float)num103), Projectile.width - num103 * 2, Projectile.height - num103 * 2, 92, 0f, 0f, 100, default, 0.6f); - Main.dust[num104].velocity *= 0.25f; - Main.dust[num104].velocity += Projectile.velocity * 0.5f; + int otherFour = 4; + int dustier = Dust.NewDust(new Vector2(Projectile.position.X + (float)otherFour, Projectile.position.Y + (float)otherFour), Projectile.width - otherFour * 2, Projectile.height - otherFour * 2, 92, 0f, 0f, 100, default, 0.6f); + Main.dust[dustier].velocity *= 0.25f; + Main.dust[dustier].velocity += Projectile.velocity * 0.5f; } Projectile.rotation += 0.3f * (float)Projectile.direction; } diff --git a/Projectiles/Summon/IrradiatedAura.cs b/Projectiles/Summon/IrradiatedAura.cs index 1fce516a5f..82d8d3248f 100644 --- a/Projectiles/Summon/IrradiatedAura.cs +++ b/Projectiles/Summon/IrradiatedAura.cs @@ -41,14 +41,14 @@ namespace CalamityMod.Projectiles.Summon { randomDust = 33; } - for (int num468 = 0; num468 < (Main.rand.NextBool() ? 1 : 2); num468++) + for (int i = 0; i < (Main.rand.NextBool() ? 1 : 2); i++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDust, 0f, 0f, 100, default, 1f); + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDust, 0f, 0f, 100, default, 1f); if (randomDust == 89) { - Main.dust[num469].scale *= 0.35f; + Main.dust[dust].scale *= 0.35f; } - Main.dust[num469].velocity *= 0f; + Main.dust[dust].velocity *= 0f; } } diff --git a/Projectiles/Summon/LanternFlame.cs b/Projectiles/Summon/LanternFlame.cs index de8e17d38d..4b6c5d4ce1 100644 --- a/Projectiles/Summon/LanternFlame.cs +++ b/Projectiles/Summon/LanternFlame.cs @@ -64,23 +64,23 @@ namespace CalamityMod.Projectiles.Summon Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; Projectile.Damage(); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 15; num623++) + for (int j = 0; j < 15; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, 3f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, 2f); + Main.dust[dust2].velocity *= 2f; } } diff --git a/Projectiles/Summon/LuxorsGiftSummon.cs b/Projectiles/Summon/LuxorsGiftSummon.cs index ed369b4a85..de2b181995 100644 --- a/Projectiles/Summon/LuxorsGiftSummon.cs +++ b/Projectiles/Summon/LuxorsGiftSummon.cs @@ -42,15 +42,15 @@ namespace CalamityMod.Projectiles.Summon CalamityPlayer modPlayer = player.Calamity(); if (dust > 0) { - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int i = 0; i < dustAmt; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 107, vector7.X * 1.75f, vector7.Y * 1.75f, 100, default, 1.1f); - Main.dust[num228].noGravity = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int dust = Dust.NewDust(rotate + faceDirection, 0, 0, 107, faceDirection.X * 1.75f, faceDirection.Y * 1.75f, 100, default, 1.1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity = faceDirection; } dust--; } @@ -75,8 +75,8 @@ namespace CalamityMod.Projectiles.Summon } } - bool flag64 = Projectile.type == ModContent.ProjectileType(); - if (flag64) + bool isMinion = Projectile.type == ModContent.ProjectileType(); + if (isMinion) { if (!modPlayer.luxorsGift || player.dead) { diff --git a/Projectiles/Summon/MiniGuardianAttack.cs b/Projectiles/Summon/MiniGuardianAttack.cs index 5d63fee825..cf558bf189 100644 --- a/Projectiles/Summon/MiniGuardianAttack.cs +++ b/Projectiles/Summon/MiniGuardianAttack.cs @@ -2,6 +2,7 @@ using System.IO; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.Summon.Whips; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.NPCs.Providence; using Microsoft.Xna.Framework; using Terraria; @@ -186,7 +187,6 @@ namespace CalamityMod.Projectiles.Summon public void AdvancedAI(NPC potentialTarget, Player owner, MiniOffenseAIState aiState) { - bool buffedAi = owner.HasBuff(); Vector2 targetDestination = potentialTarget.Center - Projectile.Center; @@ -360,6 +360,8 @@ namespace CalamityMod.Projectiles.Summon // Dynamically update stats here, originalDamage can be found in MiscEffects Projectile.damage = (int)Owner.GetTotalDamage().ApplyTo(Projectile.originalDamage); + if (Owner.Calamity().oldFashioned) + Projectile.damage = CalamityUtils.CalcOldFashionedDamage(Projectile.damage); Projectile.localNPCHitCooldown = (SpawnedFromPSC ? 6 : 9); var currentAIState = getAiState; @@ -384,7 +386,7 @@ namespace CalamityMod.Projectiles.Summon BaseAI(potentialTarget); break; default: - if (potentialTarget != null) + if (potentialTarget != null && !ForcedVanity) AdvancedAI(potentialTarget, owner, newAIState); else BaseAI(null); diff --git a/Projectiles/Summon/MiniGuardianHolyRay.cs b/Projectiles/Summon/MiniGuardianHolyRay.cs index 0ee2fbd319..6e22b082f4 100644 --- a/Projectiles/Summon/MiniGuardianHolyRay.cs +++ b/Projectiles/Summon/MiniGuardianHolyRay.cs @@ -9,6 +9,7 @@ using ReLogic.Content; using System; using System.IO; using CalamityMod.Buffs.Summon.Whips; +using CalamityMod.Items.Potions.Alcohol; using Terraria; using Terraria.Enums; using Terraria.ID; @@ -66,6 +67,8 @@ namespace CalamityMod.Projectiles.Summon Vector2 fireFrom = new Vector2(owner.Center.X, owner.Center.Y); Projectile.position = fireFrom - new Vector2(Projectile.width, Projectile.height) / 2f; Projectile.damage = (int)Owner.GetTotalDamage().ApplyTo(Projectile.originalDamage); + if (Owner.Calamity().oldFashioned) + Projectile.damage = CalamityUtils.CalcOldFashionedDamage(Projectile.damage); } else Projectile.Kill(); diff --git a/Projectiles/Summon/MiniGuardianRock.cs b/Projectiles/Summon/MiniGuardianRock.cs index 3cfb19de1c..3ebdd5ccce 100644 --- a/Projectiles/Summon/MiniGuardianRock.cs +++ b/Projectiles/Summon/MiniGuardianRock.cs @@ -1,6 +1,7 @@ using System; using CalamityMod.Buffs.Summon.Whips; using CalamityMod.Dusts; +using CalamityMod.Items.Potions.Alcohol; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -53,6 +54,9 @@ namespace CalamityMod.Projectiles.Summon Projectile.active = false; return; } + + if (Owner.Calamity().oldFashioned) + Projectile.damage = CalamityUtils.CalcOldFashionedDamage(Projectile.damage); if (Projectile.ai[0] == 0f) //regular expected behaviour of floaty rocks { diff --git a/Projectiles/Summon/MiniGuardianStars.cs b/Projectiles/Summon/MiniGuardianStars.cs index cf849fb52b..72b8d1d8f8 100644 --- a/Projectiles/Summon/MiniGuardianStars.cs +++ b/Projectiles/Summon/MiniGuardianStars.cs @@ -3,6 +3,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using CalamityMod.Items.Accessories; +using CalamityMod.Items.Potions.Alcohol; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -33,6 +34,8 @@ namespace CalamityMod.Projectiles.Summon Player owner = Main.player[Projectile.owner]; Projectile.damage = (int)owner.GetTotalDamage().ApplyTo(Projectile.originalDamage); + if (owner.Calamity().oldFashioned) + Projectile.damage = CalamityUtils.CalcOldFashionedDamage(Projectile.damage); if (Projectile.ai[0] < 240f) { diff --git a/Projectiles/Summon/MortalityBeam.cs b/Projectiles/Summon/MortalityBeam.cs index be468758fb..df5b7a67a6 100644 --- a/Projectiles/Summon/MortalityBeam.cs +++ b/Projectiles/Summon/MortalityBeam.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; using System; using Terraria; using Terraria.ID; @@ -52,7 +53,10 @@ namespace CalamityMod.Projectiles.Summon if (potentialTarget != null) Projectile.velocity = (Projectile.velocity * 5f + Projectile.SafeDirectionTo(potentialTarget.Center) * 13f) / 6f; } - + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 30); + } public override void OnKill(int timeLeft) { if (Main.myPlayer == Projectile.owner) diff --git a/Projectiles/Summon/MutatedTruffleMinion.cs b/Projectiles/Summon/MutatedTruffleMinion.cs index 471b49fb8e..6b7a38f393 100644 --- a/Projectiles/Summon/MutatedTruffleMinion.cs +++ b/Projectiles/Summon/MutatedTruffleMinion.cs @@ -55,11 +55,33 @@ namespace CalamityMod.Projectiles.Summon } } + public override void DoAnimation() + { + base.DoAnimation(); + if (State != AIState.Idle) + { + if (Projectile.frame <= 7) + Projectile.frame = 8; + } + else + { + if (Projectile.frame >= 7) + Projectile.frame = 0; + } + } + #region AI Methods private void IdleState() { - // The minion will hover around the owner. + // Quickly deaccelerate when getting too close to the owner. + if (Projectile.WithinRange(Owner.Center, 128f)) + { + Projectile.velocity *= 0.875f; + SyncVariables(); + } + + // The minion will turn to the player when it starts getting far away. if (!Projectile.WithinRange(Owner.Center, 320f)) { Projectile.velocity = (Projectile.velocity + Projectile.SafeDirectionTo(Owner.Center)) * 0.9f; @@ -225,7 +247,8 @@ namespace CalamityMod.Projectiles.Summon private void SyncVariables() { Projectile.netUpdate = true; - Projectile.netSpam = 0; + if (Projectile.netSpam >= 10) + Projectile.netSpam = 9; } #endregion diff --git a/Projectiles/Summon/PerditionBeacon.cs b/Projectiles/Summon/PerditionBeacon.cs index 2d76e0a68b..505e9616ee 100644 --- a/Projectiles/Summon/PerditionBeacon.cs +++ b/Projectiles/Summon/PerditionBeacon.cs @@ -34,8 +34,9 @@ namespace CalamityMod.Projectiles.Summon Projectile.height = 90; } - public override void ChooseTarget() + public override void SetOwnerTarget() { + base.SetOwnerTarget(); // Only attack targets if one is explicitly defined. Don't default to a closest target. Target = Owner.HasMinionAttackTargetNPC ? Main.npc[Owner.MinionAttackTargetNPC] : null; } diff --git a/Projectiles/Summon/PhantomGuy.cs b/Projectiles/Summon/PhantomGuy.cs index 9597941677..bedbe64fb8 100644 --- a/Projectiles/Summon/PhantomGuy.cs +++ b/Projectiles/Summon/PhantomGuy.cs @@ -45,21 +45,21 @@ namespace CalamityMod.Projectiles.Summon CalamityPlayer modPlayer = player.Calamity(); if (Projectile.localAI[0] == 0f) { - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int i = 0; i < dustAmt; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2(Projectile.width / 2f, Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((num227 - (num226 / 2 - 1)) * MathHelper.TwoPi / num226) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 180, vector7.X * 1.75f, vector7.Y * 1.75f, 100, default, 1.1f); - Main.dust[num228].noGravity = true; - Main.dust[num228].velocity = vector7; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2(Projectile.width / 2f, Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((i - (dustAmt / 2 - 1)) * MathHelper.TwoPi / dustAmt) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int dust = Dust.NewDust(rotate + faceDirection, 0, 0, 180, faceDirection.X * 1.75f, faceDirection.Y * 1.75f, 100, default, 1.1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity = faceDirection; } Projectile.localAI[0] += 1f; } - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isMinion = Projectile.type == ModContent.ProjectileType(); player.AddBuff(ModContent.BuffType(), 3600); - if (flag64) + if (isMinion) { if (player.dead) { @@ -71,106 +71,102 @@ namespace CalamityMod.Projectiles.Summon } } Projectile.MinionAntiClump(); - float num633 = 3000f; - float num634 = 3500f; - float num635 = 4000f; - float num636 = 600f; - Vector2 vector46 = Projectile.position; - bool flag25 = false; + float attackDistance = 3000f; + Vector2 targetCenter = Projectile.position; + bool canAttack = false; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(Projectile, false)) { - float num646 = Vector2.Distance(npc.Center, Projectile.Center); - if (num646 < num633) + float targetDist = Vector2.Distance(npc.Center, Projectile.Center); + if (targetDist < attackDistance) { - num633 = num646; - vector46 = npc.Center; - flag25 = true; + attackDistance = targetDist; + targetCenter = npc.Center; + canAttack = true; } } } - if (!flag25) + if (!canAttack) { - for (int num645 = 0; num645 < Main.maxNPCs; num645++) + for (int j = 0; j < Main.maxNPCs; j++) { - NPC nPC2 = Main.npc[num645]; + NPC nPC2 = Main.npc[j]; if (nPC2.CanBeChasedBy(Projectile, false)) { - float num646 = Vector2.Distance(nPC2.Center, Projectile.Center); - if (!flag25 && num646 < num633) + float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center); + if (!canAttack && targetDist < attackDistance) { - num633 = num646; - vector46 = nPC2.Center; - flag25 = true; + attackDistance = targetDist; + targetCenter = nPC2.Center; + canAttack = true; } } } } - float num647 = num634; - if (flag25) + float separationAnxietyDist = 3500f; + if (canAttack) { - num647 = num635; + separationAnxietyDist = 4000f; } - if (Vector2.Distance(player.Center, Projectile.Center) > num647) + if (Vector2.Distance(player.Center, Projectile.Center) > separationAnxietyDist) { Projectile.ai[0] = 1f; Projectile.netUpdate = true; } - if (flag25 && Projectile.ai[0] == 0f) + if (canAttack && Projectile.ai[0] == 0f) { - Vector2 vector47 = vector46 - Projectile.Center; - float num648 = vector47.Length(); - vector47.Normalize(); - if (num648 > 200f) + Vector2 targetDirection = targetCenter - Projectile.Center; + float targetDistance = targetDirection.Length(); + targetDirection.Normalize(); + if (targetDistance > 200f) { float scaleFactor2 = 18f; - vector47 *= scaleFactor2; - Projectile.velocity = (Projectile.velocity * 40f + vector47) / 41f; + targetDirection *= scaleFactor2; + Projectile.velocity = (Projectile.velocity * 40f + targetDirection) / 41f; } else { - float num649 = 12f; - vector47 *= -num649; - Projectile.velocity = (Projectile.velocity * 40f + vector47) / 41f; + targetDirection *= -12f; + Projectile.velocity = (Projectile.velocity * 40f + targetDirection) / 41f; } } else { - bool flag26 = false; - if (!flag26) + bool isReturning = false; + if (!isReturning) { - flag26 = Projectile.ai[0] == 1f; + isReturning = Projectile.ai[0] == 1f; } - float num650 = 12f; - if (flag26) + float returnSpeed = 12f; + if (isReturning) { - num650 = 30f; + returnSpeed = 30f; } Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2 + new Vector2(0f, -120f); - float num651 = vector48.Length(); - if (num651 > 200f && num650 < 16f) + Vector2 playerDirection = player.Center - center2 + new Vector2(0f, -120f); + float playerDist = playerDirection.Length(); + if (playerDist > 200f && returnSpeed < 16f) { - num650 = 16f; + returnSpeed = 16f; } - if (num651 < num636 && flag26) + if (playerDist < 600f && isReturning) { Projectile.ai[0] = 0f; Projectile.netUpdate = true; } - if (num651 > 3500f) + if (playerDist > 3500f) { Projectile.position.X = player.Center.X - (Projectile.width / 2); Projectile.position.Y = player.Center.Y - (Projectile.height / 2); Projectile.netUpdate = true; } - if (num651 > 70f) + if (playerDist > 70f) { - vector48.Normalize(); - vector48 *= num650; - Projectile.velocity = (Projectile.velocity * 40f + vector48) / 41f; + playerDirection.Normalize(); + playerDirection *= returnSpeed; + Projectile.velocity = (Projectile.velocity * 40f + playerDirection) / 41f; } else if (Projectile.velocity.X == 0f && Projectile.velocity.Y == 0f) { @@ -178,9 +174,9 @@ namespace CalamityMod.Projectiles.Summon Projectile.velocity.Y = -0.05f; } } - if (flag25) + if (canAttack) { - Projectile.rotation = Projectile.rotation.AngleTowards(Projectile.AngleTo(vector46), 0.1f); + Projectile.rotation = Projectile.rotation.AngleTowards(Projectile.AngleTo(targetCenter), 0.1f); } else { @@ -197,7 +193,7 @@ namespace CalamityMod.Projectiles.Summon } if (Projectile.ai[0] == 0f) { - if (flag25 && Projectile.ai[1] == 0f) + if (canAttack && Projectile.ai[1] == 0f) { Projectile.ai[1] += 1f; if (Main.myPlayer == Projectile.owner) diff --git a/Projectiles/Summon/PhantomicDagger.cs b/Projectiles/Summon/PhantomicDagger.cs index b82c4fbe46..cabc85e146 100644 --- a/Projectiles/Summon/PhantomicDagger.cs +++ b/Projectiles/Summon/PhantomicDagger.cs @@ -126,20 +126,20 @@ namespace CalamityMod.Projectiles.Summon NPC target = CalamityUtils.MinionHoming(Projectile.Center, 1500f, Main.player[Projectile.owner]); if (target != null) { - float num550 = 40f; - Vector2 vector43 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num551 = target.Center.X - vector43.X; - float num552 = target.Center.Y - vector43.Y; - float num553 = (float)Math.Sqrt((double)(num551 * num551 + num552 * num552)); - if (num553 < 100f) + float projVel = 40f; + Vector2 projDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float targetXDist = target.Center.X - projDirection.X; + float targetYDist = target.Center.Y - projDirection.Y; + float targetDist = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + if (targetDist < 100f) { - num550 = 28f; //14 + projVel = 28f; //14 } - num553 = num550 / num553; - num551 *= num553; - num552 *= num553; - Projectile.velocity.X = (Projectile.velocity.X * 25f + num551) / 26f; - Projectile.velocity.Y = (Projectile.velocity.Y * 25f + num552) / 26f; + targetDist = projVel / targetDist; + targetXDist *= targetDist; + targetYDist *= targetDist; + Projectile.velocity.X = (Projectile.velocity.X * 25f + targetXDist) / 26f; + Projectile.velocity.Y = (Projectile.velocity.Y * 25f + targetYDist) / 26f; } else { diff --git a/Projectiles/Summon/PinkButterfly.cs b/Projectiles/Summon/PinkButterfly.cs index b67ccedf92..4fcfccd7bd 100644 --- a/Projectiles/Summon/PinkButterfly.cs +++ b/Projectiles/Summon/PinkButterfly.cs @@ -40,14 +40,14 @@ namespace CalamityMod.Projectiles.Summon CalamityPlayer modPlayer = player.Calamity(); if (Projectile.localAI[0] == 0f) { - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int i = 0; i < dustAmt; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.5f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 73, vector7.X, vector7.Y, 100, default, 1.1f); - Main.dust[num228].noGravity = true; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.5f; + rotate = rotate.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int dust = Dust.NewDust(rotate + faceDirection, 0, 0, 73, faceDirection.X, faceDirection.Y, 100, default, 1.1f); + Main.dust[dust].noGravity = true; } Projectile.localAI[0] += 1f; } @@ -67,13 +67,10 @@ namespace CalamityMod.Projectiles.Summon Projectile.frame = 0; } Lighting.AddLight(Projectile.Center, 0.3f, 0.2f, 0.3f); - float num633 = 1200f; - float num634 = 1500f; - float num635 = 2400f; - float num636 = 150f; - bool flag64 = Projectile.type == ModContent.ProjectileType(); + float attackRange = 1200f; + bool isMinion = Projectile.type == ModContent.ProjectileType(); player.AddBuff(ModContent.BuffType(), 3600); - if (flag64) + if (isMinion) { if (player.dead) { @@ -85,109 +82,108 @@ namespace CalamityMod.Projectiles.Summon } } Projectile.MinionAntiClump(); - bool flag24 = false; - if (flag24) + bool returnbool = false; + if (returnbool) { return; } - Vector2 vector46 = Projectile.position; - bool flag25 = false; + Vector2 projPos = Projectile.position; + bool canAttack = false; int targetIndex = -1; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; if ((npc.CanBeChasedBy(Projectile, false) || npc.type == NPCID.DukeFishron) && npc.active) { - float num646 = Vector2.Distance(npc.Center, Projectile.Center); - if (!flag25 && num646 < num633) + float targetDist = Vector2.Distance(npc.Center, Projectile.Center); + if (!canAttack && targetDist < attackRange) { - vector46 = npc.Center; - flag25 = true; + projPos = npc.Center; + canAttack = true; targetIndex = npc.whoAmI; } } } - if (!flag25) + if (!canAttack) { - for (int num645 = 0; num645 < Main.maxNPCs; num645++) + for (int j = 0; j < Main.maxNPCs; j++) { - NPC nPC2 = Main.npc[num645]; + NPC nPC2 = Main.npc[j]; if ((nPC2.CanBeChasedBy(Projectile, false) || nPC2.type == NPCID.DukeFishron) && nPC2.active) { - float num646 = Vector2.Distance(nPC2.Center, Projectile.Center); - if (!flag25 && num646 < num633) + float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center); + if (!canAttack && targetDist < attackRange) { - num633 = num646; - vector46 = nPC2.Center; - flag25 = true; - targetIndex = num645; + attackRange = targetDist; + projPos = nPC2.Center; + canAttack = true; + targetIndex = j; } } } } - float num647 = num634; - if (flag25) + float separationAnxietyDist = 1500f; + if (canAttack) { - num647 = num635; + separationAnxietyDist = 2400f; } - if (Vector2.Distance(player.Center, Projectile.Center) > num647) + if (Vector2.Distance(player.Center, Projectile.Center) > separationAnxietyDist) { Projectile.ai[0] = 1f; Projectile.netUpdate = true; } - if (flag25 && Projectile.ai[0] == 0f) + if (canAttack && Projectile.ai[0] == 0f) { - Vector2 vector47 = vector46 - Projectile.Center; - float num648 = vector47.Length(); - vector47.Normalize(); - if (num648 > 200f) + Vector2 projDirection = projPos - Projectile.Center; + float projDistance = projDirection.Length(); + projDirection.Normalize(); + if (projDistance > 200f) { float scaleFactor2 = 12f; - vector47 *= scaleFactor2; - Projectile.velocity = (Projectile.velocity * 40f + vector47) / 41f; + projDirection *= scaleFactor2; + Projectile.velocity = (Projectile.velocity * 40f + projDirection) / 41f; } else { - float num649 = 6f; - vector47 *= -num649; - Projectile.velocity = (Projectile.velocity * 40f + vector47) / 41f; + projDirection *= -6f; + Projectile.velocity = (Projectile.velocity * 40f + projDirection) / 41f; } } else { - bool flag26 = false; - if (!flag26) + bool isReturning = false; + if (!isReturning) { - flag26 = Projectile.ai[0] == 1f; + isReturning = Projectile.ai[0] == 1f; } - float num650 = 10f; - if (flag26) + float returnSpeed = 10f; + if (isReturning) { - num650 = 24f; + returnSpeed = 24f; } Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2 + new Vector2(-40f, -40f); - float num651 = vector48.Length(); - if (num651 > 200f && num650 < 12f) + Vector2 playerDirection = player.Center - center2 + new Vector2(-40f, -40f); + float playerDist = playerDirection.Length(); + if (playerDist > 200f && returnSpeed < 12f) { - num650 = 12f; + returnSpeed = 12f; } - if (num651 < num636 && flag26 && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + if (playerDist < 150f && isReturning && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) { Projectile.ai[0] = 0f; Projectile.netUpdate = true; } - if (num651 > 2000f) + if (playerDist > 2000f) { Projectile.position.X = player.Center.X - (float)(Projectile.width / 2); Projectile.position.Y = player.Center.Y - (float)(Projectile.height / 2); Projectile.netUpdate = true; } - if (num651 > 70f) + if (playerDist > 70f) { - vector48.Normalize(); - vector48 *= num650; - Projectile.velocity = (Projectile.velocity * 40f + vector48) / 41f; + playerDirection.Normalize(); + playerDirection *= returnSpeed; + Projectile.velocity = (Projectile.velocity * 40f + playerDirection) / 41f; } else if (Projectile.velocity.X == 0f && Projectile.velocity.Y == 0f) { @@ -216,20 +212,20 @@ namespace CalamityMod.Projectiles.Summon { float velocity = 8f; int projectileType = ModContent.ProjectileType(); - if (flag25 && Projectile.ai[1] == 0f && Projectile.localAI[0] >= 120f) + if (canAttack && Projectile.ai[1] == 0f && Projectile.localAI[0] >= 120f) { Projectile.ai[1] += 1f; if (Main.myPlayer == Projectile.owner) { SoundEngine.PlaySound(SoundID.Item8, Projectile.position); - Vector2 value19 = vector46 - Projectile.Center; - value19.Normalize(); - value19 *= velocity; + Vector2 projDirectionAgain = projPos - Projectile.Center; + projDirectionAgain.Normalize(); + projDirectionAgain *= velocity; int numProj = 2; float rotation = MathHelper.ToRadians(4); for (int i = 0; i < numProj + 1; i++) { - Vector2 perturbedSpeed = value19.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numProj - 1))); + Vector2 perturbedSpeed = projDirectionAgain.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numProj - 1))); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, perturbedSpeed, projectileType, Projectile.damage / 2, Projectile.knockBack * 0.5f, Projectile.owner, targetIndex, 0f); } Projectile.netUpdate = true; @@ -242,9 +238,9 @@ namespace CalamityMod.Projectiles.Summon { SpriteEffects spriteEffects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, spriteEffects, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, spriteEffects, 0); return false; } diff --git a/Projectiles/Summon/PlaguebringerSummon.cs b/Projectiles/Summon/PlaguebringerSummon.cs index 696fbd0ca7..0638710da8 100644 --- a/Projectiles/Summon/PlaguebringerSummon.cs +++ b/Projectiles/Summon/PlaguebringerSummon.cs @@ -13,8 +13,6 @@ namespace CalamityMod.Projectiles.Summon public class PlaguebringerSummon : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Summon"; - public const float auraRange = 960f; - private int auraCounter = 0; public override void SetStaticDefaults() { Main.projFrames[Projectile.type] = 6; @@ -24,15 +22,11 @@ namespace CalamityMod.Projectiles.Summon public override void SetDefaults() { - Projectile.width = 30; - Projectile.height = 30; + Projectile.width = Projectile.height = 30; Projectile.netImportant = true; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.minionSlots = 0; - Projectile.timeLeft = 18000; - Projectile.penetrate = -1; - Projectile.timeLeft *= 5; Projectile.minion = true; Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Summon; @@ -40,10 +34,10 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Player player = Main.player[Projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); + Player Owner = Main.player[Projectile.owner]; + CalamityPlayer modPlayer = Owner.Calamity(); - if (Projectile.frameCounter++ > 6f) + if (Projectile.frameCounter++ >= 6f) { Projectile.frame++; Projectile.frameCounter = 0; @@ -54,10 +48,10 @@ namespace CalamityMod.Projectiles.Summon } bool correctMinion = Projectile.type == ModContent.ProjectileType(); - player.AddBuff(ModContent.BuffType(), 3600); + Owner.AddBuff(ModContent.BuffType(), 3600); if (correctMinion) { - if (player.dead) + if (Owner.dead) { modPlayer.plaguebringerPatronSummon = false; } @@ -71,37 +65,32 @@ namespace CalamityMod.Projectiles.Summon Projectile.MinionAntiClump(); - int buffType = ModContent.BuffType(); - float range = auraRange; - bool dealDamage = auraCounter++ % 60 == 59; - int dmg = Projectile.damage; - if (Projectile.owner == Main.myPlayer) + Projectile.ai[0]++; + NPC Target = Projectile.Center.MinionHoming(800f, Owner, false); + if (Projectile.owner == Main.myPlayer && Target != null) { - for (int l = 0; l < Main.maxNPCs; l++) + if (Projectile.ai[0] % 12 == 11) { - NPC npc = Main.npc[l]; - if (npc.IsAnEnemy() && !npc.dontTakeDamage && !npc.buffImmune[buffType] && Vector2.Distance(Projectile.Center, npc.Center) <= range) + int beeCount = Main.rand.Next(1, 3); + if (Owner.strongBees && Main.rand.NextBool(3)) + ++beeCount; + + for (int i = 0; i < beeCount; i++) { - if (npc.FindBuffIndex(buffType) == -1) - { - npc.AddBuff(buffType, 120, false); - } - if (dealDamage) - { - Projectile aura = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), npc.Center, Vector2.Zero, ModContent.ProjectileType(), dmg, 0f, Projectile.owner, l); - if (aura.whoAmI.WithinBounds(Main.maxProjectiles)) - aura.DamageType = DamageClass.Summon; - } + int beeType = Main.rand.NextBool(4) ? ModContent.ProjectileType() : Owner.beeType(); // 25% chance for plague bee, otherwise depends if Hive Pack or not + Projectile bee = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Main.rand.NextVector2Circular(0.25f, 0.25f), beeType, Projectile.damage, Owner.beeKB(0f), Projectile.owner); + bee.usesLocalNPCImmunity = true; + bee.localNPCHitCooldown = 10; + bee.penetrate = 2; + bee.DamageType = DamageClass.Generic; } } } float passiveMvtFloat = 0.5f; - Projectile.tileCollide = false; float safeDist = 100f; - Vector2 projPos = new Vector2(Projectile.Center.X, Projectile.Center.Y); - float xDist = player.Center.X - projPos.X; - float yDist = player.Center.Y - projPos.Y; + float xDist = Owner.Center.X - Projectile.Center.X; + float yDist = Owner.Center.Y - Projectile.Center.Y; yDist += Main.rand.NextFloat(-10f, 20f); xDist += Main.rand.NextFloat(-10f, 20f); yDist -= 70f; @@ -110,8 +99,8 @@ namespace CalamityMod.Projectiles.Summon float returnSpeed = 18f; //If player is close enough, resume normal - if (playerDist < safeDist && player.velocity.Y == 0f && - Projectile.position.Y + Projectile.height <= player.position.Y + player.height && + if (playerDist < safeDist && Owner.velocity.Y == 0f && + Projectile.position.Y + Projectile.height <= Owner.position.Y + Owner.height && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) { if (Projectile.velocity.Y < -6f) @@ -123,8 +112,8 @@ namespace CalamityMod.Projectiles.Summon //Teleport to player if too far if (playerDist > 2000f) { - Projectile.position.X = player.Center.X - Projectile.width / 2; - Projectile.position.Y = player.Center.Y - Projectile.height / 2; + Projectile.position.X = Owner.Center.X - Projectile.width / 2; + Projectile.position.Y = Owner.Center.Y - Projectile.height / 2; Projectile.netUpdate = true; } diff --git a/Projectiles/Summon/ProfanedEnergy.cs b/Projectiles/Summon/ProfanedEnergy.cs index db1042ee93..723a7e324f 100644 --- a/Projectiles/Summon/ProfanedEnergy.cs +++ b/Projectiles/Summon/ProfanedEnergy.cs @@ -78,55 +78,55 @@ namespace CalamityMod.Projectiles.Summon Projectile.ai[0] -= 1f; return; } - bool flag18 = false; - float num506 = Projectile.Center.X; - float num507 = Projectile.Center.Y; - float num508 = 1000f; + bool canAttack = false; + float projX = Projectile.Center.X; + float projY = Projectile.Center.Y; + float attackDistance = 1000f; int target = 0; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(Projectile, false)) { - float num539 = npc.Center.X; - float num540 = npc.Center.Y; - float num541 = Math.Abs(Projectile.Center.X - num539) + Math.Abs(Projectile.Center.Y - num540); - if (num541 < num508 && Collision.CanHit(Projectile.Center, Projectile.width, Projectile.height, npc.Center, npc.width, npc.height)) + float targetX = npc.Center.X; + float targetY = npc.Center.Y; + float targetDist = Math.Abs(Projectile.Center.X - targetX) + Math.Abs(Projectile.Center.Y - targetY); + if (targetDist < attackDistance && Collision.CanHit(Projectile.Center, Projectile.width, Projectile.height, npc.Center, npc.width, npc.height)) { - num506 = num539; - num507 = num540; - flag18 = true; + projX = targetX; + projY = targetY; + canAttack = true; target = npc.whoAmI; } } } - if (!flag18) + if (!canAttack) { - for (int num512 = 0; num512 < Main.maxNPCs; num512++) + for (int j = 0; j < Main.maxNPCs; j++) { - if (Main.npc[num512].CanBeChasedBy(Projectile, false)) + if (Main.npc[j].CanBeChasedBy(Projectile, false)) { - float num513 = Main.npc[num512].position.X + (float)(Main.npc[num512].width / 2); - float num514 = Main.npc[num512].position.Y + (float)(Main.npc[num512].height / 2); - float num515 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num513) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num514); - if (num515 < num508 && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[num512].position, Main.npc[num512].width, Main.npc[num512].height)) + float npcX = Main.npc[j].position.X + (float)(Main.npc[j].width / 2); + float npcY = Main.npc[j].position.Y + (float)(Main.npc[j].height / 2); + float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); + if (npcDist < attackDistance && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[j].position, Main.npc[j].width, Main.npc[j].height)) { - num508 = num515; - num506 = num513; - num507 = num514; - flag18 = true; - target = num512; + attackDistance = npcDist; + projX = npcX; + projY = npcY; + canAttack = true; + target = j; } } } } - if (flag18) + if (canAttack) { - float num516 = num506; - float num517 = num507; - num506 -= Projectile.Center.X; - num507 -= Projectile.Center.Y; - if (num506 < 0f) + float projXStore = projX; + float projYStore = projY; + projX -= Projectile.Center.X; + projY -= Projectile.Center.Y; + if (projX < 0f) { Projectile.spriteDirection = 1; } @@ -140,14 +140,14 @@ namespace CalamityMod.Projectiles.Summon ModContent.ProjectileType() }); float speed = 25f; - Vector2 vector29 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num404 = num516 - vector29.X; - float num405 = num517 - vector29.Y; - float num406 = (float)Math.Sqrt((double)(num404 * num404 + num405 * num405)); - num406 = speed / num406; - num404 *= num406; - num405 *= num406; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, num404, num405, projectileType, Projectile.damage, Projectile.knockBack, Projectile.owner, (float)target, 0f); + Vector2 fireDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float fireXVel = projXStore - fireDirection.X; + float fireYVel = projYStore - fireDirection.Y; + float fireVelocity = (float)Math.Sqrt((double)(fireXVel * fireXVel + fireYVel * fireYVel)); + fireVelocity = speed / fireVelocity; + fireXVel *= fireVelocity; + fireYVel *= fireVelocity; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, fireXVel, fireYVel, projectileType, Projectile.damage, Projectile.knockBack, Projectile.owner, (float)target, 0f); Projectile.ai[0] = 16f; } diff --git a/Projectiles/Summon/ProfanedSoulCrystalProjectiles.cs b/Projectiles/Summon/ProfanedSoulCrystalProjectiles.cs index b38df7c966..fd078bae10 100644 --- a/Projectiles/Summon/ProfanedSoulCrystalProjectiles.cs +++ b/Projectiles/Summon/ProfanedSoulCrystalProjectiles.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.IO; using CalamityMod.Buffs.Summon.Whips; +using CalamityMod.Items.Potions.Alcohol; using static CalamityMod.Items.Accessories.ProfanedSoulCrystal; using CalamityMod.NPCs.Providence; using CalamityMod.Particles; @@ -139,6 +140,10 @@ namespace CalamityMod.Projectiles.Summon int num469 = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, dustID, 0f, 0f, 100, default, 1f); Main.dust[num469].noGravity = true; Main.dust[num469].velocity *= 0f; + var Owner = Main.player[Projectile.owner]; + Projectile.damage = (int)Owner.GetTotalDamage().ApplyTo(Projectile.originalDamage); + if (Owner.Calamity().oldFashioned) + Projectile.damage = CalamityUtils.CalcOldFashionedDamage(Projectile.damage); } public override Color? GetAlpha(Color lightColor) @@ -247,11 +252,14 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { Lighting.AddLight(Projectile.Center, 0.5f, 0.1f, 0f); + var Owner = Main.player[Projectile.owner]; + Projectile.damage = (int)Owner.GetTotalDamage().ApplyTo(Projectile.originalDamage); + if (Owner.Calamity().oldFashioned) + Projectile.damage = CalamityUtils.CalcOldFashionedDamage(Projectile.damage); if (Projectile.timeLeft == 600) { damage = Projectile.damage; Projectile.damage = 0; - } if (Projectile.timeLeft > 550) Projectile.velocity *= 0.95f; @@ -446,6 +454,10 @@ namespace CalamityMod.Projectiles.Summon Projectile.velocity *= 1.06f; Projectile.rotation = Projectile.velocity.ToRotation() + 1.57079637f; Lighting.AddLight(Projectile.Center, 1f, 0.2f, 0f); + var Owner = Main.player[Projectile.owner]; + Projectile.damage = (int)Owner.GetTotalDamage().ApplyTo(Projectile.originalDamage); + if (Owner.Calamity().oldFashioned) + Projectile.damage = CalamityUtils.CalcOldFashionedDamage(Projectile.damage); } public override bool PreAI() @@ -715,7 +727,12 @@ namespace CalamityMod.Projectiles.Summon { if (Projectile.timeLeft == 175 && Projectile.scale == 1.5f) SoundEngine.PlaySound(SoundID.DD2_BetsyFireballShot, Projectile.Center); - + + var Owner = Main.player[Projectile.owner]; + Projectile.damage = (int)Owner.GetTotalDamage().ApplyTo(Projectile.originalDamage); + if (Owner.Calamity().oldFashioned) + Projectile.damage = CalamityUtils.CalcOldFashionedDamage(Projectile.damage); + Projectile.frameCounter++; if (Projectile.frameCounter > 8) { @@ -878,6 +895,11 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { + var Owner = Main.player[Projectile.owner]; + Projectile.damage = (int)Owner.GetTotalDamage().ApplyTo(Projectile.originalDamage); + if (Owner.Calamity().oldFashioned) + Projectile.damage = CalamityUtils.CalcOldFashionedDamage(Projectile.damage); + Projectile.frameCounter++; if (Projectile.frameCounter > 4) { @@ -996,6 +1018,11 @@ namespace CalamityMod.Projectiles.Summon private void ai() { + var Owner = Main.player[Projectile.owner]; + Projectile.damage = (int)Owner.GetTotalDamage().ApplyTo(Projectile.originalDamage); + if (Owner.Calamity().oldFashioned) + Projectile.damage = CalamityUtils.CalcOldFashionedDamage(Projectile.damage); + if (Projectile.timeLeft > 120) { Projectile.rotation += 1f; @@ -1293,6 +1320,11 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { Player owner = Main.player[Projectile.owner]; + + Projectile.damage = (int)owner.GetTotalDamage().ApplyTo(Projectile.originalDamage); + if (owner.Calamity().oldFashioned) + Projectile.damage = CalamityUtils.CalcOldFashionedDamage(Projectile.damage); + if (Projectile.ai[1] == 0f) { owner.itemAnimation = owner.itemAnimationMax; @@ -1762,6 +1794,12 @@ namespace CalamityMod.Projectiles.Summon { var psc = Projectile.ai[0] > 0f; //Ensure that psa's spears are not coloured by night + + var Owner = Main.player[Projectile.owner]; + Projectile.damage = (int)Owner.GetTotalDamage().ApplyTo(Projectile.originalDamage); + if (Owner.Calamity().oldFashioned) + Projectile.damage = CalamityUtils.CalcOldFashionedDamage(Projectile.damage); + int pscState = (int)((!Main.dayTime && psc) ? Providence.BossMode.Night : Providence.BossMode.Day); int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, ProvUtils.GetDustID(pscState), 0f, 0f, 100, default, !Main.dayTime && psc ? 0.5f : 1f); Main.dust[num469].noGravity = true; @@ -1901,6 +1939,11 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { + var Owner = Main.player[Projectile.owner]; + Projectile.damage = (int)Owner.GetTotalDamage().ApplyTo(Projectile.originalDamage); + if (Owner.Calamity().oldFashioned) + Projectile.damage = CalamityUtils.CalcOldFashionedDamage(Projectile.damage); + int pscState = (int)(Main.dayTime ? Providence.BossMode.Day : Providence.BossMode.Night); int num469 = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, ProvUtils.GetDustID(pscState), 0f, 0f, 100, default, 1f); Main.dust[num469].noGravity = true; @@ -2015,6 +2058,11 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { Lighting.AddLight(Projectile.Center, 0.3f, 0.225f, 0f); + + var Owner = Main.player[Projectile.owner]; + Projectile.damage = (int)Owner.GetTotalDamage().ApplyTo(Projectile.originalDamage); + if (Owner.Calamity().oldFashioned) + Projectile.damage = CalamityUtils.CalcOldFashionedDamage(Projectile.damage); Projectile.frameCounter++; if (Projectile.frameCounter > 6) diff --git a/Projectiles/Summon/PurpleButterfly.cs b/Projectiles/Summon/PurpleButterfly.cs index 88565068b1..fccd2d79a0 100644 --- a/Projectiles/Summon/PurpleButterfly.cs +++ b/Projectiles/Summon/PurpleButterfly.cs @@ -42,14 +42,14 @@ namespace CalamityMod.Projectiles.Summon CalamityPlayer modPlayer = player.Calamity(); if (dust > 0) { - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int i = 0; i < dustAmt; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.5f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 173, vector7.X, vector7.Y, 100, default, 1.8f); - Main.dust[num228].noGravity = true; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.5f; + rotate = rotate.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int dust = Dust.NewDust(rotate + faceDirection, 0, 0, 173, faceDirection.X, faceDirection.Y, 100, default, 1.8f); + Main.dust[dust].noGravity = true; } dust--; } @@ -70,9 +70,9 @@ namespace CalamityMod.Projectiles.Summon } Lighting.AddLight(Projectile.Center, 0.3f, 0f, 0.5f); Projectile.ChargingMinionAI(1200f, 1500f, 2400f, 150f, 0, 30f, 18f, 9f, new Vector2(0f, -60f), 30f, 12f, true, true); - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isMinion = Projectile.type == ModContent.ProjectileType(); player.AddBuff(ModContent.BuffType(), 3600); - if (flag64) + if (isMinion) { if (player.dead) { @@ -89,9 +89,9 @@ namespace CalamityMod.Projectiles.Summon { SpriteEffects spriteEffects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, spriteEffects, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, spriteEffects, 0); return false; } diff --git a/Projectiles/Summon/SageNeedle.cs b/Projectiles/Summon/SageNeedle.cs index 8895b30701..0a892ab19a 100644 --- a/Projectiles/Summon/SageNeedle.cs +++ b/Projectiles/Summon/SageNeedle.cs @@ -43,12 +43,12 @@ namespace CalamityMod.Projectiles.Summon // at around 344 allocated slots. float averageDamageMultiplier = (float)(Math.Pow(totalSageSpirits, 0.73D) + Math.Pow(totalSageSpirits, 1.1D)) * 0.5f; - // 1 slot provides 20 DoT. - // 2 slots provide 38 DoT. - // 3 slots provide 56 DoT. - // 4 slots provide 73 DoT. - // 5 slots provide 91 DoT. - int sagePoisonDamage = (int)(20 * averageDamageMultiplier); + // 1 slot provides 25 DoT. + // 2 slots provide 48 DoT. + // 3 slots provide 70 DoT. + // 4 slots provide 92 DoT. + // 5 slots provide 114 DoT. + int sagePoisonDamage = (int)(50 * averageDamageMultiplier); target.AddBuff(ModContent.BuffType(), 300); target.Calamity().sagePoisonDamage = sagePoisonDamage; } diff --git a/Projectiles/Summon/SageSpirit.cs b/Projectiles/Summon/SageSpirit.cs index 5a2f5c82ee..4a6a815670 100644 --- a/Projectiles/Summon/SageSpirit.cs +++ b/Projectiles/Summon/SageSpirit.cs @@ -176,7 +176,7 @@ namespace CalamityMod.Projectiles.Summon AttackTimer++; int totalSageSpirits = Owner.ownedProjectileCounts[Projectile.type]; - Vector2 destinationOffsetFactor = Vector2.Max(target.Size, new Vector2(160f)) * new Vector2(0.6f, 0.37f); + Vector2 destinationOffsetFactor = Vector2.Max(target.Size, new Vector2(160f)) * new Vector2(0.3f, 0.2f); Vector2 destination = target.Center + (AttackTimer / 12f).ToRotationVector2() * destinationOffsetFactor; destination += (SageSpiritIndex * MathHelper.TwoPi / totalSageSpirits).ToRotationVector2() * 130f; Projectile.Center = Vector2.Lerp(Projectile.Center, destination, 0.1f); diff --git a/Projectiles/Summon/SakuraBullet.cs b/Projectiles/Summon/SakuraBullet.cs index 449f564029..f6b29e3023 100644 --- a/Projectiles/Summon/SakuraBullet.cs +++ b/Projectiles/Summon/SakuraBullet.cs @@ -88,25 +88,25 @@ namespace CalamityMod.Projectiles.Summon Projectile.velocity = (Projectile.velocity * 20f + moveDirection * 11f) / (21f); } - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 73, 0f, 0f, 100, default, 0.6f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int pinkDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 73, 0f, 0f, 100, default, 0.6f); + Main.dust[pinkDust].noGravity = true; + Main.dust[pinkDust].velocity *= 0.5f; + Main.dust[pinkDust].velocity += Projectile.velocity * 0.1f; } public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item25, Projectile.position); - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 73, 0f, 0f, 100, default, 1f); - Main.dust[num622].velocity *= 0.5f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 73, 0f, 0f, 100, default, 1f); + Main.dust[dust].velocity *= 0.5f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 73, 0f, 0f, 100, default, 1.4f); - Main.dust[num624].noGravity = true; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 73, 0f, 0f, 100, default, 0.8f); + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 73, 0f, 0f, 100, default, 1.4f); + Main.dust[dust2].noGravity = true; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 73, 0f, 0f, 100, default, 0.8f); } } } diff --git a/Projectiles/Summon/SandElementalMinion.cs b/Projectiles/Summon/SandElementalMinion.cs index 2511555085..d8a45cdf7c 100644 --- a/Projectiles/Summon/SandElementalMinion.cs +++ b/Projectiles/Summon/SandElementalMinion.cs @@ -46,8 +46,8 @@ namespace CalamityMod.Projectiles.Summon Projectile.active = false; return; } - bool flag64 = Projectile.type == ModContent.ProjectileType(); - if (flag64) + bool isMinion = Projectile.type == ModContent.ProjectileType(); + if (isMinion) { if (player.dead) { @@ -61,12 +61,11 @@ namespace CalamityMod.Projectiles.Summon dust--; if (dust >= 0) { - int num501 = 50; - for (int num502 = 0; num502 < num501; num502++) + for (int i = 0; i < 50; i++) { - int num503 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, 32, 0f, 0f, 0, default, 1f); - Main.dust[num503].velocity *= 2f; - Main.dust[num503].scale *= 1.15f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, 32, 0f, 0f, 0, default, 1f); + Main.dust[dust].velocity *= 2f; + Main.dust[dust].scale *= 1.15f; } } bool passive = modPlayer.sandWaifuVanity || modPlayer.allWaifusVanity; @@ -74,19 +73,16 @@ namespace CalamityMod.Projectiles.Summon { Projectile.spriteDirection = -Projectile.direction; } - float num633 = 700f; //700 - float num634 = 800f; - float num635 = 1200f; - float num636 = 200f; //150 + float attackDistance = 700f; //700 if (!passive) { - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight(Projectile.Center, 0.7f * num, 0.6f * num, 0f * num); + float lights = (float)Main.rand.Next(90, 111) * 0.01f; + lights *= Main.essScale; + Lighting.AddLight(Projectile.Center, 0.7f * lights, 0.6f * lights, 0f * lights); } Projectile.MinionAntiClump(); - Vector2 vector46 = Projectile.position; - bool flag25 = false; + Vector2 projPos = Projectile.position; + bool canAttack = false; if (Projectile.ai[0] != 1f) { Projectile.tileCollide = false; @@ -100,33 +96,33 @@ namespace CalamityMod.Projectiles.Summon NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(Projectile, false)) { - float num646 = Vector2.Distance(npc.Center, Projectile.Center); - if (!flag25 && num646 < num633) + float targetDist = Vector2.Distance(npc.Center, Projectile.Center); + if (!canAttack && targetDist < attackDistance) { - vector46 = npc.Center; - flag25 = true; + projPos = npc.Center; + canAttack = true; } } } - if (!flag25 && !passive) + if (!canAttack && !passive) { - for (int num645 = 0; num645 < Main.maxNPCs; num645++) + for (int j = 0; j < Main.maxNPCs; j++) { - NPC nPC2 = Main.npc[num645]; + NPC nPC2 = Main.npc[j]; if (nPC2.CanBeChasedBy(Projectile, false)) { - float num646 = Vector2.Distance(nPC2.Center, Projectile.Center); - if ((!flag25 && num646 < num633) && Collision.CanHitLine(Projectile.position, Projectile.width, Projectile.height, nPC2.position, nPC2.width, nPC2.height)) + float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center); + if ((!canAttack && targetDist < attackDistance) && Collision.CanHitLine(Projectile.position, Projectile.width, Projectile.height, nPC2.position, nPC2.width, nPC2.height)) { - num633 = num646; - vector46 = nPC2.Center; - flag25 = true; + attackDistance = targetDist; + projPos = nPC2.Center; + canAttack = true; } } } } - float num647 = num634; - if (flag25 && !passive) + float separationAnxietyDist = 800f; + if (canAttack && !passive) { if (Projectile.frame < 6) { @@ -142,7 +138,7 @@ namespace CalamityMod.Projectiles.Summon { Projectile.frame = 6; } - num647 = num635; + separationAnxietyDist = 1200f; } else { @@ -157,65 +153,64 @@ namespace CalamityMod.Projectiles.Summon Projectile.frame = 0; } } - if (Vector2.Distance(player.Center, Projectile.Center) > num647) + if (Vector2.Distance(player.Center, Projectile.Center) > separationAnxietyDist) { Projectile.ai[0] = 1f; Projectile.tileCollide = false; Projectile.netUpdate = true; } - if (flag25 && Projectile.ai[0] == 0f) + if (canAttack && Projectile.ai[0] == 0f) { - Vector2 vector47 = vector46 - Projectile.Center; - float num648 = vector47.Length(); - vector47.Normalize(); - if (num648 > 200f) + Vector2 targetDirection = projPos - Projectile.Center; + float targetDistance = targetDirection.Length(); + targetDirection.Normalize(); + if (targetDistance > 200f) { float scaleFactor2 = 8f; - vector47 *= scaleFactor2; - Projectile.velocity = (Projectile.velocity * 40f + vector47) / 41f; + targetDirection *= scaleFactor2; + Projectile.velocity = (Projectile.velocity * 40f + targetDirection) / 41f; } else { - float num649 = 4f; - vector47 *= -num649; - Projectile.velocity = (Projectile.velocity * 40f + vector47) / 41f; + targetDirection *= -4f; + Projectile.velocity = (Projectile.velocity * 40f + targetDirection) / 41f; } } else { - bool flag26 = false; - if (!flag26) + bool isReturning = false; + if (!isReturning) { - flag26 = Projectile.ai[0] == 1f; + isReturning = Projectile.ai[0] == 1f; } - float num650 = 6f; //6 - if (flag26) + float returnSpeed = 6f; //6 + if (isReturning) { - num650 = 15f; //16 + returnSpeed = 15f; //16 } Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2 + new Vector2(250f, -60f); //-60 - float num651 = vector48.Length(); - if (num651 > 200f && num650 < 8f) //200 and 8 + Vector2 playerDirection = player.Center - center2 + new Vector2(250f, -60f); //-60 + float playerDist = playerDirection.Length(); + if (playerDist > 200f && returnSpeed < 8f) //200 and 8 { - num650 = 8f; //8 + returnSpeed = 8f; //8 } - if (num651 < num636 && flag26 && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + if (playerDist < 200f && isReturning && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) { Projectile.ai[0] = 0f; Projectile.netUpdate = true; } - if (num651 > 2000f) + if (playerDist > 2000f) { Projectile.position.X = player.Center.X - (float)(Projectile.width / 2); Projectile.position.Y = player.Center.Y - (float)(Projectile.height / 2); Projectile.netUpdate = true; } - if (num651 > 70f) + if (playerDist > 70f) { - vector48.Normalize(); - vector48 *= num650; - Projectile.velocity = (Projectile.velocity * 40f + vector48) / 41f; + playerDirection.Normalize(); + playerDirection *= returnSpeed; + Projectile.velocity = (Projectile.velocity * 40f + playerDirection) / 41f; } else if (Projectile.velocity.X == 0f && Projectile.velocity.Y == 0f) { @@ -240,16 +235,16 @@ namespace CalamityMod.Projectiles.Summon if (Projectile.ai[0] == 0f) { float scaleFactor3 = 11f; - int num658 = ModContent.ProjectileType(); - if (flag25 && Projectile.ai[1] == 0f && Projectile.localAI[0] >= 120f) + int projType = ModContent.ProjectileType(); + if (canAttack && Projectile.ai[1] == 0f && Projectile.localAI[0] >= 120f) { Projectile.ai[1] += 1f; - if (Main.myPlayer == Projectile.owner && Collision.CanHitLine(Projectile.position, Projectile.width, Projectile.height, vector46, 0, 0)) + if (Main.myPlayer == Projectile.owner && Collision.CanHitLine(Projectile.position, Projectile.width, Projectile.height, projPos, 0, 0)) { - Vector2 value19 = vector46 - Projectile.Center; - value19.Normalize(); - value19 *= scaleFactor3; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, value19, num658, Projectile.damage, 0f, Main.myPlayer); + Vector2 projVel = projPos - Projectile.Center; + projVel.Normalize(); + projVel *= scaleFactor3; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, projVel, projType, Projectile.damage, 0f, Main.myPlayer); Projectile.netUpdate = true; } } diff --git a/Projectiles/Summon/SandMark.cs b/Projectiles/Summon/SandMark.cs index 9a0606c688..e366f64e60 100644 --- a/Projectiles/Summon/SandMark.cs +++ b/Projectiles/Summon/SandMark.cs @@ -40,34 +40,34 @@ namespace CalamityMod.Projectiles.Summon } if (Projectile.localAI[1] < 30f) { - for (int num1134 = 0; num1134 < 1; num1134++) + for (int i = 0; i < 1; i++) { - float value79 = -0.5f; - float value80 = 0.9f; - float amount4 = Main.rand.NextFloat(); - Vector2 value81 = new Vector2(MathHelper.Lerp(0.1f, 1f, Main.rand.NextFloat()), MathHelper.Lerp(value79, value80, amount4)); - value81.X *= MathHelper.Lerp(2.2f, 0.6f, amount4); - value81.X *= -1f; - Vector2 value82 = new Vector2(2f, 10f); - Vector2 position4 = Projectile.Center + new Vector2(60f, 200f) * value81 * 0.5f + value82; - Dust dust34 = Main.dust[Dust.NewDust(position4, 0, 0, 269, 0f, 0f, 0, default, 0.5f)]; - dust34.position = position4; - dust34.customData = Projectile.Center + value82; - dust34.fadeIn = 1f; - dust34.scale = 0.3f; - if (value81.X > -1.2f) + float lerpvalue1 = -0.5f; + float lerpvalue2 = 0.9f; + float randomLerp = Main.rand.NextFloat(); + Vector2 dustMovement = new Vector2(MathHelper.Lerp(0.1f, 1f, Main.rand.NextFloat()), MathHelper.Lerp(lerpvalue1, lerpvalue2, randomLerp)); + dustMovement.X *= MathHelper.Lerp(2.2f, 0.6f, randomLerp); + dustMovement.X *= -1f; + Vector2 dustMovement2 = new Vector2(2f, 10f); + Vector2 position4 = Projectile.Center + new Vector2(60f, 200f) * dustMovement * 0.5f + dustMovement2; + Dust dust = Main.dust[Dust.NewDust(position4, 0, 0, 269, 0f, 0f, 0, default, 0.5f)]; + dust.position = position4; + dust.customData = Projectile.Center + dustMovement2; + dust.fadeIn = 1f; + dust.scale = 0.3f; + if (dustMovement.X > -1.2f) { - dust34.velocity.X = 1f + Main.rand.NextFloat(); + dust.velocity.X = 1f + Main.rand.NextFloat(); } - dust34.velocity.Y = Main.rand.NextFloat() * -0.5f - 1f; + dust.velocity.Y = Main.rand.NextFloat() * -0.5f - 1f; } } if (Projectile.localAI[0] == 0f) { Projectile.localAI[0] = 0.8f; Projectile.direction = 1; - Point point9 = Projectile.Center.ToTileCoordinates(); - Projectile.Center = new Vector2((float)(point9.X * 16 + 8), (float)(point9.Y * 16 + 8)); + Point projCenter = Projectile.Center.ToTileCoordinates(); + Projectile.Center = new Vector2((float)(projCenter.X * 16 + 8), (float)(projCenter.Y * 16 + 8)); } Projectile.rotation = Projectile.localAI[1] / 40f * 6.28318548f * (float)Projectile.direction; if (Projectile.localAI[1] < 33f) @@ -96,30 +96,30 @@ namespace CalamityMod.Projectiles.Summon { Lighting.AddLight(Projectile.Center, newColor3.ToVector3() * 0.5f); } - for (int num1135 = 0; num1135 < 2; num1135++) + for (int j = 0; j < 2; j++) { if (Main.rand.NextBool(10)) { - Vector2 value83 = Vector2.UnitY.RotatedBy((double)((float)num1135 * 3.14159274f), default).RotatedBy((double)Projectile.rotation, default); - Dust dust35 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 269, 0f, 0f, 225, newColor3, 1f)]; - dust35.noGravity = true; - dust35.noLight = true; - dust35.scale = Projectile.Opacity * Projectile.localAI[0]; - dust35.position = Projectile.Center; - dust35.velocity = value83 * 2.5f; + Vector2 dustVel = Vector2.UnitY.RotatedBy((double)((float)j * 3.14159274f), default).RotatedBy((double)Projectile.rotation, default); + Dust dusty = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 269, 0f, 0f, 225, newColor3, 1f)]; + dusty.noGravity = true; + dusty.noLight = true; + dusty.scale = Projectile.Opacity * Projectile.localAI[0]; + dusty.position = Projectile.Center; + dusty.velocity = dustVel * 2.5f; } } - for (int num1136 = 0; num1136 < 2; num1136++) + for (int k = 0; k < 2; k++) { if (Main.rand.NextBool(10)) { - Vector2 value84 = Vector2.UnitY.RotatedBy((double)((float)num1136 * 3.14159274f), default); - Dust dust36 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 269, 0f, 0f, 225, newColor3, 1.5f)]; - dust36.noGravity = true; - dust36.noLight = true; - dust36.scale = Projectile.Opacity * Projectile.localAI[0]; - dust36.position = Projectile.Center; - dust36.velocity = value84 * 2.5f; + Vector2 dustVel2 = Vector2.UnitY.RotatedBy((double)((float)k * 3.14159274f), default); + Dust dustier = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 269, 0f, 0f, 225, newColor3, 1.5f)]; + dustier.noGravity = true; + dustier.noLight = true; + dustier.scale = Projectile.Opacity * Projectile.localAI[0]; + dustier.position = Projectile.Center; + dustier.velocity = dustVel2 * 2.5f; } } if (Projectile.localAI[1] < 33f || Projectile.localAI[1] > 87f) @@ -141,16 +141,16 @@ namespace CalamityMod.Projectiles.Summon public override bool PreDraw(ref Color lightColor) { - Color color25 = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); - Vector2 vector38 = Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; + Color originalColor = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); + Vector2 drawPos = Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; Texture2D texture2D27 = ModContent.Request(Texture).Value; - Rectangle rectangle11 = texture2D27.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); - Color alpha5 = Projectile.GetAlpha(color25); - Vector2 origin7 = rectangle11.Size() / 2f; - Color color47 = Main.hslToRgb(0.25f, 1f, 1f).MultiplyRGBA(new Color(255, 255, 255, 0)); - Main.EntitySpriteDraw(texture2D27, vector38, new Microsoft.Xna.Framework.Rectangle?(rectangle11), color47, 0f, origin7, new Vector2(1f, 5f) * Projectile.scale * 2f, SpriteEffects.None, 0); - Main.EntitySpriteDraw(texture2D27, vector38, new Microsoft.Xna.Framework.Rectangle?(rectangle11), alpha5, Projectile.rotation, origin7, Projectile.scale, SpriteEffects.None, 0); - Main.EntitySpriteDraw(texture2D27, vector38, new Microsoft.Xna.Framework.Rectangle?(rectangle11), alpha5, 0f, origin7, new Vector2(1f, 8f) * Projectile.scale, SpriteEffects.None, 0); + Rectangle rectangle = texture2D27.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); + Color alphaColor = Projectile.GetAlpha(originalColor); + Vector2 origin7 = rectangle.Size() / 2f; + Color sandyColor = Main.hslToRgb(0.25f, 1f, 1f).MultiplyRGBA(new Color(255, 255, 255, 0)); + Main.EntitySpriteDraw(texture2D27, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangle), sandyColor, 0f, origin7, new Vector2(1f, 5f) * Projectile.scale * 2f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(texture2D27, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangle), alphaColor, Projectile.rotation, origin7, Projectile.scale, SpriteEffects.None, 0); + Main.EntitySpriteDraw(texture2D27, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangle), alphaColor, 0f, origin7, new Vector2(1f, 8f) * Projectile.scale, SpriteEffects.None, 0); return false; } } diff --git a/Projectiles/Summon/SandTornado.cs b/Projectiles/Summon/SandTornado.cs index 45c37c5bdc..8aaa6d1339 100644 --- a/Projectiles/Summon/SandTornado.cs +++ b/Projectiles/Summon/SandTornado.cs @@ -30,65 +30,63 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - float num1125 = 900f; + float lifeSpan = 900f; if (Projectile.soundDelay == 0) { Projectile.soundDelay = -1; SoundEngine.PlaySound(SoundID.Item122, Projectile.position); } Projectile.ai[0] += 1f; - if (Projectile.ai[0] >= num1125) + if (Projectile.ai[0] >= lifeSpan) { Projectile.Kill(); } if (Projectile.localAI[0] >= 30f) { Projectile.damage = 0; - if (Projectile.ai[0] < num1125 - 120f) + if (Projectile.ai[0] < lifeSpan - 120f) { - float num1126 = Projectile.ai[0] % 60f; - Projectile.ai[0] = num1125 - 120f + num1126; + float aiDecrement = Projectile.ai[0] % 60f; + Projectile.ai[0] = lifeSpan - 120f + aiDecrement; Projectile.netUpdate = true; } } - float num1127 = 15f; - float num1128 = 15f; Point point8 = Projectile.Center.ToTileCoordinates(); - int num1129; - int num1130; - Collision.ExpandVertically(point8.X, point8.Y, out num1129, out num1130, (int)num1127, (int)num1128); - num1129++; - num1130--; - Vector2 value72 = new Vector2((float)point8.X, (float)num1129) * 16f + new Vector2(8f); - Vector2 value73 = new Vector2((float)point8.X, (float)num1130) * 16f + new Vector2(8f); - Vector2 vector146 = Vector2.Lerp(value72, value73, 0.5f); - Vector2 value74 = new Vector2(0f, value73.Y - value72.Y); - value74.X = value74.Y * 0.2f; - Projectile.width = (int)(value74.X * 0.65f); - Projectile.height = (int)value74.Y; - Projectile.Center = vector146; + int sizeMod; + int sizeMod2; + Collision.ExpandVertically(point8.X, point8.Y, out sizeMod, out sizeMod2, 15, 15); + sizeMod++; + sizeMod2--; + Vector2 sizeModVector = new Vector2((float)point8.X, (float)sizeMod) * 16f + new Vector2(8f); + Vector2 sizeModVector2 = new Vector2((float)point8.X, (float)sizeMod2) * 16f + new Vector2(8f); + Vector2 centering = Vector2.Lerp(sizeModVector, sizeModVector2, 0.5f); + Vector2 sizeModPos = new Vector2(0f, sizeModVector2.Y - sizeModVector.Y); + sizeModPos.X = sizeModPos.Y * 0.2f; + Projectile.width = (int)(sizeModPos.X * 0.65f); + Projectile.height = (int)sizeModPos.Y; + Projectile.Center = centering; if (Projectile.owner == Main.myPlayer) { - bool flag74 = false; - Vector2 center16 = Main.player[Projectile.owner].Center; + bool breakFlag = false; + Vector2 playerCenter = Main.player[Projectile.owner].Center; Vector2 top = Main.player[Projectile.owner].Top; - for (float num1131 = 0f; num1131 < 1f; num1131 += 0.05f) + for (float i = 0f; i < 1f; i += 0.05f) { - Vector2 position2 = Vector2.Lerp(value72, value73, num1131); - if (Collision.CanHitLine(position2, 0, 0, center16, 0, 0) || Collision.CanHitLine(position2, 0, 0, top, 0, 0)) + Vector2 position2 = Vector2.Lerp(sizeModVector, sizeModVector2, i); + if (Collision.CanHitLine(position2, 0, 0, playerCenter, 0, 0) || Collision.CanHitLine(position2, 0, 0, top, 0, 0)) { - flag74 = true; + breakFlag = true; break; } } - if (!flag74 && Projectile.ai[0] < num1125 - 120f) + if (!breakFlag && Projectile.ai[0] < lifeSpan - 120f) { - float num1132 = Projectile.ai[0] % 60f; - Projectile.ai[0] = num1125 - 120f + num1132; + float aiDecrement2 = Projectile.ai[0] % 60f; + Projectile.ai[0] = lifeSpan - 120f + aiDecrement2; Projectile.netUpdate = true; } } - if (Projectile.ai[0] < num1125 - 120f) + if (Projectile.ai[0] < lifeSpan - 120f) { return; } @@ -96,57 +94,54 @@ namespace CalamityMod.Projectiles.Summon public override bool PreDraw(ref Color lightColor) { - float num226 = 600f; - float num227 = 15f; - float num228 = 15f; - float num229 = Projectile.ai[0]; - float scale5 = MathHelper.Clamp(num229 / 30f, 0f, 1f); - if (num229 > num226 - 60f) + float aiTracker = Projectile.ai[0]; + float trackerClamp = MathHelper.Clamp(aiTracker / 30f, 0f, 1f); + if (aiTracker > 540f) { - scale5 = MathHelper.Lerp(1f, 0f, (num229 - (num226 - 60f)) / 60f); + trackerClamp = MathHelper.Lerp(1f, 0f, (aiTracker - 540f) / 60f); } - Point point5 = Projectile.Center.ToTileCoordinates(); - int num230; - int num231; - Collision.ExpandVertically(point5.X, point5.Y, out num230, out num231, (int)num227, (int)num228); - num230++; - num231--; - float num232 = 0.2f; - Vector2 value32 = new Vector2((float)point5.X, (float)num230) * 16f + new Vector2(8f); - Vector2 value33 = new Vector2((float)point5.X, (float)num231) * 16f + new Vector2(8f); - Vector2.Lerp(value32, value33, 0.5f); - Vector2 vector33 = new Vector2(0f, value33.Y - value32.Y); - vector33.X = vector33.Y * num232; - new Vector2(value32.X - vector33.X / 2f, value32.Y); + Point centerPoint = Projectile.Center.ToTileCoordinates(); + int sizeModding; + int sizeModding2; + Collision.ExpandVertically(centerPoint.X, centerPoint.Y, out sizeModding, out sizeModding2, 15, 15); + sizeModding++; + sizeModding2--; + float vectorMult = 0.2f; + Vector2 sizeModdingVector = new Vector2((float)centerPoint.X, (float)sizeModding) * 16f + new Vector2(8f); + Vector2 sizeModdingVector2 = new Vector2((float)centerPoint.X, (float)sizeModding2) * 16f + new Vector2(8f); + Vector2.Lerp(sizeModdingVector, sizeModdingVector2, 0.5f); + Vector2 sizeModdingPos = new Vector2(0f, sizeModdingVector2.Y - sizeModdingVector.Y); + sizeModdingPos.X = sizeModdingPos.Y * vectorMult; + new Vector2(sizeModdingVector.X - sizeModdingPos.X / 2f, sizeModdingVector.Y); Texture2D texture2D23 = ModContent.Request(Texture).Value; - Rectangle rectangle9 = texture2D23.Frame(1, 1, 0, 0); - Vector2 origin3 = rectangle9.Size() / 2f; - float num233 = -0.06283186f * num229; - Vector2 spinningpoint2 = Vector2.UnitY.RotatedBy((double)(num229 * 0.1f), default); - float num234 = 0f; - float num235 = 5.1f; - Color value34 = new Color(225, 225, 100); - for (float num236 = (float)(int)value33.Y; num236 > (float)(int)value32.Y; num236 -= num235) + Rectangle drawRectangle = texture2D23.Frame(1, 1, 0, 0); + Vector2 smallRect = drawRectangle.Size() / 2f; + float aiTrackMult = -0.06283186f * aiTracker; + Vector2 spinningpoint2 = Vector2.UnitY.RotatedBy((double)(aiTracker * 0.1f), default); + float incrementStorage = 0f; + float increment = 5.1f; + Color sandYellow = new Color(225, 225, 100); + for (float k = (float)(int)sizeModdingVector2.Y; k > (float)(int)sizeModdingVector.Y; k -= increment) { - num234 += num235; - float num237 = num234 / vector33.Y; - float num238 = num234 * 6.28318548f / -20f; - float num239 = num237 - 0.15f; - Vector2 vector34 = spinningpoint2.RotatedBy((double)num238, default); - Vector2 value35 = new Vector2(0f, num237 + 1f); - value35.X = value35.Y * num232; - Color color39 = Microsoft.Xna.Framework.Color.Lerp(Microsoft.Xna.Framework.Color.Transparent, value34, num237 * 2f); - if (num237 > 0.5f) + incrementStorage += increment; + float colorChanger = incrementStorage / sizeModdingPos.Y; + float incStorageMult = incrementStorage * 6.28318548f / -20f; + float lowerColorChanger = colorChanger - 0.15f; + Vector2 spinArea = spinningpoint2.RotatedBy((double)incStorageMult, default); + Vector2 colorChangeVector = new Vector2(0f, colorChanger + 1f); + colorChangeVector.X = colorChangeVector.Y * vectorMult; + Color newSandYellow = Microsoft.Xna.Framework.Color.Lerp(Microsoft.Xna.Framework.Color.Transparent, sandYellow, colorChanger * 2f); + if (colorChanger > 0.5f) { - color39 = Microsoft.Xna.Framework.Color.Lerp(Microsoft.Xna.Framework.Color.Transparent, value34, 2f - num237 * 2f); + newSandYellow = Microsoft.Xna.Framework.Color.Lerp(Microsoft.Xna.Framework.Color.Transparent, sandYellow, 2f - colorChanger * 2f); } - color39.A = (byte)((float)color39.A * 0.5f); - color39 *= scale5; - vector34 *= value35 * 100f; - vector34.Y = 0f; - vector34.X = 0f; - vector34 += new Vector2(value33.X, num236) - Main.screenPosition; - Main.EntitySpriteDraw(texture2D23, vector34, new Microsoft.Xna.Framework.Rectangle?(rectangle9), color39, num233 + num238, origin3, 1f + num239, SpriteEffects.None, 0); + newSandYellow.A = (byte)((float)newSandYellow.A * 0.5f); + newSandYellow *= trackerClamp; + spinArea *= colorChangeVector * 100f; + spinArea.Y = 0f; + spinArea.X = 0f; + spinArea += new Vector2(sizeModdingVector2.X, k) - Main.screenPosition; + Main.EntitySpriteDraw(texture2D23, spinArea, new Microsoft.Xna.Framework.Rectangle?(drawRectangle), newSandYellow, aiTrackMult + incStorageMult, smallRect, 1f + lowerColorChanger, SpriteEffects.None, 0); } return false; } diff --git a/Projectiles/Summon/SilvaCrystal.cs b/Projectiles/Summon/SilvaCrystal.cs index 0bb2b1b993..2df2ba0adb 100644 --- a/Projectiles/Summon/SilvaCrystal.cs +++ b/Projectiles/Summon/SilvaCrystal.cs @@ -38,13 +38,13 @@ namespace CalamityMod.Projectiles.Summon { Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isMinion = Projectile.type == ModContent.ProjectileType(); if (!modPlayer.silvaSummon) { Projectile.active = false; return; } - if (flag64) + if (isMinion) { if (player.dead) { @@ -67,7 +67,6 @@ namespace CalamityMod.Projectiles.Summon } Projectile.position.X = (int)Projectile.position.X; Projectile.position.Y = (int)Projectile.position.Y; - float num1072 = 1500f; Projectile.velocity = Vector2.Zero; Projectile.alpha -= 5; if (Projectile.alpha < 0) @@ -80,12 +79,12 @@ namespace CalamityMod.Projectiles.Summon } if (Projectile.alpha == 0 && Main.rand.NextBool(15)) { - Dust dust34 = Main.dust[Dust.NewDust(Projectile.Top, 0, 0, 267, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f)]; - dust34.velocity.X = 0f; - dust34.noGravity = true; - dust34.fadeIn = 1f; - dust34.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(6.2831854820251465) * (4f * Main.rand.NextFloat() + 26f); - dust34.scale = 0.5f; + Dust silvaDust = Main.dust[Dust.NewDust(Projectile.Top, 0, 0, 267, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f)]; + silvaDust.velocity.X = 0f; + silvaDust.noGravity = true; + silvaDust.fadeIn = 1f; + silvaDust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(6.2831854820251465) * (4f * Main.rand.NextFloat() + 26f); + silvaDust.scale = 0.5f; } Projectile.localAI[0] += 1f; if (Projectile.localAI[0] >= 60f) @@ -98,51 +97,51 @@ namespace CalamityMod.Projectiles.Summon } if (Projectile.ai[0] == 0f) { - int num1074 = -1; - float num1075 = num1072; + int targetID = -1; + float attackRange = 1500f; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(Projectile, false)) { - float num1076 = Projectile.Distance(npc.Center); - if (num1076 < num1075 && Collision.CanHitLine(Projectile.Center, 0, 0, npc.Center, 0, 0)) + float targetDist = Projectile.Distance(npc.Center); + if (targetDist < attackRange && Collision.CanHitLine(Projectile.Center, 0, 0, npc.Center, 0, 0)) { - num1075 = num1076; - num1074 = npc.whoAmI; + attackRange = targetDist; + targetID = npc.whoAmI; } } } - if (num1074 < 0) + if (targetID < 0) { - int num30; - for (int num1077 = 0; num1077 < Main.maxNPCs; num1077 = num30 + 1) + int targetIDCopy; + for (int i = 0; i < Main.maxNPCs; i = targetIDCopy + 1) { - NPC nPC16 = Main.npc[num1077]; - if (nPC16.CanBeChasedBy(Projectile, false)) + NPC target = Main.npc[i]; + if (target.CanBeChasedBy(Projectile, false)) { - float num1078 = Projectile.Distance(nPC16.Center); - if (num1078 < num1075 && Collision.CanHitLine(Projectile.Center, 0, 0, nPC16.Center, 0, 0)) + float targetDistance = Projectile.Distance(target.Center); + if (targetDistance < attackRange && Collision.CanHitLine(Projectile.Center, 0, 0, target.Center, 0, 0)) { - num1075 = num1078; - num1074 = num1077; + attackRange = targetDistance; + targetID = i; } } - num30 = num1077; + targetIDCopy = i; } } - if (num1074 != -1) + if (targetID != -1) { Projectile.ai[0] = 1f; - Projectile.ai[1] = (float)num1074; + Projectile.ai[1] = (float)targetID; Projectile.netUpdate = true; return; } } if (Projectile.ai[0] > 0f) { - int num1079 = (int)Projectile.ai[1]; - if (!Main.npc[num1079].CanBeChasedBy(Projectile, false)) + int npcTrack = (int)Projectile.ai[1]; + if (!Main.npc[npcTrack].CanBeChasedBy(Projectile, false)) { Projectile.ai[0] = 0f; Projectile.ai[1] = 0f; @@ -152,24 +151,24 @@ namespace CalamityMod.Projectiles.Summon Projectile.ai[0] += 1f; if (Projectile.ai[0] >= 5f) { - int num1082 = (Projectile.SafeDirectionTo(Main.npc[num1079].Center, Vector2.UnitY).X > 0f) ? 1 : -1; - Projectile.direction = num1082; + int projXDirection = (Projectile.SafeDirectionTo(Main.npc[npcTrack].Center, Vector2.UnitY).X > 0f) ? 1 : -1; + Projectile.direction = projXDirection; Projectile.ai[0] = -20f; Projectile.netUpdate = true; if (Projectile.owner == Main.myPlayer) { - Vector2 vector155 = Main.npc[num1079].position + Main.npc[num1079].Size * Utils.RandomVector2(Main.rand, 0f, 1f) - Projectile.Center; - int num31; - for (int num1083 = 0; num1083 < 3; num1083 = num31 + 1) + Vector2 attackPos = Main.npc[npcTrack].position + Main.npc[npcTrack].Size * Utils.RandomVector2(Main.rand, 0f, 1f) - Projectile.Center; + int attackAmt; + for (int j = 0; j < 3; j = attackAmt + 1) { - Vector2 vector156 = Projectile.Center + vector155; - if (num1083 > 0) + Vector2 finalAttackPos = Projectile.Center + attackPos; + if (j > 0) { - vector156 = Projectile.Center + vector155.RotatedByRandom(0.78539818525314331) * (Main.rand.NextFloat() * 0.5f + 0.75f); + finalAttackPos = Projectile.Center + attackPos.RotatedByRandom(0.78539818525314331) * (Main.rand.NextFloat() * 0.5f + 0.75f); } float x4 = Main.rgbToHsl(new Color(Main.DiscoR, 203, 103)).X; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), vector156, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, x4, (float)Projectile.whoAmI); - num31 = num1083; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), finalAttackPos, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, x4, (float)Projectile.whoAmI); + attackAmt = j; } return; } @@ -184,19 +183,19 @@ namespace CalamityMod.Projectiles.Summon public override bool PreDraw(ref Color lightColor) { - Color color25 = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); - Vector2 vector59 = Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; + Color colorArea = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); + Vector2 projPos = Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; Texture2D texture2D34 = ModContent.Request(Texture).Value; - Rectangle rectangle17 = texture2D34.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); - Color alpha5 = Projectile.GetAlpha(color25); - Vector2 origin11 = rectangle17.Size() / 2f; - float scaleFactor5 = (float)Math.Cos((double)(6.28318548f * (Projectile.localAI[0] / 60f))) + 3f + 3f; - for (float num286 = 0f; num286 < 4f; num286 += 1f) + Rectangle rectangular = texture2D34.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); + Color colorAlpha = Projectile.GetAlpha(colorArea); + Vector2 halfRectangle = rectangular.Size() / 2f; + float scaleFactor = (float)Math.Cos((double)(6.28318548f * (Projectile.localAI[0] / 60f))) + 3f + 3f; + for (float k = 0f; k < 4f; k += 1f) { SpriteBatch spritebatch = Main.spriteBatch; - double arg_F8BE_1 = (double)(num286 * MathHelper.PiOver2); + double arg_F8BE_1 = (double)(k * MathHelper.PiOver2); Vector2 center = default; - Main.EntitySpriteDraw(texture2D34, vector59 + Vector2.UnitY.RotatedBy(arg_F8BE_1, center) * scaleFactor5, new Microsoft.Xna.Framework.Rectangle?(rectangle17), alpha5 * 0.2f, Projectile.rotation, origin11, Projectile.scale, SpriteEffects.None, 0); + Main.EntitySpriteDraw(texture2D34, projPos + Vector2.UnitY.RotatedBy(arg_F8BE_1, center) * scaleFactor, new Microsoft.Xna.Framework.Rectangle?(rectangular), colorAlpha * 0.2f, Projectile.rotation, halfRectangle, Projectile.scale, SpriteEffects.None, 0); } return false; } diff --git a/Projectiles/Summon/SilvaCrystalExplosion.cs b/Projectiles/Summon/SilvaCrystalExplosion.cs index db14aa6d3b..07d00b3d43 100644 --- a/Projectiles/Summon/SilvaCrystalExplosion.cs +++ b/Projectiles/Summon/SilvaCrystalExplosion.cs @@ -3,6 +3,7 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Summon { public class SilvaCrystalExplosion : ModProjectile, ILocalizedModType @@ -28,15 +29,15 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { Color newColor2 = Main.hslToRgb(Projectile.ai[0], 1f, 0.5f); - int num978 = (int)Projectile.ai[1]; - if (num978 < 0 || num978 >= 1000 || (!Main.projectile[num978].active && Main.projectile[num978].type != ModContent.ProjectileType())) + int activeTimer = (int)Projectile.ai[1]; + if (activeTimer < 0 || activeTimer >= 1000 || (!Main.projectile[activeTimer].active && Main.projectile[activeTimer].type != ModContent.ProjectileType())) { Projectile.ai[1] = -1f; } else { DelegateMethods.v3_1 = newColor2.ToVector3() * 0.5f; - Utils.PlotTileLine(Projectile.Center, Main.projectile[num978].Center, 8f, DelegateMethods.CastLight); + Utils.PlotTileLine(Projectile.Center, Main.projectile[activeTimer].Center, 8f, DelegateMethods.CastLight); } if (Projectile.localAI[0] == 0f) { @@ -56,72 +57,72 @@ namespace CalamityMod.Projectiles.Summon { Lighting.AddLight(Projectile.Center, newColor2.ToVector3() * 0.5f); } - int num3; - for (int num979 = 0; num979 < 2; num979 = num3 + 1) + int dustCount; + for (int i = 0; i < 2; i = dustCount + 1) { if (Main.rand.NextBool(10)) { - Vector2 value55 = Vector2.UnitY.RotatedBy((double)((float)num979 * 3.14159274f), default).RotatedBy((double)Projectile.rotation, default); - Dust dust24 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 225, newColor2, 1.5f)]; - dust24.noGravity = true; - dust24.noLight = true; - dust24.scale = Projectile.Opacity * Projectile.localAI[0]; - dust24.position = Projectile.Center; - dust24.velocity = value55 * 2.5f; + Vector2 silvaDustVel = Vector2.UnitY.RotatedBy((double)((float)i * 3.14159274f), default).RotatedBy((double)Projectile.rotation, default); + Dust silvaDust = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 225, newColor2, 1.5f)]; + silvaDust.noGravity = true; + silvaDust.noLight = true; + silvaDust.scale = Projectile.Opacity * Projectile.localAI[0]; + silvaDust.position = Projectile.Center; + silvaDust.velocity = silvaDustVel * 2.5f; } - num3 = num979; + dustCount = i; } - for (int num980 = 0; num980 < 2; num980 = num3 + 1) + for (int j = 0; j < 2; j = dustCount + 1) { if (Main.rand.NextBool(10)) { - Vector2 value56 = Vector2.UnitY.RotatedBy((double)((float)num980 * 3.14159274f), default); - Dust dust25 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 225, newColor2, 1.5f)]; - dust25.noGravity = true; - dust25.noLight = true; - dust25.scale = Projectile.Opacity * Projectile.localAI[0]; - dust25.position = Projectile.Center; - dust25.velocity = value56 * 2.5f; + Vector2 silvaDustVel2 = Vector2.UnitY.RotatedBy((double)((float)j * 3.14159274f), default); + Dust silvaDust2 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 225, newColor2, 1.5f)]; + silvaDust2.noGravity = true; + silvaDust2.noLight = true; + silvaDust2.scale = Projectile.Opacity * Projectile.localAI[0]; + silvaDust2.position = Projectile.Center; + silvaDust2.velocity = silvaDustVel2 * 2.5f; } - num3 = num980; + dustCount = j; } if (Main.rand.NextBool(10)) { - float scaleFactor13 = 1f + Main.rand.NextFloat() * 2f; + float dustVelMod = 1f + Main.rand.NextFloat() * 2f; float fadeIn = 1f + Main.rand.NextFloat(); - float num981 = 1f + Main.rand.NextFloat(); - Vector2 vector136 = Utils.RandomVector2(Main.rand, -1f, 1f); - if (vector136 != Vector2.Zero) + float dustScale = 1f + Main.rand.NextFloat(); + Vector2 randVector = Utils.RandomVector2(Main.rand, -1f, 1f); + if (randVector != Vector2.Zero) { - vector136.Normalize(); + randVector.Normalize(); } - vector136 *= 20f + Main.rand.NextFloat() * 100f; - Vector2 vector137 = Projectile.Center + vector136; - Point point3 = vector137.ToTileCoordinates(); - bool flag52 = true; - if (!WorldGen.InWorld(point3.X, point3.Y, 0)) + randVector *= 20f + Main.rand.NextFloat() * 100f; + Vector2 dustPos = Projectile.Center + randVector; + Point dustCoords = dustPos.ToTileCoordinates(); + bool shouldSpawnDust = true; + if (!WorldGen.InWorld(dustCoords.X, dustCoords.Y, 0)) { - flag52 = false; + shouldSpawnDust = false; } - if (flag52 && WorldGen.SolidTile(point3.X, point3.Y)) + if (shouldSpawnDust && WorldGen.SolidTile(dustCoords.X, dustCoords.Y)) { - flag52 = false; + shouldSpawnDust = false; } - if (flag52) + if (shouldSpawnDust) { - Dust dust26 = Main.dust[Dust.NewDust(vector137, 0, 0, 267, 0f, 0f, 127, newColor2, 1f)]; - dust26.noGravity = true; - dust26.position = vector137; - dust26.velocity = -Vector2.UnitY * scaleFactor13 * (Main.rand.NextFloat() * 0.9f + 1.6f); - dust26.fadeIn = fadeIn; - dust26.scale = num981; - dust26.noLight = true; - Dust dust27 = Dust.CloneDust(dust26); - Dust dust = dust27; + Dust rainbowDust = Main.dust[Dust.NewDust(dustPos, 0, 0, 267, 0f, 0f, 127, newColor2, 1f)]; + rainbowDust.noGravity = true; + rainbowDust.position = dustPos; + rainbowDust.velocity = -Vector2.UnitY * dustVelMod * (Main.rand.NextFloat() * 0.9f + 1.6f); + rainbowDust.fadeIn = fadeIn; + rainbowDust.scale = dustScale; + rainbowDust.noLight = true; + Dust rainbowDust2 = Dust.CloneDust(rainbowDust); + Dust dust = rainbowDust2; dust.scale *= 0.65f; - dust = dust27; + dust = rainbowDust2; dust.fadeIn *= 0.65f; - dust27.color = new Color(255, 255, 255, 255); + rainbowDust2.color = new Color(255, 255, 255, 255); } } Projectile.scale = Projectile.Opacity / 2f * Projectile.localAI[0]; @@ -135,26 +136,26 @@ namespace CalamityMod.Projectiles.Summon public override bool PreDraw(ref Color lightColor) { - Color color25 = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); - Vector2 vector59 = Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; + Color colorArea = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); + Vector2 projPos = Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; Texture2D texture2D34 = ModContent.Request(Texture).Value; - Rectangle rectangle17 = texture2D34.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); - Color alpha5 = Projectile.GetAlpha(color25); - Vector2 origin11 = rectangle17.Size() / 2f; - Color color60 = Main.hslToRgb(Projectile.ai[0], 1f, 0.5f).MultiplyRGBA(new Color(255, 255, 255, 0)); - Main.EntitySpriteDraw(texture2D34, vector59, new Microsoft.Xna.Framework.Rectangle?(rectangle17), color60, Projectile.rotation, origin11, Projectile.scale * 2f, SpriteEffects.None, 0); - Main.EntitySpriteDraw(texture2D34, vector59, new Microsoft.Xna.Framework.Rectangle?(rectangle17), color60, 0f, origin11, Projectile.scale * 2f, SpriteEffects.None, 0); + Rectangle rectangular = texture2D34.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); + Color colorAlpha = Projectile.GetAlpha(colorArea); + Vector2 halfRectangle = rectangular.Size() / 2f; + Color projColor = Main.hslToRgb(Projectile.ai[0], 1f, 0.5f).MultiplyRGBA(new Color(255, 255, 255, 0)); + Main.EntitySpriteDraw(texture2D34, projPos, new Microsoft.Xna.Framework.Rectangle?(rectangular), projColor, Projectile.rotation, halfRectangle, Projectile.scale * 2f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(texture2D34, projPos, new Microsoft.Xna.Framework.Rectangle?(rectangular), projColor, 0f, halfRectangle, Projectile.scale * 2f, SpriteEffects.None, 0); if (Projectile.ai[1] != -1f && Projectile.Opacity > 0.3f) { - Vector2 vector61 = Main.projectile[(int)Projectile.ai[1]].Center - Projectile.Center; - Vector2 vector62 = new Vector2(1f, vector61.Length() / (float)texture2D34.Height); - float rotation27 = vector61.ToRotation() + 1.57079637f; - float num279 = MathHelper.Distance(15f, Projectile.localAI[1]) / 20f; - num279 = MathHelper.Clamp(num279, 0f, 1f); - if (num279 > 0f) + Vector2 projDirection = Main.projectile[(int)Projectile.ai[1]].Center - Projectile.Center; + Vector2 projDistance = new Vector2(1f, projDirection.Length() / (float)texture2D34.Height); + float drawRotation = projDirection.ToRotation() + 1.57079637f; + float colorClamp = MathHelper.Distance(15f, Projectile.localAI[1]) / 20f; + colorClamp = MathHelper.Clamp(colorClamp, 0f, 1f); + if (colorClamp > 0f) { - Main.EntitySpriteDraw(texture2D34, vector59 + vector61 / 2f, new Microsoft.Xna.Framework.Rectangle?(rectangle17), color60 * num279, rotation27, origin11, vector62, SpriteEffects.None, 0); - Main.EntitySpriteDraw(texture2D34, vector59 + vector61 / 2f, new Microsoft.Xna.Framework.Rectangle?(rectangle17), alpha5 * num279, rotation27, origin11, vector62 / 2f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(texture2D34, projPos + projDirection / 2f, new Microsoft.Xna.Framework.Rectangle?(rectangular), projColor * colorClamp, drawRotation, halfRectangle, projDistance, SpriteEffects.None, 0); + Main.EntitySpriteDraw(texture2D34, projPos + projDirection / 2f, new Microsoft.Xna.Framework.Rectangle?(rectangular), colorAlpha * colorClamp, drawRotation, halfRectangle, projDistance / 2f, SpriteEffects.None, 0); } } return false; @@ -163,51 +164,51 @@ namespace CalamityMod.Projectiles.Summon public override void OnKill(int timeLeft) { Vector2 spinningpoint = new Vector2(0f, -3f).RotatedByRandom(3.1415927410125732); - float num69 = (float)Main.rand.Next(7, 13); - Vector2 value5 = new Vector2(2.1f, 2f); + float rando = (float)Main.rand.Next(7, 13); + Vector2 dustVel = new Vector2(2.1f, 2f); Color newColor = Main.hslToRgb(Projectile.ai[0], 1f, 0.5f); newColor.A = 255; - float num72; - for (float num70 = 0f; num70 < num69; num70 = num72 + 1f) + float dustCount; + for (float i = 0f; i < rando; i = dustCount + 1f) { - int num71 = Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 0, newColor, 1f); - Main.dust[num71].position = Projectile.Center; - Main.dust[num71].velocity = spinningpoint.RotatedBy((double)(6.28318548f * num70 / num69), default) * value5 * (0.8f + Main.rand.NextFloat() * 0.4f); - Main.dust[num71].noGravity = true; - Main.dust[num71].scale = 2f; - Main.dust[num71].fadeIn = Main.rand.NextFloat() * 2f; - Dust dust11 = Dust.CloneDust(num71); - Dust dust = dust11; + int dustID = Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 0, newColor, 1f); + Main.dust[dustID].position = Projectile.Center; + Main.dust[dustID].velocity = spinningpoint.RotatedBy((double)(6.28318548f * i / rando), default) * dustVel * (0.8f + Main.rand.NextFloat() * 0.4f); + Main.dust[dustID].noGravity = true; + Main.dust[dustID].scale = 2f; + Main.dust[dustID].fadeIn = Main.rand.NextFloat() * 2f; + Dust dustCloning = Dust.CloneDust(dustID); + Dust dust = dustCloning; dust.scale /= 2f; - dust = dust11; + dust = dustCloning; dust.fadeIn /= 2f; - dust11.color = new Color(255, 255, 255, 255); - num72 = num70; + dustCloning.color = new Color(255, 255, 255, 255); + dustCount = i; } - for (float num73 = 0f; num73 < num69; num73 = num72 + 1f) + for (float j = 0f; j < rando; j = dustCount + 1f) { - int num74 = Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 0, newColor, 1f); - Main.dust[num74].position = Projectile.Center; - Main.dust[num74].velocity = spinningpoint.RotatedBy((double)(6.28318548f * num73 / num69), default) * value5 * (0.8f + Main.rand.NextFloat() * 0.4f); - Dust dust = Main.dust[num74]; + int dustID = Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 0, newColor, 1f); + Main.dust[dustID].position = Projectile.Center; + Main.dust[dustID].velocity = spinningpoint.RotatedBy((double)(6.28318548f * j / rando), default) * dustVel * (0.8f + Main.rand.NextFloat() * 0.4f); + Dust dust = Main.dust[dustID]; dust.velocity *= Main.rand.NextFloat() * 0.8f; - Main.dust[num74].noGravity = true; - Main.dust[num74].scale = Main.rand.NextFloat() * 1f; - Main.dust[num74].fadeIn = Main.rand.NextFloat() * 2f; - Dust dust12 = Dust.CloneDust(num74); - dust = dust12; + Main.dust[dustID].noGravity = true; + Main.dust[dustID].scale = Main.rand.NextFloat() * 1f; + Main.dust[dustID].fadeIn = Main.rand.NextFloat() * 2f; + Dust dustCloning2 = Dust.CloneDust(dustID); + dust = dustCloning2; dust.scale /= 2f; - dust = dust12; + dust = dustCloning2; dust.fadeIn /= 2f; - dust12.color = new Color(255, 255, 255, 255); - num72 = num73; + dustCloning2.color = new Color(255, 255, 255, 255); + dustCount = j; } if (Main.myPlayer == Projectile.owner) { Projectile.friendly = true; int width = Projectile.width; int height2 = Projectile.height; - int num75 = Projectile.penetrate; + int penetrateClone = Projectile.penetrate; Projectile.position = Projectile.Center; Projectile.width = Projectile.height = 60; Projectile.Center = Projectile.position; @@ -216,7 +217,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; Projectile.Damage(); - Projectile.penetrate = num75; + Projectile.penetrate = penetrateClone; Projectile.position = Projectile.Center; Projectile.width = width; Projectile.height = height2; diff --git a/Projectiles/Summon/SiriusBeam.cs b/Projectiles/Summon/SiriusBeam.cs index bc70c1c24b..a8e1925172 100644 --- a/Projectiles/Summon/SiriusBeam.cs +++ b/Projectiles/Summon/SiriusBeam.cs @@ -35,11 +35,11 @@ namespace CalamityMod.Projectiles.Summon { for (int d = 0; d < 4; d++) { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * (d * 0.25f); + Vector2 projPos = Projectile.position; + projPos -= Projectile.velocity * (d * 0.25f); Projectile.alpha = 255; - int trailDust = Dust.NewDust(vector33, 1, 1, 20, 0f, 0f, 0, default, 1f); - Main.dust[trailDust].position = vector33; + int trailDust = Dust.NewDust(projPos, 1, 1, 20, 0f, 0f, 0, default, 1f); + Main.dust[trailDust].position = projPos; Main.dust[trailDust].scale = Main.rand.Next(70, 110) * 0.013f; Main.dust[trailDust].velocity *= 0.2f; Main.dust[trailDust].noGravity = true; diff --git a/Projectiles/Summon/SiriusExplosion.cs b/Projectiles/Summon/SiriusExplosion.cs index 9e3781b7e3..368594ac2a 100644 --- a/Projectiles/Summon/SiriusExplosion.cs +++ b/Projectiles/Summon/SiriusExplosion.cs @@ -29,15 +29,15 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { Color newColor2 = Main.hslToRgb(0.5f, 1f, Projectile.ai[0]); - int num978 = (int)Projectile.ai[1]; - if (num978 < 0 || num978 >= 1000 || (!Main.projectile[num978].active && Main.projectile[num978].type != ModContent.ProjectileType())) + int activeTimer = (int)Projectile.ai[1]; + if (activeTimer < 0 || activeTimer >= 1000 || (!Main.projectile[activeTimer].active && Main.projectile[activeTimer].type != ModContent.ProjectileType())) { Projectile.ai[1] = -1f; } else { DelegateMethods.v3_1 = newColor2.ToVector3() * 0.5f; - Utils.PlotTileLine(Projectile.Center, Main.projectile[num978].Center, 8f, DelegateMethods.CastLight); + Utils.PlotTileLine(Projectile.Center, Main.projectile[activeTimer].Center, 8f, DelegateMethods.CastLight); } if (Projectile.localAI[0] == 0f) { @@ -57,72 +57,72 @@ namespace CalamityMod.Projectiles.Summon { Lighting.AddLight(Projectile.Center, newColor2.ToVector3() * 0.5f); } - int num3; - for (int num979 = 0; num979 < 2; num979 = num3 + 1) + int dustCount; + for (int i = 0; i < 2; i = dustCount + 1) { if (Main.rand.NextBool(10)) { - Vector2 value55 = Vector2.UnitY.RotatedBy((double)((float)num979 * 3.14159274f), default).RotatedBy((double)Projectile.rotation, default); - Dust dust24 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 225, newColor2, 1.5f)]; - dust24.noGravity = true; - dust24.noLight = true; - dust24.scale = Projectile.Opacity * Projectile.localAI[0]; - dust24.position = Projectile.Center; - dust24.velocity = value55 * 2.5f; + Vector2 siriusDustVel = Vector2.UnitY.RotatedBy((double)((float)i * 3.14159274f), default).RotatedBy((double)Projectile.rotation, default); + Dust siriusDust = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 225, newColor2, 1.5f)]; + siriusDust.noGravity = true; + siriusDust.noLight = true; + siriusDust.scale = Projectile.Opacity * Projectile.localAI[0]; + siriusDust.position = Projectile.Center; + siriusDust.velocity = siriusDustVel * 2.5f; } - num3 = num979; + dustCount = i; } - for (int num980 = 0; num980 < 2; num980 = num3 + 1) + for (int j = 0; j < 2; j = dustCount + 1) { if (Main.rand.NextBool(10)) { - Vector2 value56 = Vector2.UnitY.RotatedBy((double)((float)num980 * 3.14159274f), default); - Dust dust25 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 225, newColor2, 1.5f)]; - dust25.noGravity = true; - dust25.noLight = true; - dust25.scale = Projectile.Opacity * Projectile.localAI[0]; - dust25.position = Projectile.Center; - dust25.velocity = value56 * 2.5f; + Vector2 siriusDustVel2 = Vector2.UnitY.RotatedBy((double)((float)j * 3.14159274f), default); + Dust siriusDust2 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 225, newColor2, 1.5f)]; + siriusDust2.noGravity = true; + siriusDust2.noLight = true; + siriusDust2.scale = Projectile.Opacity * Projectile.localAI[0]; + siriusDust2.position = Projectile.Center; + siriusDust2.velocity = siriusDustVel2 * 2.5f; } - num3 = num980; + dustCount = j; } if (Main.rand.NextBool(10)) { - float scaleFactor13 = 1f + Main.rand.NextFloat() * 2f; + float dustVelMod = 1f + Main.rand.NextFloat() * 2f; float fadeIn = 1f + Main.rand.NextFloat(); - float num981 = 1f + Main.rand.NextFloat(); - Vector2 vector136 = Utils.RandomVector2(Main.rand, -1f, 1f); - if (vector136 != Vector2.Zero) + float dustScale = 1f + Main.rand.NextFloat(); + Vector2 randVector = Utils.RandomVector2(Main.rand, -1f, 1f); + if (randVector != Vector2.Zero) { - vector136.Normalize(); + randVector.Normalize(); } - vector136 *= 20f + Main.rand.NextFloat() * 100f; - Vector2 vector137 = Projectile.Center + vector136; - Point point3 = vector137.ToTileCoordinates(); - bool flag52 = true; - if (!WorldGen.InWorld(point3.X, point3.Y, 0)) + randVector *= 20f + Main.rand.NextFloat() * 100f; + Vector2 dustPos = Projectile.Center + randVector; + Point dustCoords = dustPos.ToTileCoordinates(); + bool shouldSpawnDust = true; + if (!WorldGen.InWorld(dustCoords.X, dustCoords.Y, 0)) { - flag52 = false; + shouldSpawnDust = false; } - if (flag52 && WorldGen.SolidTile(point3.X, point3.Y)) + if (shouldSpawnDust && WorldGen.SolidTile(dustCoords.X, dustCoords.Y)) { - flag52 = false; + shouldSpawnDust = false; } - if (flag52) + if (shouldSpawnDust) { - Dust dust26 = Main.dust[Dust.NewDust(vector137, 0, 0, 267, 0f, 0f, 127, newColor2, 1f)]; - dust26.noGravity = true; - dust26.position = vector137; - dust26.velocity = -Vector2.UnitY * scaleFactor13 * (Main.rand.NextFloat() * 0.9f + 1.6f); - dust26.fadeIn = fadeIn; - dust26.scale = num981; - dust26.noLight = true; - Dust dust27 = Dust.CloneDust(dust26); - Dust dust = dust27; + Dust starDust = Main.dust[Dust.NewDust(dustPos, 0, 0, 267, 0f, 0f, 127, newColor2, 1f)]; + starDust.noGravity = true; + starDust.position = dustPos; + starDust.velocity = -Vector2.UnitY * dustVelMod * (Main.rand.NextFloat() * 0.9f + 1.6f); + starDust.fadeIn = fadeIn; + starDust.scale = dustScale; + starDust.noLight = true; + Dust starDust2 = Dust.CloneDust(starDust); + Dust dust = starDust2; dust.scale *= 0.65f; - dust = dust27; + dust = starDust2; dust.fadeIn *= 0.65f; - dust27.color = new Color(255, 255, 255, 255); + starDust2.color = new Color(255, 255, 255, 255); } } Projectile.scale = Projectile.Opacity / 2f * Projectile.localAI[0]; @@ -137,26 +137,26 @@ namespace CalamityMod.Projectiles.Summon public override bool PreDraw(ref Color lightColor) { - Color color25 = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); - Vector2 vector59 = Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; + Color colorArea = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); + Vector2 projPos = Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; Texture2D texture2D34 = ModContent.Request(Texture).Value; - Rectangle rectangle17 = texture2D34.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); - Color alpha5 = Projectile.GetAlpha(color25); - Vector2 origin11 = rectangle17.Size() / 2f; - Color color60 = Main.hslToRgb(0.5f, 1f, Projectile.ai[0]).MultiplyRGBA(new Color(255, 255, 255, 0)); - Main.EntitySpriteDraw(texture2D34, vector59, new Microsoft.Xna.Framework.Rectangle?(rectangle17), color60, Projectile.rotation, origin11, Projectile.scale * 2f, SpriteEffects.None, 0); - Main.EntitySpriteDraw(texture2D34, vector59, new Microsoft.Xna.Framework.Rectangle?(rectangle17), color60, 0f, origin11, Projectile.scale * 2f, SpriteEffects.None, 0); + Rectangle rectangular = texture2D34.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); + Color colorAlpha = Projectile.GetAlpha(colorArea); + Vector2 halfRectangle = rectangular.Size() / 2f; + Color projColor = Main.hslToRgb(0.5f, 1f, Projectile.ai[0]).MultiplyRGBA(new Color(255, 255, 255, 0)); + Main.EntitySpriteDraw(texture2D34, projPos, new Microsoft.Xna.Framework.Rectangle?(rectangular), projColor, Projectile.rotation, halfRectangle, Projectile.scale * 2f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(texture2D34, projPos, new Microsoft.Xna.Framework.Rectangle?(rectangular), projColor, 0f, halfRectangle, Projectile.scale * 2f, SpriteEffects.None, 0); if (Projectile.ai[1] != -1f && Projectile.Opacity > 0.3f) { - Vector2 vector61 = Main.projectile[(int)Projectile.ai[1]].Center - Projectile.Center; - Vector2 vector62 = new Vector2(1f, vector61.Length() / (float)texture2D34.Height); - float rotation27 = vector61.ToRotation() + 1.57079637f; - float num279 = MathHelper.Distance(30f, Projectile.localAI[1]) / 20f; - num279 = MathHelper.Clamp(num279, 0f, 1f); - if (num279 > 0f) + Vector2 projDirection = Main.projectile[(int)Projectile.ai[1]].Center - Projectile.Center; + Vector2 projDistance = new Vector2(1f, projDirection.Length() / (float)texture2D34.Height); + float drawRotation = projDirection.ToRotation() + 1.57079637f; + float colorClamp = MathHelper.Distance(30f, Projectile.localAI[1]) / 20f; + colorClamp = MathHelper.Clamp(colorClamp, 0f, 1f); + if (colorClamp > 0f) { - Main.EntitySpriteDraw(texture2D34, vector59 + vector61 / 2f, new Microsoft.Xna.Framework.Rectangle?(rectangle17), color60 * num279, rotation27, origin11, vector62, SpriteEffects.None, 0); - Main.EntitySpriteDraw(texture2D34, vector59 + vector61 / 2f, new Microsoft.Xna.Framework.Rectangle?(rectangle17), alpha5 * num279, rotation27, origin11, vector62 / 2f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(texture2D34, projPos + projDirection / 2f, new Microsoft.Xna.Framework.Rectangle?(rectangular), projColor * colorClamp, drawRotation, halfRectangle, projDistance, SpriteEffects.None, 0); + Main.EntitySpriteDraw(texture2D34, projPos + projDirection / 2f, new Microsoft.Xna.Framework.Rectangle?(rectangular), colorAlpha * colorClamp, drawRotation, halfRectangle, projDistance / 2f, SpriteEffects.None, 0); } } return false; @@ -165,51 +165,51 @@ namespace CalamityMod.Projectiles.Summon public override void OnKill(int timeLeft) { Vector2 spinningpoint = new Vector2(0f, -3f).RotatedByRandom(3.1415927410125732); - float num69 = (float)Main.rand.Next(7, 13); - Vector2 value5 = new Vector2(2.1f, 2f); + float rando = (float)Main.rand.Next(7, 13); + Vector2 dustVel = new Vector2(2.1f, 2f); Color newColor = Main.hslToRgb(0.5f, 1f, Projectile.ai[0]); newColor.A = 255; - float num72; - for (float num70 = 0f; num70 < num69; num70 = num72 + 1f) + float dustCount; + for (float i = 0f; i < rando; i = dustCount + 1f) { - int num71 = Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 0, newColor, 1f); - Main.dust[num71].position = Projectile.Center; - Main.dust[num71].velocity = spinningpoint.RotatedBy((double)(6.28318548f * num70 / num69), default) * value5 * (0.8f + Main.rand.NextFloat() * 0.4f); - Main.dust[num71].noGravity = true; - Main.dust[num71].scale = 2f; - Main.dust[num71].fadeIn = Main.rand.NextFloat() * 2f; - Dust dust11 = Dust.CloneDust(num71); + int dusty = Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 0, newColor, 1f); + Main.dust[dusty].position = Projectile.Center; + Main.dust[dusty].velocity = spinningpoint.RotatedBy((double)(6.28318548f * i / rando), default) * dustVel * (0.8f + Main.rand.NextFloat() * 0.4f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].scale = 2f; + Main.dust[dusty].fadeIn = Main.rand.NextFloat() * 2f; + Dust dust11 = Dust.CloneDust(dusty); Dust dust = dust11; dust.scale /= 2f; dust = dust11; dust.fadeIn /= 2f; dust11.color = new Color(255, 255, 255, 255); - num72 = num70; + dustCount = i; } - for (float num73 = 0f; num73 < num69; num73 = num72 + 1f) + for (float j = 0f; j < rando; j = dustCount + 1f) { - int num74 = Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 0, newColor, 1f); - Main.dust[num74].position = Projectile.Center; - Main.dust[num74].velocity = spinningpoint.RotatedBy((double)(6.28318548f * num73 / num69), default) * value5 * (0.8f + Main.rand.NextFloat() * 0.4f); - Dust dust = Main.dust[num74]; + int dusty2 = Dust.NewDust(Projectile.Center, 0, 0, 267, 0f, 0f, 0, newColor, 1f); + Main.dust[dusty2].position = Projectile.Center; + Main.dust[dusty2].velocity = spinningpoint.RotatedBy((double)(6.28318548f * j / rando), default) * dustVel * (0.8f + Main.rand.NextFloat() * 0.4f); + Dust dust = Main.dust[dusty2]; dust.velocity *= Main.rand.NextFloat() * 0.8f; - Main.dust[num74].noGravity = true; - Main.dust[num74].scale = Main.rand.NextFloat() * 1f; - Main.dust[num74].fadeIn = Main.rand.NextFloat() * 2f; - Dust dust12 = Dust.CloneDust(num74); + Main.dust[dusty2].noGravity = true; + Main.dust[dusty2].scale = Main.rand.NextFloat() * 1f; + Main.dust[dusty2].fadeIn = Main.rand.NextFloat() * 2f; + Dust dust12 = Dust.CloneDust(dusty2); dust = dust12; dust.scale /= 2f; dust = dust12; dust.fadeIn /= 2f; dust12.color = new Color(255, 255, 255, 255); - num72 = num73; + dustCount = j; } if (Main.myPlayer == Projectile.owner) { Projectile.friendly = true; int width = Projectile.width; int height2 = Projectile.height; - int num75 = Projectile.penetrate; + int penetrateClone = Projectile.penetrate; Projectile.position = Projectile.Center; Projectile.width = Projectile.height = 60; Projectile.Center = Projectile.position; @@ -218,7 +218,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; Projectile.Damage(); - Projectile.penetrate = num75; + Projectile.penetrate = penetrateClone; Projectile.position = Projectile.Center; Projectile.width = width; Projectile.height = height2; diff --git a/Projectiles/Summon/SolarBeam.cs b/Projectiles/Summon/SolarBeam.cs index 95fb7570c0..96d9be1691 100644 --- a/Projectiles/Summon/SolarBeam.cs +++ b/Projectiles/Summon/SolarBeam.cs @@ -29,15 +29,15 @@ namespace CalamityMod.Projectiles.Summon Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 9f) { - for (int num447 = 0; num447 < 4; num447++) + for (int i = 0; i < 4; i++) { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * ((float)num447 * 0.25f); + Vector2 dustPos = Projectile.position; + dustPos -= Projectile.velocity * ((float)i * 0.25f); Projectile.alpha = 255; - int num448 = Dust.NewDust(vector33, 1, 1, 246, 0f, 0f, 0, default, 1f); - Main.dust[num448].position = vector33; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.2f; + int dust = Dust.NewDust(dustPos, 1, 1, 246, 0f, 0f, 0, default, 1f); + Main.dust[dust].position = dustPos; + Main.dust[dust].scale = (float)Main.rand.Next(70, 110) * 0.013f; + Main.dust[dust].velocity *= 0.2f; } } } diff --git a/Projectiles/Summon/Valkyrie.cs b/Projectiles/Summon/Valkyrie.cs index 8f78fa731d..a26695514e 100644 --- a/Projectiles/Summon/Valkyrie.cs +++ b/Projectiles/Summon/Valkyrie.cs @@ -59,12 +59,11 @@ namespace CalamityMod.Projectiles.Summon } if (Projectile.localAI[0] == 0f) { - int num501 = 30; - for (int num502 = 0; num502 < num501; num502++) + for (int i = 0; i < 30; i++) { - int num503 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, 59, 0f, 0f, 0, default, 1f); - Main.dust[num503].velocity *= 2f; - Main.dust[num503].scale *= 1.15f; + int spawnDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, 59, 0f, 0f, 0, default, 1f); + Main.dust[spawnDust].velocity *= 2f; + Main.dust[spawnDust].scale *= 1.15f; } Projectile.localAI[0] += 1f; } @@ -99,9 +98,9 @@ namespace CalamityMod.Projectiles.Summon { SpriteEffects spriteEffects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, spriteEffects, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, spriteEffects, 0); return false; } } diff --git a/Projectiles/Summon/VileFeederProjectile.cs b/Projectiles/Summon/VileFeederProjectile.cs index a7b8074c9c..bc93e881e2 100644 --- a/Projectiles/Summon/VileFeederProjectile.cs +++ b/Projectiles/Summon/VileFeederProjectile.cs @@ -51,23 +51,23 @@ namespace CalamityMod.Projectiles.Summon { Projectile.frame = 0; } - for (int num369 = 0; num369 < 1; num369++) + for (int i = 0; i < 1; i++) { int dustType = 7; - float num370 = Projectile.velocity.X / 3f * (float)num369; - float num371 = Projectile.velocity.Y / 3f * (float)num369; - int num372 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num372]; - dust.position.X = Projectile.Center.X - num370; - dust.position.Y = Projectile.Center.Y - num371; + float smallXVel = Projectile.velocity.X / 3f * (float)i; + float smallYVel = Projectile.velocity.Y / 3f * (float)i; + int dusty = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[dusty]; + dust.position.X = Projectile.Center.X - smallXVel; + dust.position.Y = Projectile.Center.Y - smallYVel; dust.velocity *= 0f; dust.scale = 0.5f; } Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) - MathHelper.PiOver2; - float num373 = Projectile.position.X; - float num374 = Projectile.position.Y; - float num375 = 100000f; - bool flag10 = false; + float projX = Projectile.position.X; + float projY = Projectile.position.Y; + float attackDistance = 100000f; + bool canAttack = false; Projectile.ai[0] += 1f; if (Projectile.ai[0] > 30f) { @@ -76,83 +76,83 @@ namespace CalamityMod.Projectiles.Summon NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(Projectile, false)) { - float num377 = npc.position.X + (float)(npc.width / 2); - float num378 = npc.position.Y + (float)(npc.height / 2); - float num379 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num377) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num378); - if (num379 < 640f && num379 < num375 && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) + float npcX = npc.position.X + (float)(npc.width / 2); + float npcY = npc.position.Y + (float)(npc.height / 2); + float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); + if (npcDist < 640f && npcDist < attackDistance && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) { - num375 = num379; - num373 = num377; - num374 = num378; - flag10 = true; + attackDistance = npcDist; + projX = npcX; + projY = npcY; + canAttack = true; } } } - if (!flag10) + if (!canAttack) { - for (int num376 = 0; num376 < Main.maxNPCs; num376++) + for (int j = 0; j < Main.maxNPCs; j++) { - NPC npc = Main.npc[num376]; + NPC npc = Main.npc[j]; if (npc.CanBeChasedBy(Projectile, false)) { - float num377 = npc.position.X + (float)(npc.width / 2); - float num378 = npc.position.Y + (float)(npc.height / 2); - float num379 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num377) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num378); - if (num379 < 640f && num379 < num375 && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) + float npcX = npc.position.X + (float)(npc.width / 2); + float npcY = npc.position.Y + (float)(npc.height / 2); + float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); + if (npcDist < 640f && npcDist < attackDistance && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) { - num375 = num379; - num373 = num377; - num374 = num378; - flag10 = true; + attackDistance = npcDist; + projX = npcX; + projY = npcY; + canAttack = true; } } } } } - if (!flag10) + if (!canAttack) { - num373 = Projectile.position.X + (float)(Projectile.width / 2) + Projectile.velocity.X * 100f; - num374 = Projectile.position.Y + (float)(Projectile.height / 2) + Projectile.velocity.Y * 100f; + projX = Projectile.position.X + (float)(Projectile.width / 2) + Projectile.velocity.X * 100f; + projY = Projectile.position.Y + (float)(Projectile.height / 2) + Projectile.velocity.Y * 100f; } - float num380 = 10f; - float num381 = 0.16f; - Vector2 vector30 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num382 = num373 - vector30.X; - float num383 = num374 - vector30.Y; - float num384 = (float)Math.Sqrt((double)(num382 * num382 + num383 * num383)); - num384 = num380 / num384; - num382 *= num384; - num383 *= num384; - if (Projectile.velocity.X < num382) + float projSpeed = 10f; + float XSpeedMod = 0.16f; + Vector2 fireDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float fireXVel = projX - fireDirection.X; + float fireYVel = projY - fireDirection.Y; + float fireVelocity = (float)Math.Sqrt((double)(fireXVel * fireXVel + fireYVel * fireYVel)); + fireVelocity = projSpeed / fireVelocity; + fireXVel *= fireVelocity; + fireYVel *= fireVelocity; + if (Projectile.velocity.X < fireXVel) { - Projectile.velocity.X = Projectile.velocity.X + num381; - if (Projectile.velocity.X < 0f && num382 > 0f) + Projectile.velocity.X = Projectile.velocity.X + XSpeedMod; + if (Projectile.velocity.X < 0f && fireXVel > 0f) { - Projectile.velocity.X = Projectile.velocity.X + num381 * 2f; + Projectile.velocity.X = Projectile.velocity.X + XSpeedMod * 2f; } } - else if (Projectile.velocity.X > num382) + else if (Projectile.velocity.X > fireXVel) { - Projectile.velocity.X = Projectile.velocity.X - num381; - if (Projectile.velocity.X > 0f && num382 < 0f) + Projectile.velocity.X = Projectile.velocity.X - XSpeedMod; + if (Projectile.velocity.X > 0f && fireXVel < 0f) { - Projectile.velocity.X = Projectile.velocity.X - num381 * 2f; + Projectile.velocity.X = Projectile.velocity.X - XSpeedMod * 2f; } } - if (Projectile.velocity.Y < num383) + if (Projectile.velocity.Y < fireYVel) { - Projectile.velocity.Y = Projectile.velocity.Y + num381; - if (Projectile.velocity.Y < 0f && num383 > 0f) + Projectile.velocity.Y = Projectile.velocity.Y + XSpeedMod; + if (Projectile.velocity.Y < 0f && fireYVel > 0f) { - Projectile.velocity.Y = Projectile.velocity.Y + num381 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y + XSpeedMod * 2f; } } - else if (Projectile.velocity.Y > num383) + else if (Projectile.velocity.Y > fireYVel) { - Projectile.velocity.Y = Projectile.velocity.Y - num381; - if (Projectile.velocity.Y > 0f && num383 < 0f) + Projectile.velocity.Y = Projectile.velocity.Y - XSpeedMod; + if (Projectile.velocity.Y > 0f && fireYVel < 0f) { - Projectile.velocity.Y = Projectile.velocity.Y - num381 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y - XSpeedMod * 2f; } } } diff --git a/Projectiles/Summon/VileFeederSummon.cs b/Projectiles/Summon/VileFeederSummon.cs index 9b61c2efdb..92b93bf355 100644 --- a/Projectiles/Summon/VileFeederSummon.cs +++ b/Projectiles/Summon/VileFeederSummon.cs @@ -1,8 +1,8 @@ -using CalamityMod.CalPlayer; +using System.IO; using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -63,9 +63,9 @@ namespace CalamityMod.Projectiles.Summon Vector2 source = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; source = source.RotatedBy((double)((float)(d - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + Projectile.Center; Vector2 dustVel = source - Projectile.Center; - int num228 = Dust.NewDust(source + dustVel, 0, 0, 7, dustVel.X * 1.75f, dustVel.Y * 1.75f, 100, default, 1.1f); - Main.dust[num228].noGravity = true; - Main.dust[num228].velocity = dustVel; + int dusty = Dust.NewDust(source + dustVel, 0, 0, 7, dustVel.X * 1.75f, dustVel.Y * 1.75f, 100, default, 1.1f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].velocity = dustVel; } spawnDust = false; } @@ -233,15 +233,15 @@ namespace CalamityMod.Projectiles.Summon } if (projCount >= array2.Length) { - int num30 = 0; + projCount = 0; for (int m = 1; m < array2.Length; m++) { - if (array2[m].Y < array2[num30].Y) + if (array2[m].Y < array2[projCount].Y) { - num30 = m; + projCount = m; } } - Main.projectile[array2[num30].X].Kill(); + Main.projectile[array2[projCount].X].Kill(); } } } @@ -262,9 +262,9 @@ namespace CalamityMod.Projectiles.Summon public override bool PreDraw(ref Color lightColor) { Texture2D texture = ModContent.Request(Texture).Value; - int num214 = texture.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = texture.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } diff --git a/Projectiles/Summon/VoidConcentrationBlackhole.cs b/Projectiles/Summon/VoidConcentrationBlackhole.cs index 5f1c294cb9..058c45b90f 100644 --- a/Projectiles/Summon/VoidConcentrationBlackhole.cs +++ b/Projectiles/Summon/VoidConcentrationBlackhole.cs @@ -54,20 +54,20 @@ namespace CalamityMod.Projectiles.Summon Vector2 velocity = Projectile.Center - npc.Center; velocity *= 2f; velocity.SafeNormalize(Vector2.Zero); - float num550 = 5f * Projectile.scale; - Vector2 vector43 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num551 = Projectile.Center.X - vector43.X; - float num552 = Projectile.Center.Y - vector43.Y; - float num553 = (float)Math.Sqrt((double)(num551 * num551 + num552 * num552)); - if (num553 < 100f) + float projSpeed = 5f * Projectile.scale; + Vector2 fireDirection = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float fireXVel = Projectile.Center.X - fireDirection.X; + float fireYVel = Projectile.Center.Y - fireDirection.Y; + float fireVelocity = (float)Math.Sqrt((double)(fireXVel * fireXVel + fireYVel * fireYVel)); + if (fireVelocity < 100f) { - num550 = 28f; //14 + projSpeed = 28f; //14 } - num553 = num550 / num553; - num551 *= num553; - num552 *= num553; - npc.velocity.X = (velocity.X * 15f + num551) / 16f; - npc.velocity.Y = (velocity.Y * 15f + num552) / 16f; + fireVelocity = projSpeed / fireVelocity; + fireXVel *= fireVelocity; + fireYVel *= fireVelocity; + npc.velocity.X = (velocity.X * 15f + fireXVel) / 16f; + npc.velocity.Y = (velocity.Y * 15f + fireYVel) / 16f; npc.velocity = (velocity / succStrength); } diff --git a/Projectiles/Summon/VoidConcentrationOrb.cs b/Projectiles/Summon/VoidConcentrationOrb.cs index c7491c846d..6d0e1a5a03 100644 --- a/Projectiles/Summon/VoidConcentrationOrb.cs +++ b/Projectiles/Summon/VoidConcentrationOrb.cs @@ -69,20 +69,20 @@ namespace CalamityMod.Projectiles.Summon { if (target != null) { - float num550 = 40f; - Vector2 vector43 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num551 = target.Center.X - vector43.X; - float num552 = target.Center.Y - vector43.Y; - float num553 = (float)Math.Sqrt((double)(num551 * num551 + num552 * num552)); - if (num553 < 100f) + float projSpeed = 40f; + Vector2 fireDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float fireXVel = target.Center.X - fireDirection.X; + float fireYVel = target.Center.Y - fireDirection.Y; + float fireVelocity = (float)Math.Sqrt((double)(fireXVel * fireXVel + fireYVel * fireYVel)); + if (fireVelocity < 100f) { - num550 = 28f; //14 + projSpeed = 28f; //14 } - num553 = num550 / num553; - num551 *= num553; - num552 *= num553; - Projectile.velocity.X = (Projectile.velocity.X * 25f + num551) / 26f; - Projectile.velocity.Y = (Projectile.velocity.Y * 25f + num552) / 26f; + fireVelocity = projSpeed / fireVelocity; + fireXVel *= fireVelocity; + fireYVel *= fireVelocity; + Projectile.velocity.X = (Projectile.velocity.X * 25f + fireXVel) / 26f; + Projectile.velocity.Y = (Projectile.velocity.Y * 25f + fireYVel) / 26f; if (Main.rand.NextBool(5)) Projectile.velocity *= 1.1f; } diff --git a/Projectiles/Summon/WaterElementalMinion.cs b/Projectiles/Summon/WaterElementalMinion.cs index fca691fcc0..1e3faffa33 100644 --- a/Projectiles/Summon/WaterElementalMinion.cs +++ b/Projectiles/Summon/WaterElementalMinion.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isMinion = Projectile.type == ModContent.ProjectileType(); Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); if (!modPlayer.sirenWaifu && !modPlayer.allWaifus && !modPlayer.sirenWaifuVanity && !modPlayer.allWaifusVanity) @@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.active = false; return; } - if (flag64) + if (isMinion) { if (player.dead) { @@ -58,12 +58,11 @@ namespace CalamityMod.Projectiles.Summon } if (dust > 0) { - int num501 = 50; - for (int num502 = 0; num502 < num501; num502++) + for (int i = 0; i < 50; i++) { - int num503 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, 33, 0f, 0f, 0, default, 1f); - Main.dust[num503].velocity *= 2f; - Main.dust[num503].scale *= 1.15f; + int spawnDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, 33, 0f, 0f, 0, default, 1f); + Main.dust[spawnDust].velocity *= 2f; + Main.dust[spawnDust].scale *= 1.15f; } dust--; } @@ -104,52 +103,52 @@ namespace CalamityMod.Projectiles.Summon Projectile.ai[0] -= 1f; return; } - bool flag18 = false; - float num506 = Projectile.Center.X; - float num507 = Projectile.Center.Y; - float num508 = 1000f; + bool canAttack = false; + float projX = Projectile.Center.X; + float projY = Projectile.Center.Y; + float attackRange = 1000f; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(Projectile, false)) { - float num539 = npc.position.X + (float)(npc.width / 2); - float num540 = npc.position.Y + (float)(npc.height / 2); - float num541 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num539) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num540); - if (num541 < num508 && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) + float npcX = npc.position.X + (float)(npc.width / 2); + float npcY = npc.position.Y + (float)(npc.height / 2); + float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); + if (npcDist < attackRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) { - num506 = num539; - num507 = num540; - flag18 = true; + projX = npcX; + projY = npcY; + canAttack = true; } } } - if (!flag18) + if (!canAttack) { - for (int num512 = 0; num512 < Main.maxNPCs; num512++) + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num512].CanBeChasedBy(Projectile, false)) + if (Main.npc[i].CanBeChasedBy(Projectile, false)) { - float num513 = Main.npc[num512].position.X + (float)(Main.npc[num512].width / 2); - float num514 = Main.npc[num512].position.Y + (float)(Main.npc[num512].height / 2); - float num515 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - num513) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - num514); - if (num515 < num508 && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[num512].position, Main.npc[num512].width, Main.npc[num512].height)) + float targetX = Main.npc[i].position.X + (float)(Main.npc[i].width / 2); + float targetY = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2); + float targetDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - targetX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - targetY); + if (targetDist < attackRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height)) { - num508 = num515; - num506 = num513; - num507 = num514; - flag18 = true; + attackRange = targetDist; + projX = targetX; + projY = targetY; + canAttack = true; } } } } - if (flag18 && Projectile.localAI[0] >= 120f) + if (canAttack && Projectile.localAI[0] >= 120f) { - float num516 = num506; - float num517 = num507; - num506 -= Projectile.Center.X; - num507 -= Projectile.Center.Y; - if (num506 < 0f) + float projXStore = projX; + float projYStore = projY; + projX -= Projectile.Center.X; + projY -= Projectile.Center.Y; + if (projX < 0f) { Projectile.spriteDirection = 1; } @@ -166,15 +165,15 @@ namespace CalamityMod.Projectiles.Summon { projectileType = ModContent.ProjectileType(); } - float num403 = Main.rand.Next(12, 20); - Vector2 vector29 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); - float num404 = num516 - vector29.X; - float num405 = num517 - vector29.Y; - float num406 = (float)Math.Sqrt((double)(num404 * num404 + num405 * num405)); - num406 = num403 / num406; - num404 *= num406; - num405 *= num406; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X - 4f, Projectile.Center.Y, num404, num405, projectileType, Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); + float projVel = Main.rand.Next(12, 20); + Vector2 fireDirection = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float fireXVel = projXStore - fireDirection.X; + float fireYVel = projYStore - fireDirection.Y; + float fireVelocity = (float)Math.Sqrt((double)(fireXVel * fireXVel + fireYVel * fireYVel)); + fireVelocity = projVel / fireVelocity; + fireXVel *= fireVelocity; + fireYVel *= fireVelocity; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X - 4f, Projectile.Center.Y, fireXVel, fireYVel, projectileType, Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); Projectile.ai[0] = 12f; } } diff --git a/Projectiles/Summon/WaterSpearFriendly.cs b/Projectiles/Summon/WaterSpearFriendly.cs index f28667cf99..36e0cda993 100644 --- a/Projectiles/Summon/WaterSpearFriendly.cs +++ b/Projectiles/Summon/WaterSpearFriendly.cs @@ -30,14 +30,14 @@ namespace CalamityMod.Projectiles.Summon Projectile.velocity.Y *= 1.01f; if (Projectile.ai[1] == 0f) { - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } Projectile.ai[1] = 1f; diff --git a/Projectiles/Typeless/AeroExplosive.cs b/Projectiles/Typeless/AeroExplosive.cs index 3ec43df9de..accbe6929b 100644 --- a/Projectiles/Typeless/AeroExplosive.cs +++ b/Projectiles/Typeless/AeroExplosive.cs @@ -1,10 +1,9 @@ using CalamityMod.Items.Weapons.Typeless; using Microsoft.Xna.Framework; -using System.Collections.Generic; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace CalamityMod.Projectiles.Typeless { @@ -153,7 +152,7 @@ namespace CalamityMod.Projectiles.Typeless if (Projectile.owner == Main.myPlayer) { - CalamityUtils.ExplodeandDestroyTiles(Projectile, 7, true, new List() { }, new List() { }); + Projectile.ExplodeTiles(7, true); } } } diff --git a/Projectiles/Typeless/AscendantAura.cs b/Projectiles/Typeless/AscendantAura.cs new file mode 100644 index 0000000000..6e5b32dcc9 --- /dev/null +++ b/Projectiles/Typeless/AscendantAura.cs @@ -0,0 +1,107 @@ +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class AscendantAura : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public Player Owner => Main.player[Projectile.owner]; + public float beamWidth = 1.04f; + public bool beamsize = false; + public CalamityPlayer moddedOwner => Owner.Calamity(); + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailingMode[Type] = 2; + ProjectileID.Sets.TrailCacheLength[Type] = 8; + } + public override void SetDefaults() + { + Projectile.penetrate = -1; + Projectile.width = Projectile.height = 78; + Projectile.ignoreWater = true; + Projectile.timeLeft = 240; + Projectile.tileCollide = false; + Projectile.friendly = true; + Projectile.penetrate = -1; + } + + public override void AI() + { + if (beamWidth <= 0.96f) + { + beamsize = true; + } + if (beamWidth >= 1.04f) + { + beamsize = false; + } + beamWidth += (beamsize ? 0.015f : -0.015f); + + Projectile.scale = beamWidth; + + if (Projectile.timeLeft >= 240) + { + int dustAmount = 200; + for (int d = 0; d < dustAmount; d++) + { + float angle = MathHelper.TwoPi / dustAmount * d; + Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(5f, 40f); + + Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, 204, velocity); + spawnDust.noGravity = true; + spawnDust.scale = velocity.Length() * 0.05f; + spawnDust.velocity *= 0.4f; + } + } + // Stay on the player's head + Projectile.Center = (Owner.MountedCenter + new Vector2(0, -45)); + + Vector2 spawnPos = Projectile.Center + Main.rand.NextVector2Circular(5, 5); + int lifetime = Main.rand.Next(3, 6); + float scale = Main.rand.NextFloat(0.5f, 0.9f); + Color color = Main.rand.NextBool(3) ? Color.LightGreen : Color.Khaki; + SparkParticle spark1 = new SparkParticle(spawnPos, new Vector2(Main.rand.NextFloat(7, 12), Main.rand.NextFloat(7, 12)), false, lifetime, scale, color); + GeneralParticleHandler.SpawnParticle(spark1); + SparkParticle spark2 = new SparkParticle(spawnPos, new Vector2(Main.rand.NextFloat(-7, -12), Main.rand.NextFloat(7, 12)), false, lifetime, scale, color); + GeneralParticleHandler.SpawnParticle(spark2); + SparkParticle spark3 = new SparkParticle(spawnPos, new Vector2(Main.rand.NextFloat(7, 12), Main.rand.NextFloat(-7, -12)), false, lifetime, scale, color); + GeneralParticleHandler.SpawnParticle(spark3); + SparkParticle spark4 = new SparkParticle(spawnPos, new Vector2(Main.rand.NextFloat(-7, -12), Main.rand.NextFloat(-7, -12)), false, lifetime, scale, color); + GeneralParticleHandler.SpawnParticle(spark4); + SparkParticle spark5 = new SparkParticle(Projectile.Center + new Vector2(20, 0), new Vector2(Main.rand.NextFloat(7, 12), 0), false, lifetime, scale, color); + GeneralParticleHandler.SpawnParticle(spark5); + SparkParticle spark6 = new SparkParticle(Projectile.Center + new Vector2(-20, 0), new Vector2(Main.rand.NextFloat(-7, -12), 0), false, lifetime, scale - 0.3f, color); + GeneralParticleHandler.SpawnParticle(spark6); + + // Emit some light + Vector3 Light = new Vector3(0.251f, 0.255f, 0.219f); + Lighting.AddLight(Projectile.Center, Light * 5); + } + public override void OnKill(int timeLeft) + { + float numberOfDusts = 40f; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) + { + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 offset = new Vector2(8f, 0).RotatedBy(rot); + Vector2 velOffset = new Vector2(2.5f, 0).RotatedBy(rot); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, 204, new Vector2(velOffset.X, velOffset.Y)); + dust.noGravity = true; + dust.velocity = velOffset * Main.rand.NextFloat(0.9f, 1.1f); + dust.scale = 2.5f; + } + } + + public override bool? CanDamage() => false; + } +} diff --git a/Projectiles/Typeless/AscendantAura.png b/Projectiles/Typeless/AscendantAura.png new file mode 100644 index 0000000000..fb2bd6cc34 Binary files /dev/null and b/Projectiles/Typeless/AscendantAura.png differ diff --git a/Projectiles/Typeless/AstralStar.cs b/Projectiles/Typeless/AstralStar.cs index 0ceb8f68c0..0e415f6579 100644 --- a/Projectiles/Typeless/AstralStar.cs +++ b/Projectiles/Typeless/AstralStar.cs @@ -63,10 +63,10 @@ namespace CalamityMod.Projectiles.Typeless if (Main.rand.NextBool(16)) { - Vector2 value3 = Vector2.UnitX.RotatedByRandom(1.5707963705062866).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num59 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, ModContent.DustType(), Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1f); - Main.dust[num59].velocity = value3 * 0.66f; - Main.dust[num59].position = Projectile.Center + value3 * 12f; + Vector2 rotational = Vector2.UnitX.RotatedByRandom(1.5707963705062866).RotatedBy((double)Projectile.velocity.ToRotation(), default); + int astralDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, ModContent.DustType(), Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1f); + Main.dust[astralDust].velocity = rotational * 0.66f; + Main.dust[astralDust].position = Projectile.Center + rotational * 12f; } if (Main.rand.NextBool(48) && Main.netMode != NetmodeID.Server) diff --git a/Projectiles/Typeless/BlazingStarHeal.cs b/Projectiles/Typeless/BlazingStarHeal.cs index 7a0eca626c..c80b4406dd 100644 --- a/Projectiles/Typeless/BlazingStarHeal.cs +++ b/Projectiles/Typeless/BlazingStarHeal.cs @@ -1,10 +1,10 @@ -using Microsoft.Xna.Framework; +using System; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; using Terraria; -using Terraria.ModLoader; -using Terraria.ID; using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { @@ -58,34 +58,33 @@ namespace CalamityMod.Projectiles.Typeless public override bool PreDraw(ref Color lightColor) { - Texture2D value = ModContent.Request(Texture).Value; - Color color33 = new Color(54, 209, 54, 0); - Vector2 vector28 = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); - Color color34 = color33; - Vector2 origin5 = value.Size() / 2f; - Color color35 = color33 * 0.5f; - float num162 = Utils.GetLerpValue(15f, 30f, Projectile.timeLeft, clamped: true) * Utils.GetLerpValue(240f, 200f, Projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 30f / 0.5f * ((float)Math.PI * 2f) * 3f)) * 0.8f; - Vector2 vector29 = new Vector2(0.5f, 1f) * num162; - Vector2 vector30 = new Vector2(0.5f, 1f) * num162; - color34 *= num162; - color35 *= num162; + Texture2D starTexture = ModContent.Request(Texture).Value; + Color healGreen = new Color(54, 209, 54, 0); + Vector2 projPos = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); + Color healGreenDraw = healGreen; + Vector2 colorSize = starTexture.Size() / 2f; + Color lesserHealGreen = healGreen * 0.5f; + float colorLerp = Utils.GetLerpValue(15f, 30f, Projectile.timeLeft, clamped: true) * Utils.GetLerpValue(240f, 200f, Projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 30f / 0.5f * ((float)Math.PI * 2f) * 3f)) * 0.8f; + Vector2 scaledColorLerp1 = new Vector2(0.5f, 1f) * colorLerp; + Vector2 scaledColorLerp2 = new Vector2(0.5f, 1f) * colorLerp; + healGreenDraw *= colorLerp; + lesserHealGreen *= colorLerp; - int num163 = 0; - Vector2 position3 = vector28 + Projectile.velocity.SafeNormalize(Vector2.Zero) * Utils.GetLerpValue(0.5f, 1f, Projectile.localAI[0] / 60f, clamped: true) * num163; + Vector2 drawPos = projPos + Projectile.velocity.SafeNormalize(Vector2.Zero) * Utils.GetLerpValue(0.5f, 1f, Projectile.localAI[0] / 60f, clamped: true) * 0; SpriteEffects spriteEffects = SpriteEffects.None; if (Projectile.spriteDirection == -1) spriteEffects = SpriteEffects.FlipHorizontally; - Main.EntitySpriteDraw(value, position3, null, color34, (float)Math.PI / 2f, origin5, vector29, spriteEffects, 0); - Main.EntitySpriteDraw(value, position3, null, color34, 0f, origin5, vector30, spriteEffects, 0); - Main.EntitySpriteDraw(value, position3, null, color35, (float)Math.PI / 2f, origin5, vector29 * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(value, position3, null, color35, 0f, origin5, vector30 * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(starTexture, drawPos, null, healGreenDraw, (float)Math.PI / 2f, colorSize, scaledColorLerp1, spriteEffects, 0); + Main.EntitySpriteDraw(starTexture, drawPos, null, healGreenDraw, 0f, colorSize, scaledColorLerp2, spriteEffects, 0); + Main.EntitySpriteDraw(starTexture, drawPos, null, lesserHealGreen, (float)Math.PI / 2f, colorSize, scaledColorLerp1 * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(starTexture, drawPos, null, lesserHealGreen, 0f, colorSize, scaledColorLerp2 * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(value, position3, null, color34, MathHelper.PiOver4, origin5, vector29 * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(value, position3, null, color34, MathHelper.PiOver4 * 3f, origin5, vector30 * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(value, position3, null, color35, MathHelper.PiOver4, origin5, vector29 * 0.36f, spriteEffects, 0); - Main.EntitySpriteDraw(value, position3, null, color35, MathHelper.PiOver4 * 3f, origin5, vector30 * 0.36f, spriteEffects, 0); + Main.EntitySpriteDraw(starTexture, drawPos, null, healGreenDraw, MathHelper.PiOver4, colorSize, scaledColorLerp1 * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(starTexture, drawPos, null, healGreenDraw, MathHelper.PiOver4 * 3f, colorSize, scaledColorLerp2 * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(starTexture, drawPos, null, lesserHealGreen, MathHelper.PiOver4, colorSize, scaledColorLerp1 * 0.36f, spriteEffects, 0); + Main.EntitySpriteDraw(starTexture, drawPos, null, lesserHealGreen, MathHelper.PiOver4 * 3f, colorSize, scaledColorLerp2 * 0.36f, spriteEffects, 0); return false; } @@ -99,25 +98,25 @@ namespace CalamityMod.Projectiles.Typeless Projectile.height = 40; Projectile.position.X = Projectile.position.X - (Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (Projectile.height / 2); - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - Main.dust[num622].noGravity = true; + int duster = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); + Main.dust[duster].velocity *= 3f; + Main.dust[duster].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[duster].scale = 0.5f; + Main.dust[duster].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 8; num623++) + for (int j = 0; j < 8; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 247, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - Main.dust[num624].noGravity = true; + int duster2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 247, 0f, 0f, 100, default, 3f); + Main.dust[duster2].noGravity = true; + Main.dust[duster2].velocity *= 5f; + duster2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); + Main.dust[duster2].velocity *= 2f; + Main.dust[duster2].noGravity = true; } } diff --git a/Projectiles/Typeless/BloodBomb.cs b/Projectiles/Typeless/BloodBomb.cs index add83a54e7..67d697676d 100644 --- a/Projectiles/Typeless/BloodBomb.cs +++ b/Projectiles/Typeless/BloodBomb.cs @@ -29,12 +29,12 @@ namespace CalamityMod.Projectiles.Typeless SoundEngine.PlaySound(SoundID.Item73, Projectile.position); Projectile.localAI[0] += 1f; } - for (int num457 = 0; num457 < 3; num457++) + for (int j = 0; j < 3; j++) { - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 5, 0f, 0f, 100, default, 1.2f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int bloody = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 5, 0f, 0f, 100, default, 1.2f); + Main.dust[bloody].noGravity = true; + Main.dust[bloody].velocity *= 0.5f; + Main.dust[bloody].velocity += Projectile.velocity * 0.1f; } } diff --git a/Projectiles/Typeless/BloodBombExplosion.cs b/Projectiles/Typeless/BloodBombExplosion.cs index 1c8f35d578..b2183ade06 100644 --- a/Projectiles/Typeless/BloodBombExplosion.cs +++ b/Projectiles/Typeless/BloodBombExplosion.cs @@ -33,60 +33,60 @@ namespace CalamityMod.Projectiles.Typeless SoundEngine.PlaySound(SoundID.Item74, Projectile.position); Projectile.localAI[0] += 1f; } - bool flag15 = false; - bool flag16 = false; + bool xflag = false; + bool yflag = false; if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) { - flag16 = true; + yflag = true; } if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) { - flag16 = true; + yflag = true; } - if (flag15 && flag16) + if (xflag && yflag) { Projectile.Kill(); } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-30, 31); - float num464 = (float)Main.rand.Next(-30, 31); - float num465 = (float)Main.rand.Next(9, 27); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 5, 0f, 0f, 100, default, 1.8f); - Dust dust = Main.dust[num467]; + float rand1 = (float)Main.rand.Next(-30, 31); + float rand2 = (float)Main.rand.Next(-30, 31); + float rand3 = (float)Main.rand.Next(9, 27); + float randAdjust = (float)Math.Sqrt((double)(rand1 * rand1 + rand2 * rand2)); + randAdjust = rand3 / randAdjust; + rand1 *= randAdjust; + rand2 *= randAdjust; + int bloody = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 5, 0f, 0f, 100, default, 1.8f); + Dust dust = Main.dust[bloody]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = rand1; + dust.velocity.Y = rand2; + timerCounter++; } return; } diff --git a/Projectiles/Typeless/BrimstoneHellfireballFriendly2.cs b/Projectiles/Typeless/BrimstoneHellfireballFriendly2.cs index da8651cfae..11f8c94957 100644 --- a/Projectiles/Typeless/BrimstoneHellfireballFriendly2.cs +++ b/Projectiles/Typeless/BrimstoneHellfireballFriendly2.cs @@ -34,12 +34,12 @@ namespace CalamityMod.Projectiles.Typeless SoundEngine.PlaySound(SoundID.Item20, Projectile.position); Projectile.localAI[0] += 1f; } - for (int num457 = 0; num457 < 5; num457++) + for (int i = 0; i < 5; i++) { - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 0.6f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int brimDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 0.6f); + Main.dust[brimDust].noGravity = true; + Main.dust[brimDust].velocity *= 0.5f; + Main.dust[brimDust].velocity += Projectile.velocity * 0.1f; } return; } diff --git a/Projectiles/Typeless/ChaoticGeyser.cs b/Projectiles/Typeless/ChaoticGeyser.cs index dad02e60d5..066954385f 100644 --- a/Projectiles/Typeless/ChaoticGeyser.cs +++ b/Projectiles/Typeless/ChaoticGeyser.cs @@ -66,8 +66,8 @@ namespace CalamityMod.Projectiles.Typeless SoundEngine.PlaySound(SoundID.Item20, Projectile.position); } Projectile.rotation += Projectile.velocity.X * 0.1f; - int num199 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, 1f); - Dust dust = Main.dust[num199]; + int flareDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, 1f); + Dust dust = Main.dust[flareDust]; dust.position.X -= 2f; dust.position.Y += 2f; dust.scale += (float)Main.rand.Next(50) * 0.01f; @@ -75,8 +75,8 @@ namespace CalamityMod.Projectiles.Typeless dust.velocity.Y -= 16f; if (Main.rand.NextBool()) { - int num200 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, 1f); - Dust dust2 = Main.dust[num200]; + int flareDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, 1f); + Dust dust2 = Main.dust[flareDust2]; dust2.position.X -= 2f; dust2.position.Y += 2f; dust2.scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; diff --git a/Projectiles/Typeless/CursorProj.cs b/Projectiles/Typeless/CursorProj.cs index 601e6e6e7a..059f41d89a 100644 --- a/Projectiles/Typeless/CursorProj.cs +++ b/Projectiles/Typeless/CursorProj.cs @@ -37,13 +37,9 @@ namespace CalamityMod.Projectiles.Typeless if (Projectile.timeLeft > 285) return; - float num29 = 5f; - float num30 = 300f; + float aiTrack = 5f; float scaleFactor = 6f; - Vector2 value7 = new Vector2(10f, 20f); - //float num31 = 1f; - int num32 = 3 * Projectile.MaxUpdates; - int num33 = Utils.SelectRandom(Main.rand, new int[] + int dustType = Utils.SelectRandom(Main.rand, new int[] { 246, 242, @@ -51,7 +47,7 @@ namespace CalamityMod.Projectiles.Typeless 226, 247 }); - int num34 = 255; + int crystalDustType = 255; if (Projectile.ai[1] == 0f) { Projectile.ai[1] = 1f; @@ -59,38 +55,38 @@ namespace CalamityMod.Projectiles.Typeless } else if (Projectile.ai[1] == 1f && Projectile.owner == Main.myPlayer) { - int num35 = -1; - float num36 = num30; - for (int num37 = 0; num37 < Main.maxNPCs; num37++) + int targetID = -1; + float hitDistance = 300f; + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num37].active && Main.npc[num37].CanBeChasedBy(Projectile, false)) + if (Main.npc[i].active && Main.npc[i].CanBeChasedBy(Projectile, false)) { - Vector2 center3 = Main.npc[num37].Center; - float num38 = Vector2.Distance(center3, Projectile.Center); - if (num38 < num36 && num35 == -1 && Collision.CanHitLine(Projectile.Center, 1, 1, center3, 1, 1)) + Vector2 targetCenter = Main.npc[i].Center; + float targetDist = Vector2.Distance(targetCenter, Projectile.Center); + if (targetDist < hitDistance && targetID == -1 && Collision.CanHitLine(Projectile.Center, 1, 1, targetCenter, 1, 1)) { - num36 = num38; - num35 = num37; + hitDistance = targetDist; + targetID = i; } } } - if (num36 < 4f) + if (hitDistance < 4f) { Projectile.Kill(); return; } - if (num35 != -1) + if (targetID != -1) { - Projectile.ai[1] = num29 + 1f; - Projectile.ai[0] = (float)num35; + Projectile.ai[1] = aiTrack + 1f; + Projectile.ai[0] = (float)targetID; Projectile.netUpdate = true; } } - else if (Projectile.ai[1] > num29) + else if (Projectile.ai[1] > aiTrack) { Projectile.ai[1] += 1f; - int num39 = (int)Projectile.ai[0]; - if (!Main.npc[num39].active || !Main.npc[num39].CanBeChasedBy(Projectile, false)) + int npcTrack = (int)Projectile.ai[0]; + if (!Main.npc[npcTrack].active || !Main.npc[npcTrack].CanBeChasedBy(Projectile, false)) { Projectile.ai[1] = 1f; Projectile.ai[0] = 0f; @@ -99,25 +95,24 @@ namespace CalamityMod.Projectiles.Typeless else { Projectile.velocity.ToRotation(); - Vector2 vector6 = Main.npc[num39].Center - Projectile.Center; - if (vector6.Length() < 10f) + Vector2 npcDirection = Main.npc[npcTrack].Center - Projectile.Center; + if (npcDirection.Length() < 10f) { Projectile.Kill(); return; } - if (vector6 != Vector2.Zero) + if (npcDirection != Vector2.Zero) { - vector6.Normalize(); - vector6 *= scaleFactor; + npcDirection.Normalize(); + npcDirection *= scaleFactor; } - float num40 = 30f; - Projectile.velocity = (Projectile.velocity * (num40 - 1f) + vector6) / num40; + Projectile.velocity = (Projectile.velocity * 29f + npcDirection) / 30f; } } - if (Projectile.ai[1] >= 1f && Projectile.ai[1] < num29) + if (Projectile.ai[1] >= 1f && Projectile.ai[1] < aiTrack) { Projectile.ai[1] += 1f; - if (Projectile.ai[1] == num29) + if (Projectile.ai[1] == aiTrack) { Projectile.ai[1] = 1f; } @@ -129,57 +124,55 @@ namespace CalamityMod.Projectiles.Typeless } if (Main.rand.NextBool(12)) { - Vector2 value9 = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num44 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, num34, 0f, 0f, 160, default, 1f); - Main.dust[num44].velocity *= 0.1f; - Main.dust[num44].position = Projectile.Center + value9 * (float)Projectile.width / 2f + Projectile.velocity * 2f; - Main.dust[num44].fadeIn = 0.9f; + Vector2 rotateFirstDust = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)Projectile.velocity.ToRotation(), default); + int crystalDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, crystalDustType, 0f, 0f, 160, default, 1f); + Main.dust[crystalDust].velocity *= 0.1f; + Main.dust[crystalDust].position = Projectile.Center + rotateFirstDust * (float)Projectile.width / 2f + Projectile.velocity * 2f; + Main.dust[crystalDust].fadeIn = 0.9f; } if (Main.rand.NextBool(18)) { - Vector2 value10 = -Vector2.UnitX.RotatedByRandom(0.39269909262657166).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num46 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 107, 0f, 0f, 155, default, 0.8f); - Main.dust[num46].velocity *= 0.3f; - Main.dust[num46].position = Projectile.Center + value10 * (float)Projectile.width / 2f; + Vector2 rotateSecondDust = -Vector2.UnitX.RotatedByRandom(0.39269909262657166).RotatedBy((double)Projectile.velocity.ToRotation(), default); + int greenDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 107, 0f, 0f, 155, default, 0.8f); + Main.dust[greenDust].velocity *= 0.3f; + Main.dust[greenDust].position = Projectile.Center + rotateSecondDust * (float)Projectile.width / 2f; if (Main.rand.NextBool()) { - Main.dust[num46].fadeIn = 1.4f; + Main.dust[greenDust].fadeIn = 1.4f; } } if (Main.rand.NextBool(8)) { - Vector2 value11 = -Vector2.UnitX.RotatedByRandom(0.78539818525314331).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num48 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, num33, 0f, 0f, 0, default, 1f); - Main.dust[num48].velocity *= 0.3f; - Main.dust[num48].noGravity = true; - Main.dust[num48].position = Projectile.Center + value11 * (float)Projectile.width / 2f; + Vector2 rotateThirdDust = -Vector2.UnitX.RotatedByRandom(0.78539818525314331).RotatedBy((double)Projectile.velocity.ToRotation(), default); + int randomDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 1f); + Main.dust[randomDust].velocity *= 0.3f; + Main.dust[randomDust].noGravity = true; + Main.dust[randomDust].position = Projectile.Center + rotateThirdDust * (float)Projectile.width / 2f; if (Main.rand.NextBool()) { - Main.dust[num48].fadeIn = 1.4f; + Main.dust[randomDust].fadeIn = 1.4f; } } if (Main.rand.NextBool(6)) { Vector2 value13 = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num50 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, num34, 0f, 0f, 100, default, 1f); - Main.dust[num50].velocity *= 0.3f; - Main.dust[num50].position = Projectile.Center + value13 * (float)Projectile.width / 2f; - Main.dust[num50].fadeIn = 1.2f; - Main.dust[num50].scale = 1.5f; - Main.dust[num50].noGravity = true; + int crystalDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, crystalDustType, 0f, 0f, 100, default, 1f); + Main.dust[crystalDust2].velocity *= 0.3f; + Main.dust[crystalDust2].position = Projectile.Center + value13 * (float)Projectile.width / 2f; + Main.dust[crystalDust2].fadeIn = 1.2f; + Main.dust[crystalDust2].scale = 1.5f; + Main.dust[crystalDust2].noGravity = true; } Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.2f / 255f, (255 - Projectile.alpha) * 0.2f / 255f, (255 - Projectile.alpha) * 0.2f / 255f); - int num154 = 14; - int num155 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - num154 * 2, Projectile.height - num154 * 2, 234, 0f, 0f, 100, default, 0.8f); - Main.dust[num155].velocity *= 0.1f; - Main.dust[num155].velocity += Projectile.velocity * 0.5f; - Main.dust[num155].noGravity = true; + int paleDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - 28, Projectile.height - 28, 234, 0f, 0f, 100, default, 0.8f); + Main.dust[paleDust].velocity *= 0.1f; + Main.dust[paleDust].velocity += Projectile.velocity * 0.5f; + Main.dust[paleDust].noGravity = true; if (Main.rand.NextBool(12)) { - int num156 = 16; - int num157 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - num156 * 2, Projectile.height - num156 * 2, 159, 0f, 0f, 100, default, 1f); - Main.dust[num157].velocity *= 0.25f; - Main.dust[num157].velocity += Projectile.velocity * 0.5f; + int shinyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - 32, Projectile.height - 32, 159, 0f, 0f, 100, default, 1f); + Main.dust[shinyDust].velocity *= 0.25f; + Main.dust[shinyDust].velocity += Projectile.velocity * 0.5f; } } diff --git a/Projectiles/Typeless/CursorProjSplit.cs b/Projectiles/Typeless/CursorProjSplit.cs index 585026fb34..f107778b0b 100644 --- a/Projectiles/Typeless/CursorProjSplit.cs +++ b/Projectiles/Typeless/CursorProjSplit.cs @@ -36,13 +36,9 @@ namespace CalamityMod.Projectiles.Typeless Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) + 1.57f; - float num29 = 5f; - float num30 = 300f; + float aiTrack = 5f; float scaleFactor = 6f; - Vector2 value7 = new Vector2(10f, 20f); - //float num31 = 1f; - int num32 = 3 * Projectile.MaxUpdates; - int num33 = Utils.SelectRandom(Main.rand, new int[] + int dustType = Utils.SelectRandom(Main.rand, new int[] { 246, 242, @@ -50,7 +46,7 @@ namespace CalamityMod.Projectiles.Typeless 226, 247 }); - int num34 = 255; + int crystalDustType = 255; if (Projectile.ai[1] == 0f) { Projectile.ai[1] = 1f; @@ -60,39 +56,39 @@ namespace CalamityMod.Projectiles.Typeless { if (Projectile.alpha < 128) { - int num35 = -1; - float num36 = num30; - for (int num37 = 0; num37 < Main.maxNPCs; num37++) + int targetID = -1; + float hitDistance = 300f; + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num37].active && Main.npc[num37].CanBeChasedBy(Projectile, false)) + if (Main.npc[i].active && Main.npc[i].CanBeChasedBy(Projectile, false)) { - Vector2 center3 = Main.npc[num37].Center; - float num38 = Vector2.Distance(center3, Projectile.Center); - if (num38 < num36 && num35 == -1 && Collision.CanHitLine(Projectile.Center, 1, 1, center3, 1, 1)) + Vector2 targetCenter = Main.npc[i].Center; + float targetDist = Vector2.Distance(targetCenter, Projectile.Center); + if (targetDist < hitDistance && targetID == -1 && Collision.CanHitLine(Projectile.Center, 1, 1, targetCenter, 1, 1)) { - num36 = num38; - num35 = num37; + hitDistance = targetDist; + targetID = i; } } } - if (num36 < 4f) + if (hitDistance < 4f) { Projectile.Kill(); return; } - if (num35 != -1) + if (targetID != -1) { - Projectile.ai[1] = num29 + 1f; - Projectile.ai[0] = (float)num35; + Projectile.ai[1] = aiTrack + 1f; + Projectile.ai[0] = (float)targetID; Projectile.netUpdate = true; } } } - else if (Projectile.ai[1] > num29) + else if (Projectile.ai[1] > aiTrack) { Projectile.ai[1] += 1f; - int num39 = (int)Projectile.ai[0]; - if (!Main.npc[num39].active || !Main.npc[num39].CanBeChasedBy(Projectile, false)) + int npcTrack = (int)Projectile.ai[0]; + if (!Main.npc[npcTrack].active || !Main.npc[npcTrack].CanBeChasedBy(Projectile, false)) { Projectile.ai[1] = 1f; Projectile.ai[0] = 0f; @@ -101,25 +97,24 @@ namespace CalamityMod.Projectiles.Typeless else { Projectile.velocity.ToRotation(); - Vector2 vector6 = Main.npc[num39].Center - Projectile.Center; - if (vector6.Length() < 10f) + Vector2 npcDirection = Main.npc[npcTrack].Center - Projectile.Center; + if (npcDirection.Length() < 10f) { Projectile.Kill(); return; } - if (vector6 != Vector2.Zero) + if (npcDirection != Vector2.Zero) { - vector6.Normalize(); - vector6 *= scaleFactor; + npcDirection.Normalize(); + npcDirection *= scaleFactor; } - float num40 = 30f; - Projectile.velocity = (Projectile.velocity * (num40 - 1f) + vector6) / num40; + Projectile.velocity = (Projectile.velocity * 29f + npcDirection) / 30f; } } - if (Projectile.ai[1] >= 1f && Projectile.ai[1] < num29) + if (Projectile.ai[1] >= 1f && Projectile.ai[1] < aiTrack) { Projectile.ai[1] += 1f; - if (Projectile.ai[1] == num29) + if (Projectile.ai[1] == aiTrack) { Projectile.ai[1] = 1f; } @@ -131,57 +126,55 @@ namespace CalamityMod.Projectiles.Typeless } if (Main.rand.NextBool(12)) { - Vector2 value9 = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num44 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, num34, 0f, 0f, 100, default, 1f); - Main.dust[num44].velocity *= 0.1f; - Main.dust[num44].position = Projectile.Center + value9 * (float)Projectile.width / 2f + Projectile.velocity * 2f; - Main.dust[num44].fadeIn = 0.9f; + Vector2 rotateFirstDust = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)Projectile.velocity.ToRotation(), default); + int crystalDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, crystalDustType, 0f, 0f, 100, default, 1f); + Main.dust[crystalDust].velocity *= 0.1f; + Main.dust[crystalDust].position = Projectile.Center + rotateFirstDust * (float)Projectile.width / 2f + Projectile.velocity * 2f; + Main.dust[crystalDust].fadeIn = 0.9f; } if (Main.rand.NextBool(18)) { - Vector2 value10 = -Vector2.UnitX.RotatedByRandom(0.39269909262657166).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num46 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 107, 0f, 0f, 155, default, 0.8f); - Main.dust[num46].velocity *= 0.3f; - Main.dust[num46].position = Projectile.Center + value10 * (float)Projectile.width / 2f; + Vector2 rotateSecondDust = -Vector2.UnitX.RotatedByRandom(0.39269909262657166).RotatedBy((double)Projectile.velocity.ToRotation(), default); + int greenDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 107, 0f, 0f, 155, default, 0.8f); + Main.dust[greenDust].velocity *= 0.3f; + Main.dust[greenDust].position = Projectile.Center + rotateSecondDust * (float)Projectile.width / 2f; if (Main.rand.NextBool()) { - Main.dust[num46].fadeIn = 1.4f; + Main.dust[greenDust].fadeIn = 1.4f; } } if (Main.rand.NextBool(8)) { - Vector2 value11 = -Vector2.UnitX.RotatedByRandom(0.78539818525314331).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num48 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, num33, 0f, 0f, 0, default, 1f); - Main.dust[num48].velocity *= 0.3f; - Main.dust[num48].noGravity = true; - Main.dust[num48].position = Projectile.Center + value11 * (float)Projectile.width / 2f; + Vector2 rotateThirdDust = -Vector2.UnitX.RotatedByRandom(0.78539818525314331).RotatedBy((double)Projectile.velocity.ToRotation(), default); + int randomDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 1f); + Main.dust[randomDust].velocity *= 0.3f; + Main.dust[randomDust].noGravity = true; + Main.dust[randomDust].position = Projectile.Center + rotateThirdDust * (float)Projectile.width / 2f; if (Main.rand.NextBool()) { - Main.dust[num48].fadeIn = 1.4f; + Main.dust[randomDust].fadeIn = 1.4f; } } if (Main.rand.NextBool(6)) { Vector2 value13 = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num50 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, num34, 0f, 0f, 100, default, 1f); - Main.dust[num50].velocity *= 0.3f; - Main.dust[num50].position = Projectile.Center + value13 * (float)Projectile.width / 2f; - Main.dust[num50].fadeIn = 1.2f; - Main.dust[num50].scale = 1.5f; - Main.dust[num50].noGravity = true; + int crystalDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, crystalDustType, 0f, 0f, 100, default, 1f); + Main.dust[crystalDust2].velocity *= 0.3f; + Main.dust[crystalDust2].position = Projectile.Center + value13 * (float)Projectile.width / 2f; + Main.dust[crystalDust2].fadeIn = 1.2f; + Main.dust[crystalDust2].scale = 1.5f; + Main.dust[crystalDust2].noGravity = true; } Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.2f / 255f, (255 - Projectile.alpha) * 0.2f / 255f, (255 - Projectile.alpha) * 0.2f / 255f); - int num154 = 14; - int num155 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - num154 * 2, Projectile.height - num154 * 2, 234, 0f, 0f, 100, default, 0.8f); - Main.dust[num155].velocity *= 0.1f; - Main.dust[num155].velocity += Projectile.velocity * 0.5f; - Main.dust[num155].noGravity = true; + int paleDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - 28, Projectile.height - 28, 234, 0f, 0f, 100, default, 0.8f); + Main.dust[paleDust].velocity *= 0.1f; + Main.dust[paleDust].velocity += Projectile.velocity * 0.5f; + Main.dust[paleDust].noGravity = true; if (Main.rand.NextBool(12)) { - int num156 = 16; - int num157 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - num156 * 2, Projectile.height - num156 * 2, 159, 0f, 0f, 100, default, 1f); - Main.dust[num157].velocity *= 0.25f; - Main.dust[num157].velocity += Projectile.velocity * 0.5f; + int shinyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - 32, Projectile.height - 32, 159, 0f, 0f, 100, default, 1f); + Main.dust[shinyDust].velocity *= 0.25f; + Main.dust[shinyDust].velocity += Projectile.velocity * 0.5f; } } @@ -208,7 +201,7 @@ namespace CalamityMod.Projectiles.Typeless public override void OnKill(int timeLeft) { - int num47 = Utils.SelectRandom(Main.rand, new int[] + int otherDustType = Utils.SelectRandom(Main.rand, new int[] { 246, 242, @@ -217,49 +210,45 @@ namespace CalamityMod.Projectiles.Typeless 247 }); - int num48 = 187; - int num49 = 234; - //int height = 50; - float num50 = 1.2f; - float num51 = 0.6f; - float num52 = 1.5f; + int randomDust = 187; + float crystalDust2 = 1.2f; - Vector2 value3 = (Projectile.rotation - 1.57079637f).ToRotationVector2(); - Vector2 value4 = value3 * Projectile.velocity.Length() * (float)Projectile.MaxUpdates; + Vector2 dustRotate = (Projectile.rotation - 1.57079637f).ToRotationVector2(); + Vector2 dustVel = dustRotate * Projectile.velocity.Length() * (float)Projectile.MaxUpdates; SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - int num3; - for (int num53 = 0; num53 < 20; num53 = num3 + 1) + int dustCount; + for (int j = 0; j < 20; j = dustCount + 1) { - int num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num47, 0f, 0f, 200, default, num50); - Dust dust = Main.dust[num54]; + int superRandomDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, otherDustType, 0f, 0f, 200, default, crystalDust2); + Dust dust = Main.dust[superRandomDust]; dust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; dust.noGravity = true; dust.velocity.Y -= 6f; dust.velocity *= 3f; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num48, 0f, 0f, 100, default, num51); + dust.velocity += dustVel * Main.rand.NextFloat(); + superRandomDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDust, 0f, 0f, 100, default, 0.6f); dust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; dust.velocity.Y -= 6f; dust.velocity *= 2f; dust.noGravity = true; dust.fadeIn = 1f; dust.color = Color.Cyan * 0.5f; - dust.velocity += value4 * Main.rand.NextFloat(); - num3 = num53; + dust.velocity += dustVel * Main.rand.NextFloat(); + dustCount = j; } - for (int num55 = 0; num55 < 10; num55 = num3 + 1) + for (int k = 0; k < 10; k = dustCount + 1) { - int num56 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num49, 0f, 0f, 0, default, num52); - Main.dust[num56].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 3f; - Dust dust = Main.dust[num56]; + int palestDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 234, 0f, 0f, 0, default, 1.5f); + Main.dust[palestDust].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 3f; + Dust dust = Main.dust[palestDust]; dust.noGravity = true; dust.velocity.Y -= 6f; dust.velocity *= 0.5f; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); - num3 = num55; + dust.velocity += dustVel * (0.6f + 0.6f * Main.rand.NextFloat()); + dustCount = k; } } } diff --git a/Projectiles/Typeless/DeepseaBlaze.cs b/Projectiles/Typeless/DeepseaBlaze.cs index 3bd3a1438d..afffc48e1a 100644 --- a/Projectiles/Typeless/DeepseaBlaze.cs +++ b/Projectiles/Typeless/DeepseaBlaze.cs @@ -31,60 +31,60 @@ namespace CalamityMod.Projectiles.Typeless { Projectile.Kill(); } - bool flag15 = false; - bool flag16 = false; + bool xflag = false; + bool yflag = false; if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) { - flag16 = true; + yflag = true; } if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) { - flag16 = true; + yflag = true; } - if (flag15 && flag16) + if (xflag && yflag) { Projectile.Kill(); } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-30, 31); - float num464 = (float)Main.rand.Next(-30, 31); - float num465 = (float)Main.rand.Next(9, 27); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, 1.5f); - Dust dust = Main.dust[num467]; + float rand1 = (float)Main.rand.Next(-30, 31); + float rand2 = (float)Main.rand.Next(-30, 31); + float rand3 = (float)Main.rand.Next(9, 27); + float randAdjust = (float)Math.Sqrt((double)(rand1 * rand1 + rand2 * rand2)); + randAdjust = rand3 / randAdjust; + rand1 *= randAdjust; + rand2 *= randAdjust; + int fiery = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 127, 0f, 0f, 100, default, 1.5f); + Dust dust = Main.dust[fiery]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = rand1; + dust.velocity.Y = rand2; + timerCounter++; } } diff --git a/Projectiles/Typeless/DemonshadeRedDevil.cs b/Projectiles/Typeless/DemonshadeRedDevil.cs index 855548c857..8d2b584ef3 100644 --- a/Projectiles/Typeless/DemonshadeRedDevil.cs +++ b/Projectiles/Typeless/DemonshadeRedDevil.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { - bool flag64 = Projectile.type == ModContent.ProjectileType(); + bool isMinion = Projectile.type == ModContent.ProjectileType(); Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); if (!modPlayer.redDevil) @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Typeless Projectile.active = false; return; } - if (flag64) + if (isMinion) { if (player.dead) { @@ -58,12 +58,11 @@ namespace CalamityMod.Projectiles.Typeless dust--; if (dust >= 0) { - int num501 = 50; - for (int num502 = 0; num502 < num501; num502++) + for (int i = 0; i < 50; i++) { - int num503 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, (int)CalamityDusts.Brimstone, 0f, 0f, 0, default, 1f); - Main.dust[num503].velocity *= 2f; - Main.dust[num503].scale *= 1.15f; + int brimDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, (int)CalamityDusts.Brimstone, 0f, 0f, 0, default, 1f); + Main.dust[brimDust].velocity *= 2f; + Main.dust[brimDust].scale *= 1.15f; } } Projectile.frameCounter++; @@ -76,19 +75,16 @@ namespace CalamityMod.Projectiles.Typeless { Projectile.frame = 0; } - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight(Projectile.Center, 1f * num, 0f * num, 0.15f * num); + float lights = (float)Main.rand.Next(90, 111) * 0.01f; + lights *= Main.essScale; + Lighting.AddLight(Projectile.Center, 1f * lights, 0f * lights, 0.15f * lights); Projectile.rotation = Projectile.velocity.X * 0.04f; if ((double)Math.Abs(Projectile.velocity.X) > 0.2) { Projectile.spriteDirection = -Projectile.direction; } - float num633 = 2000f; - float num634 = 2000f; - float num635 = 3000f; - float num636 = 150f; - bool flag24 = false; + float attackRange = 2000f; + bool decelerate = false; if (Projectile.ai[0] == 2f) { Projectile.ai[1] += 1f; @@ -103,15 +99,15 @@ namespace CalamityMod.Projectiles.Typeless } else { - flag24 = true; + decelerate = true; } } - if (flag24) + if (decelerate) { return; } - Vector2 vector46 = Projectile.position; - bool flag25 = false; + Vector2 projPos = Projectile.position; + bool canAttack = false; if (Projectile.ai[0] != 1f) { Projectile.tileCollide = false; @@ -125,96 +121,95 @@ namespace CalamityMod.Projectiles.Typeless NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(Projectile, false)) { - float num646 = Vector2.Distance(npc.Center, Projectile.Center); - if (!flag25 && num646 < num633) + float npcDist = Vector2.Distance(npc.Center, Projectile.Center); + if (!canAttack && npcDist < attackRange) { - num633 = num646; - vector46 = npc.Center; - flag25 = true; + attackRange = npcDist; + projPos = npc.Center; + canAttack = true; } } } else { - for (int num645 = 0; num645 < Main.maxNPCs; num645++) + for (int j = 0; j < Main.maxNPCs; j++) { - NPC nPC2 = Main.npc[num645]; + NPC nPC2 = Main.npc[j]; if (nPC2.CanBeChasedBy(Projectile, false)) { - float num646 = Vector2.Distance(nPC2.Center, Projectile.Center); - if ((!flag25 && num646 < num633) && Collision.CanHitLine(Projectile.position, Projectile.width, Projectile.height, nPC2.position, nPC2.width, nPC2.height)) + float npcDist = Vector2.Distance(nPC2.Center, Projectile.Center); + if ((!canAttack && npcDist < attackRange) && Collision.CanHitLine(Projectile.position, Projectile.width, Projectile.height, nPC2.position, nPC2.width, nPC2.height)) { - num633 = num646; - vector46 = nPC2.Center; - flag25 = true; + attackRange = npcDist; + projPos = nPC2.Center; + canAttack = true; } } } } - float num647 = num634; - if (flag25) + float separationAnxietyDist = 2000f; + if (canAttack) { - num647 = num635; + separationAnxietyDist = 3000f; } - if (Vector2.Distance(player.Center, Projectile.Center) > num647) + if (Vector2.Distance(player.Center, Projectile.Center) > separationAnxietyDist) { Projectile.ai[0] = 1f; Projectile.tileCollide = false; Projectile.netUpdate = true; } - if (flag25 && Projectile.ai[0] == 0f) + if (canAttack && Projectile.ai[0] == 0f) { - Vector2 vector47 = vector46 - Projectile.Center; - float num648 = vector47.Length(); - vector47.Normalize(); - if (num648 > 200f) + Vector2 projDirection = projPos - Projectile.Center; + float projDist = projDirection.Length(); + projDirection.Normalize(); + if (projDist > 200f) { float scaleFactor2 = 16f; //8 - vector47 *= scaleFactor2; - Projectile.velocity = (Projectile.velocity * 40f + vector47) / 41f; + projDirection *= scaleFactor2; + Projectile.velocity = (Projectile.velocity * 40f + projDirection) / 41f; } else { - float num649 = 4f; - vector47 *= -num649; - Projectile.velocity = (Projectile.velocity * 40f + vector47) / 41f; + projDirection *= -4f; + Projectile.velocity = (Projectile.velocity * 40f + projDirection) / 41f; } } else { - bool flag26 = false; - if (!flag26) + bool isReturning = false; + if (!isReturning) { - flag26 = Projectile.ai[0] == 1f; + isReturning = Projectile.ai[0] == 1f; } - float num650 = 5f; //6 - if (flag26) + float returnSpeed = 5f; //6 + if (isReturning) { - num650 = 12f; //15 + returnSpeed = 12f; //15 } Vector2 center2 = Projectile.Center; - Vector2 vector48 = player.Center - center2 + new Vector2(0f, -30f); //-60 - float num651 = vector48.Length(); - if (num651 > 200f && num650 < 6.5f) //200 and 8 + Vector2 playerDirection = player.Center - center2 + new Vector2(0f, -30f); //-60 + float playerDist = playerDirection.Length(); + if (playerDist > 200f && returnSpeed < 6.5f) //200 and 8 { - num650 = 6.5f; //8 + returnSpeed = 6.5f; //8 } - if (num651 < num636 && flag26 && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + if (playerDist < 150f && isReturning && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) { Projectile.ai[0] = 0f; Projectile.netUpdate = true; } - if (num651 > 2000f) + if (playerDist > 2000f) { Projectile.position.X = player.Center.X - (float)(Projectile.width / 2); Projectile.position.Y = player.Center.Y - (float)(Projectile.height / 2); Projectile.netUpdate = true; } - if (num651 > 70f) + if (playerDist > 70f) { - vector48.Normalize(); - vector48 *= num650; - Projectile.velocity = (Projectile.velocity * 40f + vector48) / 41f; + playerDirection.Normalize(); + playerDirection *= returnSpeed; + Projectile.velocity = (Projectile.velocity * 40f + playerDirection) / 41f; } else if (Projectile.velocity.X == 0f && Projectile.velocity.Y == 0f) { @@ -235,12 +230,12 @@ namespace CalamityMod.Projectiles.Typeless { float speed = 24f; int projType = ProjectileID.UnholyTridentFriendly; - if (flag25 && Projectile.ai[1] == 0f) + if (canAttack && Projectile.ai[1] == 0f) { Projectile.ai[1] += 1f; - if (Main.myPlayer == Projectile.owner && Collision.CanHitLine(Projectile.Center, Projectile.width, Projectile.height, vector46, 0, 0)) + if (Main.myPlayer == Projectile.owner && Collision.CanHitLine(Projectile.Center, Projectile.width, Projectile.height, projPos, 0, 0)) { - Vector2 velocity = vector46 - Projectile.Center; + Vector2 velocity = projPos - Projectile.Center; velocity.Normalize(); velocity *= speed; int trident = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, projType, Projectile.damage, 0f, Main.myPlayer); @@ -261,9 +256,9 @@ namespace CalamityMod.Projectiles.Typeless { SpriteEffects spriteEffects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, spriteEffects, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, spriteEffects, 0); return false; } diff --git a/Projectiles/Typeless/DragonDust.cs b/Projectiles/Typeless/DragonDust.cs index 642eae5395..11c1c056ad 100644 --- a/Projectiles/Typeless/DragonDust.cs +++ b/Projectiles/Typeless/DragonDust.cs @@ -23,60 +23,60 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0f / 255f); - bool flag15 = false; - bool flag16 = false; + bool xflag = false; + bool yflag = false; if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) { - flag16 = true; + yflag = true; } if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) { - flag16 = true; + yflag = true; } - if (flag15 && flag16) + if (xflag && yflag) { Projectile.Kill(); } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 60f) { - num461 -= (Projectile.ai[0] - 60f) / 2f; + projTimer -= (Projectile.ai[0] - 60f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-8, 9); - float num464 = (float)Main.rand.Next(-8, 9); - float num465 = (float)Main.rand.Next(2, 7); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 1.5f); - Dust dust = Main.dust[num467]; + float rand1 = (float)Main.rand.Next(-8, 9); + float rand2 = (float)Main.rand.Next(-8, 9); + float rand3 = (float)Main.rand.Next(2, 7); + float randAdjust = (float)Math.Sqrt((double)(rand1 * rand1 + rand2 * rand2)); + randAdjust = rand3 / randAdjust; + rand1 *= randAdjust; + rand2 *= randAdjust; + int dragonDuster = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 1.5f); + Dust dust = Main.dust[dragonDuster]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = rand1; + dust.velocity.Y = rand2; + timerCounter++; } } diff --git a/Projectiles/Typeless/EmpyreanBlast.cs b/Projectiles/Typeless/EmpyreanBlast.cs index 9f6eb38ef3..a2ef4103a7 100644 --- a/Projectiles/Typeless/EmpyreanBlast.cs +++ b/Projectiles/Typeless/EmpyreanBlast.cs @@ -24,60 +24,60 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.35f / 255f, (255 - Projectile.alpha) * 0.05f / 255f, (255 - Projectile.alpha) * 0.25f / 255f); - bool flag15 = false; - bool flag16 = false; + bool xflag = false; + bool yflag = false; if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) { - flag15 = true; + xflag = true; } if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) { - flag16 = true; + yflag = true; } if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) { - flag16 = true; + yflag = true; } - if (flag15 && flag16) + if (xflag && yflag) { Projectile.Kill(); } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-10, 11); - float num464 = (float)Main.rand.Next(-10, 11); - float num465 = (float)Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 62, 0f, 0f, 100, default, 1f); - Dust dust = Main.dust[num467]; + float rand1 = (float)Main.rand.Next(-10, 11); + float rand2 = (float)Main.rand.Next(-10, 11); + float rand3 = (float)Main.rand.Next(3, 9); + float randAdjust = (float)Math.Sqrt((double)(rand1 * rand1 + rand2 * rand2)); + randAdjust = rand3 / randAdjust; + rand1 *= randAdjust; + rand2 *= randAdjust; + int ourpleDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 62, 0f, 0f, 100, default, 1f); + Dust dust = Main.dust[ourpleDust]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = rand1; + dust.velocity.Y = rand2; + timerCounter++; } } } diff --git a/Projectiles/Typeless/EmpyreanEmber.cs b/Projectiles/Typeless/EmpyreanEmber.cs index cc92fa0dcf..db48cb33a7 100644 --- a/Projectiles/Typeless/EmpyreanEmber.cs +++ b/Projectiles/Typeless/EmpyreanEmber.cs @@ -48,8 +48,8 @@ namespace CalamityMod.Projectiles.Typeless Projectile.rotation += Projectile.velocity.X * 0.1f; if (Main.rand.NextBool(3)) { - int num200 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 62, 0f, 0f, 100, default, 0.75f); - Dust dust2 = Main.dust[num200]; + int ourpleDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 62, 0f, 0f, 100, default, 0.75f); + Dust dust2 = Main.dust[ourpleDust]; dust2.position.X -= 2f; dust2.position.Y += 2f; dust2.scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; @@ -58,8 +58,8 @@ namespace CalamityMod.Projectiles.Typeless } else { - int num199 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 62, 0f, 0f, 100, default, 0.75f); - Dust dust = Main.dust[num199]; + int ourpleDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 62, 0f, 0f, 100, default, 0.75f); + Dust dust = Main.dust[ourpleDust2]; dust.position.X -= 2f; dust.position.Y += 2f; dust.scale += (float)Main.rand.Next(50) * 0.01f; diff --git a/Projectiles/Typeless/EmpyreanGlob.cs b/Projectiles/Typeless/EmpyreanGlob.cs index ed93b1dbe0..0e8e864e0f 100644 --- a/Projectiles/Typeless/EmpyreanGlob.cs +++ b/Projectiles/Typeless/EmpyreanGlob.cs @@ -23,9 +23,9 @@ namespace CalamityMod.Projectiles.Typeless Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 62, 0f, 0f, 100, default, 1f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int ourpleDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 62, 0f, 0f, 100, default, 1f); + Main.dust[ourpleDust].noGravity = true; + Main.dust[ourpleDust].velocity *= 0f; } CalamityUtils.HomeInOnNPC(Projectile, true, 200f, 8f, 20f); } diff --git a/Projectiles/Typeless/EmpyreanMarble.cs b/Projectiles/Typeless/EmpyreanMarble.cs index b062faae51..704be03a85 100644 --- a/Projectiles/Typeless/EmpyreanMarble.cs +++ b/Projectiles/Typeless/EmpyreanMarble.cs @@ -21,9 +21,9 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 62, 0f, 0f, 100, default, 2f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int ourpleDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 62, 0f, 0f, 100, default, 2f); + Main.dust[ourpleDust].noGravity = true; + Main.dust[ourpleDust].velocity *= 0f; CalamityUtils.HomeInOnNPC(Projectile, true, 200f, 7f, 20f); } } diff --git a/Projectiles/Typeless/EmpyreanStellarDetritus.cs b/Projectiles/Typeless/EmpyreanStellarDetritus.cs index 7f3e09889c..ff3a085054 100644 --- a/Projectiles/Typeless/EmpyreanStellarDetritus.cs +++ b/Projectiles/Typeless/EmpyreanStellarDetritus.cs @@ -26,9 +26,9 @@ namespace CalamityMod.Projectiles.Typeless Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 62, 0f, 0f, 100, default, 2f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int ourpleDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 62, 0f, 0f, 100, default, 2f); + Main.dust[ourpleDust].noGravity = true; + Main.dust[ourpleDust].velocity *= 0f; } CalamityUtils.HomeInOnNPC(Projectile, true, 200f, 10f, 20f); } diff --git a/Projectiles/Typeless/FuckYou.cs b/Projectiles/Typeless/FuckYou.cs index 5eac86066c..d1e83f41d9 100644 --- a/Projectiles/Typeless/FuckYou.cs +++ b/Projectiles/Typeless/FuckYou.cs @@ -65,8 +65,8 @@ namespace CalamityMod.Projectiles.Typeless SoundEngine.PlaySound(SoundID.Item14, Projectile.position); for (int dustIndexA = 0; dustIndexA < 4; dustIndexA = incrementer + 1) { - int num992 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 1.5f); - Main.dust[num992].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + int smoky = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 1.5f); + Main.dust[smoky].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; incrementer = dustIndexA; } for (int dustIndexB = 0; dustIndexB < 10; dustIndexB = incrementer + 1) @@ -94,8 +94,8 @@ namespace CalamityMod.Projectiles.Typeless } for (int dustIndexD = 0; dustIndexD < 10; dustIndexD = incrementer + 1) { - int num998 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 0, default, 1.5f); - Dust dust = Main.dust[num998]; + int smokier = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 0, default, 1.5f); + Dust dust = Main.dust[smokier]; dust.position = Projectile.Center + Vector2.UnitX.RotatedByRandom(Math.PI).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 2f; dust.noGravity = true; dust.velocity *= 3f; diff --git a/Projectiles/Typeless/GhostlyBolt.cs b/Projectiles/Typeless/GhostlyBolt.cs index 97993e25ae..236e2a67cb 100644 --- a/Projectiles/Typeless/GhostlyBolt.cs +++ b/Projectiles/Typeless/GhostlyBolt.cs @@ -31,24 +31,24 @@ namespace CalamityMod.Projectiles.Typeless if (Projectile.localAI[0] == 6f) { SoundEngine.PlaySound(SoundID.Item8, Projectile.position); - for (int num151 = 0; num151 < 40; num151++) + for (int i = 0; i < 40; i++) { - int num152 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 181, 0f, 0f, 100, default, 1f); - Main.dust[num152].velocity *= 3f; - Main.dust[num152].velocity += Projectile.velocity * 0.75f; - Main.dust[num152].scale *= 1.2f; - Main.dust[num152].noGravity = true; + int cursedDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 181, 0f, 0f, 100, default, 1f); + Main.dust[cursedDust].velocity *= 3f; + Main.dust[cursedDust].velocity += Projectile.velocity * 0.75f; + Main.dust[cursedDust].scale *= 1.2f; + Main.dust[cursedDust].noGravity = true; } } Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 6f) { - for (int num153 = 0; num153 < 3; num153++) + for (int j = 0; j < 3; j++) { - int num154 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 181, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Main.dust[num154].velocity *= 0.6f; - Main.dust[num154].scale *= 1.4f; - Main.dust[num154].noGravity = true; + int cursedDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 181, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); + Main.dust[cursedDust2].velocity *= 0.6f; + Main.dust[cursedDust2].scale *= 1.4f; + Main.dust[cursedDust2].noGravity = true; } } } diff --git a/Projectiles/Typeless/GodKiller.cs b/Projectiles/Typeless/GodKiller.cs index ec9aa3b6e1..561ef29f1b 100644 --- a/Projectiles/Typeless/GodKiller.cs +++ b/Projectiles/Typeless/GodKiller.cs @@ -52,22 +52,22 @@ namespace CalamityMod.Projectiles.Typeless { if (Math.Abs(Projectile.velocity.X) >= 2f || Math.Abs(Projectile.velocity.Y) >= 2f) { - for (int num246 = 0; num246 < 2; num246++) + for (int i = 0; i < 2; i++) { - float num247 = 0f; - float num248 = 0f; - if (num246 == 1) + float shortXVel = 0f; + float shortYVel = 0f; + if (i == 1) { - num247 = Projectile.velocity.X * 0.5f; - num248 = Projectile.velocity.Y * 0.5f; + shortXVel = Projectile.velocity.X * 0.5f; + shortYVel = Projectile.velocity.Y * 0.5f; } - int num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 173, 0f, 0f, 100, default, 1f); - Main.dust[num249].scale *= 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - num249 = Dust.NewDust(new Vector2(Projectile.position.X + 3f + num247, Projectile.position.Y + 3f + num248) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 199, 0f, 0f, 100, default, 0.1f); - Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num249].velocity *= 0.05f; + int dusting = Dust.NewDust(new Vector2(Projectile.position.X + 3f + shortXVel, Projectile.position.Y + 3f + shortYVel) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 173, 0f, 0f, 100, default, 1f); + Main.dust[dusting].scale *= 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dusting].velocity *= 0.2f; + Main.dust[dusting].noGravity = true; + dusting = Dust.NewDust(new Vector2(Projectile.position.X + 3f + shortXVel, Projectile.position.Y + 3f + shortYVel) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 199, 0f, 0f, 100, default, 0.1f); + Main.dust[dusting].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[dusting].velocity *= 0.05f; } } } @@ -83,23 +83,23 @@ namespace CalamityMod.Projectiles.Typeless public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item89, Projectile.position); - for (int num621 = 0; num621 < 5; num621++) + for (int j = 0; j < 5; j++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 199, 0f, 0f, 100, default, 1.5f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 199, 0f, 0f, 100, default, 1.5f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int k = 0; k < 10; k++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.5f); - Main.dust[num624].velocity *= 2f; + int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 2f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 1.5f); + Main.dust[dust2].velocity *= 2f; } } diff --git a/Projectiles/Typeless/GodSlayerBlaze.cs b/Projectiles/Typeless/GodSlayerBlaze.cs index d73aa76a73..0a85c77b34 100644 --- a/Projectiles/Typeless/GodSlayerBlaze.cs +++ b/Projectiles/Typeless/GodSlayerBlaze.cs @@ -27,19 +27,19 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { Lighting.AddLight(Projectile.Center, 0.5f, 0f, 0.75f); - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; + int timerCounter = 0; float scale = 0.7f; int dustType = Main.rand.NextBool() ? ModContent.DustType() : ModContent.DustType(); if (Projectile.ai[1] == 0f) @@ -47,17 +47,17 @@ namespace CalamityMod.Projectiles.Typeless scale = 1.5f; dustType = 173; } - while ((float)num462 < num461) + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-30, 31); - float num464 = (float)Main.rand.Next(-30, 31); - float num465 = (float)Main.rand.Next(9, 27); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, scale); - Dust dust = Main.dust[num467]; + float rand1 = (float)Main.rand.Next(-30, 31); + float rand2 = (float)Main.rand.Next(-30, 31); + float rand3 = (float)Main.rand.Next(9, 27); + float randAdjust = (float)Math.Sqrt((double)(rand1 * rand1 + rand2 * rand2)); + randAdjust = rand3 / randAdjust; + rand1 *= randAdjust; + rand2 *= randAdjust; + int dusty = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, scale); + Dust dust = Main.dust[dusty]; if (dustType != 173) dust.color = new Color(255, 255, 255, 0); dust.noGravity = true; @@ -65,9 +65,9 @@ namespace CalamityMod.Projectiles.Typeless dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = rand1; + dust.velocity.Y = rand2; + timerCounter++; } } diff --git a/Projectiles/Typeless/GodSlayerShrapnel.cs b/Projectiles/Typeless/GodSlayerShrapnel.cs index 839ded82f7..ca5cc26b24 100644 --- a/Projectiles/Typeless/GodSlayerShrapnel.cs +++ b/Projectiles/Typeless/GodSlayerShrapnel.cs @@ -54,8 +54,8 @@ namespace CalamityMod.Projectiles.Typeless Projectile.ai[1] = 1f; SoundEngine.PlaySound(SoundID.Item13, Projectile.position); } - int num199 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 0.5f); - Dust dust = Main.dust[num199]; + int godDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 0.5f); + Dust dust = Main.dust[godDust]; dust.position.X -= 2f; dust.position.Y += 2f; dust.scale += (float)Main.rand.Next(50) * 0.01f; @@ -63,8 +63,8 @@ namespace CalamityMod.Projectiles.Typeless dust.velocity.Y -= 2f; if (Main.rand.NextBool()) { - int num200 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 0.5f); - Dust dust2 = Main.dust[num200]; + int godDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, 0f, 0f, 100, default, 0.5f); + Dust dust2 = Main.dust[godDust2]; dust2.position.X -= 2f; dust2.position.Y += 2f; dust2.scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; diff --git a/Projectiles/Typeless/GoldenGunProj.cs b/Projectiles/Typeless/GoldenGunProj.cs index 585a64f68d..8f80048492 100644 --- a/Projectiles/Typeless/GoldenGunProj.cs +++ b/Projectiles/Typeless/GoldenGunProj.cs @@ -29,16 +29,16 @@ namespace CalamityMod.Projectiles.Typeless Projectile.localAI[0] += 1f; return; } - int num3; - for (int num586 = 0; num586 < 1; num586 = num3 + 1) + int inc; + for (int i = 0; i < 1; i = inc + 1) { - for (int num587 = 0; num587 < 6; num587 = num3 + 1) + for (int j = 0; j < 6; j = inc + 1) { - float num588 = Projectile.velocity.X / 6f * (float)num587; - float num589 = Projectile.velocity.Y / 6f * (float)num587; - int num590 = 6; - int num591 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num590, Projectile.position.Y + (float)num590), Projectile.width - num590 * 2, Projectile.height - num590 * 2, 170, 0f, 0f, 75, default, 1.2f); - Dust dust = Main.dust[num591]; + float dustX = Projectile.velocity.X / 6f * (float)j; + float dustY = Projectile.velocity.Y / 6f * (float)j; + int dustPosMod = 6; + int goldenDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)dustPosMod, Projectile.position.Y + (float)dustPosMod), Projectile.width - dustPosMod * 2, Projectile.height - dustPosMod * 2, 170, 0f, 0f, 75, default, 1.2f); + Dust dust = Main.dust[goldenDust]; if (Main.rand.NextBool()) { dust.alpha += 25; @@ -55,31 +55,31 @@ namespace CalamityMod.Projectiles.Typeless dust.velocity *= 0.3f; dust.velocity += Projectile.velocity * 0.5f; dust.position = Projectile.Center; - dust.position.X -= num588; - dust.position.Y -= num589; + dust.position.X -= dustX; + dust.position.Y -= dustY; dust.velocity *= 0.2f; - num3 = num587; + inc = j; } if (Main.rand.NextBool(4)) { - int num592 = 6; - int num593 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num592, Projectile.position.Y + (float)num592), Projectile.width - num592 * 2, Projectile.height - num592 * 2, 170, 0f, 0f, 75, default, 0.65f); - Dust dust = Main.dust[num593]; + int dustPosMod2 = 6; + int moreGoldenDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)dustPosMod2, Projectile.position.Y + (float)dustPosMod2), Projectile.width - dustPosMod2 * 2, Projectile.height - dustPosMod2 * 2, 170, 0f, 0f, 75, default, 0.65f); + Dust dust = Main.dust[moreGoldenDust]; dust.velocity *= 0.5f; dust.velocity += Projectile.velocity * 0.5f; } - num3 = num586; + inc = i; } } public override void OnKill(int timeLeft) { Projectile.velocity = Projectile.oldVelocity * 0.2f; - int num3; - for (int num362 = 0; num362 < 100; num362 = num3 + 1) + int inc; + for (int k = 0; k < 100; k = inc + 1) { - int num363 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 170, 0f, 0f, 75, default, 1.2f); - Dust dust = Main.dust[num363]; + int deathGoldenDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 170, 0f, 0f, 75, default, 1.2f); + Dust dust = Main.dust[deathGoldenDust]; if (Main.rand.NextBool()) { dust.alpha += 25; @@ -106,7 +106,7 @@ namespace CalamityMod.Projectiles.Typeless dust.velocity.X += (float)Main.rand.Next(-50, 51) * 0.015f; dust.velocity.Y += (float)Main.rand.Next(-50, 51) * 0.015f; dust.position = Projectile.Center; - num3 = num362; + inc = k; } } diff --git a/Projectiles/Typeless/HellfireExplosionFriendly2.cs b/Projectiles/Typeless/HellfireExplosionFriendly2.cs index f3933d15a9..52ecb09a68 100644 --- a/Projectiles/Typeless/HellfireExplosionFriendly2.cs +++ b/Projectiles/Typeless/HellfireExplosionFriendly2.cs @@ -34,38 +34,38 @@ namespace CalamityMod.Projectiles.Typeless SoundEngine.PlaySound(SoundID.Item20, Projectile.position); Projectile.localAI[0] += 1f; } - float num461 = 25f; + float projTimer = 25f; if (Projectile.ai[0] > 180f) { - num461 -= (Projectile.ai[0] - 180f) / 2f; + projTimer -= (Projectile.ai[0] - 180f) / 2f; } - if (num461 <= 0f) + if (projTimer <= 0f) { - num461 = 0f; + projTimer = 0f; Projectile.Kill(); } - num461 *= 0.7f; + projTimer *= 0.7f; Projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) + int timerCounter = 0; + while ((float)timerCounter < projTimer) { - float num463 = (float)Main.rand.Next(-15, 16); - float num464 = (float)Main.rand.Next(-15, 16); - float num465 = (float)Main.rand.Next(5, 12); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 0.75f); - Dust dust = Main.dust[num467]; + float rand1 = (float)Main.rand.Next(-15, 16); + float rand2 = (float)Main.rand.Next(-15, 16); + float rand3 = (float)Main.rand.Next(5, 12); + float randAdjust = (float)Math.Sqrt((double)(rand1 * rand1 + rand2 * rand2)); + randAdjust = rand3 / randAdjust; + rand1 *= randAdjust; + rand2 *= randAdjust; + int brimDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 0.75f); + Dust dust = Main.dust[brimDust]; dust.noGravity = true; dust.position.X = Projectile.Center.X; dust.position.Y = Projectile.Center.Y; dust.position.X += (float)Main.rand.Next(-10, 11); dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; + dust.velocity.X = rand1; + dust.velocity.Y = rand2; + timerCounter++; } } diff --git a/Projectiles/Typeless/HolyExplosion.cs b/Projectiles/Typeless/HolyExplosion.cs index 84cde429dc..4fc213896c 100644 --- a/Projectiles/Typeless/HolyExplosion.cs +++ b/Projectiles/Typeless/HolyExplosion.cs @@ -32,23 +32,23 @@ namespace CalamityMod.Projectiles.Typeless Projectile.height = 20; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 20; num621++) + for (int i = 0; i < 20; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int holyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); + Main.dust[holyDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[holyDust].scale = 0.5f; + Main.dust[holyDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 40; num623++) + for (int j = 0; j < 40; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int holyDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 3f); + Main.dust[holyDust2].noGravity = true; + Main.dust[holyDust2].velocity *= 5f; + holyDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); + Main.dust[holyDust2].velocity *= 2f; } } } diff --git a/Projectiles/Typeless/HolyExplosionSupreme.cs b/Projectiles/Typeless/HolyExplosionSupreme.cs index 1a370a4913..2c8c85e1ed 100644 --- a/Projectiles/Typeless/HolyExplosionSupreme.cs +++ b/Projectiles/Typeless/HolyExplosionSupreme.cs @@ -39,29 +39,29 @@ namespace CalamityMod.Projectiles.Typeless Projectile.height = 60; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int holyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[holyDust].velocity *= 3f; if (Projectile.ai[0] == 1) - Main.dust[num622].shader = GameShaders.Armor.GetSecondaryShader(Owner.cShield, Owner); + Main.dust[holyDust].shader = GameShaders.Armor.GetSecondaryShader(Owner.cShield, Owner); if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[holyDust].scale = 0.5f; + Main.dust[holyDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; + int holyDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 3f); + Main.dust[holyDust2].noGravity = true; + Main.dust[holyDust2].velocity *= 5f; if (Projectile.ai[0] == 1) - Main.dust[num624].shader = GameShaders.Armor.GetSecondaryShader(Owner.cShield, Owner); - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + Main.dust[holyDust2].shader = GameShaders.Armor.GetSecondaryShader(Owner.cShield, Owner); + holyDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f); + Main.dust[holyDust2].velocity *= 2f; if (Projectile.ai[0] == 1) - Main.dust[num624].shader = GameShaders.Armor.GetSecondaryShader(Owner.cShield, Owner); + Main.dust[holyDust2].shader = GameShaders.Armor.GetSecondaryShader(Owner.cShield, Owner); } } else @@ -74,26 +74,26 @@ namespace CalamityMod.Projectiles.Typeless Projectile.height = 60; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 8; num621++) + for (int i = 0; i < 8; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 181, 0f, 0f, 100, default, Main.rand.NextFloat(1.2f, 1.8f)); - Main.dust[num622].velocity *= 3f; - Main.dust[num622].shader = GameShaders.Armor.GetSecondaryShader(Owner.cShield, Owner); + int holyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 181, 0f, 0f, 100, default, Main.rand.NextFloat(1.2f, 1.8f)); + Main.dust[holyDust].velocity *= 3f; + Main.dust[holyDust].shader = GameShaders.Armor.GetSecondaryShader(Owner.cShield, Owner); if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[holyDust].scale = 0.5f; + Main.dust[holyDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 12; num623++) + for (int j = 0; j < 12; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 272, 0f, 0f, 100, default, 0.8f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - Main.dust[num624].shader = GameShaders.Armor.GetSecondaryShader(Owner.cShield, Owner); - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 226, 0f, 0f, 100, default, 0.6f); - Main.dust[num624].velocity *= 2f; - Main.dust[num624].shader = GameShaders.Armor.GetSecondaryShader(Owner.cShield, Owner); + int holyDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 272, 0f, 0f, 100, default, 0.8f); + Main.dust[holyDust2].noGravity = true; + Main.dust[holyDust2].velocity *= 5f; + Main.dust[holyDust2].shader = GameShaders.Armor.GetSecondaryShader(Owner.cShield, Owner); + holyDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 226, 0f, 0f, 100, default, 0.6f); + Main.dust[holyDust2].velocity *= 2f; + Main.dust[holyDust2].shader = GameShaders.Armor.GetSecondaryShader(Owner.cShield, Owner); } } } diff --git a/Projectiles/Typeless/HydrothermalSmoke.cs b/Projectiles/Typeless/HydrothermalSmoke.cs index be332b38ab..dc762df3e9 100644 --- a/Projectiles/Typeless/HydrothermalSmoke.cs +++ b/Projectiles/Typeless/HydrothermalSmoke.cs @@ -37,12 +37,12 @@ namespace CalamityMod.Projectiles.Typeless } if (Main.rand.NextBool(4)) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDust, 0f, 0f, 100, default, 1f); + int fieryDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDust, 0f, 0f, 100, default, 1f); if (Main.rand.NextBool(4)) { - Main.dust[num469].scale *= 0.35f; + Main.dust[fieryDust].scale *= 0.35f; } - Main.dust[num469].velocity *= 0f; + Main.dust[fieryDust].velocity *= 0f; } Vector2 goreVec = new Vector2(Projectile.position.X, Projectile.position.Y); diff --git a/Projectiles/Typeless/KelvinCatalystStar.cs b/Projectiles/Typeless/KelvinCatalystStar.cs index c225e89aca..7945edcc91 100644 --- a/Projectiles/Typeless/KelvinCatalystStar.cs +++ b/Projectiles/Typeless/KelvinCatalystStar.cs @@ -92,14 +92,14 @@ namespace CalamityMod.Projectiles.Typeless { SoundEngine.PlaySound(SoundID.Item27, Projectile.position); Projectile.ExpandHitboxBy(24); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int j = 0; j < dustAmt; j++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 67, vector7.X * 0.5f, vector7.Y * 0.5f, 100, default, 0.75f); - Main.dust[num228].noGravity = true; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; + rotate = rotate.RotatedBy((double)((float)(j - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; + Vector2 faceDirection = rotate - Projectile.Center; + int icyDust = Dust.NewDust(rotate + faceDirection, 0, 0, 67, faceDirection.X * 0.5f, faceDirection.Y * 0.5f, 100, default, 0.75f); + Main.dust[icyDust].noGravity = true; } } diff --git a/Projectiles/Typeless/LeviAmberDash.cs b/Projectiles/Typeless/LeviAmberDash.cs index 5ea69efa18..af40656994 100644 --- a/Projectiles/Typeless/LeviAmberDash.cs +++ b/Projectiles/Typeless/LeviAmberDash.cs @@ -40,8 +40,8 @@ namespace CalamityMod.Projectiles.Typeless target.velocity.X += 4.2f * Owner.direction; } target.AddBuff(BuffID.Wet, 300); - target.AddBuff(ModContent.BuffType(), 60); - SoundEngine.PlaySound(SoundID.Item85 with { Volume = 0.6f, PitchVariance = 0.4f }, Projectile.Center); + target.AddBuff(ModContent.BuffType(), 180); + SoundEngine.PlaySound(SoundID.Item85 with { Volume = 0.4f, PitchVariance = 0.4f }, Projectile.Center); for (int i = 0; i < 3; ++i) { int bloodLifetime = Main.rand.Next(20, 26); diff --git a/Projectiles/Typeless/LunicBeam.cs b/Projectiles/Typeless/LunicBeam.cs index 626372112e..cdcbcd0404 100644 --- a/Projectiles/Typeless/LunicBeam.cs +++ b/Projectiles/Typeless/LunicBeam.cs @@ -25,13 +25,10 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { - float num29 = 5f; - float num30 = 150f; + float aiTrack = 5f; float scaleFactor = 6f; - Vector2 value7 = new Vector2(10f, 20f); - float num31 = 1f; - int num32 = 3 * Projectile.MaxUpdates; - int num33 = Utils.SelectRandom(Main.rand, new int[] + Vector2 dustRotation = new Vector2(10f, 20f); + int dustType = Utils.SelectRandom(Main.rand, new int[] { 246, 244, @@ -39,7 +36,7 @@ namespace CalamityMod.Projectiles.Typeless 262, 247 }); - int num34 = 259; + int solarDustType = 259; if (Projectile.ai[1] == 0f) { Projectile.ai[1] = 1f; @@ -47,38 +44,38 @@ namespace CalamityMod.Projectiles.Typeless } else if (Projectile.ai[1] == 1f && Projectile.owner == Main.myPlayer) { - int num35 = -1; - float num36 = num30; - for (int num37 = 0; num37 < Main.maxNPCs; num37++) + int targetID = -1; + float hitDistance = 150f; + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num37].active && Main.npc[num37].CanBeChasedBy(Projectile, false)) + if (Main.npc[i].active && Main.npc[i].CanBeChasedBy(Projectile, false)) { - Vector2 center3 = Main.npc[num37].Center; - float num38 = Vector2.Distance(center3, Projectile.Center); - if (num38 < num36 && num35 == -1 && Collision.CanHitLine(Projectile.Center, 1, 1, center3, 1, 1)) + Vector2 targetCenter = Main.npc[i].Center; + float targetDist = Vector2.Distance(targetCenter, Projectile.Center); + if (targetDist < hitDistance && targetID == -1 && Collision.CanHitLine(Projectile.Center, 1, 1, targetCenter, 1, 1)) { - num36 = num38; - num35 = num37; + hitDistance = targetDist; + targetID = i; } } } - if (num36 < 8f) + if (hitDistance < 8f) { Projectile.Kill(); return; } - if (num35 != -1) + if (targetID != -1) { - Projectile.ai[1] = num29 + 1f; - Projectile.ai[0] = (float)num35; + Projectile.ai[1] = aiTrack + 1f; + Projectile.ai[0] = (float)targetID; Projectile.netUpdate = true; } } - else if (Projectile.ai[1] > num29) + else if (Projectile.ai[1] > aiTrack) { Projectile.ai[1] += 1f; - int num39 = (int)Projectile.ai[0]; - if (!Main.npc[num39].active || !Main.npc[num39].CanBeChasedBy(Projectile, false)) + int npcTrack = (int)Projectile.ai[0]; + if (!Main.npc[npcTrack].active || !Main.npc[npcTrack].CanBeChasedBy(Projectile, false)) { Projectile.ai[1] = 1f; Projectile.ai[0] = 0f; @@ -87,25 +84,24 @@ namespace CalamityMod.Projectiles.Typeless else { Projectile.velocity.ToRotation(); - Vector2 vector6 = Main.npc[num39].Center - Projectile.Center; - if (vector6.Length() < 20f) + Vector2 npcDirection = Main.npc[npcTrack].Center - Projectile.Center; + if (npcDirection.Length() < 20f) { Projectile.Kill(); return; } - if (vector6 != Vector2.Zero) + if (npcDirection != Vector2.Zero) { - vector6.Normalize(); - vector6 *= scaleFactor; + npcDirection.Normalize(); + npcDirection *= scaleFactor; } - float num40 = 30f; - Projectile.velocity = (Projectile.velocity * (num40 - 1f) + vector6) / num40; + Projectile.velocity = (Projectile.velocity * 29f + npcDirection) / 30f; } } - if (Projectile.ai[1] >= 1f && Projectile.ai[1] < num29) + if (Projectile.ai[1] >= 1f && Projectile.ai[1] < aiTrack) { Projectile.ai[1] += 1f; - if (Projectile.ai[1] == num29) + if (Projectile.ai[1] == aiTrack) { Projectile.ai[1] = 1f; } @@ -117,83 +113,81 @@ namespace CalamityMod.Projectiles.Typeless } else if (Projectile.alpha == 0) { - for (int num41 = 0; num41 < 2; num41++) + for (int j = 0; j < 2; j++) { - Vector2 value8 = Vector2.UnitX * -30f; - value8 = -Vector2.UnitY.RotatedBy((double)(Projectile.localAI[0] * 0.1308997f + (float)num41 * 3.14159274f), default) * value7 - Projectile.rotation.ToRotationVector2() * 10f; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, num34, 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = num31; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8 + Projectile.velocity * 2f; - Main.dust[num42].velocity = Vector2.Normalize(Projectile.Center + Projectile.velocity * 2f * 8f - Main.dust[num42].position) * 2f + Projectile.velocity * 2f; + Vector2 rotateFirstDust = Vector2.UnitX * -30f; + rotateFirstDust = -Vector2.UnitY.RotatedBy((double)(Projectile.localAI[0] * 0.1308997f + (float)j * 3.14159274f), default) * dustRotation - Projectile.rotation.ToRotationVector2() * 10f; + int solarDust = Dust.NewDust(Projectile.Center, 0, 0, solarDustType, 0f, 0f, 160, default, 1f); + Main.dust[solarDust].scale = 1f; + Main.dust[solarDust].noGravity = true; + Main.dust[solarDust].position = Projectile.Center + rotateFirstDust + Projectile.velocity * 2f; + Main.dust[solarDust].velocity = Vector2.Normalize(Projectile.Center + Projectile.velocity * 2f * 8f - Main.dust[solarDust].position) * 2f + Projectile.velocity * 2f; } } if (Main.rand.NextBool(12)) { - for (int num43 = 0; num43 < 1; num43++) + for (int k = 0; k < 1; k++) { - Vector2 value9 = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num44 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 1f); - Main.dust[num44].velocity *= 0.1f; - Main.dust[num44].position = Projectile.Center + value9 * (float)Projectile.width / 2f + Projectile.velocity * 2f; - Main.dust[num44].fadeIn = 0.9f; + Vector2 rotateSecondDust = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)Projectile.velocity.ToRotation(), default); + int smokyDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 1f); + Main.dust[smokyDust].velocity *= 0.1f; + Main.dust[smokyDust].position = Projectile.Center + rotateSecondDust * (float)Projectile.width / 2f + Projectile.velocity * 2f; + Main.dust[smokyDust].fadeIn = 0.9f; } } if (Main.rand.NextBool(64)) { - for (int num45 = 0; num45 < 1; num45++) + for (int l = 0; l < 1; l++) { - Vector2 value10 = -Vector2.UnitX.RotatedByRandom(0.39269909262657166).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num46 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 155, default, 0.8f); - Main.dust[num46].velocity *= 0.3f; - Main.dust[num46].position = Projectile.Center + value10 * (float)Projectile.width / 2f; + Vector2 rotateThirdDust = -Vector2.UnitX.RotatedByRandom(0.39269909262657166).RotatedBy((double)Projectile.velocity.ToRotation(), default); + int smokyDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 155, default, 0.8f); + Main.dust[smokyDust2].velocity *= 0.3f; + Main.dust[smokyDust2].position = Projectile.Center + rotateThirdDust * (float)Projectile.width / 2f; if (Main.rand.NextBool()) { - Main.dust[num46].fadeIn = 1.4f; + Main.dust[smokyDust2].fadeIn = 1.4f; } } } if (Main.rand.NextBool(4)) { - for (int num47 = 0; num47 < 2; num47++) + for (int m = 0; m < 2; m++) { - Vector2 value11 = -Vector2.UnitX.RotatedByRandom(0.78539818525314331).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num48 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, num33, 0f, 0f, 0, default, 1.2f); - Main.dust[num48].velocity *= 0.3f; - Main.dust[num48].noGravity = true; - Main.dust[num48].position = Projectile.Center + value11 * (float)Projectile.width / 2f; + Vector2 rotateFourthDust = -Vector2.UnitX.RotatedByRandom(0.78539818525314331).RotatedBy((double)Projectile.velocity.ToRotation(), default); + int randomDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, 1.2f); + Main.dust[randomDust].velocity *= 0.3f; + Main.dust[randomDust].noGravity = true; + Main.dust[randomDust].position = Projectile.Center + rotateFourthDust * (float)Projectile.width / 2f; if (Main.rand.NextBool()) { - Main.dust[num48].fadeIn = 1.4f; + Main.dust[randomDust].fadeIn = 1.4f; } } } if (Main.rand.NextBool(3)) { - Vector2 value13 = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int num50 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, num34, 0f, 0f, 100, default, 1f); - Main.dust[num50].velocity *= 0.3f; - Main.dust[num50].position = Projectile.Center + value13 * (float)Projectile.width / 2f; - Main.dust[num50].fadeIn = 1.2f; - Main.dust[num50].scale = 1.5f; - Main.dust[num50].noGravity = true; + Vector2 rotateFifthDust = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)Projectile.velocity.ToRotation(), default); + int solarDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, solarDustType, 0f, 0f, 100, default, 1f); + Main.dust[solarDust2].velocity *= 0.3f; + Main.dust[solarDust2].position = Projectile.Center + rotateFifthDust * (float)Projectile.width / 2f; + Main.dust[solarDust2].fadeIn = 1.2f; + Main.dust[solarDust2].scale = 1.5f; + Main.dust[solarDust2].noGravity = true; } Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.25f / 255f); - for (int num151 = 0; num151 < 3; num151++) + for (int r = 0; r < 3; r++) { - int num154 = 14; - int num155 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - num154 * 2, Projectile.height - num154 * 2, 259, 0f, 0f, 100, default, 1.35f); - Main.dust[num155].noGravity = true; - Main.dust[num155].velocity *= 0.1f; - Main.dust[num155].velocity += Projectile.velocity * 0.5f; + int moreSolarDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - 28, Projectile.height - 28, 259, 0f, 0f, 100, default, 1.35f); + Main.dust[moreSolarDust].noGravity = true; + Main.dust[moreSolarDust].velocity *= 0.1f; + Main.dust[moreSolarDust].velocity += Projectile.velocity * 0.5f; } if (Main.rand.NextBool(8)) { - int num156 = 16; - int num157 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - num156 * 2, Projectile.height - num156 * 2, 259, 0f, 0f, 100, default, 1f); - Main.dust[num157].velocity *= 0.25f; - Main.dust[num157].noGravity = true; - Main.dust[num157].velocity += Projectile.velocity * 0.5f; + int mostSolarDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - 32, Projectile.height - 32, 259, 0f, 0f, 100, default, 1f); + Main.dust[mostSolarDust].velocity *= 0.25f; + Main.dust[mostSolarDust].noGravity = true; + Main.dust[mostSolarDust].velocity += Projectile.velocity * 0.5f; } } @@ -210,7 +204,7 @@ namespace CalamityMod.Projectiles.Typeless public override void OnKill(int timeLeft) { - int num47 = Utils.SelectRandom(Main.rand, new int[] + int m = Utils.SelectRandom(Main.rand, new int[] { 246, 244, @@ -218,14 +212,11 @@ namespace CalamityMod.Projectiles.Typeless 262, 247 }); - int num48 = 259; - int num49 = 259; + int randomDust = 259; int height = 50; - float num50 = 1.7f; - float num51 = 0.8f; - float num52 = 2f; - Vector2 value3 = (Projectile.rotation - 1.57079637f).ToRotationVector2(); - Vector2 value4 = value3 * Projectile.velocity.Length() * (float)Projectile.MaxUpdates; + float solarDust2 = 1.7f; + Vector2 dustRotate = (Projectile.rotation - 1.57079637f).ToRotationVector2(); + Vector2 dustVel = dustRotate * Projectile.velocity.Length() * (float)Projectile.MaxUpdates; SoundEngine.PlaySound(SoundID.Item14, Projectile.position); Projectile.position = Projectile.Center; Projectile.width = Projectile.height = height; @@ -235,10 +226,10 @@ namespace CalamityMod.Projectiles.Typeless Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; Projectile.Damage(); - int num3; - for (int num53 = 0; num53 < 40; num53 = num3 + 1) + int inc; + for (int j = 0; j < 40; j = inc + 1) { - num47 = Utils.SelectRandom(Main.rand, new int[] + m = Utils.SelectRandom(Main.rand, new int[] { 246, 244, @@ -246,30 +237,30 @@ namespace CalamityMod.Projectiles.Typeless 262, 247 }); - int num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num47, 0f, 0f, 200, default, num50); - Dust dust = Main.dust[num54]; + int orangeDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, m, 0f, 0f, 200, default, solarDust2); + Dust dust = Main.dust[orangeDust]; dust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; dust.noGravity = true; dust.velocity *= 3f; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num48, 0f, 0f, 100, default, num51); + dust.velocity += dustVel * Main.rand.NextFloat(); + orangeDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDust, 0f, 0f, 100, default, 0.8f); dust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; dust.velocity *= 2f; dust.noGravity = true; dust.fadeIn = 1f; dust.color = Color.Crimson * 0.5f; - dust.velocity += value4 * Main.rand.NextFloat(); - num3 = num53; + dust.velocity += dustVel * Main.rand.NextFloat(); + inc = j; } - for (int num55 = 0; num55 < 20; num55 = num3 + 1) + for (int k = 0; k < 20; k = inc + 1) { - int num56 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num49, 0f, 0f, 0, default, num52); - Dust dust = Main.dust[num56]; + int deathSolar = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 259, 0f, 0f, 0, default, 2f); + Dust dust = Main.dust[deathSolar]; dust.position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 3f; dust.noGravity = true; dust.velocity *= 0.5f; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); - num3 = num55; + dust.velocity += dustVel * (0.6f + 0.6f * Main.rand.NextFloat()); + inc = k; } } } diff --git a/Projectiles/Typeless/Nanotech.cs b/Projectiles/Typeless/Nanotech.cs index 693b74c32a..616927e7de 100644 --- a/Projectiles/Typeless/Nanotech.cs +++ b/Projectiles/Typeless/Nanotech.cs @@ -56,27 +56,27 @@ namespace CalamityMod.Projectiles.Typeless public override void OnKill(int timeLeft) { - int num3; - for (int num191 = 0; num191 < 2; num191 = num3 + 1) + int inc; + for (int i = 0; i < 2; i = inc + 1) { - int num192 = (int)(10f * Projectile.scale); - int num193 = Dust.NewDust(Projectile.Center - Vector2.One * (float)num192, num192 * 2, num192 * 2, 107, 0f, 0f, 0, default, 1f); - Dust dust20 = Main.dust[num193]; - Vector2 value8 = Vector2.Normalize(dust20.position - Projectile.Center); - dust20.position = Projectile.Center + value8 * (float)num192 * Projectile.scale; - if (num191 < 30) + int dustScale = (int)(10f * Projectile.scale); + int greenDust = Dust.NewDust(Projectile.Center - Vector2.One * (float)dustScale, dustScale * 2, dustScale * 2, 107, 0f, 0f, 0, default, 1f); + Dust nanoDust = Main.dust[greenDust]; + Vector2 dustDirection = Vector2.Normalize(nanoDust.position - Projectile.Center); + nanoDust.position = Projectile.Center + dustDirection * (float)dustScale * Projectile.scale; + if (i < 30) { - dust20.velocity = value8 * dust20.velocity.Length(); + nanoDust.velocity = dustDirection * nanoDust.velocity.Length(); } else { - dust20.velocity = value8 * (float)Main.rand.Next(45, 91) / 10f; + nanoDust.velocity = dustDirection * (float)Main.rand.Next(45, 91) / 10f; } - dust20.color = Main.hslToRgb((float)(0.40000000596046448 + Main.rand.NextDouble() * 0.20000000298023224), 0.9f, 0.5f); - dust20.color = Color.Lerp(dust20.color, Color.White, 0.3f); - dust20.noGravity = true; - dust20.scale = 0.7f; - num3 = num191; + nanoDust.color = Main.hslToRgb((float)(0.40000000596046448 + Main.rand.NextDouble() * 0.20000000298023224), 0.9f, 0.5f); + nanoDust.color = Color.Lerp(nanoDust.color, Color.White, 0.3f); + nanoDust.noGravity = true; + nanoDust.scale = 0.7f; + inc = i; } } } diff --git a/Projectiles/Typeless/PauldronDash.cs b/Projectiles/Typeless/PauldronDash.cs index 6ea9a1883e..6a17b3d5f8 100644 --- a/Projectiles/Typeless/PauldronDash.cs +++ b/Projectiles/Typeless/PauldronDash.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Typeless public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(BuffID.OnFire3, 240); - target.AddBuff(ModContent.BuffType(), 240); + target.AddBuff(ModContent.BuffType(), 300); SoundEngine.PlaySound(SoundID.DD2_ExplosiveTrapExplode with { Volume = 0.6f, PitchVariance = 0.4f }, Projectile.Center); for (int i = 0; i <= 8; i++) diff --git a/Projectiles/Typeless/PendantProjectile1.cs b/Projectiles/Typeless/PendantProjectile1.cs index 6599962449..35ef3774a6 100644 --- a/Projectiles/Typeless/PendantProjectile1.cs +++ b/Projectiles/Typeless/PendantProjectile1.cs @@ -22,12 +22,12 @@ namespace CalamityMod.Projectiles.Typeless { Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.2f / 255f, (255 - Projectile.alpha) * 0.2f / 255f); Projectile.rotation += Projectile.velocity.X * 1.25f; - for (int num457 = 0; num457 < 5; num457++) + for (int i = 0; i < 5; i++) { - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 187, 0f, 0f, 100, default, 0.6f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 187, 0f, 0f, 100, default, 0.6f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0.5f; + Main.dust[dust].velocity += Projectile.velocity * 0.1f; } } diff --git a/Projectiles/Typeless/PendantProjectile2.cs b/Projectiles/Typeless/PendantProjectile2.cs index d75992ca46..195d600e90 100644 --- a/Projectiles/Typeless/PendantProjectile2.cs +++ b/Projectiles/Typeless/PendantProjectile2.cs @@ -22,12 +22,12 @@ namespace CalamityMod.Projectiles.Typeless { Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.2f / 255f, (255 - Projectile.alpha) * 0.2f / 255f); Projectile.rotation += Projectile.velocity.X * 1.25f; - for (int num457 = 0; num457 < 5; num457++) + for (int i = 0; i < 5; i++) { - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 187, 0f, 0f, 100, default, 0.6f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 187, 0f, 0f, 100, default, 0.6f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0.5f; + Main.dust[dust].velocity += Projectile.velocity * 0.1f; } } diff --git a/Projectiles/Typeless/PendantProjectile3.cs b/Projectiles/Typeless/PendantProjectile3.cs index 355e6982d1..982005b4d2 100644 --- a/Projectiles/Typeless/PendantProjectile3.cs +++ b/Projectiles/Typeless/PendantProjectile3.cs @@ -24,12 +24,12 @@ namespace CalamityMod.Projectiles.Typeless Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.2f / 255f, (255 - Projectile.alpha) * 0.2f / 255f); Projectile.rotation += Projectile.velocity.X * 1.25f; - for (int num457 = 0; num457 < 5; num457++) + for (int i = 0; i < 5; i++) { - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 187, 0f, 0f, 100, default, 0.6f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; + int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 187, 0f, 0f, 100, default, 0.6f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0.5f; + Main.dust[dust].velocity += Projectile.velocity * 0.1f; } } diff --git a/Projectiles/Typeless/PoisonousSeawater.cs b/Projectiles/Typeless/PoisonousSeawater.cs index 20f5460100..fe72306c83 100644 --- a/Projectiles/Typeless/PoisonousSeawater.cs +++ b/Projectiles/Typeless/PoisonousSeawater.cs @@ -36,14 +36,14 @@ namespace CalamityMod.Projectiles.Typeless { randomDust = 33; } - for (int num468 = 0; num468 < 2; num468++) + for (int i = 0; i < 2; i++) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDust, 0f, 0f, 100, default, 1f); + int seaDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDust, 0f, 0f, 100, default, 1f); if (randomDust == 89) { - Main.dust[num469].scale *= 0.35f; + Main.dust[seaDust].scale *= 0.35f; } - Main.dust[num469].velocity *= 0f; + Main.dust[seaDust].velocity *= 0f; } } diff --git a/Projectiles/Typeless/RelicOfDeliveranceSpear.cs b/Projectiles/Typeless/RelicOfDeliveranceSpear.cs index 45296bebd8..c6d46408fd 100644 --- a/Projectiles/Typeless/RelicOfDeliveranceSpear.cs +++ b/Projectiles/Typeless/RelicOfDeliveranceSpear.cs @@ -133,7 +133,7 @@ namespace CalamityMod.Projectiles.Typeless } SoundEngine.PlaySound(SoundID.DD2_DarkMageHealImpact, Projectile.Center); } - player.direction = (Math.Cos(Projectile.rotation) > 0).ToDirectionInt(); + player.ChangeDir((Math.Cos(Projectile.rotation) > 0).ToDirectionInt()); } } else @@ -180,7 +180,7 @@ namespace CalamityMod.Projectiles.Typeless { player.mount.Dismount(player); } - player.direction = (Projectile.velocity.X > 0).ToDirectionInt(); + player.ChangeDir((int)Projectile.velocity.X); // Generate dust if (Projectile.ai[0] % DustSpawnInterval == DustSpawnInterval - 1f) { diff --git a/Projectiles/Typeless/SkyFlareFriendly.cs b/Projectiles/Typeless/SkyFlareFriendly.cs index ac0d4505c8..3d69cbc6ff 100644 --- a/Projectiles/Typeless/SkyFlareFriendly.cs +++ b/Projectiles/Typeless/SkyFlareFriendly.cs @@ -59,23 +59,23 @@ namespace CalamityMod.Projectiles.Typeless Projectile.width = Projectile.height = 200; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 4; num621++) + for (int i = 0; i < 4; i++) { - int num622 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int skyDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[skyDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[skyDust].scale = 0.5f; + Main.dust[skyDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 12; num623++) + for (int j = 0; j < 12; j++) { - int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int skyDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 3f); + Main.dust[skyDust2].noGravity = true; + Main.dust[skyDust2].velocity *= 5f; + skyDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[skyDust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) diff --git a/Projectiles/Typeless/StandingFire.cs b/Projectiles/Typeless/StandingFire.cs index 6774138de3..b1c3b82708 100644 --- a/Projectiles/Typeless/StandingFire.cs +++ b/Projectiles/Typeless/StandingFire.cs @@ -58,8 +58,8 @@ namespace CalamityMod.Projectiles.Typeless Projectile.ai[1] = 1f; SoundEngine.PlaySound(SoundID.Item13, Projectile.position); } - int num199 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); - Dust dust = Main.dust[num199]; + int brimDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); + Dust dust = Main.dust[brimDust]; dust.position.X -= 2f; dust.position.Y += 2f; dust.scale += (float)Main.rand.Next(50) * 0.01f; @@ -67,13 +67,13 @@ namespace CalamityMod.Projectiles.Typeless dust.velocity.Y -= 2f; if (Main.rand.NextBool()) { - int num200 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); - Dust dust2 = Main.dust[num200]; - dust2.position.X -= 2f; - dust2.position.Y += 2f; - dust2.scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; - dust2.noGravity = true; - dust2.velocity *= 0.1f; + int brimDusty = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); + Dust dusty = Main.dust[brimDusty]; + dusty.position.X -= 2f; + dusty.position.Y += 2f; + dusty.scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; + dusty.noGravity = true; + dusty.velocity *= 0.1f; } if ((double)Projectile.velocity.Y < 0.25 && (double)Projectile.velocity.Y > 0.15) { diff --git a/Projectiles/Typeless/StickyFeatherAero.cs b/Projectiles/Typeless/StickyFeatherAero.cs index 52ad50eec1..a5092d1b74 100644 --- a/Projectiles/Typeless/StickyFeatherAero.cs +++ b/Projectiles/Typeless/StickyFeatherAero.cs @@ -41,23 +41,23 @@ namespace CalamityMod.Projectiles.Typeless Projectile.height = 50; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int num621 = 0; num621 < 15; num621++) + for (int i = 0; i < 15; i++) { - int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 206, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; + int blueDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 206, 0f, 0f, 100, default, 1.2f); + Main.dust[blueDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[blueDust].scale = 0.5f; + Main.dust[blueDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 206, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 206, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; + int blueDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 206, 0f, 0f, 100, default, 1.7f); + Main.dust[blueDust2].noGravity = true; + Main.dust[blueDust2].velocity *= 5f; + blueDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 206, 0f, 0f, 100, default, 1f); + Main.dust[blueDust2].velocity *= 2f; } } } diff --git a/Projectiles/Typeless/SulphuricAcidBubbleFriendly.cs b/Projectiles/Typeless/SulphuricAcidBubbleFriendly.cs index 7882562788..c636b151e4 100644 --- a/Projectiles/Typeless/SulphuricAcidBubbleFriendly.cs +++ b/Projectiles/Typeless/SulphuricAcidBubbleFriendly.cs @@ -102,9 +102,9 @@ namespace CalamityMod.Projectiles.Typeless public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + int framing = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; + int y6 = framing * Projectile.frame; + Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } @@ -135,17 +135,17 @@ namespace CalamityMod.Projectiles.Typeless Projectile.width = Projectile.height = 60; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - int num3; - for (int num246 = 0; num246 < 25; num246 = num3 + 1) + int inc; + for (int i = 0; i < 25; i = inc + 1) { - int num247 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 0, default, 1f); - Main.dust[num247].position = (Main.dust[num247].position + Projectile.position) / 2f; - Main.dust[num247].velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - Main.dust[num247].velocity.Normalize(); - Dust dust = Main.dust[num247]; + int toxicDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 0, default, 1f); + Main.dust[toxicDust].position = (Main.dust[toxicDust].position + Projectile.position) / 2f; + Main.dust[toxicDust].velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + Main.dust[toxicDust].velocity.Normalize(); + Dust dust = Main.dust[toxicDust]; dust.velocity *= (float)Main.rand.Next(1, 30) * 0.1f; - Main.dust[num247].alpha = Projectile.alpha; - num3 = num246; + Main.dust[toxicDust].alpha = Projectile.alpha; + inc = i; } } } diff --git a/Projectiles/Typeless/TarraEnergy.cs b/Projectiles/Typeless/TarraEnergy.cs index a4270a7ada..dbcbf4179d 100644 --- a/Projectiles/Typeless/TarraEnergy.cs +++ b/Projectiles/Typeless/TarraEnergy.cs @@ -32,18 +32,18 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { - for (int num136 = 0; num136 < 2; num136++) + for (int i = 0; i < 2; i++) { - float x2 = Projectile.position.X - Projectile.velocity.X / 10f * (float)num136; - float y2 = Projectile.position.Y - Projectile.velocity.Y / 10f * (float)num136; + float x2 = Projectile.position.X - Projectile.velocity.X / 10f * (float)i; + float y2 = Projectile.position.Y - Projectile.velocity.Y / 10f * (float)i; Vector2 dspeed = Projectile.velocity * Main.rand.NextFloat(0.7f, 0.4f); - int num137 = Dust.NewDust(new Vector2(x2, y2), 1, 1, 107, 0f, 0f, 0, default, 1f); - Main.dust[num137].alpha = Projectile.alpha; - Main.dust[num137].position.X = x2; - Main.dust[num137].position.Y = y2; - Main.dust[num137].velocity = dspeed; - Main.dust[num137].noGravity = true; - Main.dust[num137].noLight = true; + int greenDust = Dust.NewDust(new Vector2(x2, y2), 1, 1, 107, 0f, 0f, 0, default, 1f); + Main.dust[greenDust].alpha = Projectile.alpha; + Main.dust[greenDust].position.X = x2; + Main.dust[greenDust].position.Y = y2; + Main.dust[greenDust].velocity = dspeed; + Main.dust[greenDust].noGravity = true; + Main.dust[greenDust].noLight = true; } if (Projectile.timeLeft < 170) diff --git a/Projectiles/Typeless/VoidFieldGenerator.cs b/Projectiles/Typeless/VoidFieldGenerator.cs index 50350b04b1..caa0c96e8e 100644 --- a/Projectiles/Typeless/VoidFieldGenerator.cs +++ b/Projectiles/Typeless/VoidFieldGenerator.cs @@ -1,10 +1,10 @@ using CalamityMod.CalPlayer; -using CalamityMod.Particles.Metaballs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using CalamityMod.Graphics.Metaballs; namespace CalamityMod.Projectiles.Typeless { @@ -12,7 +12,7 @@ namespace CalamityMod.Projectiles.Typeless { public new string LocalizationCategory => "Projectiles.Typeless"; public bool start = true; - public BaseFusableParticleSet.FusableParticle voidaura; + public StreamGougeMetaball.CosmicParticle VoidAura; public override void SetDefaults() { @@ -78,14 +78,14 @@ namespace CalamityMod.Projectiles.Typeless } } - if (voidaura == null) + if (VoidAura == null) { - voidaura = FusableParticleManager.GetParticleSetByType()?.SpawnParticle(Projectile.Center, 500); + VoidAura = VoidGeneratorMetaball.SpawnParticle(Projectile.Center, Vector2.Zero, 120f); } else { - voidaura.Center = Projectile.Center; - voidaura.Size = 500; + VoidAura.Center = Projectile.Center; + VoidAura.Size = 120f; } } public override bool? CanCutTiles() => false; diff --git a/Projectiles/VanillaProjectileOverrides/ChlorophyteCrystalAI.cs b/Projectiles/VanillaProjectileOverrides/ChlorophyteCrystalAI.cs index 2c5f5d5c76..ee06064842 100644 --- a/Projectiles/VanillaProjectileOverrides/ChlorophyteCrystalAI.cs +++ b/Projectiles/VanillaProjectileOverrides/ChlorophyteCrystalAI.cs @@ -52,6 +52,9 @@ namespace CalamityMod.Projectiles.VanillaProjectileOverrides if (Main.myPlayer == projectile.owner) { int pulseDamage = (int)Main.player[projectile.owner].GetBestClassDamage().ApplyTo(ChlorophyteArmorSetChange.BaseDamageToEnemies); + if (owner.Calamity().oldFashioned) + pulseDamage = CalamityUtils.CalcOldFashionedDamage(pulseDamage); + Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, Vector2.Zero, ModContent.ProjectileType(), pulseDamage, 0f, projectile.owner); } } diff --git a/Projectiles/VanillaProjectileOverrides/HornetMinionAI.cs b/Projectiles/VanillaProjectileOverrides/HornetMinionAI.cs index 3fd48019ba..5783b083e6 100644 --- a/Projectiles/VanillaProjectileOverrides/HornetMinionAI.cs +++ b/Projectiles/VanillaProjectileOverrides/HornetMinionAI.cs @@ -1,117 +1,136 @@ -using Terraria; -using Terraria.ID; +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; namespace CalamityMod.Projectiles.VanillaProjectileOverrides { public static class HornetMinionAI { - public static bool DoHornetMinionAI(Projectile projectile) + // Shorter range when the minion has no target yet: 40 tiles + private const float MinEnemyDistanceDetection = 640f; + + // Longer range when a target is already acquired: 75 tiles + private const float MaxEnemyDistanceDetection = 1200f; + + private static float EnemyDistanceDetection { get => Target is null ? MinEnemyDistanceDetection : MaxEnemyDistanceDetection; } + + private const int FireRate = 40; + private const float ProjectileVelocity = 20f; + private static NPC Target { get; set; } + + public static bool DoHornetMinionAI(Projectile proj) { - Player owner = Main.player[projectile.owner]; - ref float timerToShoot = ref projectile.ai[0]; - projectile.aiStyle = -1; + Player owner = Main.player[proj.owner]; + Target = owner.Center.MinionHoming(EnemyDistanceDetection, owner, CalamityPlayer.areThereAnyDamnBosses); + ref float shootTimer = ref proj.ai[0]; - float enemyDistanceDetection = 1200f; - float fireRate = 90f; - float projVelocity = 15f; + CheckMinionExistence(proj, owner); + DoAnimation(proj); + DecideDirection(proj); + FollowPlayer(proj, owner); + proj.MinionAntiClump(); - NPC target = projectile.Center.MinionHoming(enemyDistanceDetection, owner); + proj.rotation = MathHelper.ToRadians(proj.velocity.X * 2f); - if (target is not null) + if (Target is not null) { - timerToShoot++; - if (timerToShoot >= fireRate && Main.myPlayer == projectile.owner) + shootTimer += Main.rand.NextBool(30) ? 2 : 1; + if (shootTimer >= FireRate - (owner.strongBees ? 10 : 0) && proj.owner == Main.myPlayer) { - int stinger = Projectile.NewProjectile(projectile.GetSource_FromThis(), - projectile.Center, - CalamityUtils.CalculatePredictiveAimToTarget(projectile.Center, target.Center, target.velocity, projVelocity), - ProjectileID.HornetStinger, - projectile.damage, - projectile.knockBack, - owner.whoAmI); + Vector2 toTargetDirection = CalamityUtils.CalculatePredictiveAimToTarget(proj.Center, Target, ProjectileVelocity); - if (Main.projectile.IndexInRange(stinger)) - Main.projectile[stinger].originalDamage = projectile.originalDamage; - - timerToShoot = 0f; - projectile.netUpdate = true; + Projectile.NewProjectileDirect(proj.GetSource_FromThis(), + proj.Center, + toTargetDirection, + ModContent.ProjectileType(), + proj.damage, + proj.knockBack, + proj.owner); + + proj.velocity -= toTargetDirection.SafeNormalize(Vector2.Zero); + + if (!Main.dedServ) + { + for (int i = 0; i < 15; i++) + { + Dust shootDust = Dust.NewDustPerfect(proj.Center + toTargetDirection.SafeNormalize(Vector2.Zero) * proj.Size / 2f, DustID.JungleGrass, toTargetDirection.SafeNormalize(Vector2.Zero).RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(3f, 6f)); + shootDust.noGravity = true; + shootDust.noLight = true; + shootDust.noLightEmittence = true; + } + + SoundEngine.PlaySound(SoundID.Item17, proj.Center); + } + + shootTimer = 0f; + SyncVariables(proj); } } - CheckMinionExistence(owner, projectile); - - DoAnimation(projectile); - - DecideDirection(target, projectile); - - FollowPlayer(owner, projectile, enemyDistanceDetection); - - projectile.MinionAntiClump(.5f); - - // Just so the minion doesn't stay weirdly still. - if (projectile.velocity == Vector2.Zero) - projectile.velocity += new Vector2(Main.rand.NextFloat(-5f, 5f), Main.rand.NextFloat(-5f, 5f)); - return false; } - #region Methods + #region AI Methods - public static void CheckMinionExistence(Player owner, Projectile projectile) + private static void CheckMinionExistence(Projectile proj, Player owner) { - owner.AddBuff(BuffID.HornetMinion, 1); - if (projectile.type != ProjectileID.Hornet) + owner.AddBuff(BuffID.HornetMinion, 2); + if (proj.type != ProjectileID.Hornet) return; if (owner.dead) owner.hornetMinion = false; if (owner.hornetMinion) - projectile.timeLeft = 2; + proj.timeLeft = 2; } - public static void DoAnimation(Projectile projectile) + private static void DoAnimation(Projectile proj) { - projectile.frameCounter++; - if (projectile.frameCounter % 6 == 0) - projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; + proj.frameCounter++; + if (proj.frameCounter >= 4) + { + proj.frame = (proj.frame + 1) % Main.projFrames[proj.type]; + proj.frameCounter = 0; + } } - public static void DecideDirection(NPC target, Projectile projectile) + private static void DecideDirection(Projectile proj) { - // Both directions are negated because some individual decided to make the minion look at the left in the sprite instead of the right. - if (target is not null) - projectile.direction = projectile.spriteDirection = (target.Center.X - projectile.Center.X < 0).ToDirectionInt(); + // Both results are negated because some individual decided to make the minion look at the left in the sprite instead of the right. + if (Target is not null) + proj.direction = proj.spriteDirection = (Target.Center.X - proj.Center.X < 0).ToDirectionInt(); else - projectile.direction = projectile.spriteDirection = -projectile.velocity.X.DirectionalSign(); - + proj.direction = proj.spriteDirection = -proj.velocity.X.DirectionalSign(); } - public static void FollowPlayer(Player owner, Projectile projectile, float enemyDistanceDetection) - { - // If the minion starts to get far, force the minion to go to you. - if (projectile.WithinRange(owner.Center, enemyDistanceDetection) && !projectile.WithinRange(owner.Center, 300f)) + private static void FollowPlayer(Projectile proj, Player owner) + { + // The minion will hover around the owner. + if (!proj.WithinRange(owner.Center, 160f)) { - projectile.velocity = (owner.Center - projectile.Center) / 30f; - projectile.netUpdate = true; + proj.velocity = (proj.velocity + proj.SafeDirectionTo(owner.Center)) * 0.9f; + SyncVariables(proj); } - // The minion will change directions to you if it's going away from you, meaning it'll just hover around you. - else if (!projectile.WithinRange(owner.Center, 160f)) + // The minion will teleport on the owner if they get far enough. + if (!proj.WithinRange(owner.Center, MaxEnemyDistanceDetection)) { - projectile.velocity = (projectile.velocity * 37f + projectile.SafeDirectionTo(owner.Center) * 17f) / 40f; - projectile.netUpdate = true; + proj.Center = owner.Center; + SyncVariables(proj); } + } - // Teleport to the owner if sufficiently far away. - if (!projectile.WithinRange(owner.Center, enemyDistanceDetection)) - { - projectile.Center = owner.Center; - projectile.velocity *= 0.3f; - projectile.netUpdate = true; - } + private static void SyncVariables(Projectile proj) + { + proj.netUpdate = true; + if (proj.netSpam >= 10) + proj.netSpam = 9; } #endregion } -} \ No newline at end of file +} diff --git a/Projectiles/VanillaProjectileOverrides/ImpMinionAI.cs b/Projectiles/VanillaProjectileOverrides/ImpMinionAI.cs index bbb693d06f..e2669c6555 100644 --- a/Projectiles/VanillaProjectileOverrides/ImpMinionAI.cs +++ b/Projectiles/VanillaProjectileOverrides/ImpMinionAI.cs @@ -1,126 +1,151 @@ -using Terraria; -using Terraria.ID; +using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; namespace CalamityMod.Projectiles.VanillaProjectileOverrides { public static class ImpMinionAI { - public static bool DoImpMinionAI(Projectile projectile) + // Shorter range when the minion has no target yet: 40 tiles + private const float MinEnemyDistanceDetection = 640f; + + // Longer range when a target is already acquired: 75 tiles + private const float MaxEnemyDistanceDetection = 1200f; + + private static float EnemyDistanceDetection { get => Target is null ? MinEnemyDistanceDetection : MaxEnemyDistanceDetection; } + + private const int FireRate = 75; + private const float ProjectileVelocity = 20f; + private static NPC Target { get; set; } + + public static bool DoImpMinionAI(Projectile proj) { - Player owner = Main.player[projectile.owner]; - ref float timerToShoot = ref projectile.ai[0]; - projectile.aiStyle = -1; + Player owner = Main.player[proj.owner]; + Target = owner.Center.MinionHoming(EnemyDistanceDetection, owner, CalamityPlayer.areThereAnyDamnBosses); + ref float shootTimer = ref proj.ai[0]; - float enemyDistanceDetection = 1200f; - float fireRate = 120f; // In frames. - float projVelocity = 20f; + CheckMinionExistence(proj, owner); + DoAnimation(proj); + DecideDirection(proj); + FollowPlayer(proj, owner); + proj.MinionAntiClump(); - // Detects a target. - NPC target = projectile.Center.MinionHoming(enemyDistanceDetection, owner); - - if (target is not null) + if (Target is not null) { - if (timerToShoot >= fireRate && Main.myPlayer == projectile.owner) + shootTimer += Main.rand.NextBool(20) ? 2 : 1; + if (shootTimer >= FireRate && proj.owner == Main.myPlayer) { - int fireball = Projectile.NewProjectile(projectile.GetSource_FromThis(), - projectile.Center, - CalamityUtils.CalculatePredictiveAimToTarget(projectile.Center, target.Center, target.velocity, projVelocity), - ProjectileID.ImpFireball, - projectile.damage, - projectile.knockBack, - owner.whoAmI); + Vector2 toTargetDirection = CalamityUtils.CalculatePredictiveAimToTarget(proj.Center, Target, ProjectileVelocity); - if (Main.projectile.IndexInRange(fireball)) + Projectile fireball = Projectile.NewProjectileDirect(proj.GetSource_FromThis(), + proj.Center, + toTargetDirection, + ProjectileID.ImpFireball, + proj.damage, + proj.knockBack, + proj.owner); + + fireball.localNPCHitCooldown = 30; + fireball.Size *= 2f; + fireball.tileCollide = false; + fireball.usesLocalNPCImmunity = true; + fireball.usesIDStaticNPCImmunity = false; + + proj.velocity -= toTargetDirection.SafeNormalize(Vector2.Zero); + + if (!Main.dedServ) { - Main.projectile[fireball].originalDamage = projectile.originalDamage; - Main.projectile[fireball].usesLocalNPCImmunity = true; - Main.projectile[fireball].localNPCHitCooldown = 30; - Main.projectile[fireball].usesIDStaticNPCImmunity = false; + for (int i = 0; i < 15; i++) + { + Dust shootDust = Dust.NewDustPerfect(proj.Center + toTargetDirection.SafeNormalize(Vector2.Zero) * proj.Size / 2f, DustID.Torch, toTargetDirection.SafeNormalize(Vector2.Zero).RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(3f, 5f), Scale: 2f); + shootDust.noGravity = true; + shootDust.noLight = true; + shootDust.noLightEmittence = true; + } } - - timerToShoot = 0f; - projectile.netUpdate = true; + + shootTimer = 0f; + SyncVariables(proj); + } + } + else + { + // Quickly deaccelerate when getting too close to the owner. + if (proj.WithinRange(owner.Center, 128f)) + { + proj.velocity *= 0.875f; + SyncVariables(proj); } - - if (timerToShoot < fireRate) - timerToShoot++; } - CheckMinionExistence(owner, projectile); - - DoAnimation(projectile); - - DecideDirection(target, projectile); - - FollowPlayer(owner, projectile, enemyDistanceDetection); - - projectile.MinionAntiClump(.5f); - - // Just so the minion doesn't stay weirdly still. - if (projectile.velocity == Vector2.Zero) - projectile.velocity += new Vector2(Main.rand.NextFloat(-5f, 5f), Main.rand.NextFloat(-5f, 5f)); - - // Flavor fire dust effect. - int dustEffect = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, Main.rand.NextBool() ? 1f : -1f, Main.rand.NextBool() ? 1f : -1f); - Main.dust[dustEffect].noGravity = true; + if (!Main.dedServ) + { + // Flavor fire dust effect. + Dust dustEffect = Dust.NewDustDirect(proj.position, proj.width, proj.height, DustID.Torch); + dustEffect.noGravity = true; + dustEffect.noLight = true; + dustEffect.noLightEmittence = true; + } return false; } - #region Methods - - public static void CheckMinionExistence(Player owner, Projectile projectile) + #region AI Methods + + private static void CheckMinionExistence(Projectile proj, Player owner) { - owner.AddBuff(BuffID.ImpMinion, 1); - if (projectile.type != ProjectileID.FlyingImp) + owner.AddBuff(BuffID.ImpMinion, 2); + if (proj.type != ProjectileID.FlyingImp) return; - + if (owner.dead) owner.impMinion = false; if (owner.impMinion) - projectile.timeLeft = 2; + proj.timeLeft = 2; } - public static void DoAnimation(Projectile projectile) + private static void DoAnimation(Projectile proj) { - projectile.frameCounter++; - if (projectile.frameCounter % 6 == 0) - projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; + proj.frameCounter++; + if (proj.frameCounter >= 6) + { + proj.frame = (proj.frame + 1) % Main.projFrames[proj.type]; + proj.frameCounter = 0; + } } - public static void DecideDirection(NPC target, Projectile projectile) + private static void DecideDirection(Projectile proj) { // Both results are negated because some individual decided to make the minion look at the left in the sprite instead of the right. - if (target is not null) - projectile.direction = projectile.spriteDirection = (target.Center.X - projectile.Center.X < 0).ToDirectionInt(); + if (Target is not null) + proj.direction = proj.spriteDirection = (Target.Center.X - proj.Center.X < 0).ToDirectionInt(); else - projectile.direction = projectile.spriteDirection = -projectile.velocity.X.DirectionalSign(); + proj.direction = proj.spriteDirection = -proj.velocity.X.DirectionalSign(); } - public static void FollowPlayer(Player owner, Projectile projectile, float enemyDistanceDetection) - { - // If the minion starts to get far, force the minion to go to you. - if (projectile.WithinRange(owner.Center, enemyDistanceDetection) && !projectile.WithinRange(owner.Center, 300f)) + private static void FollowPlayer(Projectile proj, Player owner) + { + // The minion will hover around the owner. + if (!proj.WithinRange(owner.Center, 160f)) { - projectile.velocity = (owner.Center - projectile.Center) / 30f; - projectile.netUpdate = true; + proj.velocity = (proj.velocity + proj.SafeDirectionTo(owner.Center)) * 0.9f; + SyncVariables(proj); } - // The minion will change directions to you if it's going away from you, meaning it'll just hover around you. - else if (!projectile.WithinRange(owner.Center, 160f)) + // The minion will teleport on the owner if they get far enough. + if (!proj.WithinRange(owner.Center, MaxEnemyDistanceDetection)) { - projectile.velocity = (projectile.velocity * 37f + projectile.SafeDirectionTo(owner.Center) * 17f) / 40f; - projectile.netUpdate = true; + proj.Center = owner.Center; + SyncVariables(proj); } + } - // Teleport to the owner if sufficiently far away. - if (!projectile.WithinRange(owner.Center, enemyDistanceDetection)) - { - projectile.Center = owner.Center; - projectile.velocity *= 0.3f; - projectile.netUpdate = true; - } + private static void SyncVariables(Projectile proj) + { + proj.netUpdate = true; + if (proj.netSpam >= 10) + proj.netSpam = 9; } #endregion diff --git a/Projectiles/VanillaProjectileOverrides/RavenMinionAI.cs b/Projectiles/VanillaProjectileOverrides/RavenMinionAI.cs new file mode 100644 index 0000000000..8aa29d19d9 --- /dev/null +++ b/Projectiles/VanillaProjectileOverrides/RavenMinionAI.cs @@ -0,0 +1,151 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; + +namespace CalamityMod.Projectiles.VanillaProjectileOverrides +{ + public static class RavenMinionAI + { + // Shorter range when the minion has no target yet: 60 tiles + // This is half of the width of a 1920x1080 screen. + private const float MinEnemyDistanceDetection = 960f; + + // Longer range when a target is already acquired: 150 tiles + private const float MaxEnemyDistanceDetection = 2400f; + + // The detection distance dynamically updates. + // If the minion hasn't detected a target, the minion will check within screen more or less. + // When the minion has detected a target, the minion will follow it as long as we set it to. + private static float EnemyDistanceDetection { get => Target is null ? MinEnemyDistanceDetection : MaxEnemyDistanceDetection; } + + private const float DashSpeed = 35f; + private static SoundStyle CrowNoises = new("CalamityMod/Sounds/Custom/Crow", 3); + private static NPC Target { get; set; } + + public static bool DoRavenMinionAI(Projectile proj) + { + Player owner = Main.player[proj.owner]; + Target = owner.Center.MinionHoming(EnemyDistanceDetection, owner); + + CheckMinionExistence(proj, owner); + DoAnimation(proj); + + proj.localNPCHitCooldown = 10; + proj.friendly = true; + proj.tileCollide = false; + proj.ignoreWater = true; + proj.usesLocalNPCImmunity = true; + proj.usesIDStaticNPCImmunity = false; + proj.rotation = MathHelper.ToRadians(proj.velocity.X); + proj.MinionAntiClump(0.5f); + + if (Target is not null) + { + Vector2 dashDirection = proj.SafeDirectionTo(Target.Center); + + // If the minion is not withing dashing range, go towards it. + // When the minion's inside the range, it'll just move forward + // until it hits the outside bounds of the range, changing it's directions back. + // Hence giving the effect of a dash. + if (!proj.WithinRange(Target.Center, 240f)) + { + float inertia = 5f; + proj.velocity = (proj.velocity * inertia + dashDirection * DashSpeed) / (inertia + 1f); + SyncVariables(proj); + } + + // But if there was the case where the minion was already inside the range, + // if the velocity's not around the dash speed, make it dash. + else if (proj.velocity.Length() < DashSpeed - 15f) + { + proj.velocity = dashDirection * (DashSpeed - 10f); + SyncVariables(proj); + } + } + else + { + // The minion will hover around the owner. + if (!proj.WithinRange(owner.Center, 320f)) + { + proj.velocity = (proj.velocity + proj.SafeDirectionTo(owner.Center)) * 0.9f; + SyncVariables(proj); + } + + // The minion will teleport on the owner if they get far enough. + if (!proj.WithinRange(owner.Center, MaxEnemyDistanceDetection)) + { + proj.Center = owner.Center; + SyncVariables(proj); + } + + // So the minion doens't still weirdly still, move it. + if (proj.velocity == Vector2.Zero) + proj.velocity = Main.rand.NextVector2Circular(5f, 5f); + } + + if (!Main.dedServ) + { + if (Main.rand.NextBool(6000)) + SoundEngine.PlaySound(CrowNoises, proj.Center); + } + + return false; + } + + public static bool DoRavenMinionDrawing(Projectile proj, ref Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[proj.type].Value; + Vector2 drawPosition = proj.Center - Main.screenPosition; + Rectangle frame = texture.Frame(1, Main.projFrames[proj.type], 0, proj.frame); + Vector2 origin = frame.Size() * 0.5f; + SpriteEffects effects = MathF.Sign(-proj.velocity.X) == 1f ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + + ProjectileID.Sets.TrailingMode[proj.type] = 2; + ProjectileID.Sets.TrailCacheLength[proj.type] = 5; + + if (Target is not null) + CalamityUtils.DrawAfterimagesCentered(proj, 0, Color.MediumPurple with { A = 50 }); + + Main.EntitySpriteDraw(texture, drawPosition, frame, proj.GetAlpha(lightColor), proj.rotation, origin, proj.scale, effects); + + return false; + } + + #region AI Methods + + private static void CheckMinionExistence(Projectile proj, Player owner) + { + owner.AddBuff(BuffID.Ravens, 2); + if (proj.type != ProjectileID.Raven) + return; + + if (owner.dead) + owner.raven = false; + if (owner.raven) + proj.timeLeft = 2; + } + + private static void DoAnimation(Projectile proj) + { + proj.frameCounter++; + if (proj.frameCounter >= 5) + { + proj.frame = (proj.frame + 1) % Main.projFrames[proj.type]; + proj.frameCounter = 0; + } + } + + private static void SyncVariables(Projectile proj) + { + proj.netUpdate = true; + if (proj.netSpam >= 10) + proj.netSpam = 9; + } + + #endregion + } +} diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json index 8da89fff92..a505707137 100644 --- a/Properties/launchSettings.json +++ b/Properties/launchSettings.json @@ -1,16 +1,28 @@ { "profiles": { - "Terraria": { + "Terraria Client (dotnet)": { "commandName": "Executable", "executablePath": "dotnet", "commandLineArgs": "$(tMLPath)", "workingDirectory": "$(tMLSteamPath)" }, - "TerrariaServer": { + "Terraria Server (dotnet)": { "commandName": "Executable", "executablePath": "dotnet", "commandLineArgs": "$(tMLServerPath)", "workingDirectory": "$(tMLSteamPath)" + }, + "Terraria Client (dotnet.exe)": { + "commandName": "Executable", + "executablePath": "dotnet.exe", + "commandLineArgs": "$(tMLPath)", + "workingDirectory": "$(tMLSteamPath)" + }, + "Terraria Server (dotnet.exe)": { + "commandName": "Executable", + "executablePath": "dotnet.exe", + "commandLineArgs": "$(tMLServerPath)", + "workingDirectory": "$(tMLSteamPath)" } } } \ No newline at end of file diff --git a/Scenes/BossBackgroundScenes/ProvBackgroundScene.cs b/Scenes/BossBackgroundScenes/ProvBackgroundScene.cs deleted file mode 100644 index 09ea37edb8..0000000000 --- a/Scenes/BossBackgroundScenes/ProvBackgroundScene.cs +++ /dev/null @@ -1,18 +0,0 @@ -using CalamityMod.NPCs.Providence; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Systems -{ - public class ProvBackgroundScene : ModSceneEffect - { - public override SceneEffectPriority Priority => SceneEffectPriority.BossHigh; - - public override bool IsSceneEffectActive(Player player) => NPC.AnyNPCs(ModContent.NPCType()); - - public override void SpecialVisuals(Player player, bool isActive) - { - player.ManageSpecialBiomeVisuals("CalamityMod:Providence", isActive); - } - } -} diff --git a/Sounds/Custom/Crow1.ogg b/Sounds/Custom/Crow1.ogg new file mode 100644 index 0000000000..50f84365a4 Binary files /dev/null and b/Sounds/Custom/Crow1.ogg differ diff --git a/Sounds/Custom/Crow2.ogg b/Sounds/Custom/Crow2.ogg new file mode 100644 index 0000000000..75e2da8109 Binary files /dev/null and b/Sounds/Custom/Crow2.ogg differ diff --git a/Sounds/Custom/Crow3.ogg b/Sounds/Custom/Crow3.ogg new file mode 100644 index 0000000000..7372561b5c Binary files /dev/null and b/Sounds/Custom/Crow3.ogg differ diff --git a/Sounds/Custom/GreatSandSharkRoar.ogg b/Sounds/Custom/GreatSandSharkRoar.ogg index f70f27d982..a6761195bf 100644 Binary files a/Sounds/Custom/GreatSandSharkRoar.ogg and b/Sounds/Custom/GreatSandSharkRoar.ogg differ diff --git a/Sounds/Item/AscendantActivate.ogg b/Sounds/Item/AscendantActivate.ogg new file mode 100644 index 0000000000..21498d1e8a Binary files /dev/null and b/Sounds/Item/AscendantActivate.ogg differ diff --git a/Sounds/Item/AscendantOff.ogg b/Sounds/Item/AscendantOff.ogg new file mode 100644 index 0000000000..45228532fb Binary files /dev/null and b/Sounds/Item/AscendantOff.ogg differ diff --git a/Sounds/Item/AuricBulletHit.ogg b/Sounds/Item/AuricBulletHit.ogg new file mode 100644 index 0000000000..0b9bd528ad Binary files /dev/null and b/Sounds/Item/AuricBulletHit.ogg differ diff --git a/Sounds/Item/DeadSunExplosion.ogg b/Sounds/Item/DeadSunExplosion.ogg new file mode 100644 index 0000000000..5ffd7660ce Binary files /dev/null and b/Sounds/Item/DeadSunExplosion.ogg differ diff --git a/Sounds/Item/DeadSunRicochet.ogg b/Sounds/Item/DeadSunRicochet.ogg new file mode 100644 index 0000000000..31162a2442 Binary files /dev/null and b/Sounds/Item/DeadSunRicochet.ogg differ diff --git a/Sounds/Item/DeadSunShot.ogg b/Sounds/Item/DeadSunShot.ogg new file mode 100644 index 0000000000..d551c9d68f Binary files /dev/null and b/Sounds/Item/DeadSunShot.ogg differ diff --git a/Sounds/Item/HalleysInfernoHit.ogg b/Sounds/Item/HalleysInfernoHit.ogg new file mode 100644 index 0000000000..6cb43e1cd9 Binary files /dev/null and b/Sounds/Item/HalleysInfernoHit.ogg differ diff --git a/Sounds/Item/HalleysInfernoShoot.ogg b/Sounds/Item/HalleysInfernoShoot.ogg new file mode 100644 index 0000000000..00ef951e9a Binary files /dev/null and b/Sounds/Item/HalleysInfernoShoot.ogg differ diff --git a/Sounds/Item/Heartbeat.ogg b/Sounds/Item/Heartbeat.ogg new file mode 100644 index 0000000000..b0121df73c Binary files /dev/null and b/Sounds/Item/Heartbeat.ogg differ diff --git a/Sounds/Item/MineralMortarExplode.ogg b/Sounds/Item/MineralMortarExplode.ogg new file mode 100644 index 0000000000..9f981b1356 Binary files /dev/null and b/Sounds/Item/MineralMortarExplode.ogg differ diff --git a/Sounds/Item/MurasamaBigSwing.ogg b/Sounds/Item/MurasamaBigSwing.ogg new file mode 100644 index 0000000000..9af794325e Binary files /dev/null and b/Sounds/Item/MurasamaBigSwing.ogg differ diff --git a/Sounds/Item/MurasamaHitInorganic.ogg b/Sounds/Item/MurasamaHitInorganic.ogg new file mode 100644 index 0000000000..89d1597e1b Binary files /dev/null and b/Sounds/Item/MurasamaHitInorganic.ogg differ diff --git a/Sounds/Item/MurasamaHitOrganic.ogg b/Sounds/Item/MurasamaHitOrganic.ogg new file mode 100644 index 0000000000..4898afa97c Binary files /dev/null and b/Sounds/Item/MurasamaHitOrganic.ogg differ diff --git a/Sounds/Item/MurasamaSwing.ogg b/Sounds/Item/MurasamaSwing.ogg new file mode 100644 index 0000000000..ff604d971f Binary files /dev/null and b/Sounds/Item/MurasamaSwing.ogg differ diff --git a/Sounds/Item/NanoSwarm.ogg b/Sounds/Item/NanoSwarm.ogg new file mode 100644 index 0000000000..ad6f079194 Binary files /dev/null and b/Sounds/Item/NanoSwarm.ogg differ diff --git a/Sounds/Item/PhotoHitSound.ogg b/Sounds/Item/PhotoHitSound.ogg new file mode 100644 index 0000000000..c8e7b3861c Binary files /dev/null and b/Sounds/Item/PhotoHitSound.ogg differ diff --git a/Sounds/Item/PhotoUseSound.ogg b/Sounds/Item/PhotoUseSound.ogg new file mode 100644 index 0000000000..7085134694 Binary files /dev/null and b/Sounds/Item/PhotoUseSound.ogg differ diff --git a/Sounds/Item/WeldingBurn.ogg b/Sounds/Item/WeldingBurn.ogg new file mode 100644 index 0000000000..07b57418b6 Binary files /dev/null and b/Sounds/Item/WeldingBurn.ogg differ diff --git a/Sounds/Item/WeldingShoot.ogg b/Sounds/Item/WeldingShoot.ogg new file mode 100644 index 0000000000..9befb3eb4e Binary files /dev/null and b/Sounds/Item/WeldingShoot.ogg differ diff --git a/Sounds/NPCHit/GreatSandSharkHit.ogg b/Sounds/NPCHit/GreatSandSharkHit.ogg new file mode 100644 index 0000000000..9f7db8deb5 Binary files /dev/null and b/Sounds/NPCHit/GreatSandSharkHit.ogg differ diff --git a/Sounds/NPCKilled/GreatSandSharkDeath.ogg b/Sounds/NPCKilled/GreatSandSharkDeath.ogg new file mode 100644 index 0000000000..19f1aac3ef Binary files /dev/null and b/Sounds/NPCKilled/GreatSandSharkDeath.ogg differ diff --git a/Systems/BestiaryRegistrySystem.cs b/Systems/BestiaryRegistrySystem.cs new file mode 100644 index 0000000000..cdd705172e --- /dev/null +++ b/Systems/BestiaryRegistrySystem.cs @@ -0,0 +1,18 @@ +using CalamityMod.NPCs.Abyss; +using CalamityMod.NPCs.Astral; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Systems +{ + public class BestiaryRegistrySystem : ModSystem + { + public override void PostSetupContent() + { + // Manually register variants post-initiailization + ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPCType()] = ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPCType()]; + ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPCType()] = ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPCType()]; + } + } +} diff --git a/Systems/EntityUpdateInterceptionSystem.cs b/Systems/EntityUpdateInterceptionSystem.cs index f3634046bc..98a14899e8 100644 --- a/Systems/EntityUpdateInterceptionSystem.cs +++ b/Systems/EntityUpdateInterceptionSystem.cs @@ -1,6 +1,5 @@ using CalamityMod.NPCs; using CalamityMod.Particles; -using CalamityMod.Particles.Metaballs; using CalamityMod.TileEntities; using Terraria; using Terraria.ModLoader; @@ -9,19 +8,6 @@ namespace CalamityMod.Systems { public class EntityUpdateInterceptionSystem : ModSystem { - #region Fusable Particle Updating - public override void PostUpdateProjectiles() - { - // Update all fusable particles. - // These are really only visual and as such don't really need any complex netcode. - foreach (BaseFusableParticleSet.FusableParticleRenderCollection particleSet in FusableParticleManager.ParticleSets) - { - foreach (BaseFusableParticleSet.FusableParticle particle in particleSet.ParticleSet.Particles) - particleSet.ParticleSet.UpdateBehavior(particle); - } - } - #endregion - #region Ash Drawing public override void PostUpdateDusts() => DeathAshParticle.UpdateAll(); #endregion Ash Drawing diff --git a/Systems/MiscWorldStateSystem.cs b/Systems/MiscWorldStateSystem.cs index 52fca6e672..fdda225ea0 100644 --- a/Systems/MiscWorldStateSystem.cs +++ b/Systems/MiscWorldStateSystem.cs @@ -54,6 +54,7 @@ namespace CalamityMod Abyss.AbyssChasmBottom = 0; SulphurousSea.YStart = 0; Abyss.AtLeftSideOfWorld = false; + //Abyss.AbleToUnlockChests = false; //Yet another fucking failsave for abyss chests spawnedBandit = false; spawnedCirrus = false; @@ -70,6 +71,8 @@ namespace CalamityMod armageddon = false; AcidRainEvent.AcidRainEventIsOngoing = false; AcidRainEvent.CountdownUntilForcedAcidRain = 0; + + HasGeneratedLuminitePlanetoids = false; //Allow generating planetoids in other worlds } #endregion diff --git a/Systems/WorldgenManagementSystem.cs b/Systems/WorldgenManagementSystem.cs index 67d62e751f..e2eb6a6fb3 100644 --- a/Systems/WorldgenManagementSystem.cs +++ b/Systems/WorldgenManagementSystem.cs @@ -41,13 +41,13 @@ namespace CalamityMod.Systems })); } - // Replace the entire fucking Dungeon generation pass because nothing else will work as intended + // Generate the Astral Chest right after the dungeon has finished generating int DungeonIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Dungeon")); - tasks[DungeonIndex] = new PassLegacy("Dungeon", (progress, config) => + tasks.Insert(DungeonIndex + 1, new PassLegacy("Astral Chest", (progress, config) => { - progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.BetterDungeon").Value; - CustomDungeon.NewDungeon(); - }); + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.AstralChest").Value; + AstralChestGeneration.PlaceAstralChest(); + })); // Larger Jungle Temple int JungleTempleIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Jungle Temple")); @@ -190,7 +190,7 @@ namespace CalamityMod.Systems { progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.CorruptShrine").Value; UndergroundShrines.PlaceCorruptionShrine(GenVars.structures); - } + } progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.DesertShrine").Value; UndergroundShrines.PlaceDesertShrine(GenVars.structures); diff --git a/Tiles/Abyss/AbyssAmbient/MassiveRarePearl.cs b/Tiles/Abyss/AbyssAmbient/MassiveRarePearl.cs index de8a52d827..6d4267dfa0 100644 --- a/Tiles/Abyss/AbyssAmbient/MassiveRarePearl.cs +++ b/Tiles/Abyss/AbyssAmbient/MassiveRarePearl.cs @@ -1,14 +1,9 @@ -using CalamityMod.Projectiles.Environment; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; -using Terraria.ID; using Terraria.DataStructures; -using Terraria.Enums; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; -using System; namespace CalamityMod.Tiles.Abyss.AbyssAmbient { @@ -20,8 +15,8 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient Main.tileLavaDeath[Type] = true; Main.tileWaterDeath[Type] = false; Main.tileNoAttach[Type] = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(106, 80, 102)); DustType = 33; @@ -30,9 +25,9 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient } public override void KillMultiTile(int i, int j, int frameX, int frameY) - { + { if (Main.rand.NextBool(5)) - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 32, ItemID.PinkPearl); + Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 32, ItemID.PinkPearl); else Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 32, ItemID.WhitePearl); } diff --git a/Tiles/Abyss/AbyssAmbient/PirateCrate.cs b/Tiles/Abyss/AbyssAmbient/PirateCrate.cs index 65c3282f0c..23d9edf593 100644 --- a/Tiles/Abyss/AbyssAmbient/PirateCrate.cs +++ b/Tiles/Abyss/AbyssAmbient/PirateCrate.cs @@ -1,15 +1,11 @@ -using CalamityMod.Projectiles.Environment; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.DataStructures; -using Terraria.Enums; -using Terraria.Localization; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; -using System; namespace CalamityMod.Tiles.Abyss.AbyssAmbient { @@ -22,8 +18,8 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient Main.tileLavaDeath[Type] = true; Main.tileWaterDeath[Type] = false; Main.tileNoAttach[Type] = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(97, 69, 52), CalamityUtils.GetText("Tiles.PirateCrate")); DustType = DustID.WoodFurniture; @@ -33,11 +29,11 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient } public override void KillMultiTile(int i, int j, int frameX, int frameY) - { + { //explode when broken (troll!) //also instakill players in for the worthy Vector2 spawnPosition = new(i * 16f + 24f, j * 16f - 4f); - Projectile.NewProjectile(new EntitySource_WorldEvent(), spawnPosition.X, spawnPosition.Y, 0, 0, ProjectileID.Explosives, Main.getGoodWorld ? 99999 : 130, 0f); + Projectile.NewProjectile(new EntitySource_WorldEvent(), spawnPosition.X, spawnPosition.Y, 0, 0, ProjectileID.Explosives, Main.getGoodWorld ? 99999 : 130, 0f); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -48,10 +44,10 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { Tile tile = Framing.GetTileSafely(i, j); - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate1Glow").Value; - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); + Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate1Glow").Value; + Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); - spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); + spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); } } @@ -60,10 +56,10 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { Tile tile = Framing.GetTileSafely(i, j); - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate2Glow").Value; - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); + Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate2Glow").Value; + Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); - spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); + spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); } } @@ -72,10 +68,10 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { Tile tile = Framing.GetTileSafely(i, j); - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate3Glow").Value; - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); + Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate3Glow").Value; + Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); - spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); + spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); } } @@ -88,8 +84,8 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient Main.tileLavaDeath[Type] = true; Main.tileWaterDeath[Type] = false; Main.tileNoAttach[Type] = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(97, 69, 52), CalamityUtils.GetText("Tiles.PirateCrate")); DustType = DustID.WoodFurniture; @@ -99,9 +95,9 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient } public override void KillMultiTile(int i, int j, int frameX, int frameY) - { + { if (Main.rand.NextBool()) - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 32, ItemID.GoldCoin, Main.rand.Next(1, 2)); + Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 32, ItemID.GoldCoin, Main.rand.Next(1, 2)); Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 32, ItemID.SilverCoin, Main.rand.Next(45, 75)); } diff --git a/Tiles/Abyss/AbyssTreasureChest.cs b/Tiles/Abyss/AbyssTreasureChest.cs index 7e3dbcc0f4..eed55a4907 100644 --- a/Tiles/Abyss/AbyssTreasureChest.cs +++ b/Tiles/Abyss/AbyssTreasureChest.cs @@ -29,10 +29,7 @@ namespace CalamityMod.Tiles.Abyss { //Skeletron must be dead, NPC.downedBoss3 is added as failsave in case chests fail to open in the Abyss' method. AbleToUnlockChests should be false unless //the Abyss' unlock method is being run to prevent chests spawning already unlocked. - if (World.Abyss.AbleToUnlockChests || NPC.downedBoss3) - return true; - else - return false; + return World.Abyss.UnlockChests || NPC.downedBoss3; } public override bool RightClick(int i, int j) diff --git a/Tiles/Abyss/AbyssalPots.cs b/Tiles/Abyss/AbyssalPots.cs index 15ad3b67e2..5b54a5cdf0 100644 --- a/Tiles/Abyss/AbyssalPots.cs +++ b/Tiles/Abyss/AbyssalPots.cs @@ -1,6 +1,6 @@ -using CalamityMod.Items.TreasureBags.MiscGrabBags; +using System.Collections.Generic; +using CalamityMod.Items.TreasureBags.MiscGrabBags; using Microsoft.Xna.Framework; -using System.Collections.Generic; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -21,8 +21,8 @@ namespace CalamityMod.Tiles.Abyss Main.tileSpelunker[Type] = true; Main.tileCut[Type] = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(47, 79, 79), Language.GetText("MapObject.Pot")); // dark slate gray DustType = 29; @@ -35,28 +35,28 @@ namespace CalamityMod.Tiles.Abyss if (tileAtPosition.TileFrameX % 36 == 0 && tileAtPosition.TileFrameY % 36 == 0) { if (Main.netMode != NetmodeID.Server) - { - int goreAmt = Main.rand.Next(1, 2 + 1); - for (int k = 0; k < goreAmt; k++) - { - Gore.NewGore(new EntitySource_TileBreak(i, j), new Vector2(i, j) * 16, Main.rand.NextVector2CircularEdge(3f, 3f), Mod.Find("AbyssPotGore1").Type); - Gore.NewGore(new EntitySource_TileBreak(i, j), new Vector2(i, j) * 16, Main.rand.NextVector2CircularEdge(3f, 3f), Mod.Find("AbyssPotGore2").Type); - } - } + { + int goreAmt = Main.rand.Next(1, 2 + 1); + for (int k = 0; k < goreAmt; k++) + { + Gore.NewGore(new EntitySource_TileBreak(i, j), new Vector2(i, j) * 16, Main.rand.NextVector2CircularEdge(3f, 3f), Mod.Find("AbyssPotGore1").Type); + Gore.NewGore(new EntitySource_TileBreak(i, j), new Vector2(i, j) * 16, Main.rand.NextVector2CircularEdge(3f, 3f), Mod.Find("AbyssPotGore2").Type); + } + } - // 1 in 400 for a Coin Portal - if (Player.GetClosestRollLuck(i, j, 400) == 0f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(new EntitySource_TileBreak(i, j), i * 16 + 16, j * 16 + 16, 0f, -12f, ProjectileID.CoinPortal, 0, 0f, Main.myPlayer); - } - // Followed by a 1 in 4 for a bomb in For The Worthy worlds - else if (Main.getGoodWorld && Main.rand.NextBool(4)) - Projectile.NewProjectile(new EntitySource_TileBreak(i, j), i * 16 + 16, j * 16 + 8, (float)Main.rand.Next(-100, 101) * 0.002f, 0f, ProjectileID.Bomb, 0, 0f, Player.FindClosest(new Vector2(i * 16, j * 16), 16, 16)); - else - yield return new Item(ModContent.ItemType()); - } - } + // 1 in 400 for a Coin Portal + if (Player.GetClosestRollLuck(i, j, 400) == 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(new EntitySource_TileBreak(i, j), i * 16 + 16, j * 16 + 16, 0f, -12f, ProjectileID.CoinPortal, 0, 0f, Main.myPlayer); + } + // Followed by a 1 in 4 for a bomb in For The Worthy worlds + else if (Main.getGoodWorld && Main.rand.NextBool(4)) + Projectile.NewProjectile(new EntitySource_TileBreak(i, j), i * 16 + 16, j * 16 + 8, (float)Main.rand.Next(-100, 101) * 0.002f, 0f, ProjectileID.Bomb, 0, 0f, Player.FindClosest(new Vector2(i * 16, j * 16), 16, 16)); + else + yield return new Item(ModContent.ItemType()); + } + } public override bool CreateDust(int i, int j, ref int type) { diff --git a/Tiles/Abyss/HardenedSulphurousSandstone.cs b/Tiles/Abyss/HardenedSulphurousSandstone.cs index 7710a7396f..c8becd91c8 100644 --- a/Tiles/Abyss/HardenedSulphurousSandstone.cs +++ b/Tiles/Abyss/HardenedSulphurousSandstone.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Tiles.Abyss public override void RandomUpdate(int i, int j) { - int num8 = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); + int vineLength = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); int nearbyVineCount = 0; for (int x = i - 15; x <= i + 15; x++) { @@ -84,29 +84,29 @@ namespace CalamityMod.Tiles.Abyss if (Main.tile[i, j + 1].LiquidAmount == 255 && Main.tile[i, j + 1].LiquidType != LiquidID.Lava) { - bool flag13 = false; - for (int num52 = num8; num52 > num8 - 10; num52--) + bool canGrowVine = false; + for (int k = vineLength; k > vineLength - 10; k--) { - if (CalamityUtils.ParanoidTileRetrieval(i, num52).BottomSlope) + if (CalamityUtils.ParanoidTileRetrieval(i, k).BottomSlope) { - flag13 = false; + canGrowVine = false; break; } - if (Main.tile[i, num52].HasTile && !Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].HasTile && !Main.tile[i, k].BottomSlope) { - flag13 = true; + canGrowVine = true; break; } } - if (flag13) + if (canGrowVine) { - int num53 = i; - int num54 = j + 1; - Main.tile[num53, num54].TileType = (ushort)ModContent.TileType(); - Main.tile[num53, num54].Get().HasTile = true; - WorldGen.SquareTileFrame(num53, num54, true); + int vineX = i; + int vineY = j + 1; + Main.tile[vineX, vineY].TileType = (ushort)ModContent.TileType(); + Main.tile[vineX, vineY].Get().HasTile = true; + WorldGen.SquareTileFrame(vineX, vineY, true); if (Main.netMode == NetmodeID.Server) - NetMessage.SendTileSquare(-1, num53, num54, 3, TileChangeType.None); + NetMessage.SendTileSquare(-1, vineX, vineY, 3, TileChangeType.None); } } Main.tile[i, j].Get().Slope = SlopeType.Solid; diff --git a/Tiles/Abyss/PlantyMush.cs b/Tiles/Abyss/PlantyMush.cs index d883642617..ee518f5266 100644 --- a/Tiles/Abyss/PlantyMush.cs +++ b/Tiles/Abyss/PlantyMush.cs @@ -162,7 +162,7 @@ namespace CalamityMod.Tiles.Abyss NetMessage.SendTileSquare(-1, i, j - 1, 3, TileChangeType.None); } - int num8 = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); + int vineLength = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); if (Main.tile[i, j + 1] != null) { if (!Main.tile[i, j + 1].HasTile && Main.tile[i, j + 1].TileType != (ushort)ModContent.TileType()) @@ -171,29 +171,29 @@ namespace CalamityMod.Tiles.Abyss Main.tile[i, j + 1].WallType == (ushort)ModContent.WallType() && Main.tile[i, j + 1].LiquidType != LiquidID.Lava) { - bool flag13 = false; - for (int num52 = num8; num52 > num8 - 10; num52--) + bool canGrowVine = false; + for (int k = vineLength; k > vineLength - 10; k--) { - if (Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].BottomSlope) { - flag13 = false; + canGrowVine = false; break; } - if (Main.tile[i, num52].HasTile && !Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].HasTile && !Main.tile[i, k].BottomSlope) { - flag13 = true; + canGrowVine = true; break; } } - if (flag13) + if (canGrowVine) { - int num53 = i; - int num54 = j + 1; - Main.tile[num53, num54].TileType = (ushort)ModContent.TileType(); - Main.tile[num53, num54].Get().HasTile = true; - WorldGen.SquareTileFrame(num53, num54, true); + int vineX = i; + int vineY = j + 1; + Main.tile[vineX, vineY].TileType = (ushort)ModContent.TileType(); + Main.tile[vineX, vineY].Get().HasTile = true; + WorldGen.SquareTileFrame(vineX, vineY, true); if (Main.netMode == NetmodeID.Server) - NetMessage.SendTileSquare(-1, num53, num54, 3, TileChangeType.None); + NetMessage.SendTileSquare(-1, vineX, vineY, 3, TileChangeType.None); } } } diff --git a/Tiles/Abyss/SteamGeyser.cs b/Tiles/Abyss/SteamGeyser.cs index 62dd12742a..c745770cd0 100644 --- a/Tiles/Abyss/SteamGeyser.cs +++ b/Tiles/Abyss/SteamGeyser.cs @@ -4,7 +4,6 @@ using CalamityMod.Projectiles.Environment; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -19,8 +18,8 @@ namespace CalamityMod.Tiles.Abyss { Main.tileFrameImportant[Type] = true; Main.tileNoAttach[Type] = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(103, 65, 64), CalamityUtils.GetText($"{LocalizationCategory}.SteamGeyser.MapEntry")); DustType = (int)CalamityDusts.SulfurousSeaAcid; diff --git a/Tiles/Abyss/SulphurousSand.cs b/Tiles/Abyss/SulphurousSand.cs index 21129d9a32..5d35963b13 100644 --- a/Tiles/Abyss/SulphurousSand.cs +++ b/Tiles/Abyss/SulphurousSand.cs @@ -74,18 +74,18 @@ namespace CalamityMod.Tiles.Abyss { if (Main.tile[i, tileLocationY].LiquidAmount == 255) { - int num13 = 7; - int num14 = 6; - int num15 = 0; - for (int l = i - num13; l <= i + num13; l++) + int ambientObjectDetectRadius = 7; + int ambientObjectMax = 6; + int ambientObjectAmt = 0; + for (int l = i - ambientObjectDetectRadius; l <= i + ambientObjectDetectRadius; l++) { - for (int m = tileLocationY - num13; m <= tileLocationY + num13; m++) + for (int m = tileLocationY - ambientObjectDetectRadius; m <= tileLocationY + ambientObjectDetectRadius; m++) { if (Main.tile[l, m].HasTile && Main.tile[l, m].TileType == 81) - num15++; + ambientObjectAmt++; } } - if (num15 < num14 && Main.tile[i, tileLocationY - 1].LiquidAmount == 255 && + if (ambientObjectAmt < ambientObjectMax && Main.tile[i, tileLocationY - 1].LiquidAmount == 255 && Main.tile[i, tileLocationY - 2].LiquidAmount == 255 && Main.tile[i, tileLocationY - 3].LiquidAmount == 255 && Main.tile[i, tileLocationY - 4].LiquidAmount == 255) { @@ -96,18 +96,18 @@ namespace CalamityMod.Tiles.Abyss } else if (Main.tile[i, tileLocationY].LiquidAmount == 0) { - int num13 = 7; - int num14 = 6; - int num15 = 0; - for (int l = i - num13; l <= i + num13; l++) + int ambientObjectDetectRadius = 7; + int ambientObjectMax = 6; + int ambientObjectAmt = 0; + for (int l = i - ambientObjectDetectRadius; l <= i + ambientObjectDetectRadius; l++) { - for (int m = tileLocationY - num13; m <= tileLocationY + num13; m++) + for (int m = tileLocationY - ambientObjectDetectRadius; m <= tileLocationY + ambientObjectDetectRadius; m++) { if (Main.tile[l, m].HasTile && Main.tile[l, m].TileType == 324) - num15++; + ambientObjectAmt++; } } - if (num15 < num14) + if (ambientObjectAmt < ambientObjectMax) { WorldGen.PlaceTile(i, tileLocationY, 324, true, false, -1, Main.rand.Next(2)); if (Main.netMode == NetmodeID.Server && Main.tile[i, tileLocationY].HasTile) @@ -119,7 +119,7 @@ namespace CalamityMod.Tiles.Abyss } } - int num8 = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); + int vineLength = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); int nearbyVineCount = 0; for (int x = i - 15; x <= i + 15; x++) { @@ -143,29 +143,29 @@ namespace CalamityMod.Tiles.Abyss if (Main.tile[i, j + 1].LiquidAmount == 255 && Main.tile[i, j + 1].LiquidType != LiquidID.Lava) { - bool flag13 = false; - for (int num52 = num8; num52 > num8 - 10; num52--) + bool canGrowVine = false; + for (int k = vineLength; k > vineLength - 10; k--) { - if (Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].BottomSlope) { - flag13 = false; + canGrowVine = false; break; } - if (Main.tile[i, num52].HasTile && !Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].HasTile && !Main.tile[i, k].BottomSlope) { - flag13 = true; + canGrowVine = true; break; } } - if (flag13) + if (canGrowVine) { - int num53 = i; - int num54 = j + 1; - Main.tile[num53, num54].TileType = (ushort)ModContent.TileType(); - Main.tile[num53, num54].Get().HasTile = true; - WorldGen.SquareTileFrame(num53, num54, true); + int vineX = i; + int vineY = j + 1; + Main.tile[vineX, vineY].TileType = (ushort)ModContent.TileType(); + Main.tile[vineX, vineY].Get().HasTile = true; + WorldGen.SquareTileFrame(vineX, vineY, true); if (Main.netMode == NetmodeID.Server) - NetMessage.SendTileSquare(-1, num53, num54, 3, TileChangeType.None); + NetMessage.SendTileSquare(-1, vineX, vineY, 3, TileChangeType.None); } Main.tile[i, j].Get().Slope = SlopeType.Solid; Main.tile[i, j].Get().IsHalfBlock = false; diff --git a/Tiles/Abyss/SulphurousSandstone.cs b/Tiles/Abyss/SulphurousSandstone.cs index c536be437c..a619209223 100644 --- a/Tiles/Abyss/SulphurousSandstone.cs +++ b/Tiles/Abyss/SulphurousSandstone.cs @@ -61,7 +61,7 @@ namespace CalamityMod.Tiles.Abyss public override void RandomUpdate(int i, int j) { - int num8 = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); + int vineLength = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); int nearbyVineCount = 0; for (int x = i - 15; x <= i + 15; x++) { @@ -85,29 +85,29 @@ namespace CalamityMod.Tiles.Abyss if (Main.tile[i, j + 1].LiquidAmount == 255 && Main.tile[i, j + 1].LiquidType != LiquidID.Lava) { - bool flag13 = false; - for (int num52 = num8; num52 > num8 - 10; num52--) + bool canGrowVine = false; + for (int k = vineLength; k > vineLength - 10; k--) { - if (Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].BottomSlope) { - flag13 = false; + canGrowVine = false; break; } - if (Main.tile[i, num52].HasTile && !Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].HasTile && !Main.tile[i, k].BottomSlope) { - flag13 = true; + canGrowVine = true; break; } } - if (flag13) + if (canGrowVine) { - int num53 = i; - int num54 = j + 1; - Main.tile[num53, num54].TileType = (ushort)ModContent.TileType(); - Main.tile[num53, num54].Get().HasTile = true; - WorldGen.SquareTileFrame(num53, num54, true); + int vineX = i; + int vineY = j + 1; + Main.tile[vineX, vineY].TileType = (ushort)ModContent.TileType(); + Main.tile[vineX, vineY].Get().HasTile = true; + WorldGen.SquareTileFrame(vineX, vineY, true); if (Main.netMode == NetmodeID.Server) - NetMessage.SendTileSquare(-1, num53, num54, 3, TileChangeType.None); + NetMessage.SendTileSquare(-1, vineX, vineY, 3, TileChangeType.None); } Main.tile[i, j].Get().Slope = SlopeType.Solid; Main.tile[i, j].Get().IsHalfBlock = false; diff --git a/Tiles/Abyss/SulphurousShale.cs b/Tiles/Abyss/SulphurousShale.cs index a1558e1156..87887f78e1 100644 --- a/Tiles/Abyss/SulphurousShale.cs +++ b/Tiles/Abyss/SulphurousShale.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Tiles.Abyss public override void RandomUpdate(int i, int j) { - int num8 = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); + int vineLength = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); int nearbyVineCount = 0; for (int x = i - 15; x <= i + 15; x++) { @@ -77,29 +77,29 @@ namespace CalamityMod.Tiles.Abyss if (Main.tile[i, j + 1].LiquidAmount == 255 && Main.tile[i, j + 1].LiquidType != LiquidID.Lava) { - bool flag13 = false; - for (int num52 = num8; num52 > num8 - 10; num52--) + bool canGrowVine = false; + for (int k = vineLength; k > vineLength - 10; k--) { - if (Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].BottomSlope) { - flag13 = false; + canGrowVine = false; break; } - if (Main.tile[i, num52].HasTile && !Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].HasTile && !Main.tile[i, k].BottomSlope) { - flag13 = true; + canGrowVine = true; break; } } - if (flag13) + if (canGrowVine) { - int num53 = i; - int num54 = j + 1; - Main.tile[num53, num54].TileType = (ushort)ModContent.TileType(); - Main.tile[num53, num54].Get().HasTile = true; - WorldGen.SquareTileFrame(num53, num54, true); + int vineX = i; + int vineY = j + 1; + Main.tile[vineX, vineY].TileType = (ushort)ModContent.TileType(); + Main.tile[vineX, vineY].Get().HasTile = true; + WorldGen.SquareTileFrame(vineX, vineY, true); if (Main.netMode == NetmodeID.Server) - NetMessage.SendTileSquare(-1, num53, num54, 3, TileChangeType.None); + NetMessage.SendTileSquare(-1, vineX, vineY, 3, TileChangeType.None); } Main.tile[i, j].Get().Slope = SlopeType.Solid; Main.tile[i, j].Get().IsHalfBlock = false; diff --git a/Tiles/Abyss/ViperVines.cs b/Tiles/Abyss/ViperVines.cs index 318b6590f7..3f491fe5fe 100644 --- a/Tiles/Abyss/ViperVines.cs +++ b/Tiles/Abyss/ViperVines.cs @@ -67,36 +67,36 @@ namespace CalamityMod.Tiles.Abyss { if (Main.tile[i, j + 1].LiquidAmount >= 128 && Main.tile[i, j + 1].LiquidType != LiquidID.Lava) { - bool flag13 = false; - for (int num52 = j; num52 > j - 10; j--) + bool canGrowVine = false; + for (int k = j; k > j - 10; j--) { - if (Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].BottomSlope) { - flag13 = false; + canGrowVine = false; break; } - if (Main.tile[i, num52].HasTile && !Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].HasTile && !Main.tile[i, k].BottomSlope) { - flag13 = true; + canGrowVine = true; break; } } - if (flag13) + if (canGrowVine) { - int num53 = i; - int num54 = j + 1; - Main.tile[num53, num54].TileType = (ushort)ModContent.TileType(); - Main.tile[num53, num54].TileFrameX = (short)(WorldGen.genRand.Next(8) * 18); - Main.tile[num53, num54].TileFrameY = (short)(4 * 18); - Main.tile[num53, num54 - 1].TileFrameX = (short)(WorldGen.genRand.Next(12) * 18); - Main.tile[num53, num54 - 1].TileFrameY = (short)(WorldGen.genRand.Next(4) * 18); - Main.tile[num53, num54].Get().HasTile = true; - WorldGen.SquareTileFrame(num53, num54, true); - WorldGen.SquareTileFrame(num53, num54 - 1, true); + int vineX = i; + int vineY = j + 1; + Main.tile[vineX, vineY].TileType = (ushort)ModContent.TileType(); + Main.tile[vineX, vineY].TileFrameX = (short)(WorldGen.genRand.Next(8) * 18); + Main.tile[vineX, vineY].TileFrameY = (short)(4 * 18); + Main.tile[vineX, vineY - 1].TileFrameX = (short)(WorldGen.genRand.Next(12) * 18); + Main.tile[vineX, vineY - 1].TileFrameY = (short)(WorldGen.genRand.Next(4) * 18); + Main.tile[vineX, vineY].Get().HasTile = true; + WorldGen.SquareTileFrame(vineX, vineY, true); + WorldGen.SquareTileFrame(vineX, vineY - 1, true); if (Main.netMode == NetmodeID.Server) { - NetMessage.SendTileSquare(-1, num53, num54, 3, TileChangeType.None); - NetMessage.SendTileSquare(-1, num53, num54 - 1, 3, TileChangeType.None); + NetMessage.SendTileSquare(-1, vineX, vineY, 3, TileChangeType.None); + NetMessage.SendTileSquare(-1, vineX, vineY - 1, 3, TileChangeType.None); } } } diff --git a/Tiles/Astral/AstralClay.cs b/Tiles/Astral/AstralClay.cs index 69116e461d..4d43e6e647 100644 --- a/Tiles/Astral/AstralClay.cs +++ b/Tiles/Astral/AstralClay.cs @@ -46,5 +46,11 @@ namespace CalamityMod.Tiles.Astral { num = fail ? 1 : 3; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/Astral/AstralDirt.cs b/Tiles/Astral/AstralDirt.cs index d795b831bc..6b5601c886 100644 --- a/Tiles/Astral/AstralDirt.cs +++ b/Tiles/Astral/AstralDirt.cs @@ -69,5 +69,11 @@ namespace CalamityMod.Tiles.Astral { num = fail ? 1 : 3; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/Astral/AstralGrass.cs b/Tiles/Astral/AstralGrass.cs index 5286f4af9b..ed4b52e790 100644 --- a/Tiles/Astral/AstralGrass.cs +++ b/Tiles/Astral/AstralGrass.cs @@ -177,5 +177,11 @@ namespace CalamityMod.Tiles.Astral Main.tile[i, j].TileType = (ushort)ModContent.TileType(); } } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/Astral/AstralMonolith.cs b/Tiles/Astral/AstralMonolith.cs index 1b8d10f6d8..57559d0638 100644 --- a/Tiles/Astral/AstralMonolith.cs +++ b/Tiles/Astral/AstralMonolith.cs @@ -148,5 +148,11 @@ namespace CalamityMod.Tiles.Astral } return colour; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/Astral/AstralNormalLargePiles.cs b/Tiles/Astral/AstralNormalLargePiles.cs index cda376ca8a..514260a871 100644 --- a/Tiles/Astral/AstralNormalLargePiles.cs +++ b/Tiles/Astral/AstralNormalLargePiles.cs @@ -47,6 +47,12 @@ namespace CalamityMod.Tiles.Astral Main.npc[worm].direction *= -1; Main.npc[worm].netUpdate = true; } - } + } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/Astral/AstralNormalMediumPiles.cs b/Tiles/Astral/AstralNormalMediumPiles.cs index 5772be900a..8344033cd1 100644 --- a/Tiles/Astral/AstralNormalMediumPiles.cs +++ b/Tiles/Astral/AstralNormalMediumPiles.cs @@ -47,6 +47,12 @@ namespace CalamityMod.Tiles.Astral Main.npc[worm].direction *= -1; Main.npc[worm].netUpdate = true; } - } + } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/Astral/AstralNormalSmallPiles.cs b/Tiles/Astral/AstralNormalSmallPiles.cs index d9b0d7ddc9..5ac16fc1d5 100644 --- a/Tiles/Astral/AstralNormalSmallPiles.cs +++ b/Tiles/Astral/AstralNormalSmallPiles.cs @@ -42,6 +42,12 @@ namespace CalamityMod.Tiles.Astral Main.npc[worm].direction *= -1; Main.npc[worm].netUpdate = true; } - } + } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/Astral/AstralNormalStalactite.cs b/Tiles/Astral/AstralNormalStalactite.cs index 3532ec83f0..abb434845d 100644 --- a/Tiles/Astral/AstralNormalStalactite.cs +++ b/Tiles/Astral/AstralNormalStalactite.cs @@ -1,4 +1,4 @@ - + using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; @@ -45,5 +45,11 @@ namespace CalamityMod.Tiles.Astral { num = fail ? 1 : 4; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/Astral/AstralShortPlants.cs b/Tiles/Astral/AstralShortPlants.cs index e8c7c0243e..9bc78c7804 100644 --- a/Tiles/Astral/AstralShortPlants.cs +++ b/Tiles/Astral/AstralShortPlants.cs @@ -64,5 +64,11 @@ namespace CalamityMod.Tiles.Astral yield return new Item(ModContent.ItemType()); } } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/Astral/AstralStone.cs b/Tiles/Astral/AstralStone.cs index 84b6a2ef44..8516bb4c0d 100644 --- a/Tiles/Astral/AstralStone.cs +++ b/Tiles/Astral/AstralStone.cs @@ -57,5 +57,11 @@ namespace CalamityMod.Tiles.Astral { num = fail ? 1 : 3; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/Astral/AstralTallPlants.cs b/Tiles/Astral/AstralTallPlants.cs index 14ed654c84..6560e98fe7 100644 --- a/Tiles/Astral/AstralTallPlants.cs +++ b/Tiles/Astral/AstralTallPlants.cs @@ -69,5 +69,11 @@ namespace CalamityMod.Tiles.Astral yield return new Item(ModContent.ItemType()); } } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/Astral/AstralVines.cs b/Tiles/Astral/AstralVines.cs index 3fc2c89f32..761bad74ab 100644 --- a/Tiles/Astral/AstralVines.cs +++ b/Tiles/Astral/AstralVines.cs @@ -57,5 +57,11 @@ namespace CalamityMod.Tiles.Astral g *= brightness; b *= brightness; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/Astral/NovaeSlag.cs b/Tiles/Astral/NovaeSlag.cs index 493ceafa35..01539703e5 100644 --- a/Tiles/Astral/NovaeSlag.cs +++ b/Tiles/Astral/NovaeSlag.cs @@ -62,5 +62,11 @@ namespace CalamityMod.Tiles.Astral { num = fail ? 1 : 3; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/AstralBrick.cs b/Tiles/AstralBrick.cs index af42d9246f..5c2f42bb3f 100644 --- a/Tiles/AstralBrick.cs +++ b/Tiles/AstralBrick.cs @@ -62,7 +62,6 @@ namespace CalamityMod.Tiles Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; Color drawColour = GetDrawColour(i, j, new Color(50, 50, 50, 50)); Tile trackTile = Main.tile[i, j]; - double num6 = Main.time * 0.08; TileFraming.SlopedGlowmask(i, j, 0, glowmask, drawOffset, null, GetDrawColour(i, j, drawColour), default); diff --git a/Tiles/AstralDesert/AstralDesertLargePiles.cs b/Tiles/AstralDesert/AstralDesertLargePiles.cs index 789a696886..f4335c66b2 100644 --- a/Tiles/AstralDesert/AstralDesertLargePiles.cs +++ b/Tiles/AstralDesert/AstralDesertLargePiles.cs @@ -34,5 +34,11 @@ namespace CalamityMod.Tiles.AstralDesert { num = fail ? 1 : 4; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/AstralDesert/AstralDesertMediumPiles.cs b/Tiles/AstralDesert/AstralDesertMediumPiles.cs index 175eed49ee..da7790fdc4 100644 --- a/Tiles/AstralDesert/AstralDesertMediumPiles.cs +++ b/Tiles/AstralDesert/AstralDesertMediumPiles.cs @@ -34,5 +34,11 @@ namespace CalamityMod.Tiles.AstralDesert { num = fail ? 1 : 4; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/AstralDesert/AstralDesertSmallPiles.cs b/Tiles/AstralDesert/AstralDesertSmallPiles.cs index ce5d98155d..24e267dc3c 100644 --- a/Tiles/AstralDesert/AstralDesertSmallPiles.cs +++ b/Tiles/AstralDesert/AstralDesertSmallPiles.cs @@ -29,5 +29,11 @@ namespace CalamityMod.Tiles.AstralDesert { num = fail ? 1 : 4; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/AstralDesert/AstralDesertStalactite.cs b/Tiles/AstralDesert/AstralDesertStalactite.cs index a242500ccd..92f7adf703 100644 --- a/Tiles/AstralDesert/AstralDesertStalactite.cs +++ b/Tiles/AstralDesert/AstralDesertStalactite.cs @@ -45,5 +45,11 @@ namespace CalamityMod.Tiles.AstralDesert { num = fail ? 1 : 4; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/AstralDesert/AstralSand.cs b/Tiles/AstralDesert/AstralSand.cs index c281d3ce3a..46c4c4fdb1 100644 --- a/Tiles/AstralDesert/AstralSand.cs +++ b/Tiles/AstralDesert/AstralSand.cs @@ -84,5 +84,11 @@ namespace CalamityMod.Tiles.AstralDesert { DustType = 108; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/AstralDesert/AstralSandstone.cs b/Tiles/AstralDesert/AstralSandstone.cs index f57a84115d..c64c5bb851 100644 --- a/Tiles/AstralDesert/AstralSandstone.cs +++ b/Tiles/AstralDesert/AstralSandstone.cs @@ -55,5 +55,11 @@ namespace CalamityMod.Tiles.AstralDesert { num = fail ? 1 : 3; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/AstralDesert/CelestialRemains.cs b/Tiles/AstralDesert/CelestialRemains.cs index f9657d46a8..03db9266b1 100644 --- a/Tiles/AstralDesert/CelestialRemains.cs +++ b/Tiles/AstralDesert/CelestialRemains.cs @@ -47,5 +47,11 @@ namespace CalamityMod.Tiles.AstralDesert { num = fail ? 1 : 3; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/AstralDesert/HardenedAstralSand.cs b/Tiles/AstralDesert/HardenedAstralSand.cs index 9b9ba056e1..452b866c98 100644 --- a/Tiles/AstralDesert/HardenedAstralSand.cs +++ b/Tiles/AstralDesert/HardenedAstralSand.cs @@ -60,5 +60,11 @@ namespace CalamityMod.Tiles.AstralDesert { num = fail ? 1 : 3; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/AstralSnow/AstralIce.cs b/Tiles/AstralSnow/AstralIce.cs index e5c5a893da..9d3ccb0c09 100644 --- a/Tiles/AstralSnow/AstralIce.cs +++ b/Tiles/AstralSnow/AstralIce.cs @@ -63,5 +63,11 @@ namespace CalamityMod.Tiles.AstralSnow TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out secondTileAdjacency[i, j]); return true; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/AstralSnow/AstralIceLargePiles.cs b/Tiles/AstralSnow/AstralIceLargePiles.cs index 52c63077db..6cd4787eb2 100644 --- a/Tiles/AstralSnow/AstralIceLargePiles.cs +++ b/Tiles/AstralSnow/AstralIceLargePiles.cs @@ -34,5 +34,11 @@ namespace CalamityMod.Tiles.AstralSnow { num = fail ? 1 : 4; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/AstralSnow/AstralIceMediumPiles.cs b/Tiles/AstralSnow/AstralIceMediumPiles.cs index 536e1e0402..b418f845a4 100644 --- a/Tiles/AstralSnow/AstralIceMediumPiles.cs +++ b/Tiles/AstralSnow/AstralIceMediumPiles.cs @@ -34,5 +34,11 @@ namespace CalamityMod.Tiles.AstralSnow { num = fail ? 1 : 4; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/AstralSnow/AstralIceSmallPiles.cs b/Tiles/AstralSnow/AstralIceSmallPiles.cs index 0f35bf2d49..153cdcf7b1 100644 --- a/Tiles/AstralSnow/AstralIceSmallPiles.cs +++ b/Tiles/AstralSnow/AstralIceSmallPiles.cs @@ -29,5 +29,11 @@ namespace CalamityMod.Tiles.AstralSnow { num = fail ? 1 : 4; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/AstralSnow/AstralIceStalactite.cs b/Tiles/AstralSnow/AstralIceStalactite.cs index e5e04ea9b9..b877edd3cf 100644 --- a/Tiles/AstralSnow/AstralIceStalactite.cs +++ b/Tiles/AstralSnow/AstralIceStalactite.cs @@ -44,5 +44,11 @@ namespace CalamityMod.Tiles.AstralSnow { num = fail ? 1 : 4; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/AstralSnow/AstralSnow.cs b/Tiles/AstralSnow/AstralSnow.cs index f10bdf21fe..2fcbde0bc9 100644 --- a/Tiles/AstralSnow/AstralSnow.cs +++ b/Tiles/AstralSnow/AstralSnow.cs @@ -53,5 +53,11 @@ namespace CalamityMod.Tiles.AstralSnow TileFraming.GetAdjacencyData(i, j, TileID.SnowBlock, out secondTileAdjacency[i, j]); return true; } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } } } diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index 7d32aaeaf8..66982b5582 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -365,17 +365,36 @@ namespace CalamityMod.Tiles } // Mining set gives a chance for additional ore. This can be abused for infinite ore but it has a cooldown to prevent too much abuse - if (player.Calamity().miningSet && player.Calamity().miningSetCooldown <= 0 && !fail) + if (player.Calamity().miningSet && player.Calamity().miningSetCooldown <= 0 && !fail && TileID.Sets.Ore[tile.TileType]) { - int item = tile.GetOreItemID(); - Vector2 pos = new Vector2(i, j) * 16; // 25% chance for additional ore - if (Main.rand.NextBool(MiningArmorSetChange.BonusOreChance) && item != -1) - { - Item.NewItem(new EntitySource_TileBreak(i, j), pos, item); - // Cooldown varies between 3 and 6 seconds - player.Calamity().miningSetCooldown = Main.rand.Next(MiningArmorSetChange.CooldownMin, MiningArmorSetChange.CooldownMax + 1); - } + if (!Main.rand.NextBool(MiningArmorSetChange.BonusOreChance)) + return; + + var source = new EntitySource_TileBreak(i, j); + Vector2 pos = new Vector2(i, j) * 16; + ModTile moddedTile = TileLoader.GetTile(tile.TileType); + if (moddedTile != null) // Fetch the modded tile's drop logic + { + IEnumerable itemDrops = moddedTile.GetItemDrops(i, j); + if (itemDrops == null) + return; + + foreach (Item item in itemDrops) + { + item.Prefix(-1); // You're twisted if you have a prefixable item inside ores but fuck it + int moddedOre = Item.NewItem(source, pos, item); + Main.item[moddedOre].TryCombiningIntoNearbyItems(moddedOre); + } + } + else // Fetch normal tile-item relationships (all vanilla ores are normal thankfully) + { + int itemType = TileLoader.GetItemDropFromTypeAndStyle(tile.TileType); + Item.NewItem(source, pos, itemType); + } + + // Cooldown varies between 3 and 6 seconds + player.Calamity().miningSetCooldown = Main.rand.Next(MiningArmorSetChange.CooldownMin, MiningArmorSetChange.CooldownMax + 1); } } @@ -457,19 +476,19 @@ namespace CalamityMod.Tiles return; } - int num = tileSafely.TileFrameX / 22; - int num2 = tileSafely.TileFrameY / 22; - if (num == 3 && num2 <= 2) + int treeTileX = tileSafely.TileFrameX / 22; + int treeTileY = tileSafely.TileFrameY / 22; + if (treeTileX == 3 && treeTileY <= 2) x++; - else if (num == 4 && num2 >= 3 && num2 <= 5) + else if (treeTileX == 4 && treeTileY >= 3 && treeTileY <= 5) x--; - else if (num == 1 && num2 >= 6 && num2 <= 8) + else if (treeTileX == 1 && treeTileY >= 6 && treeTileY <= 8) x--; - else if (num == 2 && num2 >= 6 && num2 <= 8) + else if (treeTileX == 2 && treeTileY >= 6 && treeTileY <= 8) x++; - else if (num == 2 && num2 >= 9) + else if (treeTileX == 2 && treeTileY >= 9) x++; - else if (num == 3 && num2 >= 9) + else if (treeTileX == 3 && treeTileY >= 9) x--; tileSafely = Framing.GetTileSafely(x, y); diff --git a/Tiles/DraedonStructures/SecurityChestTile.png b/Tiles/DraedonStructures/SecurityChestTile.png index 0d0daefcb2..0c7da764d4 100644 Binary files a/Tiles/DraedonStructures/SecurityChestTile.png and b/Tiles/DraedonStructures/SecurityChestTile.png differ diff --git a/Tiles/Furniture/BlueCandle.cs b/Tiles/Furniture/BlueCandle.cs index d9a694883b..e174008003 100644 --- a/Tiles/Furniture/BlueCandle.cs +++ b/Tiles/Furniture/BlueCandle.cs @@ -17,12 +17,12 @@ namespace CalamityMod.Tiles.Furniture Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileLavaDeath[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); TileObjectData.addTile(Type); AdjTiles = new int[] { TileID.Candles }; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(238, 145, 105), CalamityUtils.GetItemName()); - AnimationFrameHeight = 34; + AnimationFrameHeight = 18; } public override void AnimateTile(ref int frame, ref int frameCounter) @@ -30,7 +30,7 @@ namespace CalamityMod.Tiles.Furniture frameCounter++; if (frameCounter >= 6) { - frame = (frame + 1) % 6; + frame = (frame + 1) % 5; frameCounter = 0; } } diff --git a/Tiles/Furniture/BlueCandle.png b/Tiles/Furniture/BlueCandle.png index db4aea46c8..5fe20f8f8b 100644 Binary files a/Tiles/Furniture/BlueCandle.png and b/Tiles/Furniture/BlueCandle.png differ diff --git a/Tiles/Furniture/Fountains/AbyssFountainTile.cs b/Tiles/Furniture/Fountains/AbyssFountainTile.cs index a1df6681c0..253fbee3ea 100644 --- a/Tiles/Furniture/Fountains/AbyssFountainTile.cs +++ b/Tiles/Furniture/Fountains/AbyssFountainTile.cs @@ -10,8 +10,6 @@ namespace CalamityMod.Tiles.Furniture.Fountains { public class AbyssFountainTile : ModTile { - int mode = 0; - public override void SetStaticDefaults() => this.SetUpFountain(ModContent.ItemType(), new Color(71, 93, 107)); public override void NearbyEffects(int i, int j, bool closer) diff --git a/Tiles/Furniture/PinkCandle.cs b/Tiles/Furniture/PinkCandle.cs index 7c7c674b71..fd4a947066 100644 --- a/Tiles/Furniture/PinkCandle.cs +++ b/Tiles/Furniture/PinkCandle.cs @@ -17,12 +17,12 @@ namespace CalamityMod.Tiles.Furniture Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileLavaDeath[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); TileObjectData.addTile(Type); AdjTiles = new int[] { TileID.Candles }; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(238, 145, 105), CalamityUtils.GetItemName()); - AnimationFrameHeight = 34; + AnimationFrameHeight = 18; } public override void AnimateTile(ref int frame, ref int frameCounter) @@ -30,7 +30,7 @@ namespace CalamityMod.Tiles.Furniture frameCounter++; if (frameCounter >= 6) { - frame = (frame + 1) % 6; + frame = (frame + 1) % 5; frameCounter = 0; } } diff --git a/Tiles/Furniture/PinkCandle.png b/Tiles/Furniture/PinkCandle.png index a74d8acee8..e22cef9737 100644 Binary files a/Tiles/Furniture/PinkCandle.png and b/Tiles/Furniture/PinkCandle.png differ diff --git a/Tiles/Furniture/PurpleCandle.cs b/Tiles/Furniture/PurpleCandle.cs index 99e312788f..232603c410 100644 --- a/Tiles/Furniture/PurpleCandle.cs +++ b/Tiles/Furniture/PurpleCandle.cs @@ -17,12 +17,12 @@ namespace CalamityMod.Tiles.Furniture Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileLavaDeath[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); TileObjectData.addTile(Type); AdjTiles = new int[] { TileID.Candles }; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(238, 145, 105), CalamityUtils.GetItemName()); - AnimationFrameHeight = 34; + AnimationFrameHeight = 18; } public override void AnimateTile(ref int frame, ref int frameCounter) @@ -30,7 +30,7 @@ namespace CalamityMod.Tiles.Furniture frameCounter++; if (frameCounter >= 6) { - frame = (frame + 1) % 6; + frame = (frame + 1) % 5; frameCounter = 0; } } diff --git a/Tiles/Furniture/PurpleCandle.png b/Tiles/Furniture/PurpleCandle.png index e8c72dee6d..41e2f749a3 100644 Binary files a/Tiles/Furniture/PurpleCandle.png and b/Tiles/Furniture/PurpleCandle.png differ diff --git a/Tiles/Furniture/YellowCandle.cs b/Tiles/Furniture/YellowCandle.cs index 1df561d340..54779eadf4 100644 --- a/Tiles/Furniture/YellowCandle.cs +++ b/Tiles/Furniture/YellowCandle.cs @@ -15,11 +15,11 @@ namespace CalamityMod.Tiles.Furniture Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileLavaDeath[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); TileObjectData.addTile(Type); AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(238, 145, 105), CalamityUtils.GetItemName()); - AnimationFrameHeight = 34; + AnimationFrameHeight = 18; } public override void AnimateTile(ref int frame, ref int frameCounter) @@ -27,7 +27,7 @@ namespace CalamityMod.Tiles.Furniture frameCounter++; if (frameCounter >= 6) { - frame = (frame + 1) % 6; + frame = (frame + 1) % 5; frameCounter = 0; } } diff --git a/Tiles/Furniture/YellowCandle.png b/Tiles/Furniture/YellowCandle.png index 3bc79d5a42..74f2a263aa 100644 Binary files a/Tiles/Furniture/YellowCandle.png and b/Tiles/Furniture/YellowCandle.png differ diff --git a/Tiles/FurnitureAshen/AshenAccentSlab.cs b/Tiles/FurnitureAshen/AshenAccentSlab.cs index 5b213032b4..3c49bc54f5 100644 --- a/Tiles/FurnitureAshen/AshenAccentSlab.cs +++ b/Tiles/FurnitureAshen/AshenAccentSlab.cs @@ -514,7 +514,6 @@ namespace CalamityMod.Tiles.FurnitureAshen Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureAshen/AshenSlabGlow").Value; Color drawColour = GetDrawColour(i, j, new Color(64, 64, 64, 64)); Tile trackTile = Main.tile[i, j]; - double num6 = Main.time * 0.08; if (!trackTile.IsHalfBlock && trackTile.Slope == 0) { Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xDrawPos, yDrawPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); diff --git a/Tiles/FurnitureAshen/AshenSlab.cs b/Tiles/FurnitureAshen/AshenSlab.cs index 9c3713b9fd..21e695cc16 100644 --- a/Tiles/FurnitureAshen/AshenSlab.cs +++ b/Tiles/FurnitureAshen/AshenSlab.cs @@ -514,7 +514,6 @@ namespace CalamityMod.Tiles.FurnitureAshen Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureAshen/AshenSlabGlow").Value; Color drawColour = GetDrawColour(i, j, new Color(64, 64, 64, 64)); Tile trackTile = Main.tile[i, j]; - double num6 = Main.time * 0.08; if (!trackTile.IsHalfBlock && trackTile.Slope == 0) { Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xDrawPos, yDrawPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlate.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlate.cs index 9e26729104..22bb415dbe 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlate.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlate.cs @@ -43,7 +43,6 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; Color drawColour = GetDrawColour(i, j, new Color(128, 128, 128, 128)); Tile trackTile = Main.tile[i, j]; - double num6 = Main.time * 0.08; TileFraming.SlopedGlowmask(i, j, 0, glowmask, drawOffset, null, GetDrawColour(i, j, drawColour), default); } diff --git a/Tiles/FurnitureProfaned/ProfanedRock.cs b/Tiles/FurnitureProfaned/ProfanedRock.cs index e955be3677..5ee5413580 100644 --- a/Tiles/FurnitureProfaned/ProfanedRock.cs +++ b/Tiles/FurnitureProfaned/ProfanedRock.cs @@ -222,7 +222,6 @@ namespace CalamityMod.Tiles.FurnitureProfaned Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; Color drawColour = GetDrawColour(i, j, new Color(25, 25, 25, 25)); Tile trackTile = Main.tile[i, j]; - double num6 = Main.time * 0.08; TileFraming.SlopedGlowmask(i, j, 0, glowmask, drawOffset, null, GetDrawColour(i, j, drawColour), default); } diff --git a/Tiles/FurnitureProfaned/RunicProfanedBrick.cs b/Tiles/FurnitureProfaned/RunicProfanedBrick.cs index f861257602..c19ece8e26 100644 --- a/Tiles/FurnitureProfaned/RunicProfanedBrick.cs +++ b/Tiles/FurnitureProfaned/RunicProfanedBrick.cs @@ -54,7 +54,6 @@ namespace CalamityMod.Tiles.FurnitureProfaned Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; Color drawColour = GetDrawColour(i, j, new Color(128, 128, 128, 128)); Tile trackTile = Main.tile[i, j]; - double num6 = Main.time * 0.08; TileFraming.SlopedGlowmask(i, j, 0, glowmask, drawOffset, null, GetDrawColour(i, j, drawColour), default); } diff --git a/Tiles/FurnitureStratus/StratusBricks.cs b/Tiles/FurnitureStratus/StratusBricks.cs index 27a94841bb..93062b4dc7 100644 --- a/Tiles/FurnitureStratus/StratusBricks.cs +++ b/Tiles/FurnitureStratus/StratusBricks.cs @@ -43,7 +43,6 @@ namespace CalamityMod.Tiles.FurnitureStratus Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; Tile trackTile = Main.tile[i, j]; - double num6 = Main.time * 0.08; TileFraming.SlopedGlowmask(i, j, 0, glowmask, drawOffset, null, GetDrawColour(i, j, drawColour), default); } diff --git a/Tiles/FurnitureVoid/SmoothVoidstone.cs b/Tiles/FurnitureVoid/SmoothVoidstone.cs index 09c3a0cba8..0f58958ee4 100644 --- a/Tiles/FurnitureVoid/SmoothVoidstone.cs +++ b/Tiles/FurnitureVoid/SmoothVoidstone.cs @@ -228,7 +228,6 @@ namespace CalamityMod.Tiles.FurnitureVoid brightness *= (float)MathF.Sin(i * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); brightness *= (float)MathF.Sin(j * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); drawColour *= brightness; - double num6 = Main.time * 0.08; TileFraming.SlopedGlowmask(i, j, 0, glowmask, drawOffset, null, GetDrawColour(i, j, drawColour), default); } diff --git a/Tiles/FurnitureVoid/VoidstoneSlab.cs b/Tiles/FurnitureVoid/VoidstoneSlab.cs index 3e104ec428..a225d5eb71 100644 --- a/Tiles/FurnitureVoid/VoidstoneSlab.cs +++ b/Tiles/FurnitureVoid/VoidstoneSlab.cs @@ -159,7 +159,6 @@ namespace CalamityMod.Tiles.FurnitureVoid Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; Color drawColour = GetDrawColour(i, j, new Color(75, 75, 75, 75)); Tile trackTile = Main.tile[i, j]; - double num6 = Main.time * 0.08; if (!trackTile.IsHalfBlock && trackTile.Slope == 0) { Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); diff --git a/Tiles/MonsterBanner.png b/Tiles/MonsterBanner.png index 78d5000425..1ad6b8d5b4 100644 Binary files a/Tiles/MonsterBanner.png and b/Tiles/MonsterBanner.png differ diff --git a/Tiles/Rubblemaker/Abyss/MassiveRarePearlEcho.cs b/Tiles/Rubblemaker/Abyss/MassiveRarePearlEcho.cs index cc9bb319fe..9a12c0cc2e 100644 --- a/Tiles/Rubblemaker/Abyss/MassiveRarePearlEcho.cs +++ b/Tiles/Rubblemaker/Abyss/MassiveRarePearlEcho.cs @@ -1,9 +1,8 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; -using Terraria.DataStructures; -using Terraria.ModLoader; using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; using Terraria.ObjectData; namespace CalamityMod.Tiles.Rubblemaker.Abyss @@ -17,8 +16,8 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss Main.tileLavaDeath[Type] = true; Main.tileWaterDeath[Type] = false; Main.tileNoAttach[Type] = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(106, 80, 102)); DustType = 33; diff --git a/Tiles/Rubblemaker/SunkenSea/MediumCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/MediumCoralEcho.cs index cd95f01c3f..2583c0c2f7 100644 --- a/Tiles/Rubblemaker/SunkenSea/MediumCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/MediumCoralEcho.cs @@ -1,6 +1,5 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -17,8 +16,8 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea Main.tileLavaDeath[Type] = true; Main.tileWaterDeath[Type] = false; Main.tileNoAttach[Type] = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(233, 132, 58)); DustType = DustID.Coralstone; diff --git a/Tiles/Rubblemaker/SunkenSea/SmallWideCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/SmallWideCoralEcho.cs index 5ee30cd7be..61a47c4125 100644 --- a/Tiles/Rubblemaker/SunkenSea/SmallWideCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/SmallWideCoralEcho.cs @@ -1,15 +1,9 @@ -using CalamityMod.Projectiles.Environment; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.DataStructures; -using Terraria.Enums; using Terraria.GameContent; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; -using System; namespace CalamityMod.Tiles.Rubblemaker.SunkenSea { @@ -22,8 +16,8 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea Main.tileLavaDeath[Type] = true; Main.tileWaterDeath[Type] = false; Main.tileNoAttach[Type] = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(137, 154, 71)); DustType = DustID.Coralstone; diff --git a/Tiles/SunkenSea/MediumCoral.cs b/Tiles/SunkenSea/MediumCoral.cs index 90399e6c3f..0b81d79d94 100644 --- a/Tiles/SunkenSea/MediumCoral.cs +++ b/Tiles/SunkenSea/MediumCoral.cs @@ -1,6 +1,5 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -15,8 +14,8 @@ namespace CalamityMod.Tiles.SunkenSea Main.tileLavaDeath[Type] = true; Main.tileWaterDeath[Type] = false; Main.tileNoAttach[Type] = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(233, 132, 58)); DustType = DustID.Coralstone; diff --git a/Tiles/SunkenSea/SmallWideCoral.cs b/Tiles/SunkenSea/SmallWideCoral.cs index 45408576e0..f0c524f145 100644 --- a/Tiles/SunkenSea/SmallWideCoral.cs +++ b/Tiles/SunkenSea/SmallWideCoral.cs @@ -1,14 +1,8 @@ -using CalamityMod.Projectiles.Environment; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; -using Terraria.DataStructures; -using Terraria.Enums; using Terraria.ModLoader; using Terraria.ObjectData; -using System; namespace CalamityMod.Tiles.SunkenSea { @@ -20,8 +14,8 @@ namespace CalamityMod.Tiles.SunkenSea Main.tileLavaDeath[Type] = true; Main.tileWaterDeath[Type] = false; Main.tileNoAttach[Type] = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(137, 154, 71)); DustType = DustID.Coralstone; diff --git a/Utilities/CalamityRecipes.cs b/Utilities/CalamityRecipes.cs index 795f9ebd4c..787f5ee4fc 100644 --- a/Utilities/CalamityRecipes.cs +++ b/Utilities/CalamityRecipes.cs @@ -748,6 +748,7 @@ namespace CalamityMod AddCookedFood(); AddEssentialToolRecipes(); AddSummonAndProgressionRecipes(); + AddTombstoneRecipes(); AddEarlyGameWeaponRecipes(); AddEarlyGameAccessoryRecipes(); AddHardmodeItemRecipes(); @@ -1973,5 +1974,65 @@ namespace CalamityMod convert[ItemID.FlyingCarpet] = ItemID.AmberHook; } #endregion + + #region Tombstone Recipes + + private static void AddTombstoneRecipes() + { + short[] woodenTombstones = new[] + { + ItemID.CrossGraveMarker, + ItemID.GraveMarker + }; + + short[] stoneTombstones = new[] + { + ItemID.Gravestone, + ItemID.Headstone, + ItemID.Obelisk, + ItemID.Tombstone + }; + + short[] goldenTombstones = new[] + { + ItemID.RichGravestone1, + ItemID.RichGravestone2, + ItemID.RichGravestone3, + ItemID.RichGravestone4, + ItemID.RichGravestone5 + }; + + Recipe r; + + foreach (var tombstone in woodenTombstones) + { + r = Recipe.Create(tombstone); + r.AddRecipeGroup(RecipeGroupID.Wood, 15); + r.AddTile(TileID.Sawmill); + r.Register(); + r.DisableDecraft(); + } + + foreach (var tombstone in stoneTombstones) + { + r = Recipe.Create(tombstone); + r.AddRecipeGroup(AnyStoneBlock, 15); + r.AddTile(TileID.HeavyWorkBench); + r.Register(); + r.DisableDecraft(); + } + + foreach (var tombstone in goldenTombstones) + { + r = Recipe.Create(tombstone); + r.AddRecipeGroup(AnyStoneBlock, 15); + r.AddRecipeGroup(AnyGoldBar); + r.AddTile(TileID.HeavyWorkBench); + r.Register(); + r.DisableDecraft(); + } + } + + #endregion } } diff --git a/Utilities/DrawingUtils.cs b/Utilities/DrawingUtils.cs index 8e7d8da452..becea0357c 100644 --- a/Utilities/DrawingUtils.cs +++ b/Utilities/DrawingUtils.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Graphics; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using ReLogic.Graphics; @@ -858,5 +859,27 @@ namespace CalamityMod drawCall.Invoke(offset, aberrationColor); } } + + /// + /// Sets the current render target to the provided one. + /// + /// The render target to swap to + /// The color to clear the screen with. Transparent by default + public static void SwapTo(this ManagedRenderTarget target, Color? flushColor = null) => SwapTo(target.Target, flushColor); + + /// + /// Sets the current render target to the provided one. + /// + /// The render target to swap to + /// The color to clear the screen with. Transparent by default + public static void SwapTo(this RenderTarget2D target, Color? flushColor = null) + { + // If we are in the menu, a server, or any of these are null, return. + if (Main.gameMenu || Main.dedServ || target is null || Main.instance.GraphicsDevice is null || Main.spriteBatch is null) + return; + + Main.instance.GraphicsDevice.SetRenderTarget(target); + Main.instance.GraphicsDevice.Clear(flushColor ?? Color.Transparent); + } } } diff --git a/Utilities/FurnitureSetupUtils.cs b/Utilities/FurnitureSetupUtils.cs index 73ae83f344..093fbf5073 100644 --- a/Utilities/FurnitureSetupUtils.cs +++ b/Utilities/FurnitureSetupUtils.cs @@ -406,19 +406,19 @@ namespace CalamityMod { player.piggyBankProjTracker.Clear(); player.voidLensChest.Clear(); - int num213 = Chest.FindChest(left, top); - if (num213 != -1) + int dresserChestID = Chest.FindChest(left, top); + if (dresserChestID != -1) { Main.stackSplit = 600; - if (num213 == player.chest) + if (dresserChestID == player.chest) { player.chest = -1; Recipe.FindRecipes(); SoundEngine.PlaySound(SoundID.MenuClose); } - else if (num213 != player.chest && player.chest == -1) + else if (dresserChestID != player.chest && player.chest == -1) { - player.chest = num213; + player.chest = dresserChestID; Main.playerInventory = true; Main.recBigList = false; SoundEngine.PlaySound(SoundID.MenuOpen); @@ -427,7 +427,7 @@ namespace CalamityMod } else { - player.chest = num213; + player.chest = dresserChestID; Main.playerInventory = true; Main.recBigList = false; SoundEngine.PlaySound(SoundID.MenuTick); diff --git a/Utilities/GenericAIUtils.cs b/Utilities/GenericAIUtils.cs index 3743965ad5..fc86528c32 100644 --- a/Utilities/GenericAIUtils.cs +++ b/Utilities/GenericAIUtils.cs @@ -480,11 +480,11 @@ namespace CalamityMod if (npc.type == NPCID.SolarCrawltipedeTail) { Rectangle rect = npc.Hitbox; - int num5 = 8; - rect.X -= num5; - rect.Y -= num5; - rect.Width += num5 * 2; - rect.Height += num5 * 2; + int crawltipedeHitboxMod = 8; + rect.X -= crawltipedeHitboxMod; + rect.Y -= crawltipedeHitboxMod; + rect.Width += crawltipedeHitboxMod * 2; + rect.Height += crawltipedeHitboxMod * 2; stickingToNPC = projectile.Colliding(myRect, rect); } else @@ -526,15 +526,15 @@ namespace CalamityMod } if (projCount >= array2.Length) { - int num30 = 0; + int stuckProjAmt = 0; for (int m = 1; m < array2.Length; m++) { - if (array2[m].Y < array2[num30].Y) + if (array2[m].Y < array2[stuckProjAmt].Y) { - num30 = m; + stuckProjAmt = m; } } - Main.projectile[array2[num30].X].Kill(); + Main.projectile[array2[stuckProjAmt].X].Kill(); } } } diff --git a/Utilities/ItemUtils.cs b/Utilities/ItemUtils.cs index 223d1867c6..bbfb91dcf5 100644 --- a/Utilities/ItemUtils.cs +++ b/Utilities/ItemUtils.cs @@ -684,7 +684,7 @@ namespace CalamityMod { SoundEngine.PlaySound(item.UseSound.GetValueOrDefault(), player.Center); - int healAmt = (int)(item.healLife * player.Calamity().healingPotBonus); + int healAmt = (int)(item.healLife * player.Calamity().healingPotionMultiplier); if (healAmt > 0 && player.QuickHeal_GetItemToUse() != null) { if (player.QuickHeal_GetItemToUse().type != item.type) diff --git a/Utilities/MiscUtils.cs b/Utilities/MiscUtils.cs index 6a294a5d54..dd81e33cd4 100644 --- a/Utilities/MiscUtils.cs +++ b/Utilities/MiscUtils.cs @@ -197,51 +197,51 @@ namespace CalamityMod public static void StartRain(bool torrentialTear = false, bool maxSeverity = false) { - int num = 86400; - int num2 = num / 24; - Main.rainTime = Main.rand.Next(num2 * 8, num); + int framesInDay = 86400; + int framesInHour = framesInDay / 24; + Main.rainTime = Main.rand.Next(framesInHour * 8, framesInDay); if (Main.rand.NextBool(3)) { - Main.rainTime += Main.rand.Next(0, num2); + Main.rainTime += Main.rand.Next(0, framesInHour); } if (Main.rand.NextBool(4)) { - Main.rainTime += Main.rand.Next(0, num2 * 2); + Main.rainTime += Main.rand.Next(0, framesInHour * 2); } if (Main.rand.NextBool(5)) { - Main.rainTime += Main.rand.Next(0, num2 * 2); + Main.rainTime += Main.rand.Next(0, framesInHour * 2); } if (Main.rand.NextBool(6)) { - Main.rainTime += Main.rand.Next(0, num2 * 3); + Main.rainTime += Main.rand.Next(0, framesInHour * 3); } if (Main.rand.NextBool(7)) { - Main.rainTime += Main.rand.Next(0, num2 * 4); + Main.rainTime += Main.rand.Next(0, framesInHour * 4); } if (Main.rand.NextBool(8)) { - Main.rainTime += Main.rand.Next(0, num2 * 5); + Main.rainTime += Main.rand.Next(0, framesInHour * 5); } - float num3 = 1f; + float randRainExtender = 1f; if (Main.rand.NextBool()) { - num3 += 0.05f; + randRainExtender += 0.05f; } if (Main.rand.NextBool(3)) { - num3 += 0.1f; + randRainExtender += 0.1f; } if (Main.rand.NextBool(4)) { - num3 += 0.15f; + randRainExtender += 0.15f; } if (Main.rand.NextBool(5)) { - num3 += 0.2f; + randRainExtender += 0.2f; } - Main.rainTime = (int)(Main.rainTime * num3); + Main.rainTime = (int)(Main.rainTime * randRainExtender); Main.raining = true; if (torrentialTear) TorrentialTear.AdjustRainSeverity(maxSeverity); diff --git a/Utilities/NPCDebuffs.cs b/Utilities/NPCDebuffs.cs index 2e1f20417f..d57e7c20de 100644 --- a/Utilities/NPCDebuffs.cs +++ b/Utilities/NPCDebuffs.cs @@ -14,7 +14,6 @@ using CalamityMod.NPCs.CeaselessVoid; using CalamityMod.NPCs.Crags; using CalamityMod.NPCs.Cryogen; using CalamityMod.NPCs.DevourerofGods; -using CalamityMod.NPCs.ExoMechs.Ares; using CalamityMod.NPCs.ExoMechs.Thanatos; using CalamityMod.NPCs.Leviathan; using CalamityMod.NPCs.NormalNPCs; @@ -272,10 +271,6 @@ namespace CalamityMod { ModContent.NPCType(), immuneToEverything }, { ModContent.NPCType(), immuneToEverything }, - // 20FEB2023: Ozzatron: made Ares immune to Miracle Blight, because otherwise he vanishes when affected by it - // The "correct" way to fix this involves a colossal amount of work and will be handled at a later date - { ModContent.NPCType(), new(GeneralImmunityStatus.None, new int[] { ModContent.BuffType() }) }, - { ModContent.NPCType(), crags }, { ModContent.NPCType(), crags }, { ModContent.NPCType(), crags }, diff --git a/Utilities/NPCUtils.cs b/Utilities/NPCUtils.cs index 4c4ff6b994..84565bea36 100644 --- a/Utilities/NPCUtils.cs +++ b/Utilities/NPCUtils.cs @@ -55,7 +55,7 @@ namespace CalamityMod /// public static void HideFromBestiary(this ModNPC n) { - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Hide = true }; diff --git a/Utilities/PlayerUtils.cs b/Utilities/PlayerUtils.cs index 2c835c9d85..7c24ac6e90 100644 --- a/Utilities/PlayerUtils.cs +++ b/Utilities/PlayerUtils.cs @@ -1,15 +1,15 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Balancing; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer; using CalamityMod.Cooldowns; +using CalamityMod.Events; +using CalamityMod.Items.Potions.Alcohol; +using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; using static Terraria.Player; namespace CalamityMod @@ -23,9 +23,36 @@ namespace CalamityMod return player.statDefense + (accountForDefenseDamage ? 0 : mp.CurrentDefenseDamage); } + public static int GetDefenseDamageFloor() + { + if (BossRushEvent.BossRushActive) + return BalancingConstants.DefenseDamageFloor_BossRush; + else if (NPC.downedMoonlord) + { + return CalamityWorld.death ? BalancingConstants.DefenseDamageFloor_DeathPML + : CalamityWorld.revenge ? BalancingConstants.DefenseDamageFloor_RevPML + : BalancingConstants.DefenseDamageFloor_NormalPML; + } + else if (Main.hardMode) + { + return CalamityWorld.death ? BalancingConstants.DefenseDamageFloor_DeathHM + : CalamityWorld.revenge ? BalancingConstants.DefenseDamageFloor_RevHM + : BalancingConstants.DefenseDamageFloor_NormalHM; + } + else + { + return CalamityWorld.death ? BalancingConstants.DefenseDamageFloor_DeathPHM + : CalamityWorld.revenge ? BalancingConstants.DefenseDamageFloor_RevPHM + : BalancingConstants.DefenseDamageFloor_NormalPHM; + } + } + public static float CalcDamage(this Player player, float baseDamage) where T : DamageClass => player.GetTotalDamage().ApplyTo(baseDamage); public static int CalcIntDamage(this Player player, float baseDamage) where T : DamageClass => (int)player.CalcDamage(baseDamage); + // Calculate and return Old Fashioned damage adjustment for Accessories and Set Bonuses. + public static int CalcOldFashionedDamage(int damage) => (int)(damage * OldFashioned.AccessoryAndSetBonusDamageMultiplier); + // Naively determines the player's chosen (aka "best") class by whichever has the highest damage boost. public static DamageClass GetBestClass(this Player player) { @@ -654,7 +681,7 @@ namespace CalamityMod } #endregion - #region visual layers + #region Visual Layers public static void HideAccessories(this Player player, bool hideHeadAccs = true, bool hideBodyAccs = true, bool hideLegAccs = true, bool hideShield = true) { if (hideHeadAccs) diff --git a/Utilities/ProjectileUtils.cs b/Utilities/ProjectileUtils.cs index ff3ca686ae..a8840f284a 100644 --- a/Utilities/ProjectileUtils.cs +++ b/Utilities/ProjectileUtils.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Melee.Yoyos; -using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; @@ -19,7 +18,36 @@ namespace CalamityMod { public static partial class CalamityUtils { - public static int CountProjectiles(int Type) => Main.projectile.Count(proj => proj.type == Type && proj.active); + public static bool AnyProjectiles(int projectileID) + { + // Efficiently loop through all projectiles, using a specially designed continue continue that attempts to minimize the amount of OR + // checks per iteration. + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile p = Main.projectile[i]; + if (p.type != projectileID || !p.active) + continue; + + return true; + } + + return false; + } + + public static IEnumerable AllProjectilesByID(int projectileID) + { + // This uses the same efficient loop idea as AnyProjectiles. + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile p = Main.projectile[i]; + if (p.type != projectileID || !p.active) + continue; + + yield return p; + } + } + + public static int CountProjectiles(int projectileID) => Main.projectile.Count(proj => proj.type == projectileID && proj.active); public static int CountHookProj() => Main.projectile.Count(proj => Main.projHook[proj.type] && proj.ai[0] == 2f && proj.active && proj.owner == Main.myPlayer); @@ -157,7 +185,7 @@ namespace CalamityMod public static Vector2 SuperhomeTowardsTarget(this Projectile projectile, NPC target, float homingSpeed, float inertia, float predictionStrength = 1f) { if (predictionStrength < 0.01f) { predictionStrength = 0.01f; } - Vector2 idealVelocity = CalculatePredictiveAimToTarget(projectile.Center, target, homingSpeed/predictionStrength) * predictionStrength; + Vector2 idealVelocity = CalculatePredictiveAimToTarget(projectile.Center, target, homingSpeed / predictionStrength) * predictionStrength; return (projectile.velocity * (inertia - 1f) + idealVelocity) / inertia; } #endregion @@ -361,6 +389,126 @@ namespace CalamityMod } } } + + public struct RocketBehaviorInfo + { + internal int rocketItemType; + + // Explosion radii for various rocket ammos. Defaults to the sizes used in vanilla launchers. + public int smallRadius = 3; // Rocket I and II + public int mediumRadius = 6; // Rocket III and IV + public int largeRadius = 9; // Mini Nuke and Cluster Rockets + + public bool respectStandardBlastImmunity = true; + public List tilesToCheck = null; + public List wallsToCheck = null; + + public int clusterProjectileID = ProjectileID.ClusterFragmentsI; + public int destructiveClusterProjectileID = ProjectileID.ClusterFragmentsII; + public float clusterSplitDamageMultiplier = 0.5f; + + public RocketBehaviorInfo(int rocketID) + { + rocketItemType = rocketID; + } + } + + /// + /// For a given projectile that is used as a rocket and uses rocket ammo, this utility provides a shorthand way to check for checking what behaviour should each type of ammo do. It can also return you the radius of the explosion that'll happen so you can use it for your effect's size. + /// + /// The projectile in question. + /// Struct containing information on the desired rocket behavior. + public static int RocketBehavior(this Projectile proj, RocketBehaviorInfo info) + { + int explosionRadius = 0; + + // Used for Cluster Rockets to determine damage. + + // Used for Dry Rockets, Water Rockets etc. to place water. Not always needed. + Point center = proj.Center.ToTileCoordinates(); + DelegateMethods.v2_1 = center.ToVector2(); + DelegateMethods.f_1 = 3f; + + void SpawnClusterFragments(bool destructiveVariant = false) + { + if (proj.owner != Main.myPlayer) + return; + + int projID = destructiveVariant ? info.destructiveClusterProjectileID : info.clusterProjectileID; + int clusterDamage = (int)(proj.damage * info.clusterSplitDamageMultiplier); + + float thetaStart = Main.rand.NextFloat(0f, MathHelper.TwoPi); + for (float i = 0; i < 6; ++i) + { + float thetaIter = thetaStart + (i * MathHelper.TwoPi / 6f); + float dist = Main.rand.NextFloat(4f, 6f); + + Vector2 clusterVel = thetaIter.ToRotationVector2() * dist - Vector2.UnitY; + + Projectile clusterFragment = Projectile.NewProjectileDirect(proj.GetSource_FromThis(), proj.Center, clusterVel, projID, clusterDamage, 0f, proj.owner); + clusterFragment.timeLeft -= Main.rand.Next(30); + } + } + + switch (info.rocketItemType) + { + case ItemID.RocketI: + explosionRadius = info.smallRadius; + break; + + case ItemID.RocketII: + explosionRadius = info.smallRadius; + proj.ExplodeTiles(explosionRadius, info.respectStandardBlastImmunity, info.tilesToCheck, info.wallsToCheck); + break; + + case ItemID.RocketIII: + explosionRadius = info.mediumRadius; + break; + + case ItemID.RocketIV: + explosionRadius = info.mediumRadius; + proj.ExplodeTiles(explosionRadius, info.respectStandardBlastImmunity, info.tilesToCheck, info.wallsToCheck); + break; + + case ItemID.MiniNukeI: + explosionRadius = info.largeRadius; + break; + + case ItemID.MiniNukeII: + explosionRadius = info.largeRadius; + proj.ExplodeTiles(explosionRadius, info.respectStandardBlastImmunity, info.tilesToCheck, info.wallsToCheck); + break; + + case ItemID.ClusterRocketI: + explosionRadius = info.largeRadius; + SpawnClusterFragments(false); + break; + + case ItemID.ClusterRocketII: + explosionRadius = info.largeRadius; + SpawnClusterFragments(true); + break; + + case ItemID.DryRocket: + DelegateMethods.f_1 = 3.5f; + Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadDry); + break; + + case ItemID.WetRocket: + Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadWater); + break; + + case ItemID.LavaRocket: + Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadLava); + break; + + case ItemID.HoneyRocket: + Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadHoney); + break; + } + + return explosionRadius; + } #endregion public static int FindFirstProjectile(int Type) @@ -573,12 +721,30 @@ namespace CalamityMod } } - public static void ExplodeandDestroyTiles(Projectile projectile, int explosionRadius, bool checkExplosions, List tilesToCheck, List wallsToCheck) + private static readonly List vanillaBlastImmuneTiles = new List() { - int minTileX = (int)projectile.position.X / 16 - explosionRadius; - int maxTileX = (int)projectile.position.X / 16 + explosionRadius; - int minTileY = (int)projectile.position.Y / 16 - explosionRadius; - int maxTileY = (int)projectile.position.Y / 16 + explosionRadius; + TileID.DemonAltar, + TileID.Cobalt, + TileID.Mythril, + TileID.Adamantite, + TileID.Palladium, + TileID.Orichalcum, + TileID.Titanium, + TileID.Chlorophyte, + TileID.LihzahrdBrick, + TileID.LihzahrdAltar, + TileID.DesertFossil + }; + + public static void ExplodeTiles(this Projectile p, int explosionRadius, bool respectStandardBlastImmunity = true, IEnumerable customBlastImmuneTiles = null, IEnumerable customBlastImmuneWalls = null) + => ExplodeTiles(p.Center, explosionRadius, respectStandardBlastImmunity, customBlastImmuneTiles, customBlastImmuneWalls); + public static void ExplodeTiles(Vector2 explosionPos, int explosionRadius, bool respectStandardBlastImmunity = true, IEnumerable customBlastImmuneTiles = null, IEnumerable customBlastImmuneWalls = null) + { + // Define limits for explosion iteration. + int minTileX = (int)explosionPos.X / 16 - explosionRadius; + int maxTileX = (int)explosionPos.X / 16 + explosionRadius; + int minTileY = (int)explosionPos.Y / 16 - explosionRadius; + int maxTileY = (int)explosionPos.Y / 16 + explosionRadius; if (minTileX < 0) { minTileX = 0; @@ -596,109 +762,130 @@ namespace CalamityMod maxTileY = Main.maxTilesY; } - bool canKillWalls = false; - float projectilePositionX = projectile.position.X / 16f; - float projectilePositionY = projectile.position.Y / 16f; + // This checks for whether the explosion should be allowed to destroy walls. It's rather arbitrary, but it's how vanilla works. + bool allowWallDestruction = false; + float projTileX = explosionPos.X / 16f; + float projTileY = explosionPos.Y / 16f; for (int x = minTileX; x <= maxTileX; x++) { for (int y = minTileY; y <= maxTileY; y++) { - Vector2 explodeArea = new Vector2(Math.Abs(x - projectilePositionX), Math.Abs(y - projectilePositionY)); + Vector2 explodeArea = new Vector2(Math.Abs(x - projTileX), Math.Abs(y - projTileY)); float distance = explodeArea.Length(); if (distance < explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].WallType == WallID.None) { - canKillWalls = true; + allowWallDestruction = true; break; } } } - List tileExcludeList = new List() + // Tiles which can never be exploded under any circumstances. Bad things happen if they blow up. + HashSet blastImmuneTiles = new() { TileID.DemonAltar, TileID.ElderCrystalStand }; - for (int i = 0; i < tilesToCheck.Count; ++i) - tileExcludeList.Add(tilesToCheck[i]); - List wallExcludeList = new List(); - for (int i = 0; i < wallsToCheck.Count; ++i) - wallExcludeList.Add(wallsToCheck[i]); - List explosionCheckList = new List() + // If respecting vanilla blast immunities, toss in that whole list. + if (respectStandardBlastImmunity) { - TileID.DemonAltar, - TileID.Cobalt, - TileID.Mythril, - TileID.Adamantite, - TileID.Palladium, - TileID.Orichalcum, - TileID.Titanium, - TileID.Chlorophyte, - TileID.LihzahrdBrick, - TileID.LihzahrdAltar, - TileID.DesertFossil - }; - AddWithCondition(explosionCheckList, TileID.Hellstone, !Main.hardMode); + foreach (int tileID in vanillaBlastImmuneTiles) + blastImmuneTiles.Add(tileID); - for (int i = minTileX; i <= maxTileX; i++) + // Conditionally toss in Hellstone if it's not Hardmode yet. + if (!Main.hardMode) + blastImmuneTiles.Add(TileID.Hellstone); + } + + // If specified, add custom blast immune tiles. + if (customBlastImmuneTiles is not null) + foreach (int tileID in customBlastImmuneTiles) + blastImmuneTiles.Add(tileID); + + // If specified, define custom blast immune walls. + HashSet blastImmuneWalls = null; + if (customBlastImmuneWalls is not null) { - for (int j = minTileY; j <= maxTileY; j++) + blastImmuneWalls = new(); + foreach (int wallID in customBlastImmuneWalls) + blastImmuneWalls.Add(wallID); + } + + // Actually perform the explosion. + bool refTrue = true, refFalse = false; + for (int tx = minTileX; tx <= maxTileX; tx++) + { + for (int ty = minTileY; ty <= maxTileY; ty++) { - Tile tile = Main.tile[i, j]; - bool t = 1 == 1; bool f = 1 == 2; + Tile tile = Main.tile[tx, ty]; + ushort type = tile.TileType; - Vector2 explodeArea = new Vector2(Math.Abs(i - projectilePositionX), Math.Abs(j - projectilePositionY)); + Vector2 explodeArea = new Vector2(Math.Abs(tx - projTileX), Math.Abs(ty - projTileY)); float distance = explodeArea.Length(); - if (distance < explosionRadius) + if (distance >= explosionRadius) + continue; + + bool canBlastThisTile = true; + if (tile != null && tile.HasTile) { - bool canKillTile = true; - if (tile != null && tile.HasTile) + if (blastImmuneTiles.Contains(type) || // Respects standard blast immunities if enabled, so they're covered + Main.tileContainer[tile.TileType] || // Chests should never be exploded + // Dungeon tiles and TileLoader CanExplode are considered part of respecting standard blast immunities + respectStandardBlastImmunity && (Main.tileDungeon[type] || !TileLoader.CanExplode(tx, ty)) || + // TileLoader CanKillTile can block the destruction of a tile regardless of whether it is via an explosion + !TileLoader.CanKillTile(tx, ty, tile.TileType, ref refTrue) || !TileLoader.CanKillTile(tx, ty, tile.TileType, ref refFalse)) { - if (checkExplosions) - { - if (Main.tileDungeon[tile.TileType] || explosionCheckList.Contains(tile.TileType)) - canKillTile = false; - if (!TileLoader.CanExplode(i, j)) - canKillTile = false; - } - - if (Main.tileContainer[tile.TileType]) - canKillTile = false; - if (!TileLoader.CanKillTile(i, j, tile.TileType, ref t) || !TileLoader.CanKillTile(i, j, tile.TileType, ref f)) - canKillTile = false; - if (tileExcludeList.Contains(tile.TileType)) - canKillTile = false; - - if (canKillTile) - { - WorldGen.KillTile(i, j, false, false, false); - if (!tile.HasTile && Main.netMode != NetmodeID.SinglePlayer) - NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, i, j, 0f, 0, 0, 0); - } + canBlastThisTile = false; } - if (canKillTile) + // Destroy the tile itself (not the wall). + if (canBlastThisTile) { - for (int x = i - 1; x <= i + 1; x++) - { - for (int y = j - 1; y <= j + 1; y++) - { - bool canExplode = true; - if (checkExplosions) - canExplode = WallLoader.CanExplode(x, y, Main.tile[x, y].WallType); - if (wallExcludeList.Any() && wallExcludeList.Contains(Main.tile[x, y].WallType)) - canKillWalls = false; + WorldGen.KillTile(tx, ty, false, false, false); - if (Main.tile[x, y] != null && Main.tile[x, y].WallType > WallID.None && canKillWalls && canExplode) - { - WorldGen.KillWall(x, y, false); - if (Main.tile[x, y].WallType == WallID.None && Main.netMode != NetmodeID.SinglePlayer) - NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 2, x, y, 0f, 0, 0, 0); - } - } + // If the tile was actually destroyed (KillTile can fail) then send netcode indicating as such. + if (!tile.HasTile && Main.netMode != NetmodeID.SinglePlayer) + NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, tx, ty, 0f, 0, 0, 0); + } + } + + // Skip destroying walls if the tile was not blasted + // Also skip destroying walls if this explosion is not allowed to destroy walls by vanilla rules + if (!canBlastThisTile || !allowWallDestruction) + continue; + + // For every destroyed tile, destroy a 3x3 area of walls around it to prevent ugly wall corners + // This is what causes explosion packet spam, btw. + for (int wx = tx - 1; wx <= tx + 1; wx++) + { + for (int wy = ty - 1; wy <= ty + 1; wy++) + { + // Check whether this wall is explodable. + bool canBlastThisWall = !respectStandardBlastImmunity || WallLoader.CanExplode(wx, wy, Main.tile[wx, wy].WallType); + + // If custom wall blast immunities were defined, respect them. + // If this is what stops a wall from being blown up, prevent all further wall destruction to prevent ugly floating walls. + if (blastImmuneWalls is not null && blastImmuneWalls.Contains(Main.tile[wx, wy].WallType)) + { + allowWallDestruction = false; + goto PostWallBlastLoop; // Walls cannot be destroyed for the remainder of this explosion. Stop now. + } + + // Destroy the wall itself. + if (Main.tile[wx, wy] != null && Main.tile[wx, wy].WallType > WallID.None && canBlastThisWall) + { + WorldGen.KillWall(wx, wy, false); + + // If the wall was actually destroyed (KillWall can fail) then send netcode indicating as such. + if (Main.tile[wx, wy].WallType == WallID.None && Main.netMode != NetmodeID.SinglePlayer) + NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 2, wx, wy, 0f, 0, 0, 0); } } } + + // Label to jump to if wall destruction is aborted. + PostWallBlastLoop:; } } } diff --git a/Utilities/TileFraming.cs b/Utilities/TileFraming.cs index 3dc71ec86e..4b614ad800 100644 --- a/Utilities/TileFraming.cs +++ b/Utilities/TileFraming.cs @@ -1941,6 +1941,8 @@ namespace CalamityMod // 02OCT2023: MishiroUsui: The below code resulted in 30 fps drops in sulph sea, and general performance issues across the board in cal biomes // DO NOT RE-ENABLE UNTIL THE ISSUE IS RESOLVED AND VERIFIED. return; + #pragma warning disable CS0162 // Disable unreachable code errors while this code is disabled + Texture2D blendLayer = ModContent.Request(blendSheetPath).Value; Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(x * 16 - Main.screenPosition.X, y * 16 - Main.screenPosition.Y) + zero; @@ -2299,6 +2301,7 @@ namespace CalamityMod Main.spriteBatch.Draw(blendLayer, drawOffset, new Rectangle?(new Rectangle(18 + randomFrameX36 + subFrameX, 54 + subFrameY, 18, 18)), shadingColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } #endregion + #pragma warning restore CS0162 // Disable unreachable code errors while this code is disabled } /// diff --git a/Utilities/TileUtils.cs b/Utilities/TileUtils.cs index 9a5b62928b..981e12cdeb 100644 --- a/Utilities/TileUtils.cs +++ b/Utilities/TileUtils.cs @@ -114,13 +114,13 @@ namespace CalamityMod int height = 16; int yOffset = TileObjectData.GetTileData(tile).DrawYOffset; - ulong num190 = Main.TileFrameSeed ^ (ulong)((long)j << 32 | (long)(uint)i); + ulong randShakeEffect = Main.TileFrameSeed ^ (ulong)((long)j << 32 | (long)(uint)i); float drawPositionX = i * 16 - (int)Main.screenPosition.X - (width - 16f) / 2f; float drawPositionY = j * 16 - (int)Main.screenPosition.Y; for (int c = 0; c < 7; c++) { - float shakeX = Utils.RandomInt(ref num190, -10, 11) * 0.15f; - float shakeY = Utils.RandomInt(ref num190, -10, 1) * 0.35f; + float shakeX = Utils.RandomInt(ref randShakeEffect, -10, 11) * 0.15f; + float shakeY = Utils.RandomInt(ref randShakeEffect, -10, 1) * 0.35f; Main.spriteBatch.Draw(flameTexture, new Vector2(drawPositionX + shakeX, drawPositionY + shakeY + yOffset) + zero, new Rectangle(tile.TileFrameX + offsetX, tile.TileFrameY + offsetY, width, height), new Color(100, 100, 100, 0), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } } @@ -666,100 +666,5 @@ namespace CalamityMod return !Main.tileContainer[tile.TileType] && !tileExcludeList.Contains(tile.TileType); } - - /// - /// Gets the item drop of an ore tile - /// - /// - /// The item a tile breaks when drops if it's an ore - public static int GetOreItemID(this Tile tile) - { - int item = -1; - - // If it's not ore, then return - if (!TileID.Sets.Ore[tile.TileType]) - return item; - - ModTile moddedTile = TileLoader.GetTile(tile.TileType); - - //Getting the item drop of a modded tile is pretty easy. - if (moddedTile != null) - item = TileLoader.GetItemDropFromTypeAndStyle(moddedTile.Type); - - //There is no easy way for getting vanilla item drops :( - else - { - switch (tile.TileType) - { - case TileID.LunarOre: - item = ItemID.LunarOre; - break; - case TileID.Chlorophyte: - item = ItemID.ChlorophyteOre; - break; - case TileID.Titanium: - item = ItemID.TitaniumOre; - break; - case TileID.Adamantite: - item = ItemID.AdamantiteOre; - break; - case TileID.Orichalcum: - item = ItemID.OrichalcumOre; - break; - case TileID.Mythril: - item = ItemID.MythrilOre; - break; - case TileID.Palladium: - item = ItemID.PalladiumOre; - break; - case TileID.Cobalt: - item = ItemID.CobaltOre; - break; - case TileID.Hellstone: - item = ItemID.Hellstone; - break; - case TileID.Obsidian: - item = ItemID.Obsidian; - break; - case TileID.Meteorite: - item = ItemID.Meteorite; - break; - case TileID.Demonite: - item = ItemID.DemoniteOre; - break; - case TileID.Crimtane: - item = ItemID.CrimtaneOre; - break; - case TileID.Platinum: - item = ItemID.PlatinumOre; - break; - case TileID.Gold: - item = ItemID.GoldOre; - break; - case TileID.Tungsten: - item = ItemID.TungstenOre; - break; - case TileID.Silver: - item = ItemID.SilverOre; - break; - case TileID.Lead: - item = ItemID.LeadOre; - break; - case TileID.Iron: - item = ItemID.IronOre; - break; - case TileID.Tin: - item = ItemID.TinOre; - break; - case TileID.Copper: - item = ItemID.CopperOre; - break; - default: - break; - } - } - - return item; - } } } diff --git a/World/Abyss.cs b/World/Abyss.cs index 7cdca25089..a93fc44c13 100644 --- a/World/Abyss.cs +++ b/World/Abyss.cs @@ -36,7 +36,11 @@ namespace CalamityMod.World public static bool AtLeftSideOfWorld = false; public static int AbyssChasmBottom = 0; - public static bool AbleToUnlockChests = false; //used for unlocking chests during skeletron's death and so that they cannot be opened beforehand + /// + /// Forces abyss chests to unlock even if is false. Used in as it is ran during Skeletron's death, not after. + /// + public static bool UnlockChests { get; set; } + public static void PlaceAbyss() { int x = Main.maxTilesX; @@ -810,29 +814,29 @@ namespace CalamityMod.World int islandTopY = Math.Clamp((int)(islandOrigin.Y - islandWidth * 0.5), 0, Main.maxTilesY); int islandBottomY = Math.Clamp((int)(islandOrigin.Y + islandWidth * 0.5), 0, Main.maxTilesY); - double num11 = islandWidth * (double)WorldGen.genRand.Next(sizeMin, sizeMax) * 0.01; //80 120 - float num12 = islandOrigin.Y + 1f; + double extraIslandWidth = islandWidth * (double)WorldGen.genRand.Next(sizeMin, sizeMax) * 0.01; //80 120 + float islandYOffset = islandOrigin.Y + 1f; for (int k = islandLeftX; k < islandRightX; k++) { if (WorldGen.genRand.NextBool(2)) { - num12 += (float)WorldGen.genRand.Next(-1, 2); + islandYOffset += (float)WorldGen.genRand.Next(-1, 2); } - if (num12 < islandOrigin.Y) + if (islandYOffset < islandOrigin.Y) { - num12 = islandOrigin.Y; + islandYOffset = islandOrigin.Y; } - if (num12 > islandOrigin.Y + 2f) + if (islandYOffset > islandOrigin.Y + 2f) { - num12 = islandOrigin.Y + 2f; + islandYOffset = islandOrigin.Y + 2f; } for (int l = islandTopY; l < islandBottomY; l++) { - if ((float)l > num12) + if ((float)l > islandYOffset) { - float arg_218_0 = Math.Abs((float)k - islandOrigin.X); - float num13 = Math.Abs((float)l - islandOrigin.Y) * 3f; - if (Math.Sqrt((double)(arg_218_0 * arg_218_0 + num13 * num13)) < num11 * 0.4) + float tileCheckXDist = Math.Abs((float)k - islandOrigin.X); + float tileCheckYDist = Math.Abs((float)l - islandOrigin.Y) * 3f; + if (Math.Sqrt((double)(tileCheckXDist * tileCheckXDist + tileCheckYDist * tileCheckYDist)) < extraIslandWidth * 0.4) { if (k < islandPositionX) { @@ -879,17 +883,17 @@ namespace CalamityMod.World } } int m = islandPositionX; - int num15; - for (m += WorldGen.genRand.Next(5); m < islandPositionXAgain; m += WorldGen.genRand.Next(num15, (int)(num15 * 1.5))) + int randMinMaxValues; + for (m += WorldGen.genRand.Next(5); m < islandPositionXAgain; m += WorldGen.genRand.Next(randMinMaxValues, (int)(randMinMaxValues * 1.5))) { - int num14 = islandPositionY; - while (!Main.tile[m, num14].HasTile) + int islandTileY = islandPositionY; + while (!Main.tile[m, islandTileY].HasTile) { - num14--; + islandTileY--; } - num14 += WorldGen.genRand.Next(-3, 4); - num15 = WorldGen.genRand.Next(4, 8); - int num16 = tileType; + islandTileY += WorldGen.genRand.Next(-3, 4); + randMinMaxValues = WorldGen.genRand.Next(4, 8); + int placedTile = tileType; //chance to place clumps of whatever defined block if (hasClumps && WorldGen.genRand.NextBool(3)) @@ -898,30 +902,30 @@ namespace CalamityMod.World if (tileType != ModContent.TileType()) { //if scoria is enabled, then place it, otherwise place planty mush clumps - num16 = hasScoria ? ModContent.TileType() : ModContent.TileType(); + placedTile = hasScoria ? ModContent.TileType() : ModContent.TileType(); } //if the tile is pyre mantle then always place scoria else { //place molten pyre mantle and scorcia ore - num16 = hasScoria ? ModContent.TileType() : ModContent.TileType(); + placedTile = hasScoria ? ModContent.TileType() : ModContent.TileType(); } } - for (int n = m - num15; n <= m + num15; n++) + for (int n = m - randMinMaxValues; n <= m + randMinMaxValues; n++) { - for (int num17 = num14 - num15; num17 <= num14 + num15; num17++) + for (int p = islandTileY - randMinMaxValues; p <= islandTileY + randMinMaxValues; p++) { - if (num17 > islandPositionYAgain) + if (p > islandPositionYAgain) { - float arg_409_0 = (float)Math.Abs(n - m); - float num18 = (float)(Math.Abs(num17 - num14) * 2); - if (Math.Sqrt((double)(arg_409_0 * arg_409_0 + num18 * num18)) < (double)(num15 + WorldGen.genRand.Next(2))) + float islandTileXDist = (float)Math.Abs(n - m); + float islandTileYDist = (float)(Math.Abs(p - islandTileY) * 2); + if (Math.Sqrt((double)(islandTileXDist * islandTileXDist + islandTileYDist * islandTileYDist)) < (double)(randMinMaxValues + WorldGen.genRand.Next(2))) { - Main.tile[n, num17].Get().HasTile = true; + Main.tile[n, p].Get().HasTile = true; - Main.tile[n, num17].TileType = (ushort)num16; - CalamityUtils.SafeSquareTileFrame(n, num17, true); + Main.tile[n, p].TileType = (ushort)placedTile; + CalamityUtils.SafeSquareTileFrame(n, p, true); } } } @@ -963,43 +967,43 @@ namespace CalamityMod.World vector2.Y = -0.2f; } } - int num23 = islandPositionX; - num23 += WorldGen.genRand.Next(5); - while (num23 < islandPositionXAgain) + int islandXOffsetPos = islandPositionX; + islandXOffsetPos += WorldGen.genRand.Next(5); + while (islandXOffsetPos < islandPositionXAgain) { - int num24 = islandPositionY; - while ((!Main.tile[num23, num24].HasTile || Main.tile[num23, num24].TileType != 0) && num23 < islandPositionXAgain) + int islandYOffsetPos = islandPositionY; + while ((!Main.tile[islandXOffsetPos, islandYOffsetPos].HasTile || Main.tile[islandXOffsetPos, islandYOffsetPos].TileType != 0) && islandXOffsetPos < islandPositionXAgain) { - num24--; - if (num24 < islandPositionYAgain) + islandYOffsetPos--; + if (islandYOffsetPos < islandPositionYAgain) { - num24 = islandPositionY; - num23 += WorldGen.genRand.Next(1, 4); + islandYOffsetPos = islandPositionY; + islandXOffsetPos += WorldGen.genRand.Next(1, 4); } } - if (num23 < islandPositionXAgain) + if (islandXOffsetPos < islandPositionXAgain) { - num24 += WorldGen.genRand.Next(0, 4); - int num25 = WorldGen.genRand.Next(2, 5); - int num26 = tileType; - for (int num27 = num23 - num25; num27 <= num23 + num25; num27++) + islandYOffsetPos += WorldGen.genRand.Next(0, 4); + int islandOffsetRandValues = WorldGen.genRand.Next(2, 5); + int placeTile = tileType; + for (int r = islandXOffsetPos - islandOffsetRandValues; r <= islandXOffsetPos + islandOffsetRandValues; r++) { - for (int num28 = num24 - num25; num28 <= num24 + num25; num28++) + for (int s = islandYOffsetPos - islandOffsetRandValues; s <= islandYOffsetPos + islandOffsetRandValues; s++) { - if (num28 > islandPositionYAgain) + if (s > islandPositionYAgain) { - float arg_890_0 = Math.Abs(num27 - num23); - float num29 = (Math.Abs(num28 - num24) * 2); - if (Math.Sqrt((double)(arg_890_0 * arg_890_0 + num29 * num29)) < num25) + float islandOffsetXDist = Math.Abs(r - islandXOffsetPos); + float islandOffsetYDist = (Math.Abs(s - islandYOffsetPos) * 2); + if (Math.Sqrt((double)(islandOffsetXDist * islandOffsetXDist + islandOffsetYDist * islandOffsetYDist)) < islandOffsetRandValues) { - Main.tile[num27, num28].TileType = (ushort)num26; - CalamityUtils.SafeSquareTileFrame(num27, num28, true); + Main.tile[r, s].TileType = (ushort)placeTile; + CalamityUtils.SafeSquareTileFrame(r, s, true); } } } } - num23 += WorldGen.genRand.Next(num25, (int)(num25 * 1.5)); + islandXOffsetPos += WorldGen.genRand.Next(islandOffsetRandValues, (int)(islandOffsetRandValues * 1.5)); } } } @@ -1156,30 +1160,37 @@ namespace CalamityMod.World WorldGen.PlaceObject(i, j - 2, (ushort)ModContent.TileType()); } + /// + /// Unlocks all abyss chests, automatically synced across the server. + /// Only run initally on the server. + /// public static void UnlockAllAbyssChests() { - int genLimit = Main.maxTilesX / 2; - int abyssChasmX = AtLeftSideOfWorld ? genLimit - (genLimit - 135) + 35 : genLimit + (genLimit - 135) - 35; - int abyssMinX = AtLeftSideOfWorld ? 0 : abyssChasmX - 150; - int abyssMaxX = AtLeftSideOfWorld ? abyssChasmX + 150 : Main.maxTilesX; + UnlockChests = true; - //loop to unlock all abyss treasure chests - for (int x = abyssMinX; x < abyssMaxX; x++) + if (Main.netMode == NetmodeID.Server) { - for (int y = Main.remixWorld ? SulphurousSea.YStart - (int)((Main.maxTilesY - 200) * 0.4f) : (int)Main.worldSurface; y < Main.maxTilesY - 300; y++) + var netMessage = CalamityMod.Instance.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.UnlockAbyssChests); + netMessage.Send(); + } + + for (int c = 0; c < Main.maxChests; c++) + { + var chest = Main.chest[c]; + if (chest == null) { - //make SURE to check for the entire chest at once, otherwise it will break when unlocking - if (Main.tile[x, y].TileType == ModContent.TileType() && //top left - Main.tile[x + 1, y].TileType == ModContent.TileType() && //top right - Main.tile[x, y + 1].TileType == ModContent.TileType() && //bottom left - Main.tile[x + 1, y + 1].TileType == ModContent.TileType()) //bottom right - { - Chest.Unlock(x, y); - NetMessage.SendData(MessageID.LockAndUnlock, -1, -1, null, Main.LocalPlayer.whoAmI, 1f, x, y); - } + continue; + } + + var chestTile = Framing.GetTileSafely(chest.x, chest.y); + if (chestTile.HasTile && chestTile.TileType == ModContent.TileType() && Chest.IsLocked(chest.x, chest.y)) + { + Chest.Unlock(chest.x, chest.y); } } - AbleToUnlockChests = false; //reseting the variable in case players generate multiple worlds to prevent already unlocked chests from spawning + + UnlockChests = false; } } } diff --git a/World/AstralBiome.cs b/World/AstralBiome.cs index d43940cfeb..68a534ad96 100644 --- a/World/AstralBiome.cs +++ b/World/AstralBiome.cs @@ -255,8 +255,8 @@ namespace CalamityMod.World { return false; } - int num = 35; - Rectangle rectangle = new Rectangle((i - num) * 16, (j - num) * 16, num * 2 * 16, num * 2 * 16); + int avoidRectangleSize = 35; + Rectangle rectangle = new Rectangle((i - avoidRectangleSize) * 16, (j - avoidRectangleSize) * 16, avoidRectangleSize * 2 * 16, avoidRectangleSize * 2 * 16); for (int k = 0; k < Main.maxPlayers; k++) { if (Main.player[k].active) @@ -279,9 +279,9 @@ namespace CalamityMod.World } } } - for (int m = i - num; m < i + num; m++) + for (int m = i - avoidRectangleSize; m < i + avoidRectangleSize; m++) { - for (int n = j - num; n < j + num; n++) + for (int n = j - avoidRectangleSize; n < j + avoidRectangleSize; n++) { if (Main.tile[m, n].HasTile && Main.tile[m, n].TileType == 21) { @@ -289,130 +289,130 @@ namespace CalamityMod.World } } } - num = rand.Next(17, 23); - for (int num2 = i - num; num2 < i + num; num2++) + avoidRectangleSize = rand.Next(17, 23); + for (int inc = i - avoidRectangleSize; inc < i + avoidRectangleSize; inc++) { - for (int num3 = j - num; num3 < j + num; num3++) + for (int doubleinc = j - avoidRectangleSize; doubleinc < j + avoidRectangleSize; doubleinc++) { - if (num3 > j + rand.Next(-2, 3) - 5) + if (doubleinc > j + rand.Next(-2, 3) - 5) { - float num4 = (float)Math.Abs(i - num2); - float num5 = (float)Math.Abs(j - num3); - float num6 = (float)Math.Sqrt((double)(num4 * num4 + num5 * num5)); - if ((double)num6 < (double)num * 0.9 + (double)rand.Next(-4, 5)) + float tileXDist = (float)Math.Abs(i - inc); + float tileYDist = (float)Math.Abs(j - doubleinc); + float tileDistance = (float)Math.Sqrt((double)(tileXDist * tileXDist + tileYDist * tileYDist)); + if ((double)tileDistance < (double)avoidRectangleSize * 0.9 + (double)rand.Next(-4, 5)) { - if (Main.tile[num2, num3] != null) + if (Main.tile[inc, doubleinc] != null) { - if (!Main.tileSolid[(int)Main.tile[num2, num3].TileType]) + if (!Main.tileSolid[(int)Main.tile[inc, doubleinc].TileType]) { - Main.tile[num2, num3].Get().HasTile = false; + Main.tile[inc, doubleinc].Get().HasTile = false; } - Main.tile[num2, num3].TileType = (ushort)ModContent.TileType(); + Main.tile[inc, doubleinc].TileType = (ushort)ModContent.TileType(); } } } } } - num = WorldGen.genRand.Next(8, 14); - for (int num7 = i - num; num7 < i + num; num7++) + avoidRectangleSize = WorldGen.genRand.Next(8, 14); + for (int inc2 = i - avoidRectangleSize; inc2 < i + avoidRectangleSize; inc2++) { - for (int num8 = j - num; num8 < j + num; num8++) + for (int doubleinc2 = j - avoidRectangleSize; doubleinc2 < j + avoidRectangleSize; doubleinc2++) { - if (num8 > j + rand.Next(-2, 3) - 4) + if (doubleinc2 > j + rand.Next(-2, 3) - 4) { - float num9 = (float)Math.Abs(i - num7); - float num10 = (float)Math.Abs(j - num8); - float num11 = (float)Math.Sqrt((double)(num9 * num9 + num10 * num10)); - if ((double)num11 < (double)num * 0.8 + (double)rand.Next(-3, 4)) + float tileXDist2 = (float)Math.Abs(i - inc2); + float tileYDist2 = (float)Math.Abs(j - doubleinc2); + float tileDistance2 = (float)Math.Sqrt((double)(tileXDist2 * tileXDist2 + tileYDist2 * tileYDist2)); + if ((double)tileDistance2 < (double)avoidRectangleSize * 0.8 + (double)rand.Next(-3, 4)) { - if (Main.tile[num7, num8] != null) - Main.tile[num7, num8].Get().HasTile = false; + if (Main.tile[inc2, doubleinc2] != null) + Main.tile[inc2, doubleinc2].Get().HasTile = false; } } } } - num = WorldGen.genRand.Next(25, 35); - for (int num12 = i - num; num12 < i + num; num12++) + avoidRectangleSize = WorldGen.genRand.Next(25, 35); + for (int inc3 = i - avoidRectangleSize; inc3 < i + avoidRectangleSize; inc3++) { - for (int num13 = j - num; num13 < j + num; num13++) + for (int doubleinc3 = j - avoidRectangleSize; doubleinc3 < j + avoidRectangleSize; doubleinc3++) { - float num14 = (float)Math.Abs(i - num12); - float num15 = (float)Math.Abs(j - num13); - float num16 = (float)Math.Sqrt((double)(num14 * num14 + num15 * num15)); - if (Main.tile[num12, num13] != null) + float tileXDist3 = (float)Math.Abs(i - inc3); + float tileYDist3 = (float)Math.Abs(j - doubleinc3); + float tileDistance3 = (float)Math.Sqrt((double)(tileXDist3 * tileXDist3 + tileYDist3 * tileYDist3)); + if (Main.tile[inc3, doubleinc3] != null) { - if ((double)num16 < (double)num * 0.7) + if ((double)tileDistance3 < (double)avoidRectangleSize * 0.7) { - if (Main.tile[num12, num13].TileType == 5 || Main.tile[num12, num13].TileType == 32 || Main.tile[num12, num13].TileType == 352) + if (Main.tile[inc3, doubleinc3].TileType == 5 || Main.tile[inc3, doubleinc3].TileType == 32 || Main.tile[inc3, doubleinc3].TileType == 352) { try - { WorldGen.KillTile(num12, num13, false, false, true); } + { WorldGen.KillTile(inc3, doubleinc3, false, false, true); } catch (NullReferenceException) { } } - Main.tile[num12, num13].LiquidAmount = 0; + Main.tile[inc3, doubleinc3].LiquidAmount = 0; } - if (Main.tile[num12, num13].TileType == (ushort)ModContent.TileType()) + if (Main.tile[inc3, doubleinc3].TileType == (ushort)ModContent.TileType()) { - if (!WorldGen.SolidTile(num12 - 1, num13) && !WorldGen.SolidTile(num12 + 1, num13) && !WorldGen.SolidTile(num12, num13 - 1) && !WorldGen.SolidTile(num12, num13 + 1)) + if (!WorldGen.SolidTile(inc3 - 1, doubleinc3) && !WorldGen.SolidTile(inc3 + 1, doubleinc3) && !WorldGen.SolidTile(inc3, doubleinc3 - 1) && !WorldGen.SolidTile(inc3, doubleinc3 + 1)) { - Main.tile[num12, num13].Get().HasTile = false; + Main.tile[inc3, doubleinc3].Get().HasTile = false; } - else if ((Main.tile[num12, num13].IsHalfBlock || Main.tile[num12 - 1, num13].TopSlope) && !WorldGen.SolidTile(num12, num13 + 1)) + else if ((Main.tile[inc3, doubleinc3].IsHalfBlock || Main.tile[inc3 - 1, doubleinc3].TopSlope) && !WorldGen.SolidTile(inc3, doubleinc3 + 1)) { - Main.tile[num12, num13].Get().HasTile = false; + Main.tile[inc3, doubleinc3].Get().HasTile = false; } } - WorldGen.SquareTileFrame(num12, num13, true); - WorldGen.SquareWallFrame(num12, num13, true); + WorldGen.SquareTileFrame(inc3, doubleinc3, true); + WorldGen.SquareWallFrame(inc3, doubleinc3, true); } } } - num = WorldGen.genRand.Next(23, 32); - for (int num17 = i - num; num17 < i + num; num17++) + avoidRectangleSize = WorldGen.genRand.Next(23, 32); + for (int inc4 = i - avoidRectangleSize; inc4 < i + avoidRectangleSize; inc4++) { - for (int num18 = j - num; num18 < j + num; num18++) + for (int doubleinc4 = j - avoidRectangleSize; doubleinc4 < j + avoidRectangleSize; doubleinc4++) { - if (num18 > j + WorldGen.genRand.Next(-3, 4) - 3 && Main.tile[num17, num18].HasTile && rand.NextBool(10)) + if (doubleinc4 > j + WorldGen.genRand.Next(-3, 4) - 3 && Main.tile[inc4, doubleinc4].HasTile && rand.NextBool(10)) { - float num19 = (float)Math.Abs(i - num17); - float num20 = (float)Math.Abs(j - num18); - float num21 = (float)Math.Sqrt((double)(num19 * num19 + num20 * num20)); - if ((double)num21 < (double)num * 0.8) + float tileXDist4 = (float)Math.Abs(i - inc4); + float tileYDist4 = (float)Math.Abs(j - doubleinc4); + float tileDistance4 = (float)Math.Sqrt((double)(tileXDist4 * tileXDist4 + tileYDist4 * tileYDist4)); + if ((double)tileDistance4 < (double)avoidRectangleSize * 0.8) { - if (Main.tile[num17, num18] != null) + if (Main.tile[inc4, doubleinc4] != null) { - if (Main.tile[num17, num18].TileType == 5 || Main.tile[num17, num18].TileType == 32 || Main.tile[num17, num18].TileType == 352) + if (Main.tile[inc4, doubleinc4].TileType == 5 || Main.tile[inc4, doubleinc4].TileType == 32 || Main.tile[inc4, doubleinc4].TileType == 352) { - WorldGen.KillTile(num17, num18, false, false, false); + WorldGen.KillTile(inc4, doubleinc4, false, false, false); } - Main.tile[num17, num18].TileType = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(num17, num18, true); + Main.tile[inc4, doubleinc4].TileType = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(inc4, doubleinc4, true); } } } } } - num = WorldGen.genRand.Next(30, 38); - for (int num22 = i - num; num22 < i + num; num22++) + avoidRectangleSize = WorldGen.genRand.Next(30, 38); + for (int inc5 = i - avoidRectangleSize; inc5 < i + avoidRectangleSize; inc5++) { - for (int num23 = j - num; num23 < j + num; num23++) + for (int doubleinc5 = j - avoidRectangleSize; doubleinc5 < j + avoidRectangleSize; doubleinc5++) { - if (num23 > j + WorldGen.genRand.Next(-2, 3) && Main.tile[num22, num23].HasTile && rand.NextBool(20)) + if (doubleinc5 > j + WorldGen.genRand.Next(-2, 3) && Main.tile[inc5, doubleinc5].HasTile && rand.NextBool(20)) { - float num24 = (float)Math.Abs(i - num22); - float num25 = (float)Math.Abs(j - num23); - float num26 = (float)Math.Sqrt((double)(num24 * num24 + num25 * num25)); - if ((double)num26 < (double)num * 0.85) + float tileXDist5 = (float)Math.Abs(i - inc5); + float tileYDist5 = (float)Math.Abs(j - doubleinc5); + float tileDistance5 = (float)Math.Sqrt((double)(tileXDist5 * tileXDist5 + tileYDist5 * tileYDist5)); + if ((double)tileDistance5 < (double)avoidRectangleSize * 0.85) { - if (Main.tile[num22, num23] != null) + if (Main.tile[inc5, doubleinc5] != null) { - if (Main.tile[num22, num23].TileType == 5 || Main.tile[num22, num23].TileType == 32 || Main.tile[num22, num23].TileType == 352) + if (Main.tile[inc5, doubleinc5].TileType == 5 || Main.tile[inc5, doubleinc5].TileType == 32 || Main.tile[inc5, doubleinc5].TileType == 352) { - WorldGen.KillTile(num22, num23, false, false, false); + WorldGen.KillTile(inc5, doubleinc5, false, false, false); } - Main.tile[num22, num23].TileType = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(num22, num23, true); + Main.tile[inc5, doubleinc5].TileType = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(inc5, doubleinc5, true); } } } diff --git a/World/AstralChestGeneration.cs b/World/AstralChestGeneration.cs new file mode 100644 index 0000000000..e3e5a2faef --- /dev/null +++ b/World/AstralChestGeneration.cs @@ -0,0 +1,73 @@ +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Tiles.Astral; +using Terraria; +using Terraria.ModLoader; +using Terraria.WorldBuilding; + +namespace CalamityMod.World +{ + public class AstralChestGeneration + { + public static void PlaceAstralChest() + { + // Get dungeon area information. + int left = GenVars.dMinX + 25; + int right = GenVars.dMaxX - 25; + int top = (int)Main.worldSurface; + int bottom = GenVars.dMaxY - 25; + + // Sanity check: If the dungeon area information is somehow irrevocably broken in a way that will guarantee a crash, terminate this + // method immediately and leave a log message. + bool invalidWidthData = left >= right; + bool invalidHeightData = top >= bottom; + if (invalidWidthData || invalidHeightData) + { + CalamityMod.Instance.Logger.Warn("The generated dungeon was found to have unusable area bounds. As a result, the astral chest could not be generated."); + return; + } + + int astralChestItemID = ModContent.ItemType(); + ushort astralChestID = (ushort)ModContent.TileType(); + + // The Astral Chest generates in style 1, which is locked. + int chestStyle = 1; + + // Define an undefined chest and attempt counter for the loop below. + Chest chest = null; + int attempts = 0; + + // Try 1000 times to place the chest somewhere in the dungeon. + while (chest is null && attempts < 1000) + { + attempts++; + + // Pick a random potential location to generate the chest in, based on the chest placement area. + int x = WorldGen.genRand.Next(left, right); + int y = WorldGen.genRand.Next(top, bottom); + Tile randomTile = Main.tile[x, y]; + + // Determine if the randomly selected tile is a valid candidate for chest placement based on whether it has dungeon walls and has no active tile. + // The placement algorithm ensures that if it tries to appear in midair, it is moved down to the floor. + bool emptyDungeonWall = Main.wallDungeon[randomTile.WallType] && !randomTile.HasTile; + + // Attempt to place the chest. + if (emptyDungeonWall) + chest = MiscWorldgenRoutines.AddChestWithLoot(x, y, astralChestID, tileStyle: chestStyle); + } + + // If a chest was placed, force its first item to be the unique Biome Chest weapon. + if (chest != null) + { + chest.item[0].SetDefaults(astralChestItemID); + + // Apply a random prefix (including the possibility of no prefix at all) to the added item in the chest. + chest.item[0].Prefix(-1); + } + + // If a chest was NOT placed, that means that the loop somehow failed. + // Log this. + else + CalamityMod.Instance.Logger.Warn("The astral chest loop could not find a valid generation location. As a result, it has not generated."); + } + } +} diff --git a/World/BrimstoneCrag.cs b/World/BrimstoneCrag.cs index e2340865ef..e9b63229f4 100644 --- a/World/BrimstoneCrag.cs +++ b/World/BrimstoneCrag.cs @@ -25,7 +25,6 @@ namespace CalamityMod.World { static int StartX = 0; - static int lavaLakePlaceDelay = 0; static int lavaLakeBigPlaceDelay = 0; static int numLavaLakes = 0; diff --git a/World/CustomDungeon.cs b/World/CustomDungeon.cs deleted file mode 100644 index fbfc39bf4f..0000000000 --- a/World/CustomDungeon.cs +++ /dev/null @@ -1,2542 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Potions; -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Tiles.Abyss; -using CalamityMod.Tiles.Astral; -using Microsoft.VisualBasic; -using Microsoft.Xna.Framework; -using ReLogic.Utilities; -using System; -using System.Reflection; -using Terraria; -using Terraria.DataStructures; -using Terraria.GameContent.Generation; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.WorldBuilding; - -namespace CalamityMod.World -{ - public class CustomDungeon - { - public static void NewDungeon() - { - int dungeonLocation = GenVars.dungeonLocation; - int randomY = (int)((Main.worldSurface + Main.rockLayer) / 2.0) + WorldGen.genRand.Next(-200, 200); - int limit = (int)((Main.worldSurface + Main.rockLayer) / 2.0) + 200; - int y = randomY; - bool success = false; - for (int i = 0; i < 10; i++) - { - if (WorldGen.SolidTile(dungeonLocation, y + i)) - { - success = true; - break; - } - } - - if (!success) - { - for (; y < limit && !WorldGen.SolidTile(dungeonLocation, y + 10); y++) - { - } - } - - if (WorldGen.drunkWorldGen) - y = (int)Main.worldSurface + 70; - - GenNewDungeon(dungeonLocation, y); - } - - public static void GenNewDungeon(int x, int y) - { - GenVars.dEnteranceX = 0; - GenVars.numDRooms = 0; - GenVars.numDDoors = 0; - GenVars.numDungeonPlatforms = 0; - int num = WorldGen.genRand.Next(3); - WorldGen.genRand.Next(3); - if (WorldGen.remixWorldGen) - num = (WorldGen.crimson ? 2 : 0); - - ushort num2; - int num3; - switch (num) - { - case 0: - num2 = 41; - num3 = 7; - GenVars.crackedType = 481; - break; - case 1: - num2 = 43; - num3 = 8; - GenVars.crackedType = 482; - break; - default: - num2 = 44; - num3 = 9; - GenVars.crackedType = 483; - break; - } - - Main.tileSolid[GenVars.crackedType] = false; - GenVars.dungeonLake = true; - GenVars.numDDoors = 0; - GenVars.numDungeonPlatforms = 0; - GenVars.numDRooms = 0; - GenVars.dungeonX = x; - GenVars.dungeonY = y; - - // The horizontal adjustment Calamity makes. - GenVars.dungeonX = Utils.Clamp(GenVars.dungeonX, SulphurousSea.BiomeWidth + 167, Main.maxTilesX - SulphurousSea.BiomeWidth - 167); - - // Adjust the Y position of the dungeon to accomodate for the X shift. - WorldUtils.Find(new Point(GenVars.dungeonX, GenVars.dungeonY), Searches.Chain(new Searches.Down(9001), new Conditions.IsSolid()), out Point result); - GenVars.dungeonY = result.Y - 10; - - GenVars.dMinX = x; - GenVars.dMaxX = x; - GenVars.dMinY = y; - GenVars.dMaxY = y; - GenVars.dxStrength1 = WorldGen.genRand.Next(25, 30); - GenVars.dyStrength1 = WorldGen.genRand.Next(20, 25); - GenVars.dxStrength2 = WorldGen.genRand.Next(35, 50); - GenVars.dyStrength2 = WorldGen.genRand.Next(10, 15); - double num4 = Main.maxTilesX / 60; - num4 += (double)WorldGen.genRand.Next(0, (int)(num4 / 3.0)); - double num5 = num4; - int num6 = 5; - WorldGen.DungeonRoom(GenVars.dungeonX, GenVars.dungeonY, num2, num3); - while (num4 > 0.0) - { - if (GenVars.dungeonX < GenVars.dMinX) - GenVars.dMinX = GenVars.dungeonX; - - if (GenVars.dungeonX > GenVars.dMaxX) - GenVars.dMaxX = GenVars.dungeonX; - - if (GenVars.dungeonY > GenVars.dMaxY) - GenVars.dMaxY = GenVars.dungeonY; - - num4 -= 1.0; - Main.statusText = Lang.gen[58].Value + " " + (int)((num5 - num4) / num5 * 60.0) + "%"; - if (num6 > 0) - num6--; - - if ((num6 == 0) & (WorldGen.genRand.NextBool(3))) - { - num6 = 5; - if (WorldGen.genRand.NextBool()) - { - int dungeonX = GenVars.dungeonX; - int dungeonY = GenVars.dungeonY; - GenNewDungeonHalls(GenVars.dungeonX, GenVars.dungeonY, num2, num3); - if (WorldGen.genRand.NextBool()) - GenNewDungeonHalls(GenVars.dungeonX, GenVars.dungeonY, num2, num3); - - WorldGen.DungeonRoom(GenVars.dungeonX, GenVars.dungeonY, num2, num3); - GenVars.dungeonX = dungeonX; - GenVars.dungeonY = dungeonY; - } - else - { - WorldGen.DungeonRoom(GenVars.dungeonX, GenVars.dungeonY, num2, num3); - } - } - else - { - WorldGen.DungeonHalls(GenVars.dungeonX, GenVars.dungeonY, num2, num3); - } - } - - WorldGen.DungeonRoom(GenVars.dungeonX, GenVars.dungeonY, num2, num3); - int num7 = GenVars.dRoomX[0]; - int num8 = GenVars.dRoomY[0]; - for (int i = 0; i < GenVars.numDRooms; i++) - { - if (GenVars.dRoomY[i] < num8) - { - num7 = GenVars.dRoomX[i]; - num8 = GenVars.dRoomY[i]; - } - } - - GenVars.dungeonX = num7; - GenVars.dungeonY = num8; - GenVars.dEnteranceX = num7; - GenVars.dSurface = false; - num6 = 5; - if (WorldGen.drunkWorldGen) - GenVars.dSurface = true; - - while (!GenVars.dSurface) - { - if (num6 > 0) - num6--; - - if (num6 == 0 && WorldGen.genRand.NextBool(5) && (double)GenVars.dungeonY > Main.worldSurface + 100.0) - { - num6 = 10; - int dungeonX2 = GenVars.dungeonX; - int dungeonY2 = GenVars.dungeonY; - GenNewDungeonHalls(GenVars.dungeonX, GenVars.dungeonY, num2, num3, forceX: true); - WorldGen.DungeonRoom(GenVars.dungeonX, GenVars.dungeonY, num2, num3); - GenVars.dungeonX = dungeonX2; - GenVars.dungeonY = dungeonY2; - } - - WorldGen.DungeonStairs(GenVars.dungeonX, GenVars.dungeonY, num2, num3); - } - - WorldGen.DungeonEnt(GenVars.dungeonX, GenVars.dungeonY, num2, num3); - Main.statusText = Lang.gen[58].Value + " 65%"; - int num9 = Main.maxTilesX * 2; - int num10; - for (num10 = 0; num10 < num9; num10++) - { - int i2 = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); - int num11 = GenVars.dMinY; - if ((double)num11 < Main.worldSurface) - num11 = (int)Main.worldSurface; - - int j = WorldGen.genRand.Next(num11, GenVars.dMaxY); - num10 = ((!WorldGen.DungeonPitTrap(i2, j, num2, num3)) ? (num10 + 1) : (num10 + 1500)); - } - - for (int k = 0; k < GenVars.numDRooms; k++) - { - for (int l = GenVars.dRoomL[k]; l <= GenVars.dRoomR[k]; l++) - { - if (!Main.tile[l, GenVars.dRoomT[k] - 1].Get().HasTile) - { - GenVars.dungeonPlatformX[GenVars.numDungeonPlatforms] = l; - GenVars.dungeonPlatformY[GenVars.numDungeonPlatforms] = GenVars.dRoomT[k] - 1; - GenVars.numDungeonPlatforms++; - break; - } - } - - for (int m = GenVars.dRoomL[k]; m <= GenVars.dRoomR[k]; m++) - { - if (!Main.tile[m, GenVars.dRoomB[k] + 1].Get().HasTile) - { - GenVars.dungeonPlatformX[GenVars.numDungeonPlatforms] = m; - GenVars.dungeonPlatformY[GenVars.numDungeonPlatforms] = GenVars.dRoomB[k] + 1; - GenVars.numDungeonPlatforms++; - break; - } - } - - for (int n = GenVars.dRoomT[k]; n <= GenVars.dRoomB[k]; n++) - { - if (!Main.tile[GenVars.dRoomL[k] - 1, n].Get().HasTile) - { - GenVars.DDoorX[GenVars.numDDoors] = GenVars.dRoomL[k] - 1; - GenVars.DDoorY[GenVars.numDDoors] = n; - GenVars.DDoorPos[GenVars.numDDoors] = -1; - GenVars.numDDoors++; - break; - } - } - - for (int num12 = GenVars.dRoomT[k]; num12 <= GenVars.dRoomB[k]; num12++) - { - if (!Main.tile[GenVars.dRoomR[k] + 1, num12].Get().HasTile) - { - GenVars.DDoorX[GenVars.numDDoors] = GenVars.dRoomR[k] + 1; - GenVars.DDoorY[GenVars.numDDoors] = num12; - GenVars.DDoorPos[GenVars.numDDoors] = 1; - GenVars.numDDoors++; - break; - } - } - } - - Main.statusText = Lang.gen[58].Value + " 70%"; - int num13 = 0; - int num14 = 1000; - int num15 = 0; - int num16 = Main.maxTilesX / 200; - if (WorldGen.getGoodWorldGen) - num16 *= 6; - if (Main.zenithWorld) - num16 *= 4; - - while (num15 < num16) - { - num13++; - int num17 = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); - int num18 = WorldGen.genRand.Next((int)Main.worldSurface + 25, GenVars.dMaxY); - if (WorldGen.drunkWorldGen) - num18 = WorldGen.genRand.Next(GenVars.dungeonY + 25, GenVars.dMaxY); - - int num19 = num17; - if (Main.tile[num17, num18].WallType == num3 && !Main.tile[num17, num18].Get().HasTile) - { - int num20 = 1; - if (WorldGen.genRand.NextBool()) - num20 = -1; - - for (; !Main.tile[num17, num18].Get().HasTile; num18 += num20) - { - } - - if (Main.tile[num17 - 1, num18].Get().HasTile && Main.tile[num17 + 1, num18].Get().HasTile && Main.tile[num17 - 1, num18].TileType != GenVars.crackedType && !Main.tile[num17 - 1, num18 - num20].Get().HasTile && !Main.tile[num17 + 1, num18 - num20].Get().HasTile) - { - num15++; - int num21 = WorldGen.genRand.Next(5, 13); - while (Main.tile[num17 - 1, num18].Get().HasTile && Main.tile[num17 - 1, num18].TileType != GenVars.crackedType && Main.tile[num17, num18 + num20].Get().HasTile && Main.tile[num17, num18].Get().HasTile && !Main.tile[num17, num18 - num20].Get().HasTile && num21 > 0) - { - Main.tile[num17, num18].TileType = 48; - if (!Main.tile[num17 - 1, num18 - num20].Get().HasTile && !Main.tile[num17 + 1, num18 - num20].Get().HasTile) - { - Main.tile[num17, num18 - num20].Clear(TileDataType.Slope); - Main.tile[num17, num18 - num20].TileType = 48; - Main.tile[num17, num18 - num20].Get().HasTile = true; - Main.tile[num17, num18 - num20 * 2].Clear(TileDataType.Slope); - Main.tile[num17, num18 - num20 * 2].TileType = 48; - Main.tile[num17, num18 - num20 * 2].Get().HasTile = true; - } - - num17--; - num21--; - } - - num21 = WorldGen.genRand.Next(5, 13); - num17 = num19 + 1; - while (Main.tile[num17 + 1, num18].Get().HasTile && Main.tile[num17 + 1, num18].TileType != GenVars.crackedType && Main.tile[num17, num18 + num20].Get().HasTile && Main.tile[num17, num18].Get().HasTile && !Main.tile[num17, num18 - num20].Get().HasTile && num21 > 0) - { - Main.tile[num17, num18].TileType = 48; - if (!Main.tile[num17 - 1, num18 - num20].Get().HasTile && !Main.tile[num17 + 1, num18 - num20].Get().HasTile) - { - Main.tile[num17, num18 - num20].Clear(TileDataType.Slope); - Main.tile[num17, num18 - num20].TileType = 48; - Main.tile[num17, num18 - num20].Get().HasTile = true; - Main.tile[num17, num18 - num20 * 2].Clear(TileDataType.Slope); - Main.tile[num17, num18 - num20 * 2].TileType = 48; - Main.tile[num17, num18 - num20 * 2].Get().HasTile = true; - } - - num17++; - num21--; - } - } - } - - if (num13 > num14) - { - num13 = 0; - num15++; - } - } - - num13 = 0; - num14 = 1000; - num15 = 0; - Main.statusText = Lang.gen[58].Value + " 75%"; - while (num15 < num16) - { - num13++; - int num22 = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); - int num23 = WorldGen.genRand.Next((int)Main.worldSurface + 25, GenVars.dMaxY); - int num24 = num23; - if (Main.tile[num22, num23].WallType == num3 && !Main.tile[num22, num23].Get().HasTile) - { - int num25 = 1; - if (WorldGen.genRand.NextBool()) - num25 = -1; - - for (; num22 > 5 && num22 < Main.maxTilesX - 5 && !Main.tile[num22, num23].Get().HasTile; num22 += num25) - { - } - - if (Main.tile[num22, num23 - 1].Get().HasTile && Main.tile[num22, num23 + 1].Get().HasTile && Main.tile[num22, num23 - 1].TileType != GenVars.crackedType && !Main.tile[num22 - num25, num23 - 1].Get().HasTile && !Main.tile[num22 - num25, num23 + 1].Get().HasTile) - { - num15++; - int num26 = WorldGen.genRand.Next(5, 13); - while (Main.tile[num22, num23 - 1].Get().HasTile && Main.tile[num22, num23 - 1].TileType != GenVars.crackedType && Main.tile[num22 + num25, num23].Get().HasTile && Main.tile[num22, num23].Get().HasTile && !Main.tile[num22 - num25, num23].Get().HasTile && num26 > 0) - { - Main.tile[num22, num23].TileType = 48; - if (!Main.tile[num22 - num25, num23 - 1].Get().HasTile && !Main.tile[num22 - num25, num23 + 1].Get().HasTile) - { - Main.tile[num22 - num25, num23].TileType = 48; - Main.tile[num22 - num25, num23].Get().HasTile = true; - Main.tile[num22 - num25, num23].Clear(TileDataType.Slope); - Main.tile[num22 - num25 * 2, num23].TileType = 48; - Main.tile[num22 - num25 * 2, num23].Get().HasTile = true; - Main.tile[num22 - num25 * 2, num23].Clear(TileDataType.Slope); - } - - num23--; - num26--; - } - - num26 = WorldGen.genRand.Next(5, 13); - num23 = num24 + 1; - while (Main.tile[num22, num23 + 1].Get().HasTile && Main.tile[num22, num23 + 1].TileType != GenVars.crackedType && Main.tile[num22 + num25, num23].Get().HasTile && Main.tile[num22, num23].Get().HasTile && !Main.tile[num22 - num25, num23].Get().HasTile && num26 > 0) - { - Main.tile[num22, num23].TileType = 48; - if (!Main.tile[num22 - num25, num23 - 1].Get().HasTile && !Main.tile[num22 - num25, num23 + 1].Get().HasTile) - { - Main.tile[num22 - num25, num23].TileType = 48; - Main.tile[num22 - num25, num23].Get().HasTile = true; - Main.tile[num22 - num25, num23].Clear(TileDataType.Slope); - Main.tile[num22 - num25 * 2, num23].TileType = 48; - Main.tile[num22 - num25 * 2, num23].Get().HasTile = true; - Main.tile[num22 - num25 * 2, num23].Clear(TileDataType.Slope); - } - - num23++; - num26--; - } - } - } - - if (num13 > num14) - { - num13 = 0; - num15++; - } - } - - Main.statusText = Lang.gen[58].Value + " 80%"; - for (int num27 = 0; num27 < GenVars.numDDoors; num27++) - { - int num28 = GenVars.DDoorX[num27] - 10; - int num29 = GenVars.DDoorX[num27] + 10; - int num30 = 100; - int num31 = 0; - int num32 = 0; - int num33 = 0; - for (int num34 = num28; num34 < num29; num34++) - { - bool flag = true; - int num35 = GenVars.DDoorY[num27]; - while (num35 > 10 && !Main.tile[num34, num35].Get().HasTile) - { - num35--; - } - - if (!Main.tileDungeon[Main.tile[num34, num35].TileType]) - flag = false; - - num32 = num35; - for (num35 = GenVars.DDoorY[num27]; !Main.tile[num34, num35].Get().HasTile; num35++) - { - } - - if (!Main.tileDungeon[Main.tile[num34, num35].TileType]) - flag = false; - - num33 = num35; - if (num33 - num32 < 3) - continue; - - int num36 = num34 - 20; - int num37 = num34 + 20; - int num38 = num33 - 10; - int num39 = num33 + 10; - for (int num40 = num36; num40 < num37; num40++) - { - for (int num41 = num38; num41 < num39; num41++) - { - if (Main.tile[num40, num41].Get().HasTile && Main.tile[num40, num41].TileType == 10) - { - flag = false; - break; - } - } - } - - if (flag) - { - for (int num42 = num33 - 3; num42 < num33; num42++) - { - for (int num43 = num34 - 3; num43 <= num34 + 3; num43++) - { - if (Main.tile[num43, num42].Get().HasTile) - { - flag = false; - break; - } - } - } - } - - if (flag && num33 - num32 < 20) - { - bool flag2 = false; - if (GenVars.DDoorPos[num27] == 0 && num33 - num32 < num30) - flag2 = true; - - if (GenVars.DDoorPos[num27] == -1 && num34 > num31) - flag2 = true; - - if (GenVars.DDoorPos[num27] == 1 && (num34 < num31 || num31 == 0)) - flag2 = true; - - if (flag2) - { - num31 = num34; - num30 = num33 - num32; - } - } - } - - if (num30 >= 20) - continue; - - int num44 = num31; - int num45 = GenVars.DDoorY[num27]; - int num46 = num45; - for (; !Main.tile[num44, num45].Get().HasTile; num45++) - { - Main.tile[num44, num45].Get().HasTile = false; - } - - while (!Main.tile[num44, num46].Get().HasTile) - { - num46--; - } - - num45--; - num46++; - for (int num47 = num46; num47 < num45 - 2; num47++) - { - Main.tile[num44, num47].Clear(TileDataType.Slope); - Main.tile[num44, num47].Get().HasTile = true; - Main.tile[num44, num47].TileType = num2; - if (Main.tile[num44 - 1, num47].TileType == num2) - { - Main.tile[num44 - 1, num47].Get().HasTile = false; - Main.tile[num44 - 1, num47].ClearEverything(); - Main.tile[num44 - 1, num47].WallType = (ushort)num3; - } - - if (Main.tile[num44 - 2, num47].TileType == num2) - { - Main.tile[num44 - 2, num47].Get().HasTile = false; - Main.tile[num44 - 2, num47].ClearEverything(); - Main.tile[num44 - 2, num47].WallType = (ushort)num3; - } - - if (Main.tile[num44 + 1, num47].TileType == num2) - { - Main.tile[num44 + 1, num47].Get().HasTile = false; - Main.tile[num44 + 1, num47].ClearEverything(); - Main.tile[num44 + 1, num47].WallType = (ushort)num3; - } - - if (Main.tile[num44 + 2, num47].TileType == num2) - { - Main.tile[num44 + 2, num47].Get().HasTile = false; - Main.tile[num44 + 2, num47].ClearEverything(); - Main.tile[num44 + 2, num47].WallType = (ushort)num3; - } - } - - int style = 13; - if (WorldGen.genRand.NextBool(3)) - { - switch (num3) - { - case 7: - style = 16; - break; - case 8: - style = 17; - break; - case 9: - style = 18; - break; - } - } - - WorldGen.PlaceTile(num44, num45, 10, mute: true, forced: false, -1, style); - num44--; - int num48 = num45 - 3; - while (!Main.tile[num44, num48].Get().HasTile) - { - num48--; - } - - if (num45 - num48 < num45 - num46 + 5 && Main.tileDungeon[Main.tile[num44, num48].TileType]) - { - for (int num49 = num45 - 4 - WorldGen.genRand.Next(3); num49 > num48; num49--) - { - Main.tile[num44, num49].Clear(TileDataType.Slope); - Main.tile[num44, num49].Get().HasTile = true; - Main.tile[num44, num49].TileType = num2; - if (Main.tile[num44 - 1, num49].TileType == num2) - { - Main.tile[num44 - 1, num49].Get().HasTile = false; - Main.tile[num44 - 1, num49].ClearEverything(); - Main.tile[num44 - 1, num49].WallType = (ushort)num3; - } - - if (Main.tile[num44 - 2, num49].TileType == num2) - { - Main.tile[num44 - 2, num49].Get().HasTile = false; - Main.tile[num44 - 2, num49].ClearEverything(); - Main.tile[num44 - 2, num49].WallType = (ushort)num3; - } - } - } - - num44 += 2; - num48 = num45 - 3; - while (!Main.tile[num44, num48].Get().HasTile) - { - num48--; - } - - if (num45 - num48 < num45 - num46 + 5 && Main.tileDungeon[Main.tile[num44, num48].TileType]) - { - for (int num50 = num45 - 4 - WorldGen.genRand.Next(3); num50 > num48; num50--) - { - Main.tile[num44, num50].Get().HasTile = true; - Main.tile[num44, num50].Clear(TileDataType.Slope); - Main.tile[num44, num50].TileType = num2; - if (Main.tile[num44 + 1, num50].TileType == num2) - { - Main.tile[num44 + 1, num50].Get().HasTile = false; - Main.tile[num44 + 1, num50].ClearEverything(); - Main.tile[num44 + 1, num50].WallType = (ushort)num3; - } - - if (Main.tile[num44 + 2, num50].TileType == num2) - { - Main.tile[num44 + 2, num50].Get().HasTile = false; - Main.tile[num44 + 2, num50].ClearEverything(); - Main.tile[num44 + 2, num50].WallType = (ushort)num3; - } - } - } - - num45++; - num44--; - for (int num51 = num45 - 8; num51 < num45; num51++) - { - if (Main.tile[num44 + 2, num51].TileType == num2) - { - Main.tile[num44 + 2, num51].Get().HasTile = false; - Main.tile[num44 + 2, num51].ClearEverything(); - Main.tile[num44 + 2, num51].WallType = (ushort)num3; - } - - if (Main.tile[num44 + 3, num51].TileType == num2) - { - Main.tile[num44 + 3, num51].Get().HasTile = false; - Main.tile[num44 + 3, num51].ClearEverything(); - Main.tile[num44 + 3, num51].WallType = (ushort)num3; - } - - if (Main.tile[num44 - 2, num51].TileType == num2) - { - Main.tile[num44 - 2, num51].Get().HasTile = false; - Main.tile[num44 - 2, num51].ClearEverything(); - Main.tile[num44 - 2, num51].WallType = (ushort)num3; - } - - if (Main.tile[num44 - 3, num51].TileType == num2) - { - Main.tile[num44 - 3, num51].Get().HasTile = false; - Main.tile[num44 - 3, num51].ClearEverything(); - Main.tile[num44 - 3, num51].WallType = (ushort)num3; - } - } - - Main.tile[num44 - 1, num45].Get().HasTile = true; - Main.tile[num44 - 1, num45].TileType = num2; - Main.tile[num44 - 1, num45].Clear(TileDataType.Slope); - Main.tile[num44 + 1, num45].Get().HasTile = true; - Main.tile[num44 + 1, num45].TileType = num2; - Main.tile[num44 + 1, num45].Clear(TileDataType.Slope); - } - - int[] array = new int[3]; - switch (num3) - { - case 7: - array[0] = 7; - array[1] = 94; - array[2] = 95; - break; - case 9: - array[0] = 9; - array[1] = 96; - array[2] = 97; - break; - default: - array[0] = 8; - array[1] = 98; - array[2] = 99; - break; - } - - for (int num52 = 0; num52 < 5; num52++) - { - for (int num53 = 0; num53 < 3; num53++) - { - int num54 = WorldGen.genRand.Next(40, 240); - int num55 = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); - int num56 = WorldGen.genRand.Next(GenVars.dMinY, GenVars.dMaxY); - for (int num57 = num55 - num54; num57 < num55 + num54; num57++) - { - for (int num58 = num56 - num54; num58 < num56 + num54; num58++) - { - if ((double)num58 > Main.worldSurface) - { - double num59 = Math.Abs(num55 - num57); - double num60 = Math.Abs(num56 - num58); - if (Math.Sqrt(num59 * num59 + num60 * num60) < (double)num54 * 0.4 && Main.wallDungeon[Main.tile[num57, num58].WallType]) - WorldGen.Spread.WallDungeon(num57, num58, array[num53]); - } - } - } - } - } - - Main.statusText = Lang.gen[58].Value + " 85%"; - for (int num61 = 0; num61 < GenVars.numDungeonPlatforms; num61++) - { - int num62 = GenVars.dungeonPlatformX[num61]; - int num63 = GenVars.dungeonPlatformY[num61]; - int num64 = Main.maxTilesX; - int num65 = 10; - if ((double)num63 < Main.worldSurface + 50.0) - num65 = 20; - - for (int num66 = num63 - 5; num66 <= num63 + 5; num66++) - { - int num67 = num62; - int num68 = num62; - bool flag3 = false; - if (Main.tile[num67, num66].Get().HasTile) - { - flag3 = true; - } - else - { - while (!Main.tile[num67, num66].Get().HasTile) - { - num67--; - if (!Main.tileDungeon[Main.tile[num67, num66].TileType] || num67 == 0) - { - flag3 = true; - break; - } - } - - while (!Main.tile[num68, num66].Get().HasTile) - { - num68++; - if (!Main.tileDungeon[Main.tile[num68, num66].TileType] || num68 == Main.maxTilesX - 1) - { - flag3 = true; - break; - } - } - } - - if (flag3 || num68 - num67 > num65) - continue; - - bool flag4 = true; - int num69 = num62 - num65 / 2 - 2; - int num70 = num62 + num65 / 2 + 2; - int num71 = num66 - 5; - int num72 = num66 + 5; - for (int num73 = num69; num73 <= num70; num73++) - { - for (int num74 = num71; num74 <= num72; num74++) - { - if (Main.tile[num73, num74].Get().HasTile && Main.tile[num73, num74].TileType == 19) - { - flag4 = false; - break; - } - } - } - - for (int num75 = num66 + 3; num75 >= num66 - 5; num75--) - { - if (Main.tile[num62, num75].Get().HasTile) - { - flag4 = false; - break; - } - } - - if (flag4) - { - num64 = num66; - break; - } - } - - if (num64 <= num63 - 10 || num64 >= num63 + 10) - continue; - - int num76 = num62; - int num77 = num64; - int num78 = num62 + 1; - while (!Main.tile[num76, num77].Get().HasTile) - { - Main.tile[num76, num77].Get().HasTile = true; - Main.tile[num76, num77].TileType = 19; - Main.tile[num76, num77].Clear(TileDataType.Slope); - switch (num3) - { - case 7: - Main.tile[num76, num77].TileFrameY = 108; - break; - case 8: - Main.tile[num76, num77].TileFrameY = 144; - break; - default: - Main.tile[num76, num77].TileFrameY = 126; - break; - } - - WorldGen.TileFrame(num76, num77); - num76--; - } - - for (; !Main.tile[num78, num77].Get().HasTile; num78++) - { - Main.tile[num78, num77].Get().HasTile = true; - Main.tile[num78, num77].TileType = 19; - Main.tile[num78, num77].Clear(TileDataType.Slope); - switch (num3) - { - case 7: - Main.tile[num78, num77].TileFrameY = 108; - break; - case 8: - Main.tile[num78, num77].TileFrameY = 144; - break; - default: - Main.tile[num78, num77].TileFrameY = 126; - break; - } - - WorldGen.TileFrame(num78, num77); - } - } - - int num79 = 5; - if (WorldGen.drunkWorldGen) - num79 = 6; - - for (int num80 = 0; num80 < num79; num80++) - { - bool flag5 = false; - while (!flag5) - { - int num81 = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); - int num82 = WorldGen.genRand.Next((int)Main.worldSurface, GenVars.dMaxY); - if (!Main.wallDungeon[Main.tile[num81, num82].WallType] || Main.tile[num81, num82].Get().HasTile) - continue; - - ushort chestTileType = 21; - int contain = 0; - int style2 = 0; - switch (num80) - { - case 0: - style2 = 23; - contain = 1156; - break; - case 1: - if (!WorldGen.crimson) - { - style2 = 24; - contain = 1571; - } - else - { - style2 = 25; - contain = 1569; - } - break; - case 5: - if (WorldGen.crimson) - { - style2 = 24; - contain = 1571; - } - else - { - style2 = 25; - contain = 1569; - } - break; - case 2: - style2 = 26; - contain = 1260; - break; - case 3: - style2 = 27; - contain = 1572; - break; - case 4: - chestTileType = 467; - style2 = 13; - contain = 4607; - break; - } - - flag5 = WorldGen.AddBuriedChest(num81, num82, contain, notNearOtherChests: false, style2, trySlope: false, chestTileType); - } - } - - int[] array2 = new int[3] - { - WorldGen.genRand.Next(9, 13), - WorldGen.genRand.Next(9, 13), - 0 - }; - - while (array2[1] == array2[0]) - { - array2[1] = WorldGen.genRand.Next(9, 13); - } - - array2[2] = WorldGen.genRand.Next(9, 13); - while (array2[2] == array2[0] || array2[2] == array2[1]) - { - array2[2] = WorldGen.genRand.Next(9, 13); - } - - Main.statusText = Lang.gen[58].Value + " 90%"; - num13 = 0; - num14 = 1000; - num15 = 0; - while (num15 < Main.maxTilesX / 20) - { - num13++; - int num83 = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); - int num84 = WorldGen.genRand.Next(GenVars.dMinY, GenVars.dMaxY); - bool flag6 = true; - if (Main.wallDungeon[Main.tile[num83, num84].WallType] && !Main.tile[num83, num84].Get().HasTile) - { - int num85 = 1; - if (WorldGen.genRand.NextBool()) - num85 = -1; - - while (flag6 && !Main.tile[num83, num84].Get().HasTile) - { - num83 -= num85; - if (num83 < 5 || num83 > Main.maxTilesX - 5) - flag6 = false; - else if (Main.tile[num83, num84].Get().HasTile && !Main.tileDungeon[Main.tile[num83, num84].TileType]) - flag6 = false; - } - - if (flag6 && Main.tile[num83, num84].Get().HasTile && Main.tileDungeon[Main.tile[num83, num84].TileType] && Main.tile[num83, num84 - 1].Get().HasTile && Main.tileDungeon[Main.tile[num83, num84 - 1].TileType] && Main.tile[num83, num84 + 1].Get().HasTile && Main.tileDungeon[Main.tile[num83, num84 + 1].TileType]) - { - num83 += num85; - for (int num86 = num83 - 3; num86 <= num83 + 3; num86++) - { - for (int num87 = num84 - 3; num87 <= num84 + 3; num87++) - { - if (Main.tile[num86, num87].Get().HasTile && Main.tile[num86, num87].TileType == 19) - { - flag6 = false; - break; - } - } - } - - if (flag6 && (!Main.tile[num83, num84 - 1].Get().HasTile & !Main.tile[num83, num84 - 2].Get().HasTile & !Main.tile[num83, num84 - 3].Get().HasTile)) - { - int num88 = num83; - int num89 = num83; - for (; num88 > GenVars.dMinX && num88 < GenVars.dMaxX && !Main.tile[num88, num84].Get().HasTile && !Main.tile[num88, num84 - 1].Get().HasTile && !Main.tile[num88, num84 + 1].Get().HasTile; num88 += num85) - { - } - - num88 = Math.Abs(num83 - num88); - bool flag7 = false; - if (WorldGen.genRand.NextBool()) - flag7 = true; - - if (num88 > 5) - { - for (int num90 = WorldGen.genRand.Next(1, 4); num90 > 0; num90--) - { - Main.tile[num83, num84].Get().HasTile = true; - Main.tile[num83, num84].Clear(TileDataType.Slope); - Main.tile[num83, num84].TileType = 19; - if (Main.tile[num83, num84].WallType == array[0]) - Main.tile[num83, num84].TileFrameY = (short)(18 * array2[0]); - else if (Main.tile[num83, num84].WallType == array[1]) - Main.tile[num83, num84].TileFrameY = (short)(18 * array2[1]); - else - Main.tile[num83, num84].TileFrameY = (short)(18 * array2[2]); - - WorldGen.TileFrame(num83, num84); - if (flag7) - { - WorldGen.PlaceTile(num83, num84 - 1, 50, mute: true); - if (WorldGen.genRand.NextBool(50) && (double)num84 > (Main.worldSurface + Main.rockLayer) / 2.0 && Main.tile[num83, num84 - 1].TileType == 50) - Main.tile[num83, num84 - 1].TileFrameX = 90; - } - - num83 += num85; - } - - num13 = 0; - num15++; - if (!flag7 && WorldGen.genRand.NextBool()) - { - num83 = num89; - num84--; - int num91 = 0; - if (WorldGen.genRand.NextBool(4)) - num91 = 1; - - switch (num91) - { - case 0: - num91 = 13; - break; - case 1: - num91 = 49; - break; - } - - WorldGen.PlaceTile(num83, num84, num91, mute: true); - if (Main.tile[num83, num84].TileType == 13) - { - if (WorldGen.genRand.NextBool()) - Main.tile[num83, num84].TileFrameX = 18; - else - Main.tile[num83, num84].TileFrameX = 36; - } - } - } - } - } - } - - if (num13 > num14) - { - num13 = 0; - num15++; - } - } - - Main.statusText = Lang.gen[58].Value + " 95%"; - int num92 = 1; - for (int num93 = 0; num93 < GenVars.numDRooms; num93++) - { - int num94 = 0; - while (num94 < 1000) - { - int num95 = (int)((double)GenVars.dRoomSize[num93] * 0.4); - int i3 = GenVars.dRoomX[num93] + WorldGen.genRand.Next(-num95, num95 + 1); - int num96 = GenVars.dRoomY[num93] + WorldGen.genRand.Next(-num95, num95 + 1); - int num97 = 0; - int style3 = 2; - if (num92 == 1) - num92++; - - switch (num92) - { - case 2: - num97 = 155; - break; - case 3: - num97 = 156; - break; - case 4: - num97 = ((!WorldGen.remixWorldGen) ? 157 : 2623); - break; - case 5: - num97 = 163; - break; - case 6: - num97 = 113; - break; - case 7: - num97 = 3317; - break; - case 8: - num97 = 327; - style3 = 0; - break; - default: - num97 = 164; - num92 = 0; - break; - } - - if ((double)num96 < Main.worldSurface + 50.0) - { - num97 = 327; - style3 = 0; - } - - if (num97 == 0 && WorldGen.genRand.NextBool()) - { - num94 = 1000; - continue; - } - - if (WorldGen.AddBuriedChest(i3, num96, num97, notNearOtherChests: false, style3, trySlope: false, 0)) - { - num94 += 1000; - num92++; - } - - num94++; - } - } - - GenVars.dMinX -= 25; - GenVars.dMaxX += 25; - GenVars.dMinY -= 25; - GenVars.dMaxY += 25; - if (GenVars.dMinX < 0) - GenVars.dMinX = 0; - - if (GenVars.dMaxX > Main.maxTilesX) - GenVars.dMaxX = Main.maxTilesX; - - if (GenVars.dMinY < 0) - GenVars.dMinY = 0; - - if (GenVars.dMaxY > Main.maxTilesY) - GenVars.dMaxY = Main.maxTilesY; - - num13 = 0; - num14 = 1000; - num15 = 0; - MakeDungeon_Lights(num2, ref num13, num14, ref num15, array); - num13 = 0; - num14 = 1000; - num15 = 0; - MakeDungeon_Traps(ref num13, num14, ref num15); - double count = MakeDungeon_GroundFurniture(num3); - count = MakeDungeon_Pictures(array, count); - count = MakeDungeon_Banners(array, count); - - // Get dungeon size field infos. - int MinX = GenVars.dMinX + 25; - int MaxX = GenVars.dMaxX - 25; - int MaxY = GenVars.dMaxY - 25; - - int[] ChestTypes = { ModContent.TileType() }; - int[] ItemTypes = { ModContent.ItemType() }; - int[] ChestStyles = { 1 }; // Astral Chest generates in style 1, which is locked - - for (int i = 0; i < ChestTypes.Length; ++i) - { - Chest chest = null; - int attempts = 0; - - // Try 1000 times to place the chest somewhere in the dungeon. - // The placement algorithm ensures that if it tries to appear in midair, it is moved down to the floor. - while (chest == null && attempts < 1000) - { - attempts++; - int x2 = WorldGen.genRand.Next(MinX, MaxX); - int y2 = WorldGen.genRand.Next((int)Main.worldSurface, MaxY); - if (Main.wallDungeon[Main.tile[x2, y2].WallType] && !Main.tile[x2, y2].HasTile) - chest = MiscWorldgenRoutines.AddChestWithLoot(x2, y2, (ushort)ChestTypes[i], tileStyle: ChestStyles[i]); - } - - // If a chest was placed, force its first item to be the unique Biome Chest weapon. - if (chest != null) - { - chest.item[0].SetDefaults(ItemTypes[i]); - chest.item[0].Prefix(-1); - } - } - } - - public static void MakeDungeon_Traps(ref int failCount, int failMax, ref int numAdd) - { - while (numAdd < Main.maxTilesX / 500) - { - failCount++; - int num = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); - int num2 = WorldGen.genRand.Next(GenVars.dMinY, GenVars.dMaxY); - while ((double)num2 < Main.worldSurface) - { - num2 = WorldGen.genRand.Next(GenVars.dMinY, GenVars.dMaxY); - } - - if (Main.wallDungeon[Main.tile[num, num2].WallType] && WorldGen.placeTrap(num, num2, 0)) - failCount = failMax; - - if (failCount > failMax) - { - numAdd++; - failCount = 0; - } - } - } - - public static void MakeDungeon_Lights(ushort tileType, ref int failCount, int failMax, ref int numAdd, int[] roomWall) - { - int[] array = new int[3] - { - WorldGen.genRand.Next(7), - WorldGen.genRand.Next(7), - 0 - }; - - while (array[1] == array[0]) - { - array[1] = WorldGen.genRand.Next(7); - } - - array[2] = WorldGen.genRand.Next(7); - while (array[2] == array[0] || array[2] == array[1]) - { - array[2] = WorldGen.genRand.Next(7); - } - - while (numAdd < Main.maxTilesX / 150) - { - failCount++; - int num = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); - int num2 = WorldGen.genRand.Next(GenVars.dMinY, GenVars.dMaxY); - if (Main.wallDungeon[Main.tile[num, num2].WallType]) - { - for (int num3 = num2; num3 > GenVars.dMinY; num3--) - { - if (Main.tile[num, num3 - 1].HasTile && Main.tile[num, num3 - 1].TileType == tileType) - { - bool flag = false; - for (int i = num - 15; i < num + 15; i++) - { - for (int j = num3 - 15; j < num3 + 15; j++) - { - if (i > 0 && i < Main.maxTilesX && j > 0 && j < Main.maxTilesY && (Main.tile[i, j].TileType == 42 || Main.tile[i, j].TileType == 34)) - { - flag = true; - break; - } - } - } - - if (Main.tile[num - 1, num3].HasTile || Main.tile[num + 1, num3].HasTile || Main.tile[num - 1, num3 + 1].HasTile || Main.tile[num + 1, num3 + 1].HasTile || Main.tile[num, num3 + 2].HasTile) - flag = true; - - if (flag) - break; - - bool flag2 = false; - if (!flag2 && WorldGen.genRand.NextBool(7)) - { - int style = 27; - switch (roomWall[0]) - { - case 7: - style = 27; - break; - case 8: - style = 28; - break; - case 9: - style = 29; - break; - } - - bool flag3 = false; - for (int k = 0; k < 15; k++) - { - if (WorldGen.SolidTile(num, num3 + k)) - { - flag3 = true; - break; - } - } - - if (!flag3) - WorldGen.PlaceChand(num, num3, 34, style); - - if (Main.tile[num, num3].TileType == 34) - { - flag2 = true; - failCount = 0; - numAdd++; - for (int l = 0; l < 1000; l++) - { - int num4 = num + WorldGen.genRand.Next(-12, 13); - int num5 = num3 + WorldGen.genRand.Next(3, 21); - if (Main.tile[num4, num5].HasTile || Main.tile[num4, num5 + 1].HasTile || !Main.tileDungeon[Main.tile[num4 - 1, num5].TileType] || !Main.tileDungeon[Main.tile[num4 + 1, num5].TileType] || !Collision.CanHit(new Point(num4 * 16, num5 * 16), 16, 16, new Point(num * 16, num3 * 16 + 1), 16, 16)) - continue; - - if (((WorldGen.SolidTile(num4 - 1, num5) && Main.tile[num4 - 1, num5].TileType != 10) || (WorldGen.SolidTile(num4 + 1, num5) && Main.tile[num4 + 1, num5].TileType != 10) || WorldGen.SolidTile(num4, num5 + 1)) && Main.wallDungeon[Main.tile[num4, num5].WallType] && (Main.tileDungeon[Main.tile[num4 - 1, num5].TileType] || Main.tileDungeon[Main.tile[num4 + 1, num5].TileType])) - WorldGen.PlaceTile(num4, num5, 136, mute: true); - - if (!Main.tile[num4, num5].HasTile) - continue; - - while (num4 != num || num5 != num3) - { - Main.tile[num4, num5].Get().RedWire = true; - if (num4 > num) - num4--; - - if (num4 < num) - num4++; - - Main.tile[num4, num5].Get().RedWire = true; - if (num5 > num3) - num5--; - - if (num5 < num3) - num5++; - - Main.tile[num4, num5].Get().RedWire = true; - } - - if (WorldGen.genRand.Next(3) > 0) - { - Main.tile[num, num3].TileFrameX = 18; - Main.tile[num, num3 + 1].TileFrameX = 18; - } - - break; - } - } - } - - if (flag2) - break; - - int style2 = array[0]; - if (Main.tile[num, num3].WallType == roomWall[1]) - style2 = array[1]; - - if (Main.tile[num, num3].WallType == roomWall[2]) - style2 = array[2]; - - WorldGen.Place1x2Top(num, num3, 42, style2); - if (Main.tile[num, num3].TileType != 42) - break; - - flag2 = true; - failCount = 0; - numAdd++; - for (int m = 0; m < 1000; m++) - { - int num6 = num + WorldGen.genRand.Next(-12, 13); - int num7 = num3 + WorldGen.genRand.Next(3, 21); - if (Main.tile[num6, num7].HasTile || Main.tile[num6, num7 + 1].HasTile || Main.tile[num6 - 1, num7].TileType == 48 || Main.tile[num6 + 1, num7].TileType == 48 || !Collision.CanHit(new Point(num6 * 16, num7 * 16), 16, 16, new Point(num * 16, num3 * 16 + 1), 16, 16)) - continue; - - if ((WorldGen.SolidTile(num6 - 1, num7) && Main.tile[num6 - 1, num7].TileType != 10) || (WorldGen.SolidTile(num6 + 1, num7) && Main.tile[num6 + 1, num7].TileType != 10) || WorldGen.SolidTile(num6, num7 + 1)) - WorldGen.PlaceTile(num6, num7, 136, mute: true); - - if (!Main.tile[num6, num7].HasTile) - continue; - - while (num6 != num || num7 != num3) - { - Main.tile[num6, num7].Get().RedWire = true; - if (num6 > num) - num6--; - - if (num6 < num) - num6++; - - Main.tile[num6, num7].Get().RedWire = true; - if (num7 > num3) - num7--; - - if (num7 < num3) - num7++; - - Main.tile[num6, num7].Get().RedWire = true; - } - - if (WorldGen.genRand.Next(3) > 0) - { - Main.tile[num, num3].TileFrameX = 18; - Main.tile[num, num3 + 1].TileFrameX = 18; - } - - break; - } - - break; - } - } - } - - if (failCount > failMax) - { - numAdd++; - failCount = 0; - } - } - } - - public static double MakeDungeon_Banners(int[] roomWall, double count) - { - count = 840000.0 / (double)Main.maxTilesX; - for (int i = 0; (double)i < count; i++) - { - int num = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); - int num2 = WorldGen.genRand.Next(GenVars.dMinY, GenVars.dMaxY); - while (!Main.wallDungeon[Main.tile[num, num2].WallType] || Main.tile[num, num2].HasTile) - { - num = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); - num2 = WorldGen.genRand.Next(GenVars.dMinY, GenVars.dMaxY); - } - - while (!WorldGen.SolidTile(num, num2) && num2 > 10) - { - num2--; - } - - num2++; - if (!Main.wallDungeon[Main.tile[num, num2].WallType] || Main.tile[num, num2 - 1].TileType == 48 || Main.tile[num, num2].HasTile || Main.tile[num, num2 + 1].HasTile || Main.tile[num, num2 + 2].HasTile || Main.tile[num, num2 + 3].HasTile) - continue; - - bool flag = true; - for (int j = num - 1; j <= num + 1; j++) - { - for (int k = num2; k <= num2 + 3; k++) - { - if (Main.tile[j, k].HasTile && (Main.tile[j, k].TileType == 10 || Main.tile[j, k].TileType == 11 || Main.tile[j, k].TileType == 91)) - flag = false; - } - } - - if (flag) - { - int num3 = 10; - if (Main.tile[num, num2].WallType == roomWall[1]) - num3 = 12; - - if (Main.tile[num, num2].WallType == roomWall[2]) - num3 = 14; - - num3 += WorldGen.genRand.Next(2); - WorldGen.PlaceTile(num, num2, 91, mute: true, forced: false, -1, num3); - } - } - - return count; - } - - public static double MakeDungeon_Pictures(int[] roomWall, double count) - { - count = 420000.0 / (double)Main.maxTilesX; - for (int i = 0; (double)i < count; i++) - { - int num = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); - int num2 = WorldGen.genRand.Next((int)Main.worldSurface, GenVars.dMaxY); - while (!Main.wallDungeon[Main.tile[num, num2].WallType] || Main.tile[num, num2].HasTile) - { - num = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); - num2 = WorldGen.genRand.Next((int)Main.worldSurface, GenVars.dMaxY); - } - - int num3 = num; - int num4 = num; - int num5 = num2; - int num6 = num2; - int num7 = 0; - int num8 = 0; - for (int j = 0; j < 2; j++) - { - num3 = num; - num4 = num; - while (!Main.tile[num3, num2].HasTile && Main.wallDungeon[Main.tile[num3, num2].WallType]) - { - num3--; - } - - num3++; - for (; !Main.tile[num4, num2].HasTile && Main.wallDungeon[Main.tile[num4, num2].WallType]; num4++) - { - } - - num4--; - num = (num3 + num4) / 2; - num5 = num2; - num6 = num2; - while (!Main.tile[num, num5].HasTile && Main.wallDungeon[Main.tile[num, num5].WallType]) - { - num5--; - } - - num5++; - for (; !Main.tile[num, num6].HasTile && Main.wallDungeon[Main.tile[num, num6].WallType]; num6++) - { - } - - num6--; - num2 = (num5 + num6) / 2; - } - - num3 = num; - num4 = num; - while (!Main.tile[num3, num2].HasTile && !Main.tile[num3, num2 - 1].HasTile && !Main.tile[num3, num2 + 1].HasTile) - { - num3--; - } - - num3++; - for (; !Main.tile[num4, num2].HasTile && !Main.tile[num4, num2 - 1].HasTile && !Main.tile[num4, num2 + 1].HasTile; num4++) - { - } - - num4--; - num5 = num2; - num6 = num2; - while (!Main.tile[num, num5].HasTile && !Main.tile[num - 1, num5].HasTile && !Main.tile[num + 1, num5].HasTile) - { - num5--; - } - - num5++; - for (; !Main.tile[num, num6].HasTile && !Main.tile[num - 1, num6].HasTile && !Main.tile[num + 1, num6].HasTile; num6++) - { - } - - num6--; - num = (num3 + num4) / 2; - num2 = (num5 + num6) / 2; - num7 = num4 - num3; - num8 = num6 - num5; - if (num7 <= 7 || num8 <= 5) - continue; - - bool[] array = new bool[3] - { - true, - false, - false - }; - - if (num7 > num8 * 3 && num7 > 21) - array[1] = true; - - if (num8 > num7 * 3 && num8 > 21) - array[2] = true; - - int num9 = WorldGen.genRand.Next(3); - if (Main.tile[num, num2].WallType == roomWall[0]) - num9 = 0; - - while (!array[num9]) - { - num9 = WorldGen.genRand.Next(3); - } - - if (WorldGen.nearPicture2(num, num2)) - num9 = -1; - - switch (num9) - { - case 0: - { - PaintingEntry paintingEntry2 = WorldGen.RandPictureTile(); - if (Main.tile[num, num2].WallType != roomWall[0]) - paintingEntry2 = WorldGen.RandBonePicture(); - - if (!WorldGen.nearPicture(num, num2)) - WorldGen.PlaceTile(num, num2, paintingEntry2.tileType, mute: true, forced: false, -1, paintingEntry2.style); - - break; - } - case 1: - { - PaintingEntry paintingEntry3 = WorldGen.RandPictureTile(); - if (Main.tile[num, num2].WallType != roomWall[0]) - paintingEntry3 = WorldGen.RandBonePicture(); - - if (!Main.tile[num, num2].HasTile) - WorldGen.PlaceTile(num, num2, paintingEntry3.tileType, mute: true, forced: false, -1, paintingEntry3.style); - - int num13 = num; - int num14 = num2; - int num15 = num2; - for (int m = 0; m < 2; m++) - { - num += 7; - num5 = num15; - num6 = num15; - while (!Main.tile[num, num5].HasTile && !Main.tile[num - 1, num5].HasTile && !Main.tile[num + 1, num5].HasTile) - { - num5--; - } - - num5++; - for (; !Main.tile[num, num6].HasTile && !Main.tile[num - 1, num6].HasTile && !Main.tile[num + 1, num6].HasTile; num6++) - { - } - - num6--; - num15 = (num5 + num6) / 2; - paintingEntry3 = WorldGen.RandPictureTile(); - if (Main.tile[num, num15].WallType != roomWall[0]) - paintingEntry3 = WorldGen.RandBonePicture(); - - if (Math.Abs(num14 - num15) >= 4 || WorldGen.nearPicture(num, num15)) - break; - - WorldGen.PlaceTile(num, num15, paintingEntry3.tileType, mute: true, forced: false, -1, paintingEntry3.style); - } - - num15 = num2; - num = num13; - for (int n = 0; n < 2; n++) - { - num -= 7; - num5 = num15; - num6 = num15; - while (!Main.tile[num, num5].HasTile && !Main.tile[num - 1, num5].HasTile && !Main.tile[num + 1, num5].HasTile) - { - num5--; - } - - num5++; - for (; !Main.tile[num, num6].HasTile && !Main.tile[num - 1, num6].HasTile && !Main.tile[num + 1, num6].HasTile; num6++) - { - } - - num6--; - num15 = (num5 + num6) / 2; - paintingEntry3 = WorldGen.RandPictureTile(); - if (Main.tile[num, num15].WallType != roomWall[0]) - paintingEntry3 = WorldGen.RandBonePicture(); - - if (Math.Abs(num14 - num15) >= 4 || WorldGen.nearPicture(num, num15)) - break; - - WorldGen.PlaceTile(num, num15, paintingEntry3.tileType, mute: true, forced: false, -1, paintingEntry3.style); - } - - break; - } - case 2: - { - PaintingEntry paintingEntry = WorldGen.RandPictureTile(); - if (Main.tile[num, num2].WallType != roomWall[0]) - paintingEntry = WorldGen.RandBonePicture(); - - if (!Main.tile[num, num2].HasTile) - WorldGen.PlaceTile(num, num2, paintingEntry.tileType, mute: true, forced: false, -1, paintingEntry.style); - - int num10 = num2; - int num11 = num; - int num12 = num; - for (int k = 0; k < 3; k++) - { - num2 += 7; - num3 = num12; - num4 = num12; - while (!Main.tile[num3, num2].HasTile && !Main.tile[num3, num2 - 1].HasTile && !Main.tile[num3, num2 + 1].HasTile) - { - num3--; - } - - num3++; - for (; !Main.tile[num4, num2].HasTile && !Main.tile[num4, num2 - 1].HasTile && !Main.tile[num4, num2 + 1].HasTile; num4++) - { - } - - num4--; - num12 = (num3 + num4) / 2; - paintingEntry = WorldGen.RandPictureTile(); - if (Main.tile[num12, num2].WallType != roomWall[0]) - paintingEntry = WorldGen.RandBonePicture(); - - if (Math.Abs(num11 - num12) >= 4 || WorldGen.nearPicture(num12, num2)) - break; - - WorldGen.PlaceTile(num12, num2, paintingEntry.tileType, mute: true, forced: false, -1, paintingEntry.style); - } - - num12 = num; - num2 = num10; - for (int l = 0; l < 3; l++) - { - num2 -= 7; - num3 = num12; - num4 = num12; - while (!Main.tile[num3, num2].HasTile && !Main.tile[num3, num2 - 1].HasTile && !Main.tile[num3, num2 + 1].HasTile) - { - num3--; - } - - num3++; - for (; !Main.tile[num4, num2].HasTile && !Main.tile[num4, num2 - 1].HasTile && !Main.tile[num4, num2 + 1].HasTile; num4++) - { - } - - num4--; - num12 = (num3 + num4) / 2; - paintingEntry = WorldGen.RandPictureTile(); - if (Main.tile[num12, num2].WallType != roomWall[0]) - paintingEntry = WorldGen.RandBonePicture(); - - if (Math.Abs(num11 - num12) >= 4 || WorldGen.nearPicture(num12, num2)) - break; - - WorldGen.PlaceTile(num12, num2, paintingEntry.tileType, mute: true, forced: false, -1, paintingEntry.style); - } - - break; - } - } - } - - return count; - } - - public static double MakeDungeon_GroundFurniture(int wallType) - { - double num = (double)(2000 * Main.maxTilesX) / 4200.0; - int num2 = 1 + (int)((double)Main.maxTilesX / 4200.0); - int num3 = 1 + (int)((double)Main.maxTilesX / 4200.0); - for (int i = 0; (double)i < num; i++) - { - if (num2 > 0 || num3 > 0) - i--; - - int num4 = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); - int j = WorldGen.genRand.Next((int)Main.worldSurface + 10, GenVars.dMaxY); - while (!Main.wallDungeon[Main.tile[num4, j].WallType] || Main.tile[num4, j].HasTile) - { - num4 = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); - j = WorldGen.genRand.Next((int)Main.worldSurface + 10, GenVars.dMaxY); - } - - if (!Main.wallDungeon[Main.tile[num4, j].WallType] || Main.tile[num4, j].HasTile) - continue; - - for (; !WorldGen.SolidTile(num4, j) && j < Main.UnderworldLayer; j++) - { - } - - j--; - int num5 = num4; - int k = num4; - while (!Main.tile[num5, j].HasTile && WorldGen.SolidTile(num5, j + 1)) - { - num5--; - } - - num5++; - for (; !Main.tile[k, j].HasTile && WorldGen.SolidTile(k, j + 1); k++) - { - } - - k--; - int num6 = k - num5; - int num7 = (k + num5) / 2; - if (Main.tile[num7, j].HasTile || !Main.wallDungeon[Main.tile[num7, j].WallType] || !WorldGen.SolidTile(num7, j + 1) || Main.tile[num7, j + 1].TileType == 48) - continue; - - int style = 13; - int style2 = 10; - int style3 = 11; - int num8 = 1; - int num9 = 46; - int style4 = 1; - int num10 = 5; - int num11 = 11; - int num12 = 5; - int num13 = 6; - int num14 = 21; - int num15 = 22; - int num16 = 24; - int num17 = 30; - switch (wallType) - { - case 8: - style = 14; - style2 = 11; - style3 = 12; - num8 = 2; - num9 = 47; - style4 = 2; - num10 = 6; - num11 = 12; - num12 = 6; - num13 = 7; - num14 = 22; - num15 = 23; - num16 = 25; - num17 = 31; - break; - case 9: - style = 15; - style2 = 12; - style3 = 13; - num8 = 3; - num9 = 48; - style4 = 3; - num10 = 7; - num11 = 13; - num12 = 7; - num13 = 8; - num14 = 23; - num15 = 24; - num16 = 26; - num17 = 32; - break; - } - - if (Main.tile[num7, j].WallType >= 94 && Main.tile[num7, j].WallType <= 105) - { - style = 17; - style2 = 14; - style3 = 15; - num8 = -1; - num9 = -1; - style4 = 5; - num10 = -1; - num11 = -1; - num12 = -1; - num13 = -1; - num14 = -1; - num15 = -1; - num16 = -1; - num17 = -1; - } - - int num18 = WorldGen.genRand.Next(13); - if ((num18 == 10 || num18 == 11 || num18 == 12) && WorldGen.genRand.Next(4) != 0) - num18 = WorldGen.genRand.Next(13); - - while ((num18 == 2 && num9 == -1) || (num18 == 5 && num10 == -1) || (num18 == 6 && num11 == -1) || (num18 == 7 && num12 == -1) || (num18 == 8 && num13 == -1) || (num18 == 9 && num14 == -1) || (num18 == 10 && num15 == -1) || (num18 == 11 && num16 == -1) || (num18 == 12 && num17 == -1)) - { - num18 = WorldGen.genRand.Next(13); - } - - int num19 = 0; - int num20 = 0; - if (num18 == 0) - { - num19 = 5; - num20 = 4; - } - - if (num18 == 1) - { - num19 = 4; - num20 = 3; - } - - if (num18 == 2) - { - num19 = 3; - num20 = 5; - } - - if (num18 == 3) - { - num19 = 4; - num20 = 6; - } - - if (num18 == 4) - { - num19 = 3; - num20 = 3; - } - - if (num18 == 5) - { - num19 = 5; - num20 = 3; - } - - if (num18 == 6) - { - num19 = 5; - num20 = 4; - } - - if (num18 == 7) - { - num19 = 5; - num20 = 4; - } - - if (num18 == 8) - { - num19 = 5; - num20 = 4; - } - - if (num18 == 9) - { - num19 = 5; - num20 = 3; - } - - if (num18 == 10) - { - num19 = 2; - num20 = 4; - } - - if (num18 == 11) - { - num19 = 3; - num20 = 3; - } - - if (num18 == 12) - { - num19 = 2; - num20 = 5; - } - - for (int l = num7 - num19; l <= num7 + num19; l++) - { - for (int m = j - num20; m <= j; m++) - { - if (Main.tile[l, m].HasTile) - { - num18 = -1; - break; - } - } - } - - if ((double)num6 < (double)num19 * 1.75) - num18 = -1; - - if (num2 > 0 || num3 > 0) - { - if (num2 > 0) - { - WorldGen.PlaceTile(num7, j, 355, mute: true); - if (Main.tile[num7, j].TileType == 355) - num2--; - } - else if (num3 > 0) - { - WorldGen.PlaceTile(num7, j, 354, mute: true); - if (Main.tile[num7, j].TileType == 354) - num3--; - } - - continue; - } - - switch (num18) - { - case 0: - { - WorldGen.PlaceTile(num7, j, 14, mute: true, forced: false, -1, style2); - if (Main.tile[num7, j].HasTile) - { - if (!Main.tile[num7 - 2, j].HasTile) - { - WorldGen.PlaceTile(num7 - 2, j, 15, mute: true, forced: false, -1, style); - if (Main.tile[num7 - 2, j].HasTile) - { - Main.tile[num7 - 2, j].TileFrameX += 18; - Main.tile[num7 - 2, j - 1].TileFrameX += 18; - } - } - - if (!Main.tile[num7 + 2, j].HasTile) - WorldGen.PlaceTile(num7 + 2, j, 15, mute: true, forced: false, -1, style); - } - - for (int num22 = num7 - 1; num22 <= num7 + 1; num22++) - { - if (WorldGen.genRand.NextBool() && !Main.tile[num22, j - 2].HasTile) - { - int num23 = WorldGen.genRand.Next(5); - if (num8 != -1 && num23 <= 1 && !Main.tileLighted[Main.tile[num22 - 1, j - 2].TileType]) - WorldGen.PlaceTile(num22, j - 2, 33, mute: true, forced: false, -1, num8); - - if (num23 == 2 && !Main.tileLighted[Main.tile[num22 - 1, j - 2].TileType]) - WorldGen.PlaceTile(num22, j - 2, 49, mute: true); - - if (num23 == 3) - WorldGen.PlaceTile(num22, j - 2, 50, mute: true); - - if (num23 == 4) - WorldGen.PlaceTile(num22, j - 2, 103, mute: true); - } - } - - break; - } - case 1: - { - WorldGen.PlaceTile(num7, j, 18, mute: true, forced: false, -1, style3); - if (!Main.tile[num7, j].HasTile) - break; - - if (WorldGen.genRand.NextBool()) - { - if (!Main.tile[num7 - 1, j].HasTile) - { - WorldGen.PlaceTile(num7 - 1, j, 15, mute: true, forced: false, -1, style); - if (Main.tile[num7 - 1, j].HasTile) - { - Main.tile[num7 - 1, j].TileFrameX += 18; - Main.tile[num7 - 1, j - 1].TileFrameX += 18; - } - } - } - else if (!Main.tile[num7 + 2, j].HasTile) - { - WorldGen.PlaceTile(num7 + 2, j, 15, mute: true, forced: false, -1, style); - } - - for (int n = num7; n <= num7 + 1; n++) - { - if (WorldGen.genRand.NextBool() && !Main.tile[n, j - 1].HasTile) - { - int num21 = WorldGen.genRand.Next(5); - if (num8 != -1 && num21 <= 1 && !Main.tileLighted[Main.tile[n - 1, j - 1].TileType]) - WorldGen.PlaceTile(n, j - 1, 33, mute: true, forced: false, -1, num8); - - if (num21 == 2 && !Main.tileLighted[Main.tile[n - 1, j - 1].TileType]) - WorldGen.PlaceTile(n, j - 1, 49, mute: true); - - if (num21 == 3) - WorldGen.PlaceTile(n, j - 1, 50, mute: true); - - if (num21 == 4) - WorldGen.PlaceTile(n, j - 1, 103, mute: true); - } - } - - break; - } - case 2: - WorldGen.PlaceTile(num7, j, 105, mute: true, forced: false, -1, num9); - break; - case 3: - WorldGen.PlaceTile(num7, j, 101, mute: true, forced: false, -1, style4); - break; - case 4: - if (WorldGen.genRand.NextBool()) - { - WorldGen.PlaceTile(num7, j, 15, mute: true, forced: false, -1, style); - Main.tile[num7, j].TileFrameX += 18; - Main.tile[num7, j - 1].TileFrameX += 18; - } - else - { - WorldGen.PlaceTile(num7, j, 15, mute: true, forced: false, -1, style); - } - break; - case 5: - if (WorldGen.genRand.NextBool()) - WorldGen.Place4x2(num7, j, 79, 1, num10); - else - WorldGen.Place4x2(num7, j, 79, -1, num10); - break; - case 6: - WorldGen.PlaceTile(num7, j, 87, mute: true, forced: false, -1, num11); - break; - case 7: - WorldGen.PlaceTile(num7, j, 88, mute: true, forced: false, -1, num12); - break; - case 8: - WorldGen.PlaceTile(num7, j, 89, mute: true, forced: false, -1, num13); - break; - case 9: - if (WorldGen.genRand.NextBool()) - WorldGen.Place4x2(num7, j, 90, 1, num14); - else - WorldGen.Place4x2(num7, j, 90, -1, num14); - break; - case 10: - WorldGen.PlaceTile(num7, j, 93, mute: true, forced: false, -1, num16); - break; - case 11: - WorldGen.PlaceTile(num7, j, 100, mute: true, forced: false, -1, num15); - break; - case 12: - WorldGen.PlaceTile(num7, j, 104, mute: true, forced: false, -1, num17); - break; - } - } - - return num; - } - - public static void GenNewDungeonHalls(int i, int j, ushort tileType, int wallType, bool forceX = false) - { - Vector2D zero = Vector2D.Zero; - double num = WorldGen.genRand.Next(4, 6); - double num2 = num; - Vector2D zero2 = Vector2D.Zero; - Vector2D zero3 = Vector2D.Zero; - int num3 = 1; - Vector2D vector2D = default(Vector2D); - vector2D.X = i; - - // This is what the Calamity IL edit used to do, in order to move the dungeon halls away from the Sulphur Sea. - vector2D.X = MathHelper.Clamp((float)vector2D.X, SulphurousSea.BiomeWidth + 25, Main.maxTilesX - SulphurousSea.BiomeWidth - 25); - - vector2D.Y = j; - int num4 = WorldGen.genRand.Next(35, 80); - bool flag = false; - if (WorldGen.genRand.Next(6) == 0) - flag = true; - - if (forceX) - { - num4 += 20; - GenVars.lastDungeonHall = Vector2D.Zero; - } - else if (WorldGen.genRand.Next(5) == 0) - { - num *= 2.0; - num4 /= 2; - } - - bool flag2 = false; - bool flag3 = false; - bool flag4 = true; - bool flag5 = false; - while (!flag2) - { - flag5 = false; - if (flag4 && !forceX) - { - bool flag6 = true; - bool flag7 = true; - bool flag8 = true; - bool flag9 = true; - int num5 = num4; - bool flag10 = false; - for (int num6 = j; num6 > j - num5; num6--) - { - if (Main.tile[i, num6].WallType == wallType) - { - if (flag10) - { - flag6 = false; - break; - } - } - else - { - flag10 = true; - } - } - - flag10 = false; - for (int k = j; k < j + num5; k++) - { - if (Main.tile[i, k].WallType == wallType) - { - if (flag10) - { - flag7 = false; - break; - } - } - else - { - flag10 = true; - } - } - - flag10 = false; - for (int num7 = i; num7 > i - num5; num7--) - { - if (Main.tile[num7, j].WallType == wallType) - { - if (flag10) - { - flag8 = false; - break; - } - } - else - { - flag10 = true; - } - } - - flag10 = false; - for (int l = i; l < i + num5; l++) - { - if (Main.tile[l, j].WallType == wallType) - { - if (flag10) - { - flag9 = false; - break; - } - } - else - { - flag10 = true; - } - } - - if (!flag8 && !flag9 && !flag6 && !flag7) - { - num3 = (WorldGen.genRand.NextBool() ? 1 : (-1)); - if (WorldGen.genRand.NextBool()) - flag5 = true; - } - else - { - int num8 = WorldGen.genRand.Next(4); - do - { - num8 = WorldGen.genRand.Next(4); - } while (!(num8 == 0 && flag6) && !(num8 == 1 && flag7) && !(num8 == 2 && flag8) && !(num8 == 3 && flag9)); - - switch (num8) - { - case 0: - num3 = -1; - break; - case 1: - num3 = 1; - break; - default: - flag5 = true; - num3 = ((num8 != 2) ? 1 : (-1)); - break; - } - } - } - else - { - num3 = (WorldGen.genRand.NextBool() ? 1 : (-1)); - if (WorldGen.genRand.NextBool()) - flag5 = true; - } - - flag4 = false; - if (forceX) - flag5 = true; - - if (flag5) - { - zero2.Y = 0.0; - zero2.X = num3; - zero3.Y = 0.0; - zero3.X = -num3; - zero.Y = 0.0; - zero.X = num3; - if (WorldGen.genRand.Next(3) == 0) - { - if (WorldGen.genRand.NextBool()) - zero.Y = -0.2; - else - zero.Y = 0.2; - } - } - else - { - num += 1.0; - zero.Y = num3; - zero.X = 0.0; - zero2.X = 0.0; - zero2.Y = num3; - zero3.X = 0.0; - zero3.Y = -num3; - if (WorldGen.genRand.Next(3) != 0) - { - flag3 = true; - if (WorldGen.genRand.NextBool()) - zero.X = (double)WorldGen.genRand.Next(10, 20) * 0.1; - else - zero.X = (double)(-WorldGen.genRand.Next(10, 20)) * 0.1; - } - else if (WorldGen.genRand.NextBool()) - { - if (WorldGen.genRand.NextBool()) - zero.X = (double)WorldGen.genRand.Next(20, 40) * 0.01; - else - zero.X = (double)(-WorldGen.genRand.Next(20, 40)) * 0.01; - } - else - { - num4 /= 2; - } - } - - if (GenVars.lastDungeonHall != zero3) - flag2 = true; - } - - int num9 = 0; - bool flag11 = vector2D.Y < Main.rockLayer + 100.0; - if (WorldGen.remixWorldGen) - flag11 = vector2D.Y < Main.worldSurface + 100.0; - - // Fuck you - int LastMaxTilesX = (int)typeof(WorldGen).GetField("lastMaxTilesX", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null); - int LastMaxTilesY = (int)typeof(WorldGen).GetField("lastMaxTilesY", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null); - - if (!forceX) - { - if (vector2D.X > (double)(LastMaxTilesX - 200)) - { - num3 = -1; - zero2.Y = 0.0; - zero2.X = num3; - zero.Y = 0.0; - zero.X = num3; - if (WorldGen.genRand.Next(3) == 0) - { - if (WorldGen.genRand.NextBool()) - zero.Y = -0.2; - else - zero.Y = 0.2; - } - } - else if (vector2D.X < 200.0) - { - num3 = 1; - zero2.Y = 0.0; - zero2.X = num3; - zero.Y = 0.0; - zero.X = num3; - if (WorldGen.genRand.Next(3) == 0) - { - if (WorldGen.genRand.NextBool()) - zero.Y = -0.2; - else - zero.Y = 0.2; - } - } - else if (vector2D.Y > (double)(LastMaxTilesY - 300)) - { - num3 = -1; - num += 1.0; - zero.Y = num3; - zero.X = 0.0; - zero2.X = 0.0; - zero2.Y = num3; - if (WorldGen.genRand.NextBool()) - { - if (WorldGen.genRand.NextBool()) - zero.X = (double)WorldGen.genRand.Next(20, 50) * 0.01; - else - zero.X = (double)(-WorldGen.genRand.Next(20, 50)) * 0.01; - } - } - else if (flag11) - { - num3 = 1; - num += 1.0; - zero.Y = num3; - zero.X = 0.0; - zero2.X = 0.0; - zero2.Y = num3; - if (WorldGen.genRand.Next(3) != 0) - { - flag3 = true; - if (WorldGen.genRand.NextBool()) - zero.X = (double)WorldGen.genRand.Next(10, 20) * 0.1; - else - zero.X = (double)(-WorldGen.genRand.Next(10, 20)) * 0.1; - } - else if (WorldGen.genRand.NextBool()) - { - if (WorldGen.genRand.NextBool()) - zero.X = (double)WorldGen.genRand.Next(20, 50) * 0.01; - else - zero.X = (double)WorldGen.genRand.Next(20, 50) * 0.01; - } - } - else if (vector2D.X < (double)(Main.maxTilesX / 2) && vector2D.X > (double)Main.maxTilesX * 0.25) - { - num3 = -1; - zero2.Y = 0.0; - zero2.X = num3; - zero.Y = 0.0; - zero.X = num3; - if (WorldGen.genRand.Next(3) == 0) - { - if (WorldGen.genRand.NextBool()) - zero.Y = -0.2; - else - zero.Y = 0.2; - } - } - else if (vector2D.X > (double)(Main.maxTilesX / 2) && vector2D.X < (double)Main.maxTilesX * 0.75) - { - num3 = 1; - zero2.Y = 0.0; - zero2.X = num3; - zero.Y = 0.0; - zero.X = num3; - if (WorldGen.genRand.Next(3) == 0) - { - if (WorldGen.genRand.NextBool()) - zero.Y = -0.2; - else - zero.Y = 0.2; - } - } - } - - if (zero2.Y == 0.0) - { - GenVars.DDoorX[GenVars.numDDoors] = (int)vector2D.X; - GenVars.DDoorY[GenVars.numDDoors] = (int)vector2D.Y; - GenVars.DDoorPos[GenVars.numDDoors] = 0; - GenVars.numDDoors++; - } - else - { - GenVars.dungeonPlatformX[GenVars.numDungeonPlatforms] = (int)vector2D.X; - GenVars.dungeonPlatformY[GenVars.numDungeonPlatforms] = (int)vector2D.Y; - GenVars.numDungeonPlatforms++; - } - - GenVars.lastDungeonHall = zero2; - if (Math.Abs(zero.X) > Math.Abs(zero.Y) && WorldGen.genRand.Next(3) != 0) - num = (int)(num2 * ((double)WorldGen.genRand.Next(110, 150) * 0.01)); - - while (num4 > 0) - { - num9++; - if (zero2.X > 0.0 && vector2D.X > (double)(Main.maxTilesX - 100)) - num4 = 0; - else if (zero2.X < 0.0 && vector2D.X < 100.0) - num4 = 0; - else if (zero2.Y > 0.0 && vector2D.Y > (double)(Main.maxTilesY - 100)) - num4 = 0; - else if (WorldGen.remixWorldGen && zero2.Y < 0.0 && vector2D.Y < (Main.rockLayer + Main.worldSurface) / 2.0) - num4 = 0; - else if (!WorldGen.remixWorldGen && zero2.Y < 0.0 && vector2D.Y < Main.rockLayer + 50.0) - num4 = 0; - - num4--; - int num10 = (int)(vector2D.X - num - 4.0 - (double)WorldGen.genRand.Next(6)); - int num11 = (int)(vector2D.X + num + 4.0 + (double)WorldGen.genRand.Next(6)); - int num12 = (int)(vector2D.Y - num - 4.0 - (double)WorldGen.genRand.Next(6)); - int num13 = (int)(vector2D.Y + num + 4.0 + (double)WorldGen.genRand.Next(6)); - if (num10 < 0) - num10 = 0; - - if (num11 > Main.maxTilesX) - num11 = Main.maxTilesX; - - if (num12 < 0) - num12 = 0; - - if (num13 > Main.maxTilesY) - num13 = Main.maxTilesY; - - for (int m = num10; m < num11; m++) - { - for (int n = num12; n < num13; n++) - { - if (m < GenVars.dMinX) - GenVars.dMinX = m; - - if (m > GenVars.dMaxX) - GenVars.dMaxX = m; - - if (n > GenVars.dMaxY) - GenVars.dMaxY = n; - - Main.tile[m, n].LiquidAmount = 0; - if (!Main.wallDungeon[Main.tile[m, n].WallType]) - { - Main.tile[m, n].Get().HasTile = true; - Main.tile[m, n].TileType = tileType; - Main.tile[m, n].Clear(TileDataType.Slope); - } - } - } - - for (int num14 = num10 + 1; num14 < num11 - 1; num14++) - { - for (int num15 = num12 + 1; num15 < num13 - 1; num15++) - { - Main.tile[num14, num15].WallType = (ushort)wallType; - } - } - - int num16 = 0; - if (zero.Y == 0.0 && WorldGen.genRand.Next((int)num + 1) == 0) - num16 = WorldGen.genRand.Next(1, 3); - else if (zero.X == 0.0 && WorldGen.genRand.Next((int)num - 1) == 0) - num16 = WorldGen.genRand.Next(1, 3); - else if (WorldGen.genRand.Next((int)num * 3) == 0) - num16 = WorldGen.genRand.Next(1, 3); - - num10 = (int)(vector2D.X - num * 0.5 - (double)num16); - num11 = (int)(vector2D.X + num * 0.5 + (double)num16); - num12 = (int)(vector2D.Y - num * 0.5 - (double)num16); - num13 = (int)(vector2D.Y + num * 0.5 + (double)num16); - if (num10 < 0) - num10 = 0; - - if (num11 > Main.maxTilesX) - num11 = Main.maxTilesX; - - if (num12 < 0) - num12 = 0; - - if (num13 > Main.maxTilesY) - num13 = Main.maxTilesY; - - for (int num17 = num10; num17 < num11; num17++) - { - for (int num18 = num12; num18 < num13; num18++) - { - Main.tile[num17, num18].Clear(TileDataType.Slope); - if (flag) - { - if (Main.tile[num17, num18].HasTile || Main.tile[num17, num18].WallType != wallType) - { - Main.tile[num17, num18].Get().HasTile = true; - Main.tile[num17, num18].TileType = GenVars.crackedType; - } - } - else - { - Main.tile[num17, num18].Get().HasTile = false; - } - - Main.tile[num17, num18].Clear(TileDataType.Slope); - Main.tile[num17, num18].WallType = (ushort)wallType; - } - } - - vector2D += zero; - if (flag3 && num9 > WorldGen.genRand.Next(10, 20)) - { - num9 = 0; - zero.X *= -1.0; - } - } - - GenVars.dungeonX = (int)vector2D.X; - GenVars.dungeonY = (int)vector2D.Y; - if (zero2.Y == 0.0) - { - GenVars.DDoorX[GenVars.numDDoors] = (int)vector2D.X; - GenVars.DDoorY[GenVars.numDDoors] = (int)vector2D.Y; - GenVars.DDoorPos[GenVars.numDDoors] = 0; - GenVars.numDDoors++; - } - else - { - GenVars.dungeonPlatformX[GenVars.numDungeonPlatforms] = (int)vector2D.X; - GenVars.dungeonPlatformY[GenVars.numDungeonPlatforms] = (int)vector2D.Y; - GenVars.numDungeonPlatforms++; - } - } - } -} diff --git a/World/GiantHive.cs b/World/GiantHive.cs index 5584bbf17a..57adc27ea4 100644 --- a/World/GiantHive.cs +++ b/World/GiantHive.cs @@ -161,7 +161,7 @@ namespace CalamityMod.World if (ref2.Value / (float)ref1.Value < 0.75f || ref3.Value < 2) return false; - int num = 0; + int arrayInc = 0; int[] array = new int[1000]; int[] array2 = new int[1000]; Vector2 larvaLocation = origin.ToVector2(); @@ -169,32 +169,32 @@ namespace CalamityMod.World for (int i = 0; i < numHiveTunnels; i++) { - Vector2 vector2 = larvaLocation; - int num3 = WorldGen.genRand.Next(2, 5); - for (int j = 0; j < num3; j++) - vector2 = CreateHiveTunnel((int)larvaLocation.X, (int)larvaLocation.Y, WorldGen.genRand); + Vector2 movingLarvaLocation = larvaLocation; + int hiveTunnelTries = WorldGen.genRand.Next(2, 5); + for (int j = 0; j < hiveTunnelTries; j++) + movingLarvaLocation = CreateHiveTunnel((int)larvaLocation.X, (int)larvaLocation.Y, WorldGen.genRand); - larvaLocation = vector2; - array[num] = (int)larvaLocation.X; - array2[num] = (int)larvaLocation.Y; - num++; + larvaLocation = movingLarvaLocation; + array[arrayInc] = (int)larvaLocation.X; + array2[arrayInc] = (int)larvaLocation.Y; + arrayInc++; } FrameOutAllHiveContents(origin, 50); - for (int k = 0; k < num; k++) + for (int k = 0; k < arrayInc; k++) { - int num4 = array[k]; + int x = array[k]; int y = array2[k]; - int num5 = 1; + int treeIndentDirection = 1; if (WorldGen.genRand.NextBool()) - num5 = -1; + treeIndentDirection = -1; bool flag = false; - while (WorldGen.InWorld(num4, y, 10) && BadSpotForHoneyFall(num4, y)) + while (WorldGen.InWorld(x, y, 10) && BadSpotForHoneyFall(x, y)) { - num4 += num5; - if (Math.Abs(num4 - array[k]) > 50) + x += treeIndentDirection; + if (Math.Abs(x - array[k]) > 50) { flag = true; break; @@ -203,11 +203,11 @@ namespace CalamityMod.World if (!flag) { - num4 += num5; - if (!SpotActuallyNotInHive(num4, y)) + x += treeIndentDirection; + if (!SpotActuallyNotInHive(x, y)) { - CreateBlockedHoneyCube(num4, y); - CreateDentForHoneyFall(num4, y, num5); + CreateBlockedHoneyCube(x, y); + CreateDentForHoneyFall(x, y, treeIndentDirection); } } } @@ -221,13 +221,13 @@ namespace CalamityMod.World int maxAttempts = 1000; for (int l = 0; l < maxAttempts; l++) { - Vector2 vector3 = larvaLocation; - vector3.X += WorldGen.genRand.Next(-50, 51); - vector3.Y += WorldGen.genRand.Next(-50, 51); - if (WorldGen.InWorld((int)vector3.X, (int)vector3.Y) && Vector2.Distance(larvaLocation, vector3) > 10f && !Main.tile[(int)vector3.X, (int)vector3.Y].HasTile && Main.tile[(int)vector3.X, (int)vector3.Y].WallType == WallID.HiveUnsafe) + Vector2 newStructureLocation = larvaLocation; + newStructureLocation.X += WorldGen.genRand.Next(-50, 51); + newStructureLocation.Y += WorldGen.genRand.Next(-50, 51); + if (WorldGen.InWorld((int)newStructureLocation.X, (int)newStructureLocation.Y) && Vector2.Distance(larvaLocation, newStructureLocation) > 10f && !Main.tile[(int)newStructureLocation.X, (int)newStructureLocation.Y].HasTile && Main.tile[(int)newStructureLocation.X, (int)newStructureLocation.Y].WallType == WallID.HiveUnsafe) { - secondLarvaLocation = vector3; - CreateStandForLarva(vector3); + secondLarvaLocation = newStructureLocation; + CreateStandForLarva(newStructureLocation); break; } } @@ -236,24 +236,24 @@ namespace CalamityMod.World Vector2 honeyChestLocation = default; for (int l = 0; l < maxAttempts; l++) { - Vector2 vector3 = larvaLocation; - vector3.X += WorldGen.genRand.Next(-100, 101); - vector3.Y += WorldGen.genRand.Next(-100, 101); - if (WorldGen.InWorld((int)vector3.X, (int)vector3.Y) && Vector2.Distance(larvaLocation, vector3) > 10f && Vector2.Distance(secondLarvaLocation, vector3) > 10f && !Main.tile[(int)vector3.X, (int)vector3.Y].HasTile && Main.tile[(int)vector3.X, (int)vector3.Y].WallType == WallID.HiveUnsafe) + Vector2 newStructureLocation = larvaLocation; + newStructureLocation.X += WorldGen.genRand.Next(-100, 101); + newStructureLocation.Y += WorldGen.genRand.Next(-100, 101); + if (WorldGen.InWorld((int)newStructureLocation.X, (int)newStructureLocation.Y) && Vector2.Distance(larvaLocation, newStructureLocation) > 10f && Vector2.Distance(secondLarvaLocation, newStructureLocation) > 10f && !Main.tile[(int)newStructureLocation.X, (int)newStructureLocation.Y].HasTile && Main.tile[(int)newStructureLocation.X, (int)newStructureLocation.Y].WallType == WallID.HiveUnsafe) { - honeyChestLocation = vector3; - CreateStandAndPlaceHoneyChest(vector3); + honeyChestLocation = newStructureLocation; + CreateStandAndPlaceHoneyChest(newStructureLocation); break; } } for (int l = 0; l < maxAttempts; l++) { - Vector2 vector3 = larvaLocation; - vector3.X += WorldGen.genRand.Next(-100, 101); - vector3.Y += WorldGen.genRand.Next(-100, 101); - if (WorldGen.InWorld((int)vector3.X, (int)vector3.Y) && Vector2.Distance(larvaLocation, vector3) > 10f && Vector2.Distance(secondLarvaLocation, vector3) > 10f && Vector2.Distance(honeyChestLocation, vector3) > 10f && !Main.tile[(int)vector3.X, (int)vector3.Y].HasTile && Main.tile[(int)vector3.X, (int)vector3.Y].WallType == WallID.HiveUnsafe) + Vector2 newStructureLocation = larvaLocation; + newStructureLocation.X += WorldGen.genRand.Next(-100, 101); + newStructureLocation.Y += WorldGen.genRand.Next(-100, 101); + if (WorldGen.InWorld((int)newStructureLocation.X, (int)newStructureLocation.Y) && Vector2.Distance(larvaLocation, newStructureLocation) > 10f && Vector2.Distance(secondLarvaLocation, newStructureLocation) > 10f && Vector2.Distance(honeyChestLocation, newStructureLocation) > 10f && !Main.tile[(int)newStructureLocation.X, (int)newStructureLocation.Y].HasTile && Main.tile[(int)newStructureLocation.X, (int)newStructureLocation.Y].WallType == WallID.HiveUnsafe) { - CreateStandAndPlaceHoneyChest(vector3); + CreateStandAndPlaceHoneyChest(newStructureLocation); break; } } @@ -264,13 +264,13 @@ namespace CalamityMod.World private static void FrameOutAllHiveContents(Point origin, int squareHalfWidth) { - int num = Math.Max(10, origin.X - squareHalfWidth); - int num2 = Math.Min(Main.maxTilesX - 10, origin.X + squareHalfWidth); - int num3 = Math.Max(10, origin.Y - squareHalfWidth); - int num4 = Math.Min(Main.maxTilesY - 10, origin.Y + squareHalfWidth); - for (int i = num; i < num2; i++) + int maxXsize = Math.Max(10, origin.X - squareHalfWidth); + int minXsize = Math.Min(Main.maxTilesX - 10, origin.X + squareHalfWidth); + int maxYSize = Math.Max(10, origin.Y - squareHalfWidth); + int minYSize = Math.Min(Main.maxTilesY - 10, origin.Y + squareHalfWidth); + for (int i = maxXsize; i < minXsize; i++) { - for (int j = num3; j < num4; j++) + for (int j = maxYSize; j < minYSize; j++) { Tile tile = Main.tile[i, j]; if (tile.HasTile && tile.TileType == TileID.Hive) @@ -284,73 +284,73 @@ namespace CalamityMod.World private static Vector2 CreateHiveTunnel(int i, int j, UnifiedRandom random) { - double num = random.Next(20, 26); - float num2 = random.Next(30, 41); - float num3 = Main.maxTilesX / 4200; - num3 = (num3 + 1f) / 2f; - num *= (double)num3; - num2 *= num3; + double randOffset = random.Next(20, 26); + float tunnelPlacementAttempts = random.Next(30, 41); + float miniMaxXTiles = Main.maxTilesX / 4200; + miniMaxXTiles = (miniMaxXTiles + 1f) / 2f; + randOffset *= (double)miniMaxXTiles; + tunnelPlacementAttempts *= miniMaxXTiles; - double num4 = num; + double randOffsetCopy = randOffset; Vector2 result = default; result.X = i; result.Y = j; - Vector2 vector = default; - vector.X = random.Next(-10, 11) * 0.2f; - vector.Y = random.Next(-10, 11) * 0.2f; - while (num > 0.0 && num2 > 0f) + Vector2 defaultTunnelPos = default; + defaultTunnelPos.X = random.Next(-10, 11) * 0.2f; + defaultTunnelPos.Y = random.Next(-10, 11) * 0.2f; + while (randOffset > 0.0 && tunnelPlacementAttempts > 0f) { if (result.Y > (Main.maxTilesY - 250)) - num2 = 0f; + tunnelPlacementAttempts = 0f; - num = num4 * (double)(1f + random.Next(-20, 20) * 0.01f); - num2 -= 1f; - int num5 = (int)(result.X - num); - int num6 = (int)(result.X + num); - int num7 = (int)(result.Y - num); - int num8 = (int)(result.Y + num); - if (num5 < 1) - num5 = 1; + randOffset = randOffsetCopy * (double)(1f + random.Next(-20, 20) * 0.01f); + tunnelPlacementAttempts -= 1f; + int mainXOffset = (int)(result.X - randOffset); + int maxXOffset = (int)(result.X + randOffset); + int minYOffset = (int)(result.Y - randOffset); + int maxYOffset = (int)(result.Y + randOffset); + if (mainXOffset < 1) + mainXOffset = 1; - if (num6 > Main.maxTilesX - 1) - num6 = Main.maxTilesX - 1; + if (maxXOffset > Main.maxTilesX - 1) + maxXOffset = Main.maxTilesX - 1; - if (num7 < 1) - num7 = 1; + if (minYOffset < 1) + minYOffset = 1; - if (num8 > Main.maxTilesY - 1) - num8 = Main.maxTilesY - 1; + if (maxYOffset > Main.maxTilesY - 1) + maxYOffset = Main.maxTilesY - 1; - for (int k = num5; k < num6; k++) + for (int k = mainXOffset; k < maxXOffset; k++) { - for (int l = num7; l < num8; l++) + for (int l = minYOffset; l < maxYOffset; l++) { if (!WorldGen.InWorld(k, l, 50)) { - num2 = 0f; + tunnelPlacementAttempts = 0f; } else { if (Main.tile[k - 10, l].WallType == WallID.LihzahrdBrickUnsafe) - num2 = 0f; + tunnelPlacementAttempts = 0f; if (Main.tile[k + 10, l].WallType == WallID.LihzahrdBrickUnsafe) - num2 = 0f; + tunnelPlacementAttempts = 0f; if (Main.tile[k, l - 10].WallType == WallID.LihzahrdBrickUnsafe) - num2 = 0f; + tunnelPlacementAttempts = 0f; if (Main.tile[k, l + 10].WallType == WallID.LihzahrdBrickUnsafe) - num2 = 0f; + tunnelPlacementAttempts = 0f; } if (l < Main.worldSurface && Main.tile[k, l - 5].WallType == WallID.None) - num2 = 0f; + tunnelPlacementAttempts = 0f; - float num9 = Math.Abs(k - result.X); - float num10 = Math.Abs(l - result.Y); - double num11 = Math.Sqrt(num9 * num9 + num10 * num10); - if (num11 < num4 * 0.4 * (1.0 + random.Next(-10, 11) * 0.005)) + float tileXDist = Math.Abs(k - result.X); + float tileYDist = Math.Abs(l - result.Y); + double tileDistance = Math.Sqrt(tileXDist * tileXDist + tileYDist * tileYDist); + if (tileDistance < randOffsetCopy * 0.4 * (1.0 + random.Next(-10, 11) * 0.005)) { Main.tile[k, l].LiquidAmount = byte.MaxValue; Main.tile[k, l].Get().LiquidType = LiquidID.Honey; @@ -359,7 +359,7 @@ namespace CalamityMod.World Main.tile[k, l].Get().IsHalfBlock = false; Main.tile[k, l].Get().Slope = SlopeType.Solid; } - else if (num11 < num4 * 0.75 * (1.0 + random.Next(-10, 11) * 0.005)) + else if (tileDistance < randOffsetCopy * 0.75 * (1.0 + random.Next(-10, 11) * 0.005)) { Main.tile[k, l].LiquidAmount = 0; if (Main.tile[k, l].WallType != WallID.HiveUnsafe) @@ -371,7 +371,7 @@ namespace CalamityMod.World } } - if (num11 < num4 * 0.6 * (1.0 + random.Next(-10, 11) * 0.005)) + if (tileDistance < randOffsetCopy * 0.6 * (1.0 + random.Next(-10, 11) * 0.005)) { Main.tile[k, l].WallType = WallID.HiveUnsafe; if (random.NextBool()) @@ -383,10 +383,10 @@ namespace CalamityMod.World } } - result += vector; - num2 -= 1f; - vector.Y += random.Next(-10, 11) * 0.05f; - vector.X += random.Next(-10, 11) * 0.05f; + result += defaultTunnelPos; + tunnelPlacementAttempts -= 1f; + defaultTunnelPos.Y += random.Next(-10, 11) * 0.05f; + defaultTunnelPos.X += random.Next(-10, 11) * 0.05f; } return result; @@ -396,13 +396,13 @@ namespace CalamityMod.World { int x = origin.X; int y = origin.Y; - int num = 150; - for (int i = x - num; i < x + num; i += 10) + int checkRadius = 150; + for (int i = x - checkRadius; i < x + checkRadius; i += 10) { if (i <= 0 || i > Main.maxTilesX - 1) continue; - for (int j = y - num; j < y + num; j += 10) + for (int j = y - checkRadius; j < y + checkRadius; j += 10) { if (j > 0 && j <= Main.maxTilesY - 1) { @@ -411,6 +411,8 @@ namespace CalamityMod.World if (Main.tile[i, j].WallType == WallID.CrimstoneUnsafe || Main.tile[i, j].WallType == WallID.EbonstoneUnsafe || Main.tile[i, j].WallType == WallID.LihzahrdBrickUnsafe) return true; + if (Main.tile[i,j].LiquidAmount != 0 && Main.tile[i, j].LiquidType == LiquidID.Shimmer) + return true; } } } @@ -422,10 +424,10 @@ namespace CalamityMod.World { dir *= -1; y++; - int num = 0; - while ((num < 4 || WorldGen.SolidTile(x, y)) && x > 10 && x < Main.maxTilesX - 10) + int honeyDentTries = 0; + while ((honeyDentTries < 4 || WorldGen.SolidTile(x, y)) && x > 10 && x < Main.maxTilesX - 10) { - num++; + honeyDentTries++; x += dir; if (WorldGen.SolidTile(x, y)) { @@ -493,13 +495,13 @@ namespace CalamityMod.World if (GenVars.numLarva >= GenVars.larvaX.Length) GenVars.numLarva = GenVars.larvaX.Length - 1; - int num = (int)position.X; - int num2 = (int)position.Y; - for (int i = num - 1; i <= num + 1 && i > 0 && i < Main.maxTilesX; i++) + int larvaX = (int)position.X; + int larvaY = (int)position.Y; + for (int i = larvaX - 1; i <= larvaX + 1 && i > 0 && i < Main.maxTilesX; i++) { - for (int j = num2 - 2; j <= num2 + 1 && j > 0 && j < Main.maxTilesY; j++) + for (int j = larvaY - 2; j <= larvaY + 1 && j > 0 && j < Main.maxTilesY; j++) { - if (j != num2 + 1) + if (j != larvaY + 1) { Main.tile[i, j].Get().HasTile = false; continue; @@ -518,13 +520,13 @@ namespace CalamityMod.World int chestPlacementX = Utils.Clamp((int)position.X, 5, Main.maxTilesX - 5); int chestPlacementY = Utils.Clamp((int)position.Y, 5, Main.maxTilesY - 5); - int num = (int)position.X; - int num2 = (int)position.Y; - for (int i = num; i <= num + 1 && i > 0 && i < Main.maxTilesX; i++) + int chestX = (int)position.X; + int chestY = (int)position.Y; + for (int i = chestX; i <= chestX + 1 && i > 0 && i < Main.maxTilesX; i++) { - for (int j = num2 - 1; j <= num2 + 1 && j > 0 && j < Main.maxTilesY; j++) + for (int j = chestY - 1; j <= chestY + 1 && j > 0 && j < Main.maxTilesY; j++) { - if (j != num2 + 1) + if (j != chestY + 1) { Main.tile[i, j].Get().HasTile = false; continue; @@ -537,27 +539,27 @@ namespace CalamityMod.World } } - int num144 = chestPlacementX; - int num145 = chestPlacementY; - for (int num146 = num144; num146 <= num144 + 1; num146++) + int finalChestX = chestPlacementX; + int finalChestY = chestPlacementY; + for (int i = finalChestX; i <= finalChestX + 1; i++) { - for (int num147 = num145 - 1; num147 <= num145 + 1; num147++) + for (int j = finalChestY - 1; j <= finalChestY + 1; j++) { - if (num147 != num145 + 1) + if (j != finalChestY + 1) { - Main.tile[num146, num147].Get().HasTile = false; + Main.tile[i, j].Get().HasTile = false; } else { - Main.tile[num146, num147].Get().HasTile = true; - Main.tile[num146, num147].TileType = TileID.Hive; - Main.tile[num146, num147].Get().Slope = SlopeType.Solid; - Main.tile[num146, num147].Get().IsHalfBlock = false; + Main.tile[i, j].Get().HasTile = true; + Main.tile[i, j].TileType = TileID.Hive; + Main.tile[i, j].Get().Slope = SlopeType.Solid; + Main.tile[i, j].Get().IsHalfBlock = false; } } } - int chestID = WorldGen.PlaceChest(num144, num145, 21, false, 29); + int chestID = WorldGen.PlaceChest(finalChestX, finalChestY, 21, false, 29); FillHoneyChest(chestID, WorldGen.genRand); } diff --git a/World/MechanicShed.cs b/World/MechanicShed.cs index c94c2e9f7d..3a8cd8b149 100644 --- a/World/MechanicShed.cs +++ b/World/MechanicShed.cs @@ -18,7 +18,7 @@ namespace CalamityMod.World var schematic = TileMaps[mapKey]; int placementPositionX = WorldGen.genRand.Next(GenVars.snowOriginLeft + 100, GenVars.snowOriginRight - 100); - int placementPositionY = (int)Main.worldSurface - (Main.maxTilesY / 8); + int placementPositionY = (int)Main.worldSurface - (Main.maxTilesY / 6); bool foundValidGround = false; int attempts = 0; diff --git a/World/MiscWorldgenRoutines.cs b/World/MiscWorldgenRoutines.cs index 3c80021f2b..eba1b6ab7e 100644 --- a/World/MiscWorldgenRoutines.cs +++ b/World/MiscWorldgenRoutines.cs @@ -181,7 +181,7 @@ namespace CalamityMod.World #region Chasm Generator public static void ChasmGenerator(int i, int j, int steps, bool ocean = false) { - float num = steps; //850 small 1450 medium 2050 large + float maxChasmSize = steps; //850 small 1450 medium 2050 large int limitIncrease = Main.remixWorld ? 110 : 0; if (ocean) { @@ -202,20 +202,20 @@ namespace CalamityMod.World } j = tileYLookup; } - Vector2 vector; - vector.X = i; - vector.Y = j; - Vector2 vector2; - vector2.X = WorldGen.genRand.Next(-1, 2) * 0.1f; - vector2.Y = WorldGen.genRand.Next(3, 8) * 0.2f + 0.5f; - int num2 = 5; - double num3 = WorldGen.genRand.Next(5, 7) + 20; //start width - while (num3 > 0.0) + Vector2 chasmGenPosition; + chasmGenPosition.X = i; + chasmGenPosition.Y = j; + Vector2 randChasmGenOffset; + randChasmGenOffset.X = WorldGen.genRand.Next(-1, 2) * 0.1f; + randChasmGenOffset.Y = WorldGen.genRand.Next(3, 8) * 0.2f + 0.5f; + int five = 5; + double chasmWidth = WorldGen.genRand.Next(5, 7) + 20; //start width + while (chasmWidth > 0.0) { - if (num > 0f) + if (maxChasmSize > 0f) { - num3 += WorldGen.genRand.Next(10); - num3 -= WorldGen.genRand.Next(10); + chasmWidth += WorldGen.genRand.Next(10); + chasmWidth -= WorldGen.genRand.Next(10); float smallHoleLimit = 790f; //small if (Main.maxTilesY > 1500) @@ -228,97 +228,97 @@ namespace CalamityMod.World } } - if (ocean && num > smallHoleLimit) + if (ocean && maxChasmSize > smallHoleLimit) { - if (num3 < 7.0) //min width + if (chasmWidth < 7.0) //min width { - num3 = 7.0; //min width + chasmWidth = 7.0; //min width } - if (num3 > 45.0) //max width + if (chasmWidth > 45.0) //max width { - num3 = 45.0; //max width + chasmWidth = 45.0; //max width } } else //dig large hole { - if (num3 < (ocean ? 30.0 : 8.0)) //min width + if (chasmWidth < (ocean ? 30.0 : 8.0)) //min width { - num3 = ocean ? 30.0 : 8.0; //min width + chasmWidth = ocean ? 30.0 : 8.0; //min width } - if (num3 > (ocean ? 70.0 : 20.0)) //max width + if (chasmWidth > (ocean ? 70.0 : 20.0)) //max width { - num3 = ocean ? 70.0 : 20.0; //max width + chasmWidth = ocean ? 70.0 : 20.0; //max width } - if (num == 1f && num3 < (ocean ? 50.0 : 15.0)) + if (maxChasmSize == 1f && chasmWidth < (ocean ? 50.0 : 15.0)) { - num3 = ocean ? 50.0 : 15.0; + chasmWidth = ocean ? 50.0 : 15.0; } } } else { - if ((double)vector.Y > (Abyss.AbyssChasmBottom + limitIncrease)) + if ((double)chasmGenPosition.Y > (Abyss.AbyssChasmBottom + limitIncrease)) { - num3 -= WorldGen.genRand.Next(5) + 8; + chasmWidth -= WorldGen.genRand.Next(5) + 8; } } if (Main.maxTilesY > 2100) { - if (((double)vector.Y > (Abyss.AbyssChasmBottom + limitIncrease) && num > 0f && ocean) || - (vector.Y >= Main.maxTilesY && num > 0f && !ocean)) + if (((double)chasmGenPosition.Y > (Abyss.AbyssChasmBottom + limitIncrease) && maxChasmSize > 0f && ocean) || + (chasmGenPosition.Y >= Main.maxTilesY && maxChasmSize > 0f && !ocean)) { - num = 0f; + maxChasmSize = 0f; } } else if (Main.maxTilesY > 1500) { - if (((double)vector.Y > (Abyss.AbyssChasmBottom + limitIncrease) && num > 0f && ocean) || - (vector.Y > Main.maxTilesY && num > 0f && !ocean)) + if (((double)chasmGenPosition.Y > (Abyss.AbyssChasmBottom + limitIncrease) && maxChasmSize > 0f && ocean) || + (chasmGenPosition.Y > Main.maxTilesY && maxChasmSize > 0f && !ocean)) { - num = 0f; + maxChasmSize = 0f; } } else { - if (((double)vector.Y > (Abyss.AbyssChasmBottom + limitIncrease) && num > 0f && ocean) || - (vector.Y > Main.maxTilesY && num > 0f && !ocean)) + if (((double)chasmGenPosition.Y > (Abyss.AbyssChasmBottom + limitIncrease) && maxChasmSize > 0f && ocean) || + (chasmGenPosition.Y > Main.maxTilesY && maxChasmSize > 0f && !ocean)) { - num = 0f; + maxChasmSize = 0f; } } - num -= 1f; - int num4; - int num5; - int num6; - int num7; - if (num > num2) + maxChasmSize -= 1f; + int chasmWidthMin; + int chasmWidthMax; + int chasmHeightMin; + int chasmHeightMax; + if (maxChasmSize > five) { - num4 = (int)(vector.X - num3 * 0.5); - num5 = (int)(vector.X + num3 * 0.5); - num6 = (int)(vector.Y - num3 * 0.5); - num7 = (int)(vector.Y + num3 * 0.5); - if (num4 < 0) + chasmWidthMin = (int)(chasmGenPosition.X - chasmWidth * 0.5); + chasmWidthMax = (int)(chasmGenPosition.X + chasmWidth * 0.5); + chasmHeightMin = (int)(chasmGenPosition.Y - chasmWidth * 0.5); + chasmHeightMax = (int)(chasmGenPosition.Y + chasmWidth * 0.5); + if (chasmWidthMin < 0) { - num4 = 0; + chasmWidthMin = 0; } - if (num5 > Main.maxTilesX - 1) + if (chasmWidthMax > Main.maxTilesX - 1) { - num5 = Main.maxTilesX - 1; + chasmWidthMax = Main.maxTilesX - 1; } - if (num6 < 0) + if (chasmHeightMin < 0) { - num6 = 0; + chasmHeightMin = 0; } - if (num7 > Main.maxTilesY) + if (chasmHeightMax > Main.maxTilesY) { - num7 = Main.maxTilesY; + chasmHeightMax = Main.maxTilesY; } - for (int k = num4; k < num5; k++) + for (int k = chasmWidthMin; k < chasmWidthMax; k++) { - for (int l = num6; l < num7; l++) + for (int l = chasmHeightMin; l < chasmHeightMax; l++) { - if ((Math.Abs(k - vector.X) + Math.Abs(l - vector.Y)) < num3 * 0.5 * (1.0 + WorldGen.genRand.Next(-5, 6) * 0.015)) + if ((Math.Abs(k - chasmGenPosition.X) + Math.Abs(l - chasmGenPosition.Y)) < chasmWidth * 0.5 * (1.0 + WorldGen.genRand.Next(-5, 6) * 0.015)) { if (ocean) { @@ -336,51 +336,51 @@ namespace CalamityMod.World } } } - /*if (num <= 2f && vector.Y < (Main.rockLayer + Main.maxTilesY * 0.3)) + /*if (maxChasmSize <= 2f && chasmGenPosition.Y < (Main.rockLayer + Main.maxTilesY * 0.3)) { - num = 2f; + maxChasmSize = 2f; }*/ - vector += vector2; - vector2.X += WorldGen.genRand.Next(-1, 2) * 0.01f; - if (vector2.X > 0.02) + chasmGenPosition += randChasmGenOffset; + randChasmGenOffset.X += WorldGen.genRand.Next(-1, 2) * 0.01f; + if (randChasmGenOffset.X > 0.02) { - vector2.X = 0.02f; + randChasmGenOffset.X = 0.02f; } - if (vector2.X < -0.02) + if (randChasmGenOffset.X < -0.02) { - vector2.X = -0.02f; + randChasmGenOffset.X = -0.02f; } - num4 = (int)(vector.X - num3 * 1.1); - num5 = (int)(vector.X + num3 * 1.1); - num6 = (int)(vector.Y - num3 * 1.1); - num7 = (int)(vector.Y + num3 * 1.1); - if (num4 < 1) + chasmWidthMin = (int)(chasmGenPosition.X - chasmWidth * 1.1); + chasmWidthMax = (int)(chasmGenPosition.X + chasmWidth * 1.1); + chasmHeightMin = (int)(chasmGenPosition.Y - chasmWidth * 1.1); + chasmHeightMax = (int)(chasmGenPosition.Y + chasmWidth * 1.1); + if (chasmWidthMin < 1) { - num4 = 1; + chasmWidthMin = 1; } - if (num5 > Main.maxTilesX - 1) + if (chasmWidthMax > Main.maxTilesX - 1) { - num5 = Main.maxTilesX - 1; + chasmWidthMax = Main.maxTilesX - 1; } - if (num6 < 0) + if (chasmHeightMin < 0) { - num6 = 0; + chasmHeightMin = 0; } - if (num7 > Main.maxTilesY) + if (chasmHeightMax > Main.maxTilesY) { - num7 = Main.maxTilesY; + chasmHeightMax = Main.maxTilesY; } - for (int m = num4; m < num5; m++) + for (int m = chasmWidthMin; m < chasmWidthMax; m++) { - for (int n = num6; n < num7; n++) + for (int n = chasmHeightMin; n < chasmHeightMax; n++) { - if ((Math.Abs(m - vector.X) + Math.Abs(n - vector.Y)) < num3 * 1.1 * (1.0 + WorldGen.genRand.Next(-5, 6) * 0.015)) + if ((Math.Abs(m - chasmGenPosition.X) + Math.Abs(n - chasmGenPosition.Y)) < chasmWidth * 1.1 * (1.0 + WorldGen.genRand.Next(-5, 6) * 0.015)) { if (n > j + WorldGen.genRand.Next(7, 16)) { Main.tile[m, n].Get().HasTile = false; } - if (steps <= num2) + if (steps <= five) { Main.tile[m, n].Get().HasTile = false; } @@ -397,25 +397,25 @@ namespace CalamityMod.World } } } - for (int num11 = num4; num11 < num5; num11++) + for (int r = chasmWidthMin; r < chasmWidthMax; r++) { - for (int num12 = num6; num12 < num7; num12++) + for (int s = chasmHeightMin; s < chasmHeightMax; s++) { - if ((Math.Abs(num11 - vector.X) + Math.Abs(num12 - vector.Y)) < num3 * 1.1 * (1.0 + WorldGen.genRand.Next(-5, 6) * 0.015)) + if ((Math.Abs(r - chasmGenPosition.X) + Math.Abs(s - chasmGenPosition.Y)) < chasmWidth * 1.1 * (1.0 + WorldGen.genRand.Next(-5, 6) * 0.015)) { if (ocean) { - Main.tile[num11, num12].LiquidAmount = 255; - Main.tile[num11, num12].Get().LiquidType = LiquidID.Water; + Main.tile[r, s].LiquidAmount = 255; + Main.tile[r, s].Get().LiquidType = LiquidID.Water; } else { - Main.tile[num11, num12].LiquidAmount = 255; - Main.tile[num11, num12].Get().LiquidType = LiquidID.Lava; + Main.tile[r, s].LiquidAmount = 255; + Main.tile[r, s].Get().LiquidType = LiquidID.Lava; } - if (steps <= num2) + if (steps <= five) { - Main.tile[num11, num12].Get().HasTile = false; + Main.tile[r, s].Get().HasTile = false; } } } diff --git a/World/Planets/LuminitePlanet.cs b/World/Planets/LuminitePlanet.cs index 5a57634236..41ab36fe85 100644 --- a/World/Planets/LuminitePlanet.cs +++ b/World/Planets/LuminitePlanet.cs @@ -22,12 +22,12 @@ namespace CalamityMod.World.Planets GenVars.structures = new StructureMap(); var config = WorldGenConfiguration.FromEmbeddedPath("Terraria.GameContent.WorldBuilding.Configuration.json"); - int totalPlanetoidsToGenerate = Main.maxTilesX / 1500 + 2; + int totalPlanetoidsToGenerate = Main.maxTilesX / 1200 + 2; for (int i = 0; i < totalPlanetoidsToGenerate; i++) { - for (int tries = 0; tries < 6000; tries++) + for (int tries = 0; tries < 15000; tries++) { - Point planetoidOrigin = new Point(WorldGen.genRand.Next(Main.maxTilesX / 2 - 800, Main.maxTilesX / 2 + 800), WorldGen.genRand.Next(75, 125)); + Point planetoidOrigin = new Point(WorldGen.genRand.Next((int)(Main.maxTilesX*0.15), (int)(Main.maxTilesX*0.85)), WorldGen.genRand.Next(75, 125)); if (WorldGen.genRand.NextBool(2)) { if (config.CreateBiome().Place(planetoidOrigin, GenVars.structures)) @@ -44,7 +44,7 @@ namespace CalamityMod.World.Planets public override bool Place(Point origin, StructureMap structures) { - int radius = _random.Next(16, 21); + int radius = _random.Next(14, 18); if (!CheckIfPlaceable(origin, radius, structures)) return false; diff --git a/World/Planets/Planetoid.cs b/World/Planets/Planetoid.cs index d492cf7d09..5e48fd729d 100644 --- a/World/Planets/Planetoid.cs +++ b/World/Planets/Planetoid.cs @@ -36,7 +36,7 @@ namespace CalamityMod.World.Planets i = 0; while (LCPlanetoidCount > 0 && i < CrystalHeartPlanetoidAttempts) { - int x = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.2), (int)(Main.maxTilesX * 0.8)); + int x = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.15), (int)(Main.maxTilesX * 0.85)); int y = WorldGen.genRand.Next(70, 101); bool placed = config2.CreateBiome().Place(new Point(x, y), GenVars.structures); @@ -50,7 +50,7 @@ namespace CalamityMod.World.Planets i = 0; while (GrassPlanetoidCount > 0 && i < GrassPlanetoidAttempts) { - int x = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.333), (int)(Main.maxTilesX * 0.666)); + int x = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.25), (int)(Main.maxTilesX * 0.75)); int y = WorldGen.genRand.Next(100, 131); @@ -65,7 +65,7 @@ namespace CalamityMod.World.Planets i = 0; while (MudPlanetoidCount > 0 && i < MudPlanetoidAttempts) { - int x = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.3f), (int)(Main.maxTilesX * 0.7f)); + int x = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.25f), (int)(Main.maxTilesX * 0.75f)); int y = WorldGen.genRand.Next(100, 131); bool placed = config2.CreateBiome().Place(new Point(x, y), GenVars.structures); @@ -124,7 +124,7 @@ namespace CalamityMod.World.Planets public bool CheckIfPlaceable(Point origin, int radius, StructureMap structures) { //Fluff is used to create padding between the planets. this is the minimum distance between planets (they can't be within "fluff" blocks) - int fluff = 10; + int fluff = 12; int myRadius = radius + fluff; int diameter = myRadius * 2; _area = new Rectangle(origin.X - myRadius, origin.Y - myRadius, diameter, diameter); diff --git a/World/SunkenSea.cs b/World/SunkenSea.cs index 9c7e747a2e..462f2e3021 100644 --- a/World/SunkenSea.cs +++ b/World/SunkenSea.cs @@ -67,13 +67,13 @@ namespace CalamityMod.World private void AttemptClaim(int x, int y, int[,] clusterIndexMap, List> pointClusters, int index) //Attempts to create a cluster { - int num = clusterIndexMap[x, y]; - if (num != -1 && num != index) + int clusterPos = clusterIndexMap[x, y]; + if (clusterPos != -1 && clusterPos != index) { - int num2 = (WorldGen.genRand.Next(2) == 0) ? -1 : index; - foreach (Point current in pointClusters[num]) + int clusterHeight = (WorldGen.genRand.Next(2) == 0) ? -1 : index; + foreach (Point current in pointClusters[clusterPos]) { - clusterIndexMap[current.X, current.Y] = num2; + clusterIndexMap[current.X, current.Y] = clusterHeight; } } } @@ -84,14 +84,14 @@ namespace CalamityMod.World Height = height; Clear(); bool[,] array = new bool[width, height]; - int num = (width >> 1) - 1; - int num2 = (height >> 1) - 1; - int num3 = (num + 1) * (num + 1); - Point point = new Point(num, num2); - for (int i = point.Y - num2; i <= point.Y + num2; i++) + int clusterPos = (width >> 1) - 1; + int clusterHeight = (height >> 1) - 1; + int clusterSize = (clusterPos + 1) * (clusterPos + 1); + Point point = new Point(clusterPos, clusterHeight); + for (int i = point.Y - clusterHeight; i <= point.Y + clusterHeight; i++) { - float num4 = (float)num / (float)num2 * (float)(i - point.Y); - int num5 = Math.Min(num, (int)Math.Sqrt((float)num3 - num4 * num4)); + float num4 = (float)clusterPos / (float)clusterHeight * (float)(i - point.Y); + int num5 = Math.Min(clusterPos, (int)Math.Sqrt((float)clusterSize - num4 * num4)); for (int j = point.X - num5; j <= point.X + num5; j++) { array[j, i] = WorldGen.genRand.Next(2) == 0; @@ -210,7 +210,7 @@ namespace CalamityMod.World for (int j = -20; j < totalHeight + 20; j++) { float num3 = 0f; - int num4 = -1; + int clusterAmt = -1; float num5 = 0f; int num6 = i + start.X; int num7 = j + start.Y; @@ -233,7 +233,7 @@ namespace CalamityMod.World num5 = num3; } num3 = num9; - num4 = k; + clusterAmt = k; } else if (num9 > num5) { @@ -248,7 +248,7 @@ namespace CalamityMod.World { tile.ClearEverything(); tile.LiquidAmount = 192; - if (num4 % 5 == 2) + if (clusterAmt % 5 == 2) { tile.ResetToType((ushort)ModContent.TileType()); tile.Get().HasTile = true; diff --git a/World/WorldEvilIsland.cs b/World/WorldEvilIsland.cs index ded2e8ddc2..0c7d961f67 100644 --- a/World/WorldEvilIsland.cs +++ b/World/WorldEvilIsland.cs @@ -283,14 +283,14 @@ namespace CalamityMod.World ushort type = (ushort)(genCorruptHouse ? 152 : 347); //tile byte wall = (byte)(genCorruptHouse ? 35 : 174); //wall Vector2 vector = new Vector2((float)i, (float)j); - int num = 1; + int houseDirection = 1; if (WorldGen.genRand.Next(2) == 0) { - num = -1; + houseDirection = -1; } - int num2 = WorldGen.genRand.Next(7, 12); - int num3 = WorldGen.genRand.Next(5, 7); - vector.X = (float)(i + (num2 + 2) * num); + int largerRandValue = WorldGen.genRand.Next(7, 12); + int smallerRandValue = WorldGen.genRand.Next(5, 7); + vector.X = (float)(i + (largerRandValue + 2) * houseDirection); for (int k = j - 15; k < j + 30; k++) { if (Main.tile[(int)vector.X, k].HasTile) @@ -300,31 +300,31 @@ namespace CalamityMod.World } } vector.X = (float)i; - int num4 = (int)(vector.X - (float)num2 - 1f); - int num5 = (int)(vector.X + (float)num2 + 1f); - int num6 = (int)(vector.Y - (float)num3 - 1f); - int num7 = (int)(vector.Y + 2f); - if (num4 < 0) + int minXSize = (int)(vector.X - (float)largerRandValue - 1f); + int maxXSize = (int)(vector.X + (float)largerRandValue + 1f); + int minYSize = (int)(vector.Y - (float)smallerRandValue - 1f); + int maxYSize = (int)(vector.Y + 2f); + if (minXSize < 0) { - num4 = 0; + minXSize = 0; } - if (num5 > Main.maxTilesX) + if (maxXSize > Main.maxTilesX) { - num5 = Main.maxTilesX; + maxXSize = Main.maxTilesX; } - if (num6 < 0) + if (minYSize < 0) { - num6 = 0; + minYSize = 0; } - if (num7 > Main.maxTilesY) + if (maxYSize > Main.maxTilesY) { - num7 = Main.maxTilesY; + maxYSize = Main.maxTilesY; } - for (int l = num4; l <= num5; l++) + for (int l = minXSize; l <= maxXSize; l++) { - for (int m = num6 - 1; m < num7 + 1; m++) + for (int m = minYSize - 1; m < maxYSize + 1; m++) { - if (m != num6 - 1 || (l != num4 && l != num5)) + if (m != minYSize - 1 || (l != minXSize && l != maxXSize)) { Main.tile[l, m].Get().HasTile = true; Main.tile[l, m].LiquidAmount = 0; @@ -335,55 +335,55 @@ namespace CalamityMod.World } } } - num4 = (int)(vector.X - (float)num2); - num5 = (int)(vector.X + (float)num2); - num6 = (int)(vector.Y - (float)num3); - num7 = (int)(vector.Y + 1f); - if (num4 < 0) + minXSize = (int)(vector.X - (float)largerRandValue); + maxXSize = (int)(vector.X + (float)largerRandValue); + minYSize = (int)(vector.Y - (float)smallerRandValue); + maxYSize = (int)(vector.Y + 1f); + if (minXSize < 0) { - num4 = 0; + minXSize = 0; } - if (num5 > Main.maxTilesX) + if (maxXSize > Main.maxTilesX) { - num5 = Main.maxTilesX; + maxXSize = Main.maxTilesX; } - if (num6 < 0) + if (minYSize < 0) { - num6 = 0; + minYSize = 0; } - if (num7 > Main.maxTilesY) + if (maxYSize > Main.maxTilesY) { - num7 = Main.maxTilesY; + maxYSize = Main.maxTilesY; } - for (int n = num4; n <= num5; n++) + for (int n = minXSize; n <= maxXSize; n++) { - for (int num8 = num6; num8 < num7; num8++) + for (int p = minYSize; p < maxYSize; p++) { - if ((num8 != num6 || (n != num4 && n != num5)) && Main.tile[n, num8].WallType == 0) + if ((p != minYSize || (n != minXSize && n != maxXSize)) && Main.tile[n, p].WallType == 0) { - Main.tile[n, num8].Get().HasTile = false; - Main.tile[n, num8].WallType = wall; + Main.tile[n, p].Get().HasTile = false; + Main.tile[n, p].WallType = wall; } } } - int num9 = i + (num2 + 1) * num; - int num10 = (int)vector.Y; - for (int num11 = num9 - 2; num11 <= num9 + 2; num11++) + int xPos = i + (largerRandValue + 1) * houseDirection; + int t = (int)vector.Y; + for (int s = xPos - 2; s <= xPos + 2; s++) { - Main.tile[num11, num10].Get().HasTile = false; - Main.tile[num11, num10 - 1].Get().HasTile = false; - Main.tile[num11, num10 - 2].Get().HasTile = false; + Main.tile[s, t].Get().HasTile = false; + Main.tile[s, t - 1].Get().HasTile = false; + Main.tile[s, t - 2].Get().HasTile = false; } - WorldGen.PlaceTile(num9, num10, 10, true, false, -1, genCorruptHouse ? 1 : 10); //door - num9 = i + (num2 + 1) * -num - num; - for (int num12 = num6; num12 <= num7 + 1; num12++) + WorldGen.PlaceTile(xPos, t, 10, true, false, -1, genCorruptHouse ? 1 : 10); //door + xPos = i + (largerRandValue + 1) * -houseDirection - houseDirection; + for (int yPos = minYSize; yPos <= maxYSize + 1; yPos++) { - Main.tile[num9, num12].Get().HasTile = true; - Main.tile[num9, num12].LiquidAmount = 0; - Main.tile[num9, num12].TileType = type; - Main.tile[num9, num12].WallType = 0; - Main.tile[num9, num12].Get().IsHalfBlock = false; - Main.tile[num9, num12].Get().Slope = SlopeType.Solid; + Main.tile[xPos, yPos].Get().HasTile = true; + Main.tile[xPos, yPos].LiquidAmount = 0; + Main.tile[xPos, yPos].TileType = type; + Main.tile[xPos, yPos].WallType = 0; + Main.tile[xPos, yPos].Get().IsHalfBlock = false; + Main.tile[xPos, yPos].Get().Slope = SlopeType.Solid; } int contain; if (genCorruptHouse) @@ -394,37 +394,37 @@ namespace CalamityMod.World { contain = 1569; //vampire } - WorldGen.AddBuriedChest(i, num10 - 3, contain, false, genCorruptHouse ? 19 : 20); //chest - int num14 = i - num2 / 2 + 1; - int num15 = i + num2 / 2 - 1; - int num16 = 1; - if (num2 > 10) + WorldGen.AddBuriedChest(i, t - 3, contain, false, genCorruptHouse ? 19 : 20); //chest + int wallXMinSize = i - largerRandValue / 2 + 1; + int wallXMaxSize = i + largerRandValue / 2 - 1; + int wallYSize = 1; + if (largerRandValue > 10) { - num16 = 2; + wallYSize = 2; } - int num17 = (num6 + num7) / 2 - 1; - for (int num18 = num14 - num16; num18 <= num14 + num16; num18++) + int wallYRange = (minYSize + maxYSize) / 2 - 1; + for (int wallX = wallXMinSize - wallYSize; wallX <= wallXMinSize + wallYSize; wallX++) { - for (int num19 = num17 - 1; num19 <= num17 + 1; num19++) + for (int wallY = wallYRange - 1; wallY <= wallYRange + 1; wallY++) { - Main.tile[num18, num19].WallType = 21; //glass + Main.tile[wallX, wallY].WallType = 21; //glass } } - for (int num20 = num15 - num16; num20 <= num15 + num16; num20++) + for (int wallX2 = wallXMaxSize - wallYSize; wallX2 <= wallXMaxSize + wallYSize; wallX2++) { - for (int num21 = num17 - 1; num21 <= num17 + 1; num21++) + for (int wallY2 = wallYRange - 1; wallY2 <= wallYRange + 1; wallY2++) { - Main.tile[num20, num21].WallType = 21; //glass + Main.tile[wallX2, wallY2].WallType = 21; //glass } } - int num22 = i + (num2 / 2 + 1) * -num; - WorldGen.PlaceTile(num22, num7 - 1, 14, true, false, -1, genCorruptHouse ? 1 : 8); //table - WorldGen.PlaceTile(num22 - 2, num7 - 1, 15, true, false, 0, genCorruptHouse ? 2 : 11); //chair - Tile tile = Main.tile[num22 - 2, num7 - 1]; + int furnitureXPos = i + (largerRandValue / 2 + 1) * -houseDirection; + WorldGen.PlaceTile(furnitureXPos, maxYSize - 1, 14, true, false, -1, genCorruptHouse ? 1 : 8); //table + WorldGen.PlaceTile(furnitureXPos - 2, maxYSize - 1, 15, true, false, 0, genCorruptHouse ? 2 : 11); //chair + Tile tile = Main.tile[furnitureXPos - 2, maxYSize - 1]; tile.TileFrameX += 18; - Tile tile2 = Main.tile[num22 - 2, num7 - 2]; + Tile tile2 = Main.tile[furnitureXPos - 2, maxYSize - 2]; tile2.TileFrameX += 18; - WorldGen.PlaceTile(num22 + 2, num7 - 1, 15, true, false, 0, genCorruptHouse ? 2 : 11); //chair + WorldGen.PlaceTile(furnitureXPos + 2, maxYSize - 1, 15, true, false, 0, genCorruptHouse ? 2 : 11); //chair } } } diff --git a/build.txt b/build.txt index 6670624cda..9a28e5bb24 100644 --- a/build.txt +++ b/build.txt @@ -1,5 +1,5 @@ author = Fabsol and the Dev Team -version = 2.0.3.006 +version = 2.0.3.007 displayName = Calamity Mod homepage = https://discord.gg/calamity buildIgnore = .vs\*, Properties\*, *.csproj, *.user, obj\*, bin\*, *.config, .git\*, .github\*, LICENSE, README.md, .editorconfig, .gitignore, .gitattributes, Effects\Compiler\*