From 4566392ca80afaad37222090ecb8a2d1e2c2aff1 Mon Sep 17 00:00:00 2001 From: Andrew Marheine Date: Fri, 1 May 2020 08:51:15 -0500 Subject: [PATCH] Polterghast slight refactor. Moon Lord rev+ true eyes adjusted to move towards the player again. Added timed DR scaling for bosses. --- CalamityMod.cs | 104 +++++++++++++++++++++++++++++--- NPCs/CalamityGlobalAI.cs | 16 +---- NPCs/CalamityGlobalNPC.cs | 64 ++++++++++++++++---- NPCs/Polterghast/Polterghast.cs | 78 ++++++++++++------------ 4 files changed, 188 insertions(+), 74 deletions(-) diff --git a/CalamityMod.cs b/CalamityMod.cs index 4e7b27a69f..b43109e16d 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -123,9 +123,10 @@ namespace CalamityMod // DR data structure public static SortedDictionary DRValues; + public static SortedDictionary bossKillTimes; - // Lists - public static IList donatorList; + // Lists + public static IList donatorList; public static List rangedProjectileExceptionList; public static List projectileDestroyExceptionList; public static List projectileMinionList; @@ -237,6 +238,7 @@ namespace CalamityMod SetupLists(); SetupVanillaDR(); + SetupBossKillTimes(); SetupThoriumBossDR(thorium); CalamityLocalization.AddLocalizations(); @@ -338,6 +340,8 @@ namespace CalamityMod DRValues?.Clear(); DRValues = null; + bossKillTimes?.Clear(); + bossKillTimes = null; donatorList = null; rangedProjectileExceptionList = null; @@ -2541,13 +2545,14 @@ namespace CalamityMod { NPCID.Crab, 0.05f }, { NPCID.Crawdad, 0.2f }, { NPCID.Crawdad2, 0.2f }, - { NPCID.CultistBoss, 0.05f }, + { NPCID.CultistBoss, 0.1f }, { NPCID.DD2Betsy, 0.1f }, { NPCID.DD2OgreT2, 0.1f }, { NPCID.DD2OgreT3, 0.15f }, { NPCID.DeadlySphere, 0.4f }, { NPCID.DiabolistRed, 0.2f }, { NPCID.DiabolistWhite, 0.2f }, + { NPCID.DukeFishron, 0.1f }, { NPCID.DungeonGuardian, 0.999999f }, { NPCID.DungeonSpirit, 0.2f }, { NPCID.ElfCopter, 0.15f }, @@ -2592,7 +2597,9 @@ namespace CalamityMod { NPCID.Paladin, 0.45f }, { NPCID.PirateCaptain, 0.05f }, { NPCID.PirateShipCannon, 0.15f }, - { NPCID.PossessedArmor, 0.25f }, + { NPCID.Plantera, 0.15f }, + { NPCID.PlanterasTentacle, 0.1f }, + { NPCID.PossessedArmor, 0.25f }, { NPCID.PresentMimic, 0.3f }, { NPCID.PrimeCannon, 0.2f }, { NPCID.PrimeLaser, 0.2f }, @@ -2633,7 +2640,7 @@ namespace CalamityMod #region Thorium Boss DR private void SetupThoriumBossDR(Mod thorium) { - if (thorium is null || !CalamityMod.CalamityConfig.RevengeanceAndDeathThoriumBossBuff) + if (thorium is null || !CalamityConfig.RevengeanceAndDeathThoriumBossBuff) return; void ThoriumDR(string npcName, float dr) { @@ -2666,10 +2673,91 @@ namespace CalamityMod ThoriumDR("Omnicide", 0.3f); ThoriumDR("Abyssion", 0.35f); } - #endregion + #endregion - #region Music - public override void UpdateMusic(ref int music, ref MusicPriority priority) + #region Vanilla Enemy DR + private void SetupBossKillTimes() + { + bossKillTimes = new SortedDictionary { + { NPCID.KingSlime, 3600 }, + { NPCID.EyeofCthulhu, 5400 }, + { NPCID.EaterofWorldsHead, 7200 }, + { NPCID.EaterofWorldsBody, 7200 }, + { NPCID.EaterofWorldsTail, 7200 }, + { NPCID.BrainofCthulhu, 5400 }, + { NPCID.QueenBee, 7200 }, + { NPCID.WallofFlesh, 10800 }, + { NPCID.WallofFleshEye, 10800 }, + { NPCID.Spazmatism, 10800 }, + { NPCID.Retinazer, 10800 }, + { NPCID.TheDestroyer, 10800 }, + { NPCID.TheDestroyerBody, 10800 }, + { NPCID.TheDestroyerTail, 10800 }, + { NPCID.SkeletronPrime, 10800 }, + { NPCID.Plantera, 10800 }, + { NPCID.Golem, 10800 }, + { NPCID.GolemHead, 3600 }, + { NPCID.DukeFishron, 9000 }, + { NPCID.CultistBoss, 9000 }, + { NPCID.MoonLordCore, 14400 }, + { NPCID.MoonLordHand, 7200 }, + { NPCID.MoonLordHead, 7200 }, + { ModContent.NPCType(), 3600 }, + { ModContent.NPCType(), 3600 }, + { ModContent.NPCType(), 3600 }, + { ModContent.NPCType(), 5400 }, + { ModContent.NPCType(), 1800 }, + { ModContent.NPCType(), 5400 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 3600 }, + { ModContent.NPCType(), 3600 }, + { ModContent.NPCType(), 3600 }, + { ModContent.NPCType(), 3600 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 1200 }, + { ModContent.NPCType(), 11400 }, + { ModContent.NPCType(), 9000 }, + { ModContent.NPCType(), 9000 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 5400 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 14400 }, + { ModContent.NPCType(), 1200 }, + { ModContent.NPCType(), 1200 }, + { ModContent.NPCType(), 1200 }, + { ModContent.NPCType(), 5400 }, + { ModContent.NPCType(), 5400 }, + { ModContent.NPCType(), 5400 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 14400 } + }; + } + #endregion + + #region Music + public override void UpdateMusic(ref int music, ref MusicPriority priority) { Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); if (Main.musicVolume != 0) diff --git a/NPCs/CalamityGlobalAI.cs b/NPCs/CalamityGlobalAI.cs index 9c2a1a35df..c6330b50f7 100644 --- a/NPCs/CalamityGlobalAI.cs +++ b/NPCs/CalamityGlobalAI.cs @@ -13643,7 +13643,7 @@ namespace CalamityMod.NPCs float velocity = CalamityWorld.bossRushActive ? 38f : 30f; Vector2 center23 = npc.Center; - Vector2 center24 = Main.npc[(int)Main.npc[(int)npc.ai[3]].localAI[2]].Center; + Vector2 center24 = Main.player[npc.target].Center; Vector2 value24 = center24 - center23; value24 = Vector2.Normalize(value24) * velocity; @@ -13657,19 +13657,7 @@ namespace CalamityMod.NPCs { if (Main.npc[num1248].active) { - if (Main.npc[num1248].type == NPCID.MoonLordHead && Vector2.Distance(npc.Center, Main.npc[num1248].Center) > 600f) - { - if (npc.position.X < Main.npc[num1248].position.X) - npc.velocity.X = npc.velocity.X - num1247; - else - npc.velocity.X = npc.velocity.X + num1247; - - if (npc.position.Y < Main.npc[num1248].position.Y) - npc.velocity.Y = npc.velocity.Y - num1247; - else - npc.velocity.Y = npc.velocity.Y + num1247; - } - else if (num1248 != npc.whoAmI && Main.npc[num1248].type == npc.type) + if (num1248 != npc.whoAmI && Main.npc[num1248].type == npc.type) { if (Vector2.Distance(npc.Center, Main.npc[num1248].Center) < 150f) { diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index a41e4941f0..1823876fe3 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -81,10 +81,12 @@ namespace CalamityMod.NPCs #region Variables public float DR { get; set; } = 0f; - /// - /// If this is set to true, the NPC's DR cannot be reduced via any means. This applies regardless of whether customDR is true or false. - /// - public bool unbreakableDR = false; + public int KillTime { get; set; } = 0; + + /// + /// If this is set to true, the NPC's DR cannot be reduced via any means. This applies regardless of whether customDR is true or false. + /// + public bool unbreakableDR = false; /// /// Overrides the normal DR math and uses custom DR reductions for each debuff, registered separately.

@@ -104,6 +106,7 @@ namespace CalamityMod.NPCs // NewAI internal const int maxAIMod = 4; public float[] newAI = new float[maxAIMod]; + public int AITimer = 0; // Town NPC Patreon private bool setNewName = true; @@ -667,11 +670,20 @@ namespace CalamityMod.NPCs // Apply DR to vanilla NPCs. No vanilla NPCs have DR except in Rev+. // This also applies DR to other mods' NPCs who have set up their NPCs to have DR in Rev+. - if (CalamityWorld.revenge && CalamityMod.DRValues.ContainsKey(npc.type)) + if (CalamityWorld.revenge) { - CalamityMod.DRValues.TryGetValue(npc.type, out float revDR); - DR = revDR; - } + if (CalamityMod.DRValues.ContainsKey(npc.type)) + { + CalamityMod.DRValues.TryGetValue(npc.type, out float revDR); + DR = revDR; + } + + if (CalamityMod.bossKillTimes.ContainsKey(npc.type)) + { + CalamityMod.bossKillTimes.TryGetValue(npc.type, out int revKillTime); + KillTime = revKillTime; + } + } if (npc.boss && CalamityWorld.revenge) { @@ -1137,6 +1149,7 @@ namespace CalamityMod.NPCs effects, 0f); } + public static void DrawAfterimage(NPC npc, SpriteBatch spriteBatch, Color startingColor, Color endingColor, Texture2D texture = null, Func rotationCalculation = null, bool directioning = false, bool invertedDirection = false) { @@ -1215,6 +1228,7 @@ namespace CalamityMod.NPCs case 1: scalar = 1.0; break; + case 2: scalar = 0.76; break; @@ -1475,7 +1489,7 @@ namespace CalamityMod.NPCs /// private double ApplyDR(NPC npc, double damage) { - if (DR <= 0f || damage <= 1.0) + if ((DR <= 0f && KillTime == 0) || damage <= 1.0) return damage; // If the NPC currently has unbreakable DR, it cannot be reduced by any means. @@ -1486,7 +1500,28 @@ namespace CalamityMod.NPCs if (effectiveDR <= 0f) effectiveDR = 0f; - double newDamage = (1f - effectiveDR) * damage; + // Calculate extra DR based on kill time, similar to the Hush boss from The Binding of Isaac + if (KillTime > 0 && AITimer < KillTime) + { + // The limit for how much extra DR the boss can have + float extraDRLimit = 1f - effectiveDR; + + // Ranges from 1 to 0 + float currentHPRatio = npc.life / (float)npc.lifeMax; + + // Ranges from 0 to 1 + float killTimeRatio = AITimer / (float)KillTime; + + // If the player is damaging the boss too quickly + float extraDRScalar = currentHPRatio + killTimeRatio; + if (extraDRScalar < 1f) + { + // Ranges from 0 to (extraDRLimit / 2) + effectiveDR += extraDRLimit - (extraDRLimit / (1f + (1f - extraDRScalar))); + } + } + + double newDamage = (1f - effectiveDR) * damage; return newDamage < 1.0 ? 1.0 : newDamage; } @@ -1577,7 +1612,7 @@ namespace CalamityMod.NPCs { if (npc.type == NPCID.BrainofCthulhu) { - if ((float)npc.life / (float)npc.lifeMax < (CalamityWorld.death ? 0.33f : 0.2f)) + if (npc.life / (float)npc.lifeMax < (CalamityWorld.death ? 0.33f : 0.2f)) index = -1; } @@ -1585,7 +1620,7 @@ namespace CalamityMod.NPCs { if (npc.type == NPCID.DukeFishron) { - if ((float)npc.life / (float)npc.lifeMax < 0.15f) + if (npc.life / (float)npc.lifeMax < 0.15f) index = -1; } } @@ -1598,7 +1633,10 @@ namespace CalamityMod.NPCs { SetPatreonTownNPCName(npc); - if (npc.type == NPCID.TargetDummy || npc.type == NPCType()) + if (KillTime > 0 && AITimer < KillTime) + AITimer++; + + if (npc.type == NPCID.TargetDummy || npc.type == NPCType()) { npc.chaseable = !CalamityPlayer.areThereAnyDamnBosses; npc.dontTakeDamage = CalamityPlayer.areThereAnyDamnBosses; diff --git a/NPCs/Polterghast/Polterghast.cs b/NPCs/Polterghast/Polterghast.cs index 5e41ac1b95..7a8b222ab1 100644 --- a/NPCs/Polterghast/Polterghast.cs +++ b/NPCs/Polterghast/Polterghast.cs @@ -104,7 +104,7 @@ namespace CalamityMod.NPCs.Polterghast public override void AI() { // Emit light - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.1f, 0.5f, 0.5f); + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.1f, 0.5f, 0.5f); // whoAmI variable CalamityGlobalNPC.ghostBoss = npc.whoAmI; @@ -121,10 +121,10 @@ namespace CalamityMod.NPCs.Polterghast bool death = CalamityWorld.death || CalamityWorld.bossRushActive; bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive; bool expertMode = Main.expertMode || CalamityWorld.bossRushActive; - bool phase2 = (double)npc.life < (double)npc.lifeMax * (death ? 0.9 : 0.75); //hooks fire beams - bool phase3 = (double)npc.life < (double)npc.lifeMax * (revenge ? (death ? 0.8 : 0.5) : 0.33); //hooks stop shooting and polter begins charging with ghosts spinning around player - bool phase4 = (double)npc.life < (double)npc.lifeMax * (revenge ? (death ? 0.5 : 0.33) : 0.2); //starts spitting ghost dudes - bool phase5 = (double)npc.life < (double)npc.lifeMax * (revenge ? (death ? 0.25 : 0.1) : 0.05); //starts moving incredibly fast + bool phase2 = npc.life < npc.lifeMax * (death ? 0.9 : 0.75); //hooks fire beams + bool phase3 = npc.life < npc.lifeMax * (revenge ? (death ? 0.8 : 0.5) : 0.33); //hooks stop shooting and polter begins charging with ghosts spinning around player + bool phase4 = npc.life < npc.lifeMax * (revenge ? (death ? 0.5 : 0.33) : 0.2); //starts spitting ghost dudes + bool phase5 = npc.life < npc.lifeMax * (revenge ? (death ? 0.25 : 0.1) : 0.05); //starts moving incredibly fast // Target npc.TargetClosest(true); @@ -176,15 +176,15 @@ namespace CalamityMod.NPCs.Polterghast } num = num733; } - num730 /= (float)num732; - num731 /= (float)num732; + num730 /= num732; + num731 /= num732; // Velocity and acceleration bool charging = npc.ai[2] >= 300f; bool reset = npc.ai[2] >= 600f; float num734 = 2.5f; float num735 = 0.025f; - if (!player.ZoneDungeon && !CalamityWorld.bossRushActive && (double)player.position.Y < Main.worldSurface * 16.0) + if (!player.ZoneDungeon && !CalamityWorld.bossRushActive && player.position.Y < Main.worldSurface * 16.0) { despawnTimer--; if (despawnTimer <= 0) @@ -283,16 +283,16 @@ namespace CalamityMod.NPCs.Polterghast num734 += 10f; } - float num738 = (float)Math.Sqrt((double)(num736 * num736 + num737 * num737)); + float num738 = (float)Math.Sqrt(num736 * num736 + num737 * num737); int num739 = 500; if (speedBoost) num739 += 250; if (expertMode) num739 += 150; - if (num738 >= (float)num739) + if (num738 >= num739) { - num738 = (float)num739 / num738; + num738 = num739 / num738; num736 *= num738; num737 *= num738; } @@ -302,7 +302,7 @@ namespace CalamityMod.NPCs.Polterghast vector91 = new Vector2(vector.X, vector.Y); num736 = num730 - vector91.X; num737 = num731 - vector91.Y; - num738 = (float)Math.Sqrt((double)(num736 * num736 + num737 * num737)); + num738 = (float)Math.Sqrt(num736 * num736 + num737 * num737); if (num738 < num734) { @@ -319,7 +319,7 @@ namespace CalamityMod.NPCs.Polterghast Vector2 vector92 = new Vector2(vector.X, vector.Y); float num740 = player.Center.X - vector92.X; float num741 = player.Center.Y - vector92.Y; - npc.rotation = (float)Math.Atan2((double)num741, (double)num740) + 1.57f; + npc.rotation = (float)Math.Atan2(num741, num740) + MathHelper.PiOver2; if (npc.velocity.X < num736) { @@ -381,9 +381,9 @@ namespace CalamityMod.NPCs.Polterghast num742 *= 2f; Vector2 vector93 = new Vector2(vector.X, vector.Y); - float num743 = player.position.X + (float)player.width * 0.5f - vector93.X; - float num744 = player.position.Y + (float)player.height * 0.5f - vector93.Y; - float num745 = (float)Math.Sqrt((double)(num743 * num743 + num744 * num744)); + float num743 = player.position.X + player.width * 0.5f - vector93.X; + float num744 = player.position.Y + player.height * 0.5f - vector93.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); num745 = num742 / num745; num743 *= num745; @@ -415,9 +415,9 @@ namespace CalamityMod.NPCs.Polterghast num742 *= 2f; Vector2 vector93 = new Vector2(vector.X, vector.Y); - float num743 = player.position.X + (float)player.width * 0.5f - vector93.X; - float num744 = player.position.Y + (float)player.height * 0.5f - vector93.Y; - float num745 = (float)Math.Sqrt((double)(num743 * num743 + num744 * num744)); + float num743 = player.position.X + player.width * 0.5f - vector93.X; + float num744 = player.position.Y + player.height * 0.5f - vector93.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); num745 = num742 / num745; num743 *= num745; @@ -459,7 +459,7 @@ namespace CalamityMod.NPCs.Polterghast if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } for (int num623 = 0; num623 < 30; num623++) @@ -474,8 +474,8 @@ namespace CalamityMod.NPCs.Polterghast npc.GivenName = "Necroghast"; - npc.damage = (int)((float)npc.defDamage * 1.2f); - npc.defense = (int)((float)npc.defDefense * 0.8f); + npc.damage = (int)(npc.defDamage * 1.2f); + npc.defense = (int)(npc.defDefense * 0.8f); if (speedBoost || npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) { @@ -507,9 +507,9 @@ namespace CalamityMod.NPCs.Polterghast num742 *= 2f; Vector2 vector93 = new Vector2(vector.X, vector.Y); - float num743 = player.position.X + (float)player.width * 0.5f - vector93.X; - float num744 = player.position.Y + (float)player.height * 0.5f - vector93.Y; - float num745 = (float)Math.Sqrt((double)(num743 * num743 + num744 * num744)); + float num743 = player.position.X + player.width * 0.5f - vector93.X; + float num744 = player.position.Y + player.height * 0.5f - vector93.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); num745 = num742 / num745; num743 *= num745; @@ -541,9 +541,9 @@ namespace CalamityMod.NPCs.Polterghast num742 *= 2f; Vector2 vector93 = new Vector2(vector.X, vector.Y); - float num743 = player.position.X + (float)player.width * 0.5f - vector93.X; - float num744 = player.position.Y + (float)player.height * 0.5f - vector93.Y; - float num745 = (float)Math.Sqrt((double)(num743 * num743 + num744 * num744)); + float num743 = player.position.X + player.width * 0.5f - vector93.X; + float num744 = player.position.Y + player.height * 0.5f - vector93.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); num745 = num742 / num745; num743 *= num745; @@ -602,7 +602,7 @@ namespace CalamityMod.NPCs.Polterghast if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } for (int num623 = 0; num623 < 30; num623++) @@ -617,8 +617,8 @@ namespace CalamityMod.NPCs.Polterghast npc.GivenName = "Necroplasm"; - npc.damage = (int)((float)npc.defDamage * 1.4f); - npc.defense = (int)((float)npc.defDefense * 0.5f); + npc.damage = (int)(npc.defDamage * 1.4f); + npc.defense = (int)(npc.defDefense * 0.5f); if (speedBoost || npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) { @@ -632,9 +632,9 @@ namespace CalamityMod.NPCs.Polterghast npc.ai[1] = 0f; Vector2 vector93 = new Vector2(vector.X, vector.Y); float num742 = CalamityWorld.bossRushActive ? 7f : 5f; - float num743 = player.position.X + (float)player.width * 0.5f - vector93.X; - float num744 = player.position.Y + (float)player.height * 0.5f - vector93.Y; - float num745 = (float)Math.Sqrt((double)(num743 * num743 + num744 * num744)); + float num743 = player.position.X + player.width * 0.5f - vector93.X; + float num744 = player.position.Y + player.height * 0.5f - vector93.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); num745 = num742 / num745; num743 *= num745; @@ -648,7 +648,7 @@ namespace CalamityMod.NPCs.Polterghast float rotation = MathHelper.ToRadians(spread); float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); double startAngle = Math.Atan2(num743, num744) - rotation / 2; - double deltaAngle = rotation / (float)numProj; + double deltaAngle = rotation / numProj; double offsetAngle; int type = ModContent.ProjectileType(); for (int i = 0; i < numProj; i++) @@ -668,15 +668,15 @@ namespace CalamityMod.NPCs.Polterghast npc.localAI[1] = 0f; float num757 = 8f; - Vector2 vector94 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num758 = player.position.X + (float)player.width * 0.5f - vector94.X; + Vector2 vector94 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num758 = player.position.X + player.width * 0.5f - vector94.X; float num759 = Math.Abs(num758 * 0.2f); - float num760 = player.position.Y + (float)player.height * 0.5f - vector94.Y; + float num760 = player.position.Y + player.height * 0.5f - vector94.Y; if (num760 > 0f) num759 = 0f; num760 -= num759; - float num761 = (float)Math.Sqrt((double)(num758 * num758 + num760 * num760)); + float num761 = (float)Math.Sqrt(num758 * num758 + num760 * num760); num761 = num757 / num761; num758 *= num761; num760 *= num761;