From 598ceccce1c0961d252bb35afafaff97672b1ca0 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sat, 10 Apr 2021 14:06:50 -0500 Subject: [PATCH 01/32] Added a martian madness summoning item --- .../Invasion/MartianDistressBeacon.cs | 38 ++++++++++++++++++ .../Invasion/MartianDistressBeacon.png | Bin 0 -> 985 bytes NPCs/CalamityGlobalTownNPC.cs | 2 + 3 files changed, 40 insertions(+) create mode 100644 Items/SummonItems/Invasion/MartianDistressBeacon.cs create mode 100644 Items/SummonItems/Invasion/MartianDistressBeacon.png diff --git a/Items/SummonItems/Invasion/MartianDistressBeacon.cs b/Items/SummonItems/Invasion/MartianDistressBeacon.cs new file mode 100644 index 0000000000..244d951c4c --- /dev/null +++ b/Items/SummonItems/Invasion/MartianDistressBeacon.cs @@ -0,0 +1,38 @@ +using CalamityMod.Events; +using CalamityMod.Items.Materials; +using CalamityMod.World; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.SummonItems.Invasion +{ + public class MartianDistressBeacon : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Martian Distress Beacon"); + Tooltip.SetDefault("Summons the Martian Madness"); + } + + public override void SetDefaults() + { + item.width = 30; + item.height = 60; + item.maxStack = 99; + item.rare = ItemRarityID.Yellow; + item.useAnimation = 45; + item.useTime = 45; + item.useStyle = ItemUseStyleID.HoldingUp; + item.consumable = true; + } + + public override bool CanUseItem(Player player) => Main.invasionType == InvasionID.None; + + public override bool UseItem(Player player) + { + Main.StartInvasion(InvasionID.MartianMadness); + return true; + } + } +} diff --git a/Items/SummonItems/Invasion/MartianDistressBeacon.png b/Items/SummonItems/Invasion/MartianDistressBeacon.png new file mode 100644 index 0000000000000000000000000000000000000000..32afb9a520d69aed56680343a65bb10f412e2c44 GIT binary patch literal 985 zcmV;~119{5P)Px&lSxEDR9J=0nQv%KVI0Rl$IQKkZi~4ljMg$^tj$DNlrTlgUMUnsdpTKYNqZqL zY*7@=3z3pyFX-uRb+y(4z(aAj9_%Im){JufUQ z1Rx%dD@R@J?d^b<#ABDNFaSC#%&1%pmG+UkTEHUrj#z#;kvr+!r6;!Mby8hI?)^NL`4tG5RchMw90Q=g?^^<(x3?Ft zyxqKU5nz!^TU1qDn{r_9iABL+5U@xkYQ-BN4`-Y8x~j4Qu-=4RfAz9mdG6eKxk}qV z#7@$^?Cvykw2%ffLQ4Ox&Q<`XWX}PHz5)LbOI4BF>!zGpc>qM7KLe~cpzHRHvr5~4 z#CnyHjI_FZi*jDP6iHNzw?e8%z4y6VBsm*UabX9K=j-ZW?|TXg3e+17^VUEhVD7z= zUfXzVJBELWi;IiRV`&)xEl-G-DHK296^%wtxv?dEO#r}?GOdty;n=Lcn9e7eE>D%;a%|A4Hm!}E6B z_z4EU_kn)E55!Kp#KE2Xp@YECc`I`BR!IG`=E~1Eb8I{wPr%TsA``TtbxhyC|!&xn5mIg(%^1Tmxa00000NkvXX Hu0mjf!rkTU literal 0 HcmV?d00001 diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index e0031ee9c4..12927d26fb 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -7,6 +7,7 @@ using CalamityMod.Items.Placeables.Furniture.Fountains; using CalamityMod.Items.Placeables.Walls; using CalamityMod.Items.Potions; using CalamityMod.Items.SummonItems; +using CalamityMod.Items.SummonItems.Invasion; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; @@ -1217,6 +1218,7 @@ namespace CalamityMod.NPCs if (type == NPCID.Cyborg) { SetShopItem(ref shop, ref nextSlot, ItemID.RocketLauncher, NPC.downedGolemBoss, Item.buyPrice(0, 25)); + SetShopItem(ref shop, ref nextSlot, ItemType(), NPC.downedGolemBoss, Item.buyPrice(0, 50)); SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedPolterghast); } From 739a1a609094c81104cad1636d1e28315d3056fd Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 11 Apr 2021 15:30:53 -0500 Subject: [PATCH 02/32] Made every single DirectionTo safe --- Items/CalamityGlobalItem.cs | 2 +- NPCs/AcidRain/BloodwormFleeing.cs | 9 +- NPCs/AcidRain/GammaSlime.cs | 2 +- NPCs/AcidRain/NuclearTerror.cs | 4 +- NPCs/AcidRain/Orthocera.cs | 2 +- NPCs/AcidRain/Skyfin.cs | 4 +- NPCs/AcidRain/SulfurousSkater.cs | 2 +- NPCs/AcidRain/Trilobite.cs | 4 +- NPCs/AcidRain/WaterLeech.cs | 6 +- NPCs/CalamityAI.cs | 2 +- NPCs/CalamityGlobalAI.cs | 103 +++++++++--------- NPCs/CalamityVanillaMinibossesAI.cs | 14 +-- NPCs/GreatSandShark/GreatSandShark.cs | 5 +- NPCs/NormalNPCs/WulfrumDrone.cs | 13 +-- NPCs/NormalNPCs/WulfrumHovercraft.cs | 4 +- NPCs/SulphurousSea/AnthozoanCrab.cs | 4 +- NPCs/Yharon/Yharon.cs | 28 ++--- .../BaseProjectiles/BaseSpearProjectile.cs | 5 +- Projectiles/Boss/BrimstoneGigaBlast.cs | 7 +- Projectiles/Boss/BrimstoneMonster.cs | 7 +- Projectiles/Boss/FlareBomb.cs | 8 +- Projectiles/Boss/ScavengerNuke.cs | 7 +- Projectiles/CalamityGlobalProjectile.cs | 9 +- .../FrequencyManipulatorEnergy.cs | 2 +- .../DraedonsArsenal/MountedScannerSummon.cs | 3 +- .../DraedonsArsenal/PhaseslayerBeam.cs | 5 +- .../DraedonsArsenal/PoleWarperSummon.cs | 6 +- .../DraedonsArsenal/PulseDragonProjectile.cs | 52 ++++----- Projectiles/DraedonsArsenal/PulseRifleShot.cs | 5 +- Projectiles/DraedonsArsenal/PulseTurret.cs | 8 +- .../DraedonsArsenal/PulseTurretShot.cs | 4 +- .../DraedonsArsenal/SnakeEyesSummon.cs | 15 +-- .../DraedonsArsenal/StarSwallowerSummon.cs | 2 +- .../DraedonsArsenal/SystemBaneProjectile.cs | 2 +- Projectiles/DraedonsArsenal/TaserHook.cs | 7 +- .../DraedonsArsenal/TeslaCannonShot.cs | 2 +- .../DraedonsArsenal/TrackingDiskProjectile.cs | 4 +- Projectiles/DraedonsArsenal/UnstableMatter.cs | 2 +- Projectiles/DraedonsArsenal/VoltageStream.cs | 5 +- Projectiles/Enemy/CragmawVibeCheckChain.cs | 16 +-- Projectiles/Enemy/NuclearBulletMedium.cs | 5 +- Projectiles/Magic/Crescent.cs | 8 +- Projectiles/Magic/DivineRetributionSpear.cs | 8 +- Projectiles/Magic/EnormousConsumingVortex.cs | 7 +- Projectiles/Magic/EternityCrystal.cs | 3 +- Projectiles/Magic/EternityHoming.cs | 5 +- Projectiles/Magic/EventHorizonStar.cs | 8 +- Projectiles/Magic/FatesRevealFlame.cs | 13 +-- Projectiles/Magic/LightBlade.cs | 2 +- Projectiles/Magic/StratusSphereProj.cs | 12 +- Projectiles/Magic/UndinesRetributionSpear.cs | 8 +- Projectiles/Melee/DragonRageFireball.cs | 8 +- Projectiles/Melee/DragonRageStaff.cs | 23 ++-- Projectiles/Melee/ElementalExcaliburBeam.cs | 8 +- Projectiles/Melee/ExoGladSpears.cs | 2 +- Projectiles/Melee/Exocomet.cs | 8 +- Projectiles/Melee/GaelSkull.cs | 12 +- Projectiles/Melee/GaelSkull2.cs | 11 +- Projectiles/Melee/GhastlySoulLarge.cs | 8 +- Projectiles/Melee/GhastlySoulMedium.cs | 8 +- Projectiles/Melee/GhastlySoulSmall.cs | 8 +- Projectiles/Melee/Spears/BansheeHookProj.cs | 6 +- Projectiles/Melee/TyphonsGreedBubble.cs | 8 +- Projectiles/Melee/TyphonsGreedStaff.cs | 19 +--- Projectiles/Ranged/BloodflareSoul.cs | 8 +- Projectiles/Ranged/ExoSpark.cs | 5 +- Projectiles/Ranged/ThePackMissile.cs | 3 +- Projectiles/Ranged/UltimaBowProjectile.cs | 4 +- Projectiles/Ranged/UltimaSpark.cs | 2 +- Projectiles/Ranged/VeriumBulletProj.cs | 7 +- .../Rogue/CelestialReaperAfterimage.cs | 2 +- .../Rogue/CelestialReaperProjectile.cs | 4 +- Projectiles/Rogue/DragonShit.cs | 4 +- .../Rogue/EpidemicShredderProjectile.cs | 4 +- Projectiles/Rogue/FinalDawnFireball.cs | 4 +- Projectiles/Rogue/FinalDawnProjectile.cs | 4 +- Projectiles/Rogue/FinalDawnThrow.cs | 2 +- Projectiles/Rogue/IceStarProjectile.cs | 7 +- Projectiles/Rogue/PhantasmalSoul.cs | 8 +- Projectiles/Rogue/RegulusEnergy.cs | 9 +- Projectiles/Rogue/ScarletDevilBullet.cs | 9 +- Projectiles/Rogue/SpearofDestinyProjectile.cs | 7 +- Projectiles/Rogue/StellarKnifeProj.cs | 7 +- Projectiles/Rogue/SupernovaHoming.cs | 9 +- .../Rogue/ToxicantTwisterTwoPointZero.cs | 6 +- Projectiles/Summon/AstralProbeRound.cs | 2 +- Projectiles/Summon/BelladonnaSpirit.cs | 2 +- Projectiles/Summon/CinderBlossom.cs | 2 +- Projectiles/Summon/CosmicBlast.cs | 2 +- Projectiles/Summon/CosmicBlastBig.cs | 2 +- Projectiles/Summon/CosmicViperHomingRocket.cs | 8 +- .../Summon/CosmicViperSplittingRocket.cs | 8 +- Projectiles/Summon/DazzlingStabber.cs | 5 +- Projectiles/Summon/DormantBrimseekerBab.cs | 10 +- Projectiles/Summon/EndoHydraHead.cs | 6 +- Projectiles/Summon/EnergyOrb.cs | 2 +- Projectiles/Summon/FlameBlast.cs | 2 +- Projectiles/Summon/FlameBurst.cs | 2 +- Projectiles/Summon/FlyingOrthocera.cs | 4 +- Projectiles/Summon/FrostBlossom.cs | 6 +- Projectiles/Summon/FungalClumpMinion.cs | 12 +- Projectiles/Summon/GammaCanister.cs | 2 +- Projectiles/Summon/GammaHead.cs | 5 +- Projectiles/Summon/GiantIbanRobotOfDoom.cs | 11 +- Projectiles/Summon/Hiveling.cs | 2 +- Projectiles/Summon/HomingGammaBullet.cs | 2 +- Projectiles/Summon/HowlsHeartFireball.cs | 7 +- Projectiles/Summon/LanternFlame.cs | 2 +- Projectiles/Summon/MK2RocketHoming.cs | 5 +- Projectiles/Summon/MechwormHead.cs | 6 +- Projectiles/Summon/MidnightSunUFO.cs | 10 +- Projectiles/Summon/PlaguebringerMK2.cs | 10 +- Projectiles/Summon/PowerfulRaven.cs | 6 +- Projectiles/Summon/RadiantResolutionAura.cs | 13 ++- Projectiles/Summon/RadiantResolutionFire.cs | 4 +- Projectiles/Summon/RadiantResolutionOrb.cs | 4 +- Projectiles/Summon/RustyDrone.cs | 4 +- Projectiles/Summon/SakuraBullet.cs | 7 +- Projectiles/Summon/SilvaCrystal.cs | 7 +- Projectiles/Summon/SkeletalDragonChild.cs | 7 +- Projectiles/Summon/SkeletalDragonMother.cs | 10 +- Projectiles/Summon/TacticalPlagueJet.cs | 14 +-- Projectiles/Summon/YoungDuke.cs | 13 +-- Projectiles/Typeless/GodSlayerPhantom.cs | 8 +- Projectiles/Typeless/KelvinCatalystStar.cs | 7 +- .../Typeless/RelicOfDeliveranceSpear.cs | 6 +- Utilities/DrawingUtils.cs | 2 +- Utilities/EntityUtils.cs | 24 ++++ 128 files changed, 423 insertions(+), 564 deletions(-) create mode 100644 Utilities/EntityUtils.cs diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index c98da34c74..5b70ea1952 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -849,7 +849,7 @@ namespace CalamityMod.Items if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType() && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].localAI[1] == 0f) { Main.projectile[i].rotation = MathHelper.PiOver2 + MathHelper.PiOver4; - Main.projectile[i].velocity = Main.projectile[i].DirectionTo(Main.MouseWorld) * 22f; + Main.projectile[i].velocity = Main.projectile[i].SafeDirectionTo(Main.MouseWorld, Vector2.UnitY) * 22f; Main.projectile[i].rotation += Main.projectile[i].velocity.ToRotation(); Main.projectile[i].ai[0] = 180f; (Main.projectile[i].modProjectile as IgneousBlade).Firing = true; diff --git a/NPCs/AcidRain/BloodwormFleeing.cs b/NPCs/AcidRain/BloodwormFleeing.cs index 3c0567b6af..0421bac8d6 100644 --- a/NPCs/AcidRain/BloodwormFleeing.cs +++ b/NPCs/AcidRain/BloodwormFleeing.cs @@ -33,8 +33,13 @@ namespace CalamityMod.NPCs.AcidRain Player player = Main.player[Player.FindClosest(npc.Center, 1, 1)]; if (npc.velocity == Vector2.Zero) npc.velocity = Vector2.UnitY * 12f; + float intertia = 24f; - npc.velocity = (npc.velocity * intertia - npc.DirectionTo(player.Center) * 12f) / (intertia + 1f); + + // Attempt to flee from the nearest player. + npc.velocity = (npc.velocity * intertia - npc.SafeDirectionTo(player.Center) * 12f) / (intertia + 1f); + + // But always dig downward. npc.velocity.Y = Math.Abs(npc.velocity.Y); npc.rotation = npc.velocity.ToRotation() - MathHelper.PiOver2; } @@ -47,9 +52,7 @@ namespace CalamityMod.NPCs.AcidRain npc.frameCounter = 0; npc.frame.Y += frameHeight; if (npc.frame.Y >= Main.npcFrameCount[npc.type] * frameHeight) - { npc.frame.Y = 0; - } } } diff --git a/NPCs/AcidRain/GammaSlime.cs b/NPCs/AcidRain/GammaSlime.cs index 48873cc830..817b571180 100644 --- a/NPCs/AcidRain/GammaSlime.cs +++ b/NPCs/AcidRain/GammaSlime.cs @@ -71,7 +71,7 @@ namespace CalamityMod.NPCs.AcidRain if (GammaAcidShootTimer % 30f == 29f) { npc.velocity.Y -= MathHelper.Clamp(Math.Abs(Target.Center.Y - npc.Center.Y) / 16f, 5f, 15f); - npc.velocity.X = npc.DirectionTo(Target.Center).X * 16f; + npc.velocity.X = npc.SafeDirectionTo(Target.Center).X * 16f; if (Main.netMode != NetmodeID.MultiplayerClient) { diff --git a/NPCs/AcidRain/NuclearTerror.cs b/NPCs/AcidRain/NuclearTerror.cs index 1bf40d102f..a6f24d9caf 100644 --- a/NPCs/AcidRain/NuclearTerror.cs +++ b/NPCs/AcidRain/NuclearTerror.cs @@ -172,7 +172,7 @@ 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.DirectionTo(Target.Center).X * 18f; + npc.velocity.X = npc.SafeDirectionTo(Target.Center).X * 18f; npc.netUpdate = true; } else @@ -193,7 +193,7 @@ namespace CalamityMod.NPCs.AcidRain // Otherwise walk towards the target if they're not super close. else if (Math.Abs(Target.Center.X - npc.Center.X) > 125f) { - npc.velocity.X += Math.Sign(npc.DirectionTo(Target.Center).X) * 3f; + npc.velocity.X += Math.Sign(npc.SafeDirectionTo(Target.Center).X) * 3f; npc.velocity.X = MathHelper.Clamp(npc.velocity.X, -28f, 28f); } diff --git a/NPCs/AcidRain/Orthocera.cs b/NPCs/AcidRain/Orthocera.cs index 8157990f5e..2666daf81f 100644 --- a/NPCs/AcidRain/Orthocera.cs +++ b/NPCs/AcidRain/Orthocera.cs @@ -87,7 +87,7 @@ namespace CalamityMod.NPCs.AcidRain // If close, simply resume current movement. if (!npc.WithinRange(player.Center, 150f)) { - npc.velocity = (npc.velocity * 17f + npc.DirectionTo(player.Center) * maxSpeed) / 18f; + npc.velocity = (npc.velocity * 17f + npc.SafeDirectionTo(player.Center, -Vector2.UnitY) * maxSpeed) / 18f; if (FallDelay != 12f) { FallDelay = 12f; diff --git a/NPCs/AcidRain/Skyfin.cs b/NPCs/AcidRain/Skyfin.cs index 45df423cec..e7754f40b8 100644 --- a/NPCs/AcidRain/Skyfin.cs +++ b/NPCs/AcidRain/Skyfin.cs @@ -104,7 +104,7 @@ namespace CalamityMod.NPCs.AcidRain chargeSpeed = 14f; if (CalamityWorld.downedPolterghast) chargeSpeed = 18f; - npc.velocity = npc.DirectionTo(Target.Center) * chargeSpeed; + npc.velocity = npc.SafeDirectionTo(Target.Center, Vector2.UnitY) * chargeSpeed; } } else @@ -112,7 +112,7 @@ namespace CalamityMod.NPCs.AcidRain if (Math.Abs(Target.Center.X - npc.Center.X) > 320f) npc.velocity.X = MathHelper.Lerp(npc.velocity.X, (Target.Center.X - npc.Center.X > 0).ToDirectionInt() * 10f, 0.05f); if (Math.Abs(Target.Center.Y - npc.Center.Y) > 50f) - npc.velocity.Y = npc.DirectionTo(Target.Center).Y * 9f; + npc.velocity.Y = npc.SafeDirectionTo(Target.Center).Y * 9f; } } diff --git a/NPCs/AcidRain/SulfurousSkater.cs b/NPCs/AcidRain/SulfurousSkater.cs index 930d5fdc27..485f11854c 100644 --- a/NPCs/AcidRain/SulfurousSkater.cs +++ b/NPCs/AcidRain/SulfurousSkater.cs @@ -142,7 +142,7 @@ namespace CalamityMod.NPCs.AcidRain // Fly more sharply if close to the target. if (npc.WithinRange(Target.Center, 200f)) flyInertia *= 0.667f; - npc.velocity = (npc.velocity * flyInertia + npc.DirectionTo(Target.Center) * flySpeed) / (flyInertia + 1f); + npc.velocity = (npc.velocity * flyInertia + npc.SafeDirectionTo(Target.Center, Vector2.UnitY) * flySpeed) / (flyInertia + 1f); npc.spriteDirection = (npc.velocity.X < 0).ToDirectionInt(); // Have the bubble pop and stop flying if within the circular hitbox area of the player. diff --git a/NPCs/AcidRain/Trilobite.cs b/NPCs/AcidRain/Trilobite.cs index 86cc206618..7ae8abb2cf 100644 --- a/NPCs/AcidRain/Trilobite.cs +++ b/NPCs/AcidRain/Trilobite.cs @@ -70,7 +70,7 @@ namespace CalamityMod.NPCs.AcidRain npc.TargetClosest(); float lungeSpeed = CalamityWorld.downedPolterghast ? 18.5f : 15f; - npc.velocity = npc.DirectionTo(Target.Center) * lungeSpeed; + npc.velocity = npc.SafeDirectionTo(Target.Center, -Vector2.UnitY) * lungeSpeed; npc.velocity.X *= 1.6f; npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; npc.netUpdate = true; @@ -97,7 +97,7 @@ namespace CalamityMod.NPCs.AcidRain speedX = 22f; speedY = 11f; } - npc.velocity = npc.DirectionTo(Target.Center) * new Vector2(speedX, speedY); + npc.velocity = npc.SafeDirectionTo(Target.Center, -Vector2.UnitY) * new Vector2(speedX, speedY); npc.netUpdate = true; } npc.velocity.Y *= 0.98f; diff --git a/NPCs/AcidRain/WaterLeech.cs b/NPCs/AcidRain/WaterLeech.cs index c6f5ae2a28..9fa0b015fe 100644 --- a/NPCs/AcidRain/WaterLeech.cs +++ b/NPCs/AcidRain/WaterLeech.cs @@ -120,7 +120,7 @@ namespace CalamityMod.NPCs.AcidRain swimSpeed *= 1.6f; swimIntertia = 17f; } - npc.velocity = (npc.velocity * (swimIntertia - 1f) + npc.DirectionTo(Target.Center) * swimSpeed) / swimIntertia; + npc.velocity = (npc.velocity * (swimIntertia - 1f) + npc.SafeDirectionTo(Target.Center, -Vector2.UnitY) * swimSpeed) / swimIntertia; } // Rapidly slow down if the target is not in water. @@ -157,9 +157,11 @@ namespace CalamityMod.NPCs.AcidRain npc.netUpdate = true; return; } + Vector2 destination = (Target.gravDir == 1f ? Target.Top : Target.Bottom) + Target.direction * Vector2.UnitX * 4f; float speed = MathHelper.Lerp(7f, 23f, Utils.InverseLerp(10f, ChaseMaxDistance, npc.Distance(destination), true)); - npc.velocity = npc.DirectionTo(destination) * speed; + npc.velocity = npc.SafeDirectionTo(destination) * speed; + if (npc.WithinRange(destination, 45f)) { Target.AddBuff(BuffID.Bleeding, 180, true); diff --git a/NPCs/CalamityAI.cs b/NPCs/CalamityAI.cs index 33279ea7a6..7dc4ac14fe 100644 --- a/NPCs/CalamityAI.cs +++ b/NPCs/CalamityAI.cs @@ -4585,7 +4585,7 @@ namespace CalamityMod.NPCs if (npc.ai[1] == 0f) { Vector2 destination2 = player.Center + new Vector2(0f, -200f); - Vector2 desiredVelocity2 = npc.DirectionTo(destination2) * 18f; + Vector2 desiredVelocity2 = npc.SafeDirectionTo(destination2, -Vector2.UnitY) * 18f; npc.SimpleFlyMovement(desiredVelocity2, 1.5f); if (npc.velocity.X < 0f) diff --git a/NPCs/CalamityGlobalAI.cs b/NPCs/CalamityGlobalAI.cs index f65e39521c..4f00ab3390 100644 --- a/NPCs/CalamityGlobalAI.cs +++ b/NPCs/CalamityGlobalAI.cs @@ -16066,9 +16066,10 @@ namespace CalamityMod.NPCs // If there's nothing in the way of the player, swim towards them if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].Center, 1, 1)) { - npc.velocity = (npc.velocity * 19f + npc.DirectionTo(Main.player[npc.target].Center) * 10f) / 20f; + npc.velocity = (npc.velocity * 19f + npc.SafeDirectionTo(Main.player[npc.target].Center, -Vector2.UnitY) * 10f) / 20f; return false; } + float velocityMultiplier = 10f; if (npc.velocity.Y > 0f) { @@ -16503,7 +16504,7 @@ namespace CalamityMod.NPCs for (int j = 0; j < 2; j++) { // Randomize and normalize. You know the drill - Vector2 dustVelocity = Vector2.One.RotatedByRandom(MathHelper.TwoPi); + Vector2 dustVelocity = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); dustVelocity *= (float)Main.rand.Next(0, 100) * 0.1f; dustVelocity.Normalize(); dustVelocity *= (float)Main.rand.Next(50, 90) * 0.1f; @@ -16589,11 +16590,8 @@ namespace CalamityMod.NPCs { npc.ai[2] -= 1f; npc.TargetClosest(true); - Vector2 vectorToPlayer = npc.DirectionTo(Main.player[npc.target].Top + new Vector2(0f, -30f)); - if (vectorToPlayer.HasNaNs()) - { - vectorToPlayer = Vector2.Normalize(new Vector2((float)npc.spriteDirection, -1f)); - } + Vector2 vectorToPlayer = npc.SafeDirectionTo(Main.player[npc.target].Top - Vector2.UnitY * 30f, Vector2.Normalize(new Vector2(npc.spriteDirection, -1f))); + npc.velocity = vectorToPlayer * velocityMultiplier; npc.netUpdate = true; return false; @@ -16972,14 +16970,13 @@ namespace CalamityMod.NPCs } Vector2 velocityDelta = -Vector2.One; for (int j = 0; j < i; j++) - { - velocityDelta += npc.DirectionTo(Main.npc[players[j]].Center); - } + velocityDelta += npc.SafeDirectionTo(Main.npc[players[j]].Center); + velocityDelta.Normalize(); for (int j = 0; j < nailCount; j++) { - float velocityMultiplier = (float)Main.rand.Next(8, 13); - Vector2 nailVelocity = Vector2.One.RotatedByRandom(Math.PI * 2.0); + float velocityMultiplier = Main.rand.Next(8, 13); + Vector2 nailVelocity = Vector2.UnitY.RotatedByRandom(Math.PI * 2.0); if (i > 0) { nailVelocity += velocityDelta; @@ -16989,9 +16986,10 @@ namespace CalamityMod.NPCs if (i > 0) { i--; - nailVelocity = npc.DirectionTo(Main.npc[players[i]].Center) * velocityMultiplier; + nailVelocity = npc.SafeDirectionTo(Main.npc[players[i]].Center, -Vector2.UnitY) * velocityMultiplier; } - Projectile.NewProjectile(npc.Center + Vector2.UnitY * (float)(npc.width / 4), nailVelocity, ProjectileID.Nail, (int)(npc.damage * 0.15), 1f, 255, 0f, 0f); + + Projectile.NewProjectile(npc.Center + Vector2.UnitY * (npc.width / 4), nailVelocity, ProjectileID.Nail, (int)(npc.damage * 0.15), 1f, 255, 0f, 0f); } } } @@ -17854,21 +17852,19 @@ namespace CalamityMod.NPCs } if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[2] += 1f; - if (npc.localAI[2] >= (float)(240 + Main.rand.Next(240)) && npc.Distance(Main.player[npc.target].Center) < 600f && Math.Abs(npc.DirectionTo(Main.player[npc.target].Center).Y) < 0.5f && Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) + npc.localAI[2]++; + bool closeToPlayer = npc.Distance(Main.player[npc.target].Center) < 600f && Math.Abs(npc.SafeDirectionTo(Main.player[npc.target].Center).Y) < 0.5f; + if (npc.localAI[2] >= Main.rand.Next(240, 480) && closeToPlayer && Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) { npc.localAI[2] = 0f; - Vector2 spawnPos = npc.Center + new Vector2((float)(npc.direction * 30), 2f); - Vector2 velocity = npc.DirectionTo(Main.player[npc.target].Center) * 9f; - if (velocity.HasNaNs()) - { - velocity = new Vector2((float)(npc.direction * 10), 0f); - } + Vector2 spawnPosition = npc.Center + new Vector2(npc.direction * 30f, 2f); + Vector2 baseLaserVelocity = npc.SafeDirectionTo(Main.player[npc.target].Center, Vector2.UnitX * npc.direction) * 9f; + int damage = Main.expertMode ? 50 : 75; for (int i = 0; i < 4; i++) { - Vector2 vector17 = velocity + Utils.RandomVector2(Main.rand, -0.8f, 0.8f); - Projectile.NewProjectile(spawnPos, vector17, ProjectileID.VortexLaser, damage, 1f, Main.myPlayer, 0f, 0f); + Vector2 randomizedVelocity = baseLaserVelocity + Utils.RandomVector2(Main.rand, -0.8f, 0.8f); + Projectile.NewProjectile(spawnPosition, randomizedVelocity, ProjectileID.VortexLaser, damage, 1f, Main.myPlayer, 0f, 0f); } } } @@ -18046,7 +18042,7 @@ namespace CalamityMod.NPCs 229 }); Dust dust = Main.dust[Dust.NewDust(npc.Center + new Vector2((float)((npc.spriteDirection == 1) ? 8 : -20), -20f), 8, 8, dustType, npc.velocity.X, npc.velocity.Y, 100, default, 1f)]; - dust.velocity = dust.velocity / 4f + npc.DirectionTo(Main.player[npc.target].Top); + dust.velocity = dust.velocity / 4f + npc.SafeDirectionTo(Main.player[npc.target].Top); dust.scale = 1.2f; dust.noLight = true; } @@ -18112,7 +18108,7 @@ namespace CalamityMod.NPCs if (npc.localAI[0] > (float)Main.rand.Next(120, 240)) { npc.localAI[0] = 0f; - Projectile.NewProjectile(npc.Center, npc.DirectionTo(Main.player[npc.target].Center) * 10f, ProjectileID.WebSpit, 18, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.Center, npc.SafeDirectionTo(Main.player[npc.target].Center, -Vector2.UnitY) * 10f, ProjectileID.WebSpit, 18, 0f, Main.myPlayer, 0f, 0f); } } if (npcType == NPCID.IceGolem) @@ -18133,7 +18129,7 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] >= 90f && npc.velocity.Y == 0f && !Main.player[npc.target].dead && !Main.player[npc.target].frozen && ((npc.direction > 0 && npc.Center.X < Main.player[npc.target].Center.X) || (npc.direction < 0 && npc.Center.X > Main.player[npc.target].Center.X)) && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { npc.netUpdate = true; - Vector2 velocity = npc.DirectionTo(Main.player[npc.target].Center) * 15; + Vector2 velocity = npc.SafeDirectionTo(Main.player[npc.target].Center, -Vector2.UnitY) * 15; Projectile.NewProjectile(npc.Center - Vector2.UnitY * 28 + velocity * 2f, velocity, ProjectileID.FrostBeam, 32, 0f, Main.myPlayer, 0f, 0f); npc.ai[2] = 0f; } @@ -21150,11 +21146,12 @@ namespace CalamityMod.NPCs { if (!Collision.SolidCollision(npc.position, npc.width, npc.height) && 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; int damage = 17; int type = ProjectileID.CursedFlameHostile; - int idx = Projectile.NewProjectile(npc.Center, npc.DirectionTo(Main.player[npc.target].Center) * speed, type, damage, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[idx].timeLeft = 180; + Vector2 flameVelocity = npc.SafeDirectionTo(Main.player[npc.target].Center, -Vector2.UnitY) * 12f; + + int flame = Projectile.NewProjectile(npc.Center, flameVelocity, type, damage, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[flame].timeLeft = 180; npc.localAI[0] = 0f; } else @@ -21177,7 +21174,8 @@ namespace CalamityMod.NPCs { absoluteYDistance = 0f; } - Vector2 velocity = npc.DirectionTo(Main.player[npc.target].Center - npc.Center - Vector2.UnitY * absoluteYDistance) * speed; + + Vector2 velocity = npc.SafeDirectionTo(Main.player[npc.target].Center - npc.Center - Vector2.UnitY * absoluteYDistance, -Vector2.UnitY) * speed; int idx = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, NPCID.FungiSpore, 0, 0f, 0f, 0f, 0f, 255); Main.npc[idx].velocity = velocity; @@ -21424,11 +21422,12 @@ namespace CalamityMod.NPCs { 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 = 6f; int damage = 15; int type = ProjectileID.HarpyFeather; - int idx = Projectile.NewProjectile(npc.Center, npc.DirectionTo(Main.player[npc.target].Center) * speed, type, damage, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[idx].timeLeft = 300; + Vector2 featherVelocity = npc.SafeDirectionTo(Main.player[npc.target].Center) * 6f; + + int feather = Projectile.NewProjectile(npc.Center, featherVelocity, type, damage, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[feather].timeLeft = 300; } } else if (npc.ai[0] >= 400f + Main.rand.Next(200)) @@ -21443,11 +21442,12 @@ namespace CalamityMod.NPCs { 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 = 0.2f; int damage = 21; int type = ProjectileID.DemonSickle; - int idx = Projectile.NewProjectile(npc.Center, npc.DirectionTo(Main.player[npc.target].Center) * speed, type, damage, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[idx].timeLeft = 300; + Vector2 sickleVelocity = npc.SafeDirectionTo(Main.player[npc.target].Center) * 0.2f; + + int sickle = Projectile.NewProjectile(npc.Center, sickleVelocity, type, damage, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[sickle].timeLeft = 300; } } else if (npc.ai[0] >= 300f + Main.rand.Next(200)) @@ -21462,16 +21462,16 @@ namespace CalamityMod.NPCs { 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 = 0.2f; Vector2 spawnPosition = npc.Center; - Vector2 velocity = npc.DirectionTo(Main.player[npc.target].Center) * speed; + float tridentSpeed = 0.2f; + Vector2 tridentVelocity = npc.SafeDirectionTo(Main.player[npc.target].Center) * tridentSpeed; + spawnPosition += npc.velocity * 5f; int damage = 80; int type = ProjectileID.UnholyTridentHostile; - spawnPosition += npc.velocity * 5f; - int idx = Projectile.NewProjectile(spawnPosition + velocity * 100f, velocity, type, damage, 3f, Main.myPlayer, 0f, 0f); - Main.projectile[idx].timeLeft = 300; + int trident = Projectile.NewProjectile(spawnPosition + tridentVelocity * 100f, tridentVelocity, type, damage, 3f, Main.myPlayer, 0f, 0f); + Main.projectile[trident].timeLeft = 300; } } else if (npc.ai[0] >= 250f + Main.rand.Next(200)) @@ -21882,12 +21882,9 @@ namespace CalamityMod.NPCs npc.localAI[0] = 1f; } npc.TargetClosest(true); - float speed = 14f; - if (npc.type == NPCID.GreenJellyfish) - { - speed = 18f; - } - npc.velocity = npc.DirectionTo(Main.player[npc.target].Center) * speed; + + float lungeSpeed = npc.type == NPCID.GreenJellyfish ? 18f : 14f; + npc.velocity = npc.SafeDirectionTo(Main.player[npc.target].Center, -Vector2.UnitY) * lungeSpeed; } } // General floating around. @@ -22821,9 +22818,10 @@ namespace CalamityMod.NPCs // Charge if (npc.ai[0] == 0f) { - float speed = 12f; - npc.velocity = npc.DirectionTo(Main.player[npc.target].Center) * speed; + float chargeSpeed = 12f; + npc.velocity = npc.SafeDirectionTo(Main.player[npc.target].Center, -Vector2.UnitY) * chargeSpeed; npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver4; + // Slow down npc.ai[0] = 1f; npc.ai[1] = 0f; @@ -24721,12 +24719,11 @@ namespace CalamityMod.NPCs float speed = 6f; float acceleration = 0.25f; - Vector2 idealVelocity = npc.DirectionTo(Main.player[npc.target].Center - 300f * Vector2.UnitY) * speed; + Vector2 idealVelocity = npc.SafeDirectionTo(Main.player[npc.target].Center - 300f * Vector2.UnitY) * speed; float playerDistance = npc.Distance(Main.player[npc.target].Center); if (playerDistance < 20f) - { idealVelocity = npc.velocity; - } + // Yes, I understand that npc.SimpleFlyMovement exists. However, the "acceleration * 2f" is not a part of that method. // It is not identical to what is being achieved here. if (npc.velocity.X < idealVelocity.X) diff --git a/NPCs/CalamityVanillaMinibossesAI.cs b/NPCs/CalamityVanillaMinibossesAI.cs index c3efcf9aee..1121e61b2f 100644 --- a/NPCs/CalamityVanillaMinibossesAI.cs +++ b/NPCs/CalamityVanillaMinibossesAI.cs @@ -106,7 +106,7 @@ namespace CalamityMod.NPCs else if (distanceFromAboveTarget > 600f) { flyInertia = 30f; - idealFlyVelocity = npc.DirectionTo(destinationAboveTarget) * 15f; + idealFlyVelocity = npc.SafeDirectionTo(destinationAboveTarget, -Vector2.UnitY) * 15f; npc.velocity = (npc.velocity * (flyInertia - 1f) + idealFlyVelocity) / flyInertia; } @@ -168,7 +168,7 @@ namespace CalamityMod.NPCs float flySpeed = 18f + npc.Distance(target.Center) / 100f; flyInertia = 25f; - idealFlyVelocity = npc.DirectionTo(target.Center) * flySpeed; + idealFlyVelocity = npc.SafeDirectionTo(target.Center, -Vector2.UnitY) * flySpeed; npc.velocity = (npc.velocity * (flyInertia - 1f) + idealFlyVelocity) / flyInertia; break; @@ -210,7 +210,7 @@ namespace CalamityMod.NPCs flySpeed = 12f + flySpeedAdditive + npc.Distance(destination) / 120f; flyInertia = 20f; - idealFlyVelocity = npc.DirectionTo(destination) * flySpeed; + idealFlyVelocity = npc.SafeDirectionTo(destination, -Vector2.UnitY) * flySpeed; npc.velocity = (npc.velocity * (flyInertia - 1f) + idealFlyVelocity) / flyInertia; aiTimer++; @@ -254,7 +254,7 @@ namespace CalamityMod.NPCs flySpeedAdditive += 0.0333333351f; flySpeed = 24f + flySpeedAdditive; flyInertia = 4f; - idealVelocity = npc.DirectionTo(destination) * flySpeed; + idealVelocity = npc.SafeDirectionTo(destination, -Vector2.UnitY) * flySpeed; npc.velocity = (npc.velocity * (flyInertia - 1f) + idealVelocity) / flyInertia; break; case MothronAIState.ChargePreparation: @@ -267,7 +267,7 @@ namespace CalamityMod.NPCs destination = target.Center - Vector2.UnitY * 12f; float chargePreperationInertia = 8f; - Vector2 chargeVelocity = npc.DirectionTo(destination) * chargeSpeed; + Vector2 chargeVelocity = npc.SafeDirectionTo(destination, -Vector2.UnitY) * chargeSpeed; npc.velocity = (npc.velocity * (chargePreperationInertia - 1f) + chargeVelocity) / chargePreperationInertia; npc.spriteDirection = npc.direction = (npc.velocity.X > 0).ToDirectionInt(); @@ -394,7 +394,7 @@ namespace CalamityMod.NPCs } flyInertia = 10f; - npc.velocity = (npc.velocity * (flyInertia - 1f) + npc.DirectionTo(spotToLayEgg) * flySpeed) / flyInertia; + npc.velocity = (npc.velocity * (flyInertia - 1f) + npc.SafeDirectionTo(spotToLayEgg, -Vector2.UnitY) * flySpeed) / flyInertia; break; case MothronAIState.LayEgg: @@ -435,7 +435,7 @@ namespace CalamityMod.NPCs if (distanceFromSpot < hoverSpeed) hoverSpeed = distanceFromSpot; - Vector2 hoverVelocity = npc.DirectionTo(spotToLayEgg).SafeNormalize(Vector2.Zero) * hoverSpeed; + Vector2 hoverVelocity = npc.SafeDirectionTo(spotToLayEgg) * hoverSpeed; npc.velocity = (npc.velocity * (hoverInertia - 1f) + hoverVelocity) / hoverInertia; if (npc.velocity.HasNaNs()) npc.velocity = Vector2.Zero; diff --git a/NPCs/GreatSandShark/GreatSandShark.cs b/NPCs/GreatSandShark/GreatSandShark.cs index b0ef826df5..128392b785 100644 --- a/NPCs/GreatSandShark/GreatSandShark.cs +++ b/NPCs/GreatSandShark/GreatSandShark.cs @@ -413,8 +413,9 @@ namespace CalamityMod.NPCs.GreatSandShark (float)Main.rand.Next(-3, 4), (float)Main.rand.Next(-12, -6), ModContent.ProjectileType(), 40, 0f, Main.myPlayer, 0f, 0f); } npc.ai[2] = -30f; - Vector2 vector261 = npc.DirectionTo(vector260 + new Vector2(0f, -80f)); - npc.velocity = vector261 * 18f; + + Vector2 upwardChargeDirection = npc.SafeDirectionTo(vector260 + new Vector2(0f, -80f), -Vector2.UnitY); + npc.velocity = upwardChargeDirection * 18f; } } else diff --git a/NPCs/NormalNPCs/WulfrumDrone.cs b/NPCs/NormalNPCs/WulfrumDrone.cs index 65da9fa6dc..eea07039dc 100644 --- a/NPCs/NormalNPCs/WulfrumDrone.cs +++ b/NPCs/NormalNPCs/WulfrumDrone.cs @@ -118,8 +118,9 @@ namespace CalamityMod.NPCs.NormalNPCs { if (npc.direction == 0) npc.direction = 1; + Vector2 destination = player.Center + new Vector2(300f * npc.direction, -90f); - npc.velocity = Vector2.Lerp(npc.velocity, npc.DirectionTo(destination) * 8f, 0.1f); + npc.velocity = Vector2.Lerp(npc.velocity, npc.SafeDirectionTo(destination) * 8f, 0.1f); if (npc.Distance(destination) < 40f) { Time++; @@ -134,13 +135,11 @@ namespace CalamityMod.NPCs.NormalNPCs else { if (HorizontalChargeTime < 25) - { - npc.velocity = Vector2.Lerp(npc.velocity, npc.DirectionTo(player.Center) * 8f, 0.1f); - } + npc.velocity = Vector2.Lerp(npc.velocity, npc.SafeDirectionTo(player.Center) * 8f, 0.1f); + if (Supercharged && Main.netMode != NetmodeID.MultiplayerClient && HorizontalChargeTime % 30f == 29f) - { - Projectile.NewProjectile(npc.Center + Vector2.UnitX * 6f * npc.spriteDirection, npc.DirectionTo(player.Center) * 6f, ProjectileID.MartianTurretBolt, 14, 0f); - } + Projectile.NewProjectile(npc.Center + Vector2.UnitX * 6f * npc.spriteDirection, npc.SafeDirectionTo(player.Center, Vector2.UnitY) * 6f, ProjectileID.MartianTurretBolt, 14, 0f); + HorizontalChargeTime++; if (HorizontalChargeTime > TotalHorizontalChargeTime) { diff --git a/NPCs/NormalNPCs/WulfrumHovercraft.cs b/NPCs/NormalNPCs/WulfrumHovercraft.cs index 01802fe5e9..7ca82fe54c 100644 --- a/NPCs/NormalNPCs/WulfrumHovercraft.cs +++ b/NPCs/NormalNPCs/WulfrumHovercraft.cs @@ -167,11 +167,11 @@ namespace CalamityMod.NPCs.NormalNPCs AIState == HovercraftAIState.Hover) { Vector2 destination = player.Center + new Vector2(SearchXOffset * SearchDirection, -160f); - npc.velocity = npc.DirectionTo(destination) * (Supercharged ? 8.5f : 6f); + npc.velocity = npc.SafeDirectionTo(destination, Vector2.UnitY) * (Supercharged ? 8.5f : 6f); if (AIState == HovercraftAIState.Hover) { destination = player.Center + new Vector2(SearchXOffset * -SearchDirection, -160f); - npc.velocity = npc.DirectionTo(destination) * (Supercharged ? 7f : 5f); + npc.velocity = npc.SafeDirectionTo(destination, Vector2.UnitY) * (Supercharged ? 7f : 5f); } npc.rotation = npc.velocity.X / 16f; diff --git a/NPCs/SulphurousSea/AnthozoanCrab.cs b/NPCs/SulphurousSea/AnthozoanCrab.cs index 52109275aa..841ac5bf93 100644 --- a/NPCs/SulphurousSea/AnthozoanCrab.cs +++ b/NPCs/SulphurousSea/AnthozoanCrab.cs @@ -129,11 +129,9 @@ namespace CalamityMod.NPCs.SulphurousSea } else if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) { - npc.direction = npc.spriteDirection = (npc.DirectionTo(player.Center).X < 0).ToDirectionInt(); + npc.direction = npc.spriteDirection = (npc.SafeDirectionTo(player.Center).X < 0).ToDirectionInt(); if (Math.Abs(npc.velocity.X) < 14f && Math.Abs(player.Center.X - npc.Center.X) > 65f) - { npc.velocity.X += npc.spriteDirection * -0.08f; - } } } else diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index 06afd5420e..d1fa1b6fc3 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -1723,7 +1723,7 @@ namespace CalamityMod.NPCs.Yharon npc.ai[2] = (vectorCenter.X < targetData.Center.X) ? 1 : -1; Vector2 destination = targetData.Center + new Vector2(-npc.ai[2], 0f); - Vector2 desiredVelocity = npc.DirectionTo(destination) * velocity; + Vector2 desiredVelocity = npc.SafeDirectionTo(destination) * velocity; if (!targetDead) { @@ -1882,7 +1882,7 @@ namespace CalamityMod.NPCs.Yharon if (num28 == 5 && npc.ai[1] < phaseSwitchTimer + teleportPhaseTimer) { - float newRotation = npc.DirectionTo(targetData.Center).ToRotation(); + float newRotation = npc.AngleTo(targetData.Center); float amount = 0.04f; if (npc.spriteDirection == -1) @@ -1915,7 +1915,7 @@ namespace CalamityMod.NPCs.Yharon if (num28 == 7 && doFastChargeTelegraph) { - float newRotation = npc.DirectionTo(targetData.Center).ToRotation(); + float newRotation = npc.AngleTo(targetData.Center); float amount = 0.04f; if (npc.spriteDirection == -1) @@ -1989,7 +1989,7 @@ namespace CalamityMod.NPCs.Yharon { case 2: //charge { - Vector2 vector = npc.DirectionTo(targetData.Center); + Vector2 vector = npc.SafeDirectionTo(targetData.Center, Vector2.UnitX * npc.spriteDirection); npc.spriteDirection = (vector.X > 0f) ? 1 : -1; npc.rotation = vector.ToRotation(); @@ -2010,7 +2010,7 @@ namespace CalamityMod.NPCs.Yharon } case 5: //spin move { - Vector2 vector3 = npc.DirectionTo(targetData.Center); + Vector2 vector3 = npc.SafeDirectionTo(targetData.Center, Vector2.UnitX * npc.spriteDirection); npc.spriteDirection = (vector3.X > 0f) ? 1 : -1; npc.rotation = vector3.ToRotation(); @@ -2023,7 +2023,7 @@ namespace CalamityMod.NPCs.Yharon } case 7: //fast charge { - Vector2 vector = npc.DirectionTo(targetData.Center); + Vector2 vector = npc.SafeDirectionTo(targetData.Center, Vector2.UnitX * npc.spriteDirection); npc.spriteDirection = (vector.X > 0f) ? 1 : -1; npc.rotation = vector.ToRotation(); @@ -2066,7 +2066,7 @@ namespace CalamityMod.NPCs.Yharon if (npc.ai[1] < fireballBreathTimer) { Vector2 vector4 = targetData.Center + new Vector2(num29 * -750f, -300f); - Vector2 value = npc.DirectionTo(vector4) * 16f; + Vector2 value = npc.SafeDirectionTo(vector4) * 16f; if (npc.Distance(vector4) < 16f) npc.Center = vector4; @@ -2120,7 +2120,7 @@ namespace CalamityMod.NPCs.Yharon if (npc.ai[1] < splittingFireballBreathTimer) { Vector2 vector5 = targetData.Center + new Vector2(num31 * -750f, -300f); - Vector2 value2 = npc.DirectionTo(vector5) * splittingFireballBreathPhaseVelocity; + Vector2 value2 = npc.SafeDirectionTo(vector5) * splittingFireballBreathPhaseVelocity; npc.velocity = Vector2.Lerp(npc.velocity, value2, 0.0333333351f); @@ -2132,7 +2132,7 @@ namespace CalamityMod.NPCs.Yharon } else if (npc.ai[1] == splittingFireballBreathTimer) { - Vector2 vector6 = npc.DirectionTo(targetData.Center); + Vector2 vector6 = npc.SafeDirectionTo(targetData.Center, Vector2.UnitX * npc.spriteDirection); vector6.Y *= 0.15f; vector6 = vector6.SafeNormalize(Vector2.UnitX * npc.direction); @@ -2146,8 +2146,8 @@ namespace CalamityMod.NPCs.Yharon } else { - npc.position.X += npc.DirectionTo(targetData.Center).X * 7f; - npc.position.Y += npc.DirectionTo(targetData.Center + new Vector2(0f, -400f)).Y * 6f; + npc.position.X += npc.SafeDirectionTo(targetData.Center).X * 7f; + npc.position.Y += npc.SafeDirectionTo(targetData.Center + new Vector2(0f, -400f)).Y * 6f; float xOffset = 30f; Vector2 position = vectorCenter + new Vector2((110f + xOffset) * npc.direction, -20f).RotatedBy(npc.rotation); @@ -2277,7 +2277,7 @@ namespace CalamityMod.NPCs.Yharon if (npc.ai[1] == 0f) { Vector2 destination2 = targetData.Center + new Vector2(0f, -200f); - Vector2 desiredVelocity2 = npc.DirectionTo(destination2) * velocity * 1.5f; + Vector2 desiredVelocity2 = npc.SafeDirectionTo(destination2) * velocity * 1.5f; npc.SimpleFlyMovement(desiredVelocity2, acceleration * 1.5f); int num35 = (vectorCenter.X < targetData.Center.X) ? 1 : -1; @@ -2400,7 +2400,7 @@ namespace CalamityMod.NPCs.Yharon { npc.velocity *= 0.9f; - Vector2 vector = npc.DirectionTo(targetData.Center); + Vector2 vector = npc.SafeDirectionTo(targetData.Center, -Vector2.UnitY); npc.spriteDirection = (vector.X > 0f) ? 1 : -1; npc.rotation = vector.ToRotation(); @@ -2444,7 +2444,7 @@ namespace CalamityMod.NPCs.Yharon } } - float num42 = npc.DirectionTo(targetData.Center).ToRotation(); + float num42 = npc.AngleTo(targetData.Center); float num43 = 0.04f; switch ((int)npc.ai[0]) diff --git a/Projectiles/BaseProjectiles/BaseSpearProjectile.cs b/Projectiles/BaseProjectiles/BaseSpearProjectile.cs index e766d1ed90..fa3b703f08 100644 --- a/Projectiles/BaseProjectiles/BaseSpearProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseSpearProjectile.cs @@ -123,15 +123,12 @@ namespace CalamityMod.Projectiles.BaseProjectiles new Vector2(originalVelocitySpeed + TravelSpeed, 0f).RotatedBy(originalVelocityDirection); // Determine how to rotate. The larger the 40 value is, the more rapidly the projectile rotates. - Vector2 destination = playerRelativePoint + flatVelocity.RotatedBy(originalVelocityDirection) + - new Vector2(originalVelocitySpeed + TravelSpeed + 40f, 0f).RotatedBy(originalVelocityDirection); + Vector2 destination = playerRelativePoint + flatVelocity.RotatedBy(originalVelocityDirection) + originalVelocityDirection.ToRotationVector2() * (originalVelocitySpeed + TravelSpeed + 40f); projectile.rotation = player.AngleTo(destination) + MathHelper.PiOver4 * player.direction; //or this // Rotate 180 degrees if facing to the right if (projectile.spriteDirection == -1) projectile.rotation += MathHelper.Pi; - - player.DirectionTo(projectile.Center); } // Kill the hook if the player's item use cycle is almost over and reset the reuseDelay diff --git a/Projectiles/Boss/BrimstoneGigaBlast.cs b/Projectiles/Boss/BrimstoneGigaBlast.cs index 2d45188373..cf628bb7ae 100644 --- a/Projectiles/Boss/BrimstoneGigaBlast.cs +++ b/Projectiles/Boss/BrimstoneGigaBlast.cs @@ -68,11 +68,8 @@ namespace CalamityMod.Projectiles.Boss { if (projectile.Distance(Main.player[target].Center) > minDist) { - Vector2 targetVec = projectile.DirectionTo(Main.player[target].Center); - if (targetVec.HasNaNs()) - targetVec = Vector2.UnitY; - - projectile.velocity = (projectile.velocity * (inertia - 1f) + targetVec * homeSpeed) / inertia; + Vector2 moveDirection = projectile.SafeDirectionTo(Main.player[target].Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * (inertia - 1f) + moveDirection * homeSpeed) / inertia; } } else diff --git a/Projectiles/Boss/BrimstoneMonster.cs b/Projectiles/Boss/BrimstoneMonster.cs index 441c96c88c..7573d1a257 100644 --- a/Projectiles/Boss/BrimstoneMonster.cs +++ b/Projectiles/Boss/BrimstoneMonster.cs @@ -116,11 +116,8 @@ namespace CalamityMod.Projectiles.Boss { if (projectile.Distance(Main.player[target].Center) > minDist) { - Vector2 targetVec = projectile.DirectionTo(Main.player[target].Center); - if (targetVec.HasNaNs()) - targetVec = Vector2.UnitY; - - projectile.velocity = (projectile.velocity * (inertia - 1f) + targetVec * speed) / inertia; + Vector2 moveDirection = projectile.SafeDirectionTo(Main.player[target].Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * (inertia - 1f) + moveDirection * speed) / inertia; } } else diff --git a/Projectiles/Boss/FlareBomb.cs b/Projectiles/Boss/FlareBomb.cs index b8e74f36c6..49c4f1dc9c 100644 --- a/Projectiles/Boss/FlareBomb.cs +++ b/Projectiles/Boss/FlareBomb.cs @@ -71,12 +71,8 @@ namespace CalamityMod.Projectiles.Boss { if (projectile.Distance(Main.player[num959].Center) > num954) { - Vector2 vector102 = projectile.DirectionTo(Main.player[num959].Center); - if (vector102.HasNaNs()) - { - vector102 = Vector2.UnitY; - } - projectile.velocity = (projectile.velocity * (inertia - 1f) + vector102 * scaleFactor12) / inertia; + Vector2 moveDirection = projectile.SafeDirectionTo(Main.player[num959].Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * (inertia - 1f) + moveDirection * scaleFactor12) / inertia; } } else diff --git a/Projectiles/Boss/ScavengerNuke.cs b/Projectiles/Boss/ScavengerNuke.cs index 9ca45f8dca..26db926959 100644 --- a/Projectiles/Boss/ScavengerNuke.cs +++ b/Projectiles/Boss/ScavengerNuke.cs @@ -61,11 +61,8 @@ namespace CalamityMod.Projectiles.Boss { if (projectile.Distance(Main.player[num959].Center) > 320f) { - Vector2 vector102 = projectile.DirectionTo(Main.player[num959].Center); - if (vector102.HasNaNs()) - vector102 = Vector2.UnitY; - - projectile.velocity = (projectile.velocity * (inertia - 1f) + vector102 * scaleFactor12) / inertia; + Vector2 moveDirection = projectile.SafeDirectionTo(Main.player[num959].Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * (inertia - 1f) + moveDirection * scaleFactor12) / inertia; } } else diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index c8e93b1cb8..2853ace474 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -295,7 +295,7 @@ namespace CalamityMod.Projectiles // If the needle is not colliding with the target, attempt to move towards it while falling. if (!projectile.WithinRange(npcToHeal.Center, initialSpeed) && !projectile.Hitbox.Intersects(npcToHeal.Hitbox)) { - Vector2 flySpeed = projectile.DirectionTo(npcToHeal.Center) * initialSpeed; + Vector2 flySpeed = projectile.SafeDirectionTo(npcToHeal.Center) * initialSpeed; // Prevent the needle from ever violating its gravity. if (flySpeed.Y < projectile.velocity.Y) @@ -1158,11 +1158,8 @@ namespace CalamityMod.Projectiles if (homeIn) { - Vector2 homeInVector = projectile.DirectionTo(center); - if (homeInVector.HasNaNs()) - homeInVector = Vector2.UnitY; - - projectile.velocity = (projectile.velocity * 20f + homeInVector * 15f) / 21f; + Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * 20f + moveDirection * 15f) / 21f; } } diff --git a/Projectiles/DraedonsArsenal/FrequencyManipulatorEnergy.cs b/Projectiles/DraedonsArsenal/FrequencyManipulatorEnergy.cs index 9a73005d4d..0c031c9b1f 100644 --- a/Projectiles/DraedonsArsenal/FrequencyManipulatorEnergy.cs +++ b/Projectiles/DraedonsArsenal/FrequencyManipulatorEnergy.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { float oldSpeed = projectile.velocity.Length(); float inertia = MathHelper.Lerp(15f, 4f, Utils.InverseLerp(Lifetime, Lifetime - 60f, projectile.timeLeft, true)); - projectile.velocity = (projectile.velocity * inertia + projectile.DirectionTo(potentialTarget.Center) * oldSpeed) / (inertia + 1f); + projectile.velocity = (projectile.velocity * inertia + projectile.SafeDirectionTo(potentialTarget.Center, -Vector2.UnitY) * oldSpeed) / (inertia + 1f); projectile.velocity = projectile.velocity.SafeNormalize(Vector2.UnitX) * oldSpeed; } } diff --git a/Projectiles/DraedonsArsenal/MountedScannerSummon.cs b/Projectiles/DraedonsArsenal/MountedScannerSummon.cs index 8e1fb15626..7aa8217b05 100644 --- a/Projectiles/DraedonsArsenal/MountedScannerSummon.cs +++ b/Projectiles/DraedonsArsenal/MountedScannerSummon.cs @@ -110,12 +110,13 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.rotation = projectile.AngleTo(target.Center); if (!Collision.CanHitLine(projectile.position, projectile.width, projectile.height, target.position, target.width, target.height)) return; + if (Time % 80f == 79f) { if (projectile.owner == Main.myPlayer) { Projectile.NewProjectile(projectile.Center, - projectile.DirectionTo(target.Center), + projectile.SafeDirectionTo(target.Center, Vector2.UnitY), ModContent.ProjectileType(), projectile.damage, projectile.knockBack, diff --git a/Projectiles/DraedonsArsenal/PhaseslayerBeam.cs b/Projectiles/DraedonsArsenal/PhaseslayerBeam.cs index be15c6b92f..b79472f354 100644 --- a/Projectiles/DraedonsArsenal/PhaseslayerBeam.cs +++ b/Projectiles/DraedonsArsenal/PhaseslayerBeam.cs @@ -36,9 +36,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; NPC potentialTarget = projectile.Center.ClosestNPCAt(1000f); if (potentialTarget != null && projectile.Distance(potentialTarget.Center) > 40f && projectile.timeLeft > Lifetime - 60) - { - projectile.velocity = (projectile.velocity * 7f + projectile.DirectionTo(potentialTarget.Center) * 24f) / 8f; - } + projectile.velocity = (projectile.velocity * 7f + projectile.SafeDirectionTo(potentialTarget.Center, -Vector2.UnitY) * 24f) / 8f; + projectile.frameCounter++; } diff --git a/Projectiles/DraedonsArsenal/PoleWarperSummon.cs b/Projectiles/DraedonsArsenal/PoleWarperSummon.cs index dd6e6f73c3..61f235d734 100644 --- a/Projectiles/DraedonsArsenal/PoleWarperSummon.cs +++ b/Projectiles/DraedonsArsenal/PoleWarperSummon.cs @@ -116,7 +116,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public void PlayerMovement(Player player) { Vector2 destination = player.Center + Vector2.UnitY.RotatedBy(Time / 16f + AngularOffset + (!North).ToInt() * MathHelper.Pi) * 180f; - projectile.velocity = (projectile.velocity * 4f + projectile.DirectionTo(destination) * 10f) / 5f; + projectile.velocity = (projectile.velocity * 4f + projectile.SafeDirectionTo(destination) * 10f) / 5f; projectile.velocity = projectile.velocity.SafeNormalize(Vector2.UnitY) * 10f; projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; } @@ -140,7 +140,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { float offsetAngle = AngularOffset * 0.5f + (!North).ToInt() * MathHelper.Pi; Vector2 destination = npc.Center + Vector2.UnitY.RotatedBy(offsetAngle) * 180f; - projectile.velocity = (projectile.velocity * 4f + projectile.DirectionTo(destination) * 10f) / 5f; + projectile.velocity = (projectile.velocity * 4f + projectile.SafeDirectionTo(destination) * 10f) / 5f; projectile.velocity = projectile.velocity.SafeNormalize(Vector2.UnitY) * 25f; projectile.rotation = projectile.AngleTo(npc.Center) + MathHelper.PiOver2; } @@ -151,7 +151,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal } else if (Time % 60f == 35f) { - projectile.velocity = projectile.DirectionTo(npc.Center) * 29f; + projectile.velocity = projectile.SafeDirectionTo(npc.Center, -Vector2.UnitY) * 29f; projectile.rotation = projectile.AngleTo(npc.Center) + MathHelper.PiOver2; } } diff --git a/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs b/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs index 63cf0f7931..820a4a8edd 100644 --- a/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs +++ b/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs @@ -20,22 +20,12 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.timeLeft = ReelbackTime; } } + + public Player Owner => Main.player[projectile.owner]; public float Outwardness => OutwardnessMax * (float)Math.Sin(projectile.timeLeft / (float)Lifetime * MathHelper.Pi); - public float InitialRotation - { - get => projectile.ai[0]; - set => projectile.ai[0] = value; - } - public float OutwardnessMax - { - get => projectile.ai[1]; - set => projectile.ai[1] = value; - } - public float SwingDirection - { - get => projectile.localAI[0]; - set => projectile.localAI[0] = value; - } + public ref float InitialRotation => ref projectile.ai[0]; + public ref float OutwardnessMax => ref projectile.ai[1]; + public ref float SwingDirection => ref projectile.localAI[0]; public const int ChargeTime = 25; public const int ReelbackTime = 25; public const int Lifetime = ChargeTime + ReelbackTime; @@ -74,17 +64,17 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void AI() { - Player player = Main.player[projectile.owner]; - projectile.rotation = projectile.AngleTo(player.Center) - MathHelper.PiOver2; - if (player.dead) + projectile.rotation = projectile.AngleTo(Owner.Center) - MathHelper.PiOver2; + if (Owner.dead) { projectile.Kill(); return; } - projectile.direction = (player.Center.X - projectile.Center.X > 0).ToDirectionInt(); + projectile.direction = (Owner.Center.X - projectile.Center.X > 0).ToDirectionInt(); projectile.spriteDirection = projectile.direction; - ManipulatePlayer(player); + + ManipulateOwnerFields(); if (projectile.timeLeft >= Lifetime - ChargeTime) { @@ -95,30 +85,30 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.velocity = InitialRotation.ToRotationVector2().RotatedBy(offsetAngle) * 29f; // Adjust the velocity to go along with the player's if the velocity directions are similar so that the player's movement doesn't hinder the projectile's movement. - if (Vector2.Dot(projectile.velocity.SafeNormalize(Vector2.Zero), player.velocity.SafeNormalize(Vector2.Zero)) > 0.45f) + if (Vector2.Dot(projectile.velocity.SafeNormalize(Vector2.Zero), Owner.velocity.SafeNormalize(Vector2.Zero)) > 0.45f) { - projectile.velocity += player.velocity; + projectile.velocity += Owner.velocity; } } else { - projectile.velocity = projectile.DirectionTo(player.Center) * 43f; + projectile.velocity = projectile.SafeDirectionTo(Owner.Center, Vector2.UnitX * Owner.direction) * 43f; projectile.timeLeft = ReelbackTime; - if (projectile.Distance(player.Center) < 45f) + if (projectile.WithinRange(Owner.Center, 45f)) projectile.Kill(); } GenerateIdleDust(); - if (projectile.timeLeft % 3 == 2 && projectile.Distance(player.Center) > 40f) + if (projectile.timeLeft % 3 == 2 && projectile.Distance(Owner.Center) > 40f) SpawnElectricFields(); } - public void ManipulatePlayer(Player player) + public void ManipulateOwnerFields() { - player.itemAnimation = 4; - player.itemTime = 4; - player.ChangeDir(-projectile.direction); - player.itemRotation = projectile.rotation + (projectile.spriteDirection == -1).ToInt() * MathHelper.TwoPi; + Owner.itemAnimation = 4; + Owner.itemTime = 4; + Owner.ChangeDir(-projectile.direction); + Owner.itemRotation = projectile.rotation + (projectile.spriteDirection == -1).ToInt() * MathHelper.TwoPi; } public void GenerateIdleDust() @@ -166,7 +156,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { Vector2 offset = Vector2.UnitX * -SwingDirection; offset *= Outwardness * (float)Math.Sin(i / 20f * MathHelper.Pi); - offset *= Utils.InverseLerp(0f, 300f, player.Distance(Vector2.Lerp(mountedCenter, projectile.Center, i / 20f) + offset), true); + offset *= Utils.InverseLerp(0f, 300f, Owner.Distance(Vector2.Lerp(mountedCenter, projectile.Center, i / 20f) + offset), true); bezierPoints.Add(Vector2.Lerp(mountedCenter, projectile.Center, i / 20f) + offset); } bezierPoints.Add(projectile.Center); diff --git a/Projectiles/DraedonsArsenal/PulseRifleShot.cs b/Projectiles/DraedonsArsenal/PulseRifleShot.cs index db0e21a7cf..375366e4ae 100644 --- a/Projectiles/DraedonsArsenal/PulseRifleShot.cs +++ b/Projectiles/DraedonsArsenal/PulseRifleShot.cs @@ -100,10 +100,9 @@ namespace CalamityMod.Projectiles.DraedonsArsenal if (!Main.npc[i].CanBeChasedBy(projectile, false) || !Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) continue; - if (alreadyTargetedNPCType != Main.npc[i].whoAmI && - projectile.Center.ManhattanDistance(Main.npc[i].Center) < 600f) + if (alreadyTargetedNPCType != Main.npc[i].whoAmI && projectile.Center.ManhattanDistance(Main.npc[i].Center) < 600f) { - Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(Main.npc[i].Center) * 5f, projectile.type, projectile.damage / 2, 0f, projectile.owner, Main.npc[i].whoAmI, projectile.ai[1] + 1f); + Projectile.NewProjectile(projectile.Center, projectile.SafeDirectionTo(Main.npc[i].Center) * 5f, projectile.type, projectile.damage / 2, 0f, projectile.owner, Main.npc[i].whoAmI, projectile.ai[1] + 1f); break; } } diff --git a/Projectiles/DraedonsArsenal/PulseTurret.cs b/Projectiles/DraedonsArsenal/PulseTurret.cs index 527b191ef7..e01f1347e2 100644 --- a/Projectiles/DraedonsArsenal/PulseTurret.cs +++ b/Projectiles/DraedonsArsenal/PulseTurret.cs @@ -91,7 +91,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal for (int i = -1; i <= 1; i += 2) { Projectile.NewProjectile(shootPosition, - Vector2.Normalize(potentialTarget.Center - shootPosition).RotatedBy(i * MathHelper.ToRadians(28f)) * 7f, + (potentialTarget.Center - shootPosition).SafeNormalize(Vector2.UnitY).RotatedBy(i * MathHelper.ToRadians(28f)) * 7f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, @@ -100,15 +100,15 @@ namespace CalamityMod.Projectiles.DraedonsArsenal 1f); } } + if (!Main.dedServ) { for (int i = 0; i < 12; i++) - { Dust.NewDustPerfect(shootPosition, 173).scale = Main.rand.NextFloat(1.4f, 1.8f); - } } + projectile.ai[1] = 15f; - projectile.localAI[0] = Math.Sign(projectile.DirectionTo(potentialTarget.Center).X); + projectile.localAI[0] = Math.Sign(projectile.SafeDirectionTo(potentialTarget.Center).X); } } } diff --git a/Projectiles/DraedonsArsenal/PulseTurretShot.cs b/Projectiles/DraedonsArsenal/PulseTurretShot.cs index ae3ede808c..88f051de21 100644 --- a/Projectiles/DraedonsArsenal/PulseTurretShot.cs +++ b/Projectiles/DraedonsArsenal/PulseTurretShot.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { float speed = projectile.velocity.Length(); float inertia = MathHelper.Lerp(18f, 6f, 1f - projectile.timeLeft / 300f); - projectile.velocity = (projectile.velocity * inertia + projectile.DirectionTo(potentialTarget.Center) * speed) / (inertia + 1f); + projectile.velocity = (projectile.velocity * inertia + projectile.SafeDirectionTo(potentialTarget.Center) * speed) / (inertia + 1f); projectile.velocity = projectile.velocity.SafeNormalize(Vector2.UnitX) * speed; } } @@ -71,7 +71,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Dust dust = Dust.NewDustPerfect(projectile.Center + Vector2.UnitY.RotatedBy(j / (float)SpiralRings * MathHelper.TwoPi * direction).RotatedBy(i / (float)SpiralPrecision * MathHelper.TwoPi / SpiralRings * direction) * 36f * i / SpiralPrecision, 173); - dust.velocity = projectile.DirectionTo(dust.position) * 2.4f; + dust.velocity = projectile.SafeDirectionTo(dust.position) * 2.4f; dust.scale = 1.6f; dust.noGravity = true; diff --git a/Projectiles/DraedonsArsenal/SnakeEyesSummon.cs b/Projectiles/DraedonsArsenal/SnakeEyesSummon.cs index 9253d9304b..5be2791c08 100644 --- a/Projectiles/DraedonsArsenal/SnakeEyesSummon.cs +++ b/Projectiles/DraedonsArsenal/SnakeEyesSummon.cs @@ -201,14 +201,15 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { if (projectile.ai[1] > 0 && Main.myPlayer == projectile.owner) { - Projectile laser = Projectile.NewProjectileDirect(projectile.Center + Utils.Vector2FromElipse(EyeRotation.ToRotationVector2(), projectile.Size * 0.5f * EyeOutwardness), - projectile.DirectionTo(npc.Center) * 4f, ProjectileID.UFOLaser, projectile.damage, projectile.knockBack, projectile.owner); - if (laser.whoAmI.WithinBounds(Main.maxProjectiles)) + Vector2 shootPosition = projectile.Center + Utils.Vector2FromElipse(EyeRotation.ToRotationVector2(), projectile.Size * 0.5f * EyeOutwardness); + Vector2 shootVelocity = projectile.SafeDirectionTo(npc.Center, Main.rand.NextVector2Unit()) * 4f; + int laser = Projectile.NewProjectile(shootPosition, shootVelocity, ProjectileID.UFOLaser, projectile.damage, projectile.knockBack, projectile.owner); + if (laser.WithinBounds(Main.maxProjectiles)) { - laser.timeLeft *= 2; - laser.tileCollide = false; - laser.netUpdate = true; - laser.Calamity().forceMinion = true; + Main.projectile[laser].timeLeft *= 2; + Main.projectile[laser].tileCollide = false; + Main.projectile[laser].netUpdate = true; + Main.projectile[laser].Calamity().forceMinion = true; } } projectile.ai[1]++; diff --git a/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs b/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs index 01eaccc70e..648aaa1eb4 100644 --- a/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs +++ b/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs @@ -222,7 +222,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal minimumFrame = 7; maximumFrame = 11; float inertia = 30f; - projectile.velocity = (projectile.velocity * (inertia - 1) + projectile.DirectionTo(player.Center) * 18f) / inertia; + projectile.velocity = (projectile.velocity * (inertia - 1) + projectile.SafeDirectionTo(player.Center) * 18f) / inertia; } // Otherwise hop around when on the ground. else if (projectile.oldPosition.Y == projectile.position.Y) diff --git a/Projectiles/DraedonsArsenal/SystemBaneProjectile.cs b/Projectiles/DraedonsArsenal/SystemBaneProjectile.cs index 4ecab38d9c..bdac20c2e8 100644 --- a/Projectiles/DraedonsArsenal/SystemBaneProjectile.cs +++ b/Projectiles/DraedonsArsenal/SystemBaneProjectile.cs @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { NPC potentialTarget = projectile.Center.ClosestNPCAt(900f); if (potentialTarget != null) - Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(potentialTarget.Center) * 15f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + Projectile.NewProjectile(projectile.Center, projectile.SafeDirectionTo(potentialTarget.Center) * 15f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); } // Sometimes generate lightning from the outside of the energy field if the projectile was spawned by a stealth strike. diff --git a/Projectiles/DraedonsArsenal/TaserHook.cs b/Projectiles/DraedonsArsenal/TaserHook.cs index 59940763fd..c81d074aca 100644 --- a/Projectiles/DraedonsArsenal/TaserHook.cs +++ b/Projectiles/DraedonsArsenal/TaserHook.cs @@ -84,7 +84,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal return; } projectile.tileCollide = false; - projectile.velocity = projectile.DirectionTo(player.Center) * ReelbackSpeed; + projectile.velocity = projectile.SafeDirectionTo(player.Center) * ReelbackSpeed; break; } @@ -136,9 +136,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Dust dust = Dust.NewDustPerfect(target.Center + angle.ToRotationVector2() * 10f, 226); dust.velocity = Vector2.Zero; if (Main.rand.NextBool(6)) - { - dust.velocity = target.DirectionTo(dust.position) * 4.5f; - } + dust.velocity = target.SafeDirectionTo(dust.position) * 4.5f; + dust.noGravity = true; } } diff --git a/Projectiles/DraedonsArsenal/TeslaCannonShot.cs b/Projectiles/DraedonsArsenal/TeslaCannonShot.cs index 0287414264..954725406c 100644 --- a/Projectiles/DraedonsArsenal/TeslaCannonShot.cs +++ b/Projectiles/DraedonsArsenal/TeslaCannonShot.cs @@ -109,7 +109,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal if (projectile.Center.ManhattanDistance(Main.npc[i].Center) < num474) { - Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(Main.npc[i].Center) * 2f, projectile.type, (int)(projectile.damage * 0.6), projectile.knockBack * 0.6f, projectile.owner, 0f, -1f); + Projectile.NewProjectile(projectile.Center, projectile.SafeDirectionTo(Main.npc[i].Center) * 2f, projectile.type, (int)(projectile.damage * 0.6), projectile.knockBack * 0.6f, projectile.owner, 0f, -1f); projectile.ai[1] = 60f; diff --git a/Projectiles/DraedonsArsenal/TrackingDiskProjectile.cs b/Projectiles/DraedonsArsenal/TrackingDiskProjectile.cs index dcfd2bacee..36394ba750 100644 --- a/Projectiles/DraedonsArsenal/TrackingDiskProjectile.cs +++ b/Projectiles/DraedonsArsenal/TrackingDiskProjectile.cs @@ -107,7 +107,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal if (targetCount >= MaxLaserCountPerShot) break; Projectile laser = Projectile.NewProjectileDirect(projectile.Center, - projectile.DirectionTo(target.Center) * 4f, + projectile.SafeDirectionTo(target.Center) * 4f, ModContent.ProjectileType(), damage, projectile.knockBack, @@ -123,7 +123,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal NPC potentialTarget = projectile.Center.ClosestNPCAt(MaxTargetSearchDistance); if (potentialTarget != null) { - Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(potentialTarget.Center) * 3f, ModContent.ProjectileType(), damage, projectile.knockBack, projectile.owner); + Projectile.NewProjectile(projectile.Center, projectile.SafeDirectionTo(potentialTarget.Center) * 3f, ModContent.ProjectileType(), damage, projectile.knockBack, projectile.owner); } } } diff --git a/Projectiles/DraedonsArsenal/UnstableMatter.cs b/Projectiles/DraedonsArsenal/UnstableMatter.cs index 63fcc2d8f1..59e15d27cb 100644 --- a/Projectiles/DraedonsArsenal/UnstableMatter.cs +++ b/Projectiles/DraedonsArsenal/UnstableMatter.cs @@ -90,7 +90,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal // And bounce off the tile. Or towards a nearby enemy, if there is one. NPC potentialTarget = projectile.Center.ClosestNPCAt(700f, false); if (potentialTarget != null) - projectile.velocity = projectile.DirectionTo(potentialTarget.Center); + projectile.velocity = projectile.SafeDirectionTo(potentialTarget.Center); else { if (projectile.velocity.X != oldVelocity.X) diff --git a/Projectiles/DraedonsArsenal/VoltageStream.cs b/Projectiles/DraedonsArsenal/VoltageStream.cs index 59b66142a3..a3d39e2e4a 100644 --- a/Projectiles/DraedonsArsenal/VoltageStream.cs +++ b/Projectiles/DraedonsArsenal/VoltageStream.cs @@ -80,9 +80,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Dust dust = Dust.NewDustPerfect(Target.Center + angle.ToRotationVector2() * radius, 226); dust.velocity = Vector2.Zero; if (Main.rand.NextBool(6)) - { - dust.velocity = Target.DirectionTo(dust.position) * 4.5f; - } + dust.velocity = Target.SafeDirectionTo(dust.position) * 4.5f; + dust.noGravity = true; } } diff --git a/Projectiles/Enemy/CragmawVibeCheckChain.cs b/Projectiles/Enemy/CragmawVibeCheckChain.cs index 8aca72cbba..0f194414d8 100644 --- a/Projectiles/Enemy/CragmawVibeCheckChain.cs +++ b/Projectiles/Enemy/CragmawVibeCheckChain.cs @@ -48,13 +48,13 @@ namespace CalamityMod.Projectiles.Enemy projectile.rotation = (Main.npc[(int)projectile.ai[0]].Top - projectile.Center + offsetDrawVector).ToRotation() + MathHelper.PiOver2; if (projectile.localAI[0] == 0f) { - projectile.velocity = (projectile.velocity * 10f + projectile.DirectionTo(Main.player[toTarget].Center) * 9f) / 11f; + projectile.velocity = (projectile.velocity * 10f + projectile.SafeDirectionTo(Main.player[toTarget].Center) * 9f) / 11f; if (projectile.timeLeft <= 180f) { projectile.localAI[0] = 1f; projectile.netUpdate = true; } - if (projectile.Distance(Main.player[toTarget].Center) < 16f) + if (projectile.WithinRange(Main.player[toTarget].Center, 16f)) { projectile.localAI[0] = 1f; ReelingPlayer = true; @@ -64,17 +64,13 @@ namespace CalamityMod.Projectiles.Enemy else { if (ReelingPlayer) - { Main.player[toTarget].Center = projectile.Center; - } + if (Main.player[toTarget].dead) - { ReelingPlayer = false; - } - if (projectile.Distance(Main.npc[(int)projectile.ai[0]].Center) > 6f) - { - projectile.velocity = (projectile.velocity * 16f + projectile.DirectionTo(Main.npc[(int)projectile.ai[0]].Center) * 19f) / 17f; - } + + if (!projectile.WithinRange(Main.npc[(int)projectile.ai[0]].Center, 6f)) + projectile.velocity = (projectile.velocity * 16f + projectile.SafeDirectionTo(Main.npc[(int)projectile.ai[0]].Center) * 19f) / 17f; } } diff --git a/Projectiles/Enemy/NuclearBulletMedium.cs b/Projectiles/Enemy/NuclearBulletMedium.cs index 71ab545c3c..b3c5df79b6 100644 --- a/Projectiles/Enemy/NuclearBulletMedium.cs +++ b/Projectiles/Enemy/NuclearBulletMedium.cs @@ -40,9 +40,8 @@ namespace CalamityMod.Projectiles.Enemy Player player = Main.player[(int)projectile.ai[1]]; float inertia = 10f; if (projectile.Distance(player.Center) > 70f) - { - projectile.velocity = (projectile.velocity * inertia + projectile.DirectionTo(player.Center) * 18.5f) / (inertia + 1f); - } + projectile.velocity = (projectile.velocity * inertia + projectile.SafeDirectionTo(player.Center) * 18.5f) / (inertia + 1f); + projectile.tileCollide = true; } else diff --git a/Projectiles/Magic/Crescent.cs b/Projectiles/Magic/Crescent.cs index bbf98cea75..5205767607 100644 --- a/Projectiles/Magic/Crescent.cs +++ b/Projectiles/Magic/Crescent.cs @@ -38,7 +38,8 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { Projectile parent = Main.projectile[(int)projectile.ai[0]]; - if (!parent.active) projectile.Kill(); + if (!parent.active) + projectile.Kill(); projectile.rotation += 0.7f; @@ -46,8 +47,9 @@ namespace CalamityMod.Projectiles.Magic if (projectile.ai[1] > 20) { - projectile.velocity += projectile.DirectionTo(parent.Center) * 2.5f; - if (projectile.Distance(parent.Center) < 75f) projectile.active = false; + projectile.velocity += projectile.SafeDirectionTo(parent.Center) * 2.5f; + if (projectile.WithinRange(parent.Center, 75f)) + projectile.Kill(); } } } diff --git a/Projectiles/Magic/DivineRetributionSpear.cs b/Projectiles/Magic/DivineRetributionSpear.cs index 494b174ae1..58e84f49c5 100644 --- a/Projectiles/Magic/DivineRetributionSpear.cs +++ b/Projectiles/Magic/DivineRetributionSpear.cs @@ -52,12 +52,8 @@ namespace CalamityMod.Projectiles.Magic { if (projectile.Distance(Main.player[projectile.owner].Center) > num954) { - Vector2 vector102 = projectile.DirectionTo(Main.player[projectile.owner].Center); - if (vector102.HasNaNs()) - { - vector102 = Vector2.UnitY; - } - projectile.velocity = (projectile.velocity * (num953 - 1f) + vector102 * scaleFactor12) / num953; + Vector2 moveDirection = projectile.SafeDirectionTo(Main.player[projectile.owner].Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * (num953 - 1f) + moveDirection * scaleFactor12) / num953; return; } diff --git a/Projectiles/Magic/EnormousConsumingVortex.cs b/Projectiles/Magic/EnormousConsumingVortex.cs index fda7befb91..f1e79ff552 100644 --- a/Projectiles/Magic/EnormousConsumingVortex.cs +++ b/Projectiles/Magic/EnormousConsumingVortex.cs @@ -113,9 +113,7 @@ namespace CalamityMod.Projectiles.Magic { NPC potentialTarget = projectile.Center.ClosestNPCAt(1500f, true, true); if (potentialTarget != null) - { - projectile.velocity = (projectile.velocity * 5f + projectile.DirectionTo(potentialTarget.Center) * 7f) / 6f; - } + projectile.velocity = (projectile.velocity * 5f + projectile.SafeDirectionTo(potentialTarget.Center) * 7f) / 6f; } public void PulseEffect() { @@ -162,7 +160,8 @@ namespace CalamityMod.Projectiles.Magic float rotation = Main.rand.NextFloat(MathHelper.TwoPi); Vector2 velocity = Vector2.UnitY.RotatedBy(rotation); if (closestTarget != null) - velocity = projectile.DirectionTo(closestTarget.Center).RotatedByRandom(0.4f); + velocity = projectile.SafeDirectionTo(closestTarget.Center, -Vector2.UnitY).RotatedByRandom(0.4f); + velocity *= Main.rand.NextFloat(3f, 5f); Projectile.NewProjectileDirect(projectile.Center, diff --git a/Projectiles/Magic/EternityCrystal.cs b/Projectiles/Magic/EternityCrystal.cs index 18d8d23858..d42866dc1c 100644 --- a/Projectiles/Magic/EternityCrystal.cs +++ b/Projectiles/Magic/EternityCrystal.cs @@ -90,9 +90,10 @@ namespace CalamityMod.Projectiles.Magic projectile.localAI[0] += 1f; if (projectile.timeLeft == 1 && !Collapsing) { - projectile.velocity = projectile.DirectionTo(target.Center) * 2f; + projectile.velocity = projectile.SafeDirectionTo(target.Center) * 2f; projectile.timeLeft = InwardCollapseTime; Collapsing = true; + projectile.netUpdate = true; } SpinAngle -= MathHelper.ToRadians(DegreesToSpin); diff --git a/Projectiles/Magic/EternityHoming.cs b/Projectiles/Magic/EternityHoming.cs index 4fe3a17bce..a208ef02a9 100644 --- a/Projectiles/Magic/EternityHoming.cs +++ b/Projectiles/Magic/EternityHoming.cs @@ -48,9 +48,8 @@ namespace CalamityMod.Projectiles.Magic } } if (target != null) - { - projectile.velocity = (projectile.velocity * 7f + projectile.DirectionTo(target.Center) * 10f) / 8f; - } + projectile.velocity = (projectile.velocity * 7f + projectile.SafeDirectionTo(target.Center) * 10f) / 8f; + projectile.ai[0] += 0.18f; float angle = projectile.velocity.ToRotation() + MathHelper.PiOver2; float pulse = (float)Math.Sin(projectile.ai[0]); diff --git a/Projectiles/Magic/EventHorizonStar.cs b/Projectiles/Magic/EventHorizonStar.cs index 1b6fa190c2..115e28862e 100644 --- a/Projectiles/Magic/EventHorizonStar.cs +++ b/Projectiles/Magic/EventHorizonStar.cs @@ -89,7 +89,7 @@ namespace CalamityMod.Projectiles.Magic Vector2 center = projectile.Center; float homingRange = 800f; bool homeIn = false; - float N = 30f; + float inertia = 30f; float homingVelocity = 20f; for (int i = 0; i < Main.maxNPCs; i++) @@ -110,11 +110,9 @@ namespace CalamityMod.Projectiles.Magic if (homeIn) { projectile.extraUpdates = 1; - Vector2 homeInVector = projectile.DirectionTo(center); - if (homeInVector.HasNaNs()) - homeInVector = Vector2.UnitY; + Vector2 homeInVector = projectile.SafeDirectionTo(center, Vector2.UnitY); - projectile.velocity = (projectile.velocity * N + homeInVector * homingVelocity) / (N + 1f); + projectile.velocity = (projectile.velocity * inertia + homeInVector * homingVelocity) / (inertia + 1f); } else projectile.extraUpdates = 0; diff --git a/Projectiles/Magic/FatesRevealFlame.cs b/Projectiles/Magic/FatesRevealFlame.cs index 84963b257b..99c3278896 100644 --- a/Projectiles/Magic/FatesRevealFlame.cs +++ b/Projectiles/Magic/FatesRevealFlame.cs @@ -95,9 +95,8 @@ namespace CalamityMod.Projectiles.Magic 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.DirectionTo(dust13.position) * 3f; - } + dust13.velocity = projectile.SafeDirectionTo(dust13.position) * 3f; + num3 = num955; } } @@ -105,12 +104,8 @@ namespace CalamityMod.Projectiles.Magic { if (projectile.Distance(Main.player[projectile.owner].Center) > num950) { - Vector2 vector118 = projectile.DirectionTo(Main.player[projectile.owner].Center); - if (vector118.HasNaNs()) - { - vector118 = Vector2.UnitY; - } - projectile.velocity = (projectile.velocity * (num949 - 1f) + vector118 * scaleFactor11) / num949; + Vector2 moveDirection = projectile.SafeDirectionTo(Main.player[projectile.owner].Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * (num949 - 1f) + moveDirection * scaleFactor11) / num949; } } else diff --git a/Projectiles/Magic/LightBlade.cs b/Projectiles/Magic/LightBlade.cs index e7f1972e26..d6c225ead4 100644 --- a/Projectiles/Magic/LightBlade.cs +++ b/Projectiles/Magic/LightBlade.cs @@ -70,7 +70,7 @@ namespace CalamityMod.Projectiles.Magic projectile.ai[1] = 0f; else { - Vector2 homingVec = projectile.DirectionTo(paired.Center) * projectile.ai[0]; + Vector2 homingVec = projectile.SafeDirectionTo(paired.Center) * projectile.ai[0]; projectile.velocity = (projectile.velocity * (SwordHomingStrength - 1f) + homingVec) / SwordHomingStrength; } } diff --git a/Projectiles/Magic/StratusSphereProj.cs b/Projectiles/Magic/StratusSphereProj.cs index 07e0488fad..07d03804aa 100644 --- a/Projectiles/Magic/StratusSphereProj.cs +++ b/Projectiles/Magic/StratusSphereProj.cs @@ -54,20 +54,22 @@ namespace CalamityMod.Projectiles.Magic { projectile.velocity.X = projectile.velocity.X * 10 / 11; projectile.velocity.Y = projectile.velocity.Y * 10 / 11; - if (roundsGone <= 4) projectile.ai[1]++; + if (roundsGone <= 4) + projectile.ai[1]++; + int rand = Main.rand.Next(-50, 51); int rand2 = Main.rand.Next(-50, 51); Vector2 targetDir = projectile.Center + new Vector2(rand, rand2); if (projectile.ai[1] > 40) - { - Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(targetDir) * 12f, ModContent.ProjectileType(), projectile.damage / 2, 0.4f, projectile.owner, projectile.whoAmI); - } + Projectile.NewProjectile(projectile.Center, projectile.SafeDirectionTo(targetDir) * 12f, ModContent.ProjectileType(), projectile.damage / 2, 0.4f, projectile.owner, projectile.whoAmI); + if (projectile.ai[1] > 46) { projectile.ai[1] = 0; roundsGone++; } - if (roundsGone > 4 && Main.player[projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()] == 0) projectile.Kill(); + if (roundsGone > 4 && Main.player[projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()] == 0) + projectile.Kill(); } projectile.frameCounter++; diff --git a/Projectiles/Magic/UndinesRetributionSpear.cs b/Projectiles/Magic/UndinesRetributionSpear.cs index fc5566674c..5701975589 100644 --- a/Projectiles/Magic/UndinesRetributionSpear.cs +++ b/Projectiles/Magic/UndinesRetributionSpear.cs @@ -61,12 +61,8 @@ namespace CalamityMod.Projectiles.Magic { if (projectile.Distance(Main.player[projectile.owner].Center) > num954) { - Vector2 vector102 = projectile.DirectionTo(Main.player[projectile.owner].Center); - if (vector102.HasNaNs()) - { - vector102 = Vector2.UnitY; - } - projectile.velocity = (projectile.velocity * (num953 - 1f) + vector102 * scaleFactor12) / num953; + Vector2 moveDirection = projectile.SafeDirectionTo(Main.player[projectile.owner].Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * (num953 - 1f) + moveDirection * scaleFactor12) / num953; return; } diff --git a/Projectiles/Melee/DragonRageFireball.cs b/Projectiles/Melee/DragonRageFireball.cs index 8338673f60..2635b5f79b 100644 --- a/Projectiles/Melee/DragonRageFireball.cs +++ b/Projectiles/Melee/DragonRageFireball.cs @@ -55,12 +55,8 @@ namespace CalamityMod.Projectiles.Melee { float inertia = projectile.ai[0]; float speed = projectile.ai[1]; - Vector2 targetPos = projectile.DirectionTo(target.Center); - if (targetPos.HasNaNs()) - { - targetPos = Vector2.UnitY; - } - projectile.velocity = (projectile.velocity * (inertia - 1f) + targetPos * speed) / inertia; + Vector2 moveDirection = projectile.SafeDirectionTo(target.Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * (inertia - 1f) + moveDirection * speed) / inertia; } } diff --git a/Projectiles/Melee/DragonRageStaff.cs b/Projectiles/Melee/DragonRageStaff.cs index 5a252533b9..cefe9f0692 100644 --- a/Projectiles/Melee/DragonRageStaff.cs +++ b/Projectiles/Melee/DragonRageStaff.cs @@ -68,21 +68,15 @@ namespace CalamityMod.Projectiles.Melee } else if (halfWay) { - int direction2 = (player.DirectionTo(Main.MouseWorld).X > 0f) ? 1 : -1; - if ((float)direction2 != projectile.velocity.X) + int expectedDirection = (player.SafeDirectionTo(Main.MouseWorld).X > 0f).ToDirectionInt(); + if (expectedDirection != projectile.velocity.X) { - player.ChangeDir(direction2); - projectile.velocity = new Vector2(direction2, 0f); - projectile.netUpdate = true; + player.ChangeDir(expectedDirection); + projectile.velocity = Vector2.UnitX * expectedDirection; projectile.rotation -= MathHelper.Pi; + projectile.netUpdate = true; } } - if ((projectile.ai[0] == 1f || (halfWay && projectile.active)) && projectile.owner == Main.myPlayer) - { - Vector2 mouse = player.DirectionTo(Main.MouseWorld) * 0f; - player.DirectionTo(mouse); - } - SpawnDust(player, direction); PositionAndRotation(player); VisibilityAndLight(); @@ -90,14 +84,15 @@ namespace CalamityMod.Projectiles.Melee private void SpawnDust(Player player, int direction) { - float num12 = projectile.rotation - MathHelper.PiOver4 * (float)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((double)(MathHelper.PiOver2 * projectile.spriteDirection), default); + Vector2 value4 = vector2.RotatedBy(MathHelper.PiOver2 * projectile.spriteDirection); + if (Main.rand.NextBool(2)) { Dust dust = Dust.NewDustDirect(value3 - new Vector2(5f), 10, 10, 244, player.velocity.X, player.velocity.Y, 150, default, 1f); - dust.velocity = projectile.DirectionTo(dust.position) * 0.1f + dust.velocity * 0.1f; + dust.velocity = projectile.SafeDirectionTo(dust.position) * 0.1f + dust.velocity * 0.1f; } for (int j = 0; j < 4; j++) { diff --git a/Projectiles/Melee/ElementalExcaliburBeam.cs b/Projectiles/Melee/ElementalExcaliburBeam.cs index 6edb8209b4..133a483495 100644 --- a/Projectiles/Melee/ElementalExcaliburBeam.cs +++ b/Projectiles/Melee/ElementalExcaliburBeam.cs @@ -135,12 +135,8 @@ namespace CalamityMod.Projectiles.Melee { if (projectile.Distance(Main.player[projectile.owner].Center) > minDist) { - Vector2 vecToPlayer = projectile.DirectionTo(Main.player[projectile.owner].Center); - if (vecToPlayer.HasNaNs()) - { - vecToPlayer = Vector2.UnitY; - } - projectile.velocity = (projectile.velocity * (inertia - 1f) + vecToPlayer * homingSpeed) / inertia; + Vector2 moveDirection = projectile.SafeDirectionTo(Main.player[projectile.owner].Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * (inertia - 1f) + moveDirection * homingSpeed) / inertia; } } else diff --git a/Projectiles/Melee/ExoGladSpears.cs b/Projectiles/Melee/ExoGladSpears.cs index c5e4ef00e9..c392e743ff 100644 --- a/Projectiles/Melee/ExoGladSpears.cs +++ b/Projectiles/Melee/ExoGladSpears.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Melee NPC potentialTarget = projectile.Center.ClosestNPCAt(1000f); if (potentialTarget != null) - projectile.velocity = (projectile.velocity * 20f + projectile.DirectionTo(potentialTarget.Center) * 8f) / 21f; + projectile.velocity = (projectile.velocity * 20f + projectile.SafeDirectionTo(potentialTarget.Center) * 8f) / 21f; else if (projectile.Distance(Main.player[projectile.owner].Center) > 1000f) { float inertia = 25f * FlySpeedMultiplier; diff --git a/Projectiles/Melee/Exocomet.cs b/Projectiles/Melee/Exocomet.cs index a461e4dfdd..8c94e17a19 100644 --- a/Projectiles/Melee/Exocomet.cs +++ b/Projectiles/Melee/Exocomet.cs @@ -75,12 +75,8 @@ namespace CalamityMod.Projectiles.Melee { if (projectile.Distance(Main.player[projectile.owner].Center) > num954) { - Vector2 vector102 = projectile.DirectionTo(Main.player[projectile.owner].Center); - if (vector102.HasNaNs()) - { - vector102 = Vector2.UnitY; - } - projectile.velocity = (projectile.velocity * (num953 - 1f) + vector102 * scaleFactor12) / num953; + Vector2 moveDirection = projectile.SafeDirectionTo(Main.player[projectile.owner].Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * (num953 - 1f) + moveDirection * scaleFactor12) / num953; } } } diff --git a/Projectiles/Melee/GaelSkull.cs b/Projectiles/Melee/GaelSkull.cs index 7cb8df1cf1..7479a2121a 100644 --- a/Projectiles/Melee/GaelSkull.cs +++ b/Projectiles/Melee/GaelSkull.cs @@ -39,14 +39,16 @@ namespace CalamityMod.Projectiles.Melee { NPC target = projectile.Center.ClosestNPCAt(GaelsGreatsword.SearchDistance); projectile.tileCollide = target != null; //Go through walls if we're hunting an NPC + if (target != null) { - float velocityMagnitude = projectile.velocity.Length(); - Vector2 distanceNorm = projectile.DirectionTo(target.Center) * velocityMagnitude * (projectile.Distance(target.Center) < 220f ? 1.3f : 1f); - float inverseTurnSpeed = (projectile.Distance(target.Center) < 240f ? 4f : 13f); - projectile.velocity = (projectile.velocity * inverseTurnSpeed + distanceNorm) / (inverseTurnSpeed + 0.4f); + float homingSpeed = projectile.velocity.Length() * (projectile.Distance(target.Center) < 220f ? 1.3f : 1f); + Vector2 idealVelocity = projectile.SafeDirectionTo(target.Center) * homingSpeed; + + float inertia = projectile.Distance(target.Center) < 240f ? 4f : 13f; + projectile.velocity = (projectile.velocity * inertia + idealVelocity) / (inertia + 0.4f); projectile.velocity.Normalize(); - projectile.velocity *= velocityMagnitude; + projectile.velocity *= homingSpeed; } } diff --git a/Projectiles/Melee/GaelSkull2.cs b/Projectiles/Melee/GaelSkull2.cs index 1ff16e72b5..8c914d33fd 100644 --- a/Projectiles/Melee/GaelSkull2.cs +++ b/Projectiles/Melee/GaelSkull2.cs @@ -60,12 +60,13 @@ namespace CalamityMod.Projectiles.Melee projectile.tileCollide = target != null; //Go through walls if we're hunting an NPC if (target != null) { - float velocityMagnitude = projectile.velocity.Length(); - Vector2 distanceNorm = projectile.DirectionTo(target.Center) * velocityMagnitude * (projectile.Distance(target.Center) < 220f ? 1.3f : 1f); - float inverseTurnSpeed = (projectile.Distance(target.Center) < 240f ? 4f : 13f); - projectile.velocity = (projectile.velocity * inverseTurnSpeed + distanceNorm) / (inverseTurnSpeed + 0.4f); + float homingSpeed = projectile.velocity.Length() * (projectile.Distance(target.Center) < 220f ? 1.3f : 1f); + Vector2 idealVelocity = projectile.SafeDirectionTo(target.Center) * homingSpeed; + + float inertia = projectile.Distance(target.Center) < 240f ? 4f : 13f; + projectile.velocity = (projectile.velocity * inertia + idealVelocity) / (inertia + 0.4f); projectile.velocity.Normalize(); - projectile.velocity *= velocityMagnitude; + projectile.velocity *= homingSpeed; } //Dust circle diff --git a/Projectiles/Melee/GhastlySoulLarge.cs b/Projectiles/Melee/GhastlySoulLarge.cs index 6c5ccf01de..fcbb58ea43 100644 --- a/Projectiles/Melee/GhastlySoulLarge.cs +++ b/Projectiles/Melee/GhastlySoulLarge.cs @@ -59,12 +59,8 @@ namespace CalamityMod.Projectiles.Melee { if (projectile.Distance(Main.player[projectile.owner].Center) > num954) { - Vector2 vector102 = projectile.DirectionTo(Main.player[projectile.owner].Center); - if (vector102.HasNaNs()) - { - vector102 = Vector2.UnitY; - } - projectile.velocity = (projectile.velocity * (num953 - 1f) + vector102 * scaleFactor12) / num953; + Vector2 moveDirection = projectile.SafeDirectionTo(Main.player[projectile.owner].Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * (num953 - 1f) + moveDirection * scaleFactor12) / num953; return; } diff --git a/Projectiles/Melee/GhastlySoulMedium.cs b/Projectiles/Melee/GhastlySoulMedium.cs index 5f6b4a2bc1..ace5640990 100644 --- a/Projectiles/Melee/GhastlySoulMedium.cs +++ b/Projectiles/Melee/GhastlySoulMedium.cs @@ -59,12 +59,8 @@ namespace CalamityMod.Projectiles.Melee { if (projectile.Distance(Main.player[projectile.owner].Center) > num954) { - Vector2 vector102 = projectile.DirectionTo(Main.player[projectile.owner].Center); - if (vector102.HasNaNs()) - { - vector102 = Vector2.UnitY; - } - projectile.velocity = (projectile.velocity * (num953 - 1f) + vector102 * scaleFactor12) / num953; + Vector2 moveDirection = projectile.SafeDirectionTo(Main.player[projectile.owner].Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * (num953 - 1f) + moveDirection * scaleFactor12) / num953; return; } diff --git a/Projectiles/Melee/GhastlySoulSmall.cs b/Projectiles/Melee/GhastlySoulSmall.cs index dcac84ab6f..6b8e6d04ba 100644 --- a/Projectiles/Melee/GhastlySoulSmall.cs +++ b/Projectiles/Melee/GhastlySoulSmall.cs @@ -58,12 +58,8 @@ namespace CalamityMod.Projectiles.Melee { if (projectile.Distance(Main.player[projectile.owner].Center) > num954) { - Vector2 vector102 = projectile.DirectionTo(Main.player[projectile.owner].Center); - if (vector102.HasNaNs()) - { - vector102 = Vector2.UnitY; - } - projectile.velocity = (projectile.velocity * (num953 - 1f) + vector102 * scaleFactor12) / num953; + Vector2 moveDirection = projectile.SafeDirectionTo(Main.player[projectile.owner].Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * (num953 - 1f) + moveDirection * scaleFactor12) / num953; return; } diff --git a/Projectiles/Melee/Spears/BansheeHookProj.cs b/Projectiles/Melee/Spears/BansheeHookProj.cs index f7c4378fe3..40853f457b 100644 --- a/Projectiles/Melee/Spears/BansheeHookProj.cs +++ b/Projectiles/Melee/Spears/BansheeHookProj.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Melee.Spears Vector2 destination = playerRelativePoint + flatVelocity.RotatedBy(startingVelocityRotation) + new Vector2(startingVelocitySpeed + TravelSpeed + 40f, 0f).RotatedBy(startingVelocityRotation); - Vector2 directionTowardsEnd = player.DirectionTo(destination); + Vector2 directionTowardsEnd = player.SafeDirectionTo(destination, Vector2.UnitX * player.direction); Vector2 initalVelocity = projectile.velocity.SafeNormalize(Vector2.UnitY); float dustCount = 2f; @@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Melee.Spears while (i < dustCount) { Dust dust = Dust.NewDustDirect(projectile.Center, 14, 14, 60, 0f, 0f, 110, default, 1f); - dust.velocity = player.DirectionTo(dust.position) * 2f; + dust.velocity = player.SafeDirectionTo(dust.position) * 2f; dust.position = projectile.Center + initalVelocity.RotatedBy(completionAsAngle * 2f + i / dustCount * MathHelper.TwoPi) * 10f; dust.scale = 1f + Main.rand.NextFloat(0.6f); @@ -79,7 +79,7 @@ namespace CalamityMod.Projectiles.Melee.Spears if (Main.rand.NextBool(3)) { Dust dust = Dust.NewDustDirect(projectile.Center, 20, 20, 60, 0f, 0f, 110, default, 1f); - dust.velocity = player.DirectionTo(dust.position) * 2f; + dust.velocity = player.SafeDirectionTo(dust.position) * 2f; dust.position = projectile.Center + directionTowardsEnd * -110f; dust.scale = 0.45f + Main.rand.NextFloat(0.4f); dust.fadeIn = 0.7f + Main.rand.NextFloat(0.4f); diff --git a/Projectiles/Melee/TyphonsGreedBubble.cs b/Projectiles/Melee/TyphonsGreedBubble.cs index b15fa59403..cc451323ca 100644 --- a/Projectiles/Melee/TyphonsGreedBubble.cs +++ b/Projectiles/Melee/TyphonsGreedBubble.cs @@ -54,12 +54,8 @@ namespace CalamityMod.Projectiles.Melee { if (projectile.Distance(player.Center) > num954) { - Vector2 vector102 = projectile.DirectionTo(player.Center); - if (vector102.HasNaNs()) - { - vector102 = Vector2.UnitY; - } - projectile.velocity = (projectile.velocity * (inertia - 1f) + vector102 * speed) / inertia; + Vector2 moveDirection = projectile.SafeDirectionTo(player.Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * (inertia - 1f) + moveDirection * speed) / inertia; } } else diff --git a/Projectiles/Melee/TyphonsGreedStaff.cs b/Projectiles/Melee/TyphonsGreedStaff.cs index 2b213b2620..2ae51421bc 100644 --- a/Projectiles/Melee/TyphonsGreedStaff.cs +++ b/Projectiles/Melee/TyphonsGreedStaff.cs @@ -72,22 +72,15 @@ namespace CalamityMod.Projectiles.Melee } else if (flag2) { - Vector2 mouseWorld2 = Main.MouseWorld; - int num11 = (player.DirectionTo(mouseWorld2).X > 0f) ? 1 : -1; - if ((float)num11 != projectile.velocity.X) + int expectedDirection = (player.SafeDirectionTo(Main.MouseWorld).X > 0f).ToDirectionInt(); + if (expectedDirection != projectile.velocity.X) { - player.ChangeDir(num11); - projectile.velocity = new Vector2((float)num11, 0f); + player.ChangeDir(expectedDirection); + projectile.velocity = Vector2.UnitX * expectedDirection; + projectile.rotation -= MathHelper.Pi; projectile.netUpdate = true; - projectile.rotation -= 3.14159274f; } } - if ((projectile.ai[0] == num10 || (projectile.ai[0] == (float)(int)(num / 2f) && projectile.active)) && projectile.owner == Main.myPlayer) - { - Vector2 mouseWorld3 = Main.MouseWorld; - Vector2 mouse = player.DirectionTo(mouseWorld3) * 0f; - player.DirectionTo(mouse); - } 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; @@ -96,7 +89,7 @@ namespace CalamityMod.Projectiles.Melee if (Main.rand.NextBool(2)) { Dust dust3 = Dust.NewDustDirect(value3 - new Vector2(5f), 10, 10, 33, player.velocity.X, player.velocity.Y, 150, default, 1f); - dust3.velocity = projectile.DirectionTo(dust3.position) * 0.1f + dust3.velocity * 0.1f; + dust3.velocity = projectile.SafeDirectionTo(dust3.position) * 0.1f + dust3.velocity * 0.1f; } for (int j = 0; j < 4; j++) { diff --git a/Projectiles/Ranged/BloodflareSoul.cs b/Projectiles/Ranged/BloodflareSoul.cs index 1357fc2f7a..f92cb1023e 100644 --- a/Projectiles/Ranged/BloodflareSoul.cs +++ b/Projectiles/Ranged/BloodflareSoul.cs @@ -58,12 +58,8 @@ namespace CalamityMod.Projectiles.Ranged { if (projectile.Distance(Main.player[projectile.owner].Center) > num954) { - Vector2 vector102 = projectile.DirectionTo(Main.player[projectile.owner].Center); - if (vector102.HasNaNs()) - { - vector102 = Vector2.UnitY; - } - projectile.velocity = (projectile.velocity * (num953 - 1f) + vector102 * scaleFactor12) / num953; + Vector2 moveDirection = projectile.SafeDirectionTo(Main.player[projectile.owner].Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * (num953 - 1f) + moveDirection * scaleFactor12) / num953; return; } CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 11f, 20f); diff --git a/Projectiles/Ranged/ExoSpark.cs b/Projectiles/Ranged/ExoSpark.cs index 776391ca03..c698b23d06 100644 --- a/Projectiles/Ranged/ExoSpark.cs +++ b/Projectiles/Ranged/ExoSpark.cs @@ -46,9 +46,8 @@ namespace CalamityMod.Projectiles.Ranged } NPC potentialTarget = projectile.Center.ClosestNPCAt(MaxTargetDistance); if (potentialTarget != null) - { - projectile.velocity = (projectile.velocity * (HomingInertia - 1) + projectile.DirectionTo(potentialTarget.Center) * 16f) / HomingInertia; - } + projectile.velocity = (projectile.velocity * (HomingInertia - 1) + projectile.SafeDirectionTo(potentialTarget.Center) * 16f) / HomingInertia; + projectile.rotation = projectile.velocity.ToRotation(); if (!Main.dedServ) { diff --git a/Projectiles/Ranged/ThePackMissile.cs b/Projectiles/Ranged/ThePackMissile.cs index 87580ef43f..b25734ad75 100644 --- a/Projectiles/Ranged/ThePackMissile.cs +++ b/Projectiles/Ranged/ThePackMissile.cs @@ -64,9 +64,10 @@ namespace CalamityMod.Projectiles.Ranged } if (homeIn) { - projectile.velocity = (projectile.velocity * 15f + projectile.DirectionTo(targetCenter) * 30f) / 16f; + projectile.velocity = (projectile.velocity * 15f + projectile.SafeDirectionTo(targetCenter) * 30f) / 16f; return; } + projectile.frameCounter++; if (projectile.frameCounter > 3) { diff --git a/Projectiles/Ranged/UltimaBowProjectile.cs b/Projectiles/Ranged/UltimaBowProjectile.cs index 665a92b47e..22c7f00099 100644 --- a/Projectiles/Ranged/UltimaBowProjectile.cs +++ b/Projectiles/Ranged/UltimaBowProjectile.cs @@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.Ranged Vector2 shotPosition = player.RotatedRelativePoint(player.MountedCenter, true); shotPosition += projectile.velocity.ToRotation().ToRotationVector2().RotatedByRandom(MathHelper.ToRadians(40f)).RotatedBy(-0.25f * projectile.spriteDirection) * 42f; - projectile.velocity = projectile.DirectionTo(Main.MouseWorld); + projectile.velocity = projectile.SafeDirectionTo(Main.MouseWorld); Vector2 shotVelocity = projectile.velocity * shotSpeed; // The velocity should always be a unit vector. @@ -82,7 +82,7 @@ namespace CalamityMod.Projectiles.Ranged { // To ensure that the sparks don't spawn on top of the laser itself. float offsetAngle = Main.rand.NextFloat(0.2f, 0.5f) * Main.rand.NextBool(2).ToDirectionInt(); - Vector2 sparkVelocity = projectile.DirectionTo(Main.MouseWorld).RotatedByRandom(0.5f) * 13f; + Vector2 sparkVelocity = projectile.SafeDirectionTo(Main.MouseWorld, Vector2.UnitY).RotatedByRandom(0.5f) * 13f; sparkVelocity = sparkVelocity.RotatedBy(offsetAngle); Projectile.NewProjectile(shotPosition, sparkVelocity, ModContent.ProjectileType(), damage / 3, knockBack, projectile.owner); } diff --git a/Projectiles/Ranged/UltimaSpark.cs b/Projectiles/Ranged/UltimaSpark.cs index 3601f50e2d..7cc133ac60 100644 --- a/Projectiles/Ranged/UltimaSpark.cs +++ b/Projectiles/Ranged/UltimaSpark.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Projectiles.Ranged NPC potentialTarget = projectile.Center.ClosestNPCAt(MaxHomingDistance); if (potentialTarget != null) { - projectile.velocity = (projectile.velocity * 8f + projectile.DirectionTo(potentialTarget.Center) * 18f) / 9f; + projectile.velocity = (projectile.velocity * 8f + projectile.SafeDirectionTo(potentialTarget.Center) * 18f) / 9f; return; } diff --git a/Projectiles/Ranged/VeriumBulletProj.cs b/Projectiles/Ranged/VeriumBulletProj.cs index 855bdf7477..64d9a5ded7 100644 --- a/Projectiles/Ranged/VeriumBulletProj.cs +++ b/Projectiles/Ranged/VeriumBulletProj.cs @@ -108,11 +108,8 @@ namespace CalamityMod.Projectiles.Ranged if (homeIn) { - Vector2 homeInVector = projectile.DirectionTo(center); - if (homeInVector.HasNaNs()) - homeInVector = Vector2.UnitY; - - projectile.velocity = (projectile.velocity * inertia + homeInVector * speed) / (inertia + 1f); + Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * inertia + moveDirection * speed) / (inertia + 1f); } return false; } diff --git a/Projectiles/Rogue/CelestialReaperAfterimage.cs b/Projectiles/Rogue/CelestialReaperAfterimage.cs index e80b6480e8..1d4a0f8317 100644 --- a/Projectiles/Rogue/CelestialReaperAfterimage.cs +++ b/Projectiles/Rogue/CelestialReaperAfterimage.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Rogue { NPC target = projectile.Center.ClosestNPCAt(640f); if (target != null) - projectile.velocity = (projectile.velocity * 20f + projectile.DirectionTo(target.Center) * 20f) / 21f; + projectile.velocity = (projectile.velocity * 20f + projectile.SafeDirectionTo(target.Center) * 20f) / 21f; } projectile.alpha += 5; diff --git a/Projectiles/Rogue/CelestialReaperProjectile.cs b/Projectiles/Rogue/CelestialReaperProjectile.cs index b90bd6f5d3..88c5a20002 100644 --- a/Projectiles/Rogue/CelestialReaperProjectile.cs +++ b/Projectiles/Rogue/CelestialReaperProjectile.cs @@ -40,9 +40,7 @@ namespace CalamityMod.Projectiles.Rogue { NPC target = projectile.Center.ClosestNPCAt(640f); if (target != null) - { - projectile.velocity = (projectile.velocity * 20f + projectile.DirectionTo(target.Center) * 20f) / 21f; - } + projectile.velocity = (projectile.velocity * 20f + projectile.SafeDirectionTo(target.Center) * 20f) / 21f; } // This code is only run on stealth strikes and periodically spawns damaging afterimages. diff --git a/Projectiles/Rogue/DragonShit.cs b/Projectiles/Rogue/DragonShit.cs index 6bf9f3b120..837bcfe9d7 100644 --- a/Projectiles/Rogue/DragonShit.cs +++ b/Projectiles/Rogue/DragonShit.cs @@ -53,9 +53,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.velocity *= 1.07f; } else if (target != null) - { - projectile.velocity = (projectile.velocity * 23f + projectile.DirectionTo(target.Center) * 14.975f) / 24f; - } + projectile.velocity = (projectile.velocity * 23f + projectile.SafeDirectionTo(target.Center) * 14.975f) / 24f; else { projectile.timeLeft = Math.Min(projectile.timeLeft, 15); diff --git a/Projectiles/Rogue/EpidemicShredderProjectile.cs b/Projectiles/Rogue/EpidemicShredderProjectile.cs index ef94713d2b..10c8b6aa9d 100644 --- a/Projectiles/Rogue/EpidemicShredderProjectile.cs +++ b/Projectiles/Rogue/EpidemicShredderProjectile.cs @@ -38,11 +38,9 @@ namespace CalamityMod.Projectiles.Rogue } if (projectile.timeLeft < 580f) { - projectile.velocity = (projectile.velocity * 18f + projectile.DirectionTo(Main.player[projectile.owner].Center) * 18f) / 19f; + projectile.velocity = (projectile.velocity * 18f + projectile.SafeDirectionTo(Main.player[projectile.owner].Center) * 18f) / 19f; if (Main.player[projectile.owner].Hitbox.Intersects(projectile.Hitbox)) - { projectile.Kill(); - } } if (projectile.timeLeft % 5 == 0 && projectile.Calamity().stealthStrike) { diff --git a/Projectiles/Rogue/FinalDawnFireball.cs b/Projectiles/Rogue/FinalDawnFireball.cs index 0a4feb1c58..1a4e9bc4c9 100644 --- a/Projectiles/Rogue/FinalDawnFireball.cs +++ b/Projectiles/Rogue/FinalDawnFireball.cs @@ -41,11 +41,11 @@ namespace CalamityMod.Projectiles.Rogue Main.dust[idx].noLight = true; projectile.ai[0]++; - if(projectile.ai[0] >= 20) + if (projectile.ai[0] >= 20) { projectile.friendly = true; NPC npc = Main.npc[(int)projectile.ai[1]]; - Vector2 desiredVelocity = projectile.DirectionTo(npc.Center) * DesiredSpeed; + Vector2 desiredVelocity = projectile.SafeDirectionTo(npc.Center) * DesiredSpeed; projectile.velocity = Vector2.Lerp(projectile.velocity, desiredVelocity, 1f / InterpolationTime); if(!npc.active) projectile.Kill(); diff --git a/Projectiles/Rogue/FinalDawnProjectile.cs b/Projectiles/Rogue/FinalDawnProjectile.cs index 2680d6ee8d..c80923555b 100644 --- a/Projectiles/Rogue/FinalDawnProjectile.cs +++ b/Projectiles/Rogue/FinalDawnProjectile.cs @@ -99,7 +99,7 @@ namespace CalamityMod.Projectiles.Rogue if (player.Calamity().StealthStrikeAvailable() && projectile.ai[1] != 1f) { int stealth = Projectile.NewProjectile(player.Center, - player.DirectionTo(Main.MouseWorld) * 38f, + player.SafeDirectionTo(Main.MouseWorld) * 38f, ModContent.ProjectileType(), (int)(projectile.damage * 1.5f), projectile.knockBack, @@ -110,7 +110,7 @@ namespace CalamityMod.Projectiles.Rogue else { Projectile.NewProjectile(projectile.Center, - projectile.DirectionTo(Main.MouseWorld) * 38f, + projectile.SafeDirectionTo(Main.MouseWorld) * 38f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); if (projectile.ai[1] != 1f) diff --git a/Projectiles/Rogue/FinalDawnThrow.cs b/Projectiles/Rogue/FinalDawnThrow.cs index 9a339a2ba1..0487ae533b 100644 --- a/Projectiles/Rogue/FinalDawnThrow.cs +++ b/Projectiles/Rogue/FinalDawnThrow.cs @@ -50,7 +50,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.ai[0]++; if (projectile.ai[0] >= 30) { - Vector2 desiredVelocity = projectile.DirectionTo(player.Center) * DesiredSpeed; + Vector2 desiredVelocity = projectile.SafeDirectionTo(player.Center) * DesiredSpeed; projectile.velocity = Vector2.Lerp(projectile.velocity, desiredVelocity, 1f / InterpolationTime); float distance = projectile.Distance(player.Center); diff --git a/Projectiles/Rogue/IceStarProjectile.cs b/Projectiles/Rogue/IceStarProjectile.cs index 3e40d45b3e..a86c008cc6 100644 --- a/Projectiles/Rogue/IceStarProjectile.cs +++ b/Projectiles/Rogue/IceStarProjectile.cs @@ -70,11 +70,8 @@ namespace CalamityMod.Projectiles.Rogue if (homeIn) { - Vector2 homeInVector = projectile.DirectionTo(center); - if (homeInVector.HasNaNs()) - homeInVector = Vector2.UnitY; - - projectile.velocity = (projectile.velocity * 20f + homeInVector * 14f) / (21f); + Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * 20f + moveDirection * 14f) / (21f); } projectile.velocity = initStealth && !homeIn ? initialVelocity : projectile.velocity; } diff --git a/Projectiles/Rogue/PhantasmalSoul.cs b/Projectiles/Rogue/PhantasmalSoul.cs index 400206f294..6ec8979684 100644 --- a/Projectiles/Rogue/PhantasmalSoul.cs +++ b/Projectiles/Rogue/PhantasmalSoul.cs @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Rogue // Make sure the soul is always facing forwards projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; - float playerHomingStrength = 40f * projectile.ai[1]; // ranges from 20 to 60 + float inertia = 40f * projectile.ai[1]; // ranges from 20 to 60 float homingSpeed = 8f * projectile.ai[1]; // ranges from 4 to 12 float playerHomingRange = 900f; @@ -83,10 +83,8 @@ namespace CalamityMod.Projectiles.Rogue // If you are too far away from the projectiles, they home in on you. if (projectile.Distance(Main.player[projectile.owner].Center) > playerHomingRange) { - Vector2 vector102 = projectile.DirectionTo(Main.player[projectile.owner].Center); - if (vector102.HasNaNs()) - vector102 = Vector2.UnitY; - projectile.velocity = (projectile.velocity * (playerHomingStrength - 1f) + vector102 * homingSpeed) / playerHomingStrength; + Vector2 moveDirection = projectile.SafeDirectionTo(Main.player[projectile.owner].Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * (inertia - 1f) + moveDirection * homingSpeed) / inertia; return; } diff --git a/Projectiles/Rogue/RegulusEnergy.cs b/Projectiles/Rogue/RegulusEnergy.cs index a7cde511ea..6610c60468 100644 --- a/Projectiles/Rogue/RegulusEnergy.cs +++ b/Projectiles/Rogue/RegulusEnergy.cs @@ -73,12 +73,9 @@ namespace CalamityMod.Projectiles.Rogue } if (homeIn) - { - Vector2 homeInVector = projectile.DirectionTo(center); - if (homeInVector.HasNaNs()) - homeInVector = Vector2.UnitY; - - projectile.velocity = (projectile.velocity * 20f + homeInVector * 12f) / (21f); + { + Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * 20f + moveDirection * 12f) / (21f); } else projectile.Kill(); diff --git a/Projectiles/Rogue/ScarletDevilBullet.cs b/Projectiles/Rogue/ScarletDevilBullet.cs index c896663b37..84663dc8f2 100644 --- a/Projectiles/Rogue/ScarletDevilBullet.cs +++ b/Projectiles/Rogue/ScarletDevilBullet.cs @@ -51,12 +51,9 @@ namespace CalamityMod.Projectiles.Rogue } if (homeIn) - { - Vector2 homeInVector = projectile.DirectionTo(center); - if (homeInVector.HasNaNs()) - homeInVector = Vector2.UnitY; - - projectile.velocity = (projectile.velocity * 10f + homeInVector * 30f) / (11f); + { + Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * 10f + moveDirection * 30f) / (11f); } else { diff --git a/Projectiles/Rogue/SpearofDestinyProjectile.cs b/Projectiles/Rogue/SpearofDestinyProjectile.cs index dbec1dfcd9..e059580d91 100644 --- a/Projectiles/Rogue/SpearofDestinyProjectile.cs +++ b/Projectiles/Rogue/SpearofDestinyProjectile.cs @@ -74,11 +74,8 @@ namespace CalamityMod.Projectiles.Rogue if (homeIn) { projectile.extraUpdates = 2; - Vector2 homeInVector = projectile.DirectionTo(center); - if (homeInVector.HasNaNs()) - homeInVector = Vector2.UnitY; - - projectile.velocity = (projectile.velocity * 20f + homeInVector * 12f) / (21f); + Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * 20f + moveDirection * 12f) / (21f); } } diff --git a/Projectiles/Rogue/StellarKnifeProj.cs b/Projectiles/Rogue/StellarKnifeProj.cs index 820749f241..5f9598ffcd 100644 --- a/Projectiles/Rogue/StellarKnifeProj.cs +++ b/Projectiles/Rogue/StellarKnifeProj.cs @@ -89,11 +89,8 @@ namespace CalamityMod.Projectiles.Rogue { projectile.timeLeft = 600; //when homing in, the projectile cannot run out of timeLeft, but synthesized timeLeft still runs - Vector2 homeInVector = projectile.DirectionTo(center); - if (homeInVector.HasNaNs()) - homeInVector = Vector2.UnitY; - - projectile.velocity = (projectile.velocity * 10f + homeInVector * 30f) / (10f + 1f); + Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * 10f + moveDirection * 30f) / (10f + 1f); } else { diff --git a/Projectiles/Rogue/SupernovaHoming.cs b/Projectiles/Rogue/SupernovaHoming.cs index ac86eb7a62..eee05e5b13 100644 --- a/Projectiles/Rogue/SupernovaHoming.cs +++ b/Projectiles/Rogue/SupernovaHoming.cs @@ -68,12 +68,9 @@ namespace CalamityMod.Projectiles.Rogue } if (homeIn) - { - Vector2 homeInVector = projectile.DirectionTo(center); - if (homeInVector.HasNaNs()) - homeInVector = Vector2.UnitY; - - projectile.velocity = (projectile.velocity * 20f + homeInVector * 12f) / (21f); + { + Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * 20f + moveDirection * 12f) / (21f); } else projectile.Kill(); diff --git a/Projectiles/Rogue/ToxicantTwisterTwoPointZero.cs b/Projectiles/Rogue/ToxicantTwisterTwoPointZero.cs index df551d8071..2f332ec106 100644 --- a/Projectiles/Rogue/ToxicantTwisterTwoPointZero.cs +++ b/Projectiles/Rogue/ToxicantTwisterTwoPointZero.cs @@ -117,11 +117,9 @@ namespace CalamityMod.Projectiles.Rogue targetIndex = closestTarget.whoAmI; float inertia = 20f; float homingVelocity = projectile.Calamity().stealthStrike ? 30f : 20f; - Vector2 homeInVector = projectile.DirectionTo(closestTarget.Center); - if (homeInVector.HasNaNs()) - homeInVector = Vector2.UnitY; + Vector2 moveDirection = projectile.SafeDirectionTo(closestTarget.Center, Vector2.UnitY); - projectile.velocity = (projectile.velocity * inertia + homeInVector * homingVelocity) / (inertia + 1f); + projectile.velocity = (projectile.velocity * inertia + moveDirection * homingVelocity) / (inertia + 1f); } } else diff --git a/Projectiles/Summon/AstralProbeRound.cs b/Projectiles/Summon/AstralProbeRound.cs index 4367a44f85..e246811fec 100644 --- a/Projectiles/Summon/AstralProbeRound.cs +++ b/Projectiles/Summon/AstralProbeRound.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Summon } NPC potentialTarget = projectile.Center.MinionHoming(1200f, Main.player[projectile.owner]); if (potentialTarget != null) - projectile.velocity = (projectile.velocity * 20f + projectile.DirectionTo(potentialTarget.Center) * 17f) / 21f; + projectile.velocity = (projectile.velocity * 20f + projectile.SafeDirectionTo(potentialTarget.Center) * 17f) / 21f; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Summon/BelladonnaSpirit.cs b/Projectiles/Summon/BelladonnaSpirit.cs index 1b4c9423fd..7eaa0c7ad6 100644 --- a/Projectiles/Summon/BelladonnaSpirit.cs +++ b/Projectiles/Summon/BelladonnaSpirit.cs @@ -145,7 +145,7 @@ namespace CalamityMod.Projectiles.Summon { float angle = Main.rand.NextFloat(-0.1f, 0.1f) + i * 0.05f; Projectile.NewProjectile(projectile.Center + new Vector2(0f, -6f), - projectile.DirectionTo(target.Center).RotatedBy(angle) * 7.5f, + projectile.SafeDirectionTo(target.Center).RotatedBy(angle) * 7.5f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, diff --git a/Projectiles/Summon/CinderBlossom.cs b/Projectiles/Summon/CinderBlossom.cs index 7b037d1901..91ae28461b 100644 --- a/Projectiles/Summon/CinderBlossom.cs +++ b/Projectiles/Summon/CinderBlossom.cs @@ -79,7 +79,7 @@ namespace CalamityMod.Projectiles.Summon { if (Time++ % 35f == 34f && Collision.CanHit(projectile.position, projectile.width, projectile.height, potentialTarget.position, potentialTarget.width, potentialTarget.height)) { - Vector2 velocity = projectile.DirectionTo(potentialTarget.Center) * Main.rand.NextFloat(10f, 18f); + Vector2 velocity = projectile.SafeDirectionTo(potentialTarget.Center) * Main.rand.NextFloat(10f, 18f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); } } diff --git a/Projectiles/Summon/CosmicBlast.cs b/Projectiles/Summon/CosmicBlast.cs index 428ef918ba..68346087f4 100644 --- a/Projectiles/Summon/CosmicBlast.cs +++ b/Projectiles/Summon/CosmicBlast.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Summon } NPC potentialTarget = projectile.Center.MinionHoming(1200f, Main.player[projectile.owner]); if (potentialTarget != null) - projectile.velocity = (projectile.velocity * 20f + projectile.DirectionTo(potentialTarget.Center) * 40f) / 21f; + projectile.velocity = (projectile.velocity * 20f + projectile.SafeDirectionTo(potentialTarget.Center) * 40f) / 21f; } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Summon/CosmicBlastBig.cs b/Projectiles/Summon/CosmicBlastBig.cs index 8cce76312d..f8eda30ca8 100644 --- a/Projectiles/Summon/CosmicBlastBig.cs +++ b/Projectiles/Summon/CosmicBlastBig.cs @@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Summon } NPC potentialTarget = projectile.Center.MinionHoming(600f, Main.player[projectile.owner]); if (potentialTarget != null) - projectile.velocity = (projectile.velocity * 20f + projectile.DirectionTo(potentialTarget.Center) * 45f) / 21f; + projectile.velocity = (projectile.velocity * 20f + projectile.SafeDirectionTo(potentialTarget.Center) * 45f) / 21f; } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Summon/CosmicViperHomingRocket.cs b/Projectiles/Summon/CosmicViperHomingRocket.cs index 31c43114e3..3f3490836b 100644 --- a/Projectiles/Summon/CosmicViperHomingRocket.cs +++ b/Projectiles/Summon/CosmicViperHomingRocket.cs @@ -105,13 +105,11 @@ namespace CalamityMod.Projectiles.Summon if (homeIn) { - Vector2 homeInVector = projectile.DirectionTo(center); - if (homeInVector.HasNaNs()) - homeInVector = Vector2.UnitY; + Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); - float homingRatio = 20f; + float homingInertia = 20f; float homingVelocity = 20f; - projectile.velocity = (projectile.velocity * homingRatio + homeInVector * homingVelocity) / (homingRatio + 1f); + projectile.velocity = (projectile.velocity * homingInertia + moveDirection * homingVelocity) / (homingInertia + 1f); } } diff --git a/Projectiles/Summon/CosmicViperSplittingRocket.cs b/Projectiles/Summon/CosmicViperSplittingRocket.cs index 96eb17d447..f14ab583da 100644 --- a/Projectiles/Summon/CosmicViperSplittingRocket.cs +++ b/Projectiles/Summon/CosmicViperSplittingRocket.cs @@ -151,13 +151,11 @@ namespace CalamityMod.Projectiles.Summon } if (homeIn) { - Vector2 homeInVector = projectile.DirectionTo(center); - if (homeInVector.HasNaNs()) - homeInVector = Vector2.UnitY; + Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); - float homingRatio = 15f; + float homingInertia = 15f; float homingVelocity = 30f; - projectile.velocity = (projectile.velocity * homingRatio + homeInVector * homingVelocity) / (homingRatio + 1f); + projectile.velocity = (projectile.velocity * homingInertia + moveDirection * homingVelocity) / (homingInertia + 1f); } projectile.frameCounter++; if (projectile.frameCounter > 3) diff --git a/Projectiles/Summon/DazzlingStabber.cs b/Projectiles/Summon/DazzlingStabber.cs index 1a5af418d3..62b6114e16 100644 --- a/Projectiles/Summon/DazzlingStabber.cs +++ b/Projectiles/Summon/DazzlingStabber.cs @@ -123,10 +123,11 @@ namespace CalamityMod.Projectiles.Summon projectile.velocity = projectile.velocity.ToRotation().AngleTowards(angleToTargetCoords, angularTurnSpeed).ToRotationVector2() * projectile.velocity.Length(); // If not super close to the target but the target is very much in the line of sight of the summon, charge. - if (!projectile.WithinRange(target.Center, 75f) && Vector2.Dot(projectile.DirectionTo(target.Center), projectile.velocity.SafeNormalize(Vector2.Zero)) > 0.85f) + if (!projectile.WithinRange(target.Center, 75f) && Vector2.Dot(projectile.SafeDirectionTo(target.Center), projectile.velocity.SafeNormalize(Vector2.Zero)) > 0.85f) { - projectile.velocity = projectile.DirectionTo(target.Center) * 36f; + projectile.velocity = projectile.SafeDirectionTo(target.Center) * 36f; AttackDelay = 15f; + projectile.netUpdate = true; } diff --git a/Projectiles/Summon/DormantBrimseekerBab.cs b/Projectiles/Summon/DormantBrimseekerBab.cs index e9c08e0989..4b4ed9b1f2 100644 --- a/Projectiles/Summon/DormantBrimseekerBab.cs +++ b/Projectiles/Summon/DormantBrimseekerBab.cs @@ -97,7 +97,7 @@ namespace CalamityMod.Projectiles.Summon } Vector2 destination = player.Center + projectile.ai[1].ToRotationVector2() * new Vector2(1f, (float)Math.Cos(projectile.ai[1])) * 200f; - projectile.velocity = (projectile.velocity * 18f + projectile.DirectionTo(destination) * 14f) / 20f; + projectile.velocity = (projectile.velocity * 18f + projectile.SafeDirectionTo(destination) * 14f) / 20f; projectile.frameCounter++; if (projectile.frameCounter >= 6) @@ -109,8 +109,8 @@ namespace CalamityMod.Projectiles.Summon { projectile.frame = (projectile.localAI[1] == 1f).ToInt() * 4; } - - projectile.MinionAntiClump(0.1f); + + projectile.MinionAntiClump(0.1f); if (projectile.Distance(player.Center) > 2700f) { projectile.Center = player.Center; @@ -126,7 +126,7 @@ namespace CalamityMod.Projectiles.Summon float acceleration = (projectile.localAI[1] == 1f) ? 1.6f : 0.8f; float minSpeed = (projectile.localAI[1] == 1f) ? 13f : 8f; float maxSpeed = (projectile.localAI[1] == 1f) ? 21f : 18f; - projectile.velocity = projectile.DirectionTo(potentialTarget.Center) * MathHelper.Clamp(projectile.velocity.Length() + acceleration, minSpeed, maxSpeed); + projectile.velocity = projectile.SafeDirectionTo(potentialTarget.Center) * MathHelper.Clamp(projectile.velocity.Length() + acceleration, minSpeed, maxSpeed); projectile.rotation = projectile.AngleTo(potentialTarget.Center) + (projectile.spriteDirection == 1).ToInt() * MathHelper.Pi; } else if (projectile.ai[0] > 0) @@ -137,7 +137,7 @@ namespace CalamityMod.Projectiles.Summon else if (projectile.Distance(potentialTarget.Center) >= 1100f) { projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(potentialTarget.Center) + (projectile.spriteDirection == 1).ToInt() * MathHelper.Pi, 0.1f); - projectile.velocity = projectile.DirectionTo(potentialTarget.Center) * MathHelper.Clamp(projectile.velocity.Length() + 2f, 6f, 15f); + projectile.velocity = projectile.SafeDirectionTo(potentialTarget.Center) * MathHelper.Clamp(projectile.velocity.Length() + 2f, 6f, 15f); SeekingTarget = true; projectile.ai[0] = 0f; } diff --git a/Projectiles/Summon/EndoHydraHead.cs b/Projectiles/Summon/EndoHydraHead.cs index 664a2756cc..6352c75f0e 100644 --- a/Projectiles/Summon/EndoHydraHead.cs +++ b/Projectiles/Summon/EndoHydraHead.cs @@ -119,9 +119,7 @@ namespace CalamityMod.Projectiles.Summon if (targetAliveAndInLineOfSight && target.CanBeChasedBy() && Main.myPlayer == projectile.owner) { if (Time % 40f == 24f) - { - Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(target.Center) * 6f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); - } + Projectile.NewProjectile(projectile.Center, projectile.SafeDirectionTo(target.Center) * 6f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); if (Time % 40f >= 33f) projectile.frame = Main.projFrames[projectile.type] - 1; @@ -155,7 +153,7 @@ namespace CalamityMod.Projectiles.Summon if (distanceFromTarget > 7f) { float speed = MathHelper.Lerp(2f, 17f, Utils.InverseLerp(10f, 70f, distanceFromTarget, true)); - projectile.velocity = (projectile.velocity * 9f + projectile.DirectionTo(returnPosition) * speed) / 10f; + projectile.velocity = (projectile.velocity * 9f + projectile.SafeDirectionTo(returnPosition) * speed) / 10f; } if (projectile.Center.Y > body.Center.Y - 50f) diff --git a/Projectiles/Summon/EnergyOrb.cs b/Projectiles/Summon/EnergyOrb.cs index 99a5a385df..aa64f7219c 100644 --- a/Projectiles/Summon/EnergyOrb.cs +++ b/Projectiles/Summon/EnergyOrb.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Summon } NPC potentialTarget = projectile.Center.MinionHoming(400f, Main.player[projectile.owner]); if (potentialTarget != null) - projectile.velocity = (projectile.velocity * 20f + projectile.DirectionTo(potentialTarget.Center) * 10f) / 21f; + projectile.velocity = (projectile.velocity * 20f + projectile.SafeDirectionTo(potentialTarget.Center) * 10f) / 21f; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Summon/FlameBlast.cs b/Projectiles/Summon/FlameBlast.cs index d011320652..1269feae56 100644 --- a/Projectiles/Summon/FlameBlast.cs +++ b/Projectiles/Summon/FlameBlast.cs @@ -72,7 +72,7 @@ namespace CalamityMod.Projectiles.Summon } NPC potentialTarget = projectile.Center.MinionHoming(300f, Main.player[projectile.owner]); if (potentialTarget != null) - projectile.velocity = (projectile.velocity * 20f + projectile.DirectionTo(potentialTarget.Center) * 25f) / 21f; + projectile.velocity = (projectile.velocity * 20f + projectile.SafeDirectionTo(potentialTarget.Center) * 25f) / 21f; } public override void Kill(int timeLeft) diff --git a/Projectiles/Summon/FlameBurst.cs b/Projectiles/Summon/FlameBurst.cs index 183098f5bf..00d7233e4d 100644 --- a/Projectiles/Summon/FlameBurst.cs +++ b/Projectiles/Summon/FlameBurst.cs @@ -72,7 +72,7 @@ namespace CalamityMod.Projectiles.Summon } NPC potentialTarget = projectile.Center.MinionHoming(1200f, Main.player[projectile.owner]); if (potentialTarget != null) - projectile.velocity = (projectile.velocity * 20f + projectile.DirectionTo(potentialTarget.Center) * 20f) / 21f; + projectile.velocity = (projectile.velocity * 20f + projectile.SafeDirectionTo(potentialTarget.Center) * 20f) / 21f; } public override void Kill(int timeLeft) diff --git a/Projectiles/Summon/FlyingOrthocera.cs b/Projectiles/Summon/FlyingOrthocera.cs index 423efb030a..f77650b307 100644 --- a/Projectiles/Summon/FlyingOrthocera.cs +++ b/Projectiles/Summon/FlyingOrthocera.cs @@ -68,9 +68,7 @@ namespace CalamityMod.Projectiles.Summon if (projectile.ai[0]++ % 30f == 29f) { if (projectile.owner == Main.myPlayer) - { - Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(potentialTarget.Center) * 11f, ModContent.ProjectileType(), projectile.damage, 4f, projectile.owner); - } + Projectile.NewProjectile(projectile.Center, projectile.SafeDirectionTo(potentialTarget.Center, Vector2.UnitY) * 11f, ModContent.ProjectileType(), projectile.damage, 4f, projectile.owner); } } else diff --git a/Projectiles/Summon/FrostBlossom.cs b/Projectiles/Summon/FrostBlossom.cs index 6f0b771a20..53a6441b6d 100644 --- a/Projectiles/Summon/FrostBlossom.cs +++ b/Projectiles/Summon/FrostBlossom.cs @@ -87,11 +87,9 @@ namespace CalamityMod.Projectiles.Summon NPC potentialTarget = projectile.Center.MinionHoming(500f, player); if (potentialTarget != null) { - if (projectile.ai[1]++ % 35f == 34f && - Collision.CanHit(projectile.position, projectile.width, projectile.height, potentialTarget.position, potentialTarget.width, potentialTarget.height)) + if (projectile.ai[1]++ % 35f == 34f && Collision.CanHit(projectile.position, projectile.width, projectile.height, potentialTarget.position, potentialTarget.width, potentialTarget.height)) { - Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(potentialTarget.Center) * 20f, - ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + Projectile.NewProjectile(projectile.Center, projectile.SafeDirectionTo(potentialTarget.Center) * 20f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); } } } diff --git a/Projectiles/Summon/FungalClumpMinion.cs b/Projectiles/Summon/FungalClumpMinion.cs index 12c480bc43..842e6d5847 100644 --- a/Projectiles/Summon/FungalClumpMinion.cs +++ b/Projectiles/Summon/FungalClumpMinion.cs @@ -219,18 +219,12 @@ namespace CalamityMod.Projectiles.Summon projectile.friendly = true; float minionSpeed = amalgam ? 20f : 8f; float turnSpeed = 14f; - Vector2 targetLocation = targetVec - projectile.Center; - float targetDist = targetLocation.Length(); + float targetDist = projectile.Distance(targetVec); if (targetDist < 100f) minionSpeed = amalgam ? 25f : 10f; - Vector2 homeInVector = projectile.DirectionTo(targetLocation); - if (homeInVector.HasNaNs()) - homeInVector = Vector2.UnitY; - - targetLocation.Normalize(); - targetLocation *= minionSpeed; - projectile.velocity = (projectile.velocity * turnSpeed + targetLocation) / (turnSpeed + 1f); + Vector2 homingVelocity = projectile.SafeDirectionTo(targetVec) * minionSpeed; + projectile.velocity = (projectile.velocity * turnSpeed + homingVelocity) / (turnSpeed + 1f); } else { diff --git a/Projectiles/Summon/GammaCanister.cs b/Projectiles/Summon/GammaCanister.cs index 7c45c9affb..4e73e67f94 100644 --- a/Projectiles/Summon/GammaCanister.cs +++ b/Projectiles/Summon/GammaCanister.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Projectiles.Summon else if (potentialTarget != null) { // This looks quite stupid but the weapon is going to be useless otherwise and I'm not reworking this thing a 3rd time. - projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.DirectionTo(potentialTarget.Center) * 18f, 0.18f); + projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.SafeDirectionTo(potentialTarget.Center) * 18f, 0.18f); } projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; projectile.alpha = Utils.Clamp(projectile.alpha - 22, 0, 255); diff --git a/Projectiles/Summon/GammaHead.cs b/Projectiles/Summon/GammaHead.cs index 39baa1a432..726153072c 100644 --- a/Projectiles/Summon/GammaHead.cs +++ b/Projectiles/Summon/GammaHead.cs @@ -143,7 +143,8 @@ namespace CalamityMod.Projectiles.Summon Vector2 spawnPosition = projectile.Center; float shootSpeed = MathHelper.Lerp(8f, 20f, Utils.InverseLerp(90f, 850f, target.Distance(spawnPosition), true)); - Vector2 shootVelocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(spawnPosition, target.Center, GammaCanister.Gravity, shootSpeed, projectile.DirectionTo(target.Center)); + Vector2 shootVelocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(spawnPosition, target.Center, GammaCanister.Gravity, shootSpeed, projectile.SafeDirectionTo(target.Center)); + float fireAngle = shootVelocity.ToRotation(); // Direction affecting. @@ -162,7 +163,7 @@ namespace CalamityMod.Projectiles.Summon if (distanceFromTarget > 7f) { float flySpeed = MathHelper.Lerp(2f, 17f, Utils.InverseLerp(10f, 70f, distanceFromTarget, true)); - projectile.velocity = (projectile.velocity * 9f + projectile.DirectionTo(returnPosition) * flySpeed) / 10f; + projectile.velocity = (projectile.velocity * 9f + projectile.SafeDirectionTo(returnPosition) * flySpeed) / 10f; } int totalHeads = CalamityUtils.CountProjectiles(projectile.type); diff --git a/Projectiles/Summon/GiantIbanRobotOfDoom.cs b/Projectiles/Summon/GiantIbanRobotOfDoom.cs index e07cd41eb6..3ae46abad2 100644 --- a/Projectiles/Summon/GiantIbanRobotOfDoom.cs +++ b/Projectiles/Summon/GiantIbanRobotOfDoom.cs @@ -152,10 +152,13 @@ namespace CalamityMod.Projectiles.Summon { ExitChargeModeEarly(player); } - player.velocity = Vector2.Lerp(player.velocity, projectile.DirectionTo(Main.MouseWorld) * RightIconLungeSpeed, 0.225f); + + player.velocity = Vector2.Lerp(player.velocity, projectile.SafeDirectionTo(Main.MouseWorld, Vector2.UnitY) * RightIconLungeSpeed, 0.225f); projectile.rotation = player.velocity.ToRotation() + MathHelper.PiOver2; } - else projectile.rotation = 0f; + else + projectile.rotation = 0f; + if (player.mount != null) // Kill any mounts { player.mount.Dismount(player); @@ -439,13 +442,13 @@ namespace CalamityMod.Projectiles.Summon dust.noGravity = true; dust.scale = 1.6f; dust.position = player.Center + outwardness * (MathHelper.TwoPi / 10f * angleInterval).ToRotationVector2().RotatedBy(angle); - dust.velocity = player.DirectionTo(dust.position) * 8f * speedSign; + dust.velocity = player.SafeDirectionTo(dust.position) * 8f * speedSign; dust = Dust.NewDustPerfect(projectile.Center, 221); dust.noGravity = true; dust.scale = 1.6f; dust.position = player.Center + outwardness * (MathHelper.TwoPi / 10f * angleInterval).ToRotationVector2().RotatedBy(-angle); - dust.velocity = player.DirectionTo(dust.position) * 8f * speedSign; + dust.velocity = player.SafeDirectionTo(dust.position) * 8f * speedSign; } } } diff --git a/Projectiles/Summon/Hiveling.cs b/Projectiles/Summon/Hiveling.cs index 8088c8ebc9..f8b7788367 100644 --- a/Projectiles/Summon/Hiveling.cs +++ b/Projectiles/Summon/Hiveling.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Projectiles.Summon NPC potentialTarget = projectile.Center.MinionHoming(1200f, Main.player[projectile.owner]); if (potentialTarget != null) - projectile.velocity = (projectile.velocity * 30f + projectile.DirectionTo(potentialTarget.Center) * 10f) / 31f; + projectile.velocity = (projectile.velocity * 30f + projectile.SafeDirectionTo(potentialTarget.Center) * 10f) / 31f; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Summon/HomingGammaBullet.cs b/Projectiles/Summon/HomingGammaBullet.cs index 61e6d97f7b..933b4065ff 100644 --- a/Projectiles/Summon/HomingGammaBullet.cs +++ b/Projectiles/Summon/HomingGammaBullet.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Summon NPC potentialTarget = projectile.Center.MinionHoming(1000f, Main.player[projectile.owner]); if (potentialTarget != null && !projectile.WithinRange(potentialTarget.Center, 100f) && projectile.timeLeft < 290) - projectile.velocity = (projectile.velocity * 6f + projectile.DirectionTo(potentialTarget.Center) * 15f) / 7f; + projectile.velocity = (projectile.velocity * 6f + projectile.SafeDirectionTo(potentialTarget.Center) * 15f) / 7f; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => target.AddBuff(ModContent.BuffType(), 240); diff --git a/Projectiles/Summon/HowlsHeartFireball.cs b/Projectiles/Summon/HowlsHeartFireball.cs index 8dc31d65be..bea3cb6f03 100644 --- a/Projectiles/Summon/HowlsHeartFireball.cs +++ b/Projectiles/Summon/HowlsHeartFireball.cs @@ -106,11 +106,8 @@ namespace CalamityMod.Projectiles.Summon if (homeIn) { - Vector2 homeInVector = projectile.DirectionTo(center); - if (homeInVector.HasNaNs()) - homeInVector = Vector2.UnitY; - - projectile.velocity = (projectile.velocity * 20f + homeInVector * 21f) / (21f); + Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * 20f + moveDirection * 21f) / (21f); } int blueT = Dust.NewDust(projectile.position, projectile.width, projectile.height, 59, 0f, 0f, 100, default, 0.6f); diff --git a/Projectiles/Summon/LanternFlame.cs b/Projectiles/Summon/LanternFlame.cs index 34d85d07a6..89bd124696 100644 --- a/Projectiles/Summon/LanternFlame.cs +++ b/Projectiles/Summon/LanternFlame.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Projectiles.Summon { NPC potentialTarget = projectile.Center.MinionHoming(700f, Main.player[projectile.owner]); if (potentialTarget != null) - projectile.velocity = (projectile.velocity * 20f + projectile.DirectionTo(potentialTarget.Center) * 16f) / 21f; + projectile.velocity = (projectile.velocity * 20f + projectile.SafeDirectionTo(potentialTarget.Center) * 16f) / 21f; } } diff --git a/Projectiles/Summon/MK2RocketHoming.cs b/Projectiles/Summon/MK2RocketHoming.cs index 29d7cf5828..3472cab2ef 100644 --- a/Projectiles/Summon/MK2RocketHoming.cs +++ b/Projectiles/Summon/MK2RocketHoming.cs @@ -35,9 +35,8 @@ namespace CalamityMod.Projectiles.Summon NPC potentialTarget = projectile.Center.MinionHoming(1000f, player); if (potentialTarget != null) - { - projectile.velocity = (projectile.velocity * 24f + projectile.DirectionTo(potentialTarget.Center) * 14f) / 25f; - } + projectile.velocity = (projectile.velocity * 24f + projectile.SafeDirectionTo(potentialTarget.Center) * 14f) / 25f; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; projectile.frameCounter++; if (projectile.frameCounter > 6) diff --git a/Projectiles/Summon/MechwormHead.cs b/Projectiles/Summon/MechwormHead.cs index 55877e94eb..987d15575b 100644 --- a/Projectiles/Summon/MechwormHead.cs +++ b/Projectiles/Summon/MechwormHead.cs @@ -292,7 +292,7 @@ namespace CalamityMod.Projectiles.Summon projectile.velocity = projectile.velocity.ToRotation().AngleTowards(projectile.AngleTo(target.Center), angularTurnSpeed).ToRotationVector2() * newSpeed; // If the worm is very close to aiming directly at the target, immediately switch from redirecting to charging. - if (Vector2.Dot(projectile.velocity.SafeNormalize(Vector2.Zero), projectile.DirectionTo(target.Center)) > 0.86f) + if (Vector2.Dot(projectile.velocity.SafeNormalize(Vector2.Zero), projectile.SafeDirectionTo(target.Center)) > 0.86f) { AttackStateTimer += LaserRedirectFrames - (AttackStateTimer % LaserChargeFrames); projectile.netUpdate = true; @@ -303,7 +303,7 @@ namespace CalamityMod.Projectiles.Summon if (AttackStateTimer % (LaserChargeFrames + LaserRedirectFrames) == LaserChargeFrames) { // Charge and fire three lasers. - projectile.velocity = projectile.DirectionTo(target.Center) * MaxAttackFlySpeed; + projectile.velocity = projectile.SafeDirectionTo(target.Center) * MaxAttackFlySpeed; if (Main.myPlayer == projectile.owner) { @@ -379,7 +379,7 @@ namespace CalamityMod.Projectiles.Summon } projectile.alpha = 0; - projectile.velocity = projectile.DirectionTo(TeleportEndingPoint) * (MaxAttackFlySpeed + target.velocity.Length() * 0.45f); + projectile.velocity = projectile.SafeDirectionTo(TeleportEndingPoint) * (MaxAttackFlySpeed + target.velocity.Length() * 0.45f); projectile.netUpdate = true; } } diff --git a/Projectiles/Summon/MidnightSunUFO.cs b/Projectiles/Summon/MidnightSunUFO.cs index f3132eea99..b4b30c730c 100644 --- a/Projectiles/Summon/MidnightSunUFO.cs +++ b/Projectiles/Summon/MidnightSunUFO.cs @@ -95,12 +95,12 @@ namespace CalamityMod.Projectiles.Summon } float angle = MathHelper.ToRadians(2f * projectile.ai[0] % 180f); Vector2 destination = potentialTarget.Center - new Vector2((float)Math.Cos(angle) * potentialTarget.width * 0.65f, 250f); - projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.DirectionTo(destination) * 24f, 0.03f); + projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.SafeDirectionTo(destination) * 24f, 0.03f); + if (projectile.ai[0] % 3f == 2f && potentialTarget.Top.Y > projectile.Bottom.Y) { - Projectile.NewProjectile(projectile.Bottom, projectile.DirectionTo(potentialTarget.Center).RotatedByRandom(0.15f) * 25f, - ModContent.ProjectileType(), - projectile.damage, projectile.knockBack, projectile.owner); + Vector2 laserVelocity = projectile.SafeDirectionTo(potentialTarget.Center, Vector2.UnitY).RotatedByRandom(0.15f) * 25f; + Projectile.NewProjectile(projectile.Bottom, laserVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); } projectile.MinionAntiClump(0.35f); } @@ -137,7 +137,7 @@ namespace CalamityMod.Projectiles.Summon } else { - projectile.velocity = (projectile.velocity * 15f + projectile.DirectionTo(player.Center - new Vector2(player.direction * -80f, 160f)) * 19f) / 16f; + projectile.velocity = (projectile.velocity * 15f + projectile.SafeDirectionTo(player.Center - new Vector2(player.direction * -80f, 160f)) * 19f) / 16f; Vector2 distanceVector = player.Center - projectile.Center; if (distanceVector.Length() > DistanceToCheck * 1.5f) diff --git a/Projectiles/Summon/PlaguebringerMK2.cs b/Projectiles/Summon/PlaguebringerMK2.cs index 559121220d..77a5bf8b73 100644 --- a/Projectiles/Summon/PlaguebringerMK2.cs +++ b/Projectiles/Summon/PlaguebringerMK2.cs @@ -76,21 +76,19 @@ namespace CalamityMod.Projectiles.Summon projectile.velocity *= 0.9f; } else - { - Vector2 velocity = projectile.DirectionTo(destination) * projectile.Distance(destination) / 36f; - projectile.velocity = velocity; - } + projectile.velocity = projectile.SafeDirectionTo(destination) * projectile.Distance(destination) / 36f; + int timeNeeded = (int)MathHelper.Lerp(60f, 18f, MathHelper.Clamp(projectile.localAI[1] / 320f, 0f, 1f)); if (projectile.ai[0] >= timeNeeded && Main.myPlayer == projectile.owner) { Projectile.NewProjectile(projectile.Center, - projectile.DirectionTo(potentialTarget.Center) * 14f, + projectile.SafeDirectionTo(potentialTarget.Center) * 14f, ModContent.ProjectileType(), (int)(projectile.damage * 0.9), 3f, projectile.owner); Projectile.NewProjectile(projectile.Center, - projectile.DirectionTo(potentialTarget.Center) * 11.5f, + projectile.SafeDirectionTo(potentialTarget.Center) * 11.5f, ModContent.ProjectileType(), (int)(projectile.damage * 0.9), 3f, diff --git a/Projectiles/Summon/PowerfulRaven.cs b/Projectiles/Summon/PowerfulRaven.cs index c04550dbc3..d946a9477b 100644 --- a/Projectiles/Summon/PowerfulRaven.cs +++ b/Projectiles/Summon/PowerfulRaven.cs @@ -151,10 +151,8 @@ namespace CalamityMod.Projectiles.Summon projectile.velocity = Utils.NextVector2Unit(Main.rand) * 12f; projectile.netUpdate = true; } - else if (projectile.Distance(player.Center) > 90f) - { - projectile.velocity = (projectile.velocity * 19f + projectile.DirectionTo(player.Center) * 12f) / 20f; - } + else if (!projectile.WithinRange(player.Center, 90f)) + projectile.velocity = (projectile.velocity * 19f + projectile.SafeDirectionTo(player.Center) * 12f) / 20f; } projectile.direction = projectile.spriteDirection = (projectile.velocity.X > 0).ToDirectionInt(); } diff --git a/Projectiles/Summon/RadiantResolutionAura.cs b/Projectiles/Summon/RadiantResolutionAura.cs index 718b0202de..6bcaedbc13 100644 --- a/Projectiles/Summon/RadiantResolutionAura.cs +++ b/Projectiles/Summon/RadiantResolutionAura.cs @@ -99,19 +99,20 @@ namespace CalamityMod.Projectiles.Summon for (int i = 0; i < 2; i++) { float angle = MathHelper.Lerp(-MathHelper.ToRadians(20f), MathHelper.ToRadians(20f), i / 2f); - Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(potentialTarget.Center).RotatedBy(angle) * 15f, - ModContent.ProjectileType(), radiantOrbDamage / 2, projectile.knockBack, projectile.owner); + Vector2 fireVelocity = projectile.SafeDirectionTo(potentialTarget.Center).RotatedBy(angle) * 15f; + Projectile.NewProjectile(projectile.Center, fireVelocity, ModContent.ProjectileType(), radiantOrbDamage / 2, projectile.knockBack, projectile.owner); } } if (projectile.ai[1] % radiantOrbAppearRate == radiantOrbAppearRate - 1) { - Projectile.NewProjectile(projectile.Center + Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(100f, 360f), - projectile.DirectionTo(potentialTarget.Center) * 2f, ModContent.ProjectileType(), radiantOrbDamage, projectile.knockBack * 4f, projectile.owner); + Vector2 spawnPosition = projectile.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(100f, 360f); + Vector2 bootlegRadianceOrbVelocity = projectile.SafeDirectionTo(potentialTarget.Center) * 2f; + Projectile.NewProjectile(spawnPosition, bootlegRadianceOrbVelocity, ModContent.ProjectileType(), radiantOrbDamage, projectile.knockBack * 4f, projectile.owner); for (int i = 0; i < 3; i++) { float angle = MathHelper.Lerp(-MathHelper.ToRadians(30f), MathHelper.ToRadians(30f), i / 3f); - Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(potentialTarget.Center).RotatedBy(angle) * 19f, - ModContent.ProjectileType(), radiantOrbDamage / 2, projectile.knockBack, projectile.owner); + Vector2 fireVelocity = projectile.SafeDirectionTo(potentialTarget.Center).RotatedBy(angle) * 19f; + Projectile.NewProjectile(projectile.Center, fireVelocity, ModContent.ProjectileType(), radiantOrbDamage / 2, projectile.knockBack, projectile.owner); } } } diff --git a/Projectiles/Summon/RadiantResolutionFire.cs b/Projectiles/Summon/RadiantResolutionFire.cs index e4dc3ff43d..78487162b3 100644 --- a/Projectiles/Summon/RadiantResolutionFire.cs +++ b/Projectiles/Summon/RadiantResolutionFire.cs @@ -33,9 +33,7 @@ namespace CalamityMod.Projectiles.Summon dust.noGravity = true; NPC potentialTarget = projectile.Center.MinionHoming(1750f, player); if (potentialTarget != null) - { - projectile.velocity = (projectile.velocity * 19f + projectile.DirectionTo(potentialTarget.Center) * 20f) / 20f; - } + projectile.velocity = (projectile.velocity * 19f + projectile.SafeDirectionTo(potentialTarget.Center) * 20f) / 20f; } public override void Kill(int timeLeft) diff --git a/Projectiles/Summon/RadiantResolutionOrb.cs b/Projectiles/Summon/RadiantResolutionOrb.cs index 3fb5706260..a511f4f07b 100644 --- a/Projectiles/Summon/RadiantResolutionOrb.cs +++ b/Projectiles/Summon/RadiantResolutionOrb.cs @@ -55,9 +55,7 @@ namespace CalamityMod.Projectiles.Summon { NPC potentialTarget = projectile.Center.MinionHoming(2000f, player); if (potentialTarget != null) - { - projectile.velocity = (projectile.velocity * 7f + projectile.DirectionTo(potentialTarget.Center) * 19f) / 8f; - } + projectile.velocity = (projectile.velocity * 7f + projectile.SafeDirectionTo(potentialTarget.Center) * 19f) / 8f; } } } diff --git a/Projectiles/Summon/RustyDrone.cs b/Projectiles/Summon/RustyDrone.cs index 042137dfe4..1cdc716486 100644 --- a/Projectiles/Summon/RustyDrone.cs +++ b/Projectiles/Summon/RustyDrone.cs @@ -99,7 +99,7 @@ namespace CalamityMod.Projectiles.Summon { if (projectile.Distance(player.Center) > 120f) { - projectile.velocity = (projectile.velocity * PlayerHomingInertia + projectile.DirectionTo(player.Top) * PlayerHomingSpeed) / (PlayerHomingInertia + 1); + projectile.velocity = (projectile.velocity * PlayerHomingInertia + projectile.SafeDirectionTo(player.Top) * PlayerHomingSpeed) / (PlayerHomingInertia + 1); } if (projectile.frame >= 8) { @@ -110,7 +110,7 @@ namespace CalamityMod.Projectiles.Summon { // A bit above the target, and always on the opposite side of the target's sprite direction. Vector2 destination = potentialTarget.Top + Vector2.UnitX * -potentialTarget.spriteDirection * Main.rand.NextFloat(50f, 75f) - Vector2.UnitY * 42f; - projectile.velocity = (projectile.velocity * NPCHomingInertia + projectile.DirectionTo(destination) * NPCHomingSpeed) / (NPCHomingInertia + 1); + projectile.velocity = (projectile.velocity * NPCHomingInertia + projectile.SafeDirectionTo(destination) * NPCHomingSpeed) / (NPCHomingInertia + 1); if (projectile.frame < 8) { projectile.frame = 8; diff --git a/Projectiles/Summon/SakuraBullet.cs b/Projectiles/Summon/SakuraBullet.cs index 06852ff327..5e68028f20 100644 --- a/Projectiles/Summon/SakuraBullet.cs +++ b/Projectiles/Summon/SakuraBullet.cs @@ -86,11 +86,8 @@ namespace CalamityMod.Projectiles.Summon if (homeIn) { - Vector2 homeInVector = projectile.DirectionTo(center); - if (homeInVector.HasNaNs()) - homeInVector = Vector2.UnitY; - - projectile.velocity = (projectile.velocity * 20f + homeInVector * 11f) / (21f); + Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); + 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); diff --git a/Projectiles/Summon/SilvaCrystal.cs b/Projectiles/Summon/SilvaCrystal.cs index b6261124df..2190db47b7 100644 --- a/Projectiles/Summon/SilvaCrystal.cs +++ b/Projectiles/Summon/SilvaCrystal.cs @@ -164,12 +164,7 @@ namespace CalamityMod.Projectiles.Summon projectile.ai[0] += 1f; if (projectile.ai[0] >= 5f) { - Vector2 vector154 = projectile.DirectionTo(Main.npc[num1079].Center); - if (vector154.HasNaNs()) - { - vector154 = Vector2.UnitY; - } - int num1082 = (vector154.X > 0f) ? 1 : -1; + int num1082 = (projectile.SafeDirectionTo(Main.npc[num1079].Center, Vector2.UnitY).X > 0f) ? 1 : -1; projectile.direction = num1082; projectile.ai[0] = -20f; projectile.netUpdate = true; diff --git a/Projectiles/Summon/SkeletalDragonChild.cs b/Projectiles/Summon/SkeletalDragonChild.cs index 1f3fba5610..248134b6c1 100644 --- a/Projectiles/Summon/SkeletalDragonChild.cs +++ b/Projectiles/Summon/SkeletalDragonChild.cs @@ -68,10 +68,9 @@ namespace CalamityMod.Projectiles.Summon if (target != null) { projectile.ai[1]++; - if (projectile.ai[1] % 55f == 54f && - Main.myPlayer == projectile.owner) + if (projectile.ai[1] % 55f == 54f && Main.myPlayer == projectile.owner) { - Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(target.Center) * 19f, ModContent.ProjectileType(), mother.damage, mother.knockBack, mother.owner); + Projectile.NewProjectile(projectile.Center, projectile.SafeDirectionTo(target.Center) * 19f, ModContent.ProjectileType(), mother.damage, mother.knockBack, mother.owner); } } @@ -86,7 +85,7 @@ namespace CalamityMod.Projectiles.Summon } else { - projectile.velocity = (projectile.velocity * 19f + projectile.DirectionTo(mother.Center) * 18f) / 20f; + projectile.velocity = (projectile.velocity * 19f + projectile.SafeDirectionTo(mother.Center) * 18f) / 20f; } } else diff --git a/Projectiles/Summon/SkeletalDragonMother.cs b/Projectiles/Summon/SkeletalDragonMother.cs index 754738a80f..094a4c4d8a 100644 --- a/Projectiles/Summon/SkeletalDragonMother.cs +++ b/Projectiles/Summon/SkeletalDragonMother.cs @@ -83,7 +83,7 @@ namespace CalamityMod.Projectiles.Summon (modulo >= 90 && modulo < 120f)) { if (projectile.velocity.Length() == 0f) - projectile.velocity = projectile.DirectionTo(target.Center).RotatedByRandom(0.5f) * -8f; + projectile.velocity = projectile.SafeDirectionTo(target.Center).RotatedByRandom(0.5f) * -8f; float angleToTarget = projectile.AngleTo(target.Center); float velocityAngle = projectile.velocity.ToRotation(); float resultantAngle = velocityAngle.AngleLerp(angleToTarget, 0.08f); @@ -93,7 +93,7 @@ namespace CalamityMod.Projectiles.Summon } else { - projectile.velocity = (projectile.velocity * 44f + projectile.DirectionTo(player.Center) * 24f) / 45f; + projectile.velocity = (projectile.velocity * 44f + projectile.SafeDirectionTo(player.Center) * 24f) / 45f; projectile.ai[0] += 30 - projectile.ai[0] % 30f; } projectile.ai[1] = 1f; @@ -104,9 +104,9 @@ namespace CalamityMod.Projectiles.Summon } if ((modulo >= 30f && modulo <= 60f) || (modulo >= 90f && modulo <= 120f)) { - if (projectile.owner == player.whoAmI && projectile.spriteDirection == (projectile.DirectionTo(target.Center).X > 0).ToDirectionInt()) + if (projectile.owner == player.whoAmI && projectile.spriteDirection == (projectile.SafeDirectionTo(target.Center).X > 0).ToDirectionInt()) { - Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(target.Center) * 11.5f, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner); + Projectile.NewProjectile(projectile.Center, projectile.SafeDirectionTo(target.Center) * 11.5f, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner); } } } @@ -114,7 +114,7 @@ namespace CalamityMod.Projectiles.Summon { projectile.extraUpdates = 0; projectile.ai[1] = 0f; - projectile.velocity = (projectile.velocity * 24f + projectile.DirectionTo(player.Center) * 16f) / 25f; + projectile.velocity = (projectile.velocity * 24f + projectile.SafeDirectionTo(player.Center) * 16f) / 25f; if (projectile.Distance(player.Center) > 3250f) { projectile.Center = player.Center; diff --git a/Projectiles/Summon/TacticalPlagueJet.cs b/Projectiles/Summon/TacticalPlagueJet.cs index f7f7155084..977589f42e 100644 --- a/Projectiles/Summon/TacticalPlagueJet.cs +++ b/Projectiles/Summon/TacticalPlagueJet.cs @@ -161,8 +161,7 @@ namespace CalamityMod.Projectiles.Summon else { projectile.spriteDirection = 1; - Vector2 idealVelocity = projectile.DirectionTo(potentialTarget.Center - Vector2.UnitY * 195f) * 17f; - projectile.velocity = Vector2.Lerp(projectile.velocity, idealVelocity, 0.035f); + projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.SafeDirectionTo(potentialTarget.Center - Vector2.UnitY * 195f) * 17f, 0.035f); projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(potentialTarget.Center), 0.1f); if (projectile.ai[0]++ % 75f == 24f) @@ -185,15 +184,12 @@ namespace CalamityMod.Projectiles.Summon { int rocketDamage = (int)(damage * 1.5f); float rocketKB = kb + 5f; - projIndex = Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(potentialTarget.Center) * 18f, ModContent.ProjectileType(), - rocketDamage, rocketKB, projectile.owner); + projIndex = Projectile.NewProjectile(projectile.Center, projectile.SafeDirectionTo(potentialTarget.Center) * 18f, ModContent.ProjectileType(), rocketDamage, rocketKB, projectile.owner); } + + // Fire the selected bullet, nothing special. else - { - // Fire the selected bullet, nothing special. - projIndex = Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(potentialTarget.Center) * shootSpeed, projID, - damage, kb, projectile.owner); - } + projIndex = Projectile.NewProjectile(projectile.Center, projectile.SafeDirectionTo(potentialTarget.Center) * shootSpeed, projID, damage, kb, projectile.owner); // Regardless of what was fired, force it to be a summon projectile so that summon accessories work. if (projIndex.WithinBounds(Main.maxProjectiles)) diff --git a/Projectiles/Summon/YoungDuke.cs b/Projectiles/Summon/YoungDuke.cs index b33f6107c1..1cb73ca6aa 100644 --- a/Projectiles/Summon/YoungDuke.cs +++ b/Projectiles/Summon/YoungDuke.cs @@ -102,7 +102,7 @@ namespace CalamityMod.Projectiles.Summon float chargeSpeed = playerHalfLife ? 25f : 20f; if (projectile.ai[0] >= timePerCharge) { - projectile.velocity = projectile.DirectionTo(potentialTarget.Center) * chargeSpeed; + projectile.velocity = projectile.SafeDirectionTo(potentialTarget.Center) * chargeSpeed; projectile.ai[0] = 0f; } else @@ -112,15 +112,12 @@ namespace CalamityMod.Projectiles.Summon { float intertia = 0.94f; float homeSpeed = playerHalfLife ? 38f : 32f; - projectile.velocity = Vector2.Lerp(projectile.velocity, - projectile.DirectionTo(potentialTarget.Center) * homeSpeed, - 1f - intertia); + projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.SafeDirectionTo(potentialTarget.Center) * homeSpeed, 1f - intertia); } } - else if (projectile.Distance(player.Center) > 140f) - { - projectile.velocity = (projectile.velocity * 30f + projectile.DirectionTo(player.Center) * 16f) / 31f; - } + else if (!projectile.WithinRange(player.Center, 140f)) + projectile.velocity = (projectile.velocity * 30f + projectile.SafeDirectionTo(player.Center) * 16f) / 31f; + projectile.direction = projectile.spriteDirection = (projectile.velocity.X > 0).ToDirectionInt(); } } diff --git a/Projectiles/Typeless/GodSlayerPhantom.cs b/Projectiles/Typeless/GodSlayerPhantom.cs index 2c7aa3b98a..e0742c3f11 100644 --- a/Projectiles/Typeless/GodSlayerPhantom.cs +++ b/Projectiles/Typeless/GodSlayerPhantom.cs @@ -53,12 +53,8 @@ namespace CalamityMod.Projectiles.Typeless { if (projectile.Distance(Main.player[projectile.owner].Center) > num954) { - Vector2 vector102 = projectile.DirectionTo(Main.player[projectile.owner].Center); - if (vector102.HasNaNs()) - { - vector102 = Vector2.UnitY; - } - projectile.velocity = (projectile.velocity * (num953 - 1f) + vector102 * scaleFactor12) / num953; + Vector2 moveDirection = projectile.SafeDirectionTo(Main.player[projectile.owner].Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * (num953 - 1f) + moveDirection * scaleFactor12) / num953; return; } CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); diff --git a/Projectiles/Typeless/KelvinCatalystStar.cs b/Projectiles/Typeless/KelvinCatalystStar.cs index 1610ad77a6..a364b5756e 100644 --- a/Projectiles/Typeless/KelvinCatalystStar.cs +++ b/Projectiles/Typeless/KelvinCatalystStar.cs @@ -59,11 +59,8 @@ namespace CalamityMod.Projectiles.Typeless if (homeIn) { - Vector2 homeInVector = projectile.DirectionTo(center); - if (homeInVector.HasNaNs()) - homeInVector = Vector2.UnitY; - - projectile.velocity = (projectile.velocity * 20f + homeInVector * 12f) / (21f); + Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * 20f + moveDirection * 12f) / (21f); } else projectile.Kill(); diff --git a/Projectiles/Typeless/RelicOfDeliveranceSpear.cs b/Projectiles/Typeless/RelicOfDeliveranceSpear.cs index c6fab199e7..0db00af1bd 100644 --- a/Projectiles/Typeless/RelicOfDeliveranceSpear.cs +++ b/Projectiles/Typeless/RelicOfDeliveranceSpear.cs @@ -99,7 +99,7 @@ namespace CalamityMod.Projectiles.Typeless float chargeSpeed = MathHelper.Lerp(MinChargeSpeed, MaxChargeSpeed, (projectile.ai[0] - WaitTimeRequiredForCharge) / WaitTimeRequiredForMaximumCharge); if (chargeSpeed > MaxChargeSpeed) chargeSpeed = MaxChargeSpeed; - projectile.velocity = projectile.DirectionTo(Main.MouseWorld) * chargeSpeed; + projectile.velocity = projectile.SafeDirectionTo(Main.MouseWorld) * chargeSpeed; IdealVelocity = projectile.velocity; projectile.ai[1] = chargeSpeed; Main.PlaySound(SoundID.Item73, projectile.Center); @@ -112,7 +112,7 @@ namespace CalamityMod.Projectiles.Typeless { Vector2 dustPosition = Utils.NextVector2Circular(Main.rand, projectile.width * 1.6f, projectile.height * 2.3f) / 2f + projectile.Center; Dust dust = Dust.NewDustPerfect(dustPosition, (int)CalamityDusts.ProfanedFire); - dust.velocity = projectile.DirectionFrom(dust.position) * projectile.Distance(dust.position) / 11f; + dust.velocity = projectile.SafeDirectionTo(dust.position) * projectile.Distance(dust.position) / -11f; dust.velocity += player.velocity; dust.noGravity = true; dust.fadeIn = 1.6f; @@ -146,7 +146,7 @@ namespace CalamityMod.Projectiles.Typeless projectile.localAI[0] <= MaxCharges && projectile.localAI[1] <= 0f) { - IdealVelocity = projectile.DirectionTo(Main.MouseWorld) * projectile.ai[1]; + IdealVelocity = projectile.SafeDirectionTo(Main.MouseWorld) * projectile.ai[1]; projectile.localAI[0]++; projectile.localAI[1] = 40f; Main.PlaySound(SoundID.Item73, projectile.Center); diff --git a/Utilities/DrawingUtils.cs b/Utilities/DrawingUtils.cs index b1c56729ec..eec2416998 100644 --- a/Utilities/DrawingUtils.cs +++ b/Utilities/DrawingUtils.cs @@ -158,7 +158,7 @@ namespace CalamityMod } else { - center += projectile.DirectionTo(player.MountedCenter) * hookTexture.Height; + center += projectile.SafeDirectionTo(player.MountedCenter) * hookTexture.Height; Color tileAtCenterColor = Lighting.GetColor((int)center.X / 16, (int)(center.Y / 16f)); Main.spriteBatch.Draw(hookTexture, center - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, hookTexture.Width, hookTexture.Height)), diff --git a/Utilities/EntityUtils.cs b/Utilities/EntityUtils.cs new file mode 100644 index 0000000000..bcd867859c --- /dev/null +++ b/Utilities/EntityUtils.cs @@ -0,0 +1,24 @@ +using Microsoft.Xna.Framework; +using Terraria; + +namespace CalamityMod +{ + public static partial class CalamityUtils + { + /// + /// Gets a unit direction towards an arbitrary destination for an entity based on its center. Has safety in the form of a fallback vector. + /// + /// The entity to check from. + /// The destination to get the direction to. + /// A fallback value to use in the event of an unsafe normalization. + public static Vector2 SafeDirectionTo(this Entity entity, Vector2 destination, Vector2? fallback = null) + { + // Fall back to zero by default. default(Vector2) could be used in the parameter definition, but + // this is more clear. + if (!fallback.HasValue) + fallback = Vector2.Zero; + + return (destination - entity.Center).SafeNormalize(fallback.Value); + } + } +} From 7a62e5fef77e8cb815088a57fa6d6d4f1146e24a Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 11 Apr 2021 18:50:02 -0500 Subject: [PATCH 03/32] Adjusted Yharon projectile resists --- NPCs/Yharon/Yharon.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index d1fa1b6fc3..8fb1f483d5 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -2949,8 +2949,12 @@ namespace CalamityMod.NPCs.Yharon public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { if (projectile.type == ModContent.ProjectileType()) + damage = (int)(damage * 0.7); + if (projectile.type == ModContent.ProjectileType()) damage = (int)(damage * 0.85); - } + if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + damage = (int)(damage * 0.95); + } #endregion #region HP Bar Cooldown Slot and Stats From 9968693c81344b56f53687c8d84699c622fc74e2 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 11 Apr 2021 18:50:40 -0500 Subject: [PATCH 04/32] Nerfed Phantasmal Ruin damage to 955 --- Items/Weapons/Rogue/PhantasmalRuin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/Rogue/PhantasmalRuin.cs b/Items/Weapons/Rogue/PhantasmalRuin.cs index 08ab914385..edb6b28409 100644 --- a/Items/Weapons/Rogue/PhantasmalRuin.cs +++ b/Items/Weapons/Rogue/PhantasmalRuin.cs @@ -19,7 +19,7 @@ Stealth strikes continuously leave spectral clones in their wake"); public override void SafeSetDefaults() { - item.damage = 1060; + item.damage = 955; item.knockBack = 8f; item.width = 102; From 72254a4b501db46170345ba450bc1af835a62fcb Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 11 Apr 2021 18:51:10 -0500 Subject: [PATCH 05/32] Buffed Executioner's Blade damage to 181 --- Items/Weapons/Rogue/ExecutionersBlade.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/Rogue/ExecutionersBlade.cs b/Items/Weapons/Rogue/ExecutionersBlade.cs index 43ea6ac838..4a23b4dd1d 100644 --- a/Items/Weapons/Rogue/ExecutionersBlade.cs +++ b/Items/Weapons/Rogue/ExecutionersBlade.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SafeSetDefaults() { item.width = 64; - item.damage = 168; + item.damage = 181; item.noMelee = true; item.noUseGraphic = true; item.useTime = 3; From 91accfb21828cac3ddf71d57fcd10ec7f4977081 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 11 Apr 2021 18:51:38 -0500 Subject: [PATCH 06/32] Buffed God's Paranoia damage to 70 --- Items/Weapons/Rogue/GodsParanoia.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/Rogue/GodsParanoia.cs b/Items/Weapons/Rogue/GodsParanoia.cs index c6c7f4f6aa..8509185fcf 100644 --- a/Items/Weapons/Rogue/GodsParanoia.cs +++ b/Items/Weapons/Rogue/GodsParanoia.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Weapons.Rogue { public class GodsParanoia : RogueWeapon { - private static int damage = 66; + private static int damage = 70; private static int knockBack = 5; public override void SetStaticDefaults() From f5f84acf4cf6abaa3a8449c4d5514d2aa1b38353 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 11 Apr 2021 18:51:59 -0500 Subject: [PATCH 07/32] Buffed Penumbra's damage to 1008 --- Items/Weapons/Rogue/Penumbra.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/Rogue/Penumbra.cs b/Items/Weapons/Rogue/Penumbra.cs index 288bb9377e..afb2183f5e 100644 --- a/Items/Weapons/Rogue/Penumbra.cs +++ b/Items/Weapons/Rogue/Penumbra.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.value = Item.buyPrice(1, 80, 0, 0); item.rare = ItemRarityID.Red; - item.damage = 806; + item.damage = 1008; item.useAnimation = 40; item.useTime = 40; item.knockBack = 8f; From 523bccf5e2c2575aff45275d54efc1f875688219 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 11 Apr 2021 18:52:30 -0500 Subject: [PATCH 08/32] Buffed Eclipse's Fall damage to 512 --- Items/Weapons/Rogue/EclipsesFall.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/Rogue/EclipsesFall.cs b/Items/Weapons/Rogue/EclipsesFall.cs index 71290a0580..7cb2780183 100644 --- a/Items/Weapons/Rogue/EclipsesFall.cs +++ b/Items/Weapons/Rogue/EclipsesFall.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SafeSetDefaults() { - item.damage = 487; + item.damage = 512; item.knockBack = 3.5f; item.useAnimation = item.useTime = 21; item.autoReuse = true; From 9083b2907552cc7b2d53d9bab8e7c9ca08dd1e79 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 11 Apr 2021 18:52:54 -0500 Subject: [PATCH 09/32] Buffed Hypothermia damage to 216 --- Items/Weapons/Rogue/Hypothermia.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/Rogue/Hypothermia.cs b/Items/Weapons/Rogue/Hypothermia.cs index 88d540ac4c..a4fecafe3e 100644 --- a/Items/Weapons/Rogue/Hypothermia.cs +++ b/Items/Weapons/Rogue/Hypothermia.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.value = Item.buyPrice(1, 80, 0, 0); item.rare = ItemRarityID.Red; - item.damage = 176; + item.damage = 216; item.useAnimation = 21; item.useTime = 3; item.reuseDelay = 1; From 59e4c501ee6aa85f49c843bb12510db89819457c Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 11 Apr 2021 18:53:20 -0500 Subject: [PATCH 10/32] Nerfed Plasma Grenade's damage to 1312 --- Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs b/Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs index e7f50a0060..8c494e15b1 100644 --- a/Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs +++ b/Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal item.width = 22; item.height = 28; - item.damage = 1640; + item.damage = 1312; item.noMelee = true; item.noUseGraphic = true; item.consumable = true; From ee7e30f62fe293ac66a85fba8b690216ef8e1eaf Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 11 Apr 2021 18:53:39 -0500 Subject: [PATCH 11/32] Nerfed Pole Warper damage to 310 --- Items/Weapons/DraedonsArsenal/PoleWarper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/DraedonsArsenal/PoleWarper.cs b/Items/Weapons/DraedonsArsenal/PoleWarper.cs index 8a993c2ab7..709fd95d9e 100644 --- a/Items/Weapons/DraedonsArsenal/PoleWarper.cs +++ b/Items/Weapons/DraedonsArsenal/PoleWarper.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal CalamityGlobalItem modItem = item.Calamity(); item.shootSpeed = 10f; - item.damage = 356; + item.damage = 310; item.mana = 12; item.width = 38; item.height = 24; From dc593e7f62cffea5fcf9210326d5d607b0c63f02 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 11 Apr 2021 18:54:10 -0500 Subject: [PATCH 12/32] Nerfed T1000 damage to 142 --- Items/Weapons/Magic/T1000.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/Magic/T1000.cs b/Items/Weapons/Magic/T1000.cs index 47b6607b42..872b6fc0b6 100644 --- a/Items/Weapons/Magic/T1000.cs +++ b/Items/Weapons/Magic/T1000.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 150; + item.damage = 142; item.magic = true; item.mana = 10; item.width = 20; From de4141aa041438ebf7bb35f7e57e5eddca9eddbf Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 11 Apr 2021 18:54:53 -0500 Subject: [PATCH 13/32] Net nerfed Light God's Brilliance --- Items/Weapons/Magic/LightGodsBrilliance.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Items/Weapons/Magic/LightGodsBrilliance.cs b/Items/Weapons/Magic/LightGodsBrilliance.cs index 6ab86a9318..daeda0ae41 100644 --- a/Items/Weapons/Magic/LightGodsBrilliance.cs +++ b/Items/Weapons/Magic/LightGodsBrilliance.cs @@ -17,13 +17,12 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 62; + item.damage = 64; item.magic = true; item.mana = 4; item.width = 34; item.height = 36; - item.useTime = 3; - item.useAnimation = 3; + item.useTime = item.useAnimation = 4; item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 3f; @@ -40,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - int totalBeads = Main.rand.Next(2, 3 + 1); + int totalBeads = 2; for (int index = 0; index < totalBeads; index++) { float SpeedX = speedX + (float)Main.rand.Next(-50, 51) * 0.05f; From 9f69f9ffcc83ce6e09ecba6f09dd093e07163b9f Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 11 Apr 2021 18:55:25 -0500 Subject: [PATCH 14/32] Buffed Primordial Ancient damage to 170 --- Items/Weapons/Magic/PrimordialAncient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/Magic/PrimordialAncient.cs b/Items/Weapons/Magic/PrimordialAncient.cs index 6b380c6aa8..ccbfe09aee 100644 --- a/Items/Weapons/Magic/PrimordialAncient.cs +++ b/Items/Weapons/Magic/PrimordialAncient.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 122; + item.damage = 170; item.magic = true; item.mana = 20; item.width = 36; From 4deaff5e77c62b532574b48a61f93e379aa8a0f6 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 11 Apr 2021 18:55:47 -0500 Subject: [PATCH 15/32] Buffed Recitation of the Beast's damage to 128 --- Items/Weapons/Magic/RecitationoftheBeast.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/Magic/RecitationoftheBeast.cs b/Items/Weapons/Magic/RecitationoftheBeast.cs index f014d1daf6..70c73c1e1d 100644 --- a/Items/Weapons/Magic/RecitationoftheBeast.cs +++ b/Items/Weapons/Magic/RecitationoftheBeast.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Magic item.mana = 24; item.width = 38; item.height = 34; - item.damage = 125; + item.damage = 128; item.noMelee = true; item.useAnimation = 18; item.useStyle = ItemUseStyleID.HoldingOut; From 08b052d91e221cf98a54c9dc4f9f5df085ddd7f2 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 11 Apr 2021 18:56:14 -0500 Subject: [PATCH 16/32] Nerfed Event Horizon's damage to 130 --- Items/Weapons/Magic/EventHorizon.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/Magic/EventHorizon.cs b/Items/Weapons/Magic/EventHorizon.cs index 042c4eaadd..c33df0cf97 100644 --- a/Items/Weapons/Magic/EventHorizon.cs +++ b/Items/Weapons/Magic/EventHorizon.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Magic item.width = 28; item.height = 30; - item.damage = 148; + item.damage = 130; item.knockBack = 3.5f; item.noMelee = true; item.magic = true; From 0dc914792a8e4a823856ca4ae22e04bcb79744ed Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 11 Apr 2021 18:57:01 -0500 Subject: [PATCH 17/32] Buffed Alluvion damage to 120 --- Items/Weapons/Ranged/Alluvion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/Ranged/Alluvion.cs b/Items/Weapons/Ranged/Alluvion.cs index ffd2dc81aa..6555f98a72 100644 --- a/Items/Weapons/Ranged/Alluvion.cs +++ b/Items/Weapons/Ranged/Alluvion.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 80; + item.damage = 120; item.ranged = true; item.width = 60; item.height = 90; From 05a3486bef57a710258a15f42cd6ed38e6485856 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 11 Apr 2021 18:57:29 -0500 Subject: [PATCH 18/32] Buffed Starmada damage to 145 --- Items/Weapons/Ranged/StarfleetMK2.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/Ranged/StarfleetMK2.cs b/Items/Weapons/Ranged/StarfleetMK2.cs index 7809144154..cd793b98fd 100644 --- a/Items/Weapons/Ranged/StarfleetMK2.cs +++ b/Items/Weapons/Ranged/StarfleetMK2.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 130; + item.damage = 145; item.knockBack = 15f; item.shootSpeed = 16f; item.useStyle = ItemUseStyleID.HoldingOut; From 10492787856e63c040e67f4f21b77af54f7718c5 Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Mon, 12 Apr 2021 15:47:10 -0500 Subject: [PATCH 19/32] Nerfed Phaseslayer damage to 980 --- Items/Weapons/DraedonsArsenal/Phaseslayer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/DraedonsArsenal/Phaseslayer.cs b/Items/Weapons/DraedonsArsenal/Phaseslayer.cs index b003af15b7..9ac5070780 100644 --- a/Items/Weapons/DraedonsArsenal/Phaseslayer.cs +++ b/Items/Weapons/DraedonsArsenal/Phaseslayer.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal { public class Phaseslayer : ModItem { - public const int Damage = 1080; + public const int Damage = 980; // When below this percentage of charge, the sword is small instead of big. public const float SizeChargeThreshold = 0.25f; // The small sword barely affects damage on its own because damage is already dropping significantly at low charge. From 2c259a6f8e6878da28d6e00a540f8c31ae7a7f94 Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Mon, 12 Apr 2021 15:47:38 -0500 Subject: [PATCH 20/32] Nerfed the Obliterator damage to 255 --- Items/Weapons/Melee/TheObliterator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/Melee/TheObliterator.cs b/Items/Weapons/Melee/TheObliterator.cs index 308b48f679..3ad17f6554 100644 --- a/Items/Weapons/Melee/TheObliterator.cs +++ b/Items/Weapons/Melee/TheObliterator.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Melee item.width = 42; item.height = 40; item.melee = true; - item.damage = 276; + item.damage = 255; item.knockBack = 7.5f; item.useTime = 20; item.useAnimation = 20; From 3adb4750b01841f4d2c2ec86a65b78a95cded452 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sun, 11 Apr 2021 14:22:27 -0400 Subject: [PATCH 21/32] Refactored PSC & Andromecha's code to be in their own files --- Items/Accessories/ProfanedSoulCrystal.cs | 149 +++++++++- Items/CalamityGlobalItem.cs | 260 +----------------- .../Weapons/Summon/PrototypeAndromechaRing.cs | 93 +++++++ 3 files changed, 244 insertions(+), 258 deletions(-) diff --git a/Items/Accessories/ProfanedSoulCrystal.cs b/Items/Accessories/ProfanedSoulCrystal.cs index 5cf0b4f0c4..a72cf2a678 100644 --- a/Items/Accessories/ProfanedSoulCrystal.cs +++ b/Items/Accessories/ProfanedSoulCrystal.cs @@ -1,7 +1,9 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Summon; using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.World; +using Microsoft.Xna.Framework; using System.Collections.Generic; using Terraria; using Terraria.DataStructures; @@ -123,6 +125,152 @@ namespace CalamityMod.Items.Accessories modPlayer.profanedCrystalHide = true; } + // Moved from CalamityGlobalItem since it's just a function called in one place. + internal static bool TransformItemUsage(Item item, Player player) + { + if (player.whoAmI != Main.myPlayer) + return false; + int weaponType = item.melee ? 1 : item.ranged ? 2 : item.magic ? 3 : item.Calamity().rogue ? 4 : -1; + if (weaponType > 0) + { + if (player.Calamity().profanedSoulWeaponType != weaponType || player.Calamity().profanedSoulWeaponUsage >= 300) + { + player.Calamity().profanedSoulWeaponType = weaponType; + player.Calamity().profanedSoulWeaponUsage = 0; + } + Vector2 correctedVelocity = Main.MouseWorld - player.Center; + correctedVelocity.Normalize(); + bool shouldNerf = player.Calamity().endoCooper || player.Calamity().magicHat; //No bonkers damage memes thank you very much. + bool enrage = player.statLife <= (int)(player.statLifeMax2 * 0.5); + if (item.melee) + { + if (player.Calamity().profanedSoulWeaponUsage % (enrage ? 4 : 6) == 0) + { + if (player.Calamity().profanedSoulWeaponUsage > 0 && player.Calamity().profanedSoulWeaponUsage % (enrage ? 20 : 30) == 0) //every 5 shots is a shotgun spread + { + int numProj = 5; + + correctedVelocity *= 12f; + int spread = 3; + for (int i = 0; i < numProj; i++) + { + Vector2 perturbedspeed = new Vector2(correctedVelocity.X, correctedVelocity.Y + Main.rand.Next(-3, 4)).RotatedBy(MathHelper.ToRadians(spread)); + + Projectile.NewProjectile(player.Center.X, player.Center.Y - 10, perturbedspeed.X, perturbedspeed.Y, ModContent.ProjectileType(), (int)((shouldNerf ? 350 : 700) * player.MinionDamage()), 1f, player.whoAmI, Main.rand.NextBool(player.Calamity().profanedSoulWeaponUsage == 4 ? 5 : 7) ? 1f : 0f); + spread -= Main.rand.Next(2, 4); + Main.PlaySound(SoundID.Item20, player.Center); + } + player.Calamity().profanedSoulWeaponUsage = 0; + } + else + { + Projectile.NewProjectile(player.Center, correctedVelocity * 6.9f, ModContent.ProjectileType(), (int)((shouldNerf ? 250 : 500) * player.MinionDamage()), 1f, player.whoAmI, Main.rand.NextBool(player.Calamity().profanedSoulWeaponUsage == 4 ? 5 : 7) ? 1f : 0f, 1f); + Main.PlaySound(SoundID.Item20, player.Center); + } + + } + player.Calamity().profanedSoulWeaponUsage++; + + } + else if (item.ranged) + { + if (enrage || Main.rand.NextBool(2)) //100% chance if 50% or lower, else 1 in 2 chance + { + correctedVelocity *= 20f; + Vector2 perturbedspeed = new Vector2(correctedVelocity.X + Main.rand.Next(-3, 4), correctedVelocity.Y + Main.rand.Next(-3, 4)).RotatedBy(MathHelper.ToRadians(3)); + bool isSmallBoomer = Main.rand.NextDouble() <= (enrage ? 0.2 : 0.3); // 20% chance if enraged, else 30% This is intentional due to literally doubling the amount of projectiles fired. + bool isThiccBoomer = isSmallBoomer && Main.rand.NextDouble() <= 0.05; // 5% + int projType = isSmallBoomer ? isThiccBoomer ? 1 : 2 : 3; + int dam = (int)((shouldNerf ? 200 : 400) * player.MinionDamage()); + switch (projType) + { + case 1: //big boomer + case 2: //boomer + int proj = Projectile.NewProjectile(player.Center, perturbedspeed, ModContent.ProjectileType(), dam, 0f, player.whoAmI, projType == 1 ? 1f : 0f); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMinion = true; + break; + case 3: //bab boomer + int proj2 = Projectile.NewProjectile(player.Center, perturbedspeed, ModContent.ProjectileType(), dam, 0f, player.whoAmI, 0f); + if (proj2.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj2].Calamity().forceMinion = true; + break; + } + if (projType > 1) + { + Main.PlaySound(SoundID.Item20, player.Center); + } + } + } + else if (item.magic) + { + if (player.ownedProjectileCounts[ModContent.ProjectileType()] == 0 && player.ownedProjectileCounts[ModContent.ProjectileType()] == 0) + { + player.Calamity().profanedSoulWeaponUsage = 0; + } + int manaCost = (int)(100 * player.manaCost); + if (player.statMana < manaCost && player.Calamity().profanedSoulWeaponUsage == 0) + { + if (player.manaFlower) + { + player.QuickMana(); + } + } + if (player.statMana >= manaCost && player.Calamity().profanedSoulWeaponUsage == 0 && !player.silence) + { + player.manaRegenDelay = (int)player.maxRegenDelay; + player.statMana -= manaCost; + correctedVelocity *= 25f; + Main.PlaySound(SoundID.Item20, player.Center); + int dam = (int)((shouldNerf ? 900 : 1800) * player.MinionDamage()); + if (player.HasBuff(BuffID.ManaSickness)) + { + int sickPenalty = (int)(dam * (0.05f * ((player.buffTime[player.FindBuffIndex(BuffID.ManaSickness)] + 60) / 60))); + dam -= sickPenalty; + } + int proj = Projectile.NewProjectile(player.position, correctedVelocity, ModContent.ProjectileType(), dam, 1f, player.whoAmI, enrage ? 1f : 0f); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMinion = true; + player.Calamity().profanedSoulWeaponUsage = enrage ? 20 : 25; + } + if (player.Calamity().profanedSoulWeaponUsage > 0) + player.Calamity().profanedSoulWeaponUsage--; + } + else if (item.Calamity().rogue) + { + if (player.ownedProjectileCounts[ModContent.ProjectileType()] == 0) + { + player.Calamity().profanedSoulWeaponUsage = 0; + } + if (player.Calamity().profanedSoulWeaponUsage >= (enrage ? 69 : 180)) + { + float crystalCount = 36f; + for (float i = 0; i < crystalCount; i++) + { + float angle = MathHelper.TwoPi / crystalCount * i; + int proj = Projectile.NewProjectile(player.Center, angle.ToRotationVector2() * 8f, ModContent.ProjectileType(), (int)((shouldNerf ? 175 : 350) * player.MinionDamage()), 1f, player.whoAmI, 0f, 0f); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMinion = true; + Main.PlaySound(SoundID.Item20, player.Center); + } + player.Calamity().profanedSoulWeaponUsage = 0; + } + else if (player.Calamity().profanedSoulWeaponUsage % (enrage ? 5 : 10) == 0) + { + float angle = MathHelper.TwoPi / (enrage ? 9 : 18) * (player.Calamity().profanedSoulWeaponUsage / (enrage ? 1 : 10)); + int proj = Projectile.NewProjectile(player.Center, angle.ToRotationVector2() * 8f, ModContent.ProjectileType(), (int)((shouldNerf ? 220 : 440) * player.MinionDamage()), 1f, player.whoAmI, 1f, 0f); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMinion = true; + Main.PlaySound(SoundID.Item20, player.Center); + } + player.Calamity().profanedSoulWeaponUsage += enrage ? 1 : 2; + if (!enrage && player.Calamity().profanedSoulWeaponUsage % 2 != 0) + player.Calamity().profanedSoulWeaponUsage--; + } + } + return false; + } + public override void AddRecipes() { PSCRecipe recipe = new PSCRecipe(mod); @@ -142,7 +290,6 @@ namespace CalamityMod.Items.Accessories public class PSCRecipe : ModRecipe { - public PSCRecipe(Mod mod) : base(mod) { } public override int ConsumeItem(int type, int numRequired) diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 5b70ea1952..582bf2342f 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -555,248 +555,6 @@ namespace CalamityMod.Items } #endregion - #region Profaned Soul Crystal Attacks - - private bool HandleAttackTransforms(Item item, Player player) - { - if (player.whoAmI != Main.myPlayer) - return false; - int weaponType = item.melee ? 1 : item.ranged ? 2 : item.magic ? 3 : item.Calamity().rogue ? 4 : -1; - if (weaponType > 0) - { - if (player.Calamity().profanedSoulWeaponType != weaponType || player.Calamity().profanedSoulWeaponUsage >= 300) - { - player.Calamity().profanedSoulWeaponType = weaponType; - player.Calamity().profanedSoulWeaponUsage = 0; - } - Vector2 correctedVelocity = Main.MouseWorld - player.Center; - correctedVelocity.Normalize(); - bool shouldNerf = player.Calamity().endoCooper || player.Calamity().magicHat; //No bonkers damage memes thank you very much. - bool enrage = player.statLife <= (int)(player.statLifeMax2 * 0.5); - if (item.melee) - { - if (player.Calamity().profanedSoulWeaponUsage % (enrage ? 4 : 6) == 0) - { - if (player.Calamity().profanedSoulWeaponUsage > 0 && player.Calamity().profanedSoulWeaponUsage % (enrage ? 20 : 30) == 0) //every 5 shots is a shotgun spread - { - int numProj = 5; - - correctedVelocity *= 12f; - int spread = 3; - for (int i = 0; i < numProj; i++) - { - Vector2 perturbedspeed = new Vector2(correctedVelocity.X, correctedVelocity.Y + Main.rand.Next(-3, 4)).RotatedBy(MathHelper.ToRadians(spread)); - - Projectile.NewProjectile(player.Center.X, player.Center.Y - 10, perturbedspeed.X, perturbedspeed.Y, ModContent.ProjectileType(), (int)((shouldNerf ? 350 : 700) * player.MinionDamage()), 1f, player.whoAmI, Main.rand.NextBool(player.Calamity().profanedSoulWeaponUsage == 4 ? 5 : 7) ? 1f : 0f); - spread -= Main.rand.Next(2, 4); - Main.PlaySound(SoundID.Item20, player.Center); - } - player.Calamity().profanedSoulWeaponUsage = 0; - } - else - { - Projectile.NewProjectile(player.Center, correctedVelocity * 6.9f, ModContent.ProjectileType(), (int)((shouldNerf ? 250 : 500) * player.MinionDamage()), 1f, player.whoAmI, Main.rand.NextBool(player.Calamity().profanedSoulWeaponUsage == 4 ? 5 : 7) ? 1f : 0f, 1f); - Main.PlaySound(SoundID.Item20, player.Center); - } - - } - player.Calamity().profanedSoulWeaponUsage++; - - } - else if (item.ranged) - { - if (enrage || Main.rand.NextBool(2)) //100% chance if 50% or lower, else 1 in 2 chance - { - correctedVelocity *= 20f; - Vector2 perturbedspeed = new Vector2(correctedVelocity.X + Main.rand.Next(-3, 4), correctedVelocity.Y + Main.rand.Next(-3, 4)).RotatedBy(MathHelper.ToRadians(3)); - bool isSmallBoomer = Main.rand.NextDouble() <= (enrage ? 0.2 : 0.3); // 20% chance if enraged, else 30% This is intentional due to literally doubling the amount of projectiles fired. - bool isThiccBoomer = isSmallBoomer && Main.rand.NextDouble() <= 0.05; // 5% - int projType = isSmallBoomer ? isThiccBoomer ? 1 : 2 : 3; - int dam = (int)((shouldNerf ? 200 : 400) * player.MinionDamage()); - switch (projType) - { - case 1: //big boomer - case 2: //boomer - int proj = Projectile.NewProjectile(player.Center, perturbedspeed, ModContent.ProjectileType(), dam, 0f, player.whoAmI, projType == 1 ? 1f : 0f); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceMinion = true; - break; - case 3: //bab boomer - int proj2 = Projectile.NewProjectile(player.Center, perturbedspeed, ModContent.ProjectileType(), dam, 0f, player.whoAmI, 0f); - if (proj2.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj2].Calamity().forceMinion = true; - break; - } - if (projType > 1) - { - Main.PlaySound(SoundID.Item20, player.Center); - } - } - } - else if (item.magic) - { - if (player.ownedProjectileCounts[ModContent.ProjectileType()] == 0 && player.ownedProjectileCounts[ModContent.ProjectileType()] == 0) - { - player.Calamity().profanedSoulWeaponUsage = 0; - } - int manaCost = (int)(100 * player.manaCost); - if (player.statMana < manaCost && player.Calamity().profanedSoulWeaponUsage == 0) - { - if (player.manaFlower) - { - player.QuickMana(); - } - } - if (player.statMana >= manaCost && player.Calamity().profanedSoulWeaponUsage == 0 && !player.silence) - { - player.manaRegenDelay = (int)player.maxRegenDelay; - player.statMana -= manaCost; - correctedVelocity *= 25f; - Main.PlaySound(SoundID.Item20, player.Center); - int dam = (int)((shouldNerf ? 900 : 1800) * player.MinionDamage()); - if (player.HasBuff(BuffID.ManaSickness)) - { - int sickPenalty = (int)(dam * (0.05f * ((player.buffTime[player.FindBuffIndex(BuffID.ManaSickness)] + 60) / 60))); - dam -= sickPenalty; - } - int proj = Projectile.NewProjectile(player.position, correctedVelocity, ModContent.ProjectileType(), dam, 1f, player.whoAmI, enrage ? 1f : 0f); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceMinion = true; - player.Calamity().profanedSoulWeaponUsage = enrage ? 20 : 25; - } - if (player.Calamity().profanedSoulWeaponUsage > 0) - player.Calamity().profanedSoulWeaponUsage--; - } - else if (item.Calamity().rogue) - { - if (player.ownedProjectileCounts[ModContent.ProjectileType()] == 0) - { - player.Calamity().profanedSoulWeaponUsage = 0; - } - if (player.Calamity().profanedSoulWeaponUsage >= (enrage ? 69 : 180)) - { - float crystalCount = 36f; - for (float i = 0; i < crystalCount; i++) - { - float angle = MathHelper.TwoPi / crystalCount * i; - int proj = Projectile.NewProjectile(player.Center, angle.ToRotationVector2() * 8f, ModContent.ProjectileType(), (int)((shouldNerf ? 175 : 350) * player.MinionDamage()), 1f, player.whoAmI, 0f, 0f); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceMinion = true; - Main.PlaySound(SoundID.Item20, player.Center); - } - player.Calamity().profanedSoulWeaponUsage = 0; - } - else if (player.Calamity().profanedSoulWeaponUsage % (enrage ? 5 : 10) == 0) - { - float angle = MathHelper.TwoPi / (enrage ? 9 : 18) * (player.Calamity().profanedSoulWeaponUsage / (enrage ? 1 : 10)); - int proj = Projectile.NewProjectile(player.Center, angle.ToRotationVector2() * 8f, ModContent.ProjectileType(), (int)((shouldNerf ? 220 : 440) * player.MinionDamage()), 1f, player.whoAmI, 1f, 0f); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceMinion = true; - Main.PlaySound(SoundID.Item20, player.Center); - } - player.Calamity().profanedSoulWeaponUsage += enrage ? 1 : 2; - if (!enrage && player.Calamity().profanedSoulWeaponUsage % 2 != 0) - player.Calamity().profanedSoulWeaponUsage--; - } - } - return false; - } - #endregion - - #region Andromeda Dev Item Attacks - private bool PerformAndromedaAttacks(Item item, Player player) - { - if (player.whoAmI != Main.myPlayer) - return false; - - int robotIndex = -1; - - for (int i = 0; i < Main.projectile.Length; i++) - { - if (Main.projectile[i].active && - Main.projectile[i].type == ModContent.ProjectileType() && - Main.projectile[i].owner == player.whoAmI) - { - robotIndex = i; - break; - } - } - if (robotIndex != -1) - { - Projectile robot = Main.projectile[robotIndex]; - GiantIbanRobotOfDoom robotModProjectile = ((GiantIbanRobotOfDoom)robot.modProjectile); - if (player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0 && - robotModProjectile.TopIconActive && - (robotModProjectile.RightIconCooldown <= GiantIbanRobotOfDoom.RightIconAttackTime || - !robotModProjectile.RightIconActive)) // "Melee" attack - { - int damage = player.Calamity().andromedaState == AndromedaPlayerState.SmallRobot ? GiantIbanRobotOfDoom.RegicideBaseDamageSmall : GiantIbanRobotOfDoom.RegicideBaseDamageLarge; - if (item.Calamity().rogue) - { - damage = (int)(damage * player.RogueDamage()); - } - if (item.melee) - { - damage = (int)(damage * player.MeleeDamage()); - } - if (item.ranged) - { - damage = (int)(damage * player.RangedDamage()); - } - if (item.magic) - { - damage = (int)(damage * player.MagicDamage()); - } - if (item.summon) - { - damage = (int)(damage * player.MinionDamage()); - } - Projectile blade = Projectile.NewProjectileDirect(robot.Center + (robot.spriteDirection > 0).ToDirectionInt() * robot.width / 2 * Vector2.UnitX, - Vector2.Zero, ModContent.ProjectileType(), damage, 15f, player.whoAmI, Projectile.GetByUUID(robot.owner, robot.whoAmI)); - - if (blade.whoAmI.WithinBounds(Main.maxProjectiles)) - { - if (item.Calamity().rogue) - { - blade.Calamity().forceRogue = true; - } - if (item.melee) - { - blade.Calamity().forceMelee = true; - } - if (item.ranged) - { - blade.Calamity().forceRanged = true; - } - if (item.magic) - { - blade.Calamity().forceMagic = true; - } - if (item.summon) - { - blade.Calamity().forceMinion = true; - } - } - } - - if (!robotModProjectile.TopIconActive && - (robotModProjectile.LeftBracketActive || robotModProjectile.RightBracketActive) && - !robotModProjectile.BottomBracketActive && - robotModProjectile.LaserCooldown <= 0 && - (robotModProjectile.RightIconCooldown <= GiantIbanRobotOfDoom.RightIconAttackTime || - !robotModProjectile.RightIconActive)) // "Ranged" attack - { - robotModProjectile.LaserCooldown = AndromedaDeathRay.TrueTimeLeft * 2; - if (player.Calamity().andromedaState == AndromedaPlayerState.SmallRobot) - { - robotModProjectile.LaserCooldown = AndromedaDeathRay.TrueTimeLeft + 1; - } - } - } - return false; - } - #endregion - #region Use Item Changes public override bool UseItem(Item item, Player player) { @@ -933,26 +691,14 @@ namespace CalamityMod.Items return false; if (item.pick > 0 || item.axe > 0 || item.hammer > 0 || item.fishingPole > 0) return false; + // compiler optimization: && short-circuits, so if altFunctionUse != 0, Andromeda code is never called. if (item.Calamity().rogue || item.magic || item.ranged || item.melee) - { - if (player.altFunctionUse == 0) - return PerformAndromedaAttacks(item, player); - else return false; - } + return player.altFunctionUse == 0 && PrototypeAndromechaRing.TransformItemUsage(item, player); } // Conversion for Profaned Soul Crystal if (modPlayer.profanedCrystalBuffs && item.pick == 0 && item.axe == 0 && item.hammer == 0 && item.autoReuse && (modItem.rogue || item.magic || item.ranged || item.melee)) - { - if (player.altFunctionUse == 0) - { - return HandleAttackTransforms(item, player); - } - else - { - return AltFunctionUse(item, player); - } - } + return player.altFunctionUse == 0 ? ProfanedSoulCrystal.TransformItemUsage(item, player) : AltFunctionUse(item, player); // Check for sufficient charge if this item uses charge. if (item.type >= ItemID.Count && modItem.UsesCharge) diff --git a/Items/Weapons/Summon/PrototypeAndromechaRing.cs b/Items/Weapons/Summon/PrototypeAndromechaRing.cs index 2308e0f276..91f015d49e 100644 --- a/Items/Weapons/Summon/PrototypeAndromechaRing.cs +++ b/Items/Weapons/Summon/PrototypeAndromechaRing.cs @@ -88,5 +88,98 @@ namespace CalamityMod.Items.Weapons.Summon // Otherwise create one. return true; } + + // Moved from CalamityGlobalItem since it's just a function called in one place. + internal static bool TransformItemUsage(Item item, Player player) + { + if (player.whoAmI != Main.myPlayer) + return false; + + int robotIndex = -1; + + for (int i = 0; i < Main.projectile.Length; i++) + { + if (Main.projectile[i].active && + Main.projectile[i].type == ModContent.ProjectileType() && + Main.projectile[i].owner == player.whoAmI) + { + robotIndex = i; + break; + } + } + if (robotIndex != -1) + { + Projectile robot = Main.projectile[robotIndex]; + GiantIbanRobotOfDoom robotModProjectile = ((GiantIbanRobotOfDoom)robot.modProjectile); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0 && + robotModProjectile.TopIconActive && + (robotModProjectile.RightIconCooldown <= GiantIbanRobotOfDoom.RightIconAttackTime || + !robotModProjectile.RightIconActive)) // "Melee" attack + { + int damage = player.Calamity().andromedaState == AndromedaPlayerState.SmallRobot ? GiantIbanRobotOfDoom.RegicideBaseDamageSmall : GiantIbanRobotOfDoom.RegicideBaseDamageLarge; + if (item.Calamity().rogue) + { + damage = (int)(damage * player.RogueDamage()); + } + if (item.melee) + { + damage = (int)(damage * player.MeleeDamage()); + } + if (item.ranged) + { + damage = (int)(damage * player.RangedDamage()); + } + if (item.magic) + { + damage = (int)(damage * player.MagicDamage()); + } + if (item.summon) + { + damage = (int)(damage * player.MinionDamage()); + } + Projectile blade = Projectile.NewProjectileDirect(robot.Center + (robot.spriteDirection > 0).ToDirectionInt() * robot.width / 2 * Vector2.UnitX, + Vector2.Zero, ModContent.ProjectileType(), damage, 15f, player.whoAmI, Projectile.GetByUUID(robot.owner, robot.whoAmI)); + + if (blade.whoAmI.WithinBounds(Main.maxProjectiles)) + { + if (item.Calamity().rogue) + { + blade.Calamity().forceRogue = true; + } + if (item.melee) + { + blade.Calamity().forceMelee = true; + } + if (item.ranged) + { + blade.Calamity().forceRanged = true; + } + if (item.magic) + { + blade.Calamity().forceMagic = true; + } + if (item.summon) + { + blade.Calamity().forceMinion = true; + } + } + } + + if (!robotModProjectile.TopIconActive && + (robotModProjectile.LeftBracketActive || robotModProjectile.RightBracketActive) && + !robotModProjectile.BottomBracketActive && + robotModProjectile.LaserCooldown <= 0 && + (robotModProjectile.RightIconCooldown <= GiantIbanRobotOfDoom.RightIconAttackTime || + !robotModProjectile.RightIconActive)) // "Ranged" attack + { + robotModProjectile.LaserCooldown = AndromedaDeathRay.TrueTimeLeft * 2; + if (player.Calamity().andromedaState == AndromedaPlayerState.SmallRobot) + { + robotModProjectile.LaserCooldown = AndromedaDeathRay.TrueTimeLeft + 1; + } + } + } + return false; + } } } From ad4e60ebabed7521a9d3c8e068169e8e4f144b74 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sun, 11 Apr 2021 16:37:31 -0400 Subject: [PATCH 22/32] 1 - Partialed out all GlobalItem tooltip code into its own class. 2 - Added modular tooltip editing system. 3 - Set up Calamity's standard rarities and rarity colors to use constant integers/colors and a single utility function. 4 - In-progress usage of the modular tooltip editing system on all vanilla tooltips. --- Enums/CalamityRarity.cs | 14 +- Items/CalamityGlobalItem.cs | 2051 +--------------------------- Items/CalamityGlobalItemLoot.cs | 2 - Items/CalamityGlobalItemTooltip.cs | 1926 ++++++++++++++++++++++++++ Utilities/ItemUtils.cs | 42 + 5 files changed, 1976 insertions(+), 2059 deletions(-) create mode 100644 Items/CalamityGlobalItemTooltip.cs diff --git a/Enums/CalamityRarity.cs b/Enums/CalamityRarity.cs index bd92f19ca9..6c28e8ed3a 100644 --- a/Enums/CalamityRarity.cs +++ b/Enums/CalamityRarity.cs @@ -3,12 +3,12 @@ public enum CalamityRarity { NoEffect = 0, - Turquoise = 12, - PureGreen = 13, - DarkBlue = 14, - Violet = 15, - HotPink = 16, - Rainbow = 30, - DraedonRust = 33, + Turquoise = CalamityUtils.TurquoiseRarityValue, + PureGreen = CalamityUtils.PureGreenRarityValue, + DarkBlue = CalamityUtils.DarkBlueRarityValue, + Violet = CalamityUtils.VioletRarityValue, + HotPink = CalamityUtils.HotPinkRarityValue, + Rainbow = CalamityUtils.RainbowRarityValue, + DraedonRust = CalamityUtils.DraedonRustRarityValue, } } \ No newline at end of file diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 582bf2342f..8514f0ff90 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -3,14 +3,7 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer; using CalamityMod.Events; using CalamityMod.Items.Accessories; -using CalamityMod.Items.Armor; -using CalamityMod.Items.Placeables.Furniture.Fountains; using CalamityMod.Items.Potions; -using CalamityMod.Items.Tools; -using CalamityMod.Items.Weapons.Magic; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.NPCs.TownNPCs; @@ -24,9 +17,7 @@ using CalamityMod.UI; using CalamityMod.World; using Microsoft.Xna.Framework; using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -34,7 +25,7 @@ using Terraria.ModLoader.IO; namespace CalamityMod.Items { - public class CalamityGlobalItem : GlobalItem + public partial class CalamityGlobalItem : GlobalItem { public override bool InstancePerEntity => true; public override bool CloneNewInstances => true; @@ -821,2046 +812,6 @@ namespace CalamityMod.Items } #endregion - #region Modify Tooltips - public override void ModifyTooltips(Item item, List tooltips) - { - #region Rarity Coloration - TooltipLine nameLine = tooltips.FirstOrDefault(x => x.Name == "ItemName" && x.mod == "Terraria"); - if (nameLine != null) - { - #region Standard Post-ML Rarities - // TODO -- these should be handled automatically with a separate function and the colors should be tied to the rarity definitions - switch (customRarity) - { - default: - break; - case CalamityRarity.Turquoise: - nameLine.overrideColor = new Color(0, 255, 200); - break; - case CalamityRarity.PureGreen: - nameLine.overrideColor = new Color(0, 255, 0); - break; - case CalamityRarity.DarkBlue: - nameLine.overrideColor = new Color(43, 96, 222); - break; - case CalamityRarity.Violet: - nameLine.overrideColor = new Color(108, 45, 199); - break; - case CalamityRarity.HotPink: - nameLine.overrideColor = new Color(255, 0, 255); - break; - - case CalamityRarity.Rainbow: - nameLine.overrideColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); - break; - case CalamityRarity.DraedonRust: - nameLine.overrideColor = new Color(204, 71, 35); - break; - } - #endregion - - #region Uniquely Colored Dev Items - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = new Color(Main.DiscoR, 100, 255); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = new Color(0, 0, 255); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = Judgement.GetSyncedLightColor(); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = new Color(0.34f, 0.34f + 0.66f * Main.DiscoG / 255f, 0.34f + 0.5f * Main.DiscoG / 255f); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = ShatteredCommunity.GetRarityColor(); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(255, 166, 0), new Color(25, 250, 25), 4f); //alternates between emerald green and amber (BanditHueh) - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(210, 0, 255), new Color(255, 248, 24), 4f); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(131, 239, 255), new Color(36, 55, 230), 4f); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(255, 69, 0), new Color(139, 0, 0), 4f); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(191, 45, 71), new Color(185, 187, 253), 4f); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(204, 86, 80), new Color(237, 69, 141), 4f); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = new Color(146, 0, 0); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = new Color(129, 29, 149); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = new Color(220, 20, 60); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = new Color(254, 253, 235); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = new Color(207, 17, 117); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = new Color(227, 226, 180); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(154, 255, 151), new Color(228, 151, 255), 4f); - if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) - nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(255, 132, 22), new Color(221, 85, 7), 4f); - - // TODO -- for cleanliness, ALL color math should either be a one-line ColorSwap or inside the item's own file - // The items that currently violate this are all below: - // Eternity, Flamsteed Ring, Earth - if (item.type == ModContent.ItemType()) - { - List colorSet = new List() - { - new Color(188, 192, 193), // white - new Color(157, 100, 183), // purple - new Color(249, 166, 77), // honey-ish orange - new Color(255, 105, 234), // pink - new Color(67, 204, 219), // sky blue - new Color(249, 245, 99), // bright yellow - new Color(236, 168, 247), // purplish pink - }; - if (nameLine != null) - { - int colorIndex = (int)(Main.GlobalTime / 2 % colorSet.Count); - Color currentColor = colorSet[colorIndex]; - Color nextColor = colorSet[(colorIndex + 1) % colorSet.Count]; - nameLine.overrideColor = Color.Lerp(currentColor, nextColor, Main.GlobalTime % 2f > 1f ? 1f : Main.GlobalTime % 1f); - } - } - if (item.type == ModContent.ItemType()) - { - if (Main.GlobalTime % 1f < 0.6f) - { - nameLine.overrideColor = new Color(89, 229, 255); - } - else if (Main.GlobalTime % 1f < 0.8f) - { - nameLine.overrideColor = Color.Lerp(new Color(89, 229, 255), Color.White, (Main.GlobalTime % 1f - 0.6f) / 0.2f); - } - else - { - nameLine.overrideColor = Color.Lerp(Color.White, new Color(89, 229, 255), (Main.GlobalTime % 1f - 0.8f) / 0.2f); - } - } - if (item.type == ModContent.ItemType()) - { - List earthColors = new List() - { - new Color(255, 99, 146), - new Color(255, 228, 94), - new Color(127, 200, 248) - }; - if (nameLine != null) - { - int colorIndex = (int)(Main.GlobalTime / 2 % earthColors.Count); - Color currentColor = earthColors[colorIndex]; - Color nextColor = earthColors[(colorIndex + 1) % earthColors.Count]; - nameLine.overrideColor = Color.Lerp(currentColor, nextColor, Main.GlobalTime % 2f > 1f ? 1f : Main.GlobalTime % 1f); - } - } - #endregion - } - #endregion - - #region Stealth Accessory Prefixes Display - if (item.accessory) - { - if (!item.social && item.prefix > 0) - { - float stealthGenBoost = item.Calamity().StealthGenBonus - 1f; - if (stealthGenBoost > 0) - { - TooltipLine StealthGen = new TooltipLine(mod, "PrefixStealthGenBoost", "+" + Math.Round(stealthGenBoost * 100f) + "% stealth generation") - { - isModifier = true - }; - tooltips.Add(StealthGen); - } - } - } - #endregion - - #region Vanilla Item Tooltip Edits - if (item.type == ItemID.MagicMirror || item.type == ItemID.IceMirror || item.type == ItemID.CellPhone || item.type == ItemID.RecallPotion) - { - foreach (TooltipLine line2 in tooltips) - { - bool editLine = item.type == ItemID.CellPhone ? line2.Name == "Tooltip1" : line2.Name == "Tooltip0"; - if (line2.mod == "Terraria" && editLine) - line2.text += "\nCannot be used while a boss is alive"; - } - } - if (item.type == ItemID.Pwnhammer || item.type == ItemID.Hammush) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - line2.text += "\nDemon Altars no longer spawn ores when destroyed"; - } - } - if (item.type == ItemID.BlackBelt) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - line2.text = "Grants the ability to dodge attacks\n" + - "The dodge has a 60 second cooldown which is shared with all other dodges and reflects"; - - } - } - if (item.type == ItemID.MasterNinjaGear) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - line2.text = "Grants the ability to dodge attacks\n" + - "The dodge has a 60 second cooldown which is shared with all other dodges and reflects"; - } - } - if (item.type == ItemID.CobaltSword || item.type == ItemID.CobaltNaginata) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Knockback") - line2.text += "\nDecreases enemy defense by 10% on hit"; - } - } - if (item.type == ItemID.PalladiumSword || item.type == ItemID.PalladiumPike) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Knockback") - line2.text += "\nIncreases life regen on hit"; - } - } - if (item.type == ItemID.MythrilSword || item.type == ItemID.MythrilHalberd) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Knockback") - line2.text += "\nDecreases enemy contact damage by 10% on hit"; - } - } - if (item.type == ItemID.OrichalcumSword || item.type == ItemID.OrichalcumHalberd) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Knockback") - line2.text += "\nIncreases how frequently the Orichalcum set bonus triggers on hit"; - } - } - if (item.type == ItemID.AdamantiteSword || item.type == ItemID.AdamantiteGlaive) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Knockback") - line2.text += "\nSlows enemies on hit"; - } - } - if (item.type == ItemID.TitaniumSword || item.type == ItemID.TitaniumTrident) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Knockback") - line2.text += "\nDeals increased damage to enemies with high knockback resistance"; - } - } - if (item.type == ItemID.Excalibur || item.type == ItemID.Gungnir || item.type == ItemID.TrueExcalibur) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Knockback") - line2.text += "\nInflicts Holy Flames\n" + - "Deals double damage to enemies above 75% life"; - } - } - if (item.type == ItemID.CandyCaneSword || item.type == ItemID.FruitcakeChakram) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Knockback") - line2.text += "\nHeals you on hit"; - } - } - if (item.type == ItemID.StylistKilLaKillScissorsIWish || (item.type >= ItemID.BluePhaseblade && item.type <= ItemID.YellowPhaseblade) || (item.type >= ItemID.BluePhasesaber && item.type <= ItemID.YellowPhasesaber)) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Knockback") - line2.text += "\nIgnores 100% of enemy defense"; - } - } - if (item.type == ItemID.AntlionClaw || item.type == ItemID.BoneSword || item.type == ItemID.BreakerBlade) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Knockback") - line2.text += "\nIgnores 50% of enemy defense"; - } - } - if (item.type == ItemID.LightsBane || item.type == ItemID.NightsEdge || item.type == ItemID.TrueNightsEdge) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Knockback") - line2.text += "\nInflicts Shadowflame"; - } - } - if (item.type == ItemID.BloodButcherer || item.type == ItemID.TheRottedFork) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Knockback") - line2.text += "\nInflicts Burning Blood"; - } - } - if (item.type == ItemID.BottledHoney) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "HealLife") - line2.text += "\nGrants the Honey buff for 2 minutes"; - } - } - if (item.type == ItemID.RodofDiscord) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - line2.text += "\nTeleportation is disabled while Chaos State is active"; - } - } - if (item.type == ItemID.SuperAbsorbantSponge) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - line2.text += "\nCannot be used in the Abyss"; - } - } - if (item.type == ItemID.EmptyBucket) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Defense") - line2.text += "\nCannot be used in the Abyss"; - } - } - if (item.type == ItemID.CrimsonHeart) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - line2.text += "\nProvides a small amount of light in the abyss"; - } - } - if (item.type == ItemID.ShadowOrb) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - line2.text += "\nProvides a small amount of light in the abyss"; - } - } - if (item.type == ItemID.MagicLantern) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - line2.text += "\nProvides a small amount of light in the abyss"; - } - } - if (item.type == ItemID.ArcticDivingGear) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - { - line2.text += "\nProvides a small amount of light in the abyss\n" + - "Moderately reduces breath loss in the abyss"; - } - } - } - if (item.type == ItemID.JellyfishNecklace) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\nProvides a small amount of light in the abyss"; - } - } - } - if (item.type == ItemID.JellyfishDivingGear) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - { - line2.text += "\nProvides a small amount of light in the abyss"; - } - } - } - if (item.type == ItemID.FairyBell) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\nProvides a moderate amount of light in the abyss"; - } - } - } - if (item.type == ItemID.DD2PetGhost) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\nProvides a moderate amount of light in the abyss"; - } - } - } - if (item.type == ItemID.ShinePotion) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "BuffTime") - { - line2.text += "\nProvides a moderate amount of light in the abyss"; - } - } - } - if (item.type == ItemID.WispinaBottle) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\nProvides a large amount of light in the abyss"; - } - } - } - if (item.type == ItemID.SuspiciousLookingTentacle) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - { - line2.text += "\nProvides a large amount of light in the abyss"; - } - } - } - if (item.type == ItemID.GillsPotion) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "BuffTime") - { - line2.text += "\nGreatly reduces breath loss in the abyss"; - } - } - } - if (item.type == ItemID.DivingHelmet) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\nModerately reduces breath loss in the abyss"; - } - } - } - if (item.type == ItemID.NeptunesShell || item.type == ItemID.MoonShell) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\nGreatly reduces breath loss in the abyss"; - } - } - } - if (item.type == ItemID.CelestialShell) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - { - line2.text += "\nGreatly reduces breath loss in the abyss"; - } - } - } - if (item.type == ItemID.WarmthPotion) - { - if (CalamityWorld.death) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\nMakes you immune to the Chilled, Frozen, and Glacial State debuffs\n" + - "Provides cold protection in Death Mode"; - } - } - } - else - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\nMakes you immune to the Chilled, Frozen, and Glacial State debuffs"; - } - } - } - } - if (item.type == ItemID.FlaskofVenom) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Melee and rogue attacks inflict Venom on enemies"; - } - } - } - if (item.type == ItemID.FlaskofCursedFlames) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Melee and rogue attacks inflict enemies with cursed flames"; - } - } - } - if (item.type == ItemID.FlaskofFire) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Melee and rogue attacks set enemies on fire"; - } - } - } - if (item.type == ItemID.FlaskofGold) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Melee and rogue attacks make enemies drop more gold"; - } - } - } - if (item.type == ItemID.FlaskofIchor) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Melee and rogue attacks decrease enemy defense"; - } - } - } - if (item.type == ItemID.FlaskofNanites) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Melee and rogue attacks confuse enemies"; - } - } - } - if (item.type == ItemID.FlaskofParty) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "All attacks cause confetti to appear"; - } - } - } - if (item.type == ItemID.FlaskofPoison) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Melee and rogue attacks poison enemies"; - } - } - } - if (item.type == ItemID.WormScarf) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Reduces damage taken by 10%"; - } - } - } - if (item.type == ItemID.TitanGlove) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\n10% increased true melee damage"; - } - } - } - if (item.type == ItemID.PowerGlove) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - { - line2.text += "\n10% increased true melee damage"; - } - } - } - if (item.type == ItemID.MechanicalGlove) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - { - line2.text += "\n10% increased true melee damage"; - } - } - } - if (item.type == ItemID.FireGauntlet) - { - if (CalamityWorld.death) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - { - line2.text = "14% increased melee damage and speed\n" + - "10% increased true melee damage\n" + - "Provides heat and cold protection in Death Mode"; - } - } - } - else - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - { - line2.text = "14% increased melee damage and speed\n" + - "10% increased true melee damage"; - } - } - } - } - if (item.type == ItemID.SpectreHood) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "20% decreased magic damage"; - } - } - } - if (item.type == ItemID.ObsidianSkinPotion) - { - string heatImmunity = CalamityWorld.death ? "\nProvides heat protection in Death Mode" : ""; - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Provides immunity to direct damage from touching lava\n" + - "Provides temporary immunity to lava burn damage\n" + - "Greatly increases lava immunity time regeneration\n" + - "Reduces lava burn damage" + heatImmunity; - } - } - } - if (item.type == ItemID.ObsidianRose) - { - string heatImmunity = CalamityWorld.death ? "\nProvides heat protection in Death Mode" : ""; - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Reduced direct damage from touching lava\n" + - "Greatly reduces lava burn damage" + heatImmunity; - } - } - } - if (item.type == ItemID.MagmaStone && CalamityWorld.death) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\nProvides heat and cold protection in Death Mode"; - } - } - } - if (item.type == ItemID.LavaCharm && CalamityWorld.death) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\nProvides heat protection in Death Mode"; - } - } - } - if (item.type == ItemID.LavaWaders && CalamityWorld.death) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - { - line2.text += "\nProvides heat protection in Death Mode"; - } - } - } - if (item.type == ItemID.InvisibilityPotion) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\nBoosts certain stats when holding certain types of rogue weapons"; - } - } - } - if (item.type == ItemID.GoldenFishingRod) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "NeedsBait") - { - line2.text = "Requires bait to catch fish\n" + - "The line will never break"; - } - } - } - if (item.type == ItemID.Picksaw) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - // I'm leaving this intentionally ambiguous so that people have to search for Scoria Ore - line2.text = "Capable of mining Lihzahrd Bricks and Scoria Ore"; - } - } - } - if (item.type == ItemID.SolarFlarePickaxe) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Material") - { - line2.text = "Material\n" + - "Can mine Uelibloom Ore"; - } - } - } - if (item.type == ItemID.VortexPickaxe) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Material") - { - line2.text = "Material\n" + - "Can mine Uelibloom Ore"; - } - } - } - if (item.type == ItemID.NebulaPickaxe) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Material") - { - line2.text = "Material\n" + - "Can mine Uelibloom Ore"; - } - } - } - if (item.type == ItemID.StardustPickaxe) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Material") - { - line2.text = "Material\n" + - "Can mine Uelibloom Ore"; - } - } - } - - if (Main.player[Main.myPlayer].Calamity().trueMeleeDamage > 0D) - { - if (item.melee && item.damage > 0) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Damage") - { - line2.text += " : " + string.Concat((int)(Main.player[Main.myPlayer].Calamity().actualMeleeDamageStat * item.damage * - (1D + Main.player[Main.myPlayer].Calamity().trueMeleeDamage) + 5E-06f)) + " true melee damage"; - } - } - } - } - - if (item.type == ItemID.MeteorHelmet || item.type == ItemID.MeteorSuit || item.type == ItemID.MeteorLeggings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = "Set Bonus: Reduces the mana cost of the Space Gun by 50%"; - } - } - } - if (item.type == ItemID.CopperHelmet || item.type == ItemID.CopperChainmail || item.type == ItemID.CopperGreaves) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = "Set Bonus: +2 defense and 15% increased mining speed"; - } - } - } - if (item.type == ItemID.TinHelmet || item.type == ItemID.TinChainmail || item.type == ItemID.TinGreaves) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = "Set Bonus: +2 defense and 10% increased mining speed"; - } - } - } - if (item.type == ItemID.AncientIronHelmet || item.type == ItemID.IronHelmet || item.type == ItemID.IronChainmail || item.type == ItemID.IronGreaves) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = "Set Bonus: +2 defense and 25% increased mining speed"; - } - } - } - if (item.type == ItemID.LeadHelmet || item.type == ItemID.LeadChainmail || item.type == ItemID.LeadGreaves) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = "Set Bonus: +3 defense and 20% increased mining speed"; - } - } - } - if (item.type == ItemID.SilverHelmet || item.type == ItemID.SilverChainmail || item.type == ItemID.SilverGreaves) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = "Set Bonus: +3 defense and 35% increased mining speed"; - } - } - } - if (item.type == ItemID.TungstenHelmet || item.type == ItemID.TungstenChainmail || item.type == ItemID.TungstenGreaves) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = "Set Bonus: +3 defense and 30% increased mining speed"; - } - } - } - if (item.type == ItemID.AncientGoldHelmet || item.type == ItemID.GoldHelmet || item.type == ItemID.GoldChainmail || item.type == ItemID.GoldGreaves) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = "Set Bonus: +3 defense and 45% increased mining speed"; - } - } - } - if (item.type == ItemID.PlatinumHelmet || item.type == ItemID.PlatinumChainmail || item.type == ItemID.PlatinumGreaves) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = "Set Bonus: +4 defense and 40% increased mining speed"; - } - } - } - if (item.type == ItemID.AncientBattleArmorHat || item.type == ItemID.AncientBattleArmorShirt || item.type == ItemID.AncientBattleArmorPants) - { - if (!Main.player[Main.myPlayer].Calamity().forbiddenCirclet) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text += "\nThe minion damage nerf is reduced while wielding magic weapons"; - } - } - } - } - if (item.type == ItemID.StardustBreastplate || item.type == ItemID.StardustLeggings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Increases your max number of minions"; - } - } - } - if (item.type == ItemID.StardustHelmet || item.type == ItemID.StardustBreastplate || item.type == ItemID.StardustLeggings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text += "\nIncreases your max number of minions by 2"; - } - } - } - if (item.type == ItemID.GladiatorHelmet) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Defense") - { - line2.text = "3 defense\n" + - "3% increased rogue damage"; - } - } - } - if (item.type == ItemID.GladiatorBreastplate) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Defense") - { - line2.text = "5 defense\n" + - "3% increased rogue critical strike chance"; - } - } - } - if (item.type == ItemID.GladiatorLeggings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Defense") - { - line2.text = "4 defense\n" + - "3% increased rogue velocity"; - } - } - } - if (item.type == ItemID.ObsidianHelm) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Defense") - { - line2.text = "4 defense\n" + - "3% increased rogue damage"; - } - } - } - if (item.type == ItemID.ObsidianShirt) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Defense") - { - line2.text = "5 defense\n" + - "3% increased rogue critical strike chance"; - } - } - } - if (item.type == ItemID.ObsidianPants) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Defense") - { - line2.text = "4 defense\n" + - "3% increased rogue velocity"; - } - } - } - if (item.type == ItemID.MoltenHelmet || item.type == ItemID.MoltenBreastplate || item.type == ItemID.MoltenGreaves) - { - if (CalamityWorld.death) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = @"Set Bonus: 17% extra melee damage -20% extra true melee damage -Grants immunity to fire blocks, and temporary immunity to lava -Provides heat and cold protection in Death Mode"; - } - } - } - else - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = @"Set Bonus: 17% extra melee damage -20% extra true melee damage -Grants immunity to fire blocks, and temporary immunity to lava"; - } - } - } - } - if (item.type == ItemID.FrostHelmet || item.type == ItemID.FrostBreastplate || item.type == ItemID.FrostLeggings) - { - if (CalamityWorld.death) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text += "\nProvides heat and cold protection in Death Mode"; - } - } - } - } - if (item.type == ItemID.DD2ElderCrystal) - tooltips.FirstOrDefault(line => line.mod == "Terraria" && line.Name == "Tooltip0").text += "\nOnce placed you can right click the crystal to skip waves or increase the spawn rate of the invaders"; - - if (item.type == ItemID.MagicQuiver) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Increases arrow damage by 10% and greatly increases arrow speed"; - } - } - } - if (item.type == ItemID.MiningHelmet) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Provides light when worn\n" + - "Provides a small amount of light in the Abyss"; - } - } - } - if (item.type == ItemID.HandWarmer) - { - string coldImmunity = CalamityWorld.death ? "\nProvides cold protection in Death Mode" : ""; - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Provides immunity to chilling and freezing effects\n" + - "Provides a regeneration boost while wearing the Eskimo armor" + coldImmunity; - } - } - } - if (item.type == ItemID.AngelWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 6.25\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 100\n" + - "+20 max life, +10 defense and +2 life regen"; - } - } - } - if (item.type == ItemID.DemonWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 6.25\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 100\n" + - "5% increased damage and critical strike chance"; - } - } - } - if (item.type == ItemID.Jetpack) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 6.5\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 115"; - } - } - } - if (item.type == ItemID.ButterflyWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 6.75\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 130\n" + - "+20 max mana, 5% decreased mana usage,\n" + - "5% increased magic damage and magic critical strike chance"; - } - } - } - if (item.type == ItemID.FairyWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 6.75\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 130\n" + - "+60 max life"; - } - } - } - if (item.type == ItemID.BeeWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 6.75\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 130\n" + - "Honey buff at all times"; - } - } - } - if (item.type == ItemID.HarpyWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 7\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 140\n" + - "20% increased movement speed\n" + - "Most attacks have a chance to fire a feather on swing if Harpy Ring or Angel Treads are equipped"; - } - } - } - if (item.type == ItemID.BoneWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 7\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 140\n" + - "10% increased movement speed, ranged damage and critical strike chance\n" + - "and +30 defense while wearing the Necro Armor"; - } - } - } - if (item.type == ItemID.FlameWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 7.5\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 160\n" + - "5% increased melee damage and critical strike chance"; - } - } - } - if (item.type == ItemID.FrozenWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 7.5\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 160\n" + - "2% increased melee and ranged damage\n" + - "and 1% increased melee and ranged critical strike chance\n" + - "while wearing the Frost Armor"; - } - } - } - if (item.type == ItemID.GhostWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 7.5\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 160\n" + - "+10 defense and 5% increased damage reduction while wearing the Spectre Armor and Hood\n" + - "5% increased magic damage and critical strike chance while wearing the Spectre Armor and Mask"; - } - } - } - if (item.type == ItemID.BeetleWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 7.5\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 160\n" + - "+10 defense and 5% increased damage reduction while wearing the Beetle Armor and Shell\n" + - "5% increased melee damage and critical strike chance while wearing the Beetle Armor and Scale Mail"; - } - } - } - if (item.type == ItemID.FinWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 0\n" + - "Acceleration multiplier: 0\n" + - "Average vertical speed\n" + - "Flight time: 100\n" + - "Gills effect and you can move freely through liquids\n" + - "You fall faster while submerged in liquid\n" + - "15% increased movement speed and 18% increased jump speed"; - } - } - } - if (item.type == ItemID.FishronWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 8\n" + - "Acceleration multiplier: 2\n" + - "Good vertical speed\n" + - "Flight time: 180"; - } - } - } - if (item.type == ItemID.SteampunkWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 7.75\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 180\n" + - "+8 defense, 10% increased movement speed,\n" + - "4% increased damage, and 2% increased critical strike chance"; - } - } - } - if (item.type == ItemID.LeafWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 6.75\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 160\n" + - "+5 defense, 5% increased damage reduction,\n" + - "and the Dryad's permanent blessing while wearing the Tiki Armor"; - } - } - } - if (item.type == ItemID.BatWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 0\n" + - "Acceleration multiplier: 0\n" + - "Average vertical speed\n" + - "Flight time: 140\n" + - "At night or during an eclipse, you will gain the following boosts:\n" + - "10% increased movement speed, 10% increased jump speed,\n" + - "7% increased damage and 3% increased critical strike chance"; - } - } - } - if (item.type == ItemID.Yoraiz0rWings || item.type == ItemID.JimsWings || item.type == ItemID.SkiphsWings || - item.type == ItemID.LokisWings || item.type == ItemID.ArkhalisWings || item.type == ItemID.LeinforsWings || - item.type == ItemID.BejeweledValkyrieWing || item.type == ItemID.RedsWings || item.type == ItemID.DTownsWings || - item.type == ItemID.WillsWings || item.type == ItemID.CrownosWings || item.type == ItemID.CenxsWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "'Great for impersonating devs!'\n" + - "Horizontal speed: 7\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 150"; - } - } - } - if (item.type == ItemID.TatteredFairyWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 7.5\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 180\n" + - "5% increased damage and critical strike chance"; - } - } - } - if (item.type == ItemID.SpookyWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 7.5\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 180\n" + - "Increased minion knockback and 5% increased minion damage while wearing the Spooky Armor"; - } - } - } - if (item.type == ItemID.Hoverboard) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - { - line2.text = "Hold DOWN and JUMP to hover\n" + - "Horizontal speed: 6.25\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 170\n" + - "10% increased damage to bows, guns, rocket launchers, and flamethrowers while wearing the Shroomite Armor\n" + - "Boosted weapon type depends on the Shroomite Helmet worn"; - } - } - } - if (item.type == ItemID.FestiveWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 7.5\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 170\n" + - "+40 max life\n" + - "Ornaments rain down as you fly"; - } - } - } - if (item.type == ItemID.MothronWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 0\n" + - "Acceleration multiplier: 0\n" + - "Average vertical speed\n" + - "Flight time: 160\n" + - "+5 defense, 5% increased damage,\n" + - "10% increased movement speed and 12% increased jump speed"; - } - } - } - if (item.type == ItemID.WingsSolar) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 9\n" + - "Acceleration multiplier: 2.5\n" + - "Great vertical speed\n" + - "Flight time: 180\n" + - "7% increased melee damage and 3% increased melee critical strike chance\n" + - "while wearing the Solar Flare Armor"; - } - } - } - if (item.type == ItemID.WingsStardust) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 9\n" + - "Acceleration multiplier: 2.5\n" + - "Great vertical speed\n" + - "Flight time: 180\n" + - "+1 max minion and 5% increased minion damage while wearing the Stardust Armor"; - } - } - } - if (item.type == ItemID.WingsVortex) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Hold DOWN and JUMP to hover\n" + - "Horizontal speed: 6.5\n" + - "Acceleration multiplier: 1.5\n" + - "Good vertical speed\n" + - "Flight time: 160\n" + - "3% increased ranged damage and 7% increased ranged critical strike chance\n" + - "while wearing the Vortex Armor"; - } - } - } - if (item.type == ItemID.WingsNebula) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Hold DOWN and JUMP to hover\n" + - "Horizontal speed: 6.5\n" + - "Acceleration multiplier: 1.5\n" + - "Good vertical speed\n" + - "Flight time: 160\n" + - "+20 max mana, 5% increased magic damage and critical strike chance,\n" + - "and 5% decreased mana usage while wearing the Nebula Armor"; - } - } - } - if (item.type == ItemID.BetsyWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Allows flight and slow fall\n" + - "Hold DOWN and JUMP to hover\n" + - "Horizontal speed: 6\n" + - "Acceleration multiplier: 2.5\n" + - "Good vertical speed\n" + - "Flight time: 150"; - } - } - } - if (item.type == ItemID.GrapplingHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 18.75\n" + - "Launch Velocity: 11.5\n" + - "Pull Velocity: 11"; - } - } - } - if (item.type == ItemID.AmethystHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 18.75\n" + - "Launch Velocity: 10\n" + - "Pull Velocity: 11"; - } - } - } - if (item.type == ItemID.TopazHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 20.625\n" + - "Launch Velocity: 10.5\n" + - "Pull Velocity: 11.75"; - } - } - } - if (item.type == ItemID.SapphireHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 22.5\n" + - "Launch Velocity: 11\n" + - "Pull Velocity: 12.5"; - } - } - } - if (item.type == ItemID.EmeraldHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 24.375\n" + - "Launch Velocity: 11.5\n" + - "Pull Velocity: 13.25"; - } - } - } - if (item.type == ItemID.RubyHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 26.25\n" + - "Launch Velocity: 12\n" + - "Pull Velocity: 14"; - } - } - } - if (item.type == ItemID.DiamondHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 28.125\n" + - "Launch Velocity: 12.5\n" + - "Pull Velocity: 14.75"; - } - } - } - if (item.type == ItemID.WebSlinger) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 15.625\n" + - "Launch Velocity: 10\n" + - "Pull Velocity: 11"; - } - } - } - if (item.type == ItemID.SkeletronHand) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 21.875\n" + - "Launch Velocity: 15\n" + - "Pull Velocity: 11"; - } - } - } - if (item.type == ItemID.SlimeHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 18.75\n" + - "Launch Velocity: 13\n" + - "Pull Velocity: 11"; - } - } - } - if (item.type == ItemID.FishHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 25\n" + - "Launch Velocity: 13\n" + - "Pull Velocity: 11"; - } - } - } - if (item.type == ItemID.IvyWhip) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 25\n" + - "Launch Velocity: 13\n" + - "Pull Velocity: 15"; - } - } - } - if (item.type == ItemID.BatHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 31.25\n" + - "Launch Velocity: 15.5\n" + - "Pull Velocity: 20"; - } - } - } - if (item.type == ItemID.CandyCaneHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 25\n" + - "Launch Velocity: 11.5\n" + - "Pull Velocity: 11"; - } - } - } - if (item.type == ItemID.DualHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 27.5\n" + - "Launch Velocity: 14\n" + - "Pull Velocity: 17"; - } - } - } - if (item.type == ItemID.ThornHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 30\n" + - "Launch Velocity: 15\n" + - "Pull Velocity: 18"; - } - } - } - if (item.type == ItemID.WormHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 30\n" + - "Launch Velocity: 15\n" + - "Pull Velocity: 18"; - } - } - } - if (item.type == ItemID.TendonHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 30\n" + - "Launch Velocity: 15\n" + - "Pull Velocity: 18"; - } - } - } - if (item.type == ItemID.IlluminantHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 30\n" + - "Launch Velocity: 15\n" + - "Pull Velocity: 18"; - } - } - } - if (item.type == ItemID.AntiGravityHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 31.25\n" + - "Launch Velocity: 14\n" + - "Pull Velocity: 20"; - } - } - } - if (item.type == ItemID.SpookyHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 34.375\n" + - "Launch Velocity: 15.5\n" + - "Pull Velocity: 22"; - } - } - } - if (item.type == ItemID.ChristmasHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 34.375\n" + - "Launch Velocity: 15.5\n" + - "Pull Velocity: 17"; - } - } - } - if (item.type == ItemID.LunarHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 34.375\n" + - "Launch Velocity: 16\n" + - "Pull Velocity: 24"; - } - } - } - if (item.type == ItemID.StaticHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 37.5\n" + - "Launch Velocity: 16\n" + - "Pull Velocity: 24"; - } - } - } - if (item.type == ItemID.StaticHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 37.5\n" + - "Launch Velocity: 16\n" + - "Pull Velocity: 24"; - } - } - } - if (item.accessory) - { - if (item.prefix == PrefixID.Brisk) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "PrefixAccMoveSpeed") - line2.text = "+2% movement speed"; - } - } - if (item.prefix == PrefixID.Fleeting) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "PrefixAccMoveSpeed") - line2.text = "+4% movement speed"; - } - } - if (item.prefix == PrefixID.Hasty2) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "PrefixAccMoveSpeed") - line2.text = "+6% movement speed"; - } - } - if (item.prefix == PrefixID.Quick2) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "PrefixAccMoveSpeed") - line2.text = "+8% movement speed"; - } - } - if (item.prefix == PrefixID.Precise || item.prefix == PrefixID.Lucky) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "PrefixAccCritChance") - line2.text += "\n+1 armor penetration"; - } - } - if (item.prefix == PrefixID.Hard) - { - string defenseBoost = "+1 defense\n"; - if (CalamityWorld.downedDoG) - defenseBoost = "+4 defense\n"; - else if (CalamityWorld.downedProvidence || CalamityWorld.downedPolterghast) - defenseBoost = "+3 defense\n"; - else if (NPC.downedGolemBoss || NPC.downedMoonlord) - defenseBoost = "+2 defense\n"; - - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "PrefixAccDefense") - line2.text = defenseBoost + "+0.25% damage reduction"; - } - } - if (item.prefix == PrefixID.Guarding) - { - string defenseBoost = "+2 defense\n"; - if (CalamityWorld.downedDoG) - defenseBoost = "+8 defense\n"; - else if (CalamityWorld.downedPolterghast) - defenseBoost = "+7 defense\n"; - else if (CalamityWorld.downedProvidence) - defenseBoost = "+6 defense\n"; - else if (NPC.downedMoonlord) - defenseBoost = "+5 defense\n"; - else if (NPC.downedGolemBoss) - defenseBoost = "+4 defense\n"; - else if (Main.hardMode) - defenseBoost = "+3 defense\n"; - - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "PrefixAccDefense") - line2.text = defenseBoost + "+0.5% damage reduction"; - } - } - if (item.prefix == PrefixID.Armored) - { - string defenseBoost = "+3 defense\n"; - if (CalamityWorld.downedDoG) - defenseBoost = "+12 defense\n"; - else if (CalamityWorld.downedPolterghast) - defenseBoost = "+10 defense\n"; - else if (CalamityWorld.downedProvidence) - defenseBoost = "+9 defense\n"; - else if (NPC.downedMoonlord) - defenseBoost = "+7 defense\n"; - else if (NPC.downedGolemBoss) - defenseBoost = "+6 defense\n"; - else if (Main.hardMode) - defenseBoost = "+4 defense\n"; - - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "PrefixAccDefense") - line2.text = defenseBoost + "+0.75% damage reduction"; - } - } - if (item.prefix == PrefixID.Warding) - { - string defenseBoost = "+4 defense\n"; - if (CalamityWorld.downedDoG) - defenseBoost = "+16 defense\n"; - else if (CalamityWorld.downedPolterghast) - defenseBoost = "+14 defense\n"; - else if (CalamityWorld.downedProvidence) - defenseBoost = "+12 defense\n"; - else if (NPC.downedMoonlord) - defenseBoost = "+10 defense\n"; - else if (NPC.downedGolemBoss) - defenseBoost = "+8 defense\n"; - else if (Main.hardMode) - defenseBoost = "+6 defense\n"; - - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "PrefixAccDefense") - line2.text = defenseBoost + "+1% damage reduction"; - } - } - } - #endregion - - #region Mod Mechanic Tooltips - if (item.type < ItemID.Count) - return; - - // TODO -- mod references should be kept statically - // Adds tooltips to Calamity fountains which match Fargo's fountain tooltips. - Mod fargos = ModLoader.GetMod("Fargowiltas"); - if (fargos != null) - { - if (item.type == ModContent.ItemType()) - { - TooltipLine line = new TooltipLine(mod, "FargoFountain", "Forces surrounding biome state to Sunken Sea upon activation"); - tooltips.Add(line); - } - if (item.type == ModContent.ItemType()) - { - TooltipLine line = new TooltipLine(mod, "FargoFountain", "Forces surrounding biome state to Sulphurous Sea upon activation"); - tooltips.Add(line); - } - if (item.type == ModContent.ItemType()) - { - TooltipLine line = new TooltipLine(mod, "FargoFountain", "Forces surrounding biome state to Astral upon activation"); - tooltips.Add(line); - } - } - - // Adds a Current Charge tooltip to all items which use charge. - CalamityGlobalItem modItem = item.Calamity(); - if (modItem?.UsesCharge ?? false) - { - // Convert current charge ratio into a percentage. - float displayedPercent = ChargeRatio * 100f; - TooltipLine line = new TooltipLine(mod, "CalamityCharge", $"Current Charge: {displayedPercent:N1}%"); - tooltips.Add(line); - } - - // Adds "Donor Item" and "Developer Item" to donor items and developer items respectively. - if (donorItem) - { - TooltipLine line = new TooltipLine(mod, "CalamityDonor", CalamityUtils.ColorMessage("- Donor Item -", new Color(139, 0, 0))); - tooltips.Add(line); - } - if (devItem) - { - TooltipLine line = new TooltipLine(mod, "CalamityDev", CalamityUtils.ColorMessage("- Developer Item -", new Color(255, 0, 255))); - tooltips.Add(line); - } - - // Adds "Challenge Drop" or "Legendary Challenge Drop" to malice mode drops. - if (challengeDrop) - { - Color lineColor = default; - if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) - lineColor = new Color(255, Main.DiscoG, 53); - if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) - lineColor = new Color(Main.DiscoR, 203, 103); - if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) - lineColor = new Color(53, Main.DiscoG, 255); - if (item.type == ModContent.ItemType()) - lineColor = new Color(150, Main.DiscoG, 255); - if (item.type == ModContent.ItemType()) - lineColor = new Color(60, Main.DiscoG, 190); - if (item.type == ModContent.ItemType()) - lineColor = new Color(255, Main.DiscoG, 155); - if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) - lineColor = new Color(255, Main.DiscoG, 0); - if (item.type == ModContent.ItemType()) - lineColor = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); - if (item.type == ModContent.ItemType()) - lineColor = CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 3f); - if (item.type == ModContent.ItemType()) - lineColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); - - if (lineColor != default) - { - TooltipLine line = new TooltipLine(mod, "LegendaryChallengeDrop", CalamityUtils.ColorMessage("- Legendary Challenge Drop -", lineColor)); - tooltips.Add(line); - return; - } - - TooltipLine line2 = new TooltipLine(mod, "ChallengeDrop", CalamityUtils.ColorMessage("- Challenge Drop -", new Color(255, 140, 0))); - tooltips.Add(line2); - } - #endregion - } - #endregion - #region Armor Set Changes public override string IsArmorSet(Item head, Item body, Item legs) { diff --git a/Items/CalamityGlobalItemLoot.cs b/Items/CalamityGlobalItemLoot.cs index fcf9741e0e..b8051353f5 100644 --- a/Items/CalamityGlobalItemLoot.cs +++ b/Items/CalamityGlobalItemLoot.cs @@ -3,8 +3,6 @@ using CalamityMod.Items.DifficultyItems; using CalamityMod.Items.Materials; using CalamityMod.Items.PermanentBoosters; using CalamityMod.Items.Potions; -using CalamityMod.Items.Weapons.Magic; -using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs new file mode 100644 index 0000000000..093a641800 --- /dev/null +++ b/Items/CalamityGlobalItemTooltip.cs @@ -0,0 +1,1926 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Items.Accessories; +using CalamityMod.Items.Armor; +using CalamityMod.Items.Placeables.Furniture.Fountains; +using CalamityMod.Items.Tools; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items +{ + public partial class CalamityGlobalItem : GlobalItem + { + #region Main ModifyTooltips Function + public override void ModifyTooltips(Item item, List tooltips) + { + // Apply rarity coloration to the item's name. + TooltipLine nameLine = tooltips.FirstOrDefault(x => x.Name == "ItemName" && x.mod == "Terraria"); + if (nameLine != null) + ApplyRarityColors(item, nameLine); + + // Modify all vanilla tooltips before appending mod mechanics (if any). + ModifyVanillaTooltips(item, tooltips); + + // If the item has a stealth generation prefix, show that on the tooltip. + // This is placed between vanilla tooltip edits and mod mechanics because it can apply to vanilla items. + StealthGenAccessoryTooltip(item, tooltips); + + // Everything below this line can only apply to modded items. If the item is vanilla, stop here for efficiency. + if (item.type < ItemID.Count) + return; + + // TODO -- mod references should be kept statically + // Adds tooltips to Calamity fountains which match Fargo's fountain tooltips. + Mod fargos = ModLoader.GetMod("Fargowiltas"); + if (fargos != null) + { + if (item.type == ModContent.ItemType()) + { + TooltipLine line = new TooltipLine(mod, "FargoFountain", "Forces surrounding biome state to Sunken Sea upon activation"); + tooltips.Add(line); + } + if (item.type == ModContent.ItemType()) + { + TooltipLine line = new TooltipLine(mod, "FargoFountain", "Forces surrounding biome state to Sulphurous Sea upon activation"); + tooltips.Add(line); + } + if (item.type == ModContent.ItemType()) + { + TooltipLine line = new TooltipLine(mod, "FargoFountain", "Forces surrounding biome state to Astral upon activation"); + tooltips.Add(line); + } + } + + // Adds a Current Charge tooltip to all items which use charge. + CalamityGlobalItem modItem = item.Calamity(); + if (modItem?.UsesCharge ?? false) + { + // Convert current charge ratio into a percentage. + float displayedPercent = ChargeRatio * 100f; + TooltipLine line = new TooltipLine(mod, "CalamityCharge", $"Current Charge: {displayedPercent:N1}%"); + tooltips.Add(line); + } + + // Adds "Donor Item" and "Developer Item" to donor items and developer items respectively. + if (donorItem) + { + TooltipLine line = new TooltipLine(mod, "CalamityDonor", CalamityUtils.ColorMessage("- Donor Item -", new Color(139, 0, 0))); + tooltips.Add(line); + } + if (devItem) + { + TooltipLine line = new TooltipLine(mod, "CalamityDev", CalamityUtils.ColorMessage("- Developer Item -", new Color(255, 0, 255))); + tooltips.Add(line); + } + + // Adds "Challenge Drop" or "Legendary Challenge Drop" to malice mode drops. + if (challengeDrop) + { + Color lineColor = default; + if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) + lineColor = new Color(255, Main.DiscoG, 53); + if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) + lineColor = new Color(Main.DiscoR, 203, 103); + if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) + lineColor = new Color(53, Main.DiscoG, 255); + if (item.type == ModContent.ItemType()) + lineColor = new Color(150, Main.DiscoG, 255); + if (item.type == ModContent.ItemType()) + lineColor = new Color(60, Main.DiscoG, 190); + if (item.type == ModContent.ItemType()) + lineColor = new Color(255, Main.DiscoG, 155); + if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) + lineColor = new Color(255, Main.DiscoG, 0); + if (item.type == ModContent.ItemType()) + lineColor = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); + if (item.type == ModContent.ItemType()) + lineColor = CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 3f); + if (item.type == ModContent.ItemType()) + lineColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); + + if (lineColor != default) + { + TooltipLine line = new TooltipLine(mod, "LegendaryChallengeDrop", CalamityUtils.ColorMessage("- Legendary Challenge Drop -", lineColor)); + tooltips.Add(line); + return; + } + + TooltipLine line2 = new TooltipLine(mod, "ChallengeDrop", CalamityUtils.ColorMessage("- Challenge Drop -", new Color(255, 140, 0))); + tooltips.Add(line2); + } + } + #endregion + + #region Rarity Coloration + private void ApplyRarityColors(Item item, TooltipLine nameLine) + { + // Apply standard post-ML rarities to the item's color first. + Color? standardRarityColor = CalamityUtils.GetRarityColor(customRarity); + if (standardRarityColor.HasValue) + nameLine.overrideColor = standardRarityColor.Value; + + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = new Color(Main.DiscoR, 100, 255); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = new Color(0, 0, 255); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = Judgement.GetSyncedLightColor(); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = new Color(0.34f, 0.34f + 0.66f * Main.DiscoG / 255f, 0.34f + 0.5f * Main.DiscoG / 255f); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = ShatteredCommunity.GetRarityColor(); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(255, 166, 0), new Color(25, 250, 25), 4f); //alternates between emerald green and amber (BanditHueh) + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(210, 0, 255), new Color(255, 248, 24), 4f); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(131, 239, 255), new Color(36, 55, 230), 4f); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(255, 69, 0), new Color(139, 0, 0), 4f); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(191, 45, 71), new Color(185, 187, 253), 4f); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(204, 86, 80), new Color(237, 69, 141), 4f); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = new Color(146, 0, 0); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = new Color(129, 29, 149); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = new Color(220, 20, 60); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = new Color(254, 253, 235); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = new Color(207, 17, 117); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = new Color(227, 226, 180); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(154, 255, 151), new Color(228, 151, 255), 4f); + if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) + nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(255, 132, 22), new Color(221, 85, 7), 4f); + + // TODO -- for cleanliness, ALL color math should either be a one-line color swap or inside the item's own file + // The items that currently violate this are all below: + // Eternity, Flamsteed Ring, Earth + if (item.type == ModContent.ItemType()) + { + List colorSet = new List() + { + new Color(188, 192, 193), // white + new Color(157, 100, 183), // purple + new Color(249, 166, 77), // honey-ish orange + new Color(255, 105, 234), // pink + new Color(67, 204, 219), // sky blue + new Color(249, 245, 99), // bright yellow + new Color(236, 168, 247), // purplish pink + }; + if (nameLine != null) + { + int colorIndex = (int)(Main.GlobalTime / 2 % colorSet.Count); + Color currentColor = colorSet[colorIndex]; + Color nextColor = colorSet[(colorIndex + 1) % colorSet.Count]; + nameLine.overrideColor = Color.Lerp(currentColor, nextColor, Main.GlobalTime % 2f > 1f ? 1f : Main.GlobalTime % 1f); + } + } + if (item.type == ModContent.ItemType()) + { + if (Main.GlobalTime % 1f < 0.6f) + { + nameLine.overrideColor = new Color(89, 229, 255); + } + else if (Main.GlobalTime % 1f < 0.8f) + { + nameLine.overrideColor = Color.Lerp(new Color(89, 229, 255), Color.White, (Main.GlobalTime % 1f - 0.6f) / 0.2f); + } + else + { + nameLine.overrideColor = Color.Lerp(Color.White, new Color(89, 229, 255), (Main.GlobalTime % 1f - 0.8f) / 0.2f); + } + } + if (item.type == ModContent.ItemType()) + { + List earthColors = new List() + { + new Color(255, 99, 146), + new Color(255, 228, 94), + new Color(127, 200, 248) + }; + if (nameLine != null) + { + int colorIndex = (int)(Main.GlobalTime / 2 % earthColors.Count); + Color currentColor = earthColors[colorIndex]; + Color nextColor = earthColors[(colorIndex + 1) % earthColors.Count]; + nameLine.overrideColor = Color.Lerp(currentColor, nextColor, Main.GlobalTime % 2f > 1f ? 1f : Main.GlobalTime % 1f); + } + } + } + #endregion + + #region Vanilla Item Tooltip Modification + private void ModifyVanillaTooltips(Item item, IList tooltips) + { + #region Modular Tooltip Editing Code + // This is a modular tooltip editor which loops over all tooltip lines of an item, + // selects all those which match an arbitrary function you provide, + // then edits them using another arbitrary function you provide. + void ApplyTooltipEdits(IList lines, Func predicate, Action action) + { + foreach (TooltipLine line in lines) + if (predicate.Invoke(item, line)) + action.Invoke(line); + } + + // This function produces simple predicates to match a specific line of a tooltip, by number/index. + Func LineNum(int n) => (Item i, TooltipLine l) => l.mod == "Terraria" && l.Name == $"Tooltip{n}"; + // This function produces simple predicates to match a specific line of a tooltip, by name. + Func LineName(string s) => (Item i, TooltipLine l) => l.mod == "Terraria" && l.Name == s; + + // These functions are shorthand to invoke ApplyTooltipEdits using the above predicates. + void EditTooltipByNum(int lineNum, Action action) => ApplyTooltipEdits(tooltips, LineNum(lineNum), action); + void EditTooltipByName(string lineName, Action action) => ApplyTooltipEdits(tooltips, LineName(lineName), action); + #endregion + + // 1) Mirrors and Recall Potions cannot be used while a boss is alive. + if (item.type == ItemID.MagicMirror || item.type == ItemID.IceMirror || item.type == ItemID.CellPhone || item.type == ItemID.RecallPotion) + ApplyTooltipEdits(tooltips, + (i, l) => l.mod == "Terraria" && l.Name == (i.type == ItemID.CellPhone ? "Tooltip1" : "Tooltip0"), + (line) => line.text += "\nCannot be used while a boss is alive"); + + // 2) If Early Hardmode Rework is enabled: Remind users that ores will NOT spawn when an altar is smashed. + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && (item.type == ItemID.Pwnhammer || item.type == ItemID.Hammush)) + EditTooltipByNum(0, (line) => line.text += "\nDemon Altars no longer spawn ores when destroyed"); + + // 3) Black Belt and Master Ninja Gear have guaranteed dodges on a 60 second cooldown. + string beltDodgeLine = "Grants the ability to dodge attacks\n" + + $"The dodge has a {CalamityPlayer.BeltDodgeCooldown} second cooldown which is shared with all other dodges and reflects"; + if (item.type == ItemID.BlackBelt) + EditTooltipByNum(0, (line) => line.text = beltDodgeLine); + if (item.type == ItemID.MasterNinjaGear) + EditTooltipByNum(1, (line) => line.text = beltDodgeLine); + + // 4) Early Hardmode ore melee weapons have new on-hit effects. + #region Early Hardmode Melee Tooltips + + // Cobalt + if (item.type == ItemID.CobaltSword || item.type == ItemID.CobaltNaginata) + EditTooltipByName("Knockback", (line) => line.text += "\nDecreases enemy defense by 10% on hit"); + + // Palladium + if (item.type == ItemID.PalladiumSword || item.type == ItemID.PalladiumPike) + EditTooltipByName("Knockback", (line) => line.text += "\nIncreases life regen on hit"); + + // Mythril + if (item.type == ItemID.MythrilSword || item.type == ItemID.MythrilHalberd) + EditTooltipByName("Knockback", (line) => line.text += "\nDecreases enemy contact damage by 10% on hit"); + + // Orichalcum + if (item.type == ItemID.OrichalcumSword || item.type == ItemID.OrichalcumHalberd) + EditTooltipByName("Knockback", (line) => line.text += "\nIncreases how frequently the Orichalcum set bonus triggers on hit"); + + // Adamantite + if (item.type == ItemID.AdamantiteSword || item.type == ItemID.AdamantiteGlaive) + EditTooltipByName("Knockback", (line) => line.text += "\nSlows enemies on hit"); + + // Titanium + if (item.type == ItemID.TitaniumSword || item.type == ItemID.TitaniumTrident) + EditTooltipByName("Knockback", (line) => line.text += "\nDeals increased damage to enemies with high knockback resistance"); + + // Hallowed (and True Excalibur) + if (item.type == ItemID.Excalibur || item.type == ItemID.Gungnir || item.type == ItemID.TrueExcalibur) + EditTooltipByName("Knockback", (line) => line.text += "\nInflicts Holy Flames\nDeals double damage to enemies above 75% life"); + #endregion + + // 5) Other melee weapon tooltips + #region Other Melee Tooltips + + if (item.type == ItemID.CandyCaneSword || item.type == ItemID.FruitcakeChakram) + EditTooltipByName("Knockback", (line) => line.text += "\nHeals you on hit"); + + // Stylish Scissors, all Phaseblades, and all Phasesabers + if (item.type == ItemID.StylistKilLaKillScissorsIWish || (item.type >= ItemID.BluePhaseblade && item.type <= ItemID.YellowPhaseblade) || (item.type >= ItemID.BluePhasesaber && item.type <= ItemID.YellowPhasesaber)) + EditTooltipByName("Knockback", (line) => line.text += "\nIgnores 100% of enemy defense"); + + if (item.type == ItemID.AntlionClaw || item.type == ItemID.BoneSword || item.type == ItemID.BreakerBlade) + EditTooltipByName("Knockback", (line) => line.text += "\nIgnores 50% of enemy defense"); + + if (item.type == ItemID.LightsBane || item.type == ItemID.NightsEdge || item.type == ItemID.TrueNightsEdge) + EditTooltipByName("Knockback", (line) => line.text += "\nInflicts Shadowflame on hit"); + + if (item.type == ItemID.BloodButcherer || item.type == ItemID.TheRottedFork) + EditTooltipByName("Knockback", (line) => line.text += "\nInflicts Burning Blood on hit"); + #endregion + + // 6) Bottled Honey gives the Honey buff + if (item.type == ItemID.BottledHoney) + EditTooltipByName("HealLife", (line) => line.text += "\nGrants the Honey buff for 2 minutes"); + + // 7) Rod of Discord cannot be used multiple times to hurt yourself + if (item.type == ItemID.RodofDiscord) + EditTooltipByNum(0, (line) => line.text += "\nTeleportation is disabled while Chaos State is active"); + + // 8) Water removing items cannot be used in the Abyss + string noAbyssLine = "\nCannot be used in the Abyss"; + if (item.type == ItemID.SuperAbsorbantSponge) + EditTooltipByNum(0, (line) => line.text += noAbyssLine); + if (item.type == ItemID.EmptyBucket) + EditTooltipByName("Defense", (line) => line.text += noAbyssLine); + + // 9) Light pets, accessories, and other items which boost the player's Abyss light stat + #region Abyss Light Tooltips + + // +1 to Abyss light level + string abyssSmallLightLine = "\nProvides a small amount of light in the abyss"; + + if (item.type == ItemID.CrimsonHeart || item.type == ItemID.ShadowOrb || item.type == ItemID.MagicLantern || item.type == ItemID.JellyfishNecklace) + EditTooltipByNum(0, (line) => line.text += abyssSmallLightLine); + if (item.type == ItemID.JellyfishDivingGear) + EditTooltipByNum(1, (line) => line.text += abyssSmallLightLine); + + // +2 to Abyss light level + string abyssMediumLightLine = "\nProvides a moderate amount of light in the abyss"; + + if (item.type == ItemID.FairyBell || item.type == ItemID.DD2PetGhost) + EditTooltipByNum(0, (line) => line.text += abyssMediumLightLine); + + if (item.type == ItemID.ShinePotion) + EditTooltipByName("BuffTime", (line) => line.text += abyssMediumLightLine); + + // +3 to Abyss light level + string abyssLargeLightLine = "\nProvides a large amount of light in the abyss"; + + if (item.type == ItemID.WispinaBottle) + EditTooltipByNum(0, (line) => line.text += abyssLargeLightLine); + if (item.type == ItemID.SuspiciousLookingTentacle) + EditTooltipByNum(1, (line) => line.text += abyssLargeLightLine); + + if (item.type == ItemID.ArcticDivingGear) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + { + line2.text += "\nProvides a small amount of light in the abyss\n" + + "Moderately reduces breath loss in the abyss"; + } + } + } + #endregion + + if (item.type == ItemID.GillsPotion) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "BuffTime") + { + line2.text += "\nGreatly reduces breath loss in the abyss"; + } + } + } + if (item.type == ItemID.DivingHelmet) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text += "\nModerately reduces breath loss in the abyss"; + } + } + } + if (item.type == ItemID.NeptunesShell || item.type == ItemID.MoonShell) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text += "\nGreatly reduces breath loss in the abyss"; + } + } + } + if (item.type == ItemID.CelestialShell) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + { + line2.text += "\nGreatly reduces breath loss in the abyss"; + } + } + } + if (item.type == ItemID.WarmthPotion) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text += "\nMakes you immune to the Chilled, Frozen, and Glacial State debuffs\n" + + "Provides cold protection in Death Mode"; + } + } + } + else + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text += "\nMakes you immune to the Chilled, Frozen, and Glacial State debuffs"; + } + } + } + } + if (item.type == ItemID.FlaskofVenom) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Melee and rogue attacks inflict Venom on enemies"; + } + } + } + if (item.type == ItemID.FlaskofCursedFlames) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Melee and rogue attacks inflict enemies with cursed flames"; + } + } + } + if (item.type == ItemID.FlaskofFire) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Melee and rogue attacks set enemies on fire"; + } + } + } + if (item.type == ItemID.FlaskofGold) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Melee and rogue attacks make enemies drop more gold"; + } + } + } + if (item.type == ItemID.FlaskofIchor) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Melee and rogue attacks decrease enemy defense"; + } + } + } + if (item.type == ItemID.FlaskofNanites) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Melee and rogue attacks confuse enemies"; + } + } + } + if (item.type == ItemID.FlaskofParty) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "All attacks cause confetti to appear"; + } + } + } + if (item.type == ItemID.FlaskofPoison) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Melee and rogue attacks poison enemies"; + } + } + } + if (item.type == ItemID.WormScarf) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Reduces damage taken by 10%"; + } + } + } + if (item.type == ItemID.TitanGlove) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text += "\n10% increased true melee damage"; + } + } + } + if (item.type == ItemID.PowerGlove) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + { + line2.text += "\n10% increased true melee damage"; + } + } + } + if (item.type == ItemID.MechanicalGlove) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + { + line2.text += "\n10% increased true melee damage"; + } + } + } + if (item.type == ItemID.FireGauntlet) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + { + line2.text = "14% increased melee damage and speed\n" + + "10% increased true melee damage\n" + + "Provides heat and cold protection in Death Mode"; + } + } + } + else + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + { + line2.text = "14% increased melee damage and speed\n" + + "10% increased true melee damage"; + } + } + } + } + if (item.type == ItemID.SpectreHood) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "20% decreased magic damage"; + } + } + } + if (item.type == ItemID.ObsidianSkinPotion) + { + string heatImmunity = CalamityWorld.death ? "\nProvides heat protection in Death Mode" : ""; + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Provides immunity to direct damage from touching lava\n" + + "Provides temporary immunity to lava burn damage\n" + + "Greatly increases lava immunity time regeneration\n" + + "Reduces lava burn damage" + heatImmunity; + } + } + } + if (item.type == ItemID.ObsidianRose) + { + string heatImmunity = CalamityWorld.death ? "\nProvides heat protection in Death Mode" : ""; + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Reduced direct damage from touching lava\n" + + "Greatly reduces lava burn damage" + heatImmunity; + } + } + } + if (item.type == ItemID.MagmaStone && CalamityWorld.death) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text += "\nProvides heat and cold protection in Death Mode"; + } + } + } + if (item.type == ItemID.LavaCharm && CalamityWorld.death) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text += "\nProvides heat protection in Death Mode"; + } + } + } + if (item.type == ItemID.LavaWaders && CalamityWorld.death) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + { + line2.text += "\nProvides heat protection in Death Mode"; + } + } + } + if (item.type == ItemID.InvisibilityPotion) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text += "\nBoosts certain stats when holding certain types of rogue weapons"; + } + } + } + if (item.type == ItemID.GoldenFishingRod) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "NeedsBait") + { + line2.text = "Requires bait to catch fish\n" + + "The line will never break"; + } + } + } + if (item.type == ItemID.Picksaw) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + // I'm leaving this intentionally ambiguous so that people have to search for Scoria Ore + line2.text = "Capable of mining Lihzahrd Bricks and Scoria Ore"; + } + } + } + if (item.type == ItemID.SolarFlarePickaxe) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Material") + { + line2.text = "Material\n" + + "Can mine Uelibloom Ore"; + } + } + } + if (item.type == ItemID.VortexPickaxe) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Material") + { + line2.text = "Material\n" + + "Can mine Uelibloom Ore"; + } + } + } + if (item.type == ItemID.NebulaPickaxe) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Material") + { + line2.text = "Material\n" + + "Can mine Uelibloom Ore"; + } + } + } + if (item.type == ItemID.StardustPickaxe) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Material") + { + line2.text = "Material\n" + + "Can mine Uelibloom Ore"; + } + } + } + + if (Main.player[Main.myPlayer].Calamity().trueMeleeDamage > 0D) + { + if (item.melee && item.damage > 0) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Damage") + { + line2.text += " : " + string.Concat((int)(Main.player[Main.myPlayer].Calamity().actualMeleeDamageStat * item.damage * + (1D + Main.player[Main.myPlayer].Calamity().trueMeleeDamage) + 5E-06f)) + " true melee damage"; + } + } + } + } + + if (item.type == ItemID.MeteorHelmet || item.type == ItemID.MeteorSuit || item.type == ItemID.MeteorLeggings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "SetBonus") + { + line2.text = "Set Bonus: Reduces the mana cost of the Space Gun by 50%"; + } + } + } + if (item.type == ItemID.CopperHelmet || item.type == ItemID.CopperChainmail || item.type == ItemID.CopperGreaves) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "SetBonus") + { + line2.text = "Set Bonus: +2 defense and 15% increased mining speed"; + } + } + } + if (item.type == ItemID.TinHelmet || item.type == ItemID.TinChainmail || item.type == ItemID.TinGreaves) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "SetBonus") + { + line2.text = "Set Bonus: +2 defense and 10% increased mining speed"; + } + } + } + if (item.type == ItemID.AncientIronHelmet || item.type == ItemID.IronHelmet || item.type == ItemID.IronChainmail || item.type == ItemID.IronGreaves) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "SetBonus") + { + line2.text = "Set Bonus: +2 defense and 25% increased mining speed"; + } + } + } + if (item.type == ItemID.LeadHelmet || item.type == ItemID.LeadChainmail || item.type == ItemID.LeadGreaves) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "SetBonus") + { + line2.text = "Set Bonus: +3 defense and 20% increased mining speed"; + } + } + } + if (item.type == ItemID.SilverHelmet || item.type == ItemID.SilverChainmail || item.type == ItemID.SilverGreaves) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "SetBonus") + { + line2.text = "Set Bonus: +3 defense and 35% increased mining speed"; + } + } + } + if (item.type == ItemID.TungstenHelmet || item.type == ItemID.TungstenChainmail || item.type == ItemID.TungstenGreaves) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "SetBonus") + { + line2.text = "Set Bonus: +3 defense and 30% increased mining speed"; + } + } + } + if (item.type == ItemID.AncientGoldHelmet || item.type == ItemID.GoldHelmet || item.type == ItemID.GoldChainmail || item.type == ItemID.GoldGreaves) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "SetBonus") + { + line2.text = "Set Bonus: +3 defense and 45% increased mining speed"; + } + } + } + if (item.type == ItemID.PlatinumHelmet || item.type == ItemID.PlatinumChainmail || item.type == ItemID.PlatinumGreaves) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "SetBonus") + { + line2.text = "Set Bonus: +4 defense and 40% increased mining speed"; + } + } + } + if (item.type == ItemID.AncientBattleArmorHat || item.type == ItemID.AncientBattleArmorShirt || item.type == ItemID.AncientBattleArmorPants) + { + if (!Main.player[Main.myPlayer].Calamity().forbiddenCirclet) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "SetBonus") + { + line2.text += "\nThe minion damage nerf is reduced while wielding magic weapons"; + } + } + } + } + if (item.type == ItemID.StardustBreastplate || item.type == ItemID.StardustLeggings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Increases your max number of minions"; + } + } + } + if (item.type == ItemID.StardustHelmet || item.type == ItemID.StardustBreastplate || item.type == ItemID.StardustLeggings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "SetBonus") + { + line2.text += "\nIncreases your max number of minions by 2"; + } + } + } + if (item.type == ItemID.GladiatorHelmet) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Defense") + { + line2.text = "3 defense\n" + + "3% increased rogue damage"; + } + } + } + if (item.type == ItemID.GladiatorBreastplate) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Defense") + { + line2.text = "5 defense\n" + + "3% increased rogue critical strike chance"; + } + } + } + if (item.type == ItemID.GladiatorLeggings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Defense") + { + line2.text = "4 defense\n" + + "3% increased rogue velocity"; + } + } + } + if (item.type == ItemID.ObsidianHelm) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Defense") + { + line2.text = "4 defense\n" + + "3% increased rogue damage"; + } + } + } + if (item.type == ItemID.ObsidianShirt) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Defense") + { + line2.text = "5 defense\n" + + "3% increased rogue critical strike chance"; + } + } + } + if (item.type == ItemID.ObsidianPants) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Defense") + { + line2.text = "4 defense\n" + + "3% increased rogue velocity"; + } + } + } + if (item.type == ItemID.MoltenHelmet || item.type == ItemID.MoltenBreastplate || item.type == ItemID.MoltenGreaves) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "SetBonus") + { + line2.text = @"Set Bonus: 17% extra melee damage +20% extra true melee damage +Grants immunity to fire blocks, and temporary immunity to lava +Provides heat and cold protection in Death Mode"; + } + } + } + else + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "SetBonus") + { + line2.text = @"Set Bonus: 17% extra melee damage +20% extra true melee damage +Grants immunity to fire blocks, and temporary immunity to lava"; + } + } + } + } + if (item.type == ItemID.FrostHelmet || item.type == ItemID.FrostBreastplate || item.type == ItemID.FrostLeggings) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "SetBonus") + { + line2.text += "\nProvides heat and cold protection in Death Mode"; + } + } + } + } + if (item.type == ItemID.DD2ElderCrystal) + tooltips.FirstOrDefault(line => line.mod == "Terraria" && line.Name == "Tooltip0").text += "\nOnce placed you can right click the crystal to skip waves or increase the spawn rate of the invaders"; + + if (item.type == ItemID.MagicQuiver) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Increases arrow damage by 10% and greatly increases arrow speed"; + } + } + } + if (item.type == ItemID.MiningHelmet) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Provides light when worn\n" + + "Provides a small amount of light in the Abyss"; + } + } + } + if (item.type == ItemID.HandWarmer) + { + string coldImmunity = CalamityWorld.death ? "\nProvides cold protection in Death Mode" : ""; + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Provides immunity to chilling and freezing effects\n" + + "Provides a regeneration boost while wearing the Eskimo armor" + coldImmunity; + } + } + } + if (item.type == ItemID.AngelWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 6.25\n" + + "Acceleration multiplier: 1\n" + + "Average vertical speed\n" + + "Flight time: 100\n" + + "+20 max life, +10 defense and +2 life regen"; + } + } + } + if (item.type == ItemID.DemonWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 6.25\n" + + "Acceleration multiplier: 1\n" + + "Average vertical speed\n" + + "Flight time: 100\n" + + "5% increased damage and critical strike chance"; + } + } + } + if (item.type == ItemID.Jetpack) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 6.5\n" + + "Acceleration multiplier: 1\n" + + "Average vertical speed\n" + + "Flight time: 115"; + } + } + } + if (item.type == ItemID.ButterflyWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 6.75\n" + + "Acceleration multiplier: 1\n" + + "Average vertical speed\n" + + "Flight time: 130\n" + + "+20 max mana, 5% decreased mana usage,\n" + + "5% increased magic damage and magic critical strike chance"; + } + } + } + if (item.type == ItemID.FairyWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 6.75\n" + + "Acceleration multiplier: 1\n" + + "Average vertical speed\n" + + "Flight time: 130\n" + + "+60 max life"; + } + } + } + if (item.type == ItemID.BeeWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 6.75\n" + + "Acceleration multiplier: 1\n" + + "Average vertical speed\n" + + "Flight time: 130\n" + + "Honey buff at all times"; + } + } + } + if (item.type == ItemID.HarpyWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 7\n" + + "Acceleration multiplier: 1\n" + + "Average vertical speed\n" + + "Flight time: 140\n" + + "20% increased movement speed\n" + + "Most attacks have a chance to fire a feather on swing if Harpy Ring or Angel Treads are equipped"; + } + } + } + if (item.type == ItemID.BoneWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 7\n" + + "Acceleration multiplier: 1\n" + + "Average vertical speed\n" + + "Flight time: 140\n" + + "10% increased movement speed, ranged damage and critical strike chance\n" + + "and +30 defense while wearing the Necro Armor"; + } + } + } + if (item.type == ItemID.FlameWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 7.5\n" + + "Acceleration multiplier: 1\n" + + "Average vertical speed\n" + + "Flight time: 160\n" + + "5% increased melee damage and critical strike chance"; + } + } + } + if (item.type == ItemID.FrozenWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 7.5\n" + + "Acceleration multiplier: 1\n" + + "Average vertical speed\n" + + "Flight time: 160\n" + + "2% increased melee and ranged damage\n" + + "and 1% increased melee and ranged critical strike chance\n" + + "while wearing the Frost Armor"; + } + } + } + if (item.type == ItemID.GhostWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 7.5\n" + + "Acceleration multiplier: 1\n" + + "Average vertical speed\n" + + "Flight time: 160\n" + + "+10 defense and 5% increased damage reduction while wearing the Spectre Armor and Hood\n" + + "5% increased magic damage and critical strike chance while wearing the Spectre Armor and Mask"; + } + } + } + if (item.type == ItemID.BeetleWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 7.5\n" + + "Acceleration multiplier: 1\n" + + "Average vertical speed\n" + + "Flight time: 160\n" + + "+10 defense and 5% increased damage reduction while wearing the Beetle Armor and Shell\n" + + "5% increased melee damage and critical strike chance while wearing the Beetle Armor and Scale Mail"; + } + } + } + if (item.type == ItemID.FinWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 0\n" + + "Acceleration multiplier: 0\n" + + "Average vertical speed\n" + + "Flight time: 100\n" + + "Gills effect and you can move freely through liquids\n" + + "You fall faster while submerged in liquid\n" + + "15% increased movement speed and 18% increased jump speed"; + } + } + } + if (item.type == ItemID.FishronWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 8\n" + + "Acceleration multiplier: 2\n" + + "Good vertical speed\n" + + "Flight time: 180"; + } + } + } + if (item.type == ItemID.SteampunkWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 7.75\n" + + "Acceleration multiplier: 1\n" + + "Average vertical speed\n" + + "Flight time: 180\n" + + "+8 defense, 10% increased movement speed,\n" + + "4% increased damage, and 2% increased critical strike chance"; + } + } + } + if (item.type == ItemID.LeafWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 6.75\n" + + "Acceleration multiplier: 1\n" + + "Average vertical speed\n" + + "Flight time: 160\n" + + "+5 defense, 5% increased damage reduction,\n" + + "and the Dryad's permanent blessing while wearing the Tiki Armor"; + } + } + } + if (item.type == ItemID.BatWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 0\n" + + "Acceleration multiplier: 0\n" + + "Average vertical speed\n" + + "Flight time: 140\n" + + "At night or during an eclipse, you will gain the following boosts:\n" + + "10% increased movement speed, 10% increased jump speed,\n" + + "7% increased damage and 3% increased critical strike chance"; + } + } + } + if (item.type == ItemID.Yoraiz0rWings || item.type == ItemID.JimsWings || item.type == ItemID.SkiphsWings || + item.type == ItemID.LokisWings || item.type == ItemID.ArkhalisWings || item.type == ItemID.LeinforsWings || + item.type == ItemID.BejeweledValkyrieWing || item.type == ItemID.RedsWings || item.type == ItemID.DTownsWings || + item.type == ItemID.WillsWings || item.type == ItemID.CrownosWings || item.type == ItemID.CenxsWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "'Great for impersonating devs!'\n" + + "Horizontal speed: 7\n" + + "Acceleration multiplier: 1\n" + + "Average vertical speed\n" + + "Flight time: 150"; + } + } + } + if (item.type == ItemID.TatteredFairyWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 7.5\n" + + "Acceleration multiplier: 1\n" + + "Average vertical speed\n" + + "Flight time: 180\n" + + "5% increased damage and critical strike chance"; + } + } + } + if (item.type == ItemID.SpookyWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 7.5\n" + + "Acceleration multiplier: 1\n" + + "Average vertical speed\n" + + "Flight time: 180\n" + + "Increased minion knockback and 5% increased minion damage while wearing the Spooky Armor"; + } + } + } + if (item.type == ItemID.Hoverboard) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + { + line2.text = "Hold DOWN and JUMP to hover\n" + + "Horizontal speed: 6.25\n" + + "Acceleration multiplier: 1\n" + + "Average vertical speed\n" + + "Flight time: 170\n" + + "10% increased damage to bows, guns, rocket launchers, and flamethrowers while wearing the Shroomite Armor\n" + + "Boosted weapon type depends on the Shroomite Helmet worn"; + } + } + } + if (item.type == ItemID.FestiveWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 7.5\n" + + "Acceleration multiplier: 1\n" + + "Average vertical speed\n" + + "Flight time: 170\n" + + "+40 max life\n" + + "Ornaments rain down as you fly"; + } + } + } + if (item.type == ItemID.MothronWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 0\n" + + "Acceleration multiplier: 0\n" + + "Average vertical speed\n" + + "Flight time: 160\n" + + "+5 defense, 5% increased damage,\n" + + "10% increased movement speed and 12% increased jump speed"; + } + } + } + if (item.type == ItemID.WingsSolar) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 9\n" + + "Acceleration multiplier: 2.5\n" + + "Great vertical speed\n" + + "Flight time: 180\n" + + "7% increased melee damage and 3% increased melee critical strike chance\n" + + "while wearing the Solar Flare Armor"; + } + } + } + if (item.type == ItemID.WingsStardust) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Horizontal speed: 9\n" + + "Acceleration multiplier: 2.5\n" + + "Great vertical speed\n" + + "Flight time: 180\n" + + "+1 max minion and 5% increased minion damage while wearing the Stardust Armor"; + } + } + } + if (item.type == ItemID.WingsVortex) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Hold DOWN and JUMP to hover\n" + + "Horizontal speed: 6.5\n" + + "Acceleration multiplier: 1.5\n" + + "Good vertical speed\n" + + "Flight time: 160\n" + + "3% increased ranged damage and 7% increased ranged critical strike chance\n" + + "while wearing the Vortex Armor"; + } + } + } + if (item.type == ItemID.WingsNebula) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Allows flight and slow fall\n" + + "Hold DOWN and JUMP to hover\n" + + "Horizontal speed: 6.5\n" + + "Acceleration multiplier: 1.5\n" + + "Good vertical speed\n" + + "Flight time: 160\n" + + "+20 max mana, 5% increased magic damage and critical strike chance,\n" + + "and 5% decreased mana usage while wearing the Nebula Armor"; + } + } + } + if (item.type == ItemID.BetsyWings) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Allows flight and slow fall\n" + + "Hold DOWN and JUMP to hover\n" + + "Horizontal speed: 6\n" + + "Acceleration multiplier: 2.5\n" + + "Good vertical speed\n" + + "Flight time: 150"; + } + } + } + if (item.type == ItemID.GrapplingHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 18.75\n" + + "Launch Velocity: 11.5\n" + + "Pull Velocity: 11"; + } + } + } + if (item.type == ItemID.AmethystHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 18.75\n" + + "Launch Velocity: 10\n" + + "Pull Velocity: 11"; + } + } + } + if (item.type == ItemID.TopazHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 20.625\n" + + "Launch Velocity: 10.5\n" + + "Pull Velocity: 11.75"; + } + } + } + if (item.type == ItemID.SapphireHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 22.5\n" + + "Launch Velocity: 11\n" + + "Pull Velocity: 12.5"; + } + } + } + if (item.type == ItemID.EmeraldHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 24.375\n" + + "Launch Velocity: 11.5\n" + + "Pull Velocity: 13.25"; + } + } + } + if (item.type == ItemID.RubyHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 26.25\n" + + "Launch Velocity: 12\n" + + "Pull Velocity: 14"; + } + } + } + if (item.type == ItemID.DiamondHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 28.125\n" + + "Launch Velocity: 12.5\n" + + "Pull Velocity: 14.75"; + } + } + } + if (item.type == ItemID.WebSlinger) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 15.625\n" + + "Launch Velocity: 10\n" + + "Pull Velocity: 11"; + } + } + } + if (item.type == ItemID.SkeletronHand) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 21.875\n" + + "Launch Velocity: 15\n" + + "Pull Velocity: 11"; + } + } + } + if (item.type == ItemID.SlimeHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 18.75\n" + + "Launch Velocity: 13\n" + + "Pull Velocity: 11"; + } + } + } + if (item.type == ItemID.FishHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 25\n" + + "Launch Velocity: 13\n" + + "Pull Velocity: 11"; + } + } + } + if (item.type == ItemID.IvyWhip) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 25\n" + + "Launch Velocity: 13\n" + + "Pull Velocity: 15"; + } + } + } + if (item.type == ItemID.BatHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 31.25\n" + + "Launch Velocity: 15.5\n" + + "Pull Velocity: 20"; + } + } + } + if (item.type == ItemID.CandyCaneHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 25\n" + + "Launch Velocity: 11.5\n" + + "Pull Velocity: 11"; + } + } + } + if (item.type == ItemID.DualHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 27.5\n" + + "Launch Velocity: 14\n" + + "Pull Velocity: 17"; + } + } + } + if (item.type == ItemID.ThornHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 30\n" + + "Launch Velocity: 15\n" + + "Pull Velocity: 18"; + } + } + } + if (item.type == ItemID.WormHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 30\n" + + "Launch Velocity: 15\n" + + "Pull Velocity: 18"; + } + } + } + if (item.type == ItemID.TendonHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 30\n" + + "Launch Velocity: 15\n" + + "Pull Velocity: 18"; + } + } + } + if (item.type == ItemID.IlluminantHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 30\n" + + "Launch Velocity: 15\n" + + "Pull Velocity: 18"; + } + } + } + if (item.type == ItemID.AntiGravityHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 31.25\n" + + "Launch Velocity: 14\n" + + "Pull Velocity: 20"; + } + } + } + if (item.type == ItemID.SpookyHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 34.375\n" + + "Launch Velocity: 15.5\n" + + "Pull Velocity: 22"; + } + } + } + if (item.type == ItemID.ChristmasHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 34.375\n" + + "Launch Velocity: 15.5\n" + + "Pull Velocity: 17"; + } + } + } + if (item.type == ItemID.LunarHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 34.375\n" + + "Launch Velocity: 16\n" + + "Pull Velocity: 24"; + } + } + } + if (item.type == ItemID.StaticHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 37.5\n" + + "Launch Velocity: 16\n" + + "Pull Velocity: 24"; + } + } + } + if (item.type == ItemID.StaticHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 37.5\n" + + "Launch Velocity: 16\n" + + "Pull Velocity: 24"; + } + } + } + if (item.accessory) + { + if (item.prefix == PrefixID.Brisk) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "PrefixAccMoveSpeed") + line2.text = "+2% movement speed"; + } + } + if (item.prefix == PrefixID.Fleeting) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "PrefixAccMoveSpeed") + line2.text = "+4% movement speed"; + } + } + if (item.prefix == PrefixID.Hasty2) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "PrefixAccMoveSpeed") + line2.text = "+6% movement speed"; + } + } + if (item.prefix == PrefixID.Quick2) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "PrefixAccMoveSpeed") + line2.text = "+8% movement speed"; + } + } + if (item.prefix == PrefixID.Precise || item.prefix == PrefixID.Lucky) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "PrefixAccCritChance") + line2.text += "\n+1 armor penetration"; + } + } + if (item.prefix == PrefixID.Hard) + { + string defenseBoost = "+1 defense\n"; + if (CalamityWorld.downedDoG) + defenseBoost = "+4 defense\n"; + else if (CalamityWorld.downedProvidence || CalamityWorld.downedPolterghast) + defenseBoost = "+3 defense\n"; + else if (NPC.downedGolemBoss || NPC.downedMoonlord) + defenseBoost = "+2 defense\n"; + + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "PrefixAccDefense") + line2.text = defenseBoost + "+0.25% damage reduction"; + } + } + if (item.prefix == PrefixID.Guarding) + { + string defenseBoost = "+2 defense\n"; + if (CalamityWorld.downedDoG) + defenseBoost = "+8 defense\n"; + else if (CalamityWorld.downedPolterghast) + defenseBoost = "+7 defense\n"; + else if (CalamityWorld.downedProvidence) + defenseBoost = "+6 defense\n"; + else if (NPC.downedMoonlord) + defenseBoost = "+5 defense\n"; + else if (NPC.downedGolemBoss) + defenseBoost = "+4 defense\n"; + else if (Main.hardMode) + defenseBoost = "+3 defense\n"; + + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "PrefixAccDefense") + line2.text = defenseBoost + "+0.5% damage reduction"; + } + } + if (item.prefix == PrefixID.Armored) + { + string defenseBoost = "+3 defense\n"; + if (CalamityWorld.downedDoG) + defenseBoost = "+12 defense\n"; + else if (CalamityWorld.downedPolterghast) + defenseBoost = "+10 defense\n"; + else if (CalamityWorld.downedProvidence) + defenseBoost = "+9 defense\n"; + else if (NPC.downedMoonlord) + defenseBoost = "+7 defense\n"; + else if (NPC.downedGolemBoss) + defenseBoost = "+6 defense\n"; + else if (Main.hardMode) + defenseBoost = "+4 defense\n"; + + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "PrefixAccDefense") + line2.text = defenseBoost + "+0.75% damage reduction"; + } + } + if (item.prefix == PrefixID.Warding) + { + string defenseBoost = "+4 defense\n"; + if (CalamityWorld.downedDoG) + defenseBoost = "+16 defense\n"; + else if (CalamityWorld.downedPolterghast) + defenseBoost = "+14 defense\n"; + else if (CalamityWorld.downedProvidence) + defenseBoost = "+12 defense\n"; + else if (NPC.downedMoonlord) + defenseBoost = "+10 defense\n"; + else if (NPC.downedGolemBoss) + defenseBoost = "+8 defense\n"; + else if (Main.hardMode) + defenseBoost = "+6 defense\n"; + + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "PrefixAccDefense") + line2.text = defenseBoost + "+1% damage reduction"; + } + } + } + } + #endregion + + #region Stealth Generation Prefix Accessory Tooltip + private void StealthGenAccessoryTooltip(Item item, IList tooltips) + { + if (!item.accessory || item.social || item.prefix <= 0) + return; + + float stealthGenBoost = item.Calamity().StealthGenBonus - 1f; + if (stealthGenBoost > 0) + { + TooltipLine StealthGen = new TooltipLine(mod, "PrefixStealthGenBoost", "+" + Math.Round(stealthGenBoost * 100f) + "% stealth generation") + { + isModifier = true + }; + tooltips.Add(StealthGen); + } + } + #endregion + } +} diff --git a/Utilities/ItemUtils.cs b/Utilities/ItemUtils.cs index a96224be03..40a3f708f6 100644 --- a/Utilities/ItemUtils.cs +++ b/Utilities/ItemUtils.cs @@ -10,6 +10,22 @@ namespace CalamityMod { public static partial class CalamityUtils { + #region Item Rarity Utilities + internal const int TurquoiseRarityValue = 12; + internal static readonly Color TurquoiseRarityColor = new Color(0, 255, 200); + internal const int PureGreenRarityValue = 13; + internal static readonly Color PureGreenRarityColor = new Color(0, 255, 0); + internal const int DarkBlueRarityValue = 14; + internal static readonly Color DarkBlueRarityColor = new Color(43, 96, 222); + internal const int VioletRarityValue = 15; + internal static readonly Color VioletRarityColor = new Color(108, 45, 199); + internal const int HotPinkRarityValue = 16; + internal static readonly Color HotPinkRarityColor = new Color(255, 0, 255); + internal const int RainbowRarityValue = 30; + // The rainbow rarity has an ever-shifting color, not a stored constant + internal const int DraedonRustRarityValue = 33; + internal static readonly Color DraedonRustRarityColor = new Color(204, 71, 35); + public static readonly CalamityRarity[] postMLRarities = { CalamityRarity.Turquoise, @@ -18,6 +34,7 @@ namespace CalamityMod CalamityRarity.Violet, CalamityRarity.HotPink }; + public static bool IsPostML(this CalamityRarity calrare) { for(int i = 0; i < postMLRarities.Length; ++i) @@ -26,6 +43,31 @@ namespace CalamityMod return false; } + public static Color? GetRarityColor(CalamityRarity calrare) + { + switch (calrare) + { + default: + return null; + case CalamityRarity.Turquoise: + return TurquoiseRarityColor; + case CalamityRarity.PureGreen: + return PureGreenRarityColor; + case CalamityRarity.DarkBlue: + return DarkBlueRarityColor; + case CalamityRarity.Violet: + return VioletRarityColor; + case CalamityRarity.HotPink: + return HotPinkRarityColor; + + case CalamityRarity.Rainbow: + return new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); + case CalamityRarity.DraedonRust: + return DraedonRustRarityColor; + } + } + #endregion + /// /// Converts the given ModHotKey into a string for insertion into item tooltips.

/// This allows the user's actual keybind choices to be shown to them in tooltips. From 6691cd1ea31951d6fddd4ec85ba546b088be2f1a Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sun, 11 Apr 2021 18:30:39 -0400 Subject: [PATCH 23/32] Removed old broken code from Endogenesis beams --- Projectiles/Summon/EndoBeam.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Projectiles/Summon/EndoBeam.cs b/Projectiles/Summon/EndoBeam.cs index f37d040193..6f234bf436 100644 --- a/Projectiles/Summon/EndoBeam.cs +++ b/Projectiles/Summon/EndoBeam.cs @@ -3,9 +3,10 @@ using Microsoft.Xna.Framework.Graphics; using System; using System.IO; using Terraria; -using Terraria.ID; using Terraria.Enums; +using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Summon { public class EndoBeam : ModProjectile @@ -38,7 +39,7 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = timeToExist; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.coldDamage = true; + projectile.coldDamage = true; } // Netcode for sending and receiving shit @@ -201,10 +202,5 @@ namespace CalamityMod.Projectiles.Summon } return false; } - - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModLoader.GetMod("CalamityMod").BuffType("GodSlayerInferno"), 300); - } } } From 33ba777195c1c6bf18647759093fa12eb992b147 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sun, 11 Apr 2021 18:34:31 -0400 Subject: [PATCH 24/32] All other mods are cached in CalamityMod for efficiency. This includes Music Mod. --- Buffs/Mounts/AndromedaBuff.cs | 16 ++-- CalamityMod.cs | 81 +++++++++++++------ Items/Fishing/GlimmeringGemfish.cs | 2 +- Items/Fishing/StuffedFish.cs | 18 +++-- Items/TreasureBags/StarterBag.cs | 2 +- ModSupport/WeakReferenceSupport.cs | 14 ++-- NPCs/AquaticScourge/AquaticScourgeHead.cs | 2 +- NPCs/AstrumAureus/AstrumAureus.cs | 2 +- NPCs/AstrumDeus/AstrumDeusBodySpectral.cs | 2 +- NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs | 2 +- NPCs/AstrumDeus/AstrumDeusTailSpectral.cs | 2 +- NPCs/BrimstoneElemental/BrimstoneElemental.cs | 2 +- NPCs/Bumblebirb/Bumblefuck.cs | 4 +- NPCs/Calamitas/CalamitasRun.cs | 2 +- NPCs/Calamitas/CalamitasRun2.cs | 2 +- NPCs/Calamitas/CalamitasRun3.cs | 2 +- NPCs/CeaselessVoid/CeaselessVoid.cs | 2 +- NPCs/Crabulon/CrabulonIdle.cs | 2 +- NPCs/Cryogen/Cryogen.cs | 2 +- NPCs/DesertScourge/DesertScourgeBody.cs | 2 +- NPCs/DesertScourge/DesertScourgeHead.cs | 2 +- NPCs/DesertScourge/DesertScourgeTail.cs | 2 +- NPCs/DevourerofGods/DevourerofGodsBody.cs | 2 +- NPCs/DevourerofGods/DevourerofGodsBodyS.cs | 2 +- NPCs/DevourerofGods/DevourerofGodsHead.cs | 2 +- NPCs/DevourerofGods/DevourerofGodsHeadS.cs | 2 +- NPCs/DevourerofGods/DevourerofGodsTail.cs | 2 +- NPCs/DevourerofGods/DevourerofGodsTailS.cs | 2 +- NPCs/HiveMind/HiveMind.cs | 2 +- NPCs/HiveMind/HiveMindP2.cs | 2 +- NPCs/Leviathan/Leviathan.cs | 2 +- NPCs/Leviathan/LeviathanStart.cs | 2 +- NPCs/Leviathan/Siren.cs | 6 +- NPCs/OldDuke/OldDuke.cs | 4 +- NPCs/Perforator/PerforatorHive.cs | 4 +- .../PlaguebringerGoliath.cs | 2 +- NPCs/Polterghast/Polterghast.cs | 4 +- .../ProfanedGuardians/ProfanedGuardianBoss.cs | 2 +- .../ProfanedGuardianBoss2.cs | 2 +- .../ProfanedGuardianBoss3.cs | 2 +- NPCs/Providence/Providence.cs | 4 +- NPCs/Ravager/RavagerBody.cs | 2 +- NPCs/Signus/Signus.cs | 2 +- NPCs/SlimeGod/SlimeGod.cs | 2 +- NPCs/SlimeGod/SlimeGodCore.cs | 4 +- NPCs/SlimeGod/SlimeGodRun.cs | 2 +- NPCs/SlimeGod/SlimeGodRunSplit.cs | 2 +- NPCs/SlimeGod/SlimeGodSplit.cs | 2 +- NPCs/StormWeaver/StormWeaverBody.cs | 2 +- NPCs/StormWeaver/StormWeaverBodyNaked.cs | 2 +- NPCs/StormWeaver/StormWeaverHead.cs | 2 +- NPCs/StormWeaver/StormWeaverHeadNaked.cs | 2 +- NPCs/StormWeaver/StormWeaverTail.cs | 2 +- NPCs/StormWeaver/StormWeaverTailNaked.cs | 2 +- NPCs/SupremeCalamitas/SupremeCalamitas.cs | 8 +- NPCs/Yharon/Yharon.cs | 4 +- World/DraedonStructures.cs | 4 +- World/Planets/Planetoid.cs | 2 +- World/WorldGenerationMethods.cs | 2 +- 59 files changed, 146 insertions(+), 119 deletions(-) diff --git a/Buffs/Mounts/AndromedaBuff.cs b/Buffs/Mounts/AndromedaBuff.cs index f6ee2e2f68..87e673f814 100644 --- a/Buffs/Mounts/AndromedaBuff.cs +++ b/Buffs/Mounts/AndromedaBuff.cs @@ -3,7 +3,7 @@ using Terraria.ModLoader; namespace CalamityMod.Buffs.Mounts { - public class AndromedaBuff : ModBuff + public class AndromedaBuff : ModBuff { public override void SetDefaults() { @@ -15,15 +15,15 @@ namespace CalamityMod.Buffs.Mounts public override void Update(Player player, ref int buffIndex) { - //Disables crouching with the Crouch, Crawl, and Roll Mod - Mod crouchMod = ModLoader.GetMod("CrouchMod"); + // Disables crouching with the Crouch, Crawl, and Roll Mod + Mod crouchMod = CalamityMod.Instance.crouchMod; if (crouchMod != null) { - //Mod Call inputs - //"CanCrouch" //string which is required - //p //int for the player's index - //canCrouch //bool whether the player can input crouch (point being to set this to false) - //forceUnCrouch //bool which, if true, forces the player to uncrouch (forcing their head into the ceiling) + // Mod Call inputs + // 1) "CanCrouch" -- name of operation + // 2) int for the player's index + // 3) bool for whether the player can use the crouch input this frame + // 4) bool for whether the player should be force-uncrouched this frame crouchMod.Call("CanCrouch", player.whoAmI, false, true); } } diff --git a/CalamityMod.cs b/CalamityMod.cs index 544e28d565..6f28e75e10 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -48,7 +48,6 @@ using System.Reflection; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.Dyes; -using Terraria.GameContent.Events; using Terraria.Graphics.Effects; using Terraria.Graphics.Shaders; using Terraria.ID; @@ -101,16 +100,37 @@ namespace CalamityMod public const float velocityScaleMin = 0.5f; public const float bitingEnemeyVelocityScale = 0.8f; - // TODO -- Calamity should check for other mods existing in exactly one place - public bool fargosMutant = false; - internal static CalamityMod Instance; + internal Mod musicMod = null; // this is Calamity's official music mod, CalamityModMusic + internal Mod ancientsAwakened = null; + internal Mod bossChecklist = null; + internal Mod census = null; + internal Mod crouchMod = null; + internal Mod fargos = null; + internal Mod redemption = null; + internal Mod soa = null; + internal Mod summonersAssociation = null; + internal Mod thorium = null; + internal Mod varia = null; #region Load public override void Load() { Instance = this; + // If any of these mods aren't loaded, it will simply keep them as null. + musicMod = ModLoader.GetMod("CalamityModMusic"); + ancientsAwakened = ModLoader.GetMod("AAMod"); + bossChecklist = ModLoader.GetMod("BossChecklist"); + census = ModLoader.GetMod("Census"); + crouchMod = ModLoader.GetMod("CrouchMod"); + fargos = ModLoader.GetMod("Fargowiltas"); + redemption = ModLoader.GetMod("Redemption"); + soa = ModLoader.GetMod("SacredTools"); + summonersAssociation = ModLoader.GetMod("SummonersAssociation"); + thorium = ModLoader.GetMod("ThoriumMod"); + varia = ModLoader.GetMod("Varia"); + // Initialize the BossStats struct as early as it is safe to do so NPCStats.Load(); @@ -236,6 +256,18 @@ namespace CalamityMod #region Unload public override void Unload() { + musicMod = null; + ancientsAwakened = null; + bossChecklist = null; + census = null; + crouchMod = null; + fargos = null; + redemption = null; + soa = null; + summonersAssociation = null; + thorium = null; + varia = null; + NormalityRelocatorHotKey = null; RageHotKey = null; AdrenalineHotKey = null; @@ -262,8 +294,6 @@ namespace CalamityMod CalamityLists.UnloadLists(); NPCStats.Unload(); - fargosMutant = false; - PopupGUIManager.UnloadGUIs(); InvasionProgressUIManager.UnloadGUIs(); BossRushEvent.Unload(); @@ -647,7 +677,6 @@ namespace CalamityMod #region Music public override void UpdateMusic(ref int music, ref MusicPriority priority) { - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); if (Main.musicVolume != 0) { if (Main.myPlayer != -1 && !Main.gameMenu && Main.LocalPlayer.active) @@ -657,8 +686,8 @@ namespace CalamityMod { if (!CalamityPlayer.areThereAnyDamnBosses) { - if (calamityModMusic != null) - music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/Crag"); + if (musicMod != null) + music = musicMod.GetSoundSlot(SoundType.Music, "Sounds/Music/Crag"); else music = MusicID.Eerie; priority = MusicPriority.Environment; @@ -668,8 +697,8 @@ namespace CalamityMod { if (!CalamityPlayer.areThereAnyDamnBosses) { - if (calamityModMusic != null) - music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/SunkenSea"); + if (musicMod != null) + music = musicMod.GetSoundSlot(SoundType.Music, "Sounds/Music/SunkenSea"); else music = MusicID.Temple; priority = MusicPriority.Environment; @@ -679,9 +708,9 @@ namespace CalamityMod { if (!CalamityPlayer.areThereAnyDamnBosses) { - if (calamityModMusic != null) + if (musicMod != null) { - music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/Astral"); + music = musicMod.GetSoundSlot(SoundType.Music, "Sounds/Music/Astral"); } else music = MusicID.Space; @@ -692,9 +721,9 @@ namespace CalamityMod { if (!CalamityPlayer.areThereAnyDamnBosses) { - if (calamityModMusic != null) + if (musicMod != null) { - music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/AstralUnderground"); + music = musicMod.GetSoundSlot(SoundType.Music, "Sounds/Music/AstralUnderground"); } else music = MusicID.Space; @@ -705,8 +734,8 @@ namespace CalamityMod { if (!CalamityPlayer.areThereAnyDamnBosses) { - if (calamityModMusic != null) - music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/TheAbyss"); + if (musicMod != null) + music = musicMod.GetSoundSlot(SoundType.Music, "Sounds/Music/TheAbyss"); else music = MusicID.Hell; priority = MusicPriority.BiomeHigh; @@ -716,8 +745,8 @@ namespace CalamityMod { if (!CalamityPlayer.areThereAnyDamnBosses) { - if (calamityModMusic != null) - music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/TheDeepAbyss"); + if (musicMod != null) + music = musicMod.GetSoundSlot(SoundType.Music, "Sounds/Music/TheDeepAbyss"); else music = MusicID.Hell; priority = MusicPriority.BiomeHigh; @@ -727,8 +756,8 @@ namespace CalamityMod { if (!CalamityPlayer.areThereAnyDamnBosses) { - if (calamityModMusic != null) - music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/TheVoid"); + if (musicMod != null) + music = musicMod.GetSoundSlot(SoundType.Music, "Sounds/Music/TheVoid"); else music = MusicID.Hell; priority = MusicPriority.BiomeHigh; @@ -739,11 +768,11 @@ namespace CalamityMod if (!CalamityPlayer.areThereAnyDamnBosses) { bool acidRain = CalamityWorld.rainingAcid; - if (calamityModMusic != null) + if (musicMod != null) { string rainMusic = "Sounds/Music/AcidRain"; string musicChoice = acidRain ? rainMusic + (CalamityWorld.downedPolterghast ? "2" : "1") : "Sounds/Music/Sulphur"; //replace first acidrain1 once second theme is added. - music = calamityModMusic.GetSoundSlot(SoundType.Music, musicChoice); + music = musicMod.GetSoundSlot(SoundType.Music, musicChoice); } else @@ -755,8 +784,8 @@ namespace CalamityMod { if (!CalamityPlayer.areThereAnyDamnBosses) { - if (calamityModMusic != null) - music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/UniversalCollapse"); + if (musicMod != null) + music = musicMod.GetSoundSlot(SoundType.Music, "Sounds/Music/UniversalCollapse"); else music = MusicID.LunarBoss; priority = MusicPriority.BossMedium; @@ -767,7 +796,7 @@ namespace CalamityMod } #endregion - #region ModSupport + #region Mod Support public override void PostSetupContent() => WeakReferenceSupport.Setup(); public override object Call(params object[] args) => ModCalls.Call(args); diff --git a/Items/Fishing/GlimmeringGemfish.cs b/Items/Fishing/GlimmeringGemfish.cs index 19d07620da..bc5867add3 100644 --- a/Items/Fishing/GlimmeringGemfish.cs +++ b/Items/Fishing/GlimmeringGemfish.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Items.Fishing DropHelper.DropItemChance(player, ItemID.Ruby, 0.15f, gemMin, gemMax); DropHelper.DropItemChance(player, ItemID.Diamond, 0.1f, gemMin, gemMax); DropHelper.DropItemChance(player, ItemID.Amber, 0.25f, gemMin, gemMax); - Mod thorium = ModLoader.GetMod("ThoriumMod"); + Mod thorium = CalamityMod.Instance.thorium; if (thorium != null) { DropHelper.DropItemChance(player, thorium.ItemType("Pearl"), 0.25f, gemMin, gemMax); diff --git a/Items/Fishing/StuffedFish.cs b/Items/Fishing/StuffedFish.cs index 701afa63d0..503018b1ac 100644 --- a/Items/Fishing/StuffedFish.cs +++ b/Items/Fishing/StuffedFish.cs @@ -54,20 +54,22 @@ namespace CalamityMod.Items.Fishing DropHelper.DropItemCondition(player, ItemID.CorruptSeeds, !WorldGen.crimson, 0.05f, seedMin, seedMax); DropHelper.DropItemCondition(player, ItemID.CrimsonSeeds, WorldGen.crimson, 0.05f, seedMin, seedMax); DropHelper.DropItemCondition(player, ItemID.HallowedSeeds, Main.hardMode, 0.05f, seedMin, seedMax); - Mod thorium = ModLoader.GetMod("ThoriumMod"); + Mod thorium = CalamityMod.Instance.thorium; if (thorium != null) { DropHelper.DropItemChance(player, thorium.ItemType("MarineKelp"), 0.25f, herbMin, herbMax); DropHelper.DropItemChance(player, thorium.ItemType("MarineKelpSeeds"), 0.1f, seedMin, seedMax); } - Mod shadowsOfAbaddon = ModLoader.GetMod("SacredTools"); - if (shadowsOfAbaddon != null) + Mod soa = CalamityMod.Instance.soa; + if (soa != null) { - DropHelper.DropItemChance(player, shadowsOfAbaddon.ItemType("Welkinbell"), 0.25f, herbMin, herbMax); - DropHelper.DropItemChance(player, shadowsOfAbaddon.ItemType("WelkinbellSeeds"), 0.1f, seedMin, seedMax); - DropHelper.DropItemCondition(player, shadowsOfAbaddon.ItemType("Illumifern"), Main.hardMode, 0.25f, herbMin, herbMax); - DropHelper.DropItemCondition(player, shadowsOfAbaddon.ItemType("IllumifernSeeds"), Main.hardMode, 0.1f, seedMin, seedMax); - //There's no mod call for Abaddon being dead + DropHelper.DropItemChance(player, soa.ItemType("Welkinbell"), 0.25f, herbMin, herbMax); + DropHelper.DropItemChance(player, soa.ItemType("WelkinbellSeeds"), 0.1f, seedMin, seedMax); + DropHelper.DropItemCondition(player, soa.ItemType("Illumifern"), Main.hardMode, 0.25f, herbMin, herbMax); + DropHelper.DropItemCondition(player, soa.ItemType("IllumifernSeeds"), Main.hardMode, 0.1f, seedMin, seedMax); + + // TODO -- There is no way to determine if SoA's Abaddon is dead without reflection. + // Dan Yami has confirmed that downed calls will be added to SoA eventually. //DropHelper.DropItemCondition(player, shadowsOfAbaddon.ItemType("Enduflora"), SacredTools.ModdedWorld.downedAbaddon, 0.25f, herbMin, herbMax); //DropHelper.DropItemCondition(player, shadowsOfAbaddon.ItemType("EndufloraSeeds"), SacredTools.ModdedWorld.downedAbaddon, 0.1f, seedMin, seedMax); } diff --git a/Items/TreasureBags/StarterBag.cs b/Items/TreasureBags/StarterBag.cs index 885bd33912..afeb433019 100644 --- a/Items/TreasureBags/StarterBag.cs +++ b/Items/TreasureBags/StarterBag.cs @@ -62,7 +62,7 @@ namespace CalamityMod.Items.TreasureBags DropHelper.DropItemCondition(player, ModContent.ItemType(), player.name == "Aleksh" || player.name == "Shark Lad"); // Music box (if music mod installed) - Mod musicMod = ModLoader.GetMod("CalamityModMusic"); + Mod musicMod = CalamityMod.Instance.musicMod; if (musicMod != null) DropHelper.DropItem(player, musicMod.ItemType("CalamityMusicbox")); } diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index 748971b1d2..b5809c6b10 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -225,9 +225,8 @@ namespace CalamityMod ///
private static void BossChecklistSupport() { - Mod bossChecklist = ModLoader.GetMod("BossChecklist"); - Mod calamity = GetInstance(); - + CalamityMod calamity = GetInstance(); + Mod bossChecklist = calamity.bossChecklist; if (bossChecklist is null) return; @@ -798,13 +797,10 @@ namespace CalamityMod private static void FargosSupport() { - Mod fargos = ModLoader.GetMod("Fargowiltas"); + Mod fargos = GetInstance().fargos; if (fargos is null) return; - // Mark Fargo's Mutant Mod as loaded so that Calamity doesn't add ANY boss summons to vanilla NPCs, even for its own bosses - GetInstance().fargosMutant = true; - void AddToMutantShop(string bossName, string summonItemName, Func downed, int price) { BossDifficulty.TryGetValue(bossName, out float order); @@ -838,7 +834,7 @@ namespace CalamityMod private static void CensusSupport() { - Mod censusMod = ModLoader.GetMod("Census"); + Mod censusMod = GetInstance().census; if (censusMod != null) { censusMod.Call("TownNPCCondition", NPCType(), "Defeat a Giant Clam after defeating the Desert Scourge"); @@ -850,7 +846,7 @@ namespace CalamityMod private static void SummonersAssociationSupport() { - Mod sAssociation = ModLoader.GetMod("SummonersAssociation"); + Mod sAssociation = GetInstance().summonersAssociation; if (sAssociation is null) return; diff --git a/NPCs/AquaticScourge/AquaticScourgeHead.cs b/NPCs/AquaticScourge/AquaticScourgeHead.cs index 6d680bf3da..890fdb2e7c 100644 --- a/NPCs/AquaticScourge/AquaticScourgeHead.cs +++ b/NPCs/AquaticScourge/AquaticScourgeHead.cs @@ -87,7 +87,7 @@ namespace CalamityMod.NPCs.AquaticScourge { if (npc.justHit || npc.life <= npc.lifeMax * 0.99 || BossRushEvent.BossRushActive) { - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/AquaticScourge"); else diff --git a/NPCs/AstrumAureus/AstrumAureus.cs b/NPCs/AstrumAureus/AstrumAureus.cs index a48ef86a06..5c3fd7f69c 100644 --- a/NPCs/AstrumAureus/AstrumAureus.cs +++ b/NPCs/AstrumAureus/AstrumAureus.cs @@ -55,7 +55,7 @@ namespace CalamityMod.NPCs.AstrumAureus npc.value = Item.buyPrice(0, 15, 0, 0); npc.boss = true; npc.DeathSound = SoundID.NPCDeath14; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/Astrageldon"); else diff --git a/NPCs/AstrumDeus/AstrumDeusBodySpectral.cs b/NPCs/AstrumDeus/AstrumDeusBodySpectral.cs index ca698e163b..cc9ca555e8 100644 --- a/NPCs/AstrumDeus/AstrumDeusBodySpectral.cs +++ b/NPCs/AstrumDeus/AstrumDeusBodySpectral.cs @@ -46,7 +46,7 @@ namespace CalamityMod.NPCs.AstrumDeus npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstrumDeusDeath"); npc.netAlways = true; npc.boss = true; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/AstrumDeus"); else diff --git a/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs b/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs index e397f16129..fdb8e2e10d 100644 --- a/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs +++ b/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs @@ -61,7 +61,7 @@ namespace CalamityMod.NPCs.AstrumDeus npc.HitSound = SoundID.NPCHit4; npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstrumDeusDeath"); npc.netAlways = true; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/AstrumDeus"); else diff --git a/NPCs/AstrumDeus/AstrumDeusTailSpectral.cs b/NPCs/AstrumDeus/AstrumDeusTailSpectral.cs index 1ea03efe87..34527b9bea 100644 --- a/NPCs/AstrumDeus/AstrumDeusTailSpectral.cs +++ b/NPCs/AstrumDeus/AstrumDeusTailSpectral.cs @@ -46,7 +46,7 @@ namespace CalamityMod.NPCs.AstrumDeus npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstrumDeusDeath"); npc.netAlways = true; npc.boss = true; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/AstrumDeus"); else diff --git a/NPCs/BrimstoneElemental/BrimstoneElemental.cs b/NPCs/BrimstoneElemental/BrimstoneElemental.cs index c941dd699b..1f2045a690 100644 --- a/NPCs/BrimstoneElemental/BrimstoneElemental.cs +++ b/NPCs/BrimstoneElemental/BrimstoneElemental.cs @@ -59,7 +59,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental npc.netAlways = true; npc.HitSound = SoundID.NPCHit23; npc.DeathSound = SoundID.NPCDeath39; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/LeftAlone"); else diff --git a/NPCs/Bumblebirb/Bumblefuck.cs b/NPCs/Bumblebirb/Bumblefuck.cs index 1fbba45016..7a81f3edb1 100644 --- a/NPCs/Bumblebirb/Bumblefuck.cs +++ b/NPCs/Bumblebirb/Bumblefuck.cs @@ -53,8 +53,8 @@ namespace CalamityMod.NPCs.Bumblebirb npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.knockBackResist = 0f; npc.boss = true; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); - if (calamityModMusic != null) + Mod calamityModMusic = CalamityMod.Instance.musicMod; + if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/Murderswarm"); else music = MusicID.Boss4; diff --git a/NPCs/Calamitas/CalamitasRun.cs b/NPCs/Calamitas/CalamitasRun.cs index 7038986beb..e5c9326a84 100644 --- a/NPCs/Calamitas/CalamitasRun.cs +++ b/NPCs/Calamitas/CalamitasRun.cs @@ -47,7 +47,7 @@ namespace CalamityMod.NPCs.Calamitas npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath14; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/Calamitas"); else diff --git a/NPCs/Calamitas/CalamitasRun2.cs b/NPCs/Calamitas/CalamitasRun2.cs index 949da6fc25..f4fe36a3e2 100644 --- a/NPCs/Calamitas/CalamitasRun2.cs +++ b/NPCs/Calamitas/CalamitasRun2.cs @@ -47,7 +47,7 @@ namespace CalamityMod.NPCs.Calamitas npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath14; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/Calamitas"); else diff --git a/NPCs/Calamitas/CalamitasRun3.cs b/NPCs/Calamitas/CalamitasRun3.cs index d105c254ae..bef9d6b164 100644 --- a/NPCs/Calamitas/CalamitasRun3.cs +++ b/NPCs/Calamitas/CalamitasRun3.cs @@ -62,7 +62,7 @@ namespace CalamityMod.NPCs.Calamitas npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath14; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/Calamitas"); else diff --git a/NPCs/CeaselessVoid/CeaselessVoid.cs b/NPCs/CeaselessVoid/CeaselessVoid.cs index 61c77d6c3a..621ca28d4d 100644 --- a/NPCs/CeaselessVoid/CeaselessVoid.cs +++ b/NPCs/CeaselessVoid/CeaselessVoid.cs @@ -37,7 +37,7 @@ namespace CalamityMod.NPCs.CeaselessVoid CalamityGlobalNPC global = npc.Calamity(); global.DR = 0.5f; npc.lifeMax = 25000; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/ScourgeofTheUniverse"); else diff --git a/NPCs/Crabulon/CrabulonIdle.cs b/NPCs/Crabulon/CrabulonIdle.cs index 2f9fa798f8..078b02ea12 100644 --- a/NPCs/Crabulon/CrabulonIdle.cs +++ b/NPCs/Crabulon/CrabulonIdle.cs @@ -47,7 +47,7 @@ namespace CalamityMod.NPCs.Crabulon aiType = -1; npc.noGravity = false; npc.noTileCollide = false; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/Crabulon"); else diff --git a/NPCs/Cryogen/Cryogen.cs b/NPCs/Cryogen/Cryogen.cs index b541ecb015..c22c467fdd 100644 --- a/NPCs/Cryogen/Cryogen.cs +++ b/NPCs/Cryogen/Cryogen.cs @@ -62,7 +62,7 @@ namespace CalamityMod.NPCs.Cryogen npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit5; npc.DeathSound = SoundID.NPCDeath15; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/Cryogen"); else diff --git a/NPCs/DesertScourge/DesertScourgeBody.cs b/NPCs/DesertScourge/DesertScourgeBody.cs index 109bfde2fd..f93a6fc0e7 100644 --- a/NPCs/DesertScourge/DesertScourgeBody.cs +++ b/NPCs/DesertScourge/DesertScourgeBody.cs @@ -32,7 +32,7 @@ namespace CalamityMod.NPCs.DesertScourge npc.knockBackResist = 0f; npc.alpha = 255; npc.boss = true; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/DesertScourge"); else diff --git a/NPCs/DesertScourge/DesertScourgeHead.cs b/NPCs/DesertScourge/DesertScourgeHead.cs index 1baadfbd3e..83f8312f44 100644 --- a/NPCs/DesertScourge/DesertScourgeHead.cs +++ b/NPCs/DesertScourge/DesertScourgeHead.cs @@ -55,7 +55,7 @@ namespace CalamityMod.NPCs.DesertScourge npc.DeathSound = SoundID.NPCDeath1; npc.netAlways = true; bossBag = ModContent.ItemType(); - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/DesertScourge"); else diff --git a/NPCs/DesertScourge/DesertScourgeTail.cs b/NPCs/DesertScourge/DesertScourgeTail.cs index 1f86623a32..9b4403dd18 100644 --- a/NPCs/DesertScourge/DesertScourgeTail.cs +++ b/NPCs/DesertScourge/DesertScourgeTail.cs @@ -30,7 +30,7 @@ namespace CalamityMod.NPCs.DesertScourge npc.knockBackResist = 0f; npc.alpha = 255; npc.boss = true; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/DesertScourge"); else diff --git a/NPCs/DevourerofGods/DevourerofGodsBody.cs b/NPCs/DevourerofGods/DevourerofGodsBody.cs index 862deda1f5..4f4a8e9e56 100644 --- a/NPCs/DevourerofGods/DevourerofGodsBody.cs +++ b/NPCs/DevourerofGods/DevourerofGodsBody.cs @@ -48,7 +48,7 @@ namespace CalamityMod.NPCs.DevourerofGods npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; npc.boss = true; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/ScourgeofTheUniverse"); else diff --git a/NPCs/DevourerofGods/DevourerofGodsBodyS.cs b/NPCs/DevourerofGods/DevourerofGodsBodyS.cs index 09dd81d7df..1a210c14a6 100644 --- a/NPCs/DevourerofGods/DevourerofGodsBodyS.cs +++ b/NPCs/DevourerofGods/DevourerofGodsBodyS.cs @@ -48,7 +48,7 @@ namespace CalamityMod.NPCs.DevourerofGods npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; npc.boss = true; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/UniversalCollapse"); else diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index e94685fede..eaa49220fb 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -68,7 +68,7 @@ namespace CalamityMod.NPCs.DevourerofGods npc.noTileCollide = true; npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/ScourgeofTheUniverse"); else diff --git a/NPCs/DevourerofGods/DevourerofGodsHeadS.cs b/NPCs/DevourerofGods/DevourerofGodsHeadS.cs index 91507c5091..366fd50305 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHeadS.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHeadS.cs @@ -100,7 +100,7 @@ namespace CalamityMod.NPCs.DevourerofGods npc.noTileCollide = true; npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/UniversalCollapse"); else diff --git a/NPCs/DevourerofGods/DevourerofGodsTail.cs b/NPCs/DevourerofGods/DevourerofGodsTail.cs index e220819830..2fa3f688d2 100644 --- a/NPCs/DevourerofGods/DevourerofGodsTail.cs +++ b/NPCs/DevourerofGods/DevourerofGodsTail.cs @@ -41,7 +41,7 @@ namespace CalamityMod.NPCs.DevourerofGods npc.netAlways = true; npc.boss = true; npc.takenDamageMultiplier = 1.25f; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/ScourgeofTheUniverse"); else diff --git a/NPCs/DevourerofGods/DevourerofGodsTailS.cs b/NPCs/DevourerofGods/DevourerofGodsTailS.cs index 7c00707ebd..49587254e0 100644 --- a/NPCs/DevourerofGods/DevourerofGodsTailS.cs +++ b/NPCs/DevourerofGods/DevourerofGodsTailS.cs @@ -50,7 +50,7 @@ namespace CalamityMod.NPCs.DevourerofGods npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; npc.boss = true; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/UniversalCollapse"); else diff --git a/NPCs/HiveMind/HiveMind.cs b/NPCs/HiveMind/HiveMind.cs index 37431ecdb3..6b122faa69 100644 --- a/NPCs/HiveMind/HiveMind.cs +++ b/NPCs/HiveMind/HiveMind.cs @@ -36,7 +36,7 @@ namespace CalamityMod.NPCs.HiveMind npc.value = 0f; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/HiveMind"); else diff --git a/NPCs/HiveMind/HiveMindP2.cs b/NPCs/HiveMind/HiveMindP2.cs index 1f151d0f59..c21872e673 100644 --- a/NPCs/HiveMind/HiveMindP2.cs +++ b/NPCs/HiveMind/HiveMindP2.cs @@ -87,7 +87,7 @@ namespace CalamityMod.NPCs.HiveMind npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/HiveMind"); else diff --git a/NPCs/Leviathan/Leviathan.cs b/NPCs/Leviathan/Leviathan.cs index f6317bb048..a68fc5d86c 100644 --- a/NPCs/Leviathan/Leviathan.cs +++ b/NPCs/Leviathan/Leviathan.cs @@ -61,7 +61,7 @@ namespace CalamityMod.NPCs.Leviathan npc.noGravity = true; npc.boss = true; npc.netAlways = true; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/LeviathanAndSiren"); else diff --git a/NPCs/Leviathan/LeviathanStart.cs b/NPCs/Leviathan/LeviathanStart.cs index 85b16709f7..5956cff4c0 100644 --- a/NPCs/Leviathan/LeviathanStart.cs +++ b/NPCs/Leviathan/LeviathanStart.cs @@ -34,7 +34,7 @@ namespace CalamityMod.NPCs.Leviathan npc.HitSound = SoundID.NPCHit1; npc.DeathSound = null; npc.rarity = 2; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/SirenLure"); } diff --git a/NPCs/Leviathan/Siren.cs b/NPCs/Leviathan/Siren.cs index 6682548e91..7b0b0a0541 100644 --- a/NPCs/Leviathan/Siren.cs +++ b/NPCs/Leviathan/Siren.cs @@ -49,8 +49,8 @@ namespace CalamityMod.NPCs.Leviathan npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); - if (calamityModMusic != null) + Mod calamityModMusic = CalamityMod.Instance.musicMod; + if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/Siren"); else music = MusicID.Boss3; @@ -145,7 +145,7 @@ namespace CalamityMod.NPCs.Leviathan { if (!spawnedLevi) { - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/LeviathanAndSiren"); else diff --git a/NPCs/OldDuke/OldDuke.cs b/NPCs/OldDuke/OldDuke.cs index ec42550fd6..cf5fbcb238 100644 --- a/NPCs/OldDuke/OldDuke.cs +++ b/NPCs/OldDuke/OldDuke.cs @@ -55,8 +55,8 @@ namespace CalamityMod.NPCs.OldDuke npc.boss = true; npc.netAlways = true; npc.timeLeft = NPC.activeTime * 30; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); - if (calamityModMusic != null) + Mod calamityModMusic = CalamityMod.Instance.musicMod; + if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/BoomerDuke"); else music = MusicID.Boss1; diff --git a/NPCs/Perforator/PerforatorHive.cs b/NPCs/Perforator/PerforatorHive.cs index 79938668ea..b90ba70037 100644 --- a/NPCs/Perforator/PerforatorHive.cs +++ b/NPCs/Perforator/PerforatorHive.cs @@ -57,8 +57,8 @@ namespace CalamityMod.NPCs.Perforator npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit13; npc.DeathSound = SoundID.NPCDeath19; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); - if (calamityModMusic != null) + Mod calamityModMusic = CalamityMod.Instance.musicMod; + if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/BloodCoagulant"); else music = MusicID.Boss2; diff --git a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs index 28c3f05a32..7cd203eb0f 100644 --- a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs +++ b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs @@ -88,7 +88,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath14; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/PlaguebringerGoliath"); else diff --git a/NPCs/Polterghast/Polterghast.cs b/NPCs/Polterghast/Polterghast.cs index ce54dd99df..8ac69715f1 100644 --- a/NPCs/Polterghast/Polterghast.cs +++ b/NPCs/Polterghast/Polterghast.cs @@ -76,8 +76,8 @@ namespace CalamityMod.NPCs.Polterghast npc.noGravity = true; npc.noTileCollide = true; npc.netAlways = true; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); - if (calamityModMusic != null) + Mod calamityModMusic = CalamityMod.Instance.musicMod; + if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/RUIN"); else music = MusicID.Plantera; diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs b/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs index 285eae2e47..8b3cd1ce1e 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs @@ -51,7 +51,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians npc.noTileCollide = true; aiType = -1; npc.boss = true; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/Guardians"); else diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs b/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs index 334fa0ce6a..8442dda34b 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs @@ -44,7 +44,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians npc.canGhostHeal = false; aiType = -1; npc.boss = true; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/Guardians"); else diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianBoss3.cs b/NPCs/ProfanedGuardians/ProfanedGuardianBoss3.cs index 044f546538..d0ce8cf6fe 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianBoss3.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianBoss3.cs @@ -44,7 +44,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians npc.canGhostHeal = false; aiType = -1; npc.boss = true; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/Guardians"); else diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index 19b09cbd30..3eb58c8144 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -104,8 +104,8 @@ namespace CalamityMod.NPCs.Providence npc.netAlways = true; npc.chaseable = true; npc.canGhostHeal = false; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); - if (calamityModMusic != null) + Mod calamityModMusic = CalamityMod.Instance.musicMod; + if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/ProvidenceTheme"); else music = MusicID.LunarBoss; diff --git a/NPCs/Ravager/RavagerBody.cs b/NPCs/Ravager/RavagerBody.cs index 46ef60e755..2de8c36f7a 100644 --- a/NPCs/Ravager/RavagerBody.cs +++ b/NPCs/Ravager/RavagerBody.cs @@ -62,7 +62,7 @@ namespace CalamityMod.NPCs.Ravager npc.alpha = 255; npc.HitSound = SoundID.NPCHit41; npc.DeathSound = SoundID.NPCDeath14; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/Ravager"); else diff --git a/NPCs/Signus/Signus.cs b/NPCs/Signus/Signus.cs index 9f40f27a4e..b162273c6d 100644 --- a/NPCs/Signus/Signus.cs +++ b/NPCs/Signus/Signus.cs @@ -42,7 +42,7 @@ namespace CalamityMod.NPCs.Signus npc.width = 130; npc.height = 130; npc.defense = 60; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/ScourgeofTheUniverse"); else diff --git a/NPCs/SlimeGod/SlimeGod.cs b/NPCs/SlimeGod/SlimeGod.cs index 0805f8f3f1..54ce5f0b0d 100644 --- a/NPCs/SlimeGod/SlimeGod.cs +++ b/NPCs/SlimeGod/SlimeGod.cs @@ -41,7 +41,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.alpha = 55; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/SlimeGod"); else diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index 5a8452a602..eab46f5a02 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -56,8 +56,8 @@ namespace CalamityMod.NPCs.SlimeGod npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); - if (calamityModMusic != null) + Mod calamityModMusic = CalamityMod.Instance.musicMod; + if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/SlimeGod"); else music = MusicID.Boss1; diff --git a/NPCs/SlimeGod/SlimeGodRun.cs b/NPCs/SlimeGod/SlimeGodRun.cs index 579c832150..b9d12b9f1e 100644 --- a/NPCs/SlimeGod/SlimeGodRun.cs +++ b/NPCs/SlimeGod/SlimeGodRun.cs @@ -42,7 +42,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.noTileCollide = false; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/SlimeGod"); else diff --git a/NPCs/SlimeGod/SlimeGodRunSplit.cs b/NPCs/SlimeGod/SlimeGodRunSplit.cs index d13dd5b3ca..93d7ab0195 100644 --- a/NPCs/SlimeGod/SlimeGodRunSplit.cs +++ b/NPCs/SlimeGod/SlimeGodRunSplit.cs @@ -42,7 +42,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.noTileCollide = false; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/SlimeGod"); else diff --git a/NPCs/SlimeGod/SlimeGodSplit.cs b/NPCs/SlimeGod/SlimeGodSplit.cs index 2c21aff441..5dae4e75f3 100644 --- a/NPCs/SlimeGod/SlimeGodSplit.cs +++ b/NPCs/SlimeGod/SlimeGodSplit.cs @@ -44,7 +44,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.noTileCollide = false; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/SlimeGod"); else diff --git a/NPCs/StormWeaver/StormWeaverBody.cs b/NPCs/StormWeaver/StormWeaverBody.cs index 0a831e39ad..d6ccf72dfc 100644 --- a/NPCs/StormWeaver/StormWeaverBody.cs +++ b/NPCs/StormWeaver/StormWeaverBody.cs @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.StormWeaver global.unbreakableDR = true; bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; npc.LifeMaxNERB(notDoGFight ? 65000 : 13000, notDoGFight ? 65000 : 13000, 170000); - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/ScourgeofTheUniverse"); else diff --git a/NPCs/StormWeaver/StormWeaverBodyNaked.cs b/NPCs/StormWeaver/StormWeaverBodyNaked.cs index 855f41bfb9..bdab186bb3 100644 --- a/NPCs/StormWeaver/StormWeaverBodyNaked.cs +++ b/NPCs/StormWeaver/StormWeaverBodyNaked.cs @@ -29,7 +29,7 @@ namespace CalamityMod.NPCs.StormWeaver npc.lifeMax = 100000; bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; npc.LifeMaxNERB(notDoGFight ? 585000 : 97500, notDoGFight ? 585000 : 97500, 3500000); - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/ScourgeofTheUniverse"); else diff --git a/NPCs/StormWeaver/StormWeaverHead.cs b/NPCs/StormWeaver/StormWeaverHead.cs index ca0dba0b22..0aa90d6cea 100644 --- a/NPCs/StormWeaver/StormWeaverHead.cs +++ b/NPCs/StormWeaver/StormWeaverHead.cs @@ -37,7 +37,7 @@ namespace CalamityMod.NPCs.StormWeaver global.unbreakableDR = true; bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; npc.LifeMaxNERB(notDoGFight ? 65000 : 13000, notDoGFight ? 65000 : 13000, 170000); - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/ScourgeofTheUniverse"); else diff --git a/NPCs/StormWeaver/StormWeaverHeadNaked.cs b/NPCs/StormWeaver/StormWeaverHeadNaked.cs index fd8c86f702..2cd6c028c3 100644 --- a/NPCs/StormWeaver/StormWeaverHeadNaked.cs +++ b/NPCs/StormWeaver/StormWeaverHeadNaked.cs @@ -42,7 +42,7 @@ namespace CalamityMod.NPCs.StormWeaver npc.height = 74; bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; npc.LifeMaxNERB(notDoGFight ? 585000 : 97500, notDoGFight ? 585000 : 97500, 3500000); - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/ScourgeofTheUniverse"); else diff --git a/NPCs/StormWeaver/StormWeaverTail.cs b/NPCs/StormWeaver/StormWeaverTail.cs index 5476f18879..62c186a6c9 100644 --- a/NPCs/StormWeaver/StormWeaverTail.cs +++ b/NPCs/StormWeaver/StormWeaverTail.cs @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.StormWeaver npc.takenDamageMultiplier = 3f; bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; npc.LifeMaxNERB(notDoGFight ? 65000 : 13000, notDoGFight ? 65000 : 13000, 170000); - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/ScourgeofTheUniverse"); else diff --git a/NPCs/StormWeaver/StormWeaverTailNaked.cs b/NPCs/StormWeaver/StormWeaverTailNaked.cs index 7d8e0ffa83..d19d16c24b 100644 --- a/NPCs/StormWeaver/StormWeaverTailNaked.cs +++ b/NPCs/StormWeaver/StormWeaverTailNaked.cs @@ -28,7 +28,7 @@ namespace CalamityMod.NPCs.StormWeaver npc.height = 80; bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; npc.LifeMaxNERB(notDoGFight ? 585000 : 97500, notDoGFight ? 585000 : 97500, 3500000); - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/ScourgeofTheUniverse"); else diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index 811e217227..1a82cfbbbd 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -104,7 +104,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.noGravity = true; npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit4; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/SCG"); else @@ -586,7 +586,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas } if (!startThirdAttack && (npc.life <= npc.lifeMax * 0.5)) { - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/SCL"); else @@ -652,7 +652,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas } if (!startFourthAttack && (npc.life <= npc.lifeMax * 0.3)) { - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/SCE"); else @@ -732,7 +732,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas { if (gettingTired5) { - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/SCA"); else diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index 8fb1f483d5..c07231acc8 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -92,7 +92,7 @@ namespace CalamityMod.NPCs.Yharon npc.noTileCollide = true; npc.netAlways = true; - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/YHARON"); else @@ -1552,7 +1552,7 @@ namespace CalamityMod.NPCs.Yharon if (!moveCloser) { - Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); + Mod calamityModMusic = CalamityMod.Instance.musicMod; if (calamityModMusic != null) music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/DragonGod"); else diff --git a/World/DraedonStructures.cs b/World/DraedonStructures.cs index 3402eab80b..f10e8a59d7 100644 --- a/World/DraedonStructures.cs +++ b/World/DraedonStructures.cs @@ -23,7 +23,7 @@ namespace CalamityMod.World IList avoid = new List(16); // Mod of Redemption's labs use modded blocks, but must still be avoided. - Mod mor = ModLoader.GetMod("Redemption"); + Mod mor = CalamityMod.Instance.redemption; if (mor != null) { // Thanks to Hallam to providing these tile names. @@ -534,7 +534,7 @@ namespace CalamityMod.World new ChestItem(potionType, WorldGen.genRand.Next(3, 5 + 1)), }; - Mod thorium = ModLoader.GetMod("ThoriumMod"); + Mod thorium = CalamityMod.Instance.thorium; if (thorium != null) contents.Add(new ChestItem(thorium.ItemType("MarineKelpPlanterBox"), WorldGen.genRand.Next(5, 9 + 1))); diff --git a/World/Planets/Planetoid.cs b/World/Planets/Planetoid.cs index ada543be6b..8a50a06157 100644 --- a/World/Planets/Planetoid.cs +++ b/World/Planets/Planetoid.cs @@ -13,7 +13,7 @@ namespace CalamityMod.World.Planets public static bool InvalidSkyPlacementArea(Rectangle area) { - Mod varia = ModLoader.GetMod("Varia"); + Mod varia = CalamityMod.Instance.varia; for (int i = area.Left; i < area.Right; i++) { for (int j = area.Top; j < area.Bottom; j++) diff --git a/World/WorldGenerationMethods.cs b/World/WorldGenerationMethods.cs index d71c9035bb..63d04c4e68 100644 --- a/World/WorldGenerationMethods.cs +++ b/World/WorldGenerationMethods.cs @@ -337,7 +337,7 @@ namespace CalamityMod.World public static void PlaceAstralMeteor() { - Mod ancientsAwakened = ModLoader.GetMod("AAMod"); + Mod ancientsAwakened = CalamityMod.Instance.ancientsAwakened; // This flag is also used to determine whether players are nearby. bool meteorDropped = true; From 903c6d4f95c9f21f8965f0f8fb3cb51be33d48a1 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sun, 11 Apr 2021 19:58:39 -0400 Subject: [PATCH 25/32] 1 - Ongoing tooltip reworking. 2 - Removed an unnecessary tracked stat for "actual melee damage". --- CalPlayer/CalamityPlayer.cs | 3 +- CalPlayer/CalamityPlayerMiscEffects.cs | 1 - Items/CalamityGlobalItemTooltip.cs | 607 ++++++++++--------------- Utilities/ItemUtils.cs | 4 + 4 files changed, 242 insertions(+), 373 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 5cf0890c55..e0d394afb2 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -155,7 +155,6 @@ namespace CalamityMod.CalPlayer #region Stat Meter public int[] damageStats = new int[6]; public int[] critStats = new int[4]; - public float actualMeleeDamageStat = 0f; public int defenseStat = 0; public int DRStat = 0; public int meleeSpeedStat = 0; @@ -2529,7 +2528,7 @@ namespace CalamityMod.CalPlayer if (Main.snowTiles > 300) player.ZoneSnow = true; - Mod fargos = ModLoader.GetMod("Fargowiltas"); + Mod fargos = CalamityMod.Instance.fargos; if (fargos != null) { //Fargo's fountain effects diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 9f61959bb8..c7245767a4 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -3984,7 +3984,6 @@ namespace CalamityMod.CalPlayer private static void UpdateStatMeter(Player player, CalamityPlayer modPlayer) { float allDamageStat = player.allDamage - 1f; - modPlayer.actualMeleeDamageStat = player.meleeDamage + allDamageStat; modPlayer.damageStats[0] = (int)((player.meleeDamage + allDamageStat - 1f) * 100f); modPlayer.damageStats[1] = (int)((player.rangedDamage + allDamageStat - 1f) * 100f); modPlayer.damageStats[2] = (int)((player.magicDamage + allDamageStat - 1f) * 100f); diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index 093a641800..fd5e298fb2 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -13,6 +13,7 @@ using Microsoft.Xna.Framework; using System; using System.Collections.Generic; using System.Linq; +using System.Text; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -27,7 +28,11 @@ namespace CalamityMod.Items // Apply rarity coloration to the item's name. TooltipLine nameLine = tooltips.FirstOrDefault(x => x.Name == "ItemName" && x.mod == "Terraria"); if (nameLine != null) - ApplyRarityColors(item, nameLine); + ApplyRarityColor(item, nameLine); + + // If the item is melee, add a true melee damage number adjacent to the standard damage number. + if (item.melee && item.damage > 0 && Main.LocalPlayer.Calamity().trueMeleeDamage > 0D) + TrueMeleeDamageTooltip(item, tooltips); // Modify all vanilla tooltips before appending mod mechanics (if any). ModifyVanillaTooltips(item, tooltips); @@ -40,27 +45,8 @@ namespace CalamityMod.Items if (item.type < ItemID.Count) return; - // TODO -- mod references should be kept statically // Adds tooltips to Calamity fountains which match Fargo's fountain tooltips. - Mod fargos = ModLoader.GetMod("Fargowiltas"); - if (fargos != null) - { - if (item.type == ModContent.ItemType()) - { - TooltipLine line = new TooltipLine(mod, "FargoFountain", "Forces surrounding biome state to Sunken Sea upon activation"); - tooltips.Add(line); - } - if (item.type == ModContent.ItemType()) - { - TooltipLine line = new TooltipLine(mod, "FargoFountain", "Forces surrounding biome state to Sulphurous Sea upon activation"); - tooltips.Add(line); - } - if (item.type == ModContent.ItemType()) - { - TooltipLine line = new TooltipLine(mod, "FargoFountain", "Forces surrounding biome state to Astral upon activation"); - tooltips.Add(line); - } - } + FargoFountainTooltip(item, tooltips); // Adds a Current Charge tooltip to all items which use charge. CalamityGlobalItem modItem = item.Calamity(); @@ -75,61 +61,31 @@ namespace CalamityMod.Items // Adds "Donor Item" and "Developer Item" to donor items and developer items respectively. if (donorItem) { - TooltipLine line = new TooltipLine(mod, "CalamityDonor", CalamityUtils.ColorMessage("- Donor Item -", new Color(139, 0, 0))); + TooltipLine line = new TooltipLine(mod, "CalamityDonor", CalamityUtils.ColorMessage("- Donor Item -", CalamityUtils.DonatorItemColor)); tooltips.Add(line); } if (devItem) { - TooltipLine line = new TooltipLine(mod, "CalamityDev", CalamityUtils.ColorMessage("- Developer Item -", new Color(255, 0, 255))); + TooltipLine line = new TooltipLine(mod, "CalamityDev", CalamityUtils.ColorMessage("- Developer Item -", CalamityUtils.HotPinkRarityColor)); tooltips.Add(line); } - // Adds "Challenge Drop" or "Legendary Challenge Drop" to malice mode drops. + // Adds "Challenge Drop" or "Legendary Challenge Drop" to Malice Mode drops. + // For Legendary Challenge Drops, this tooltip matches their unique rarity color. if (challengeDrop) - { - Color lineColor = default; - if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) - lineColor = new Color(255, Main.DiscoG, 53); - if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) - lineColor = new Color(Main.DiscoR, 203, 103); - if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) - lineColor = new Color(53, Main.DiscoG, 255); - if (item.type == ModContent.ItemType()) - lineColor = new Color(150, Main.DiscoG, 255); - if (item.type == ModContent.ItemType()) - lineColor = new Color(60, Main.DiscoG, 190); - if (item.type == ModContent.ItemType()) - lineColor = new Color(255, Main.DiscoG, 155); - if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) - lineColor = new Color(255, Main.DiscoG, 0); - if (item.type == ModContent.ItemType()) - lineColor = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); - if (item.type == ModContent.ItemType()) - lineColor = CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 3f); - if (item.type == ModContent.ItemType()) - lineColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); - - if (lineColor != default) - { - TooltipLine line = new TooltipLine(mod, "LegendaryChallengeDrop", CalamityUtils.ColorMessage("- Legendary Challenge Drop -", lineColor)); - tooltips.Add(line); - return; - } - - TooltipLine line2 = new TooltipLine(mod, "ChallengeDrop", CalamityUtils.ColorMessage("- Challenge Drop -", new Color(255, 140, 0))); - tooltips.Add(line2); - } + ChallengeDropTooltip(item, tooltips); } #endregion #region Rarity Coloration - private void ApplyRarityColors(Item item, TooltipLine nameLine) + private void ApplyRarityColor(Item item, TooltipLine nameLine) { // Apply standard post-ML rarities to the item's color first. Color? standardRarityColor = CalamityUtils.GetRarityColor(customRarity); if (standardRarityColor.HasValue) nameLine.overrideColor = standardRarityColor.Value; + #region Uniquely Colored Developer Items if (item.type == ModContent.ItemType()) nameLine.overrideColor = new Color(Main.DiscoR, 100, 255); if (item.type == ModContent.ItemType()) @@ -223,6 +179,42 @@ namespace CalamityMod.Items nameLine.overrideColor = Color.Lerp(currentColor, nextColor, Main.GlobalTime % 2f > 1f ? 1f : Main.GlobalTime % 1f); } } + #endregion + } + #endregion + + #region Challenge Drop Tooltip + private void ChallengeDropTooltip(Item item, IList tooltips) + { + Color? legendaryColor = null; + if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) + legendaryColor = new Color(255, Main.DiscoG, 53); + if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) + legendaryColor = new Color(Main.DiscoR, 203, 103); + if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) + legendaryColor = new Color(53, Main.DiscoG, 255); + if (item.type == ModContent.ItemType()) + legendaryColor = new Color(150, Main.DiscoG, 255); + if (item.type == ModContent.ItemType()) + legendaryColor = new Color(60, Main.DiscoG, 190); + if (item.type == ModContent.ItemType()) + legendaryColor = new Color(255, Main.DiscoG, 155); + if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) + legendaryColor = new Color(255, Main.DiscoG, 0); + if (item.type == ModContent.ItemType()) + legendaryColor = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); + if (item.type == ModContent.ItemType()) + legendaryColor = CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 3f); + if (item.type == ModContent.ItemType()) + legendaryColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); + + Color lineColor = legendaryColor.GetValueOrDefault(CalamityUtils.ChallengeDropColor); + string text = legendaryColor.HasValue ? "- Legendary Challenge Drop -" : "- Challenge Drop"; + TooltipLine line = new TooltipLine(mod, "CalamityChallengeDrop", text) + { + overrideColor = lineColor + }; + tooltips.Add(line); } #endregion @@ -250,25 +242,81 @@ namespace CalamityMod.Items void EditTooltipByName(string lineName, Action action) => ApplyTooltipEdits(tooltips, LineName(lineName), action); #endregion - // 1) Mirrors and Recall Potions cannot be used while a boss is alive. + // Numerous random tooltip edits which don't fit into another category + #region Various Tooltip Edits + + // Mirrors and Recall Potions cannot be used while a boss is alive. if (item.type == ItemID.MagicMirror || item.type == ItemID.IceMirror || item.type == ItemID.CellPhone || item.type == ItemID.RecallPotion) ApplyTooltipEdits(tooltips, (i, l) => l.mod == "Terraria" && l.Name == (i.type == ItemID.CellPhone ? "Tooltip1" : "Tooltip0"), (line) => line.text += "\nCannot be used while a boss is alive"); - // 2) If Early Hardmode Rework is enabled: Remind users that ores will NOT spawn when an altar is smashed. + // Rod of Discord cannot be used multiple times to hurt yourself + if (item.type == ItemID.RodofDiscord) + EditTooltipByNum(0, (line) => line.text += "\nTeleportation is disabled while Chaos State is active"); + + // Water removing items cannot be used in the Abyss + string noAbyssLine = "\nCannot be used in the Abyss"; + if (item.type == ItemID.SuperAbsorbantSponge) + EditTooltipByNum(0, (line) => line.text += noAbyssLine); + if (item.type == ItemID.EmptyBucket) + EditTooltipByName("Defense", (line) => line.text += noAbyssLine); + + // If Early Hardmode Rework is enabled: Remind users that ores will NOT spawn when an altar is smashed. if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && (item.type == ItemID.Pwnhammer || item.type == ItemID.Hammush)) EditTooltipByNum(0, (line) => line.text += "\nDemon Altars no longer spawn ores when destroyed"); - // 3) Black Belt and Master Ninja Gear have guaranteed dodges on a 60 second cooldown. + // Bottled Honey gives the Honey buff + if (item.type == ItemID.BottledHoney) + EditTooltipByName("HealLife", (line) => line.text += "\nGrants the Honey buff for 2 minutes"); + + // Warmth Potion provides debuff immunities and Death Mode cold protection + if (item.type == ItemID.WarmthPotion) + { + string immunityLine = "\nMakes you immune to the Chilled, Frozen, and Glacial State debuffs"; + if (CalamityWorld.death) + immunityLine += "\nProvides cold protection in Death Mode"; + EditTooltipByNum(0, (line) => line.text += immunityLine); + } + + // Hand Warmer provides Death Mode cold protection and has a side bonus with Eskimo armor + if (item.type == ItemID.HandWarmer) + { + string extraLine = "\nProvides a regeneration boost while wearing the Eskimo armor"; + if (CalamityWorld.death) + extraLine += "\nProvides cold protection in Death Mode"; + EditTooltipByNum(0, (line) => line.text += extraLine); + } + + // Invisibility Potion provides various rogue boosts + if (item.type == ItemID.InvisibilityPotion) + EditTooltipByNum(0, (line) => line.text += "\nBoosts various rogue stats depending on held weapon"); + + // Golden Fishing Rod inherently contains High Test Fishing Line + if (item.type == ItemID.GoldenFishingRod) + EditTooltipByName("NeedsBait", (line) => line.text += "\nIts fishing line will never break"); + + // Eternity Crystal notifies the player that they can accelerate the invasion + if (item.type == ItemID.DD2ElderCrystal) + EditTooltipByNum(0, (line) => line.text += "\nOnce placed you can right click the crystal to skip waves or increase the spawn rate of the invaders"); + + // Fix a vanilla mistake in Magic Quiver's tooltip + // TODO -- in 1.4 this mistake is already corrected + if (item.type == ItemID.MagicQuiver) + EditTooltipByNum(0, (line) => line.text = line.text.Replace(" damage", " arrow damage")); + #endregion + + // Black Belt and Master Ninja Gear have guaranteed dodges on a 60 second cooldown. + #region Dodging Belt Tooltips string beltDodgeLine = "Grants the ability to dodge attacks\n" + $"The dodge has a {CalamityPlayer.BeltDodgeCooldown} second cooldown which is shared with all other dodges and reflects"; if (item.type == ItemID.BlackBelt) EditTooltipByNum(0, (line) => line.text = beltDodgeLine); if (item.type == ItemID.MasterNinjaGear) EditTooltipByNum(1, (line) => line.text = beltDodgeLine); + #endregion - // 4) Early Hardmode ore melee weapons have new on-hit effects. + // Early Hardmode ore melee weapons have new on-hit effects. #region Early Hardmode Melee Tooltips // Cobalt @@ -300,7 +348,7 @@ namespace CalamityMod.Items EditTooltipByName("Knockback", (line) => line.text += "\nInflicts Holy Flames\nDeals double damage to enemies above 75% life"); #endregion - // 5) Other melee weapon tooltips + // Other melee weapon tooltips #region Other Melee Tooltips if (item.type == ItemID.CandyCaneSword || item.type == ItemID.FruitcakeChakram) @@ -320,28 +368,13 @@ namespace CalamityMod.Items EditTooltipByName("Knockback", (line) => line.text += "\nInflicts Burning Blood on hit"); #endregion - // 6) Bottled Honey gives the Honey buff - if (item.type == ItemID.BottledHoney) - EditTooltipByName("HealLife", (line) => line.text += "\nGrants the Honey buff for 2 minutes"); - - // 7) Rod of Discord cannot be used multiple times to hurt yourself - if (item.type == ItemID.RodofDiscord) - EditTooltipByNum(0, (line) => line.text += "\nTeleportation is disabled while Chaos State is active"); - - // 8) Water removing items cannot be used in the Abyss - string noAbyssLine = "\nCannot be used in the Abyss"; - if (item.type == ItemID.SuperAbsorbantSponge) - EditTooltipByNum(0, (line) => line.text += noAbyssLine); - if (item.type == ItemID.EmptyBucket) - EditTooltipByName("Defense", (line) => line.text += noAbyssLine); - - // 9) Light pets, accessories, and other items which boost the player's Abyss light stat + // Light pets, accessories, and other items which boost the player's Abyss light stat #region Abyss Light Tooltips // +1 to Abyss light level string abyssSmallLightLine = "\nProvides a small amount of light in the abyss"; - if (item.type == ItemID.CrimsonHeart || item.type == ItemID.ShadowOrb || item.type == ItemID.MagicLantern || item.type == ItemID.JellyfishNecklace) + if (item.type == ItemID.CrimsonHeart || item.type == ItemID.ShadowOrb || item.type == ItemID.MagicLantern || item.type == ItemID.JellyfishNecklace || item.type == ItemID.MiningHelmet) EditTooltipByNum(0, (line) => line.text += abyssSmallLightLine); if (item.type == ItemID.JellyfishDivingGear) EditTooltipByNum(1, (line) => line.text += abyssSmallLightLine); @@ -349,12 +382,12 @@ namespace CalamityMod.Items // +2 to Abyss light level string abyssMediumLightLine = "\nProvides a moderate amount of light in the abyss"; - if (item.type == ItemID.FairyBell || item.type == ItemID.DD2PetGhost) - EditTooltipByNum(0, (line) => line.text += abyssMediumLightLine); - if (item.type == ItemID.ShinePotion) EditTooltipByName("BuffTime", (line) => line.text += abyssMediumLightLine); + if (item.type == ItemID.FairyBell || item.type == ItemID.DD2PetGhost) + EditTooltipByNum(0, (line) => line.text += abyssMediumLightLine); + // +3 to Abyss light level string abyssLargeLightLine = "\nProvides a large amount of light in the abyss"; @@ -362,240 +395,78 @@ namespace CalamityMod.Items EditTooltipByNum(0, (line) => line.text += abyssLargeLightLine); if (item.type == ItemID.SuspiciousLookingTentacle) EditTooltipByNum(1, (line) => line.text += abyssLargeLightLine); - - if (item.type == ItemID.ArcticDivingGear) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - { - line2.text += "\nProvides a small amount of light in the abyss\n" + - "Moderately reduces breath loss in the abyss"; - } - } - } #endregion - if (item.type == ItemID.GillsPotion) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "BuffTime") - { - line2.text += "\nGreatly reduces breath loss in the abyss"; - } - } - } + // Accessories and other items which boost the player's ability to breathe in the Abyss + #region Abyss Breath Tooltips + + // Moderate breath boost + string abyssModerateBreathLine = "\nModerately reduces breath loss in the abyss"; + if (item.type == ItemID.DivingHelmet) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\nModerately reduces breath loss in the abyss"; - } - } - } + EditTooltipByNum(0, (line) => line.text += abyssModerateBreathLine); + if (item.type == ItemID.ArcticDivingGear) + EditTooltipByNum(1, (line) => line.text += abyssSmallLightLine + abyssModerateBreathLine); + + // Great breath boost + string abyssGreatBreathLine = "\nGreatly reduces breath loss in the abyss"; + + if (item.type == ItemID.GillsPotion) + EditTooltipByName("BuffTime", (line) => line.text += abyssGreatBreathLine); + if (item.type == ItemID.NeptunesShell || item.type == ItemID.MoonShell) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\nGreatly reduces breath loss in the abyss"; - } - } - } + EditTooltipByNum(0, (line) => line.text += abyssGreatBreathLine); if (item.type == ItemID.CelestialShell) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - { - line2.text += "\nGreatly reduces breath loss in the abyss"; - } - } - } - if (item.type == ItemID.WarmthPotion) - { - if (CalamityWorld.death) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\nMakes you immune to the Chilled, Frozen, and Glacial State debuffs\n" + - "Provides cold protection in Death Mode"; - } - } - } - else - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\nMakes you immune to the Chilled, Frozen, and Glacial State debuffs"; - } - } - } - } - if (item.type == ItemID.FlaskofVenom) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Melee and rogue attacks inflict Venom on enemies"; - } - } - } + EditTooltipByNum(1, (line) => line.text += abyssModerateBreathLine); + #endregion + + // Flasks apply to Rogue weapons + #region Rogue Flask Tooltips if (item.type == ItemID.FlaskofCursedFlames) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Melee and rogue attacks inflict enemies with cursed flames"; - } - } - } + EditTooltipByNum(0, (line) => line.text += "\nRogue attacks inflict enemies with cursed flames"); if (item.type == ItemID.FlaskofFire) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Melee and rogue attacks set enemies on fire"; - } - } - } + EditTooltipByNum(0, (line) => line.text += "\nRogue attacks set enemies on fire"); if (item.type == ItemID.FlaskofGold) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Melee and rogue attacks make enemies drop more gold"; - } - } - } + EditTooltipByNum(0, (line) => line.text += "\nRogue attacks make enemies drop more gold"); if (item.type == ItemID.FlaskofIchor) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Melee and rogue attacks decrease enemy defense"; - } - } - } + EditTooltipByNum(0, (line) => line.text += "\nRogue attacks decrease enemy defense"); if (item.type == ItemID.FlaskofNanites) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Melee and rogue attacks confuse enemies"; - } - } - } + EditTooltipByNum(0, (line) => line.text += "\nRogue attacks confuse enemies"); + // party flask is unique because it affects ALL projectiles in Calamity, not just "also rogue ones" if (item.type == ItemID.FlaskofParty) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "All attacks cause confetti to appear"; - } - } - } + EditTooltipByNum(0, (line) => line.text = "All attacks cause confetti to appear"); if (item.type == ItemID.FlaskofPoison) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Melee and rogue attacks poison enemies"; - } - } - } + EditTooltipByNum(0, (line) => line.text += "\nRogue attacks poison enemies"); + if (item.type == ItemID.FlaskofVenom) + EditTooltipByNum(0, (line) => line.text += "\nRogue attacks inflict Venom on enemies"); + #endregion + + // Rebalances to vanilla item stats + #region Vanilla Item Rebalance Tooltips + + // Worm Scarf only gives 10% DR instead of 17% if (item.type == ItemID.WormScarf) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Reduces damage taken by 10%"; - } - } - } + EditTooltipByNum(0, (line) => line.text = line.text = line.text.Replace("17%", "10%")); + if (item.type == ItemID.TitanGlove) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\n10% increased true melee damage"; - } - } - } - if (item.type == ItemID.PowerGlove) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - { - line2.text += "\n10% increased true melee damage"; - } - } - } - if (item.type == ItemID.MechanicalGlove) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - { - line2.text += "\n10% increased true melee damage"; - } - } - } + EditTooltipByNum(0, (line) => line.text += "\n10% increased true melee damage"); + if (item.type == ItemID.PowerGlove || item.type == ItemID.MechanicalGlove) + EditTooltipByNum(1, (line) => line.text += "\n10% increased true melee damage"); if (item.type == ItemID.FireGauntlet) { + string extraLine = "\n10% increased true melee damage"; if (CalamityWorld.death) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - { - line2.text = "14% increased melee damage and speed\n" + - "10% increased true melee damage\n" + - "Provides heat and cold protection in Death Mode"; - } - } - } - else - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - { - line2.text = "14% increased melee damage and speed\n" + - "10% increased true melee damage"; - } - } - } + extraLine += "\nProvides heat and cold protection in Death Mode"; + EditTooltipByNum(1, (line) => line.text = line.text.Replace("12%", "14%") + extraLine); } + + // Spectre Hood's lifesteal is heavily nerfed, so it only reduces magic damage by 20% instead of 40% if (item.type == ItemID.SpectreHood) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "20% decreased magic damage"; - } - } - } + EditTooltipByNum(0, (line) => line.text = line.text.Replace("40%", "20%")); + #endregion + + // Items which provide immunity to either heat or cold in Death Mode + #region Death Mode Environmental Immunity Tooltips if (item.type == ItemID.ObsidianSkinPotion) { string heatImmunity = CalamityWorld.death ? "\nProvides heat protection in Death Mode" : ""; @@ -652,34 +523,16 @@ namespace CalamityMod.Items } } } - if (item.type == ItemID.InvisibilityPotion) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\nBoosts certain stats when holding certain types of rogue weapons"; - } - } - } - if (item.type == ItemID.GoldenFishingRod) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "NeedsBait") - { - line2.text = "Requires bait to catch fish\n" + - "The line will never break"; - } - } - } + #endregion + + // Add mentions of what Calamity ores vanilla pickaxes can mine + #region Pickaxe New Ore Tooltips if (item.type == ItemID.Picksaw) { foreach (TooltipLine line2 in tooltips) { if (line2.mod == "Terraria" && line2.Name == "Tooltip0") { - // I'm leaving this intentionally ambiguous so that people have to search for Scoria Ore line2.text = "Capable of mining Lihzahrd Bricks and Scoria Ore"; } } @@ -728,22 +581,10 @@ namespace CalamityMod.Items } } } + #endregion - if (Main.player[Main.myPlayer].Calamity().trueMeleeDamage > 0D) - { - if (item.melee && item.damage > 0) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Damage") - { - line2.text += " : " + string.Concat((int)(Main.player[Main.myPlayer].Calamity().actualMeleeDamageStat * item.damage * - (1D + Main.player[Main.myPlayer].Calamity().trueMeleeDamage) + 5E-06f)) + " true melee damage"; - } - } - } - } - + // Rebalances and information about vanilla set bonuses + #region Vanilla Set Bonus Tooltips if (item.type == ItemID.MeteorHelmet || item.type == ItemID.MeteorSuit || item.type == ItemID.MeteorLeggings) { foreach (TooltipLine line2 in tooltips) @@ -974,42 +815,10 @@ Grants immunity to fire blocks, and temporary immunity to lava"; } } } - if (item.type == ItemID.DD2ElderCrystal) - tooltips.FirstOrDefault(line => line.mod == "Terraria" && line.Name == "Tooltip0").text += "\nOnce placed you can right click the crystal to skip waves or increase the spawn rate of the invaders"; + #endregion - if (item.type == ItemID.MagicQuiver) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Increases arrow damage by 10% and greatly increases arrow speed"; - } - } - } - if (item.type == ItemID.MiningHelmet) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Provides light when worn\n" + - "Provides a small amount of light in the Abyss"; - } - } - } - if (item.type == ItemID.HandWarmer) - { - string coldImmunity = CalamityWorld.death ? "\nProvides cold protection in Death Mode" : ""; - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Provides immunity to chilling and freezing effects\n" + - "Provides a regeneration boost while wearing the Eskimo armor" + coldImmunity; - } - } - } + // Provide the full, raw stats of every vanilla set of wings + #region Wing Stat Tooltips if (item.type == ItemID.AngelWings) { foreach (TooltipLine line2 in tooltips) @@ -1452,6 +1261,9 @@ Grants immunity to fire blocks, and temporary immunity to lava"; } } } + #endregion + + #region Grappling Hook Stat Tooltips if (item.type == ItemID.GrapplingHook) { foreach (TooltipLine line2 in tooltips) @@ -1777,6 +1589,9 @@ Grants immunity to fire blocks, and temporary immunity to lava"; } } } + #endregion + + #region Accessory Prefix Rebalance Tooltips if (item.accessory) { if (item.prefix == PrefixID.Brisk) @@ -1902,6 +1717,34 @@ Grants immunity to fire blocks, and temporary immunity to lava"; } } } + #endregion + } + #endregion + + #region True Melee Damage Tooltip + private void TrueMeleeDamageTooltip(Item item, IList tooltips) + { + TooltipLine line = tooltips.FirstOrDefault((l) => l.mod == "Terraria" && l.Name == "Damage"); + + // If there somehow isn't a damage tooltip line, do not try to perform any edits. + if (line is null) + return; + + // Start with the existing line of melee damage. + StringBuilder sb = new StringBuilder(64); + sb.Append(line.text).Append(" : "); + + Player p = Main.LocalPlayer; + float itemCurrentDamage = item.damage * p.MeleeDamage(); + double trueMeleeBoost = 1D + p.Calamity().trueMeleeDamage; + double imprecisionRoundingCorrection = 5E-06D; + int damageToDisplay = (int)(itemCurrentDamage * trueMeleeBoost + imprecisionRoundingCorrection); + sb.Append(damageToDisplay); + + // These two pieces are split apart for ease of translation + sb.Append(' '); + sb.Append("true melee damage"); + line.text = sb.ToString(); } #endregion @@ -1922,5 +1765,29 @@ Grants immunity to fire blocks, and temporary immunity to lava"; } } #endregion + + #region Fargo Biome Fountain Tooltip + private void FargoFountainTooltip(Item item, IList tooltips) + { + if (CalamityMod.Instance.fargos is null) + return; + + if (item.type == ModContent.ItemType()) + { + TooltipLine line = new TooltipLine(mod, "FargoFountain", "Forces surrounding biome state to Sunken Sea upon activation"); + tooltips.Add(line); + } + if (item.type == ModContent.ItemType()) + { + TooltipLine line = new TooltipLine(mod, "FargoFountain", "Forces surrounding biome state to Sulphurous Sea upon activation"); + tooltips.Add(line); + } + if (item.type == ModContent.ItemType()) + { + TooltipLine line = new TooltipLine(mod, "FargoFountain", "Forces surrounding biome state to Astral upon activation"); + tooltips.Add(line); + } + } + #endregion } } diff --git a/Utilities/ItemUtils.cs b/Utilities/ItemUtils.cs index 40a3f708f6..014fe00f1f 100644 --- a/Utilities/ItemUtils.cs +++ b/Utilities/ItemUtils.cs @@ -25,6 +25,10 @@ namespace CalamityMod // The rainbow rarity has an ever-shifting color, not a stored constant internal const int DraedonRustRarityValue = 33; internal static readonly Color DraedonRustRarityColor = new Color(204, 71, 35); + // The donator rarity isn't technically a rarity, but is a constant color used in tooltips + internal static readonly Color DonatorItemColor = new Color(139, 0, 0); + // The Challenge Drop rarity isn't technically a rarity, but is a constant color used in tooltips + internal static readonly Color ChallengeDropColor = new Color(255, 140, 0); public static readonly CalamityRarity[] postMLRarities = { From 9219fccde35bd6d9094e15ff635b71343aa2bbaf Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sun, 11 Apr 2021 22:50:25 -0400 Subject: [PATCH 26/32] Ongoing tooltip work. Everything but grapple hooks is done. --- Items/CalamityGlobalItemTooltip.cs | 937 +++++++---------------------- 1 file changed, 215 insertions(+), 722 deletions(-) diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index fd5e298fb2..1bef8abfe3 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -465,802 +465,295 @@ namespace CalamityMod.Items EditTooltipByNum(0, (line) => line.text = line.text.Replace("40%", "20%")); #endregion - // Items which provide immunity to either heat or cold in Death Mode - #region Death Mode Environmental Immunity Tooltips + // Items which provide immunity to either heat or cold in Death Mode, or interact with Lethal Lava + #region Lava and Death Mode Environmental Immunity Tooltips + string heatProtectionLine = "\nProvides heat protection in Death Mode"; + string bothProtectionLine = "\nProvides heat and cold protection in Death Mode"; + if (item.type == ItemID.ObsidianSkinPotion) { - string heatImmunity = CalamityWorld.death ? "\nProvides heat protection in Death Mode" : ""; - foreach (TooltipLine line2 in tooltips) + // If Lethal Lava is enabled, Obsidian Skin Potions work very differently. + if (CalamityConfig.Instance.LethalLava) { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Provides immunity to direct damage from touching lava\n" + - "Provides temporary immunity to lava burn damage\n" + - "Greatly increases lava immunity time regeneration\n" + - "Reduces lava burn damage" + heatImmunity; - } + string lethalLavaReplacement = "Provides immunity to direct damage from touching lava\n" + + "Provides temporary immunity to lava burn damage\n" + + "Greatly increases the speed at which lava immunity recharges\n" + + "Reduces lava burn damage"; + if (CalamityWorld.death) + lethalLavaReplacement += heatProtectionLine; + EditTooltipByNum(0, (line) => line.text = lethalLavaReplacement); } + + // Otherwise, changes are only made on Death Mode, where heat immunity is mentioned. + else if (CalamityWorld.death) + EditTooltipByNum(0, (line) => line.text += heatProtectionLine); } + if (item.type == ItemID.ObsidianRose) { - string heatImmunity = CalamityWorld.death ? "\nProvides heat protection in Death Mode" : ""; - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Reduced direct damage from touching lava\n" + - "Greatly reduces lava burn damage" + heatImmunity; - } - } + StringBuilder sb = new StringBuilder(128); + // If Lethal Lava is enabled, Obsidian Rose reduces the damage from the debuff. + if (CalamityConfig.Instance.LethalLava) + sb.Append("\nGreatly reduces lava burn damage"); + if (CalamityWorld.death) + sb.Append(heatProtectionLine); + EditTooltipByNum(0, (line) => line.text += sb.ToString()); } - if (item.type == ItemID.MagmaStone && CalamityWorld.death) + + if (CalamityWorld.death) { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\nProvides heat and cold protection in Death Mode"; - } - } - } - if (item.type == ItemID.LavaCharm && CalamityWorld.death) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\nProvides heat protection in Death Mode"; - } - } - } - if (item.type == ItemID.LavaWaders && CalamityWorld.death) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - { - line2.text += "\nProvides heat protection in Death Mode"; - } - } + if (item.type == ItemID.MagmaStone) + EditTooltipByNum(0, (line) => line.text += bothProtectionLine); + if (item.type == ItemID.LavaCharm) + EditTooltipByNum(0, (line) => line.text += heatProtectionLine); + if (item.type == ItemID.LavaWaders) + EditTooltipByNum(1, (line) => line.text += heatProtectionLine); + if (item.type == ItemID.FrostHelmet || item.type == ItemID.FrostBreastplate || item.type == ItemID.FrostLeggings) + EditTooltipByName("SetBonus", (line) => line.text += bothProtectionLine); } #endregion // Add mentions of what Calamity ores vanilla pickaxes can mine #region Pickaxe New Ore Tooltips if (item.type == ItemID.Picksaw) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Capable of mining Lihzahrd Bricks and Scoria Ore"; - } - } - } - if (item.type == ItemID.SolarFlarePickaxe) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Material") - { - line2.text = "Material\n" + - "Can mine Uelibloom Ore"; - } - } - } - if (item.type == ItemID.VortexPickaxe) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Material") - { - line2.text = "Material\n" + - "Can mine Uelibloom Ore"; - } - } - } - if (item.type == ItemID.NebulaPickaxe) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Material") - { - line2.text = "Material\n" + - "Can mine Uelibloom Ore"; - } - } - } - if (item.type == ItemID.StardustPickaxe) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Material") - { - line2.text = "Material\n" + - "Can mine Uelibloom Ore"; - } - } - } + EditTooltipByNum(0, (line) => line.text += "\nCan mine Scoria Ore"); + + if (item.type == ItemID.SolarFlarePickaxe || item.type == ItemID.VortexPickaxe || item.type == ItemID.NebulaPickaxe || item.type == ItemID.StardustPickaxe) + EditTooltipByName("Material", (line) => line.text += "\nCan mine Uelibloom Ore"); #endregion // Rebalances and information about vanilla set bonuses #region Vanilla Set Bonus Tooltips - if (item.type == ItemID.MeteorHelmet || item.type == ItemID.MeteorSuit || item.type == ItemID.MeteorLeggings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = "Set Bonus: Reduces the mana cost of the Space Gun by 50%"; - } - } - } + + string MiningSpeedString(int percent) => $"\n{percent}% increased mining speed"; + + // Copper if (item.type == ItemID.CopperHelmet || item.type == ItemID.CopperChainmail || item.type == ItemID.CopperGreaves) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = "Set Bonus: +2 defense and 15% increased mining speed"; - } - } - } + EditTooltipByName("SetBonus", (line) => line.text += MiningSpeedString(15)); + + // Tin if (item.type == ItemID.TinHelmet || item.type == ItemID.TinChainmail || item.type == ItemID.TinGreaves) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = "Set Bonus: +2 defense and 10% increased mining speed"; - } - } - } + EditTooltipByName("SetBonus", (line) => line.text += MiningSpeedString(10)); + + // Iron if (item.type == ItemID.AncientIronHelmet || item.type == ItemID.IronHelmet || item.type == ItemID.IronChainmail || item.type == ItemID.IronGreaves) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = "Set Bonus: +2 defense and 25% increased mining speed"; - } - } - } + EditTooltipByName("SetBonus", (line) => line.text += MiningSpeedString(25)); + + // Lead if (item.type == ItemID.LeadHelmet || item.type == ItemID.LeadChainmail || item.type == ItemID.LeadGreaves) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = "Set Bonus: +3 defense and 20% increased mining speed"; - } - } - } + EditTooltipByName("SetBonus", (line) => line.text += MiningSpeedString(20)); + + // Silver if (item.type == ItemID.SilverHelmet || item.type == ItemID.SilverChainmail || item.type == ItemID.SilverGreaves) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = "Set Bonus: +3 defense and 35% increased mining speed"; - } - } - } + EditTooltipByName("SetBonus", (line) => line.text += MiningSpeedString(35)); + + // Tungsten if (item.type == ItemID.TungstenHelmet || item.type == ItemID.TungstenChainmail || item.type == ItemID.TungstenGreaves) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = "Set Bonus: +3 defense and 30% increased mining speed"; - } - } - } + EditTooltipByName("SetBonus", (line) => line.text += MiningSpeedString(30)); + + // Gold if (item.type == ItemID.AncientGoldHelmet || item.type == ItemID.GoldHelmet || item.type == ItemID.GoldChainmail || item.type == ItemID.GoldGreaves) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = "Set Bonus: +3 defense and 45% increased mining speed"; - } - } - } + EditTooltipByName("SetBonus", (line) => line.text += MiningSpeedString(45)); + + // Platinum if (item.type == ItemID.PlatinumHelmet || item.type == ItemID.PlatinumChainmail || item.type == ItemID.PlatinumGreaves) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = "Set Bonus: +4 defense and 40% increased mining speed"; - } - } - } - if (item.type == ItemID.AncientBattleArmorHat || item.type == ItemID.AncientBattleArmorShirt || item.type == ItemID.AncientBattleArmorPants) - { - if (!Main.player[Main.myPlayer].Calamity().forbiddenCirclet) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text += "\nThe minion damage nerf is reduced while wielding magic weapons"; - } - } - } - } - if (item.type == ItemID.StardustBreastplate || item.type == ItemID.StardustLeggings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Increases your max number of minions"; - } - } - } - if (item.type == ItemID.StardustHelmet || item.type == ItemID.StardustBreastplate || item.type == ItemID.StardustLeggings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text += "\nIncreases your max number of minions by 2"; - } - } - } + EditTooltipByName("SetBonus", (line) => line.text += MiningSpeedString(40)); + + // Gladiator if (item.type == ItemID.GladiatorHelmet) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Defense") - { - line2.text = "3 defense\n" + - "3% increased rogue damage"; - } - } - } + EditTooltipByName("Defense", (line) => line.text += "\n3% increased rogue damage"); if (item.type == ItemID.GladiatorBreastplate) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Defense") - { - line2.text = "5 defense\n" + - "3% increased rogue critical strike chance"; - } - } - } + EditTooltipByName("Defense", (line) => line.text += "\n3% increased rogue critical strike chance"); if (item.type == ItemID.GladiatorLeggings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Defense") - { - line2.text = "4 defense\n" + - "3% increased rogue velocity"; - } - } - } + EditTooltipByName("Defense", (line) => line.text += "\n3% increased rogue velocity"); + + // Obsidian if (item.type == ItemID.ObsidianHelm) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Defense") - { - line2.text = "4 defense\n" + - "3% increased rogue damage"; - } - } - } + EditTooltipByName("Defense", (line) => line.text += "\n3% increased rogue damage"); if (item.type == ItemID.ObsidianShirt) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Defense") - { - line2.text = "5 defense\n" + - "3% increased rogue critical strike chance"; - } - } - } + EditTooltipByName("Defense", (line) => line.text += "\n3% increased rogue critical strike chance"); if (item.type == ItemID.ObsidianPants) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Defense") - { - line2.text = "4 defense\n" + - "3% increased rogue velocity"; - } - } - } + EditTooltipByName("Defense", (line) => line.text += "\n3% increased rogue velocity"); + + // Meteor Armor only makes space gun cost 50% instead of zero mana + if (item.type == ItemID.MeteorHelmet || item.type == ItemID.MeteorSuit || item.type == ItemID.MeteorLeggings) + EditTooltipByName("SetBonus", (line) => line.text = line.text.Replace("0", "50%")); + + // Molten if (item.type == ItemID.MoltenHelmet || item.type == ItemID.MoltenBreastplate || item.type == ItemID.MoltenGreaves) { + string extraLine = "\n20% extra true melee damage\nGrants immunity to fire blocks and temporary immunity to lava"; if (CalamityWorld.death) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = @"Set Bonus: 17% extra melee damage -20% extra true melee damage -Grants immunity to fire blocks, and temporary immunity to lava -Provides heat and cold protection in Death Mode"; - } - } - } - else - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = @"Set Bonus: 17% extra melee damage -20% extra true melee damage -Grants immunity to fire blocks, and temporary immunity to lava"; - } - } - } - } - if (item.type == ItemID.FrostHelmet || item.type == ItemID.FrostBreastplate || item.type == ItemID.FrostLeggings) - { - if (CalamityWorld.death) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text += "\nProvides heat and cold protection in Death Mode"; - } - } - } + extraLine += bothProtectionLine; + EditTooltipByName("SetBonus", (line) => line.text += extraLine); } + + // Forbidden (UNLESS you are wearing the Circlet, which is Summon/Rogue and does not get this line) + if (item.type == ItemID.AncientBattleArmorHat || item.type == ItemID.AncientBattleArmorShirt || item.type == ItemID.AncientBattleArmorPants + && !Main.LocalPlayer.Calamity().forbiddenCirclet) + EditTooltipByName("SetBonus", (line) => line.text += "\nThe minion damage nerf is reduced while wielding magic weapons"); + + // Stardust + // 1) Chest and Legs only give 1 minion slot each instead of 2 each. + if (item.type == ItemID.StardustBreastplate || item.type == ItemID.StardustLeggings) + EditTooltipByNum(0, (line) => line.text = line.text.Replace('2', '1')); + // 2) Set bonus gives 2 minions instead of 0. + if (item.type == ItemID.StardustHelmet || item.type == ItemID.StardustBreastplate || item.type == ItemID.StardustLeggings) + EditTooltipByName("SetBonus", (line) => line.text += "\nIncreases your max number of minions by 2"); #endregion // Provide the full, raw stats of every vanilla set of wings #region Wing Stat Tooltips + + // This function produces a "stat sheet" for a pair of wings from the raw stats. + // For "vertical speed", 0 = Average, 1 = Good, 2 = Great. + string[] vertSpeedStrings = new string[] { "Average vertical speed", "Good vertical speed", "Great vertical speed" }; + string WingStatsTooltip(float hSpeed, float accelMult, int vertSpeed, int flightTime, string extraTooltip = null) + { + StringBuilder sb = new StringBuilder(512); + sb.Append('\n'); + sb.Append($"Horizontal speed: {hSpeed:N2}\n"); + sb.Append($"Acceleration multiplier: {accelMult:N1}\n"); + sb.Append(vertSpeedStrings[vertSpeed]); + sb.Append('\n'); + sb.Append($"Flight time: {flightTime}"); + if (extraTooltip != null) + { + sb.Append('\n'); + sb.Append(extraTooltip); + } + return sb.ToString(); + } + if (item.type == ItemID.AngelWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 6.25\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 100\n" + - "+20 max life, +10 defense and +2 life regen"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6.25f, 1f, 0, 100, + "+20 max life, +10 defense and +2 life regen")); + if (item.type == ItemID.DemonWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 6.25\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 100\n" + - "5% increased damage and critical strike chance"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6.25f, 1f, 0, 100, + "5% increased damage and critical strike chance")); + if (item.type == ItemID.Jetpack) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 6.5\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 115"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6.5f, 1f, 0, 115)); + if (item.type == ItemID.ButterflyWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 6.75\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 130\n" + - "+20 max mana, 5% decreased mana usage,\n" + - "5% increased magic damage and magic critical strike chance"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6.75f, 1f, 0, 130, + "+20 max mana, 5% decreased mana usage,\n" + + "5% increased magic damage and magic critical strike chance")); + if (item.type == ItemID.FairyWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 6.75\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 130\n" + - "+60 max life"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6.75f, 1f, 0, 130, "+60 max life")); + if (item.type == ItemID.BeeWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 6.75\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 130\n" + - "Honey buff at all times"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6.75f, 1f, 0, 130, "Permanently gives the Honey buff")); + if (item.type == ItemID.HarpyWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 7\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 140\n" + - "20% increased movement speed\n" + - "Most attacks have a chance to fire a feather on swing if Harpy Ring or Angel Treads are equipped"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7f, 1f, 0, 140, + "20% increased movement speed\n" + + "Most attacks have a chance to fire a feather on swing if Harpy Ring or Angel Treads are equipped")); + if (item.type == ItemID.BoneWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 7\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 140\n" + - "10% increased movement speed, ranged damage and critical strike chance\n" + - "and +30 defense while wearing the Necro Armor"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7f, 1f, 0, 140, + "10% increased movement speed, ranged damage and critical strike chance\n" + + "and +30 defense while wearing the Necro Armor")); + if (item.type == ItemID.FlameWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 7.5\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 160\n" + - "5% increased melee damage and critical strike chance"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7.5f, 1f, 0, 160, + "5% increased melee damage and critical strike chance")); + if (item.type == ItemID.FrozenWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 7.5\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 160\n" + - "2% increased melee and ranged damage\n" + - "and 1% increased melee and ranged critical strike chance\n" + - "while wearing the Frost Armor"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7.5f, 1f, 0, 160, + "2% increased melee and ranged damage\n" + + "and 1% increased melee and ranged critical strike chance\n" + + "while wearing the Frost Armor")); + if (item.type == ItemID.GhostWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 7.5\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 160\n" + - "+10 defense and 5% increased damage reduction while wearing the Spectre Armor and Hood\n" + - "5% increased magic damage and critical strike chance while wearing the Spectre Armor and Mask"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7.5f, 1f, 0, 160, + "+10 defense and 5% increased damage reduction while wearing the Spectre Hood set\n" + + "5% increased magic damage and critical strike chance while wearing the Spectre Mask set")); + if (item.type == ItemID.BeetleWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 7.5\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 160\n" + - "+10 defense and 5% increased damage reduction while wearing the Beetle Armor and Shell\n" + - "5% increased melee damage and critical strike chance while wearing the Beetle Armor and Scale Mail"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7.5f, 1f, 0, 160, + "+10 defense and 5% increased damage reduction while wearing the Beetle Shell set\n" + + "5% increased melee damage and critical strike chance while wearing the Beetle Scale Mail set")); + if (item.type == ItemID.FinWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 0\n" + - "Acceleration multiplier: 0\n" + - "Average vertical speed\n" + - "Flight time: 100\n" + - "Gills effect and you can move freely through liquids\n" + - "You fall faster while submerged in liquid\n" + - "15% increased movement speed and 18% increased jump speed"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(0f, 0f, 0, 100, + "Gills effect and you can move freely through liquids\n" + + "You fall faster while submerged in liquid\n" + + "15% increased movement speed and 18% increased jump speed")); + if (item.type == ItemID.FishronWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 8\n" + - "Acceleration multiplier: 2\n" + - "Good vertical speed\n" + - "Flight time: 180"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(8f, 2f, 1, 180)); + if (item.type == ItemID.SteampunkWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 7.75\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 180\n" + - "+8 defense, 10% increased movement speed,\n" + - "4% increased damage, and 2% increased critical strike chance"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7.75f, 1f, 0, 180, + "+8 defense, 10% increased movement speed,\n" + + "4% increased damage, and 2% increased critical strike chance")); + if (item.type == ItemID.LeafWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 6.75\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 160\n" + - "+5 defense, 5% increased damage reduction,\n" + - "and the Dryad's permanent blessing while wearing the Tiki Armor"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6.75f, 1f, 0, 160, + "+5 defense, 5% increased damage reduction,\n" + + "and permanent Dryad's Blessing while wearing the Tiki Armor")); + if (item.type == ItemID.BatWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 0\n" + - "Acceleration multiplier: 0\n" + - "Average vertical speed\n" + - "Flight time: 140\n" + - "At night or during an eclipse, you will gain the following boosts:\n" + - "10% increased movement speed, 10% increased jump speed,\n" + - "7% increased damage and 3% increased critical strike chance"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(0f, 0f, 0, 140, + "At night or during an eclipse, you will gain the following boosts:\n" + + "10% increased movement speed, 10% increased jump speed,\n" + + "7% increased damage and 3% increased critical strike chance")); + + // All developer wings have identical stats and no special effects if (item.type == ItemID.Yoraiz0rWings || item.type == ItemID.JimsWings || item.type == ItemID.SkiphsWings || item.type == ItemID.LokisWings || item.type == ItemID.ArkhalisWings || item.type == ItemID.LeinforsWings || item.type == ItemID.BejeweledValkyrieWing || item.type == ItemID.RedsWings || item.type == ItemID.DTownsWings || item.type == ItemID.WillsWings || item.type == ItemID.CrownosWings || item.type == ItemID.CenxsWings) { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "'Great for impersonating devs!'\n" + - "Horizontal speed: 7\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 150"; - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7f, 1f, 0, 150)); } + if (item.type == ItemID.TatteredFairyWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 7.5\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 180\n" + - "5% increased damage and critical strike chance"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7.5f, 1f, 0, 180, + "5% increased damage and critical strike chance")); + if (item.type == ItemID.SpookyWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 7.5\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 180\n" + - "Increased minion knockback and 5% increased minion damage while wearing the Spooky Armor"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7.5f, 1f, 0, 180, + "Increased minion knockback and 5% increased minion damage while wearing the Spooky Armor")); + if (item.type == ItemID.Hoverboard) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - { - line2.text = "Hold DOWN and JUMP to hover\n" + - "Horizontal speed: 6.25\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 170\n" + - "10% increased damage to bows, guns, rocket launchers, and flamethrowers while wearing the Shroomite Armor\n" + - "Boosted weapon type depends on the Shroomite Helmet worn"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6.25f, 1f, 0, 170, + "10% increased weapon-type damage while wearing the Shroomite Armor\n" + + "The weapon type boosted matches which Shroomite helmet is worn")); + if (item.type == ItemID.FestiveWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 7.5\n" + - "Acceleration multiplier: 1\n" + - "Average vertical speed\n" + - "Flight time: 170\n" + - "+40 max life\n" + - "Ornaments rain down as you fly"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7.5f, 1f, 0, 170, + "+40 max life\nOrnaments rain down as you fly")); + if (item.type == ItemID.MothronWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 0\n" + - "Acceleration multiplier: 0\n" + - "Average vertical speed\n" + - "Flight time: 160\n" + - "+5 defense, 5% increased damage,\n" + - "10% increased movement speed and 12% increased jump speed"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(0f, 0f, 0, 160, + "+5 defense, 5% increased damage,\n" + + "10% increased movement speed and 12% increased jump speed")); + if (item.type == ItemID.WingsSolar) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 9\n" + - "Acceleration multiplier: 2.5\n" + - "Great vertical speed\n" + - "Flight time: 180\n" + - "7% increased melee damage and 3% increased melee critical strike chance\n" + - "while wearing the Solar Flare Armor"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(9f, 2.5f, 2, 180, + "7% increased melee damage and 3% increased melee critical strike chance\n" + + "while wearing the Solar Flare Armor")); + if (item.type == ItemID.WingsStardust) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Horizontal speed: 9\n" + - "Acceleration multiplier: 2.5\n" + - "Great vertical speed\n" + - "Flight time: 180\n" + - "+1 max minion and 5% increased minion damage while wearing the Stardust Armor"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(9f, 2.5f, 2, 180, + "+1 max minion and 5% increased minion damage while wearing the Stardust Armor")); + if (item.type == ItemID.WingsVortex) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Hold DOWN and JUMP to hover\n" + - "Horizontal speed: 6.5\n" + - "Acceleration multiplier: 1.5\n" + - "Good vertical speed\n" + - "Flight time: 160\n" + - "3% increased ranged damage and 7% increased ranged critical strike chance\n" + - "while wearing the Vortex Armor"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6.5f, 1.5f, 1, 160, + "3% increased ranged damage and 7% increased ranged critical strike chance\n" + + "while wearing the Vortex Armor")); + if (item.type == ItemID.WingsNebula) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Allows flight and slow fall\n" + - "Hold DOWN and JUMP to hover\n" + - "Horizontal speed: 6.5\n" + - "Acceleration multiplier: 1.5\n" + - "Good vertical speed\n" + - "Flight time: 160\n" + - "+20 max mana, 5% increased magic damage and critical strike chance,\n" + - "and 5% decreased mana usage while wearing the Nebula Armor"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6.5f, 1.5f, 1, 160, + "+20 max mana, 5% increased magic damage and critical strike chance,\n" + + "and 5% decreased mana usage while wearing the Nebula Armor")); + if (item.type == ItemID.BetsyWings) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Allows flight and slow fall\n" + - "Hold DOWN and JUMP to hover\n" + - "Horizontal speed: 6\n" + - "Acceleration multiplier: 2.5\n" + - "Good vertical speed\n" + - "Flight time: 150"; - } - } - } + EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6f, 2.5f, 1, 150)); #endregion #region Grappling Hook Stat Tooltips From 0c617164082f7cb93d70aa9f61511a488ef15857 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sun, 11 Apr 2021 23:30:06 -0400 Subject: [PATCH 27/32] Grappling hook tooltips improved. --- Items/CalamityGlobalItemTooltip.cs | 344 ++++------------------------- 1 file changed, 42 insertions(+), 302 deletions(-) diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index 1bef8abfe3..23f2b1cd34 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -756,332 +756,72 @@ namespace CalamityMod.Items EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6f, 2.5f, 1, 150)); #endregion + // Provide the full, raw stats of every vanilla grappling hook #region Grappling Hook Stat Tooltips + + // This function produces a "stat sheet" for a grappling hook from the raw stats. + string HookStatsTooltip(float reach, float launch, float pull) + { + StringBuilder sb = new StringBuilder(128); + sb.Append('\n'); + sb.Append($"Reach: {reach:N3}\n"); + sb.Append($"Launch Velocity: {launch:N2}\n"); + sb.Append($"Pull Velocity: {pull:N2}"); + return sb.ToString(); + } + + // This function is shorthand for appending a stat sheet to a grappling hook. + void AddGrappleStats(float r, float l, float p) => EditTooltipByName("Equipable", (line) => line.text += HookStatsTooltip(r, l, p)); + + // TODO -- Some of these stats are probably wrong, but finding them is so difficult I don't want to do it right now. if (item.type == ItemID.GrapplingHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 18.75\n" + - "Launch Velocity: 11.5\n" + - "Pull Velocity: 11"; - } - } - } + AddGrappleStats(18.75f, 11.5f, 11f); if (item.type == ItemID.AmethystHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 18.75\n" + - "Launch Velocity: 10\n" + - "Pull Velocity: 11"; - } - } - } + AddGrappleStats(18.75f, 10f, 11f); if (item.type == ItemID.TopazHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 20.625\n" + - "Launch Velocity: 10.5\n" + - "Pull Velocity: 11.75"; - } - } - } + AddGrappleStats(20.625f, 10.5f, 11.75f); if (item.type == ItemID.SapphireHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 22.5\n" + - "Launch Velocity: 11\n" + - "Pull Velocity: 12.5"; - } - } - } + AddGrappleStats(22.5f, 11f, 12.5f); if (item.type == ItemID.EmeraldHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 24.375\n" + - "Launch Velocity: 11.5\n" + - "Pull Velocity: 13.25"; - } - } - } + AddGrappleStats(24.375f, 11.5f, 13.25f); if (item.type == ItemID.RubyHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 26.25\n" + - "Launch Velocity: 12\n" + - "Pull Velocity: 14"; - } - } - } + AddGrappleStats(26.25f, 12f, 14f); if (item.type == ItemID.DiamondHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 28.125\n" + - "Launch Velocity: 12.5\n" + - "Pull Velocity: 14.75"; - } - } - } + AddGrappleStats(28.125f, 12.5f, 14.75f); if (item.type == ItemID.WebSlinger) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 15.625\n" + - "Launch Velocity: 10\n" + - "Pull Velocity: 11"; - } - } - } + AddGrappleStats(15.625f, 10f, 11f); if (item.type == ItemID.SkeletronHand) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 21.875\n" + - "Launch Velocity: 15\n" + - "Pull Velocity: 11"; - } - } - } + AddGrappleStats(21.875f, 15f, 11f); if (item.type == ItemID.SlimeHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 18.75\n" + - "Launch Velocity: 13\n" + - "Pull Velocity: 11"; - } - } - } + AddGrappleStats(18.75f, 13f, 11f); if (item.type == ItemID.FishHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 25\n" + - "Launch Velocity: 13\n" + - "Pull Velocity: 11"; - } - } - } + AddGrappleStats(25f, 13f, 11f); if (item.type == ItemID.IvyWhip) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 25\n" + - "Launch Velocity: 13\n" + - "Pull Velocity: 15"; - } - } - } - if (item.type == ItemID.BatHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 31.25\n" + - "Launch Velocity: 15.5\n" + - "Pull Velocity: 20"; - } - } - } + AddGrappleStats(25f, 13f, 15f); + if (item.type == ItemID.BatHook) // TODO -- This item should be dropped by Vampires in the Eclipse. It is very overpowered. + AddGrappleStats(31.25f, 15.5f, 20f); if (item.type == ItemID.CandyCaneHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 25\n" + - "Launch Velocity: 11.5\n" + - "Pull Velocity: 11"; - } - } - } + AddGrappleStats(25f, 11.5f, 11f); if (item.type == ItemID.DualHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 27.5\n" + - "Launch Velocity: 14\n" + - "Pull Velocity: 17"; - } - } - } + AddGrappleStats(27.5f, 14f, 17f); if (item.type == ItemID.ThornHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 30\n" + - "Launch Velocity: 15\n" + - "Pull Velocity: 18"; - } - } - } + AddGrappleStats(30f, 15f, 18f); if (item.type == ItemID.WormHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 30\n" + - "Launch Velocity: 15\n" + - "Pull Velocity: 18"; - } - } - } + AddGrappleStats(30f, 15f, 18f); if (item.type == ItemID.TendonHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 30\n" + - "Launch Velocity: 15\n" + - "Pull Velocity: 18"; - } - } - } + AddGrappleStats(30f, 15f, 18f); if (item.type == ItemID.IlluminantHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 30\n" + - "Launch Velocity: 15\n" + - "Pull Velocity: 18"; - } - } - } + AddGrappleStats(30f, 15f, 18f); if (item.type == ItemID.AntiGravityHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 31.25\n" + - "Launch Velocity: 14\n" + - "Pull Velocity: 20"; - } - } - } + AddGrappleStats(31.25f, 14f, 20f); if (item.type == ItemID.SpookyHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 34.375\n" + - "Launch Velocity: 15.5\n" + - "Pull Velocity: 22"; - } - } - } + AddGrappleStats(34.375f, 15.5f, 22f); if (item.type == ItemID.ChristmasHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 34.375\n" + - "Launch Velocity: 15.5\n" + - "Pull Velocity: 17"; - } - } - } + AddGrappleStats(34.375f, 15.5f, 17f); if (item.type == ItemID.LunarHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 34.375\n" + - "Launch Velocity: 16\n" + - "Pull Velocity: 24"; - } - } - } + AddGrappleStats(34.375f, 16f, 24f); if (item.type == ItemID.StaticHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 37.5\n" + - "Launch Velocity: 16\n" + - "Pull Velocity: 24"; - } - } - } - if (item.type == ItemID.StaticHook) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Equipable") - { - line2.text = "Equipable\n" + - "Reach: 37.5\n" + - "Launch Velocity: 16\n" + - "Pull Velocity: 24"; - } - } - } + AddGrappleStats(37.5f, 16f, 0f); #endregion #region Accessory Prefix Rebalance Tooltips From ebb035aa12e55c82cedf5a58161dba5447b40fef Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Mon, 12 Apr 2021 00:26:42 -0400 Subject: [PATCH 28/32] Grapple hook stats are triple checked and include reelback speed. --- Items/CalamityGlobalItemTooltip.cs | 59 ++++++++++++++---------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index 23f2b1cd34..29a6e1d88f 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -760,68 +760,63 @@ namespace CalamityMod.Items #region Grappling Hook Stat Tooltips // This function produces a "stat sheet" for a grappling hook from the raw stats. - string HookStatsTooltip(float reach, float launch, float pull) + string HookStatsTooltip(float reach, float launch, float reel, float pull) { StringBuilder sb = new StringBuilder(128); sb.Append('\n'); - sb.Append($"Reach: {reach:N3}\n"); + sb.Append($"Reach: {reach:N3} tiles\n"); sb.Append($"Launch Velocity: {launch:N2}\n"); + sb.Append($"Reelback Velocity: {reel:N2}\n"); sb.Append($"Pull Velocity: {pull:N2}"); return sb.ToString(); } // This function is shorthand for appending a stat sheet to a grappling hook. - void AddGrappleStats(float r, float l, float p) => EditTooltipByName("Equipable", (line) => line.text += HookStatsTooltip(r, l, p)); + void AddGrappleStats(float r, float l, float e, float p) => EditTooltipByName("Equipable", (line) => line.text += HookStatsTooltip(r, l, e, p)); - // TODO -- Some of these stats are probably wrong, but finding them is so difficult I don't want to do it right now. if (item.type == ItemID.GrapplingHook) - AddGrappleStats(18.75f, 11.5f, 11f); + AddGrappleStats(18.75f, 11.5f, 11f, 11f); if (item.type == ItemID.AmethystHook) - AddGrappleStats(18.75f, 10f, 11f); + AddGrappleStats(18.75f, 10f, 11f, 11f); if (item.type == ItemID.TopazHook) - AddGrappleStats(20.625f, 10.5f, 11.75f); + AddGrappleStats(20.625f, 10.5f, 11.75f, 11f); if (item.type == ItemID.SapphireHook) - AddGrappleStats(22.5f, 11f, 12.5f); + AddGrappleStats(22.5f, 11f, 12.5f, 11f); if (item.type == ItemID.EmeraldHook) - AddGrappleStats(24.375f, 11.5f, 13.25f); + AddGrappleStats(24.375f, 11.5f, 13.25f, 11f); if (item.type == ItemID.RubyHook) - AddGrappleStats(26.25f, 12f, 14f); + AddGrappleStats(26.25f, 12f, 14f, 11f); if (item.type == ItemID.DiamondHook) - AddGrappleStats(28.125f, 12.5f, 14.75f); + AddGrappleStats(28.125f, 12.5f, 14.75f, 11f); if (item.type == ItemID.WebSlinger) - AddGrappleStats(15.625f, 10f, 11f); + AddGrappleStats(15.625f, 10f, 11f, 11f); if (item.type == ItemID.SkeletronHand) - AddGrappleStats(21.875f, 15f, 11f); + AddGrappleStats(21.875f, 15f, 11f, 11f); if (item.type == ItemID.SlimeHook) - AddGrappleStats(18.75f, 13f, 11f); + AddGrappleStats(18.75f, 13f, 11f, 11f); if (item.type == ItemID.FishHook) - AddGrappleStats(25f, 13f, 11f); + AddGrappleStats(25f, 13f, 11f, 11f); if (item.type == ItemID.IvyWhip) - AddGrappleStats(25f, 13f, 15f); + AddGrappleStats(25f, 13f, 15f, 11f); if (item.type == ItemID.BatHook) // TODO -- This item should be dropped by Vampires in the Eclipse. It is very overpowered. - AddGrappleStats(31.25f, 15.5f, 20f); + AddGrappleStats(31.25f, 15.5f, 20f, 16f); if (item.type == ItemID.CandyCaneHook) - AddGrappleStats(25f, 11.5f, 11f); + AddGrappleStats(25f, 11.5f, 11f, 11f); if (item.type == ItemID.DualHook) - AddGrappleStats(27.5f, 14f, 17f); - if (item.type == ItemID.ThornHook) - AddGrappleStats(30f, 15f, 18f); - if (item.type == ItemID.WormHook) - AddGrappleStats(30f, 15f, 18f); - if (item.type == ItemID.TendonHook) - AddGrappleStats(30f, 15f, 18f); - if (item.type == ItemID.IlluminantHook) - AddGrappleStats(30f, 15f, 18f); + AddGrappleStats(27.5f, 14f, 17f, 11f); + // these four grapple hooks are all functionally identical + if (item.type == ItemID.ThornHook || item.type == ItemID.WormHook || item.type == ItemID.TendonHook || item.type == ItemID.IlluminantHook) + AddGrappleStats(30f, 15f, 18f, 11f); if (item.type == ItemID.AntiGravityHook) - AddGrappleStats(31.25f, 14f, 20f); + AddGrappleStats(31.25f, 14f, 20f, 11f); if (item.type == ItemID.SpookyHook) - AddGrappleStats(34.375f, 15.5f, 22f); + AddGrappleStats(34.375f, 15.5f, 22f, 11f); if (item.type == ItemID.ChristmasHook) - AddGrappleStats(34.375f, 15.5f, 17f); + AddGrappleStats(34.375f, 15.5f, 17f, 11f); if (item.type == ItemID.LunarHook) - AddGrappleStats(34.375f, 16f, 24f); + AddGrappleStats(34.375f, 16f, 24f, 13f); if (item.type == ItemID.StaticHook) - AddGrappleStats(37.5f, 16f, 0f); + AddGrappleStats(37.5f, 16f, 24f, 0f); #endregion #region Accessory Prefix Rebalance Tooltips From 77db526474f33f6a33fa269344707a928d94be6c Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Mon, 12 Apr 2021 12:03:53 -0400 Subject: [PATCH 29/32] 1 - Accessory stat edit tooltips optimized. 2 - Added a helper function for the scaling defense prefixes. 3 - Further improved the wing stat sheet code. --- Items/CalamityGlobalItemTooltip.cs | 281 +++++++++-------------------- Utilities/ItemUtils.cs | 56 ++++++ 2 files changed, 146 insertions(+), 191 deletions(-) diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index 29a6e1d88f..e6b3df9f97 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -525,6 +525,7 @@ namespace CalamityMod.Items // Rebalances and information about vanilla set bonuses #region Vanilla Set Bonus Tooltips + // Turns a number into a string of increased mining speed. string MiningSpeedString(int percent) => $"\n{percent}% increased mining speed"; // Copper @@ -602,7 +603,7 @@ namespace CalamityMod.Items EditTooltipByName("SetBonus", (line) => line.text += "\nIncreases your max number of minions by 2"); #endregion - // Provide the full, raw stats of every vanilla set of wings + // Provide the full stats of every vanilla set of wings #region Wing Stat Tooltips // This function produces a "stat sheet" for a pair of wings from the raw stats. @@ -625,82 +626,70 @@ namespace CalamityMod.Items return sb.ToString(); } + // This function is shorthand for appending a stat sheet to a pair of wings. + void AddWingStats(float h, float a, int v, int f, string s = null) => EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(h, a, v, f, s)); + if (item.type == ItemID.AngelWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6.25f, 1f, 0, 100, - "+20 max life, +10 defense and +2 life regen")); + AddWingStats(6.25f, 1f, 0, 100, "+20 max life, +10 defense and +2 life regen"); if (item.type == ItemID.DemonWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6.25f, 1f, 0, 100, - "5% increased damage and critical strike chance")); + AddWingStats(6.25f, 1f, 0, 100, "5% increased damage and critical strike chance"); if (item.type == ItemID.Jetpack) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6.5f, 1f, 0, 115)); + AddWingStats(6.5f, 1f, 0, 115); if (item.type == ItemID.ButterflyWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6.75f, 1f, 0, 130, - "+20 max mana, 5% decreased mana usage,\n" - + "5% increased magic damage and magic critical strike chance")); + AddWingStats(6.75f, 1f, 0, 130, "+20 max mana, 5% decreased mana usage,\n" + + "5% increased magic damage and magic critical strike chance"); if (item.type == ItemID.FairyWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6.75f, 1f, 0, 130, "+60 max life")); + AddWingStats(6.75f, 1f, 0, 130, "+60 max life"); if (item.type == ItemID.BeeWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6.75f, 1f, 0, 130, "Permanently gives the Honey buff")); + AddWingStats(6.75f, 1f, 0, 130, "Permanently gives the Honey buff"); if (item.type == ItemID.HarpyWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7f, 1f, 0, 140, - "20% increased movement speed\n" + - "Most attacks have a chance to fire a feather on swing if Harpy Ring or Angel Treads are equipped")); + AddWingStats(7f, 1f, 0, 140, "20% increased movement speed\n" + + "With Harpy Ring or Angel Treads equipped, most attacks sometimes launch feathers"); if (item.type == ItemID.BoneWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7f, 1f, 0, 140, - "10% increased movement speed, ranged damage and critical strike chance\n" + - "and +30 defense while wearing the Necro Armor")); + AddWingStats(7f, 1f, 0, 140, "10% increased movement speed, ranged damage and critical strike chance\n" + + "and +30 defense while wearing the Necro Armor"); if (item.type == ItemID.FlameWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7.5f, 1f, 0, 160, - "5% increased melee damage and critical strike chance")); + AddWingStats(7.5f, 1f, 0, 160, "5% increased melee damage and critical strike chance"); if (item.type == ItemID.FrozenWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7.5f, 1f, 0, 160, - "2% increased melee and ranged damage\n" + + AddWingStats(7.5f, 1f, 0, 160, "2% increased melee and ranged damage\n" + "and 1% increased melee and ranged critical strike chance\n" + - "while wearing the Frost Armor")); + "while wearing the Frost Armor"); if (item.type == ItemID.GhostWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7.5f, 1f, 0, 160, - "+10 defense and 5% increased damage reduction while wearing the Spectre Hood set\n" + - "5% increased magic damage and critical strike chance while wearing the Spectre Mask set")); + AddWingStats(7.5f, 1f, 0, 160, "+10 defense and 5% increased damage reduction while wearing the Spectre Hood set\n" + + "5% increased magic damage and critical strike chance while wearing the Spectre Mask set"); if (item.type == ItemID.BeetleWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7.5f, 1f, 0, 160, - "+10 defense and 5% increased damage reduction while wearing the Beetle Shell set\n" + - "5% increased melee damage and critical strike chance while wearing the Beetle Scale Mail set")); + AddWingStats(7.5f, 1f, 0, 160, "+10 defense and 5% increased damage reduction while wearing the Beetle Shell set\n" + + "5% increased melee damage and critical strike chance while wearing the Beetle Scale Mail set"); if (item.type == ItemID.FinWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(0f, 0f, 0, 100, - "Gills effect and you can move freely through liquids\n" + + AddWingStats(0f, 0f, 0, 100, "Gills effect and you can move freely through liquids\n" + "You fall faster while submerged in liquid\n" + - "15% increased movement speed and 18% increased jump speed")); + "15% increased movement speed and 18% increased jump speed"); if (item.type == ItemID.FishronWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(8f, 2f, 1, 180)); + AddWingStats(8f, 2f, 1, 180); if (item.type == ItemID.SteampunkWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7.75f, 1f, 0, 180, - "+8 defense, 10% increased movement speed,\n" + - "4% increased damage, and 2% increased critical strike chance")); + AddWingStats(7.75f, 1f, 0, 180, "+8 defense, 10% increased movement speed,\n" + "4% increased damage, and 2% increased critical strike chance"); if (item.type == ItemID.LeafWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6.75f, 1f, 0, 160, - "+5 defense, 5% increased damage reduction,\n" + - "and permanent Dryad's Blessing while wearing the Tiki Armor")); + AddWingStats(6.75f, 1f, 0, 160, "+5 defense, 5% increased damage reduction,\n" + "and permanent Dryad's Blessing while wearing the Tiki Armor"); if (item.type == ItemID.BatWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(0f, 0f, 0, 140, - "At night or during an eclipse, you will gain the following boosts:\n" - + "10% increased movement speed, 10% increased jump speed,\n" - + "7% increased damage and 3% increased critical strike chance")); + AddWingStats(0f, 0f, 0, 140, "At night or during an eclipse, you will gain the following boosts:\n" + + "10% increased movement speed, 10% increased jump speed,\n" + + "7% increased damage and 3% increased critical strike chance"); // All developer wings have identical stats and no special effects if (item.type == ItemID.Yoraiz0rWings || item.type == ItemID.JimsWings || item.type == ItemID.SkiphsWings || @@ -708,55 +697,46 @@ namespace CalamityMod.Items item.type == ItemID.BejeweledValkyrieWing || item.type == ItemID.RedsWings || item.type == ItemID.DTownsWings || item.type == ItemID.WillsWings || item.type == ItemID.CrownosWings || item.type == ItemID.CenxsWings) { - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7f, 1f, 0, 150)); + AddWingStats(7f, 1f, 0, 150); } if (item.type == ItemID.TatteredFairyWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7.5f, 1f, 0, 180, - "5% increased damage and critical strike chance")); + AddWingStats(7.5f, 1f, 0, 180, "5% increased damage and critical strike chance"); if (item.type == ItemID.SpookyWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7.5f, 1f, 0, 180, - "Increased minion knockback and 5% increased minion damage while wearing the Spooky Armor")); + AddWingStats(7.5f, 1f, 0, 180, "Increased minion knockback and 5% increased minion damage while wearing the Spooky Armor"); if (item.type == ItemID.Hoverboard) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6.25f, 1f, 0, 170, - "10% increased weapon-type damage while wearing the Shroomite Armor\n" + - "The weapon type boosted matches which Shroomite helmet is worn")); + AddWingStats(6.25f, 1f, 0, 170, "10% increased weapon-type damage while wearing the Shroomite Armor\n" + + "The weapon type boosted matches which Shroomite helmet is worn"); if (item.type == ItemID.FestiveWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(7.5f, 1f, 0, 170, - "+40 max life\nOrnaments rain down as you fly")); + AddWingStats(7.5f, 1f, 0, 170, "+40 max life\nOrnaments rain down as you fly"); if (item.type == ItemID.MothronWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(0f, 0f, 0, 160, - "+5 defense, 5% increased damage,\n" + - "10% increased movement speed and 12% increased jump speed")); + AddWingStats(0f, 0f, 0, 160, "+5 defense, 5% increased damage,\n" + + "10% increased movement speed and 12% increased jump speed"); if (item.type == ItemID.WingsSolar) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(9f, 2.5f, 2, 180, - "7% increased melee damage and 3% increased melee critical strike chance\n" + - "while wearing the Solar Flare Armor")); + AddWingStats(9f, 2.5f, 2, 180, "7% increased melee damage and 3% increased melee critical strike chance\n" + + "while wearing the Solar Flare Armor"); if (item.type == ItemID.WingsStardust) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(9f, 2.5f, 2, 180, - "+1 max minion and 5% increased minion damage while wearing the Stardust Armor")); + AddWingStats(9f, 2.5f, 2, 180, "+1 max minion and 5% increased minion damage while wearing the Stardust Armor"); if (item.type == ItemID.WingsVortex) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6.5f, 1.5f, 1, 160, - "3% increased ranged damage and 7% increased ranged critical strike chance\n" + - "while wearing the Vortex Armor")); + AddWingStats(6.5f, 1.5f, 1, 160, "3% increased ranged damage and 7% increased ranged critical strike chance\n" + + "while wearing the Vortex Armor"); if (item.type == ItemID.WingsNebula) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6.5f, 1.5f, 1, 160, - "+20 max mana, 5% increased magic damage and critical strike chance,\n" + - "and 5% decreased mana usage while wearing the Nebula Armor")); + AddWingStats(6.5f, 1.5f, 1, 160, "+20 max mana, 5% increased magic damage and critical strike chance,\n" + + "and 5% decreased mana usage while wearing the Nebula Armor"); if (item.type == ItemID.BetsyWings) - EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(6f, 2.5f, 1, 150)); + AddWingStats(6f, 2.5f, 1, 150); #endregion - // Provide the full, raw stats of every vanilla grappling hook + // Provide the full stats of every vanilla grappling hook #region Grappling Hook Stat Tooltips // This function produces a "stat sheet" for a grappling hook from the raw stats. @@ -819,131 +799,50 @@ namespace CalamityMod.Items AddGrappleStats(37.5f, 16f, 24f, 0f); #endregion + // Beyond this point all code only applies to accessories. Skip it all if the item is not an accessory. + if (!item.accessory) + return; + + // Display the stat changes to vanilla prefixes #region Accessory Prefix Rebalance Tooltips - if (item.accessory) + + // Turns a number into a string of increased DR. + string DRString(float percent) => $"\n+{percent:N2}% damage reduction"; + + switch (item.prefix) { - if (item.prefix == PrefixID.Brisk) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "PrefixAccMoveSpeed") - line2.text = "+2% movement speed"; - } - } - if (item.prefix == PrefixID.Fleeting) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "PrefixAccMoveSpeed") - line2.text = "+4% movement speed"; - } - } - if (item.prefix == PrefixID.Hasty2) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "PrefixAccMoveSpeed") - line2.text = "+6% movement speed"; - } - } - if (item.prefix == PrefixID.Quick2) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "PrefixAccMoveSpeed") - line2.text = "+8% movement speed"; - } - } - if (item.prefix == PrefixID.Precise || item.prefix == PrefixID.Lucky) - { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "PrefixAccCritChance") - line2.text += "\n+1 armor penetration"; - } - } - if (item.prefix == PrefixID.Hard) - { - string defenseBoost = "+1 defense\n"; - if (CalamityWorld.downedDoG) - defenseBoost = "+4 defense\n"; - else if (CalamityWorld.downedProvidence || CalamityWorld.downedPolterghast) - defenseBoost = "+3 defense\n"; - else if (NPC.downedGolemBoss || NPC.downedMoonlord) - defenseBoost = "+2 defense\n"; - - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "PrefixAccDefense") - line2.text = defenseBoost + "+0.25% damage reduction"; - } - } - if (item.prefix == PrefixID.Guarding) - { - string defenseBoost = "+2 defense\n"; - if (CalamityWorld.downedDoG) - defenseBoost = "+8 defense\n"; - else if (CalamityWorld.downedPolterghast) - defenseBoost = "+7 defense\n"; - else if (CalamityWorld.downedProvidence) - defenseBoost = "+6 defense\n"; - else if (NPC.downedMoonlord) - defenseBoost = "+5 defense\n"; - else if (NPC.downedGolemBoss) - defenseBoost = "+4 defense\n"; - else if (Main.hardMode) - defenseBoost = "+3 defense\n"; - - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "PrefixAccDefense") - line2.text = defenseBoost + "+0.5% damage reduction"; - } - } - if (item.prefix == PrefixID.Armored) - { - string defenseBoost = "+3 defense\n"; - if (CalamityWorld.downedDoG) - defenseBoost = "+12 defense\n"; - else if (CalamityWorld.downedPolterghast) - defenseBoost = "+10 defense\n"; - else if (CalamityWorld.downedProvidence) - defenseBoost = "+9 defense\n"; - else if (NPC.downedMoonlord) - defenseBoost = "+7 defense\n"; - else if (NPC.downedGolemBoss) - defenseBoost = "+6 defense\n"; - else if (Main.hardMode) - defenseBoost = "+4 defense\n"; - - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "PrefixAccDefense") - line2.text = defenseBoost + "+0.75% damage reduction"; - } - } - if (item.prefix == PrefixID.Warding) - { - string defenseBoost = "+4 defense\n"; - if (CalamityWorld.downedDoG) - defenseBoost = "+16 defense\n"; - else if (CalamityWorld.downedPolterghast) - defenseBoost = "+14 defense\n"; - else if (CalamityWorld.downedProvidence) - defenseBoost = "+12 defense\n"; - else if (NPC.downedMoonlord) - defenseBoost = "+10 defense\n"; - else if (NPC.downedGolemBoss) - defenseBoost = "+8 defense\n"; - else if (Main.hardMode) - defenseBoost = "+6 defense\n"; - - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "PrefixAccDefense") - line2.text = defenseBoost + "+1% damage reduction"; - } - } + case PrefixID.Brisk: + EditTooltipByName("PrefixAccMoveSpeed", (line) => line.text = line.text.Replace("1%", "2%")); + return; + case PrefixID.Fleeting: + EditTooltipByName("PrefixAccMoveSpeed", (line) => line.text = line.text.Replace("2%", "4%")); + return; + case PrefixID.Hasty2: // Hasty2 is the "Hasty" for accessories + EditTooltipByName("PrefixAccMoveSpeed", (line) => line.text = line.text.Replace("3%", "6%")); + return; + case PrefixID.Quick2: // Quick2 is the "Quick" for accessories + EditTooltipByName("PrefixAccMoveSpeed", (line) => line.text = line.text.Replace("4%", "8%")); + return; + case PrefixID.Precise: + case PrefixID.Lucky: + EditTooltipByName("PrefixAccCritChance", (line) => line.text += "\n+1 armor penetration"); + return; + case PrefixID.Hard: + EditTooltipByName("PrefixAccDefense", + (line) => line.text = line.text.Replace("1", CalamityUtils.GetScalingDefense(item.prefix).ToString()) + DRString(0.25f)); + return; + case PrefixID.Guarding: + EditTooltipByName("PrefixAccDefense", + (line) => line.text = line.text.Replace("2", CalamityUtils.GetScalingDefense(item.prefix).ToString()) + DRString(0.5f)); + return; + case PrefixID.Armored: + EditTooltipByName("PrefixAccDefense", + (line) => line.text = line.text.Replace("3", CalamityUtils.GetScalingDefense(item.prefix).ToString()) + DRString(0.75f)); + return; + case PrefixID.Warding: + EditTooltipByName("PrefixAccDefense", + (line) => line.text = line.text.Replace("4", CalamityUtils.GetScalingDefense(item.prefix).ToString()) + DRString(1f)); + return; } #endregion } diff --git a/Utilities/ItemUtils.cs b/Utilities/ItemUtils.cs index 014fe00f1f..d743b3f451 100644 --- a/Utilities/ItemUtils.cs +++ b/Utilities/ItemUtils.cs @@ -72,6 +72,62 @@ namespace CalamityMod } #endregion + // TODO -- This probably isn't the best place to put this but it needs to be somewhere easily accessible. + #region Accessory Prefix Stats + internal static int GetScalingDefense(int prefixID) + { + switch (prefixID) + { + default: + return 0; + case PrefixID.Hard: + return CalamityWorld.downedDoG ? 4 : CalamityWorld.downedProvidence || CalamityWorld.downedPolterghast ? 3 : NPC.downedMoonlord || NPC.downedGolemBoss ? 2 : 1; + case PrefixID.Guarding: + if (CalamityWorld.downedDoG) + return 8; + else if (CalamityWorld.downedPolterghast) + return 7; + else if (CalamityWorld.downedProvidence) + return 6; + else if (NPC.downedMoonlord) + return 5; + else if (NPC.downedGolemBoss) + return 4; + else if (Main.hardMode) + return 3; + return 2; + case PrefixID.Armored: + if (CalamityWorld.downedDoG) + return 12; + else if (CalamityWorld.downedPolterghast) + return 10; + else if (CalamityWorld.downedProvidence) + return 9; + else if (NPC.downedMoonlord) + return 7; + else if (NPC.downedGolemBoss) + return 6; + else if (Main.hardMode) + return 4; + return 3; + case PrefixID.Warding: + if (CalamityWorld.downedDoG) + return 16; + else if (CalamityWorld.downedPolterghast) + return 14; + else if (CalamityWorld.downedProvidence) + return 12; + else if (NPC.downedMoonlord) + return 10; + else if (NPC.downedGolemBoss) + return 8; + else if (Main.hardMode) + return 6; + return 4; + } + } + #endregion + /// /// Converts the given ModHotKey into a string for insertion into item tooltips.

/// This allows the user's actual keybind choices to be shown to them in tooltips. From cb6b42f43f144447132a0427d64feea50d5a8386 Mon Sep 17 00:00:00 2001 From: Andrew Marheine Date: Tue, 13 Apr 2021 00:19:56 -0500 Subject: [PATCH 30/32] 1 - Highest tier accessory reforges now reforge into other highest tier accessory reforges. 2 - Nerfed Amalgam extra projectile damage values. 3 - Arma bags now only drop on first boss kills. 4 - Nerfed Conference Call extra bullet damage by 30%. 5 - Cal Clone dashes are no longer predictive. 6 - Old Duke looks in the direction he's about to dash instead of directly at the player, if he's going to dash. 7 - Updated pillar spawn code a bit more. 8 - Pulse Rifle now works like it should and doesn't hit 4 times on a single target. 9 - Adjusted HomeInOnNPC calls to use projectile.tileCollide to decide homing through tiles or not. --- CalPlayer/CalamityPlayer.cs | 8 +- Items/Accessories/TheAmalgam.cs | 6 +- Items/CalamityGlobalItem.cs | 160 +++++++++++++++--- Items/DifficultyItems/Armageddon.cs | 3 +- Items/Weapons/Melee/PrismaticBreaker.cs | 4 +- Items/Weapons/Ranged/ConferenceCall.cs | 2 +- Items/Weapons/Ranged/TrueConferenceCall.cs | 7 +- NPCs/AquaticScourge/AquaticScourgeHead.cs | 1 - NPCs/CalamityAI.cs | 74 +++++--- NPCs/CalamityGlobalNPC.cs | 89 +++++----- NPCs/CalamityGlobalNPCLoot.cs | 110 ++++++------ NPCs/Yharon/Yharon.cs | 8 +- Projectiles/DraedonsArsenal/PulseRifleShot.cs | 7 +- Projectiles/Magic/AstralachneaFang.cs | 2 +- Projectiles/Magic/BeamingBolt2.cs | 2 +- Projectiles/Magic/BlueBubble.cs | 2 +- Projectiles/Magic/BrimstoneHomer.cs | 7 +- Projectiles/Magic/ForbiddenAxeBlade.cs | 2 +- Projectiles/Magic/GhastlyExplosionShard.cs | 2 +- Projectiles/Magic/GraniteEnergy.cs | 2 +- Projectiles/Magic/IceSpike.cs | 2 +- Projectiles/Magic/LightBead.cs | 2 +- Projectiles/Magic/Phantom.cs | 2 +- Projectiles/Magic/PoseidonTyphoon.cs | 2 +- Projectiles/Magic/VividLaser2.cs | 2 +- Projectiles/Melee/Blood.cs | 2 +- Projectiles/Melee/Blood2.cs | 2 +- Projectiles/Melee/Brimlash2.cs | 2 +- Projectiles/Melee/DepthOrb2.cs | 2 +- Projectiles/Melee/ElementalExcaliburBeam.cs | 2 +- Projectiles/Melee/EmpyreanKnife.cs | 2 +- Projectiles/Melee/Flarefrost.cs | 2 +- Projectiles/Melee/GhastlySoulLarge.cs | 2 +- Projectiles/Melee/GhastlySoulMedium.cs | 2 +- Projectiles/Melee/GhastlySoulSmall.cs | 2 +- Projectiles/Melee/IllustriousKnife.cs | 2 +- Projectiles/Melee/JudgementBlah.cs | 2 +- Projectiles/Melee/JudgementProj.cs | 2 +- Projectiles/Melee/Leech.cs | 2 +- .../Melee/MeldGreatswordBigProjectile.cs | 2 +- .../Melee/MeldGreatswordMediumProjectile.cs | 2 +- .../Melee/MeldGreatswordSmallProjectile.cs | 2 +- Projectiles/Melee/OmegaBiomeOrb.cs | 2 +- Projectiles/Melee/PlagueSeeker.cs | 2 +- Projectiles/Melee/RainBolt.cs | 2 +- Projectiles/Melee/Razorwind.cs | 2 +- Projectiles/Melee/TerraBall.cs | 2 +- Projectiles/Melee/TinyCrystal.cs | 2 +- Projectiles/Ranged/AquashardSplit.cs | 2 +- Projectiles/Ranged/AstralRound.cs | 2 +- Projectiles/Ranged/AstrealFlame.cs | 2 +- Projectiles/Ranged/BigNuke.cs | 2 +- Projectiles/Ranged/BloodfireArrowProj.cs | 2 +- Projectiles/Ranged/CardClubSplit.cs | 2 +- Projectiles/Ranged/ClamorRifleProj.cs | 2 +- Projectiles/Ranged/ClamorRifleProjSplit.cs | 2 +- Projectiles/Ranged/FishronRPG.cs | 2 +- Projectiles/Ranged/FungiOrb2.cs | 2 +- Projectiles/Ranged/MiniRocket.cs | 2 +- Projectiles/Ranged/Minibirb.cs | 2 +- .../Ranged/PlanetaryAnnihilationProj.cs | 2 +- Projectiles/Ranged/PolarStar.cs | 2 +- Projectiles/Ranged/RainbowBlast.cs | 2 +- Projectiles/Ranged/SeaDragonRocket.cs | 2 +- Projectiles/Ranged/SicknessRound2.cs | 2 +- Projectiles/Ranged/SputterCometBig.cs | 2 +- Projectiles/Ranged/TerraArrowSplit.cs | 2 +- Projectiles/Ranged/TerraBulletSplit.cs | 2 +- Projectiles/Ranged/ThePackMinissile.cs | 2 +- Projectiles/Rogue/CobaltEnergy.cs | 2 +- Projectiles/Rogue/Crushax.cs | 2 +- Projectiles/Rogue/DeepSeaDumbbell2.cs | 2 +- Projectiles/Rogue/DeepSeaDumbbell3.cs | 2 +- Projectiles/Rogue/GacruxianHome.cs | 2 +- Projectiles/Rogue/LostSoulFriendly.cs | 2 +- Projectiles/Rogue/LunarKunaiProj.cs | 2 +- Projectiles/Rogue/MoonSigil.cs | 2 +- Projectiles/Rogue/Prismalline3.cs | 8 +- Projectiles/Rogue/ProfanedPartisanSpear.cs | 2 +- Projectiles/Rogue/RadiantStar2.cs | 10 +- Projectiles/Rogue/SkyfinNuke.cs | 2 +- Projectiles/Rogue/TurbulanceWindSlash.cs | 2 +- Projectiles/Typeless/ChaosFlare.cs | 12 +- Projectiles/Typeless/ChaosFlare2.cs | 9 +- Projectiles/Typeless/GodSlayerPhantom.cs | 2 +- Projectiles/Typeless/VanquisherArrowSplit.cs | 2 +- Utilities/DropHelper.cs | 5 +- 87 files changed, 416 insertions(+), 250 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 5cf0890c55..364cf3002c 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -108,6 +108,7 @@ namespace CalamityMod.CalPlayer public bool noLifeRegen = false; public int itemTypeLastReforged = 0; public int reforgeTierSafety = 0; + public bool finalTierAccessoryReforge = false; public int defenseDamage = 0; public float rangedAmmoCost = 1f; public bool heldGaelsLastFrame = false; @@ -1062,6 +1063,7 @@ namespace CalamityMod.CalPlayer boost.AddWithCondition("bossHPBar", drawBossHPBar); boost.AddWithCondition("drawSmallText", shouldDrawSmallText); boost.AddWithCondition("fullHPRespawn", healToFull); + boost.AddWithCondition("finalTierAccessoryReforge", finalTierAccessoryReforge); boost.AddWithCondition("newMerchantInventory", newMerchantInventory); boost.AddWithCondition("newPainterInventory", newPainterInventory); @@ -1136,8 +1138,9 @@ namespace CalamityMod.CalPlayer drawBossHPBar = boost.Contains("bossHPBar"); shouldDrawSmallText = boost.Contains("drawSmallText"); healToFull = boost.Contains("fullHPRespawn"); + finalTierAccessoryReforge = boost.Contains("finalTierAccessoryReforge"); - newMerchantInventory = boost.Contains("newMerchantInventory"); + newMerchantInventory = boost.Contains("newMerchantInventory"); newPainterInventory = boost.Contains("newPainterInventory"); newDyeTraderInventory = boost.Contains("newDyeTraderInventory"); newPartyGirlInventory = boost.Contains("newPartyGirlInventory"); @@ -1293,7 +1296,8 @@ namespace CalamityMod.CalPlayer BitsByte flags6 = reader.ReadByte(); newBanditInventory = flags6[0]; - } + finalTierAccessoryReforge = flags6[1]; + } else { ModContent.GetInstance().Logger.Error("Unknown loadVersion: " + loadVersion); diff --git a/Items/Accessories/TheAmalgam.cs b/Items/Accessories/TheAmalgam.cs index ffb6057df0..f145ce960b 100644 --- a/Items/Accessories/TheAmalgam.cs +++ b/Items/Accessories/TheAmalgam.cs @@ -21,9 +21,9 @@ namespace CalamityMod.Items.Accessories public const int FireProjectiles = 2; public const float FireAngleSpread = 120; public int counter = 0; - public const int ProjectileDamage = 1000; - public const int FungalClumpDamage = 500; - public const int AuraDamage = 150; + public const int ProjectileDamage = 300; + public const int FungalClumpDamage = 150; + public const int AuraDamage = 100; public override void SetStaticDefaults() { diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index c98da34c74..13129350b0 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -497,7 +497,7 @@ namespace CalamityMod.Items { BitsByte flags = reader.ReadByte(); rogue = flags[0]; - } + } else { ModContent.GetInstance().Logger.Error("Unknown loadVersion: " + loadVersion); @@ -509,7 +509,7 @@ namespace CalamityMod.Items BitsByte flags = new BitsByte(); flags[0] = rogue; - writer.Write(flags); + writer.Write(flags); writer.Write((int)customRarity); writer.Write(timesUsed); writer.Write(Charge); @@ -521,7 +521,7 @@ namespace CalamityMod.Items BitsByte flags = reader.ReadByte(); rogue = flags[0]; - customRarity = (CalamityRarity)reader.ReadInt32(); + customRarity = (CalamityRarity)reader.ReadInt32(); timesUsed = reader.ReadInt32(); Charge = reader.ReadSingle(); reforgeTier = reader.ReadInt32(); @@ -3754,7 +3754,118 @@ Grants immunity to fire blocks, and temporary immunity to lava"; private int NewPrefixType(Item item) { int prefix = -2; - if (item.melee) + if (item.accessory) + { + if (Main.player[Main.myPlayer].Calamity().finalTierAccessoryReforge) + { + // Warding = 18, Menacing = 19, Quick = 20, Violent = 21, Lucky = 22, Silent = 23 + prefix = Main.rand.Next(18, 24); + } + else + { + switch (reforgeTier) + { + case 0: + break; + case 1: + // Hard = 1, Jagged = 2, Brisk = 3, Wild = 4, Quiet = 5 + prefix = Main.rand.Next(1, 6); + break; + case 2: + // Guarding = 6, Spiked = 7, Fleeting = 8, Rash = 9, Cloaked = 10 + prefix = Main.rand.Next(6, 11); + break; + case 3: + // Precise = 11, Arcane = 12 + prefix = Main.rand.Next(11, 13); + break; + case 4: + // Armored = 13, Angry = 14, Hasty = 15, Intrepid = 16, Camouflaged = 17 + prefix = Main.rand.Next(13, 18); + break; + case 5: + case 6: + // Warding = 18, Menacing = 19, Quick = 20, Violent = 21, Lucky = 22, Silent = 23 + prefix = Main.rand.Next(18, 24); + break; + } + } + switch (prefix) + { + case -2: + break; + case 1: + prefix = PrefixID.Hard; + break; + case 2: + prefix = PrefixID.Jagged; + break; + case 3: + prefix = PrefixID.Brisk; + break; + case 4: + prefix = PrefixID.Wild; + break; + case 5: + prefix = mod.PrefixType("Quiet"); + break; + case 6: + prefix = PrefixID.Guarding; + break; + case 7: + prefix = PrefixID.Spiked; + break; + case 8: + prefix = PrefixID.Fleeting; + break; + case 9: + prefix = PrefixID.Rash; + break; + case 10: + prefix = mod.PrefixType("Cloaked"); + break; + case 11: + prefix = PrefixID.Precise; + break; + case 12: + prefix = PrefixID.Arcane; + break; + case 13: + prefix = PrefixID.Armored; + break; + case 14: + prefix = PrefixID.Angry; + break; + case 15: + prefix = PrefixID.Hasty2; + break; + case 16: + prefix = PrefixID.Intrepid; + break; + case 17: + prefix = mod.PrefixType("Camouflaged"); + break; + case 18: + prefix = PrefixID.Warding; + break; + case 19: + prefix = PrefixID.Menacing; + break; + case 20: + prefix = PrefixID.Quick2; + break; + case 21: + prefix = PrefixID.Violent; + break; + case 22: + prefix = PrefixID.Lucky; + break; + case 23: + prefix = mod.PrefixType("Silent"); + break; + } + } + else if (item.melee) { if (item.knockBack == 0f) { @@ -4595,28 +4706,31 @@ Grants immunity to fire blocks, and temporary immunity to lava"; // Get cash from dickhead goblin fuck public override void PostReforge(Item item) { - if (!item.accessory) + CalamityPlayer modPlayer = Main.player[Main.myPlayer].Calamity(); + if (modPlayer.itemTypeLastReforged != item.type) { - CalamityPlayer modPlayer = Main.player[Main.myPlayer].Calamity(); - if (modPlayer.itemTypeLastReforged != item.type) - modPlayer.reforgeTierSafety = 0; - - modPlayer.itemTypeLastReforged = item.type; - - if (modPlayer.reforgeTierSafety > 6) - modPlayer.reforgeTierSafety = 0; - - modPlayer.reforgeTierSafety += 1; - reforgeTier = modPlayer.reforgeTierSafety; - - bool favorited = item.favorited; - item.netDefaults(item.netID); - item.Prefix(NewPrefixType(item)); - - item.Center = Main.player[Main.myPlayer].Center; - item.favorited = favorited; + modPlayer.reforgeTierSafety = 0; + modPlayer.finalTierAccessoryReforge = false; } + modPlayer.itemTypeLastReforged = item.type; + + if (modPlayer.reforgeTierSafety > 6) + { + modPlayer.reforgeTierSafety = 0; + modPlayer.finalTierAccessoryReforge = true; + } + + modPlayer.reforgeTierSafety++; + reforgeTier = modPlayer.reforgeTierSafety; + + bool favorited = item.favorited; + item.netDefaults(item.netID); + item.Prefix(NewPrefixType(item)); + + item.Center = Main.player[Main.myPlayer].Center; + item.favorited = favorited; + if (NPC.AnyNPCs(ModContent.NPCType())) { int value = item.value; diff --git a/Items/DifficultyItems/Armageddon.cs b/Items/DifficultyItems/Armageddon.cs index 99170c08c3..faf4f3c1e4 100644 --- a/Items/DifficultyItems/Armageddon.cs +++ b/Items/DifficultyItems/Armageddon.cs @@ -16,7 +16,8 @@ namespace CalamityMod.Items.DifficultyItems DisplayName.SetDefault("Armageddon"); Tooltip.SetDefault("Makes any hit while a boss is alive instantly kill you\n" + "Effect can be toggled on and off\n" + - "If a boss is defeated with this effect active it will drop 6 treasure bags, 5 in normal mode"); + "If a boss is defeated with this effect active it will drop 6 treasure bags, 5 in normal mode\n" + + "These extra bags will only drop if it's your first time killing the boss"); } public override void SetDefaults() diff --git a/Items/Weapons/Melee/PrismaticBreaker.cs b/Items/Weapons/Melee/PrismaticBreaker.cs index 021b035518..e5ccfb9e7f 100644 --- a/Items/Weapons/Melee/PrismaticBreaker.cs +++ b/Items/Weapons/Melee/PrismaticBreaker.cs @@ -90,11 +90,11 @@ namespace CalamityMod.Items.Weapons.Melee { if (player.altFunctionUse == 2) { - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), (int)(damage * 1), knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); } else { - Projectile.NewProjectile(position.X, position.Y, speedX * 0.5f, speedY * 0.5f, type, damage, knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position.X, position.Y, speedX * 0.5f, speedY * 0.5f, type, damage, knockBack, player.whoAmI); } return false; } diff --git a/Items/Weapons/Ranged/ConferenceCall.cs b/Items/Weapons/Ranged/ConferenceCall.cs index d8987ebee9..fbe8e1ec2f 100644 --- a/Items/Weapons/Ranged/ConferenceCall.cs +++ b/Items/Weapons/Ranged/ConferenceCall.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.rare = ItemRarityID.Yellow; item.UseSound = SoundID.Item38; item.autoReuse = true; - item.shootSpeed = 13f; + item.shootSpeed = 12f; item.shoot = ProjectileID.PurificationPowder; item.useAmmo = AmmoID.Bullet; } diff --git a/Items/Weapons/Ranged/TrueConferenceCall.cs b/Items/Weapons/Ranged/TrueConferenceCall.cs index 3ca06c3bf0..09768c5b75 100644 --- a/Items/Weapons/Ranged/TrueConferenceCall.cs +++ b/Items/Weapons/Ranged/TrueConferenceCall.cs @@ -78,6 +78,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); + int extraBulletDamage = (int)(damage * 0.7); for (int j = 0; j < targetArrayIndex; j++) { @@ -87,7 +88,7 @@ namespace CalamityMod.Items.Weapons.Ranged Vector2 velocity2 = Vector2.Normalize(Main.npc[targets[j]].Center - vector2) * item.shootSpeed; - int proj = Projectile.NewProjectile(vector2, velocity2, type, damage, knockBack, player.whoAmI); + int proj = Projectile.NewProjectile(vector2, velocity2, type, extraBulletDamage, knockBack, player.whoAmI); Main.projectile[proj].extraUpdates += 2; Main.projectile[proj].tileCollide = false; Main.projectile[proj].timeLeft /= 2; @@ -96,7 +97,7 @@ namespace CalamityMod.Items.Weapons.Ranged if (targetArrayIndex == 12) return false; - // Fire bullets at the same targets if + // Fire bullets at the same targets if 12 unique targets aren't found for (int k = 0; k < maxTargets - targetArrayIndex; k++) { int randomTarget = Main.rand.Next(targetArrayIndex); @@ -107,7 +108,7 @@ namespace CalamityMod.Items.Weapons.Ranged Vector2 velocity2 = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - vector2) * item.shootSpeed; - int proj = Projectile.NewProjectile(vector2, velocity2, type, damage, knockBack, player.whoAmI); + int proj = Projectile.NewProjectile(vector2, velocity2, type, extraBulletDamage, knockBack, player.whoAmI); Main.projectile[proj].extraUpdates += 2; Main.projectile[proj].tileCollide = false; Main.projectile[proj].timeLeft /= 2; diff --git a/NPCs/AquaticScourge/AquaticScourgeHead.cs b/NPCs/AquaticScourge/AquaticScourgeHead.cs index 6d680bf3da..827d1ef9cf 100644 --- a/NPCs/AquaticScourge/AquaticScourgeHead.cs +++ b/NPCs/AquaticScourge/AquaticScourgeHead.cs @@ -17,7 +17,6 @@ using Microsoft.Xna.Framework.Graphics; using System.IO; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using CalamityMod.Items.Armor.Vanity; diff --git a/NPCs/CalamityAI.cs b/NPCs/CalamityAI.cs index 33279ea7a6..0f4d54072a 100644 --- a/NPCs/CalamityAI.cs +++ b/NPCs/CalamityAI.cs @@ -1666,7 +1666,7 @@ namespace CalamityMod.NPCs if (provy) chargeVelocity *= 1.25f; - Vector2 vector = Vector2.Normalize(player.Center + player.velocity * 10f - npc.Center); + Vector2 vector = Vector2.Normalize(player.Center - npc.Center); npc.velocity = vector * chargeVelocity; npc.ai[1] = 3f; @@ -1676,7 +1676,7 @@ namespace CalamityMod.NPCs { npc.ai[2] += 1f; - float chargeTime = BossRushEvent.BossRushActive ? 56f : (70f - (death ? 6f * (1f - lifeRatio) : 0f)); + float chargeTime = BossRushEvent.BossRushActive ? 45f : (56f - (death ? 6f * (1f - lifeRatio) : 0f)); if (npc.ai[2] >= chargeTime) { npc.velocity *= 0.93f; @@ -1688,7 +1688,7 @@ namespace CalamityMod.NPCs else npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; - if (npc.ai[2] >= chargeTime + 15f) + if (npc.ai[2] >= chargeTime + 12f) { npc.ai[3] += 1f; npc.ai[2] = 0f; @@ -1706,7 +1706,7 @@ namespace CalamityMod.NPCs } else { - int num62 = 500; + int num62 = 400; float num63 = (calamityGlobalNPC.enraged > 0) ? 20f : 14f; float num64 = (calamityGlobalNPC.enraged > 0) ? 0.5f : 0.35f; @@ -1767,7 +1767,7 @@ namespace CalamityMod.NPCs } npc.ai[2] += 1f; - if (npc.ai[2] >= 45f) + if (npc.ai[2] >= 36f) { npc.TargetClosest(); npc.ai[1] = 2f; @@ -4902,7 +4902,47 @@ namespace CalamityMod.NPCs } // Rotation - float num17 = (float)Math.Atan2(player.Center.Y - vector.Y, player.Center.X - vector.X); + // Phase switch + float rateOfRotation = 0.04f; + if (npc.ai[0] == 1f || npc.ai[0] == 6f || npc.ai[0] == 7f || npc.ai[0] == 14f) + rateOfRotation = 0f; + if (npc.ai[0] == 3f || npc.ai[0] == 4f) + rateOfRotation = 0.01f; + if (npc.ai[0] == 8f || npc.ai[0] == 13f) + rateOfRotation = 0.05f; + + Vector2 playerCenter = player.Center; + if (calamityGlobalNPC.newAI[1] != 1f && !player.dead) + { + // Rotate to show direction of predictive charge + Vector2 distanceVector = player.Center + player.velocity * 20f - vector; + if (npc.ai[0] == 0f && !phase2) + { + if (npc.ai[3] < 6f) + { + rateOfRotation = 0.1f; + playerCenter += Vector2.Normalize(distanceVector) * chargeVelocity; + } + } + else if (npc.ai[0] == 5f && !phase3) + { + if (npc.ai[3] < 4f) + { + rateOfRotation = 0.1f; + playerCenter += Vector2.Normalize(distanceVector) * chargeVelocity; + } + } + else if (npc.ai[0] == 10f) + { + if (npc.ai[3] < 8f && npc.ai[3] != 1f && npc.ai[3] != 4f) + { + rateOfRotation = 0.1f; + playerCenter += Vector2.Normalize(distanceVector) * chargeVelocity; + } + } + } + + float num17 = (float)Math.Atan2(playerCenter.Y - vector.Y, playerCenter.X - vector.X); if (npc.spriteDirection == 1) num17 += pie; if (num17 < 0f) @@ -4912,42 +4952,32 @@ namespace CalamityMod.NPCs if (npc.ai[0] == -1f || npc.ai[0] == 3f || npc.ai[0] == 4f) num17 = 0f; if (npc.ai[0] == 8f || npc.ai[0] == 13f) - { num17 = pie * 0.1666666667f * npc.spriteDirection; - } - - float num18 = 0.04f; - if (npc.ai[0] == 1f || npc.ai[0] == 6f || npc.ai[0] == 7f || npc.ai[0] == 14f) - num18 = 0f; - if (npc.ai[0] == 3f || npc.ai[0] == 4f) - num18 = 0.01f; - if (npc.ai[0] == 8f || npc.ai[0] == 13f) - num18 = 0.05f; if (npc.rotation < num17) { if (num17 - npc.rotation > pie) - npc.rotation -= num18; + npc.rotation -= rateOfRotation; else - npc.rotation += num18; + npc.rotation += rateOfRotation; } if (npc.rotation > num17) { if (npc.rotation - num17 > pie) - npc.rotation += num18; + npc.rotation += rateOfRotation; else - npc.rotation -= num18; + npc.rotation -= rateOfRotation; } if ((npc.ai[0] != 8f && npc.ai[0] != 13f) || npc.spriteDirection == 1) { - if (npc.rotation > num17 - num18 && npc.rotation < num17 + num18) + if (npc.rotation > num17 - rateOfRotation && npc.rotation < num17 + rateOfRotation) npc.rotation = num17; 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) + if (npc.rotation > num17 - rateOfRotation && npc.rotation < num17 + rateOfRotation) npc.rotation = num17; } diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 21d5d1559e..ac29ce0773 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -3161,12 +3161,11 @@ namespace CalamityMod.NPCs private void PillarEventProgressionEdit(NPC npc) { // Make pillars a bit more fun by forcing more difficult enemies based on progression. - int solarTowerShieldStrength = NPC.ShieldStrengthTowerSolar / 25; + int solarTowerShieldStrength = (int)Math.Ceiling(NPC.ShieldStrengthTowerSolar / 25D); switch (solarTowerShieldStrength) { case 4: - case 3: - // Possible spawns: Corite, Drakanian, Drakomire, Drakomire Rider + // Possible spawns: Drakanian, Drakomire, Drakomire Rider switch (npc.type) { case NPCID.SolarCrawltipedeHead: @@ -3174,22 +3173,33 @@ namespace CalamityMod.NPCs case NPCID.SolarCrawltipedeTail: case NPCID.SolarSolenian: case NPCID.SolarSroller: + case NPCID.SolarCorite: npc.active = false; npc.netUpdate = true; break; + default: + break; + } + break; + case 3: + // Possible spawns: Drakomire, Drakomire Rider, Sroller + switch (npc.type) + { + case NPCID.SolarCrawltipedeHead: + case NPCID.SolarCrawltipedeBody: + case NPCID.SolarCrawltipedeTail: + case NPCID.SolarSpearman: + case NPCID.SolarSolenian: case NPCID.SolarCorite: - if (NPC.CountNPCS(NPCID.SolarCorite) > 2) - { - npc.active = false; - npc.netUpdate = true; - } + npc.active = false; + npc.netUpdate = true; break; default: break; } break; case 2: - // Possible spawns: Corite, Drakomire Rider, Sroller + // Possible spawns: Drakomire Rider, Selenian, Sroller switch (npc.type) { case NPCID.SolarDrakomire: @@ -3197,17 +3207,10 @@ namespace CalamityMod.NPCs case NPCID.SolarCrawltipedeBody: case NPCID.SolarCrawltipedeTail: case NPCID.SolarSpearman: - case NPCID.SolarSolenian: + case NPCID.SolarCorite: npc.active = false; npc.netUpdate = true; break; - case NPCID.SolarCorite: - if (NPC.CountNPCS(NPCID.SolarCorite) > 3) - { - npc.active = false; - npc.netUpdate = true; - } - break; default: break; } @@ -3225,19 +3228,12 @@ namespace CalamityMod.NPCs npc.active = false; npc.netUpdate = true; break; - case NPCID.SolarCorite: - if (NPC.CountNPCS(NPCID.SolarCorite) > 4) - { - npc.active = false; - npc.netUpdate = true; - } - break; default: break; } break; case 0: - // Possible spawns: Corite, Selenian, Crawltipede + // Possible spawns: Corite, Crawltipede, Selenian switch (npc.type) { case NPCID.SolarDrakomire: @@ -3247,24 +3243,16 @@ namespace CalamityMod.NPCs npc.active = false; npc.netUpdate = true; break; - case NPCID.SolarCorite: - if (NPC.CountNPCS(NPCID.SolarCorite) > 5) - { - npc.active = false; - npc.netUpdate = true; - } - break; default: break; } break; } - int vortexTowerShieldStrength = NPC.ShieldStrengthTowerVortex / 25; + int vortexTowerShieldStrength = (int)Math.Ceiling(NPC.ShieldStrengthTowerVortex / 25D); switch (vortexTowerShieldStrength) { case 4: - case 3: // Possible spawns: Alien Larva, Alien Hornet, Alien Queen switch (npc.type) { @@ -3277,7 +3265,7 @@ namespace CalamityMod.NPCs break; } break; - case 2: + case 3: // Possible spawns: Alien Larva, Alien Hornet, Alien Queen, Vortexian if (npc.type == NPCID.VortexRifleman) { @@ -3285,7 +3273,7 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } break; - case 1: + case 2: // Possible spawns: Alien Larva, Alien Hornet, Alien Queen, Storm Diver if (npc.type == NPCID.VortexSoldier) { @@ -3293,16 +3281,16 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } break; + case 1: case 0: // Possible spawns: Alien Larva, Alien Hornet, Alien Queen, Vortexian, Storm Diver break; } - int nebulaTowerShieldStrength = NPC.ShieldStrengthTowerNebula / 25; + int nebulaTowerShieldStrength = (int)Math.Ceiling(NPC.ShieldStrengthTowerNebula / 25D); switch (nebulaTowerShieldStrength) { case 4: - case 3: // Possible spawns: Brain Suckler switch (npc.type) { @@ -3316,7 +3304,7 @@ namespace CalamityMod.NPCs break; } break; - case 2: + case 3: // Possible spawns: Brain Suckler, Predictor switch (npc.type) { @@ -3329,7 +3317,7 @@ namespace CalamityMod.NPCs break; } break; - case 1: + case 2: // Possible spawns: Brain Suckler, Predictor, Evolution Beast if (npc.type == NPCID.NebulaBrain) { @@ -3337,6 +3325,7 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } break; + case 1: case 0: // Possible spawns: Predictor, Evolution Beast, Nebula Floater if (npc.type == NPCID.NebulaHeadcrab) @@ -3347,11 +3336,10 @@ namespace CalamityMod.NPCs break; } - int stardustTowerShieldStrength = NPC.ShieldStrengthTowerStardust / 25; + int stardustTowerShieldStrength = (int)Math.Ceiling(NPC.ShieldStrengthTowerStardust / 25D); switch (stardustTowerShieldStrength) { case 4: - case 3: // Possible spawns: Milkyway Weaver, Star Cell switch (npc.type) { @@ -3365,7 +3353,7 @@ namespace CalamityMod.NPCs break; } break; - case 2: + case 3: // Possible spawns: Milkyway Weaver, Stargazer, Twinkle Popper switch (npc.type) { @@ -3378,7 +3366,7 @@ namespace CalamityMod.NPCs break; } break; - case 1: + case 2: // Possible spawns: Stargazer, Twinkle Popper, Flow Invader switch (npc.type) { @@ -3393,6 +3381,7 @@ namespace CalamityMod.NPCs break; } break; + case 1: case 0: // Possible spawns: Twinkle Popper, Flow Invader switch (npc.type) @@ -4066,6 +4055,16 @@ namespace CalamityMod.NPCs maxSpawns = (int)(maxSpawns * 10f); } + if (NPC.LunarApocalypseIsUp) + { + if ((player.ZoneTowerNebula && NPC.ShieldStrengthTowerNebula == 0) || (player.ZoneTowerStardust && NPC.ShieldStrengthTowerStardust == 0) || + (player.ZoneTowerVortex && NPC.ShieldStrengthTowerVortex == 0) || (player.ZoneTowerSolar && NPC.ShieldStrengthTowerSolar == 0)) + { + spawnRate = (int)(spawnRate * 0.85); + maxSpawns = (int)(maxSpawns * 1.25f); + } + } + if (CalamityWorld.revenge) spawnRate = (int)(spawnRate * 0.85); @@ -5174,7 +5173,7 @@ namespace CalamityMod.NPCs return CalamityWorld.downedSCal; } - return false; + return true; } #endregion diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index a7f6125f42..bd07a57cd5 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -50,13 +50,13 @@ namespace CalamityMod.NPCs return false; // Servants of Cthulhu and Probes do not provide free hearts in Rev+. - if (CalamityWorld.revenge && (npc.type == NPCID.ServantofCthulhu || npc.type == NPCID.Probe)) + if (CalamityWorld.revenge && (npc.type == NPCID.ServantofCthulhu || npc.type == NPCID.Probe)) NPCLoader.blockLoot.Add(ItemID.Heart); // // Ozzatron 17FEB2021: A NOTE about PreNPCLoot vs NPCLoot // PreNPCLoot runs before the boss is marked as dead. This means it is required for lore items and Resident Evil ammo. - // Because we already have clauses here for every boss, it is more convenient to drop everything here than it is + // Because we already have clauses here for every boss, it is more convenient to drop everything here than it is. // to iterate through all the bosses twice. // @@ -72,19 +72,18 @@ namespace CalamityMod.NPCs // Determine whether this NPC is the second Twin killed in a fight, regardless of which Twin it is. bool lastTwinStanding = false; if (npc.type == NPCID.Retinazer) - { lastTwinStanding = !NPC.AnyNPCs(NPCID.Spazmatism); - } else if (npc.type == NPCID.Spazmatism) - { lastTwinStanding = !NPC.AnyNPCs(NPCID.Retinazer); - } // Mechanical Bosses' combined lore item bool mechLore = !NPC.downedMechBossAny && (lastTwinStanding || npc.type == NPCID.TheDestroyer || npc.type == NPCID.SkeletronPrime); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, mechLore); - if (npc.type == NPCID.KingSlime) + if (CalamityWorld.armageddon) + ArmageddonLoot(npc); + + if (npc.type == NPCID.KingSlime) { // Drop a huge spray of Gel items int minGel = Main.expertMode ? 90 : 60; @@ -663,10 +662,54 @@ namespace CalamityMod.NPCs return true; } - #endregion + #endregion - #region NPCLoot - public override void NPCLoot(NPC npc) + #region Armageddon Loot + private void ArmageddonLoot(NPC npc) + { + switch (npc.type) + { + case NPCID.EaterofWorldsHead: + case NPCID.EaterofWorldsBody: + case NPCID.EaterofWorldsTail: + if (npc.boss) // only drop from the 1 "boss" segment (redcode) + DropHelper.DropArmageddonBags(npc); + break; + + case NPCID.Retinazer: // only drop if spaz is already dead + if (!NPC.AnyNPCs(NPCID.Spazmatism)) + DropHelper.DropArmageddonBags(npc); + break; + + case NPCID.Spazmatism: // only drop if ret is already dead + if (!NPC.AnyNPCs(NPCID.Retinazer)) + DropHelper.DropArmageddonBags(npc); + break; + + case NPCID.KingSlime: + case NPCID.EyeofCthulhu: + case NPCID.BrainofCthulhu: + case NPCID.QueenBee: + case NPCID.SkeletronHead: + case NPCID.WallofFlesh: + case NPCID.TheDestroyer: + case NPCID.SkeletronPrime: + case NPCID.Plantera: + case NPCID.Golem: + case NPCID.DD2Betsy: + case NPCID.DukeFishron: + case NPCID.MoonLordCore: + DropHelper.DropArmageddonBags(npc); + break; + + default: + break; + } + } + #endregion + + #region NPCLoot + public override void NPCLoot(NPC npc) { // LATER -- keeping bosses alive lets draedon mayhem continue even after killing mechs // Reset Draedon Mayhem to false if no bosses are alive @@ -679,9 +722,6 @@ namespace CalamityMod.NPCs } } - if (CalamityWorld.armageddon) - ArmageddonLoot(npc); - // Miscellaneous on-enemy-kill effects. CheckBossSpawn(npc); if (CalamityWorld.rainingAcid) @@ -695,50 +735,6 @@ namespace CalamityMod.NPCs } #endregion - #region Armageddon Loot - private void ArmageddonLoot(NPC npc) - { - switch (npc.type) - { - case NPCID.EaterofWorldsHead: - case NPCID.EaterofWorldsBody: - case NPCID.EaterofWorldsTail: - if (npc.boss) // only drop from the 1 "boss" segment (redcode) - DropHelper.DropArmageddonBags(npc); - break; - - case NPCID.Retinazer: // only drop if spaz is already dead - if (!NPC.AnyNPCs(NPCID.Spazmatism)) - DropHelper.DropArmageddonBags(npc); - break; - - case NPCID.Spazmatism: // only drop if ret is already dead - if (!NPC.AnyNPCs(NPCID.Retinazer)) - DropHelper.DropArmageddonBags(npc); - break; - - case NPCID.KingSlime: - case NPCID.EyeofCthulhu: - case NPCID.BrainofCthulhu: - case NPCID.QueenBee: - case NPCID.SkeletronHead: - case NPCID.WallofFlesh: - case NPCID.TheDestroyer: - case NPCID.SkeletronPrime: - case NPCID.Plantera: - case NPCID.Golem: - case NPCID.DD2Betsy: - case NPCID.DukeFishron: - case NPCID.MoonLordCore: - DropHelper.DropArmageddonBags(npc); - break; - - default: - break; - } - } - #endregion - #region Check Boss Spawn // not really drop code private void CheckBossSpawn(NPC npc) diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index 06afd5420e..c99f5c7544 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -989,7 +989,7 @@ namespace CalamityMod.NPCs.Yharon } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center + Main.player[t].velocity * 20f - flareDustBulletHellSpawn) * 10f; + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center + Main.player[t].velocity * 30f - flareDustBulletHellSpawn) * 8f; int type = ModContent.ProjectileType(); int proj = Projectile.NewProjectile(flareDustBulletHellSpawn, velocity2, type, npc.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); Main.projectile[proj].extraUpdates += 1; @@ -1358,7 +1358,7 @@ namespace CalamityMod.NPCs.Yharon } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center + Main.player[t].velocity * 20f - flareDustBulletHellSpawn) * 10f; + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center + Main.player[t].velocity * 30f - flareDustBulletHellSpawn) * 8f; int type = ModContent.ProjectileType(); int proj = Projectile.NewProjectile(flareDustBulletHellSpawn, velocity2, type, npc.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); Main.projectile[proj].extraUpdates += 1; @@ -2214,7 +2214,7 @@ namespace CalamityMod.NPCs.Yharon } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center + Main.player[t].velocity * 20f - flareDustBulletHellSpawn) * 10f; + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center + Main.player[t].velocity * 30f - flareDustBulletHellSpawn) * (projectileVelocity * 0.7f); int type = ModContent.ProjectileType(); int proj = Projectile.NewProjectile(flareDustBulletHellSpawn, velocity2, type, npc.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); Main.projectile[proj].extraUpdates += 1; @@ -2244,7 +2244,7 @@ namespace CalamityMod.NPCs.Yharon } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center + Main.player[t].velocity * 20f - flareDustBulletHellSpawn) * 10f; + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center + Main.player[t].velocity * 30f - flareDustBulletHellSpawn) * 8f; int type = ModContent.ProjectileType(); int proj = Projectile.NewProjectile(flareDustBulletHellSpawn, velocity2, type, npc.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); Main.projectile[proj].extraUpdates += 1; diff --git a/Projectiles/DraedonsArsenal/PulseRifleShot.cs b/Projectiles/DraedonsArsenal/PulseRifleShot.cs index db0e21a7cf..38aeffea55 100644 --- a/Projectiles/DraedonsArsenal/PulseRifleShot.cs +++ b/Projectiles/DraedonsArsenal/PulseRifleShot.cs @@ -85,6 +85,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal PulseBurst(4f, 5f); } + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 280; + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { if (projectile.ai[1] < 5f && !hasHit && Main.myPlayer == projectile.owner) @@ -94,14 +96,15 @@ namespace CalamityMod.Projectiles.DraedonsArsenal int alreadyTargetedNPCType = 0; if (projectile.ai[1] > 0f) alreadyTargetedNPCType = (int)projectile.ai[0]; + else + alreadyTargetedNPCType = target.whoAmI; 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 (alreadyTargetedNPCType != Main.npc[i].whoAmI && - projectile.Center.ManhattanDistance(Main.npc[i].Center) < 600f) + if (alreadyTargetedNPCType != Main.npc[i].whoAmI && projectile.Center.ManhattanDistance(Main.npc[i].Center) < 600f) { Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(Main.npc[i].Center) * 5f, projectile.type, projectile.damage / 2, 0f, projectile.owner, Main.npc[i].whoAmI, projectile.ai[1] + 1f); break; diff --git a/Projectiles/Magic/AstralachneaFang.cs b/Projectiles/Magic/AstralachneaFang.cs index ca20db538b..be56475489 100644 --- a/Projectiles/Magic/AstralachneaFang.cs +++ b/Projectiles/Magic/AstralachneaFang.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Magic projectile.rotation = projectile.velocity.ToRotation(); - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 150f, 12f, 25f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 150f, 12f, 25f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Magic/BeamingBolt2.cs b/Projectiles/Magic/BeamingBolt2.cs index 9000083e9c..227f53dfb4 100644 --- a/Projectiles/Magic/BeamingBolt2.cs +++ b/Projectiles/Magic/BeamingBolt2.cs @@ -46,7 +46,7 @@ namespace CalamityMod.Projectiles.Magic Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, randomDust, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); if (projectile.timeLeft < 90) - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 600f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Magic/BlueBubble.cs b/Projectiles/Magic/BlueBubble.cs index e21fc693bd..0bbd4c9cc6 100644 --- a/Projectiles/Magic/BlueBubble.cs +++ b/Projectiles/Magic/BlueBubble.cs @@ -50,7 +50,7 @@ namespace CalamityMod.Projectiles.Magic projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; if (projectile.timeLeft < 90) - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 400f, 8f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 400f, 8f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Magic/BrimstoneHomer.cs b/Projectiles/Magic/BrimstoneHomer.cs index 9bc5233111..1a45c24fff 100644 --- a/Projectiles/Magic/BrimstoneHomer.cs +++ b/Projectiles/Magic/BrimstoneHomer.cs @@ -24,14 +24,17 @@ namespace CalamityMod.Projectiles.Magic projectile.timeLeft = 180; } - public override void AI() + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + + public override void AI() { projectile.rotation += 0.7f * projectile.direction; int brimstone = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); Main.dust[brimstone].noGravity = true; - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 8f, 20f); + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 8f, 20f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Magic/ForbiddenAxeBlade.cs b/Projectiles/Magic/ForbiddenAxeBlade.cs index d755326aa6..91af3e6eb7 100644 --- a/Projectiles/Magic/ForbiddenAxeBlade.cs +++ b/Projectiles/Magic/ForbiddenAxeBlade.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Magic else if (projectile.ai[1] > 20f && projectile.ai[1] <= 39f) { projectile.velocity *= 1.25f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 150f, 10f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 10f, 20f); } else if (projectile.ai[1] == 40f) { diff --git a/Projectiles/Magic/GhastlyExplosionShard.cs b/Projectiles/Magic/GhastlyExplosionShard.cs index 65bc7dbc1b..44fc7c6fc9 100644 --- a/Projectiles/Magic/GhastlyExplosionShard.cs +++ b/Projectiles/Magic/GhastlyExplosionShard.cs @@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.Magic } if (projectile.timeLeft < 50) - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Magic/GraniteEnergy.cs b/Projectiles/Magic/GraniteEnergy.cs index 817c590618..892578be7d 100644 --- a/Projectiles/Magic/GraniteEnergy.cs +++ b/Projectiles/Magic/GraniteEnergy.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Magic Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 229, 0f, 0f, 100, default, 0.6f); if (projectile.timeLeft < 60) - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 600f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); } } } diff --git a/Projectiles/Magic/IceSpike.cs b/Projectiles/Magic/IceSpike.cs index 4e93b13dba..d9e96126e3 100644 --- a/Projectiles/Magic/IceSpike.cs +++ b/Projectiles/Magic/IceSpike.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Projectiles.Magic int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 67, 0f, 0f, 100, default, 1f); Main.dust[num469].noGravity = true; - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 10f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 10f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Magic/LightBead.cs b/Projectiles/Magic/LightBead.cs index 107a5e21b3..72e26b74fc 100644 --- a/Projectiles/Magic/LightBead.cs +++ b/Projectiles/Magic/LightBead.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Magic return; } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 18f, 10f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 18f, 10f); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Magic/Phantom.cs b/Projectiles/Magic/Phantom.cs index 154b30798a..b60d0e5070 100644 --- a/Projectiles/Magic/Phantom.cs +++ b/Projectiles/Magic/Phantom.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Magic Main.dust[num458].noGravity = true; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 300f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 20f); } } } diff --git a/Projectiles/Magic/PoseidonTyphoon.cs b/Projectiles/Magic/PoseidonTyphoon.cs index 58757ecc35..438bc07c38 100644 --- a/Projectiles/Magic/PoseidonTyphoon.cs +++ b/Projectiles/Magic/PoseidonTyphoon.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Magic { projectile.rotation += projectile.velocity.X * 0.05f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 300f, 6f, 30f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 6f, 30f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Magic/VividLaser2.cs b/Projectiles/Magic/VividLaser2.cs index d26f4005d2..efe1637bcb 100644 --- a/Projectiles/Magic/VividLaser2.cs +++ b/Projectiles/Magic/VividLaser2.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Projectiles.Magic projectile.ai[0] = 1f; if (projectile.ai[0] >= 1f) - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 400f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 400f, 12f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Melee/Blood.cs b/Projectiles/Melee/Blood.cs index b5c53cc385..8c2514c89b 100644 --- a/Projectiles/Melee/Blood.cs +++ b/Projectiles/Melee/Blood.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.Melee } if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 600f, 6f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 6f, 20f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Melee/Blood2.cs b/Projectiles/Melee/Blood2.cs index a8bce41e60..d4cbfb19ee 100644 --- a/Projectiles/Melee/Blood2.cs +++ b/Projectiles/Melee/Blood2.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.Melee } if (projectile.timeLeft < 120) - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 450f, 6f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 6f, 20f); } } } diff --git a/Projectiles/Melee/Brimlash2.cs b/Projectiles/Melee/Brimlash2.cs index dfdb00110a..93ea5af1fd 100644 --- a/Projectiles/Melee/Brimlash2.cs +++ b/Projectiles/Melee/Brimlash2.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Melee Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.05f / 255f, (255 - projectile.alpha) * 0.05f / 255f); if (projectile.timeLeft < 90) - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 600f, 12f, 15f); + CalamityGlobalProjectile.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; diff --git a/Projectiles/Melee/DepthOrb2.cs b/Projectiles/Melee/DepthOrb2.cs index 43369ecfee..b07f379930 100644 --- a/Projectiles/Melee/DepthOrb2.cs +++ b/Projectiles/Melee/DepthOrb2.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].velocity *= 0.5f; Main.dust[num458].velocity += projectile.velocity * 0.1f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/ElementalExcaliburBeam.cs b/Projectiles/Melee/ElementalExcaliburBeam.cs index 6edb8209b4..8293bfe507 100644 --- a/Projectiles/Melee/ElementalExcaliburBeam.cs +++ b/Projectiles/Melee/ElementalExcaliburBeam.cs @@ -156,7 +156,7 @@ namespace CalamityMod.Projectiles.Melee case 4: // Green, home in on enemies color = new Color(0, 255, 0, alpha); - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 300f, 6f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 6f, 20f); break; diff --git a/Projectiles/Melee/EmpyreanKnife.cs b/Projectiles/Melee/EmpyreanKnife.cs index 7448f1821a..14cc693be9 100644 --- a/Projectiles/Melee/EmpyreanKnife.cs +++ b/Projectiles/Melee/EmpyreanKnife.cs @@ -46,7 +46,7 @@ namespace CalamityMod.Projectiles.Melee { projectile.rotation += 0.5f; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 150f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 150f, 12f, 20f); if (Main.rand.NextBool(6)) Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 58, projectile.velocity.X * 0.1f, projectile.velocity.Y * 0.1f); } diff --git a/Projectiles/Melee/Flarefrost.cs b/Projectiles/Melee/Flarefrost.cs index 17b632fd01..adb064c5cf 100644 --- a/Projectiles/Melee/Flarefrost.cs +++ b/Projectiles/Melee/Flarefrost.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Melee } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 250f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 250f, 12f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Melee/GhastlySoulLarge.cs b/Projectiles/Melee/GhastlySoulLarge.cs index 6c5ccf01de..4a4b7b678f 100644 --- a/Projectiles/Melee/GhastlySoulLarge.cs +++ b/Projectiles/Melee/GhastlySoulLarge.cs @@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Melee return; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 300f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 20f); } else { diff --git a/Projectiles/Melee/GhastlySoulMedium.cs b/Projectiles/Melee/GhastlySoulMedium.cs index 5f6b4a2bc1..af8ea96587 100644 --- a/Projectiles/Melee/GhastlySoulMedium.cs +++ b/Projectiles/Melee/GhastlySoulMedium.cs @@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Melee return; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 300f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 20f); } else { diff --git a/Projectiles/Melee/GhastlySoulSmall.cs b/Projectiles/Melee/GhastlySoulSmall.cs index dcac84ab6f..c6f608baf1 100644 --- a/Projectiles/Melee/GhastlySoulSmall.cs +++ b/Projectiles/Melee/GhastlySoulSmall.cs @@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.Melee return; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 300f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 20f); } else { diff --git a/Projectiles/Melee/IllustriousKnife.cs b/Projectiles/Melee/IllustriousKnife.cs index 865133ee30..68a7cfee06 100644 --- a/Projectiles/Melee/IllustriousKnife.cs +++ b/Projectiles/Melee/IllustriousKnife.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Projectiles.Melee { projectile.rotation += 0.5f; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 300f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 20f); if (Main.rand.NextBool(6)) Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 20, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } diff --git a/Projectiles/Melee/JudgementBlah.cs b/Projectiles/Melee/JudgementBlah.cs index 2bc5842d8f..66d9c390b0 100644 --- a/Projectiles/Melee/JudgementBlah.cs +++ b/Projectiles/Melee/JudgementBlah.cs @@ -88,7 +88,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].velocity *= 0.5f; Main.dust[num458].velocity += projectile.velocity * 0.1f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 10f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 10f, 20f); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Melee/JudgementProj.cs b/Projectiles/Melee/JudgementProj.cs index c6d67131be..acea99dd2a 100644 --- a/Projectiles/Melee/JudgementProj.cs +++ b/Projectiles/Melee/JudgementProj.cs @@ -63,7 +63,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].velocity += projectile.velocity * 0.1f; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 9f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 9f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Melee/Leech.cs b/Projectiles/Melee/Leech.cs index b803545516..28c6540f85 100644 --- a/Projectiles/Melee/Leech.cs +++ b/Projectiles/Melee/Leech.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.Melee } if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 600f, 6f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 6f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Melee/MeldGreatswordBigProjectile.cs b/Projectiles/Melee/MeldGreatswordBigProjectile.cs index b088bf77e0..1529447900 100644 --- a/Projectiles/Melee/MeldGreatswordBigProjectile.cs +++ b/Projectiles/Melee/MeldGreatswordBigProjectile.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].noGravity = true; Main.dust[num458].velocity *= 0f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/MeldGreatswordMediumProjectile.cs b/Projectiles/Melee/MeldGreatswordMediumProjectile.cs index b3aa5d6781..5935b9a6e3 100644 --- a/Projectiles/Melee/MeldGreatswordMediumProjectile.cs +++ b/Projectiles/Melee/MeldGreatswordMediumProjectile.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].noGravity = true; Main.dust[num458].velocity *= 0f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/MeldGreatswordSmallProjectile.cs b/Projectiles/Melee/MeldGreatswordSmallProjectile.cs index bf677cc1fc..6dc60f13e7 100644 --- a/Projectiles/Melee/MeldGreatswordSmallProjectile.cs +++ b/Projectiles/Melee/MeldGreatswordSmallProjectile.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].noGravity = true; Main.dust[num458].velocity *= 0f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/OmegaBiomeOrb.cs b/Projectiles/Melee/OmegaBiomeOrb.cs index 5d442703ee..b04dc85ebc 100644 --- a/Projectiles/Melee/OmegaBiomeOrb.cs +++ b/Projectiles/Melee/OmegaBiomeOrb.cs @@ -144,7 +144,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].velocity *= 0.5f; Main.dust[num458].velocity += projectile.velocity * 0.1f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Melee/PlagueSeeker.cs b/Projectiles/Melee/PlagueSeeker.cs index 9fbb1e59b9..0f8ddbac50 100644 --- a/Projectiles/Melee/PlagueSeeker.cs +++ b/Projectiles/Melee/PlagueSeeker.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Melee } if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 600f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Melee/RainBolt.cs b/Projectiles/Melee/RainBolt.cs index cdbe479b94..af92adcf1e 100644 --- a/Projectiles/Melee/RainBolt.cs +++ b/Projectiles/Melee/RainBolt.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num469].velocity *= 0f; if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 600f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Melee/Razorwind.cs b/Projectiles/Melee/Razorwind.cs index 9960b690d1..f7f912a065 100644 --- a/Projectiles/Melee/Razorwind.cs +++ b/Projectiles/Melee/Razorwind.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Melee } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 250f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 250f, 12f, 20f); } public override bool OnTileCollide(Vector2 oldVelocity) diff --git a/Projectiles/Melee/TerraBall.cs b/Projectiles/Melee/TerraBall.cs index daa23c377f..f5525bf045 100644 --- a/Projectiles/Melee/TerraBall.cs +++ b/Projectiles/Melee/TerraBall.cs @@ -49,7 +49,7 @@ namespace CalamityMod.Projectiles.Melee projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Melee/TinyCrystal.cs b/Projectiles/Melee/TinyCrystal.cs index eae3462707..3fce8b2801 100644 --- a/Projectiles/Melee/TinyCrystal.cs +++ b/Projectiles/Melee/TinyCrystal.cs @@ -54,7 +54,7 @@ namespace CalamityMod.Projectiles.Melee } if (projectile.timeLeft < 75) - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 450f, 9f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 9f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Ranged/AquashardSplit.cs b/Projectiles/Ranged/AquashardSplit.cs index ce79b796e3..40c8692781 100644 --- a/Projectiles/Ranged/AquashardSplit.cs +++ b/Projectiles/Ranged/AquashardSplit.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.velocity.Y += 0.01f; if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 450f, 6f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 6f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Ranged/AstralRound.cs b/Projectiles/Ranged/AstralRound.cs index a43f9b7e03..310dd83141 100644 --- a/Projectiles/Ranged/AstralRound.cs +++ b/Projectiles/Ranged/AstralRound.cs @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Ranged if (speed == 0f) speed = projectile.velocity.Length(); - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, speed, 12f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, speed, 12f); return false; } diff --git a/Projectiles/Ranged/AstrealFlame.cs b/Projectiles/Ranged/AstrealFlame.cs index 41cfd23d61..1ad7677ee2 100644 --- a/Projectiles/Ranged/AstrealFlame.cs +++ b/Projectiles/Ranged/AstrealFlame.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.frame = 0; if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 600f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Ranged/BigNuke.cs b/Projectiles/Ranged/BigNuke.cs index 44b927fc07..b8e1367877 100644 --- a/Projectiles/Ranged/BigNuke.cs +++ b/Projectiles/Ranged/BigNuke.cs @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[num249].velocity *= 0.05f; } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override bool OnTileCollide(Vector2 oldVelocity) diff --git a/Projectiles/Ranged/BloodfireArrowProj.cs b/Projectiles/Ranged/BloodfireArrowProj.cs index 2caec238b0..675e8d329f 100644 --- a/Projectiles/Ranged/BloodfireArrowProj.cs +++ b/Projectiles/Ranged/BloodfireArrowProj.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Ranged } if (projectile.ai[1] == 80f) //means it's from Arterial Assault's wooden arrow conversion - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Ranged/CardClubSplit.cs b/Projectiles/Ranged/CardClubSplit.cs index f91eef94a6..b32aa6aa96 100644 --- a/Projectiles/Ranged/CardClubSplit.cs +++ b/Projectiles/Ranged/CardClubSplit.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Projectiles.Ranged if (projectile.alpha < 128) { - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 300f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 20f); } } diff --git a/Projectiles/Ranged/ClamorRifleProj.cs b/Projectiles/Ranged/ClamorRifleProj.cs index 5c4de46ac4..0f3bc0490e 100644 --- a/Projectiles/Ranged/ClamorRifleProj.cs +++ b/Projectiles/Ranged/ClamorRifleProj.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[num155].velocity += projectile.velocity * 0.5f; } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 150f, 12f, 25f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 150f, 12f, 25f); } /*public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Ranged/ClamorRifleProjSplit.cs b/Projectiles/Ranged/ClamorRifleProjSplit.cs index ef578c3f60..14b6ffc0da 100644 --- a/Projectiles/Ranged/ClamorRifleProjSplit.cs +++ b/Projectiles/Ranged/ClamorRifleProjSplit.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Projectiles.Ranged } if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 450f, 12f, 25f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 12f, 25f); } /* override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Ranged/FishronRPG.cs b/Projectiles/Ranged/FishronRPG.cs index 34993fbc0a..3a7e947ebd 100644 --- a/Projectiles/Ranged/FishronRPG.cs +++ b/Projectiles/Ranged/FishronRPG.cs @@ -76,7 +76,7 @@ namespace CalamityMod.Projectiles.Ranged } } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override bool OnTileCollide(Vector2 oldVelocity) diff --git a/Projectiles/Ranged/FungiOrb2.cs b/Projectiles/Ranged/FungiOrb2.cs index 002a63cfc9..ec3d69c4d2 100644 --- a/Projectiles/Ranged/FungiOrb2.cs +++ b/Projectiles/Ranged/FungiOrb2.cs @@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.Ranged } if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 450f, 6f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 6f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Ranged/MiniRocket.cs b/Projectiles/Ranged/MiniRocket.cs index b81c11cf56..d832f23a71 100644 --- a/Projectiles/Ranged/MiniRocket.cs +++ b/Projectiles/Ranged/MiniRocket.cs @@ -65,7 +65,7 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[num249].velocity *= 0.05f; } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Ranged/Minibirb.cs b/Projectiles/Ranged/Minibirb.cs index 6a455c9bc7..99d25e0ba9 100644 --- a/Projectiles/Ranged/Minibirb.cs +++ b/Projectiles/Ranged/Minibirb.cs @@ -56,7 +56,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? MathHelper.Pi : 0f); - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 300f, 10f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 10f, 20f); } } } diff --git a/Projectiles/Ranged/PlanetaryAnnihilationProj.cs b/Projectiles/Ranged/PlanetaryAnnihilationProj.cs index 2807ed41be..2efbf38199 100644 --- a/Projectiles/Ranged/PlanetaryAnnihilationProj.cs +++ b/Projectiles/Ranged/PlanetaryAnnihilationProj.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[num469].noGravity = true; Main.dust[num469].velocity *= 0f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Ranged/PolarStar.cs b/Projectiles/Ranged/PolarStar.cs index 5adde0e561..1a1ad3f71b 100644 --- a/Projectiles/Ranged/PolarStar.cs +++ b/Projectiles/Ranged/PolarStar.cs @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Ranged } if (projectile.ai[1] == 2f) //Boost three { - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } else if (projectile.ai[1] == 1f) //Boost two { diff --git a/Projectiles/Ranged/RainbowBlast.cs b/Projectiles/Ranged/RainbowBlast.cs index 0baec808fa..159a069a2d 100644 --- a/Projectiles/Ranged/RainbowBlast.cs +++ b/Projectiles/Ranged/RainbowBlast.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[num469].velocity = dspeed; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Ranged/SeaDragonRocket.cs b/Projectiles/Ranged/SeaDragonRocket.cs index e75b6b39b0..4e3592c4c7 100644 --- a/Projectiles/Ranged/SeaDragonRocket.cs +++ b/Projectiles/Ranged/SeaDragonRocket.cs @@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Ranged } } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Ranged/SicknessRound2.cs b/Projectiles/Ranged/SicknessRound2.cs index 7738a5519d..2b77b4363b 100644 --- a/Projectiles/Ranged/SicknessRound2.cs +++ b/Projectiles/Ranged/SicknessRound2.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) + MathHelper.ToRadians(90) * projectile.direction; if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 450f, 12f, 25f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 12f, 25f); return false; } diff --git a/Projectiles/Ranged/SputterCometBig.cs b/Projectiles/Ranged/SputterCometBig.cs index 2af8ba7525..019dc6374a 100644 --- a/Projectiles/Ranged/SputterCometBig.cs +++ b/Projectiles/Ranged/SputterCometBig.cs @@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.Ranged Main.PlaySound(SoundID.Item9, projectile.position); } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 150f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 150f, 12f, 20f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Ranged/TerraArrowSplit.cs b/Projectiles/Ranged/TerraArrowSplit.cs index 5bb98f459d..a44a9e22a7 100644 --- a/Projectiles/Ranged/TerraArrowSplit.cs +++ b/Projectiles/Ranged/TerraArrowSplit.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; if (projectile.timeLeft < 90) - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 450f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 12f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Ranged/TerraBulletSplit.cs b/Projectiles/Ranged/TerraBulletSplit.cs index 0e7e763a9e..123160eef0 100644 --- a/Projectiles/Ranged/TerraBulletSplit.cs +++ b/Projectiles/Ranged/TerraBulletSplit.cs @@ -65,7 +65,7 @@ namespace CalamityMod.Projectiles.Ranged speed = projectile.velocity.Length(); if (projectile.timeLeft < 90) - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 450f, speed, 12f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, speed, 12f); } } } diff --git a/Projectiles/Ranged/ThePackMinissile.cs b/Projectiles/Ranged/ThePackMinissile.cs index 30a04d008e..aa9fe01b38 100644 --- a/Projectiles/Ranged/ThePackMinissile.cs +++ b/Projectiles/Ranged/ThePackMinissile.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X); - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 300f, 12f, 15f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 15f); projectile.frameCounter++; if (projectile.frameCounter > 3) { diff --git a/Projectiles/Rogue/CobaltEnergy.cs b/Projectiles/Rogue/CobaltEnergy.cs index 1fbe717762..3d8a030cb1 100644 --- a/Projectiles/Rogue/CobaltEnergy.cs +++ b/Projectiles/Rogue/CobaltEnergy.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Rogue if (!hasHitEnemy && projectile.timeLeft < 575) { - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } else if (hasHitEnemy) { diff --git a/Projectiles/Rogue/Crushax.cs b/Projectiles/Rogue/Crushax.cs index da72366dbe..1381d861d5 100644 --- a/Projectiles/Rogue/Crushax.cs +++ b/Projectiles/Rogue/Crushax.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override bool OnTileCollide(Vector2 oldVelocity) diff --git a/Projectiles/Rogue/DeepSeaDumbbell2.cs b/Projectiles/Rogue/DeepSeaDumbbell2.cs index 5d3799cc06..90c9672d52 100644 --- a/Projectiles/Rogue/DeepSeaDumbbell2.cs +++ b/Projectiles/Rogue/DeepSeaDumbbell2.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.ai[0] += 1f; else { - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 300f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 20f); } projectile.rotation += Math.Abs(projectile.velocity.X) * 0.01f * (float)projectile.direction; diff --git a/Projectiles/Rogue/DeepSeaDumbbell3.cs b/Projectiles/Rogue/DeepSeaDumbbell3.cs index 821e073b67..49758ee5e9 100644 --- a/Projectiles/Rogue/DeepSeaDumbbell3.cs +++ b/Projectiles/Rogue/DeepSeaDumbbell3.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.ai[0] += 1f; else { - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 300f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 20f); } projectile.rotation += Math.Abs(projectile.velocity.X) * 0.01f * (float)projectile.direction; diff --git a/Projectiles/Rogue/GacruxianHome.cs b/Projectiles/Rogue/GacruxianHome.cs index 3af56fd1f7..f3502d90a7 100644 --- a/Projectiles/Rogue/GacruxianHome.cs +++ b/Projectiles/Rogue/GacruxianHome.cs @@ -47,7 +47,7 @@ namespace CalamityMod.Projectiles.Rogue Main.projectile[proj].penetrate = 3; } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 250f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 250f, 12f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Rogue/LostSoulFriendly.cs b/Projectiles/Rogue/LostSoulFriendly.cs index 3de9a9002e..9aad503dc5 100644 --- a/Projectiles/Rogue/LostSoulFriendly.cs +++ b/Projectiles/Rogue/LostSoulFriendly.cs @@ -46,7 +46,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); if (projectile.ai[0] != 1f && projectile.timeLeft < 210) - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 600f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Rogue/LunarKunaiProj.cs b/Projectiles/Rogue/LunarKunaiProj.cs index c5c35db273..60fd36b6ce 100644 --- a/Projectiles/Rogue/LunarKunaiProj.cs +++ b/Projectiles/Rogue/LunarKunaiProj.cs @@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.frame = 0; projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, lunarEnhance ? 300f : 150f, lunarEnhance ? 12f : 8f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, lunarEnhance ? 300f : 150f, lunarEnhance ? 12f : 8f, 20f); if (Main.rand.Next(6) == 0 && lunarEnhance) Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 229, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } diff --git a/Projectiles/Rogue/MoonSigil.cs b/Projectiles/Rogue/MoonSigil.cs index d4204923e6..af64e67075 100644 --- a/Projectiles/Rogue/MoonSigil.cs +++ b/Projectiles/Rogue/MoonSigil.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Rogue return; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 300f, 8f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 8f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Rogue/Prismalline3.cs b/Projectiles/Rogue/Prismalline3.cs index 945c21ea12..2484329355 100644 --- a/Projectiles/Rogue/Prismalline3.cs +++ b/Projectiles/Rogue/Prismalline3.cs @@ -25,10 +25,14 @@ namespace CalamityMod.Projectiles.Rogue projectile.Calamity().rogue = true; } - public override void AI() + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + + public override void AI() { projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(45f); - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 150f, 12f, 20f); + + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 12f, 20f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/ProfanedPartisanSpear.cs b/Projectiles/Rogue/ProfanedPartisanSpear.cs index ef6b67cef4..fd54a84369 100644 --- a/Projectiles/Rogue/ProfanedPartisanSpear.cs +++ b/Projectiles/Rogue/ProfanedPartisanSpear.cs @@ -86,7 +86,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.penetrate = 1; if (timer >= 10) { - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 300f, 7f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 7f, 20f); } } diff --git a/Projectiles/Rogue/RadiantStar2.cs b/Projectiles/Rogue/RadiantStar2.cs index f2f7c0d964..6b071842a8 100644 --- a/Projectiles/Rogue/RadiantStar2.cs +++ b/Projectiles/Rogue/RadiantStar2.cs @@ -31,7 +31,9 @@ namespace CalamityMod.Projectiles.Rogue projectile.Calamity().rogue = true; } - public override void AI() + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 270; + + public override void AI() { projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(45f); if (projectile.ai[0] == 1f) @@ -69,10 +71,8 @@ namespace CalamityMod.Projectiles.Rogue } } } - else - { - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, projectile.Calamity().stealthStrike ? 300f : 150f, 12f, 20f); - } + else if (projectile.timeLeft < 270) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, projectile.Calamity().stealthStrike ? 900f : 450f, 12f, 20f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Rogue/SkyfinNuke.cs b/Projectiles/Rogue/SkyfinNuke.cs index 27a7a3c380..f8ce36f5f3 100644 --- a/Projectiles/Rogue/SkyfinNuke.cs +++ b/Projectiles/Rogue/SkyfinNuke.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Rogue else { //More range - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, homingRange, speedMult, turnSpeed); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, homingRange, speedMult, turnSpeed); } } diff --git a/Projectiles/Rogue/TurbulanceWindSlash.cs b/Projectiles/Rogue/TurbulanceWindSlash.cs index 8870070baa..46223a9b51 100644 --- a/Projectiles/Rogue/TurbulanceWindSlash.cs +++ b/Projectiles/Rogue/TurbulanceWindSlash.cs @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Rogue } if (projectile.ai[1] == 1f) { - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, projectile.ai[0] == 1f ? 900f : 450f, 8f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, projectile.ai[0] == 1f ? 900f : 450f, 8f, 20f); } } diff --git a/Projectiles/Typeless/ChaosFlare.cs b/Projectiles/Typeless/ChaosFlare.cs index 80bc7859d7..b3b6a248cf 100644 --- a/Projectiles/Typeless/ChaosFlare.cs +++ b/Projectiles/Typeless/ChaosFlare.cs @@ -25,14 +25,18 @@ namespace CalamityMod.Projectiles.Typeless projectile.extraUpdates = 1; } - public override void AI() + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90; + + public override void AI() { - Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.25f / 255f, (255 - projectile.alpha) * 0f / 255f); + Lighting.AddLight(projectile.Center, 0.5f, 0.25f, 0f); + if (projectile.localAI[0] == 0f) { Main.PlaySound(SoundID.Item20, (int)projectile.position.X, (int)projectile.position.Y); projectile.localAI[0] += 1f; } + for (int num457 = 0; num457 < 6; num457++) { int num458 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 127, 0f, 0f, 100, default, 1.2f); @@ -40,7 +44,9 @@ namespace CalamityMod.Projectiles.Typeless Main.dust[num458].velocity *= 0.5f; Main.dust[num458].velocity += projectile.velocity * 0.1f; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 150f, 12f, 20f); + + if (projectile.timeLeft < 90) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 12f, 20f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Typeless/ChaosFlare2.cs b/Projectiles/Typeless/ChaosFlare2.cs index 43fd3163c8..efdc08d0b8 100644 --- a/Projectiles/Typeless/ChaosFlare2.cs +++ b/Projectiles/Typeless/ChaosFlare2.cs @@ -25,14 +25,19 @@ namespace CalamityMod.Projectiles.Typeless projectile.extraUpdates = 2; } + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 270; + public override void AI() { - Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.25f / 255f, (255 - projectile.alpha) * 0f / 255f); + Lighting.AddLight(projectile.Center, 0.5f, 0.25f, 0f); + int num458 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 127, 0f, 0f, 100, default, 2f); Main.dust[num458].noGravity = true; Main.dust[num458].velocity *= 0.5f; Main.dust[num458].velocity += projectile.velocity * 0.1f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 250f, 11f, 20f); + + if (projectile.timeLeft < 270) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 250f, 11f, 20f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Typeless/GodSlayerPhantom.cs b/Projectiles/Typeless/GodSlayerPhantom.cs index 2c7aa3b98a..9353b7572a 100644 --- a/Projectiles/Typeless/GodSlayerPhantom.cs +++ b/Projectiles/Typeless/GodSlayerPhantom.cs @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Typeless projectile.velocity = (projectile.velocity * (num953 - 1f) + vector102 * scaleFactor12) / num953; return; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } else { diff --git a/Projectiles/Typeless/VanquisherArrowSplit.cs b/Projectiles/Typeless/VanquisherArrowSplit.cs index 118b54c852..9f82647636 100644 --- a/Projectiles/Typeless/VanquisherArrowSplit.cs +++ b/Projectiles/Typeless/VanquisherArrowSplit.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Utilities/DropHelper.cs b/Utilities/DropHelper.cs index d7ea1e9509..52af1999df 100644 --- a/Utilities/DropHelper.cs +++ b/Utilities/DropHelper.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Ammo.FiniteUse; +using CalamityMod.NPCs; using CalamityMod.World; using Microsoft.Xna.Framework; using System.Collections.Generic; @@ -319,10 +320,10 @@ namespace CalamityMod /// Drops the correct number of boss bags for Armageddon. ///
/// The NPC to drop boss bags for. - /// The number of boss bags dropped. + /// The number of boss bags dropped. No bags are dropped if the boss has been downed already. public static int DropArmageddonBags(NPC theBoss) { - if (!CalamityWorld.armageddon) + if (!CalamityWorld.armageddon || CalamityGlobalNPC.GetDownedBossVariable(theBoss.type)) return 0; for (int i = 0; i < ArmageddonExtraBags; ++i) From 63e02ec355eada0a0de831536498d9197824274e Mon Sep 17 00:00:00 2001 From: Andrew Marheine Date: Tue, 13 Apr 2021 18:13:41 -0500 Subject: [PATCH 31/32] 1 - Certain projectiles can no longer hit town NPCs. --- Projectiles/DraedonsArsenal/PulseRifleShot.cs | 2 +- Projectiles/Enemy/ToxicMinnowCloud.cs | 18 ++---------------- Projectiles/Magic/BeamingBolt2.cs | 2 +- Projectiles/Magic/BlueBubble.cs | 2 +- Projectiles/Magic/BrimstoneHomer.cs | 2 +- Projectiles/Magic/GhastlyExplosionShard.cs | 2 +- Projectiles/Magic/GleamingBolt2.cs | 2 +- Projectiles/Magic/GraniteEnergy.cs | 2 +- .../Magic/MadAlchemistsCocktailShrapnel.cs | 2 +- Projectiles/Magic/ManaBoltSmall.cs | 2 +- Projectiles/Magic/VividLaser2.cs | 16 +++------------- Projectiles/Melee/Blood.cs | 2 +- Projectiles/Melee/Blood2.cs | 2 +- Projectiles/Melee/BonebreakerProjectile.cs | 9 +-------- Projectiles/Melee/Brimlash2.cs | 2 +- Projectiles/Melee/EssenceFlame2.cs | 2 +- Projectiles/Melee/Exocomet.cs | 2 +- Projectiles/Melee/HolyColliderHolyFire.cs | 2 +- Projectiles/Melee/Leech.cs | 2 +- Projectiles/Melee/NightStabber.cs | 2 +- Projectiles/Melee/PlagueSeeker.cs | 2 +- Projectiles/Melee/PwnagehammerEcho.cs | 12 ++---------- Projectiles/Melee/RainBolt.cs | 2 +- Projectiles/Melee/ScourgeoftheCosmosMini.cs | 2 +- Projectiles/Melee/TinyCrystal.cs | 2 +- Projectiles/Melee/TinyFlare.cs | 2 +- Projectiles/Ranged/AquashardSplit.cs | 2 +- Projectiles/Ranged/AstrealFlame.cs | 2 +- Projectiles/Ranged/ClamorRifleProjSplit.cs | 2 +- Projectiles/Ranged/FungiOrb2.cs | 2 +- Projectiles/Ranged/SandyWaifuShark.cs | 2 +- Projectiles/Ranged/SicknessRound2.cs | 2 +- Projectiles/Ranged/TerraArrowSplit.cs | 2 +- Projectiles/Ranged/TerraBulletSplit.cs | 2 +- Projectiles/Ranged/VeriumBulletProj.cs | 9 +-------- Projectiles/Rogue/CelestialReaperAfterimage.cs | 2 +- Projectiles/Rogue/DesecratedBubble.cs | 16 +++------------- Projectiles/Rogue/EclipsesStealth.cs | 9 +-------- Projectiles/Rogue/LostSoulFriendly.cs | 2 +- Projectiles/Rogue/LuminousShard.cs | 2 +- Projectiles/Rogue/PhantasmalSoul.cs | 2 +- Projectiles/Rogue/Prismalline3.cs | 2 +- Projectiles/Rogue/RadiantStar2.cs | 2 +- Projectiles/Rogue/TheSyringeS1.cs | 2 +- Projectiles/Rogue/TurbulanceWindSlash.cs | 2 +- Projectiles/Rogue/Valaricicle.cs | 2 +- Projectiles/Rogue/Valaricicle2.cs | 2 +- Projectiles/Typeless/AtaxiaOrb.cs | 2 +- Projectiles/Typeless/ChaosFlare.cs | 2 +- Projectiles/Typeless/ChaosFlare2.cs | 2 +- Projectiles/Typeless/CursorProjSplit.cs | 14 ++------------ 51 files changed, 58 insertions(+), 131 deletions(-) diff --git a/Projectiles/DraedonsArsenal/PulseRifleShot.cs b/Projectiles/DraedonsArsenal/PulseRifleShot.cs index a6cf71eb1a..d1412009e6 100644 --- a/Projectiles/DraedonsArsenal/PulseRifleShot.cs +++ b/Projectiles/DraedonsArsenal/PulseRifleShot.cs @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal PulseBurst(4f, 5f); } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 280; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 280 && target.CanBeChasedBy(projectile); public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { diff --git a/Projectiles/Enemy/ToxicMinnowCloud.cs b/Projectiles/Enemy/ToxicMinnowCloud.cs index f4feb53ef0..82efe42b9e 100644 --- a/Projectiles/Enemy/ToxicMinnowCloud.cs +++ b/Projectiles/Enemy/ToxicMinnowCloud.cs @@ -79,28 +79,14 @@ namespace CalamityMod.Projectiles.Enemy } } - public override bool CanHitPlayer(Player target) - { - if (projectile.timeLeft < 40) - { - return false; - } - return true; - } + public override bool CanHitPlayer(Player target) => projectile.timeLeft > 40; public override void OnHitPlayer(Player target, int damage, bool crit) { target.AddBuff(BuffID.Poisoned, 600); } - public override bool? CanHitNPC(NPC target) - { - if (projectile.timeLeft < 40) - { - return false; - } - return null; - } + public override bool? CanHitNPC(NPC target) => projectile.timeLeft > 40; public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { diff --git a/Projectiles/Magic/BeamingBolt2.cs b/Projectiles/Magic/BeamingBolt2.cs index 227f53dfb4..c5fd72da18 100644 --- a/Projectiles/Magic/BeamingBolt2.cs +++ b/Projectiles/Magic/BeamingBolt2.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Magic projectile.magic = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Magic/BlueBubble.cs b/Projectiles/Magic/BlueBubble.cs index 0bbd4c9cc6..8e62069c6d 100644 --- a/Projectiles/Magic/BlueBubble.cs +++ b/Projectiles/Magic/BlueBubble.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Magic projectile.timeLeft = 120; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Magic/BrimstoneHomer.cs b/Projectiles/Magic/BrimstoneHomer.cs index 1a45c24fff..22f7fd7817 100644 --- a/Projectiles/Magic/BrimstoneHomer.cs +++ b/Projectiles/Magic/BrimstoneHomer.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Magic projectile.timeLeft = 180; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Magic/GhastlyExplosionShard.cs b/Projectiles/Magic/GhastlyExplosionShard.cs index 44fc7c6fc9..bc39226c3b 100644 --- a/Projectiles/Magic/GhastlyExplosionShard.cs +++ b/Projectiles/Magic/GhastlyExplosionShard.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Magic projectile.magic = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 50; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 50 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Magic/GleamingBolt2.cs b/Projectiles/Magic/GleamingBolt2.cs index c52b87bfe1..3c2e79cc99 100644 --- a/Projectiles/Magic/GleamingBolt2.cs +++ b/Projectiles/Magic/GleamingBolt2.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Magic projectile.magic = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Magic/GraniteEnergy.cs b/Projectiles/Magic/GraniteEnergy.cs index 892578be7d..07156b0a76 100644 --- a/Projectiles/Magic/GraniteEnergy.cs +++ b/Projectiles/Magic/GraniteEnergy.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Magic projectile.timeLeft = 90; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 60; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 60 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Magic/MadAlchemistsCocktailShrapnel.cs b/Projectiles/Magic/MadAlchemistsCocktailShrapnel.cs index 2623c7d651..258fa2ba58 100644 --- a/Projectiles/Magic/MadAlchemistsCocktailShrapnel.cs +++ b/Projectiles/Magic/MadAlchemistsCocktailShrapnel.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Magic projectile.extraUpdates = 1; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Magic/ManaBoltSmall.cs b/Projectiles/Magic/ManaBoltSmall.cs index b5ae75f9aa..4ab8bc09a8 100644 --- a/Projectiles/Magic/ManaBoltSmall.cs +++ b/Projectiles/Magic/ManaBoltSmall.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Magic projectile.magic = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 40; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 40 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Magic/VividLaser2.cs b/Projectiles/Magic/VividLaser2.cs index efe1637bcb..4147656221 100644 --- a/Projectiles/Magic/VividLaser2.cs +++ b/Projectiles/Magic/VividLaser2.cs @@ -70,19 +70,9 @@ namespace CalamityMod.Projectiles.Magic target.ExoDebuffs(); } - // Cannot deal damage for the first several frames of existence. - public override bool? CanHitNPC(NPC target) - { - if (projectile.timeLeft >= 110) - { - return false; - } - return null; - } + // Cannot deal damage for the first several frames of existence. + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 110; - public override bool CanHitPvp(Player target) - { - return projectile.timeLeft < 110; - } + public override bool CanHitPvp(Player target) => projectile.timeLeft < 110; } } diff --git a/Projectiles/Melee/Blood.cs b/Projectiles/Melee/Blood.cs index 8c2514c89b..4da978c197 100644 --- a/Projectiles/Melee/Blood.cs +++ b/Projectiles/Melee/Blood.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Melee projectile.timeLeft = 180; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Melee/Blood2.cs b/Projectiles/Melee/Blood2.cs index d4cbfb19ee..f55ebc98ae 100644 --- a/Projectiles/Melee/Blood2.cs +++ b/Projectiles/Melee/Blood2.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Melee projectile.timeLeft = 150; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 120; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 120 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Melee/BonebreakerProjectile.cs b/Projectiles/Melee/BonebreakerProjectile.cs index 704f138600..6020ec3daa 100644 --- a/Projectiles/Melee/BonebreakerProjectile.cs +++ b/Projectiles/Melee/BonebreakerProjectile.cs @@ -110,14 +110,7 @@ namespace CalamityMod.Projectiles.Melee target.AddBuff(ModContent.BuffType(), 240); } - public override bool? CanHitNPC(NPC target) - { - if (projectile.ai[0] == 1f) - { - return false; - } - return null; - } + public override bool? CanHitNPC(NPC target) => projectile.ai[0] != 1f; public override bool CanHitPvp(Player target) => projectile.ai[0] != 1f; } diff --git a/Projectiles/Melee/Brimlash2.cs b/Projectiles/Melee/Brimlash2.cs index 93ea5af1fd..c8c52d1ccb 100644 --- a/Projectiles/Melee/Brimlash2.cs +++ b/Projectiles/Melee/Brimlash2.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Melee projectile.timeLeft = 120; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Melee/EssenceFlame2.cs b/Projectiles/Melee/EssenceFlame2.cs index fc3403403c..4ac31bb0fe 100644 --- a/Projectiles/Melee/EssenceFlame2.cs +++ b/Projectiles/Melee/EssenceFlame2.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Melee projectile.extraUpdates = 3; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Melee/Exocomet.cs b/Projectiles/Melee/Exocomet.cs index 8c94e17a19..beda999085 100644 --- a/Projectiles/Melee/Exocomet.cs +++ b/Projectiles/Melee/Exocomet.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Melee projectile.timeLeft = 360; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 240; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 240 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Melee/HolyColliderHolyFire.cs b/Projectiles/Melee/HolyColliderHolyFire.cs index afcc0b639e..60b5fd08f2 100644 --- a/Projectiles/Melee/HolyColliderHolyFire.cs +++ b/Projectiles/Melee/HolyColliderHolyFire.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Melee projectile.timeLeft = 90; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 75; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 75 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Melee/Leech.cs b/Projectiles/Melee/Leech.cs index 28c6540f85..b9de3fbfaa 100644 --- a/Projectiles/Melee/Leech.cs +++ b/Projectiles/Melee/Leech.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Melee projectile.melee = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Melee/NightStabber.cs b/Projectiles/Melee/NightStabber.cs index cd8a418258..c7c57a7b87 100644 --- a/Projectiles/Melee/NightStabber.cs +++ b/Projectiles/Melee/NightStabber.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Melee projectile.melee = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Melee/PlagueSeeker.cs b/Projectiles/Melee/PlagueSeeker.cs index 0f8ddbac50..5091e4cb7c 100644 --- a/Projectiles/Melee/PlagueSeeker.cs +++ b/Projectiles/Melee/PlagueSeeker.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Melee projectile.extraUpdates = 1; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Melee/PwnagehammerEcho.cs b/Projectiles/Melee/PwnagehammerEcho.cs index 244d4fd9b8..ff2fab74e3 100644 --- a/Projectiles/Melee/PwnagehammerEcho.cs +++ b/Projectiles/Melee/PwnagehammerEcho.cs @@ -89,17 +89,9 @@ namespace CalamityMod.Projectiles.Melee } } - public override bool? CanHitNPC(NPC target) - { - if (projectile.ai[0] <= 42f) - return false; - return null; - } + public override bool? CanHitNPC(NPC target) => projectile.ai[0] > 42f; - public override bool CanHitPvp(Player target) - { - return projectile.ai[0] > 42f; - } + public override bool CanHitPvp(Player target) => projectile.ai[0] > 42f; public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { diff --git a/Projectiles/Melee/RainBolt.cs b/Projectiles/Melee/RainBolt.cs index af92adcf1e..a1817ae411 100644 --- a/Projectiles/Melee/RainBolt.cs +++ b/Projectiles/Melee/RainBolt.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Melee projectile.timeLeft = 180; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Melee/ScourgeoftheCosmosMini.cs b/Projectiles/Melee/ScourgeoftheCosmosMini.cs index 3e322794da..10173ef279 100644 --- a/Projectiles/Melee/ScourgeoftheCosmosMini.cs +++ b/Projectiles/Melee/ScourgeoftheCosmosMini.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Melee projectile.extraUpdates = 3; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 270; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 270 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Melee/TinyCrystal.cs b/Projectiles/Melee/TinyCrystal.cs index 3fce8b2801..c4ce4ad91a 100644 --- a/Projectiles/Melee/TinyCrystal.cs +++ b/Projectiles/Melee/TinyCrystal.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Melee projectile.timeLeft = 90; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 75; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 75 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Melee/TinyFlare.cs b/Projectiles/Melee/TinyFlare.cs index 684f8e4ccd..55762268fa 100644 --- a/Projectiles/Melee/TinyFlare.cs +++ b/Projectiles/Melee/TinyFlare.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Melee projectile.extraUpdates = 1; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Ranged/AquashardSplit.cs b/Projectiles/Ranged/AquashardSplit.cs index 40c8692781..9b0f5db1f6 100644 --- a/Projectiles/Ranged/AquashardSplit.cs +++ b/Projectiles/Ranged/AquashardSplit.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.aiStyle = 1; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Ranged/AstrealFlame.cs b/Projectiles/Ranged/AstrealFlame.cs index 1ad7677ee2..0bbca59048 100644 --- a/Projectiles/Ranged/AstrealFlame.cs +++ b/Projectiles/Ranged/AstrealFlame.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.alpha = 255; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Ranged/ClamorRifleProjSplit.cs b/Projectiles/Ranged/ClamorRifleProjSplit.cs index 14b6ffc0da..1c6bd95dae 100644 --- a/Projectiles/Ranged/ClamorRifleProjSplit.cs +++ b/Projectiles/Ranged/ClamorRifleProjSplit.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Ranged/FungiOrb2.cs b/Projectiles/Ranged/FungiOrb2.cs index ec3d69c4d2..241dea6b6b 100644 --- a/Projectiles/Ranged/FungiOrb2.cs +++ b/Projectiles/Ranged/FungiOrb2.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.timeLeft = 180; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Ranged/SandyWaifuShark.cs b/Projectiles/Ranged/SandyWaifuShark.cs index 9d57932272..33c2e01724 100644 --- a/Projectiles/Ranged/SandyWaifuShark.cs +++ b/Projectiles/Ranged/SandyWaifuShark.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.timeLeft = 240; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 210; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 210 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Ranged/SicknessRound2.cs b/Projectiles/Ranged/SicknessRound2.cs index 2b77b4363b..6d90d0a8e4 100644 --- a/Projectiles/Ranged/SicknessRound2.cs +++ b/Projectiles/Ranged/SicknessRound2.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Ranged aiType = ProjectileID.WoodenArrowFriendly; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Ranged/TerraArrowSplit.cs b/Projectiles/Ranged/TerraArrowSplit.cs index a44a9e22a7..281e5dc197 100644 --- a/Projectiles/Ranged/TerraArrowSplit.cs +++ b/Projectiles/Ranged/TerraArrowSplit.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.aiStyle = 1; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Ranged/TerraBulletSplit.cs b/Projectiles/Ranged/TerraBulletSplit.cs index 123160eef0..449eee3399 100644 --- a/Projectiles/Ranged/TerraBulletSplit.cs +++ b/Projectiles/Ranged/TerraBulletSplit.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Ranged aiType = ProjectileID.Bullet; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Ranged/VeriumBulletProj.cs b/Projectiles/Ranged/VeriumBulletProj.cs index 64d9a5ded7..6324b18c2a 100644 --- a/Projectiles/Ranged/VeriumBulletProj.cs +++ b/Projectiles/Ranged/VeriumBulletProj.cs @@ -116,14 +116,7 @@ namespace CalamityMod.Projectiles.Ranged return true; } - public override bool? CanHitNPC(NPC target) - { - if (projectile.ai[0] > 0f) - { - return false; - } - return null; - } + public override bool? CanHitNPC(NPC target) => projectile.ai[0] <= 0f; public override bool CanHitPvp(Player target) => projectile.ai[0] <= 0f; diff --git a/Projectiles/Rogue/CelestialReaperAfterimage.cs b/Projectiles/Rogue/CelestialReaperAfterimage.cs index 1d4a0f8317..47ce05b8f9 100644 --- a/Projectiles/Rogue/CelestialReaperAfterimage.cs +++ b/Projectiles/Rogue/CelestialReaperAfterimage.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.timeLeft = 180; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Rogue/DesecratedBubble.cs b/Projectiles/Rogue/DesecratedBubble.cs index b403f91cff..67965c5e3a 100644 --- a/Projectiles/Rogue/DesecratedBubble.cs +++ b/Projectiles/Rogue/DesecratedBubble.cs @@ -82,19 +82,9 @@ namespace CalamityMod.Projectiles.Rogue } } - // Cannot deal damage for the first several frames of existence. - public override bool? CanHitNPC(NPC target) - { - if (projectile.timeLeft >= 100) - { - return false; - } - return null; - } + // Cannot deal damage for the first several frames of existence. + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 100; - public override bool CanHitPvp(Player target) - { - return projectile.timeLeft < 100; - } + public override bool CanHitPvp(Player target) => projectile.timeLeft < 100; } } \ No newline at end of file diff --git a/Projectiles/Rogue/EclipsesStealth.cs b/Projectiles/Rogue/EclipsesStealth.cs index 65cdb57cb0..8f3e81bde2 100644 --- a/Projectiles/Rogue/EclipsesStealth.cs +++ b/Projectiles/Rogue/EclipsesStealth.cs @@ -90,14 +90,7 @@ namespace CalamityMod.Projectiles.Rogue return false; } - public override bool? CanHitNPC(NPC target) - { - if (projectile.ai[0] == 1f) - { - return false; - } - return null; - } + public override bool? CanHitNPC(NPC target) => projectile.ai[0] != 1f; public override bool CanHitPvp(Player target) => projectile.ai[0] != 1f; } diff --git a/Projectiles/Rogue/LostSoulFriendly.cs b/Projectiles/Rogue/LostSoulFriendly.cs index 9aad503dc5..480d759d1c 100644 --- a/Projectiles/Rogue/LostSoulFriendly.cs +++ b/Projectiles/Rogue/LostSoulFriendly.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.alpha = 150; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 210; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 210 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Rogue/LuminousShard.cs b/Projectiles/Rogue/LuminousShard.cs index 6d5fe0c9c2..13ae3aa831 100644 --- a/Projectiles/Rogue/LuminousShard.cs +++ b/Projectiles/Rogue/LuminousShard.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.Calamity().rogue = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Rogue/PhantasmalSoul.cs b/Projectiles/Rogue/PhantasmalSoul.cs index 6ec8979684..ebdd9fb1fd 100644 --- a/Projectiles/Rogue/PhantasmalSoul.cs +++ b/Projectiles/Rogue/PhantasmalSoul.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.timeLeft = Lifetime; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < Lifetime - NoHomingFrames; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < Lifetime - NoHomingFrames && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Rogue/Prismalline3.cs b/Projectiles/Rogue/Prismalline3.cs index 2484329355..f7837120e8 100644 --- a/Projectiles/Rogue/Prismalline3.cs +++ b/Projectiles/Rogue/Prismalline3.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.Calamity().rogue = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Rogue/RadiantStar2.cs b/Projectiles/Rogue/RadiantStar2.cs index 6b071842a8..6f4ee3b57b 100644 --- a/Projectiles/Rogue/RadiantStar2.cs +++ b/Projectiles/Rogue/RadiantStar2.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.Calamity().rogue = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 270; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 270 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Rogue/TheSyringeS1.cs b/Projectiles/Rogue/TheSyringeS1.cs index 03495b70b2..a3eb0bb390 100644 --- a/Projectiles/Rogue/TheSyringeS1.cs +++ b/Projectiles/Rogue/TheSyringeS1.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.Calamity().rogue = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); public override void PostAI() { diff --git a/Projectiles/Rogue/TurbulanceWindSlash.cs b/Projectiles/Rogue/TurbulanceWindSlash.cs index 46223a9b51..60ae74c45b 100644 --- a/Projectiles/Rogue/TurbulanceWindSlash.cs +++ b/Projectiles/Rogue/TurbulanceWindSlash.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.timeLeft = 180; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Rogue/Valaricicle.cs b/Projectiles/Rogue/Valaricicle.cs index 5c40e27c53..4cf1eef705 100644 --- a/Projectiles/Rogue/Valaricicle.cs +++ b/Projectiles/Rogue/Valaricicle.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.coldDamage = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Rogue/Valaricicle2.cs b/Projectiles/Rogue/Valaricicle2.cs index 0cc49a54be..3627bbe3da 100644 --- a/Projectiles/Rogue/Valaricicle2.cs +++ b/Projectiles/Rogue/Valaricicle2.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.coldDamage = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Typeless/AtaxiaOrb.cs b/Projectiles/Typeless/AtaxiaOrb.cs index fb480c6b54..a6544f5859 100644 --- a/Projectiles/Typeless/AtaxiaOrb.cs +++ b/Projectiles/Typeless/AtaxiaOrb.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Typeless projectile.timeLeft = 200; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 170; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 170 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Typeless/ChaosFlare.cs b/Projectiles/Typeless/ChaosFlare.cs index b3b6a248cf..04869804f8 100644 --- a/Projectiles/Typeless/ChaosFlare.cs +++ b/Projectiles/Typeless/ChaosFlare.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Typeless projectile.extraUpdates = 1; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Typeless/ChaosFlare2.cs b/Projectiles/Typeless/ChaosFlare2.cs index efdc08d0b8..3f26337b07 100644 --- a/Projectiles/Typeless/ChaosFlare2.cs +++ b/Projectiles/Typeless/ChaosFlare2.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Typeless projectile.extraUpdates = 2; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 270; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 270 && target.CanBeChasedBy(projectile); public override void AI() { diff --git a/Projectiles/Typeless/CursorProjSplit.cs b/Projectiles/Typeless/CursorProjSplit.cs index c06e659950..12e4a3fe56 100644 --- a/Projectiles/Typeless/CursorProjSplit.cs +++ b/Projectiles/Typeless/CursorProjSplit.cs @@ -201,19 +201,9 @@ namespace CalamityMod.Projectiles.Typeless target.AddBuff(ModContent.BuffType(), 120); } - public override bool? CanHitNPC(NPC target) - { - if (projectile.alpha >= 128) - { - return false; - } - return null; - } + public override bool? CanHitNPC(NPC target) => projectile.alpha < 128; - public override bool CanHitPvp(Player target) - { - return projectile.alpha < 128; - } + public override bool CanHitPvp(Player target) => projectile.alpha < 128; public override void Kill(int timeLeft) { From a33b98f9a4d3bfd57b506b1a6a2a49df7390c5d7 Mon Sep 17 00:00:00 2001 From: Andrew Marheine Date: Fri, 16 Apr 2021 16:35:07 -0500 Subject: [PATCH 32/32] 1 - Reduced Mechanical Cart speed by 30%. 2 - Reduced Portal Gun fall speed while a boss is alive from 3.5x to 2x. 3 - Made the hardmode progression config option actually do what it's supposed to do. 4 - Teleporters are disabled during boss fights. 5 - Celestial Jewel and Astral Arcanum teleports no longer work if a boss is alive. 6 - Added Malice Mode activation item with placeholder sprite. 7 - Adjusted Alicorn mount offsets a bit. --- Buffs/Pets/SCalPetBuff.cs | 2 +- CalPlayer/CalamityPlayer.cs | 13 +- CalPlayer/CalamityPlayerMiscEffects.cs | 12 +- CalamityMod.cs | 8 +- ILEditing/ILChanges.cs | 42 ++++--- Items/Accessories/AstralArcanum.cs | 2 +- Items/Accessories/CelestialJewel.cs | 2 +- Items/CalamityGlobalItemLoot.cs | 113 ++++++++++-------- Items/DifficultyItems/Malice.cs | 77 ++++++++++++ Items/DifficultyItems/Malice.png | Bin 0 -> 497 bytes Items/Mounts/AlicornMount.cs | 11 +- Items/Placeables/AstralFossil.cs | 8 +- Items/Placeables/AstralSilt.cs | 8 +- Items/TreasureBags/StarterBag.cs | 7 +- Localization/CalamityLocalization.cs | 9 +- NPCs/CalamityGlobalNPC.cs | 39 +++--- NPCs/CalamityGlobalNPCLoot.cs | 28 +++-- .../PlaguebringerGoliath.cs | 21 ---- NPCs/TownNPCs/FAP.cs | 4 +- Projectiles/CalamityGlobalProjectile.cs | 34 +++--- Tiles/CalamityGlobalTile.cs | 2 +- Utilities/NPCUtils.cs | 2 +- 22 files changed, 267 insertions(+), 177 deletions(-) create mode 100644 Items/DifficultyItems/Malice.cs create mode 100644 Items/DifficultyItems/Malice.png diff --git a/Buffs/Pets/SCalPetBuff.cs b/Buffs/Pets/SCalPetBuff.cs index bef829c02f..97c5974f70 100644 --- a/Buffs/Pets/SCalPetBuff.cs +++ b/Buffs/Pets/SCalPetBuff.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Buffs.Pets public override void SetDefaults() { DisplayName.SetDefault("Supreme Calamitas"); - Description.SetDefault("Watching over you with supreme calamitous energy... How adorable"); + Description.SetDefault("Watching over you with supreme calamitous energy...how adorable"); Main.buffNoTimeDisplay[Type] = true; Main.vanityPet[Type] = true; } diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index d71a4ba69f..b3d2901dc5 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -296,10 +296,11 @@ namespace CalamityMod.CalPlayer public AndromedaPlayerState andromedaState; public int andromedaCripple; public const float UnicornSpeedNerfPower = 0.8f; - #endregion + public const float MechanicalCartSpeedNerfPower = 0.7f; + #endregion - #region Pet - public bool thirdSage = false; + #region Pet + public bool thirdSage = false; public bool thirdSageH = true; // Third sage healing public bool perfmini = false; public bool akato = false; @@ -2963,13 +2964,13 @@ namespace CalamityMod.CalPlayer if (prismaticSet && !prismaticCooldown && prismaticLasers <= 0) prismaticLasers = CalamityUtils.SecondsToFrames(35f); } - if (CalamityMod.AstralArcanumUIHotkey.JustPressed && astralArcanum) + if (CalamityMod.AstralArcanumUIHotkey.JustPressed && astralArcanum && !areThereAnyDamnBosses) { AstralArcanumUI.Toggle(); } if (CalamityMod.AstralTeleportHotKey.JustPressed) { - if (celestialJewel) + if (celestialJewel && !areThereAnyDamnBosses) { if (Main.netMode == NetmodeID.SinglePlayer) { @@ -8822,7 +8823,7 @@ namespace CalamityMod.CalPlayer #region Nurse Modifications public override bool ModifyNurseHeal(NPC nurse, ref int health, ref bool removeDebuffs, ref string chatText) { - if (CalamityWorld.death && areThereAnyDamnBosses) + if ((CalamityWorld.death || CalamityWorld.malice) && areThereAnyDamnBosses) { chatText = "Now is not the time!"; return false; diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index c7245767a4..cc4c7d2b2d 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -962,10 +962,14 @@ namespace CalamityMod.CalPlayer { if (player.IsUnderwater() && modPlayer.ironBoots) player.maxFallSpeed = 9f; - if (modPlayer.aeroSet && !player.wet) - player.maxFallSpeed = 15f; - if (modPlayer.gSabatonFall > 0 && !player.wet) - player.maxFallSpeed = 20f; + + if (!player.wet) + { + if (modPlayer.aeroSet) + player.maxFallSpeed = 15f; + if (modPlayer.gSabatonFall > 0 || (player.PortalPhysicsEnabled && CalamityPlayer.areThereAnyDamnBosses)) + player.maxFallSpeed = 20f; + } } // Omega Blue Armor bonus diff --git a/CalamityMod.cs b/CalamityMod.cs index 6f28e75e10..9f74bf5964 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -141,8 +141,10 @@ namespace CalamityMod carpetOriginal = Main.flyingCarpetTexture; Mount.mounts[Mount.Unicorn].dashSpeed *= CalamityPlayer.UnicornSpeedNerfPower; Mount.mounts[Mount.Unicorn].runSpeed *= CalamityPlayer.UnicornSpeedNerfPower; + Mount.mounts[Mount.MinecartMech].dashSpeed *= CalamityPlayer.MechanicalCartSpeedNerfPower; + Mount.mounts[Mount.MinecartMech].runSpeed *= CalamityPlayer.MechanicalCartSpeedNerfPower; - NormalityRelocatorHotKey = RegisterHotKey("Normality Relocator", "Z"); + NormalityRelocatorHotKey = RegisterHotKey("Normality Relocator", "Z"); RageHotKey = RegisterHotKey("Rage Mode", "V"); AdrenalineHotKey = RegisterHotKey("Adrenaline Mode", "B"); AegisHotKey = RegisterHotKey("Elysian Guard", "N"); @@ -316,8 +318,10 @@ namespace CalamityMod } Mount.mounts[Mount.Unicorn].dashSpeed /= CalamityPlayer.UnicornSpeedNerfPower; Mount.mounts[Mount.Unicorn].runSpeed /= CalamityPlayer.UnicornSpeedNerfPower; + Mount.mounts[Mount.MinecartMech].dashSpeed /= CalamityPlayer.MechanicalCartSpeedNerfPower; + Mount.mounts[Mount.MinecartMech].runSpeed /= CalamityPlayer.MechanicalCartSpeedNerfPower; - heartOriginal2 = null; + heartOriginal2 = null; heartOriginal = null; rainOriginal = null; manaOriginal = null; diff --git a/ILEditing/ILChanges.cs b/ILEditing/ILChanges.cs index b994912092..291605d234 100644 --- a/ILEditing/ILChanges.cs +++ b/ILEditing/ILChanges.cs @@ -57,7 +57,7 @@ namespace CalamityMod.ILEditing RemoveAerialBaneDamageBoost(); AdjustDamageVariance(); RemoveExpertHardmodeScaling(); - IncreaseaChlorophyteSpreadChance(); + IncreaseChlorophyteSpreadChance(); ReduceTileBoostedRunSpeeds(); ReduceWingHoverVelocities(); RemoveRNGFromBlackBelt(); @@ -67,6 +67,7 @@ namespace CalamityMod.ILEditing LabDoorFixes(); AlterTownNPCSpawnRate(); DisableDemonAltarGeneration(); + DisableTeleportersDuringBossFights(); FixSplittingWormBannerDrops(); } @@ -139,7 +140,7 @@ namespace CalamityMod.ILEditing }; } - private static void IncreaseaChlorophyteSpreadChance() + private static void IncreaseChlorophyteSpreadChance() { // Change the Chlorophyte spawn rate. IL.Terraria.WorldGen.hardUpdateWorld += (il) => @@ -176,11 +177,11 @@ namespace CalamityMod.ILEditing cursor.GotoNext(MoveType.Before, i => i.MatchLdcR4(1.25f)); // The max run speed multiplier for Frozen Slime Blocks. cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R4, 1.1f); // Reduce by 0.15. + cursor.Emit(OpCodes.Ldc_R4, 1f); // Reduce boost to 0. cursor.GotoNext(MoveType.Before, i => i.MatchLdcR4(1.25f)); // The max run speed multiplier for Ice Blocks. cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R4, 1.1f); // Reduce by 0.15. + cursor.Emit(OpCodes.Ldc_R4, 1f); // Reduce boost to 0. }; } @@ -353,14 +354,9 @@ namespace CalamityMod.ILEditing }; } - private static void DisableDemonAltarGeneration() - { - IL.Terraria.WorldGen.SmashAltar += (il) => - { - var cursor = new ILCursor(il); - cursor.Emit(OpCodes.Ret); - }; - } + private static void DisableDemonAltarGeneration() => On.Terraria.WorldGen.SmashAltar += PreventSmashAltarCode; + + private static void DisableTeleportersDuringBossFights() => On.Terraria.Wiring.Teleport += DisableTeleporters; private static void FixSplittingWormBannerDrops() { @@ -442,10 +438,26 @@ namespace CalamityMod.ILEditing // If it's anything else, let vanilla and/or TML handle it. return orig(i, j, forced); } - #endregion - #region Helper Functions - private static int FindTopOfDoor(int i, int j, Tile rootTile) + private static void PreventSmashAltarCode(On.Terraria.WorldGen.orig_SmashAltar orig, int i, int j) + { + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework) + return; + + orig(i, j); + } + + private static void DisableTeleporters(On.Terraria.Wiring.orig_Teleport orig) + { + if (CalamityPlayer.areThereAnyDamnBosses) + return; + + orig(); + } + #endregion + + #region Helper Functions + private static int FindTopOfDoor(int i, int j, Tile rootTile) { Tile t = Main.tile[i, j]; int topY = j; diff --git a/Items/Accessories/AstralArcanum.cs b/Items/Accessories/AstralArcanum.cs index 63bf2776fd..3fac295c54 100644 --- a/Items/Accessories/AstralArcanum.cs +++ b/Items/Accessories/AstralArcanum.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Items.Accessories { if (line2.mod == "Terraria" && line2.Name == "Tooltip6") { - line2.text = "Press " + hotkey + " to toggle teleportation UI"; + line2.text = "Press " + hotkey + " to toggle teleportation UI while no bosses are alive"; } } } diff --git a/Items/Accessories/CelestialJewel.cs b/Items/Accessories/CelestialJewel.cs index e30dc6d600..4e593c59b4 100644 --- a/Items/Accessories/CelestialJewel.cs +++ b/Items/Accessories/CelestialJewel.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Accessories { if (line2.mod == "Terraria" && line2.Name == "Tooltip2") { - line2.text = "Press " + hotkey + " to teleport to a random location"; + line2.text = "Press " + hotkey + " to teleport to a random location while no bosses are alive"; } } } diff --git a/Items/CalamityGlobalItemLoot.cs b/Items/CalamityGlobalItemLoot.cs index b8051353f5..333fb21183 100644 --- a/Items/CalamityGlobalItemLoot.cs +++ b/Items/CalamityGlobalItemLoot.cs @@ -92,7 +92,7 @@ namespace CalamityMod.Items case ItemID.TwinsBossBag: case ItemID.SkeletronPrimeBossBag: // Only drop hallowed bars after all mechs are down. - if (!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) + if ((!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) && CalamityConfig.Instance.EarlyHardmodeProgressionRework) DropHelper.BlockDrops(ItemID.HallowedBar); break; @@ -205,74 +205,83 @@ namespace CalamityMod.Items switch (itemID) { case ItemID.WoodenCrate: - int[] preMechBlockedDrops_WoodenCrate = new int[] + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework) { - ItemID.MythrilOre, - ItemID.OrichalcumOre, - ItemID.AdamantiteOre, - ItemID.TitaniumOre, - ItemID.MythrilBar, - ItemID.OrichalcumBar, - ItemID.AdamantiteBar, - ItemID.TitaniumBar, - }; - int[] postOneMechBlockedDrops_WoodenCrate = new int[] - { - ItemID.AdamantiteOre, - ItemID.TitaniumOre, - ItemID.AdamantiteBar, - ItemID.TitaniumBar, - }; + int[] preMechBlockedDrops_WoodenCrate = new int[] + { + ItemID.MythrilOre, + ItemID.OrichalcumOre, + ItemID.AdamantiteOre, + ItemID.TitaniumOre, + ItemID.MythrilBar, + ItemID.OrichalcumBar, + ItemID.AdamantiteBar, + ItemID.TitaniumBar, + }; + int[] postOneMechBlockedDrops_WoodenCrate = new int[] + { + ItemID.AdamantiteOre, + ItemID.TitaniumOre, + ItemID.AdamantiteBar, + ItemID.TitaniumBar, + }; - if (!NPC.downedMechBossAny) - DropHelper.BlockDrops(preMechBlockedDrops_WoodenCrate); - else if (!twoMechsDowned) - DropHelper.BlockDrops(postOneMechBlockedDrops_WoodenCrate); + if (!NPC.downedMechBossAny) + DropHelper.BlockDrops(preMechBlockedDrops_WoodenCrate); + else if (!twoMechsDowned) + DropHelper.BlockDrops(postOneMechBlockedDrops_WoodenCrate); + } DropHelper.DropItemChance(player, ModContent.ItemType(), 0.25f, 3, 5); break; case ItemID.IronCrate: - int[] preMechBlockedDrops_IronCrate = new int[] + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework) { - ItemID.MythrilBar, - ItemID.OrichalcumBar, - ItemID.AdamantiteBar, - ItemID.TitaniumBar, - }; - int[] postOneMechBlockedDrops_IronCrate = new int[] - { - ItemID.AdamantiteBar, - ItemID.TitaniumBar, - }; + int[] preMechBlockedDrops_IronCrate = new int[] + { + ItemID.MythrilBar, + ItemID.OrichalcumBar, + ItemID.AdamantiteBar, + ItemID.TitaniumBar, + }; + int[] postOneMechBlockedDrops_IronCrate = new int[] + { + ItemID.AdamantiteBar, + ItemID.TitaniumBar, + }; - if (!NPC.downedMechBossAny) - DropHelper.BlockDrops(preMechBlockedDrops_IronCrate); - else if (!twoMechsDowned) - DropHelper.BlockDrops(postOneMechBlockedDrops_IronCrate); + if (!NPC.downedMechBossAny) + DropHelper.BlockDrops(preMechBlockedDrops_IronCrate); + else if (!twoMechsDowned) + DropHelper.BlockDrops(postOneMechBlockedDrops_IronCrate); + } DropHelper.DropItemChance(player, ModContent.ItemType(), 0.25f, 5, 8); DropHelper.DropItemChance(player, ModContent.ItemType(), 0.25f, 5, 8); break; case ItemID.GoldenCrate: - int[] preMechBlockedDrops_GoldenCrate = new int[] + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework) { - ItemID.MythrilBar, - ItemID.OrichalcumBar, - ItemID.AdamantiteBar, - ItemID.TitaniumBar, - }; - int[] postOneMechBlockedDrops_GoldenCrate = new int[] - { - ItemID.AdamantiteBar, - ItemID.TitaniumBar, - }; + int[] preMechBlockedDrops_GoldenCrate = new int[] + { + ItemID.MythrilBar, + ItemID.OrichalcumBar, + ItemID.AdamantiteBar, + ItemID.TitaniumBar, + }; + int[] postOneMechBlockedDrops_GoldenCrate = new int[] + { + ItemID.AdamantiteBar, + ItemID.TitaniumBar, + }; - if (!NPC.downedMechBossAny) - DropHelper.BlockDrops(preMechBlockedDrops_GoldenCrate); - else if (!twoMechsDowned) - DropHelper.BlockDrops(postOneMechBlockedDrops_GoldenCrate); + if (!NPC.downedMechBossAny) + DropHelper.BlockDrops(preMechBlockedDrops_GoldenCrate); + else if (!twoMechsDowned) + DropHelper.BlockDrops(postOneMechBlockedDrops_GoldenCrate); + } break; case ItemID.CorruptFishingCrate: diff --git a/Items/DifficultyItems/Malice.cs b/Items/DifficultyItems/Malice.cs new file mode 100644 index 0000000000..9d7d905971 --- /dev/null +++ b/Items/DifficultyItems/Malice.cs @@ -0,0 +1,77 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Events; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.DifficultyItems +{ + public class Malice : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Malice"); + Tooltip.SetDefault("Enrages every boss and allows them to drop special items.\n" + + "Nurse no longer heals while a boss is alive.\n" + + "Effect can be toggled on and off."); + } + + public override void SetDefaults() + { + item.rare = ItemRarityID.Purple; + item.width = 28; + item.height = 28; + item.useAnimation = 45; + item.useTime = 45; + item.useStyle = ItemUseStyleID.HoldingUp; + item.UseSound = SoundID.Item119; + item.consumable = false; + } + + public override bool CanUseItem(Player player) => CalamityWorld.revenge; + + public override bool UseItem(Player player) + { + // This world syncing code should only be run by one entity- the server, to prevent a race condition + // with the packets. + if (Main.netMode == NetmodeID.MultiplayerClient) + return true; + + if (CalamityPlayer.areThereAnyDamnBosses || CalamityWorld.DoGSecondStageCountdown > 0 || BossRushEvent.BossRushActive) + { + string key = "Mods.CalamityMod.ChangingTheRules"; + Color messageColor = Color.Crimson; + CalamityUtils.DisplayLocalizedText(key, messageColor); + return true; + } + if (!CalamityWorld.malice) + { + CalamityWorld.malice = true; + string key = "Mods.CalamityMod.MaliceText"; + Color messageColor = Color.Crimson; + CalamityUtils.DisplayLocalizedText(key, messageColor); + } + else + { + CalamityWorld.malice = false; + string key = "Mods.CalamityMod.MaliceText2"; + Color messageColor = Color.Crimson; + CalamityUtils.DisplayLocalizedText(key, messageColor); + } + CalamityWorld.DoGSecondStageCountdown = 0; + CalamityNetcode.SyncWorld(); + + return true; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddTile(TileID.DemonAltar); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/DifficultyItems/Malice.png b/Items/DifficultyItems/Malice.png new file mode 100644 index 0000000000000000000000000000000000000000..493a9b001ca2fca997f4041e011df8e577faa106 GIT binary patch literal 497 zcmeAS@N?(olHy`uVBq!ia0vp^MnJ5?!3-n?Y^5`R6k~CayA#8@b22Z19F}xPUq=Rp zjs4tz5?O(KtpJ}8S0K&LC$?PCFDI^tuw zi~ZuGP!@-@SuaYN!zM0 zS@YejtlRIL1YE`bRd;!mUFq@WcyxIwFVE5sORj$RPUd|m!BptE;c5=c%ww}xX0cu@ ze0XwE@F~e7vB}q!jr%`vCNDd2`f)~*>NSh`oA+$yV4d~w`t1v)j!Oy+9E&~VA6;!M zDE6<8~h7mA7^%`5f9J^i!rOLX7F4m5R%xa<bP0l+XkK`yS3u literal 0 HcmV?d00001 diff --git a/Items/Mounts/AlicornMount.cs b/Items/Mounts/AlicornMount.cs index 01a43700e7..df04e74dc0 100644 --- a/Items/Mounts/AlicornMount.cs +++ b/Items/Mounts/AlicornMount.cs @@ -28,18 +28,15 @@ namespace CalamityMod.Items.Mounts mountData.blockExtraJumps = false; mountData.totalFrames = 15; mountData.constantJump = false; + int baseYOffset = 24; int[] array = new int[mountData.totalFrames]; for (int l = 0; l < array.Length; l++) { - array[l] = 30; + array[l] = baseYOffset; } - array[1] = 28; - array[3] = 28; - array[5] = 28; - array[7] = 28; - array[12] = 28; + array[1] = array[3] = array[5] = array[7] = array[12] = baseYOffset - 2; mountData.playerYOffsets = array; - mountData.xOffset = 0; + mountData.xOffset = -4; mountData.bodyFrame = 3; mountData.yOffset = 7; //-8 mountData.playerHeadOffset = 36; //30 diff --git a/Items/Placeables/AstralFossil.cs b/Items/Placeables/AstralFossil.cs index 314647ff93..a16bb08606 100644 --- a/Items/Placeables/AstralFossil.cs +++ b/Items/Placeables/AstralFossil.cs @@ -140,22 +140,22 @@ namespace CalamityMod.Items.Placeables } else if (val < 85.03f) { - resultType = !NPC.downedMechBossAny ? ItemID.CobaltOre : ItemID.MythrilOre; + resultType = CalamityConfig.Instance.EarlyHardmodeProgressionRework ? (!NPC.downedMechBossAny ? ItemID.CobaltOre : ItemID.MythrilOre) : ItemID.MythrilOre; resultStack = Main.rand.Next(1, 17); } else if (val < 87.03f) { - resultType = !NPC.downedMechBossAny ? ItemID.PalladiumOre : ItemID.OrichalcumOre; + resultType = CalamityConfig.Instance.EarlyHardmodeProgressionRework ? (!NPC.downedMechBossAny ? ItemID.PalladiumOre : ItemID.OrichalcumOre) : ItemID.OrichalcumOre; resultStack = Main.rand.Next(1, 17); } else if (val < 88.78f) { - resultType = !NPC.downedMechBossAny ? ItemID.CobaltOre : !twoMechsDowned ? ItemID.MythrilOre : ItemID.AdamantiteOre; + resultType = CalamityConfig.Instance.EarlyHardmodeProgressionRework ? (!NPC.downedMechBossAny ? ItemID.CobaltOre : !twoMechsDowned ? ItemID.MythrilOre : ItemID.AdamantiteOre) : ItemID.AdamantiteOre; resultStack = Main.rand.Next(1, 17); } else if (val < 89.53f) { - resultType = !NPC.downedMechBossAny ? ItemID.PalladiumOre : !twoMechsDowned ? ItemID.OrichalcumOre : ItemID.TitaniumOre; + resultType = CalamityConfig.Instance.EarlyHardmodeProgressionRework ? (!NPC.downedMechBossAny ? ItemID.PalladiumOre : !twoMechsDowned ? ItemID.OrichalcumOre : ItemID.TitaniumOre) : ItemID.TitaniumOre; resultStack = Main.rand.Next(1, 17); } else if (CalamityWorld.downedStarGod) diff --git a/Items/Placeables/AstralSilt.cs b/Items/Placeables/AstralSilt.cs index 50893dbe30..b50a00e6ea 100644 --- a/Items/Placeables/AstralSilt.cs +++ b/Items/Placeables/AstralSilt.cs @@ -118,22 +118,22 @@ namespace CalamityMod.Items.Placeables } else if (val < 83.03f) { - resultType = !NPC.downedMechBossAny ? ItemID.CobaltOre : ItemID.MythrilOre; + resultType = CalamityConfig.Instance.EarlyHardmodeProgressionRework ? (!NPC.downedMechBossAny ? ItemID.CobaltOre : ItemID.MythrilOre) : ItemID.MythrilOre; resultStack = Main.rand.Next(1, 17); } else if (val < 85.03f) { - resultType = !NPC.downedMechBossAny ? ItemID.PalladiumOre : ItemID.OrichalcumOre; + resultType = CalamityConfig.Instance.EarlyHardmodeProgressionRework ? (!NPC.downedMechBossAny ? ItemID.PalladiumOre : ItemID.OrichalcumOre) : ItemID.OrichalcumOre; resultStack = Main.rand.Next(1, 17); } else if (val < 86.78f) { - resultType = !NPC.downedMechBossAny ? ItemID.CobaltOre : !twoMechsDowned ? ItemID.MythrilOre : ItemID.AdamantiteOre; + resultType = CalamityConfig.Instance.EarlyHardmodeProgressionRework ? (!NPC.downedMechBossAny ? ItemID.CobaltOre : !twoMechsDowned ? ItemID.MythrilOre : ItemID.AdamantiteOre) : ItemID.AdamantiteOre; resultStack = Main.rand.Next(1, 17); } else if (val < 88.53f) { - resultType = !NPC.downedMechBossAny ? ItemID.PalladiumOre : !twoMechsDowned ? ItemID.OrichalcumOre : ItemID.TitaniumOre; + resultType = CalamityConfig.Instance.EarlyHardmodeProgressionRework ? (!NPC.downedMechBossAny ? ItemID.PalladiumOre : !twoMechsDowned ? ItemID.OrichalcumOre : ItemID.TitaniumOre) : ItemID.TitaniumOre; resultStack = Main.rand.Next(1, 17); } else if (CalamityWorld.downedStarGod) diff --git a/Items/TreasureBags/StarterBag.cs b/Items/TreasureBags/StarterBag.cs index afeb433019..1b9cb7fdc8 100644 --- a/Items/TreasureBags/StarterBag.cs +++ b/Items/TreasureBags/StarterBag.cs @@ -51,8 +51,11 @@ namespace CalamityMod.Items.TreasureBags DropHelper.DropItem(player, ItemID.Torch, 25); DropHelper.DropItem(player, ItemID.Chest, 3); - // Difficulty items (doesn't drop in Normal) - DropHelper.DropItemCondition(player, ModContent.ItemType(), Main.expertMode); + // Malice item + DropHelper.DropItem(player, ModContent.ItemType()); + + // Difficulty items (doesn't drop in Normal) + DropHelper.DropItemCondition(player, ModContent.ItemType(), Main.expertMode); DropHelper.DropItemCondition(player, ModContent.ItemType(), Main.expertMode); // Speedrun King Slime diff --git a/Localization/CalamityLocalization.cs b/Localization/CalamityLocalization.cs index b4cbef35e7..698cd3151c 100644 --- a/Localization/CalamityLocalization.cs +++ b/Localization/CalamityLocalization.cs @@ -120,10 +120,13 @@ namespace CalamityMod.Localization new [] { "RevengeText", "Revengeance is active." }, new [] { "RevengeText2", "Revengeance is not active." }, - new [] { "DeathText", "Death is active, enjoy the fun." }, - new [] { "DeathText2", "Death is not active, not fun enough for you?" }, + new [] { "DeathText", "Death is active; enjoy the fun." }, + new [] { "DeathText2", "Death is not active; not fun enough for you?" }, - new [] { "ArmageddonText", "Bosses will now kill you instantly." }, + new [] { "MaliceText", "Malice is active; witness the horror!" }, + new [] { "MaliceText2", "Malice is not active." }, + + new [] { "ArmageddonText", "Bosses will now kill you instantly." }, new [] { "ArmageddonText2", "Bosses will no longer kill you instantly." }, new [] { "DefiledText", "Your soul is mine..." }, diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index ac29ce0773..a81da6eb1e 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -1445,22 +1445,25 @@ namespace CalamityMod.NPCs } // Reduce mech boss HP and damage depending on the new ore progression changes - if (!NPC.downedMechBossAny) + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework) { - if (DestroyerIDs.Contains(npc.type) || npc.type == NPCID.Probe || SkeletronPrimeIDs.Contains(npc.type) || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer) + if (!NPC.downedMechBossAny) { - npc.lifeMax = (int)(npc.lifeMax * 0.8); - npc.damage = (int)(npc.damage * 0.8); - npc.defDamage = npc.damage; + if (DestroyerIDs.Contains(npc.type) || npc.type == NPCID.Probe || SkeletronPrimeIDs.Contains(npc.type) || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer) + { + npc.lifeMax = (int)(npc.lifeMax * 0.8); + npc.damage = (int)(npc.damage * 0.8); + npc.defDamage = npc.damage; + } } - } - else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) - { - if (DestroyerIDs.Contains(npc.type) || npc.type == NPCID.Probe || SkeletronPrimeIDs.Contains(npc.type) || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer) + else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) { - npc.lifeMax = (int)(npc.lifeMax * 0.9); - npc.damage = (int)(npc.damage * 0.9); - npc.defDamage = npc.damage; + if (DestroyerIDs.Contains(npc.type) || npc.type == NPCID.Probe || SkeletronPrimeIDs.Contains(npc.type) || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer) + { + npc.lifeMax = (int)(npc.lifeMax * 0.9); + npc.damage = (int)(npc.damage * 0.9); + npc.defDamage = npc.damage; + } } } @@ -3923,9 +3926,7 @@ namespace CalamityMod.NPCs npc2.ai[0] = -1000 * Main.rand.Next(3); if (Main.netMode == NetmodeID.Server && slime < Main.maxNPCs) - { NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slime, 0f, 0f, 0f, 0, 0, 0); - } } } } @@ -3940,9 +3941,7 @@ namespace CalamityMod.NPCs case NPCID.EnchantedSword: case NPCID.CrimsonAxe: if (npc.life <= npc.lifeMax * 0.5) - { npc.justHit = false; - } break; @@ -3953,25 +3952,19 @@ namespace CalamityMod.NPCs case NPCID.BlackRecluse: case NPCID.BlackRecluseWall: if (npc.life <= npc.lifeMax * 0.25) - { npc.justHit = false; - } break; case NPCID.Paladin: if (npc.life <= npc.lifeMax * 0.15) - { npc.justHit = false; - } break; case NPCID.Clown: if (Main.netMode != NetmodeID.MultiplayerClient && !Main.player[npc.target].dead) - { npc.ai[2] += 29f; - } break; } @@ -3979,9 +3972,7 @@ namespace CalamityMod.NPCs if (npc.type == NPCType() || npc.type == NPCType()) { if (npc.life <= npc.lifeMax * 0.25) - { npc.justHit = false; - } } } } diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 598ef4a7c1..13fd69a399 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -206,23 +206,27 @@ namespace CalamityMod.NPCs if (!Main.hardMode) { // Increase altar count to allow natural mech boss spawning. - WorldGen.altarCount++; + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework) + WorldGen.altarCount++; string key2 = "Mods.CalamityMod.UglyBossText"; Color messageColor2 = Color.Aquamarine; CalamityUtils.DisplayLocalizedText(key2, messageColor2); - string key3 = "Mods.CalamityMod.HardmodeOreTier1Text"; - Color messageColor3 = new Color(50, 255, 130); - WorldGenerationMethods.SpawnOre(TileID.Cobalt, 12E-05, .4f, .6f); - WorldGenerationMethods.SpawnOre(TileID.Palladium, 12E-05, .4f, .6f); - CalamityUtils.DisplayLocalizedText(key3, messageColor3); + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework) + { + string key3 = "Mods.CalamityMod.HardmodeOreTier1Text"; + Color messageColor3 = new Color(50, 255, 130); + WorldGenerationMethods.SpawnOre(TileID.Cobalt, 12E-05, .4f, .6f); + WorldGenerationMethods.SpawnOre(TileID.Palladium, 12E-05, .4f, .6f); + CalamityUtils.DisplayLocalizedText(key3, messageColor3); + } } } else if (lastTwinStanding) { // Only drop hallowed bars after all mechs are down - if (!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) + if ((!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) && CalamityConfig.Instance.EarlyHardmodeProgressionRework) DropHelper.BlockDrops(ItemID.HallowedBar); DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, CalamityGlobalNPC.DraedonMayhem, 8, 16); @@ -237,13 +241,13 @@ namespace CalamityMod.NPCs CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }, !NPC.downedMechBoss1 || NPC.downedMechBoss2 || !NPC.downedMechBoss3); CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Steampunker }, NPC.downedMechBoss2 || !CalamityConfig.Instance.SellVanillaSummons); - if (!NPC.downedMechBoss2) + if (!NPC.downedMechBoss2 && CalamityConfig.Instance.EarlyHardmodeProgressionRework) SpawnMechBossHardmodeOres(); } else if (npc.type == NPCID.TheDestroyer) { // Only drop hallowed bars after all mechs are down - if (!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) + if ((!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) && CalamityConfig.Instance.EarlyHardmodeProgressionRework) DropHelper.BlockDrops(ItemID.HallowedBar); DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, CalamityGlobalNPC.DraedonMayhem, 8, 16); @@ -258,13 +262,13 @@ namespace CalamityMod.NPCs CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }, NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3); CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Steampunker }, NPC.downedMechBoss1 || !CalamityConfig.Instance.SellVanillaSummons); - if (!NPC.downedMechBoss1) + if (!NPC.downedMechBoss1 && CalamityConfig.Instance.EarlyHardmodeProgressionRework) SpawnMechBossHardmodeOres(); } else if (npc.type == NPCID.SkeletronPrime) { // Only drop hallowed bars after all mechs are down - if (!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) + if ((!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) && CalamityConfig.Instance.EarlyHardmodeProgressionRework) DropHelper.BlockDrops(ItemID.HallowedBar); DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, CalamityGlobalNPC.DraedonMayhem, 8, 16); @@ -280,7 +284,7 @@ namespace CalamityMod.NPCs CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }, !NPC.downedMechBoss1 || !NPC.downedMechBoss2 || NPC.downedMechBoss3); CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Steampunker }, NPC.downedMechBoss3 || !CalamityConfig.Instance.SellVanillaSummons); - if (!NPC.downedMechBoss3) + if (!NPC.downedMechBoss3 && CalamityConfig.Instance.EarlyHardmodeProgressionRework) SpawnMechBossHardmodeOres(); } else if (npc.type == NPCID.Plantera) diff --git a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs index 7cd203eb0f..2f1bbe799b 100644 --- a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs +++ b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs @@ -1017,27 +1017,6 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath public override bool CheckActive() => canDespawn; - // Can only hit the target if within certain distance - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - 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 minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; - - return minDist <= 100f; - } - public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 2; k++) diff --git a/NPCs/TownNPCs/FAP.cs b/NPCs/TownNPCs/FAP.cs index 699e1db6e9..9b24365075 100644 --- a/NPCs/TownNPCs/FAP.cs +++ b/NPCs/TownNPCs/FAP.cs @@ -114,11 +114,11 @@ namespace CalamityMod.NPCs.TownNPCs if (Main.dayTime) { - dialogue.Add("Like I always say, when you're drunk you can tolerate annoying people a lot more easily..."); + dialogue.Add("Like I always say, when you're drunk you can tolerate annoying people a lot easier..."); dialogue.Add("I'm literally balls drunk off my sass right now."); dialogue.Add("I'm either laughing because I'm drunk or because I've lost my mind. Probably both."); dialogue.Add("When I'm drunk I'm way happier...at least until the talking worms start to appear."); - dialogue.Add("I should reprogram the whole game while drunk and send it back to the testers."); + dialogue.Add("I should reprogram the whole game, while drunk, and send it back to the testers."); dialogue.Add("What a great day, might just drink so much that I get poisoned again."); } else diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 2853ace474..1a98e8bd61 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -362,10 +362,13 @@ namespace CalamityMod.Projectiles if (defDamage == 0) { // Reduce mech boss projectile damage depending on the new ore progression changes - if (!NPC.downedMechBossAny) - projectile.damage = (int)(projectile.damage * 0.8); - else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) - projectile.damage = (int)(projectile.damage * 0.9); + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework) + { + if (!NPC.downedMechBossAny) + projectile.damage = (int)(projectile.damage * 0.8); + else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) + projectile.damage = (int)(projectile.damage * 0.9); + } defDamage = projectile.damage; } @@ -971,20 +974,23 @@ namespace CalamityMod.Projectiles } // Reduce mech boss projectile damage depending on the new ore progression changes - if (!NPC.downedMechBossAny) + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework) { - if (MechBossProjectileIDs.Contains(projectile.type)) + if (!NPC.downedMechBossAny) { - if (CalamityUtils.AnyBossNPCS(true)) - projectile.damage = (int)(projectile.damage * 0.8); + if (MechBossProjectileIDs.Contains(projectile.type)) + { + if (CalamityUtils.AnyBossNPCS(true)) + projectile.damage = (int)(projectile.damage * 0.8); + } } - } - else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) - { - if (MechBossProjectileIDs.Contains(projectile.type)) + else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) { - if (CalamityUtils.AnyBossNPCS(true)) - projectile.damage = (int)(projectile.damage * 0.9); + if (MechBossProjectileIDs.Contains(projectile.type)) + { + if (CalamityUtils.AnyBossNPCS(true)) + projectile.damage = (int)(projectile.damage * 0.9); + } } } diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index eb9cffe787..c8971770ab 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -194,7 +194,7 @@ namespace CalamityMod.Tiles Gore.NewGore(new Vector2(i, j) * 16, Main.rand.NextVector2CircularEdge(3f, 3f), mod.GetGoreSlot("Gores/SulphSeaGen/SulphPotGore2")); } } - else if (type == TileID.DemonAltar) + else if (type == TileID.DemonAltar && CalamityConfig.Instance.EarlyHardmodeProgressionRework) { int quantity = 6; Vector2 pos = new Vector2(i, j) * 16; diff --git a/Utilities/NPCUtils.cs b/Utilities/NPCUtils.cs index a26a1f69c7..fd2e8bb769 100644 --- a/Utilities/NPCUtils.cs +++ b/Utilities/NPCUtils.cs @@ -108,7 +108,7 @@ namespace CalamityMod NPC npc = Main.npc[i]; if (npc.IsABoss()) { - // Added due to the new mech boss ore progression, return true if any mech is alive and checkForMechs is true, reduces mech boss projectile damage if true + // Added due to the new mech boss ore progression, return true if any mech is alive and checkForMechs is true, reduces mech boss projectile damage if true. if (checkForMechs) return npc.type == NPCID.TheDestroyer || npc.type == NPCID.SkeletronPrime || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer; return true;