diff --git a/NPCs/DesertScourge/DesertNuisanceBody.cs b/NPCs/DesertScourge/DesertNuisanceBody.cs index 8aab82bdb2..7b9a2d68a4 100644 --- a/NPCs/DesertScourge/DesertNuisanceBody.cs +++ b/NPCs/DesertScourge/DesertNuisanceBody.cs @@ -38,8 +38,8 @@ namespace CalamityMod.NPCs.DesertScourge public override void SetDefaults() { NPC.GetNPCDamage(); - NPC.width = 92; - NPC.height = 92; + NPC.width = 88; + NPC.height = 88; NPC.defense = 4; if (Main.getGoodWorld) @@ -195,44 +195,20 @@ namespace CalamityMod.NPCs.DesertScourge if (Main.player[NPC.target].dead) NPC.TargetClosest(false); - Vector2 segmentTilePos = NPC.Center; - float playerXPos = Main.player[NPC.target].Center.X; - float playerYPos = Main.player[NPC.target].Center.Y; - playerXPos = (float)((int)(playerXPos / 16f) * 16); - playerYPos = (float)((int)(playerYPos / 16f) * 16); - segmentTilePos.X = (float)((int)(segmentTilePos.X / 16f) * 16); - segmentTilePos.Y = (float)((int)(segmentTilePos.Y / 16f) * 16); - playerXPos -= segmentTilePos.X; - playerYPos -= segmentTilePos.Y; - float playerDistance = (float)System.Math.Sqrt((double)(playerXPos * playerXPos + playerYPos * playerYPos)); - if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) + NPC aheadSegment = Main.npc[(int)NPC.ai[1]]; + Vector2 directionToNextSegment = aheadSegment.Center - NPC.Center; + if (aheadSegment.rotation != NPC.rotation) { - try - { - segmentTilePos = NPC.Center; - playerXPos = Main.npc[(int)NPC.ai[1]].Center.X - segmentTilePos.X; - playerYPos = Main.npc[(int)NPC.ai[1]].Center.Y - segmentTilePos.Y; - } - catch - { - } - NPC.rotation = (float)System.Math.Atan2((double)playerYPos, (double)playerXPos) + MathHelper.PiOver2; - playerDistance = (float)System.Math.Sqrt((double)(playerXPos * playerXPos + playerYPos * playerYPos)); - - int segmentOffset = 72; - playerDistance = (playerDistance - segmentOffset) / playerDistance; - playerXPos *= playerDistance; - playerYPos *= playerDistance; - NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + playerXPos; - NPC.position.Y = NPC.position.Y + playerYPos; - - if (playerXPos < 0f) - NPC.spriteDirection = 1; - else if (playerXPos > 0f) - NPC.spriteDirection = -1; + directionToNextSegment = directionToNextSegment.RotatedBy(MathHelper.WrapAngle(aheadSegment.rotation - NPC.rotation) * 0.08f); + directionToNextSegment = directionToNextSegment.MoveTowards((aheadSegment.rotation - NPC.rotation).ToRotationVector2(), 1f); } + // Decide segment offset stuff. + int segmentOffset = 66; + NPC.rotation = directionToNextSegment.ToRotation() + MathHelper.PiOver2; + NPC.Center = aheadSegment.Center - directionToNextSegment.SafeNormalize(Vector2.Zero) * NPC.scale * segmentOffset; + NPC.spriteDirection = (directionToNextSegment.X > 0).ToDirectionInt(); + // Calculate contact damage based on velocity float maxChaseSpeed = Main.zenithWorld ? DesertNuisanceHead.SegmentVelocity_ZenithSeed : Main.getGoodWorld ? DesertNuisanceHead.SegmentVelocity_GoodWorld : diff --git a/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs b/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs index 4a5918c6d6..de9767ca12 100644 --- a/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs +++ b/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs @@ -38,8 +38,8 @@ namespace CalamityMod.NPCs.DesertScourge public override void SetDefaults() { NPC.GetNPCDamage(); - NPC.width = 76; - NPC.height = 76; + NPC.width = 78; + NPC.height = 78; NPC.defense = 4; if (Main.getGoodWorld) @@ -195,44 +195,20 @@ namespace CalamityMod.NPCs.DesertScourge if (Main.player[NPC.target].dead) NPC.TargetClosest(false); - Vector2 segmentTilePos = NPC.Center; - float playerXPos = Main.player[NPC.target].Center.X; - float playerYPos = Main.player[NPC.target].Center.Y; - playerXPos = (float)((int)(playerXPos / 16f) * 16); - playerYPos = (float)((int)(playerYPos / 16f) * 16); - segmentTilePos.X = (float)((int)(segmentTilePos.X / 16f) * 16); - segmentTilePos.Y = (float)((int)(segmentTilePos.Y / 16f) * 16); - playerXPos -= segmentTilePos.X; - playerYPos -= segmentTilePos.Y; - float playerDistance = (float)System.Math.Sqrt((double)(playerXPos * playerXPos + playerYPos * playerYPos)); - if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) + NPC aheadSegment = Main.npc[(int)NPC.ai[1]]; + Vector2 directionToNextSegment = aheadSegment.Center - NPC.Center; + if (aheadSegment.rotation != NPC.rotation) { - try - { - segmentTilePos = NPC.Center; - playerXPos = Main.npc[(int)NPC.ai[1]].Center.X - segmentTilePos.X; - playerYPos = Main.npc[(int)NPC.ai[1]].Center.Y - segmentTilePos.Y; - } - catch - { - } - NPC.rotation = (float)System.Math.Atan2((double)playerYPos, (double)playerXPos) + MathHelper.PiOver2; - playerDistance = (float)System.Math.Sqrt((double)(playerXPos * playerXPos + playerYPos * playerYPos)); - - int segmentOffset = 60; - playerDistance = (playerDistance - segmentOffset) / playerDistance; - playerXPos *= playerDistance; - playerYPos *= playerDistance; - NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + playerXPos; - NPC.position.Y = NPC.position.Y + playerYPos; - - if (playerXPos < 0f) - NPC.spriteDirection = 1; - else if (playerXPos > 0f) - NPC.spriteDirection = -1; + directionToNextSegment = directionToNextSegment.RotatedBy(MathHelper.WrapAngle(aheadSegment.rotation - NPC.rotation) * 0.08f); + directionToNextSegment = directionToNextSegment.MoveTowards((aheadSegment.rotation - NPC.rotation).ToRotationVector2(), 1f); } + // Decide segment offset stuff. + int segmentOffset = 58; + NPC.rotation = directionToNextSegment.ToRotation() + MathHelper.PiOver2; + NPC.Center = aheadSegment.Center - directionToNextSegment.SafeNormalize(Vector2.Zero) * NPC.scale * segmentOffset; + NPC.spriteDirection = (directionToNextSegment.X > 0).ToDirectionInt(); + // Calculate contact damage based on velocity float maxChaseSpeed = Main.zenithWorld ? DesertNuisanceHeadYoung.SegmentVelocity_ZenithSeed : Main.getGoodWorld ? DesertNuisanceHeadYoung.SegmentVelocity_GoodWorld : diff --git a/NPCs/DesertScourge/DesertNuisanceHead.cs b/NPCs/DesertScourge/DesertNuisanceHead.cs index 4f0dc7bbcb..bd6daab46f 100644 --- a/NPCs/DesertScourge/DesertNuisanceHead.cs +++ b/NPCs/DesertScourge/DesertNuisanceHead.cs @@ -57,8 +57,8 @@ namespace CalamityMod.NPCs.DesertScourge if (Main.getGoodWorld) NPC.defense += 18; - NPC.width = 92; - NPC.height = 92; + NPC.width = 88; + NPC.height = 88; NPC.lifeMax = BossRushEvent.BossRushActive ? 35000 : (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 4000 : 1300; double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; NPC.lifeMax += (int)(NPC.lifeMax * HPBoost); diff --git a/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs b/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs index 57ba06ea2a..62b69745d8 100644 --- a/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs +++ b/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs @@ -57,8 +57,8 @@ namespace CalamityMod.NPCs.DesertScourge if (Main.getGoodWorld) NPC.defense += 18; - NPC.width = 76; - NPC.height = 76; + NPC.width = 78; + NPC.height = 78; NPC.lifeMax = BossRushEvent.BossRushActive ? 35000 : (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 4000 : 1300; double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; NPC.lifeMax += (int)(NPC.lifeMax * HPBoost); diff --git a/NPCs/DesertScourge/DesertNuisanceTail.cs b/NPCs/DesertScourge/DesertNuisanceTail.cs index 95ce4a962a..0121f02613 100644 --- a/NPCs/DesertScourge/DesertNuisanceTail.cs +++ b/NPCs/DesertScourge/DesertNuisanceTail.cs @@ -20,8 +20,8 @@ namespace CalamityMod.NPCs.DesertScourge public override void SetDefaults() { NPC.GetNPCDamage(); - NPC.width = 92; - NPC.height = 92; + NPC.width = 88; + NPC.height = 88; NPC.defense = 7; if (Main.getGoodWorld) @@ -124,7 +124,7 @@ namespace CalamityMod.NPCs.DesertScourge NPC.rotation = (float)System.Math.Atan2((double)playerYPos, (double)playerXPos) + MathHelper.PiOver2; playerDistance = (float)System.Math.Sqrt((double)(playerXPos * playerXPos + playerYPos * playerYPos)); - int segmentOffset = 72; + int segmentOffset = 66; playerDistance = (playerDistance - segmentOffset) / playerDistance; playerXPos *= playerDistance; playerYPos *= playerDistance; diff --git a/NPCs/DesertScourge/DesertNuisanceTailYoung.cs b/NPCs/DesertScourge/DesertNuisanceTailYoung.cs index b5ec91282b..f26c17b312 100644 --- a/NPCs/DesertScourge/DesertNuisanceTailYoung.cs +++ b/NPCs/DesertScourge/DesertNuisanceTailYoung.cs @@ -20,8 +20,8 @@ namespace CalamityMod.NPCs.DesertScourge public override void SetDefaults() { NPC.GetNPCDamage(); - NPC.width = 76; - NPC.height = 76; + NPC.width = 78; + NPC.height = 78; NPC.defense = 7; if (Main.getGoodWorld) @@ -124,7 +124,7 @@ namespace CalamityMod.NPCs.DesertScourge NPC.rotation = (float)System.Math.Atan2((double)playerYPos, (double)playerXPos) + MathHelper.PiOver2; playerDistance = (float)System.Math.Sqrt((double)(playerXPos * playerXPos + playerYPos * playerYPos)); - int segmentOffset = 60; + int segmentOffset = 58; playerDistance = (playerDistance - segmentOffset) / playerDistance; playerXPos *= playerDistance; playerYPos *= playerDistance; diff --git a/NPCs/DesertScourge/DesertScourgeBody.cs b/NPCs/DesertScourge/DesertScourgeBody.cs index 0643d1d28f..30cdcfccfc 100644 --- a/NPCs/DesertScourge/DesertScourgeBody.cs +++ b/NPCs/DesertScourge/DesertScourgeBody.cs @@ -205,44 +205,20 @@ namespace CalamityMod.NPCs.DesertScourge if (Main.player[NPC.target].dead) NPC.TargetClosest(false); - Vector2 segmentTilePos = NPC.Center; - float playerXPos = Main.player[NPC.target].Center.X; - float playerYPos = Main.player[NPC.target].Center.Y; - playerXPos = (float)((int)(playerXPos / 16f) * 16); - playerYPos = (float)((int)(playerYPos / 16f) * 16); - segmentTilePos.X = (float)((int)(segmentTilePos.X / 16f) * 16); - segmentTilePos.Y = (float)((int)(segmentTilePos.Y / 16f) * 16); - playerXPos -= segmentTilePos.X; - playerYPos -= segmentTilePos.Y; - float playerDistance = (float)Math.Sqrt((double)(playerXPos * playerXPos + playerYPos * playerYPos)); - if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) + NPC aheadSegment = Main.npc[(int)NPC.ai[1]]; + Vector2 directionToNextSegment = aheadSegment.Center - NPC.Center; + if (aheadSegment.rotation != NPC.rotation) { - try - { - segmentTilePos = NPC.Center; - playerXPos = Main.npc[(int)NPC.ai[1]].Center.X - segmentTilePos.X; - playerYPos = Main.npc[(int)NPC.ai[1]].Center.Y - segmentTilePos.Y; - } - catch - { - } - NPC.rotation = (float)Math.Atan2((double)playerYPos, (double)playerXPos) + MathHelper.PiOver2; - playerDistance = (float)Math.Sqrt((double)(playerXPos * playerXPos + playerYPos * playerYPos)); - - int segmentOffset = 74; - playerDistance = (playerDistance - segmentOffset) / playerDistance; - playerXPos *= playerDistance; - playerYPos *= playerDistance; - NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + playerXPos; - NPC.position.Y = NPC.position.Y + playerYPos; - - if (playerXPos < 0f) - NPC.spriteDirection = 1; - else if (playerXPos > 0f) - NPC.spriteDirection = -1; + directionToNextSegment = directionToNextSegment.RotatedBy(MathHelper.WrapAngle(aheadSegment.rotation - NPC.rotation) * 0.08f); + directionToNextSegment = directionToNextSegment.MoveTowards((aheadSegment.rotation - NPC.rotation).ToRotationVector2(), 1f); } + // Decide segment offset stuff. + int segmentOffset = 74; + NPC.rotation = directionToNextSegment.ToRotation() + MathHelper.PiOver2; + NPC.Center = aheadSegment.Center - directionToNextSegment.SafeNormalize(Vector2.Zero) * NPC.scale * segmentOffset; + NPC.spriteDirection = (directionToNextSegment.X > 0).ToDirectionInt(); + NPC head = Main.npc[(int)NPC.ai[2]]; float burrowTimeGateValue = (CalamityWorld.death || BossRushEvent.BossRushActive) ? DesertScourgeHead.BurrowTimeGateValue_Death : DesertScourgeHead.BurrowTimeGateValue; bool burrow = head.Calamity().newAI[0] >= burrowTimeGateValue;