diff --git a/NPCs/Ravager/FlamePillar.cs b/NPCs/Ravager/FlamePillar.cs index 7e5d7f7777..4b61c255ff 100644 --- a/NPCs/Ravager/FlamePillar.cs +++ b/NPCs/Ravager/FlamePillar.cs @@ -149,17 +149,17 @@ namespace CalamityMod.NPCs.Ravager spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/Ravager/FlamePillarGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + Color flameBlue = Color.Lerp(Color.White, Color.Cyan, 0.5f); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, flameBlue, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -176,44 +176,44 @@ namespace CalamityMod.NPCs.Ravager NPC.height = 180; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 30; num621++) + for (int i = 0; i < 30; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 135, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int iceFlame = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 135, 0f, 0f, 100, default, 2f); + Main.dust[iceFlame].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[iceFlame].scale = 0.5f; + Main.dust[iceFlame].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Stone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int rockDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Stone, 0f, 0f, 100, default, 3f); + Main.dust[rockDust].noGravity = true; + Main.dust[rockDust].velocity *= 5f; + rockDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[rockDust].velocity *= 2f; } } else { - for (int num621 = 0; num621 < 2; num621++) + for (int i = 0; i < 2; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int iceFlame = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[iceFlame].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[iceFlame].scale = 0.5f; + Main.dust[iceFlame].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 2; num623++) + for (int j = 0; j < 2; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Stone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int rockDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Stone, 0f, 0f, 100, default, 3f); + Main.dust[rockDust].noGravity = true; + Main.dust[rockDust].velocity *= 5f; + rockDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[rockDust].velocity *= 2f; } } } diff --git a/NPCs/Ravager/RavagerBody.cs b/NPCs/Ravager/RavagerBody.cs index eabf873fe6..49b2079dd2 100644 --- a/NPCs/Ravager/RavagerBody.cs +++ b/NPCs/Ravager/RavagerBody.cs @@ -858,35 +858,35 @@ namespace CalamityMod.NPCs.Ravager spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); - Vector2 vector = center - screenPos; - vector -= new Vector2(ModContent.Request("CalamityMod/NPCs/Ravager/RavagerBodyGlow").Value.Width, ModContent.Request("CalamityMod/NPCs/Ravager/RavagerBodyGlow").Value.Height / Main.npcFrameCount[NPC.type]) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); - Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Color.Blue); - spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Ravager/RavagerBodyGlow").Value, vector, - NPC.frame, color, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); + Vector2 glowmaskPosition = center - screenPos; + glowmaskPosition -= new Vector2(ModContent.Request("CalamityMod/NPCs/Ravager/RavagerBodyGlow").Value.Width, ModContent.Request("CalamityMod/NPCs/Ravager/RavagerBodyGlow").Value.Height / Main.npcFrameCount[NPC.type]) * 1f / 2f; + glowmaskPosition += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + Color glowmaskColor = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Color.Blue); + spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Ravager/RavagerBodyGlow").Value, glowmaskPosition, + NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); float legOffset = 20f; float headOffset = 75f; - Color color2 = Lighting.GetColor((int)center.X / 16, (int)(center.Y / 16f)); + Color drawLighting = Lighting.GetColor((int)center.X / 16, (int)(center.Y / 16f)); if (NPC.IsABestiaryIconDummy) { - color2 = Color.White; + drawLighting = Color.White; legOffset = 60f; headOffset = 0f; } spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Ravager/RavagerLegRight").Value, new Vector2(center.X - screenPos.X + NPC.scale * 28f, center.Y - screenPos.Y + legOffset), //72 new Rectangle?(new Rectangle(0, 0, ModContent.Request("CalamityMod/NPCs/Ravager/RavagerLegRight").Value.Width, ModContent.Request("CalamityMod/NPCs/Ravager/RavagerLegRight").Value.Height)), - color2, 0f, default, NPC.scale, SpriteEffects.None, 0f); + drawLighting, 0f, default, NPC.scale, SpriteEffects.None, 0f); spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Ravager/RavagerLegLeft").Value, new Vector2(center.X - screenPos.X - NPC.scale * 112f, center.Y - screenPos.Y + legOffset), //72 new Rectangle?(new Rectangle(0, 0, ModContent.Request("CalamityMod/NPCs/Ravager/RavagerLegLeft").Value.Width, ModContent.Request("CalamityMod/NPCs/Ravager/RavagerLegLeft").Value.Height)), - color2, 0f, default, NPC.scale, SpriteEffects.None, 0f); + drawLighting, 0f, default, NPC.scale, SpriteEffects.None, 0f); if (NPC.AnyNPCs(ModContent.NPCType()) || NPC.IsABestiaryIconDummy) { spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Ravager/RavagerHead").Value, new Vector2(center.X - screenPos.X - NPC.scale * 70f, center.Y - screenPos.Y - NPC.scale * headOffset), new Rectangle?(new Rectangle(0, 0, ModContent.Request("CalamityMod/NPCs/Ravager/RavagerHead").Value.Width, ModContent.Request("CalamityMod/NPCs/Ravager/RavagerHead").Value.Height)), - color2, 0f, default, NPC.scale, SpriteEffects.None, 0f); + drawLighting, 0f, default, NPC.scale, SpriteEffects.None, 0f); } } diff --git a/NPCs/Ravager/RavagerClawLeft.cs b/NPCs/Ravager/RavagerClawLeft.cs index 7fe4eb3640..202654ffa7 100644 --- a/NPCs/Ravager/RavagerClawLeft.cs +++ b/NPCs/Ravager/RavagerClawLeft.cs @@ -81,14 +81,13 @@ namespace CalamityMod.NPCs.Ravager if (NPC.ai[0] == 0f) { NPC.noTileCollide = true; - float num659 = 36f; - Vector2 vector79 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num660 = Main.npc[CalamityGlobalNPC.scavenger].Center.X - vector79.X; - float num661 = Main.npc[CalamityGlobalNPC.scavenger].Center.Y - vector79.Y; - num660 -= 120f; - num661 += 50f; - float num662 = (float)Math.Sqrt(num660 * num660 + num661 * num661); - if (num662 < 12f + num659) + Vector2 npcCenter = new Vector2(NPC.Center.X, NPC.Center.Y); + float ravBodyXDist = Main.npc[CalamityGlobalNPC.scavenger].Center.X - npcCenter.X; + float ravBodyYDist = Main.npc[CalamityGlobalNPC.scavenger].Center.Y - npcCenter.Y; + ravBodyXDist -= 120f; + ravBodyYDist += 50f; + float ravBodyDistance = (float)Math.Sqrt(ravBodyXDist * ravBodyXDist + ravBodyYDist * ravBodyYDist); + if (ravBodyDistance < 48f) { NPC.rotation = 0f; NPC.Center = Main.npc[CalamityGlobalNPC.scavenger].Center + new Vector2(-120f, 50f); @@ -127,9 +126,9 @@ namespace CalamityMod.NPCs.Ravager } else { - num662 = num659 / num662; - NPC.velocity.X = num660 * num662; - NPC.velocity.Y = num661 * num662; + ravBodyDistance = 36f / ravBodyDistance; + NPC.velocity.X = ravBodyXDist * ravBodyDistance; + NPC.velocity.Y = ravBodyYDist * ravBodyDistance; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); } } @@ -139,26 +138,26 @@ namespace CalamityMod.NPCs.Ravager NPC.noTileCollide = true; NPC.collideX = false; NPC.collideY = false; - float num663 = 12f; + float clawSpeed = 12f; if (NPC.life < NPC.lifeMax / 2 || death) { - num663 += 2f; + clawSpeed += 2f; } if (NPC.life < NPC.lifeMax / 3 || death) { - num663 += 2f; + clawSpeed += 2f; } if (NPC.life < NPC.lifeMax / 5 || death) { - num663 += 5f; + clawSpeed += 5f; } - Vector2 vector80 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num664 = Main.player[NPC.target].Center.X - vector80.X; - float num665 = Main.player[NPC.target].Center.Y - vector80.Y; - float num666 = (float)Math.Sqrt(num664 * num664 + num665 * num665); - num666 = num663 / num666; - NPC.velocity.X = num664 * num666; - NPC.velocity.Y = num665 * num666; + Vector2 npcCenterAttack = new Vector2(NPC.Center.X, NPC.Center.Y); + float targetX = Main.player[NPC.target].Center.X - npcCenterAttack.X; + float targetY = Main.player[NPC.target].Center.Y - npcCenterAttack.Y; + float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); + targetDistance = clawSpeed / targetDistance; + NPC.velocity.X = targetX * targetDistance; + NPC.velocity.Y = targetY * targetDistance; NPC.ai[0] = 2f; NPC.rotation = (float)Math.Atan2(-NPC.velocity.Y, -NPC.velocity.X); } @@ -186,15 +185,15 @@ namespace CalamityMod.NPCs.Ravager NPC.noTileCollide = false; } } - Vector2 vector81 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num667 = Main.npc[CalamityGlobalNPC.scavenger].Center.X - vector81.X; - float num668 = Main.npc[CalamityGlobalNPC.scavenger].Center.Y - vector81.Y; - num667 += Main.npc[CalamityGlobalNPC.scavenger].velocity.X; - num668 += Main.npc[CalamityGlobalNPC.scavenger].velocity.Y; - num668 += 40f; - num667 -= 110f; - float num669 = (float)Math.Sqrt(num667 * num667 + num668 * num668); - if ((num669 > (death ? 900f : 700f) || NPC.collideX || NPC.collideY) | NPC.justHit) + Vector2 npcCenterRetract = new Vector2(NPC.Center.X, NPC.Center.Y); + float bodyReturnXDist = Main.npc[CalamityGlobalNPC.scavenger].Center.X - npcCenterRetract.X; + float bodyReturnYDist = Main.npc[CalamityGlobalNPC.scavenger].Center.Y - npcCenterRetract.Y; + bodyReturnXDist += Main.npc[CalamityGlobalNPC.scavenger].velocity.X; + bodyReturnYDist += Main.npc[CalamityGlobalNPC.scavenger].velocity.Y; + bodyReturnYDist += 40f; + bodyReturnXDist -= 110f; + float bodyReturnDistance = (float)Math.Sqrt(bodyReturnXDist * bodyReturnXDist + bodyReturnYDist * bodyReturnYDist); + if ((bodyReturnDistance > (death ? 900f : 700f) || NPC.collideX || NPC.collideY) | NPC.justHit) { NPC.noTileCollide = true; NPC.ai[0] = 0f; @@ -203,45 +202,44 @@ namespace CalamityMod.NPCs.Ravager else if (NPC.ai[0] == 3f) { NPC.noTileCollide = true; - float num671 = 12f; - float num672 = 0.4f; - Vector2 vector82 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num673 = Main.player[NPC.target].Center.X - vector82.X; - float num674 = Main.player[NPC.target].Center.Y - vector82.Y; - float num675 = (float)Math.Sqrt(num673 * num673 + num674 * num674); - num675 = num671 / num675; - num673 *= num675; - num674 *= num675; - if (NPC.velocity.X < num673) + float velocityMult = 0.4f; + Vector2 clawCenter = new Vector2(NPC.Center.X, NPC.Center.Y); + float playerX = Main.player[NPC.target].Center.X - clawCenter.X; + float playerY = Main.player[NPC.target].Center.Y - clawCenter.Y; + float playerDist = (float)Math.Sqrt(playerX * playerX + playerY * playerY); + playerDist = 12f / playerDist; + playerX *= playerDist; + playerY *= playerDist; + if (NPC.velocity.X < playerX) { - NPC.velocity.X += num672; - if (NPC.velocity.X < 0f && num673 > 0f) + NPC.velocity.X += velocityMult; + if (NPC.velocity.X < 0f && playerX > 0f) { - NPC.velocity.X += num672 * 2f; + NPC.velocity.X += velocityMult * 2f; } } - else if (NPC.velocity.X > num673) + else if (NPC.velocity.X > playerX) { - NPC.velocity.X -= num672; - if (NPC.velocity.X > 0f && num673 < 0f) + NPC.velocity.X -= velocityMult; + if (NPC.velocity.X > 0f && playerX < 0f) { - NPC.velocity.X -= num672 * 2f; + NPC.velocity.X -= velocityMult * 2f; } } - if (NPC.velocity.Y < num674) + if (NPC.velocity.Y < playerY) { - NPC.velocity.Y += num672; - if (NPC.velocity.Y < 0f && num674 > 0f) + NPC.velocity.Y += velocityMult; + if (NPC.velocity.Y < 0f && playerY > 0f) { - NPC.velocity.Y += num672 * 2f; + NPC.velocity.Y += velocityMult * 2f; } } - else if (NPC.velocity.Y > num674) + else if (NPC.velocity.Y > playerY) { - NPC.velocity.Y -= num672; - if (NPC.velocity.Y > 0f && num674 < 0f) + NPC.velocity.Y -= velocityMult; + if (NPC.velocity.Y > 0f && playerY < 0f) { - NPC.velocity.Y -= num672 * 2f; + NPC.velocity.Y -= velocityMult * 2f; } } NPC.rotation = (float)Math.Atan2(-NPC.velocity.Y, -NPC.velocity.X); @@ -302,11 +300,11 @@ namespace CalamityMod.NPCs.Ravager { if (NPC.life > 0) { - int num285 = 0; - while (num285 < hit.Damage / NPC.lifeMax * 100.0) + int dustCounter = 0; + while (dustCounter < hit.Damage / NPC.lifeMax * 100.0) { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f, 0, default, 1f); - num285++; + dustCounter++; } } else diff --git a/NPCs/Ravager/RavagerClawRight.cs b/NPCs/Ravager/RavagerClawRight.cs index 91518ff377..205e010f02 100644 --- a/NPCs/Ravager/RavagerClawRight.cs +++ b/NPCs/Ravager/RavagerClawRight.cs @@ -82,14 +82,13 @@ namespace CalamityMod.NPCs.Ravager if (NPC.ai[0] == 0f) { NPC.noTileCollide = true; - float num659 = 36f; - Vector2 vector79 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num660 = Main.npc[CalamityGlobalNPC.scavenger].Center.X - vector79.X; - float num661 = Main.npc[CalamityGlobalNPC.scavenger].Center.Y - vector79.Y; - num660 += 120f; - num661 += 50f; - float num662 = (float)Math.Sqrt(num660 * num660 + num661 * num661); - if (num662 < 12f + num659) + Vector2 npcCenter = new Vector2(NPC.Center.X, NPC.Center.Y); + float ravBodyXDist = Main.npc[CalamityGlobalNPC.scavenger].Center.X - npcCenter.X; + float ravBodyYDist = Main.npc[CalamityGlobalNPC.scavenger].Center.Y - npcCenter.Y; + ravBodyXDist += 120f; + ravBodyYDist += 50f; + float ravBodyDistance = (float)Math.Sqrt(ravBodyXDist * ravBodyXDist + ravBodyYDist * ravBodyYDist); + if (ravBodyDistance < 48f) { NPC.rotation = 0f; NPC.Center = Main.npc[CalamityGlobalNPC.scavenger].Center + new Vector2(120f, 50f); @@ -128,9 +127,9 @@ namespace CalamityMod.NPCs.Ravager } else { - num662 = num659 / num662; - NPC.velocity.X = num660 * num662; - NPC.velocity.Y = num661 * num662; + ravBodyDistance = 36f / ravBodyDistance; + NPC.velocity.X = ravBodyXDist * ravBodyDistance; + NPC.velocity.Y = ravBodyYDist * ravBodyDistance; NPC.rotation = (float)Math.Atan2(-NPC.velocity.Y, -NPC.velocity.X); } } @@ -140,26 +139,26 @@ namespace CalamityMod.NPCs.Ravager NPC.noTileCollide = true; NPC.collideX = false; NPC.collideY = false; - float num663 = 12f; + float clawSpeed = 12f; if (NPC.life < NPC.lifeMax / 2 || death) { - num663 += 2f; + clawSpeed += 2f; } if (NPC.life < NPC.lifeMax / 3 || death) { - num663 += 2f; + clawSpeed += 2f; } if (NPC.life < NPC.lifeMax / 5 || death) { - num663 += 5f; + clawSpeed += 5f; } - Vector2 vector80 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num664 = Main.player[NPC.target].Center.X - vector80.X; - float num665 = Main.player[NPC.target].Center.Y - vector80.Y; - float num666 = (float)Math.Sqrt(num664 * num664 + num665 * num665); - num666 = num663 / num666; - NPC.velocity.X = num664 * num666; - NPC.velocity.Y = num665 * num666; + Vector2 npcCenterAttack = new Vector2(NPC.Center.X, NPC.Center.Y); + float targetX = Main.player[NPC.target].Center.X - npcCenterAttack.X; + float targetY = Main.player[NPC.target].Center.Y - npcCenterAttack.Y; + float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); + targetDistance = clawSpeed / targetDistance; + NPC.velocity.X = targetX * targetDistance; + NPC.velocity.Y = targetY * targetDistance; NPC.ai[0] = 2f; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); } @@ -187,15 +186,15 @@ namespace CalamityMod.NPCs.Ravager NPC.noTileCollide = false; } } - Vector2 vector81 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num667 = Main.npc[CalamityGlobalNPC.scavenger].Center.X - vector81.X; - float num668 = Main.npc[CalamityGlobalNPC.scavenger].Center.Y - vector81.Y; - num667 += Main.npc[CalamityGlobalNPC.scavenger].velocity.X; - num668 += Main.npc[CalamityGlobalNPC.scavenger].velocity.Y; - num668 += 40f; - num667 += 110f; - float num669 = (float)Math.Sqrt(num667 * num667 + num668 * num668); - if ((num669 > (death ? 900f : 700f) || NPC.collideX || NPC.collideY) | NPC.justHit) + Vector2 npcCenterRetract = new Vector2(NPC.Center.X, NPC.Center.Y); + float bodyReturnXDist = Main.npc[CalamityGlobalNPC.scavenger].Center.X - npcCenterRetract.X; + float bodyReturnYDist = Main.npc[CalamityGlobalNPC.scavenger].Center.Y - npcCenterRetract.Y; + bodyReturnXDist += Main.npc[CalamityGlobalNPC.scavenger].velocity.X; + bodyReturnYDist += Main.npc[CalamityGlobalNPC.scavenger].velocity.Y; + bodyReturnYDist += 40f; + bodyReturnXDist += 110f; + float bodyReturnDistance = (float)Math.Sqrt(bodyReturnXDist * bodyReturnXDist + bodyReturnYDist * bodyReturnYDist); + if ((bodyReturnDistance > (death ? 900f : 700f) || NPC.collideX || NPC.collideY) | NPC.justHit) { NPC.noTileCollide = true; NPC.ai[0] = 0f; @@ -204,45 +203,44 @@ namespace CalamityMod.NPCs.Ravager else if (NPC.ai[0] == 3f) { NPC.noTileCollide = true; - float num671 = 12f; - float num672 = 0.4f; - Vector2 vector82 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num673 = Main.player[NPC.target].Center.X - vector82.X; - float num674 = Main.player[NPC.target].Center.Y - vector82.Y; - float num675 = (float)Math.Sqrt(num673 * num673 + num674 * num674); - num675 = num671 / num675; - num673 *= num675; - num674 *= num675; - if (NPC.velocity.X < num673) + float velocityMult = 0.4f; + Vector2 clawCenter = new Vector2(NPC.Center.X, NPC.Center.Y); + float playerX = Main.player[NPC.target].Center.X - clawCenter.X; + float playerY = Main.player[NPC.target].Center.Y - clawCenter.Y; + float playerDist = (float)Math.Sqrt(playerX * playerX + playerY * playerY); + playerDist = 12f / playerDist; + playerX *= playerDist; + playerY *= playerDist; + if (NPC.velocity.X < playerX) { - NPC.velocity.X += num672; - if (NPC.velocity.X < 0f && num673 > 0f) + NPC.velocity.X += velocityMult; + if (NPC.velocity.X < 0f && playerX > 0f) { - NPC.velocity.X += num672 * 2f; + NPC.velocity.X += velocityMult * 2f; } } - else if (NPC.velocity.X > num673) + else if (NPC.velocity.X > playerX) { - NPC.velocity.X -= num672; - if (NPC.velocity.X > 0f && num673 < 0f) + NPC.velocity.X -= velocityMult; + if (NPC.velocity.X > 0f && playerX < 0f) { - NPC.velocity.X -= num672 * 2f; + NPC.velocity.X -= velocityMult * 2f; } } - if (NPC.velocity.Y < num674) + if (NPC.velocity.Y < playerY) { - NPC.velocity.Y += num672; - if (NPC.velocity.Y < 0f && num674 > 0f) + NPC.velocity.Y += velocityMult; + if (NPC.velocity.Y < 0f && playerY > 0f) { - NPC.velocity.Y += num672 * 2f; + NPC.velocity.Y += velocityMult * 2f; } } - else if (NPC.velocity.Y > num674) + else if (NPC.velocity.Y > playerY) { - NPC.velocity.Y -= num672; - if (NPC.velocity.Y > 0f && num674 < 0f) + NPC.velocity.Y -= velocityMult; + if (NPC.velocity.Y > 0f && playerY < 0f) { - NPC.velocity.Y -= num672 * 2f; + NPC.velocity.Y -= velocityMult * 2f; } } NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); @@ -303,11 +301,11 @@ namespace CalamityMod.NPCs.Ravager { if (NPC.life > 0) { - int num285 = 0; - while (num285 < hit.Damage / NPC.lifeMax * 100.0) + int dustCounter = 0; + while (dustCounter < hit.Damage / NPC.lifeMax * 100.0) { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f, 0, default, 1f); - num285++; + dustCounter++; } } else diff --git a/NPCs/Ravager/RavagerHead.cs b/NPCs/Ravager/RavagerHead.cs index 5779b396d6..803f524d53 100644 --- a/NPCs/Ravager/RavagerHead.cs +++ b/NPCs/Ravager/RavagerHead.cs @@ -112,11 +112,11 @@ namespace CalamityMod.NPCs.Ravager { if (NPC.life > 0) { - int num285 = 0; - while ((double)num285 < hit.Damage / (double)NPC.lifeMax * 100.0) + int dustCounter = 0; + while ((double)dustCounter < hit.Damage / (double)NPC.lifeMax * 100.0) { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, (float)hit.HitDirection, -1f, 0, default, 1f); - num285++; + dustCounter++; } } else if (Main.netMode != NetmodeID.MultiplayerClient && !Main.zenithWorld) //GFB does something else diff --git a/NPCs/Ravager/RavagerHead2.cs b/NPCs/Ravager/RavagerHead2.cs index 4a2cffaa40..543f15d387 100644 --- a/NPCs/Ravager/RavagerHead2.cs +++ b/NPCs/Ravager/RavagerHead2.cs @@ -74,38 +74,38 @@ namespace CalamityMod.NPCs.Ravager NPC.timeLeft = 1800; // Rotation - float num801 = NPC.position.X + (NPC.width / 2) - player.position.X - (player.width / 2); - float num802 = NPC.position.Y + NPC.height - 59f - player.position.Y - (player.height / 2); - float num803 = (float)Math.Atan2(num802, num801) + MathHelper.PiOver2; - if (num803 < 0f) - num803 += MathHelper.TwoPi; - else if (num803 > MathHelper.TwoPi) - num803 -= MathHelper.TwoPi; + float playerXDist = NPC.position.X + (NPC.width / 2) - player.position.X - (player.width / 2); + float playerYDist = NPC.position.Y + NPC.height - 59f - player.position.Y - (player.height / 2); + float headRotation = (float)Math.Atan2(playerYDist, playerXDist) + MathHelper.PiOver2; + if (headRotation < 0f) + headRotation += MathHelper.TwoPi; + else if (headRotation > MathHelper.TwoPi) + headRotation -= MathHelper.TwoPi; - float num804 = 0.1f; - if (NPC.rotation < num803) + float headRotateIncrement = 0.1f; + if (NPC.rotation < headRotation) { - if ((num803 - NPC.rotation) > MathHelper.Pi) - NPC.rotation -= num804; + if ((headRotation - NPC.rotation) > MathHelper.Pi) + NPC.rotation -= headRotateIncrement; else - NPC.rotation += num804; + NPC.rotation += headRotateIncrement; } - else if (NPC.rotation > num803) + else if (NPC.rotation > headRotation) { - if ((NPC.rotation - num803) > MathHelper.Pi) - NPC.rotation += num804; + if ((NPC.rotation - headRotation) > MathHelper.Pi) + NPC.rotation += headRotateIncrement; else - NPC.rotation -= num804; + NPC.rotation -= headRotateIncrement; } - if (NPC.rotation > num803 - num804 && NPC.rotation < num803 + num804) - NPC.rotation = num803; + if (NPC.rotation > headRotation - headRotateIncrement && NPC.rotation < headRotation + headRotateIncrement) + NPC.rotation = headRotation; if (NPC.rotation < 0f) NPC.rotation += MathHelper.TwoPi; else if (NPC.rotation > MathHelper.TwoPi) NPC.rotation -= MathHelper.TwoPi; - if (NPC.rotation > num803 - num804 && NPC.rotation < num803 + num804) - NPC.rotation = num803; + if (NPC.rotation > headRotation - headRotateIncrement && NPC.rotation < headRotation + headRotateIncrement) + NPC.rotation = headRotation; NPC.ai[1] += 1f; bool fireProjectiles = NPC.ai[1] >= (bossRush ? 240f : 480f); @@ -141,52 +141,52 @@ namespace CalamityMod.NPCs.Ravager } } - float num823 = 22f; - float num824 = 0.3f; + float attackMovementVel = 22f; + float attackMovementAccel = 0.3f; if (death) { - num823 += 4f; - num824 += 0.05f; + attackMovementVel += 4f; + attackMovementAccel += 0.05f; } if (provy) { - num823 *= 1.25f; - num824 *= 1.25f; + attackMovementVel *= 1.25f; + attackMovementAccel *= 1.25f; } - Vector2 vector82 = NPC.Center; + Vector2 npcCenter = NPC.Center; float distanceX = NPC.ai[0] % 2f == 0f ? 480f : -480f; float distanceY = fireProjectiles ? -320f : 320f; - float num825 = player.Center.X + (fireProjectiles ? distanceX : 0f) - vector82.X; - float num826 = player.Center.Y + distanceY - vector82.Y; - float num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); - num827 = num823 / num827; - num825 *= num827; - num826 *= num827; + float playerXDistAttack = player.Center.X + (fireProjectiles ? distanceX : 0f) - npcCenter.X; + float playerYDistAttack = player.Center.Y + distanceY - npcCenter.Y; + float playerDistanceAttack = (float)Math.Sqrt(playerXDistAttack * playerXDistAttack + playerYDistAttack * playerYDistAttack); + playerDistanceAttack = attackMovementVel / playerDistanceAttack; + playerXDistAttack *= playerDistanceAttack; + playerYDistAttack *= playerDistanceAttack; - if (NPC.velocity.X < num825) + if (NPC.velocity.X < playerXDistAttack) { - NPC.velocity.X += num824; - if (NPC.velocity.X < 0f && num825 > 0f) - NPC.velocity.X += num824; + NPC.velocity.X += attackMovementAccel; + if (NPC.velocity.X < 0f && playerXDistAttack > 0f) + NPC.velocity.X += attackMovementAccel; } - else if (NPC.velocity.X > num825) + else if (NPC.velocity.X > playerXDistAttack) { - NPC.velocity.X -= num824; - if (NPC.velocity.X > 0f && num825 < 0f) - NPC.velocity.X -= num824; + NPC.velocity.X -= attackMovementAccel; + if (NPC.velocity.X > 0f && playerXDistAttack < 0f) + NPC.velocity.X -= attackMovementAccel; } - if (NPC.velocity.Y < num826) + if (NPC.velocity.Y < playerYDistAttack) { - NPC.velocity.Y += num824; - if (NPC.velocity.Y < 0f && num826 > 0f) - NPC.velocity.Y += num824; + NPC.velocity.Y += attackMovementAccel; + if (NPC.velocity.Y < 0f && playerYDistAttack > 0f) + NPC.velocity.Y += attackMovementAccel; } - else if (NPC.velocity.Y > num826) + else if (NPC.velocity.Y > playerYDistAttack) { - NPC.velocity.Y -= num824; - if (NPC.velocity.Y > 0f && num826 < 0f) - NPC.velocity.Y -= num824; + NPC.velocity.Y -= attackMovementAccel; + if (NPC.velocity.Y > 0f && playerYDistAttack < 0f) + NPC.velocity.Y -= attackMovementAccel; } } diff --git a/NPCs/Ravager/RockPillar.cs b/NPCs/Ravager/RockPillar.cs index 50a59b8c75..953f224ad4 100644 --- a/NPCs/Ravager/RockPillar.cs +++ b/NPCs/Ravager/RockPillar.cs @@ -77,23 +77,23 @@ namespace CalamityMod.NPCs.Ravager { SoundEngine.PlaySound(SoundID.Item62, NPC.Center); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int rockDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[rockDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[rockDust].scale = 0.5f; + Main.dust[rockDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Stone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int rockDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Stone, 0f, 0f, 100, default, 3f); + Main.dust[rockDust2].noGravity = true; + Main.dust[rockDust2].velocity *= 5f; + rockDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[rockDust2].velocity *= 2f; } NPC.noTileCollide = true; @@ -151,23 +151,23 @@ namespace CalamityMod.NPCs.Ravager NPC.height = 360; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 30; num621++) + for (int i = 0; i < 30; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int rockDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[rockDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[rockDust].scale = 0.5f; + Main.dust[rockDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 30; num623++) + for (int j = 0; j < 30; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Stone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int rockDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Stone, 0f, 0f, 100, default, 3f); + Main.dust[rockDust2].noGravity = true; + Main.dust[rockDust2].velocity *= 5f; + rockDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[rockDust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) @@ -188,23 +188,23 @@ namespace CalamityMod.NPCs.Ravager } else { - for (int num621 = 0; num621 < 2; num621++) + for (int i = 0; i < 2; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int rockDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[rockDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[rockDust].scale = 0.5f; + Main.dust[rockDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 2; num623++) + for (int j = 0; j < 2; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Stone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int rockDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Stone, 0f, 0f, 100, default, 3f); + Main.dust[rockDust2].noGravity = true; + Main.dust[rockDust2].velocity *= 5f; + rockDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[rockDust2].velocity *= 2f; } } } diff --git a/NPCs/Signus/CosmicLantern.cs b/NPCs/Signus/CosmicLantern.cs index 7ae8f2477d..fddafbc722 100644 --- a/NPCs/Signus/CosmicLantern.cs +++ b/NPCs/Signus/CosmicLantern.cs @@ -92,9 +92,9 @@ namespace CalamityMod.NPCs.Signus if (NPC.alpha < 0) { NPC.alpha = 0; - int num1262 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 204, 0f, 0f, 0, default, 0.25f); - Main.dust[num1262].velocity *= 0.1f; - Main.dust[num1262].noGravity = true; + int lightDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 204, 0f, 0f, 0, default, 0.25f); + Main.dust[lightDust].velocity *= 0.1f; + Main.dust[lightDust].noGravity = true; } bool revenge = CalamityWorld.revenge; @@ -111,50 +111,48 @@ namespace CalamityMod.NPCs.Signus spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + int afterimageAmt = 5; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/Signus/CosmicLanternGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + Color cyanLerp = Color.Lerp(Color.White, Color.Cyan, 0.5f); if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = NPC.GetAlpha(color41); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color flameAfterimageColor = cyanLerp; + flameAfterimageColor = Color.Lerp(flameAfterimageColor, Color.White, 0.5f); + flameAfterimageColor = NPC.GetAlpha(flameAfterimageColor); + flameAfterimageColor *= (float)(afterimageAmt - j) / 15f; + Vector2 flameAfterimagePos = NPC.oldPos[j] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + flameAfterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + flameAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, flameAfterimagePos, NPC.frame, flameAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, cyanLerp, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/Signus/CosmicMine.cs b/NPCs/Signus/CosmicMine.cs index da2bb1d95d..39bbd0604b 100644 --- a/NPCs/Signus/CosmicMine.cs +++ b/NPCs/Signus/CosmicMine.cs @@ -119,18 +119,18 @@ namespace CalamityMod.NPCs.Signus } } - float num1372 = death ? 16f : 14f; + float mineSpeed = death ? 16f : 14f; Vector2 vector167 = new Vector2(NPC.Center.X + (NPC.direction * 20), NPC.Center.Y + 6f); - float num1373 = player.position.X + player.width * 0.5f - vector167.X; - float num1374 = player.Center.Y - vector167.Y; - float num1375 = (float)Math.Sqrt(num1373 * num1373 + num1374 * num1374); - float num1376 = num1372 / num1375; - num1373 *= num1376; - num1374 *= num1376; + float playerXDist = player.position.X + player.width * 0.5f - vector167.X; + float playerYDist = player.Center.Y - vector167.Y; + float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); + float velocityMult = mineSpeed / playerDistance; + playerXDist *= velocityMult; + playerYDist *= velocityMult; NPC.ai[0] -= 1f; - if (num1375 < 200f || NPC.ai[0] > 0f) + if (playerDistance < 200f || NPC.ai[0] > 0f) { - if (num1375 < 200f) + if (playerDistance < 200f) { NPC.ai[0] = 20f; } @@ -145,17 +145,17 @@ namespace CalamityMod.NPCs.Signus return; } - NPC.velocity.X = (NPC.velocity.X * 50f + num1373) / 51f; - NPC.velocity.Y = (NPC.velocity.Y * 50f + num1374) / 51f; - if (num1375 < 350f) + NPC.velocity.X = (NPC.velocity.X * 50f + playerXDist) / 51f; + NPC.velocity.Y = (NPC.velocity.Y * 50f + playerYDist) / 51f; + if (playerDistance < 350f) { - NPC.velocity.X = (NPC.velocity.X * 10f + num1373) / 11f; - NPC.velocity.Y = (NPC.velocity.Y * 10f + num1374) / 11f; + NPC.velocity.X = (NPC.velocity.X * 10f + playerXDist) / 11f; + NPC.velocity.Y = (NPC.velocity.Y * 10f + playerYDist) / 11f; } - if (num1375 < 300f) + if (playerDistance < 300f) { - NPC.velocity.X = (NPC.velocity.X * 7f + num1373) / 8f; - NPC.velocity.Y = (NPC.velocity.Y * 7f + num1374) / 8f; + NPC.velocity.X = (NPC.velocity.X * 7f + playerXDist) / 8f; + NPC.velocity.Y = (NPC.velocity.Y * 7f + playerYDist) / 8f; } } @@ -171,30 +171,28 @@ namespace CalamityMod.NPCs.Signus spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / 2); + int afterimageAmt = 5; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -208,25 +206,25 @@ namespace CalamityMod.NPCs.Signus NPC.width = NPC.height = 256; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int cosmiliteDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[cosmiliteDust].scale = 0.5f; + Main.dust[cosmiliteDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } - Main.dust[num622].noGravity = true; + Main.dust[cosmiliteDust].noGravity = true; } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - Main.dust[num624].noGravity = true; + int cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[cosmiliteDust2].noGravity = true; + Main.dust[cosmiliteDust2].velocity *= 5f; + cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust2].velocity *= 2f; + Main.dust[cosmiliteDust2].noGravity = true; } return true; } diff --git a/NPCs/Signus/Signus.cs b/NPCs/Signus/Signus.cs index 7d4e7e6e39..9f2f65c90f 100644 --- a/NPCs/Signus/Signus.cs +++ b/NPCs/Signus/Signus.cs @@ -185,14 +185,14 @@ namespace CalamityMod.NPCs.Signus if (lifeToAlpha < (Main.getGoodWorld ? 100 : 50) && NPC.ai[0] != 1f) { - for (int num1011 = 0; num1011 < 2; num1011++) + for (int i = 0; i < 2; i++) { if (Main.rand.Next(3) < 1) { - int num1012 = Dust.NewDust(vectorCenter - new Vector2(70f), 70 * 2, 70 * 2, (int)CalamityDusts.PurpleCosmilite, NPC.velocity.X * 0.5f, NPC.velocity.Y * 0.5f, 90, default, 1.5f); - Main.dust[num1012].noGravity = true; - Main.dust[num1012].velocity *= 0.2f; - Main.dust[num1012].fadeIn = 1f; + int cosmiliteDust = Dust.NewDust(vectorCenter - new Vector2(70f), 70 * 2, 70 * 2, (int)CalamityDusts.PurpleCosmilite, NPC.velocity.X * 0.5f, NPC.velocity.Y * 0.5f, 90, default, 1.5f); + Main.dust[cosmiliteDust].noGravity = true; + Main.dust[cosmiliteDust].velocity *= 0.2f; + Main.dust[cosmiliteDust].fadeIn = 1f; } } } @@ -238,19 +238,19 @@ namespace CalamityMod.NPCs.Signus if (expertMode) speed += death ? 6f * (float)(1D - lifeRatio) : 4f * (float)(1D - lifeRatio); - float num795 = player.Center.X - vectorCenter.X; - float num796 = player.Center.Y - vectorCenter.Y; - float num797 = (float)Math.Sqrt(num795 * num795 + num796 * num796); - num797 = speed / num797; - num795 *= num797; - num796 *= num797; + float playerXDist = player.Center.X - vectorCenter.X; + float playerYDist = player.Center.Y - vectorCenter.Y; + float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); + playerDistance = speed / playerDistance; + playerXDist *= playerDistance; + playerYDist *= playerDistance; float inertia2 = 50f; if (Main.getGoodWorld) inertia2 *= 0.5f; - NPC.velocity.X = (NPC.velocity.X * inertia2 + num795) / (inertia2 + 1f); - NPC.velocity.Y = (NPC.velocity.Y * inertia2 + num796) / (inertia2 + 1f); + NPC.velocity.X = (NPC.velocity.X * inertia2 + playerXDist) / (inertia2 + 1f); + NPC.velocity.Y = (NPC.velocity.Y * inertia2 + playerYDist) / (inertia2 + 1f); } else NPC.knockBackResist = 0f; @@ -284,38 +284,38 @@ namespace CalamityMod.NPCs.Signus NPC.TargetClosest(); - int num1249 = 0; - int num1250; - int num1251; + int maxTeleportTries = 0; + int playerTileX; + int playerTileY; while (true) { - num1249++; - num1250 = (int)player.Center.X / 16; - num1251 = (int)player.Center.Y / 16; + maxTeleportTries++; + playerTileX = (int)player.Center.X / 16; + playerTileY = (int)player.Center.Y / 16; int min = 14; int max = 18; if (Main.rand.NextBool()) - num1250 += Main.rand.Next(min, max); + playerTileX += Main.rand.Next(min, max); else - num1250 -= Main.rand.Next(min, max); + playerTileX -= Main.rand.Next(min, max); if (Main.rand.NextBool()) - num1251 += Main.rand.Next(min, max); + playerTileY += Main.rand.Next(min, max); else - num1251 -= Main.rand.Next(min, max); + playerTileY -= Main.rand.Next(min, max); - if (!WorldGen.SolidTile(num1250, num1251)) + if (!WorldGen.SolidTile(playerTileX, playerTileY)) break; - if (num1249 > 100) + if (maxTeleportTries > 100) return; } NPC.ai[0] = 1f; - NPC.ai[1] = num1250; - NPC.ai[2] = num1251; + NPC.ai[1] = playerTileX; + NPC.ai[2] = playerTileY; NPC.netUpdate = true; @@ -350,8 +350,8 @@ namespace CalamityMod.NPCs.Signus for (int n = 0; n < 15; n++) { - int num39 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 90, default, 3f); - Main.dust[num39].noGravity = true; + int cosmiliteDusty = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 90, default, 3f); + Main.dust[cosmiliteDusty].noGravity = true; } NPC.ai[0] = 2f; @@ -371,60 +371,60 @@ namespace CalamityMod.NPCs.Signus { SoundEngine.PlaySound(SoundID.Item122, NPC.Center); - int num660 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X + 750f), (int)player.position.Y, ModContent.NPCType()); + int cosmicMineSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X + 750f), (int)player.position.Y, ModContent.NPCType()); if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num660, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, cosmicMineSpawn, 0f, 0f, 0f, 0, 0, 0); - int num661 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X - 750f), (int)player.position.Y, ModContent.NPCType()); + int cosmicMineSpawn2 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X - 750f), (int)player.position.Y, ModContent.NPCType()); if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num661, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, cosmicMineSpawn2, 0f, 0f, 0f, 0, 0, 0); if (stealthTimer >= maxStealth) { - int num662 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X + 950f), (int)player.position.Y, ModContent.NPCType()); + int stealthCosmicMine = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X + 950f), (int)player.position.Y, ModContent.NPCType()); if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num662, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, stealthCosmicMine, 0f, 0f, 0f, 0, 0, 0); - int num663 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X - 950f), (int)player.position.Y, ModContent.NPCType()); + int stealthCosmicMine2 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X - 950f), (int)player.position.Y, ModContent.NPCType()); if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num663, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, stealthCosmicMine2, 0f, 0f, 0f, 0, 0, 0); SoundEngine.PlaySound(RaidersTalisman.StealthHitSound, NPC.Center); stealthTimer = 0; } - for (int num621 = 0; num621 < 5; num621++) + for (int i = 0; i < 5; i++) { - int num622 = Dust.NewDust(new Vector2(player.position.X + 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - Main.dust[num622].noGravity = true; + int teleportDust = Dust.NewDust(new Vector2(player.position.X + 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[teleportDust].velocity *= 3f; + Main.dust[teleportDust].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[teleportDust].scale = 0.5f; + Main.dust[teleportDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } - int num623 = Dust.NewDust(new Vector2(player.position.X - 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num623].velocity *= 3f; - Main.dust[num623].noGravity = true; + int j = Dust.NewDust(new Vector2(player.position.X - 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[j].velocity *= 3f; + Main.dust[j].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[num623].scale = 0.5f; - Main.dust[num623].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[j].scale = 0.5f; + Main.dust[j].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(new Vector2(player.position.X + 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(player.position.X + 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - int num625 = Dust.NewDust(new Vector2(player.position.X - 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num625].noGravity = true; - Main.dust[num625].velocity *= 5f; - num625 = Dust.NewDust(new Vector2(player.position.X - 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num625].velocity *= 2f; + int teleportDust2 = Dust.NewDust(new Vector2(player.position.X + 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[teleportDust2].noGravity = true; + Main.dust[teleportDust2].velocity *= 5f; + teleportDust2 = Dust.NewDust(new Vector2(player.position.X + 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[teleportDust2].velocity *= 2f; + int teleportDusty = Dust.NewDust(new Vector2(player.position.X - 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[teleportDusty].noGravity = true; + Main.dust[teleportDusty].velocity *= 5f; + teleportDusty = Dust.NewDust(new Vector2(player.position.X - 750f, player.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[teleportDusty].velocity *= 2f; } } @@ -466,16 +466,15 @@ namespace CalamityMod.NPCs.Signus { if (Main.netMode != NetmodeID.MultiplayerClient) { - float num1070 = 15f; - float num1071 = player.Center.X - vectorCenter.X; - float num1072 = player.Center.Y - vectorCenter.Y; - float num1073 = (float)Math.Sqrt(num1071 * num1071 + num1072 * num1072); - num1073 = num1070 / num1073; - num1071 *= num1073; - num1072 *= num1073; + float scytheXDist = player.Center.X - vectorCenter.X; + float scytheYDist = player.Center.Y - vectorCenter.Y; + float scytheDistance = (float)Math.Sqrt(scytheXDist * scytheXDist + scytheYDist * scytheYDist); + scytheDistance = 15f / scytheDistance; + scytheXDist *= scytheDistance; + scytheYDist *= scytheDistance; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter.X, vectorCenter.Y, num1071, num1072, type, damage, 0f, Main.myPlayer, 0f, NPC.target + 1); + Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter.X, vectorCenter.Y, scytheXDist, scytheYDist, type, damage, 0f, Main.myPlayer, 0f, NPC.target + 1); if (stealthTimer >= maxStealth) { damage *= 2; @@ -483,7 +482,7 @@ namespace CalamityMod.NPCs.Signus for (int i = 0; i < 4; i++) { Vector2 offset = new Vector2(Main.rand.Next(-5, 6), Main.rand.Next(-5, 6)); - Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter.X, vectorCenter.Y, num1071 + offset.X, num1072 + offset.Y, type, damage, 0f, Main.myPlayer, 0f, NPC.target + 1); + Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter.X, vectorCenter.Y, scytheXDist + offset.X, scytheYDist + offset.Y, type, damage, 0f, Main.myPlayer, 0f, NPC.target + 1); } stealthTimer = 0; } @@ -567,23 +566,23 @@ namespace CalamityMod.NPCs.Signus { type = ModContent.NPCType(); } - int num660 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X + spawnX), (int)(player.position.Y + spawnY), type); + int cosmicMineSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X + spawnX), (int)(player.position.Y + spawnY), type); if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num660, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, cosmicMineSpawn, 0f, 0f, 0f, 0, 0, 0); - int num661 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X - spawnX), (int)(player.position.Y + spawnY), type); + int cosmicMineSpawn2 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X - spawnX), (int)(player.position.Y + spawnY), type); if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num661, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, cosmicMineSpawn2, 0f, 0f, 0f, 0, 0, 0); if (buffed) { - int num662 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X + spawnX + spawnX / 2), (int)(player.position.Y + spawnY), ModContent.NPCType()); + int stealthCosmicMine = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X + spawnX + spawnX / 2), (int)(player.position.Y + spawnY), ModContent.NPCType()); if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num662, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, stealthCosmicMine, 0f, 0f, 0f, 0, 0, 0); - int num663 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X - spawnX - spawnX / 2), (int)(player.position.Y + spawnY), ModContent.NPCType()); + int stealthCosmicMine2 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.position.X - spawnX - spawnX / 2), (int)(player.position.Y + spawnY), ModContent.NPCType()); if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num663, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, stealthCosmicMine2, 0f, 0f, 0f, 0, 0, 0); } spawnY -= 60; @@ -614,22 +613,19 @@ namespace CalamityMod.NPCs.Signus if (expertMode) velocity += death ? 6f * (float)(1D - lifeRatio) : 4f * (float)(1D - lifeRatio); - Vector2 vector126 = player.Center - vectorCenter; - Vector2 vector127 = vector126 - Vector2.UnitY * 300f; + Vector2 playerCenterDist = player.Center - vectorCenter; + Vector2 playerHoverAboveDist = playerCenterDist - Vector2.UnitY * 300f; - float num1013 = vector126.Length(); + playerCenterDist = Vector2.Normalize(playerCenterDist) * velocity; + playerHoverAboveDist = Vector2.Normalize(playerHoverAboveDist) * velocity; - vector126 = Vector2.Normalize(vector126) * velocity; - vector127 = Vector2.Normalize(vector127) * velocity; - - bool flag64 = Collision.CanHit(vectorCenter, 1, 1, player.Center, 1, 1) || NPC.ai[3] >= 120f; - float num1014 = 8f; - flag64 = flag64 && vector126.ToRotation() > MathHelper.Pi / num1014 && vector126.ToRotation() < MathHelper.Pi - MathHelper.Pi / num1014; - if (num1013 > 1400f || !flag64) + bool canLineUpCharge = Collision.CanHit(vectorCenter, 1, 1, player.Center, 1, 1) || NPC.ai[3] >= 120f; + canLineUpCharge = canLineUpCharge && playerCenterDist.ToRotation() > MathHelper.Pi / 8f && playerCenterDist.ToRotation() < MathHelper.Pi - MathHelper.Pi / 8f; + if (playerCenterDist.Length() > 1400f || !canLineUpCharge) { - NPC.velocity = (NPC.velocity * (inertia - 1f) + vector127) / inertia; + NPC.velocity = (NPC.velocity * (inertia - 1f) + playerHoverAboveDist) / inertia; - if (!flag64) + if (!canLineUpCharge) { NPC.ai[3] += 1f; if (NPC.ai[3] == 120f) @@ -641,8 +637,8 @@ namespace CalamityMod.NPCs.Signus else { calamityGlobalNPC.newAI[0] = 1f; - NPC.ai[2] = vector126.X; - NPC.ai[3] = vector126.Y; + NPC.ai[2] = playerCenterDist.X; + NPC.ai[3] = playerCenterDist.Y; NPC.netUpdate = true; } } @@ -694,8 +690,8 @@ namespace CalamityMod.NPCs.Signus } NPC.ai[1] += 1f; - bool flag65 = vectorCenter.Y + 50f > player.Center.Y; - if ((NPC.ai[1] >= 90f && flag65) || NPC.velocity.Length() < 8f) + bool shouldEndCharge = vectorCenter.Y + 50f > player.Center.Y; + if ((NPC.ai[1] >= 90f && shouldEndCharge) || NPC.velocity.Length() < 8f) { calamityGlobalNPC.newAI[0] = 3f; NPC.ai[1] = 30f; @@ -709,12 +705,12 @@ namespace CalamityMod.NPCs.Signus } else { - Vector2 vec2 = player.Center - vectorCenter; - vec2.Normalize(); - if (vec2.HasNaNs()) - vec2 = new Vector2(NPC.direction, 0f); + Vector2 distFromPlayerCenter = player.Center - vectorCenter; + distFromPlayerCenter.Normalize(); + if (distFromPlayerCenter.HasNaNs()) + distFromPlayerCenter = new Vector2(NPC.direction, 0f); - NPC.velocity = (NPC.velocity * (inertia - 1f) + vec2 * (NPC.velocity.Length() + 0.111111117f * inertia)) / inertia; + NPC.velocity = (NPC.velocity * (inertia - 1f) + distFromPlayerCenter * (NPC.velocity.Length() + 0.111111117f * inertia)) / inertia; } } else if (calamityGlobalNPC.newAI[0] == 3f) // Slow down after charging and reset @@ -782,7 +778,7 @@ namespace CalamityMod.NPCs.Signus if (NPC.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; - int num153 = 5; + int afterimageAmt = 5; Rectangle frame = NPC.frame; int frameCount = Main.npcFrameCount[NPC.type]; @@ -790,7 +786,7 @@ namespace CalamityMod.NPCs.Signus { NPCTexture = ModContent.Request("CalamityMod/NPCs/Signus/SignusAlt2").Value; glowMaskTexture = ModContent.Request("CalamityMod/NPCs/Signus/SignusAlt2Glow").Value; - num153 = 10; + afterimageAmt = 10; int frameY = 94 * (int)(NPC.frameCounter / 12.0); if (frameY >= 94 * 6) frameY = 0; @@ -800,7 +796,7 @@ namespace CalamityMod.NPCs.Signus { NPCTexture = ModContent.Request("CalamityMod/NPCs/Signus/SignusAlt").Value; glowMaskTexture = ModContent.Request("CalamityMod/NPCs/Signus/SignusAltGlow").Value; - num153 = 7; + afterimageAmt = 7; } else { @@ -808,9 +804,7 @@ namespace CalamityMod.NPCs.Signus glowMaskTexture = ModContent.Request("CalamityMod/NPCs/Signus/SignusGlow").Value; } - Vector2 vector11 = new Vector2(NPCTexture.Width / 2, NPCTexture.Height / frameCount / 2); - Color color36 = Color.White; - float amount9 = 0.5f; + Vector2 halfSizeTexture = new Vector2(NPCTexture.Width / 2, NPCTexture.Height / frameCount / 2); float scale = NPC.scale; float rotation = NPC.rotation; float offsetY = NPC.gfxOffY; @@ -822,42 +816,42 @@ namespace CalamityMod.NPCs.Signus if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(NPCTexture.Width, NPCTexture.Height / frameCount) * scale / 2f; - vector41 += vector11 * scale + new Vector2(0f, 4f + offsetY); - spriteBatch.Draw(NPCTexture, vector41, new Rectangle?(frame), color38 * transparency, rotation, vector11, scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(NPCTexture.Width, NPCTexture.Height / frameCount) * scale / 2f; + afterimagePos += halfSizeTexture * scale + new Vector2(0f, 4f + offsetY); + spriteBatch.Draw(NPCTexture, afterimagePos, new Rectangle?(frame), afterimageColor * transparency, rotation, halfSizeTexture, scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(NPCTexture.Width, NPCTexture.Height / frameCount) * scale / 2f; - vector43 += vector11 * scale + new Vector2(0f, 4f + offsetY); - spriteBatch.Draw(NPCTexture, vector43, new Rectangle?(frame), NPC.GetAlpha(drawColor) * transparency, rotation, vector11, scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(NPCTexture.Width, NPCTexture.Height / frameCount) * scale / 2f; + drawLocation += halfSizeTexture * scale + new Vector2(0f, 4f + offsetY); + spriteBatch.Draw(NPCTexture, drawLocation, new Rectangle?(frame), NPC.GetAlpha(drawColor) * transparency, rotation, halfSizeTexture, scale, spriteEffects, 0f); - Color color40 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + Color eyeGlowColor = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); if (Main.zenithWorld) { - color40 = Color.MediumBlue; + eyeGlowColor = Color.MediumBlue; } if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color40; - color41 = Color.Lerp(color41, color36, amount9); - color41 = NPC.GetAlpha(color41); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector44 -= new Vector2(glowMaskTexture.Width, glowMaskTexture.Height / frameCount) * scale / 2f; - vector44 += vector11 * scale + new Vector2(0f, 4f + offsetY); - spriteBatch.Draw(glowMaskTexture, vector44, new Rectangle?(frame), color41, rotation, vector11, scale, spriteEffects, 0f); + Color eyeAfterimageColor = eyeGlowColor; + eyeAfterimageColor = Color.Lerp(eyeAfterimageColor, Color.White, 0.5f); + eyeAfterimageColor = NPC.GetAlpha(eyeAfterimageColor); + eyeAfterimageColor *= (afterimageAmt - j) / 15f; + Vector2 eyeAfterimagePos = NPC.oldPos[j] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + eyeAfterimagePos -= new Vector2(glowMaskTexture.Width, glowMaskTexture.Height / frameCount) * scale / 2f; + eyeAfterimagePos += halfSizeTexture * scale + new Vector2(0f, 4f + offsetY); + spriteBatch.Draw(glowMaskTexture, eyeAfterimagePos, new Rectangle?(frame), eyeAfterimageColor, rotation, halfSizeTexture, scale, spriteEffects, 0f); } } @@ -874,12 +868,12 @@ namespace CalamityMod.NPCs.Signus for (float i = 0; i < 1; i += 0.125f) { - spriteBatch.Draw(glowMaskTexture, vector43 + (i * MathHelper.TwoPi).ToRotationVector2() * outlineThickness, new Rectangle?(frame), outlineColor, rotation, vector11, scale, spriteEffects, 0f); + spriteBatch.Draw(glowMaskTexture, drawLocation + (i * MathHelper.TwoPi).ToRotationVector2() * outlineThickness, new Rectangle?(frame), outlineColor, rotation, halfSizeTexture, scale, spriteEffects, 0f); } CalamityUtils.ExitShaderRegion(spriteBatch); } - spriteBatch.Draw(glowMaskTexture, vector43, new Rectangle?(frame), color40, rotation, vector11, scale, spriteEffects, 0f); + spriteBatch.Draw(glowMaskTexture, drawLocation, new Rectangle?(frame), eyeGlowColor, rotation, halfSizeTexture, scale, spriteEffects, 0f); return false; } @@ -965,23 +959,23 @@ namespace CalamityMod.NPCs.Signus NPC.height = 150; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int teleportDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[teleportDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[teleportDust].scale = 0.5f; + Main.dust[teleportDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 60; num623++) + for (int j = 0; j < 60; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int teleportDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[teleportDust2].noGravity = true; + Main.dust[teleportDust2].velocity *= 5f; + teleportDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[teleportDust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) { @@ -1000,18 +994,18 @@ namespace CalamityMod.NPCs.Signus { Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= 60f; } diff --git a/NPCs/SlimeGod/CrimsonSlimeSpawn2.cs b/NPCs/SlimeGod/CrimsonSlimeSpawn2.cs index 5542aebf97..4f189ae655 100644 --- a/NPCs/SlimeGod/CrimsonSlimeSpawn2.cs +++ b/NPCs/SlimeGod/CrimsonSlimeSpawn2.cs @@ -103,11 +103,11 @@ namespace CalamityMod.NPCs.SlimeGod } if (!NPC.wet) { - Vector2 vector3 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num14 = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - vector3.X; - float num15 = Main.player[NPC.target].position.Y - vector3.Y; - float num16 = (float)Math.Sqrt((double)(num14 * num14 + num15 * num15)); - if (Main.expertMode && num16 < 120f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && NPC.velocity.Y == 0f) + Vector2 faceDirection = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetX = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - faceDirection.X; + float targetY = Main.player[NPC.target].position.Y - faceDirection.Y; + float targetDistance = (float)Math.Sqrt((double)(targetX * targetX + targetY * targetY)); + if (Main.expertMode && targetDistance < 120f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && NPC.velocity.Y == 0f) { NPC.ai[0] = -40f; if (NPC.velocity.Y == 0f) @@ -119,17 +119,17 @@ namespace CalamityMod.NPCs.SlimeGod int projcount = Main.zenithWorld ? 12 : 5; for (int n = 0; n < projcount; n++) { - Vector2 vector4 = new Vector2((float)(n - 2), -4f); - vector4.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; - vector4.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; - vector4.Normalize(); - vector4 *= 4f + (float)Main.rand.Next(-50, 51) * 0.01f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector3.X, vector3.Y, vector4.X, vector4.Y, type, damage, 0f, Main.myPlayer, 0f, 0f); + Vector2 spikeDirection = new Vector2((float)(n - 2), -4f); + spikeDirection.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; + spikeDirection.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; + spikeDirection.Normalize(); + spikeDirection *= 4f + (float)Main.rand.Next(-50, 51) * 0.01f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), faceDirection.X, faceDirection.Y, spikeDirection.X, spikeDirection.Y, type, damage, 0f, Main.myPlayer, 0f, 0f); spikeTimer = 30f; } } } - else if (num16 < 360f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && NPC.velocity.Y == 0f) + else if (targetDistance < 360f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && NPC.velocity.Y == 0f) { NPC.ai[0] = -40f; if (NPC.velocity.Y == 0f) @@ -138,13 +138,13 @@ namespace CalamityMod.NPCs.SlimeGod } if (Main.netMode != NetmodeID.MultiplayerClient && spikeTimer == 0f) { - num15 = Main.player[NPC.target].position.Y - vector3.Y - (float)Main.rand.Next(0, 200); - num16 = (float)Math.Sqrt((double)(num14 * num14 + num15 * num15)); - num16 = 6.5f / num16; - num14 *= num16; - num15 *= num16; + targetY = Main.player[NPC.target].position.Y - faceDirection.Y - (float)Main.rand.Next(0, 200); + targetDistance = (float)Math.Sqrt((double)(targetX * targetX + targetY * targetY)); + targetDistance = 6.5f / targetDistance; + targetX *= targetDistance; + targetY *= targetDistance; spikeTimer = 50f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector3.X, vector3.Y, num14, num15, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), faceDirection.X, faceDirection.Y, targetX, targetY, type, damage, 0f, Main.myPlayer, 0f, 0f); } } } diff --git a/NPCs/SlimeGod/CrimulanPaladin.cs b/NPCs/SlimeGod/CrimulanPaladin.cs index fd8b9e4c4d..23bfbfd72c 100644 --- a/NPCs/SlimeGod/CrimulanPaladin.cs +++ b/NPCs/SlimeGod/CrimulanPaladin.cs @@ -184,34 +184,33 @@ namespace CalamityMod.NPCs.SlimeGod NPC.TargetClosest(false); player = Main.player[NPC.target]; Vector2 vectorAimedAheadOfTarget = player.Center + new Vector2((float)Math.Round(player.velocity.X), 0f).SafeNormalize(Vector2.Zero) * 960f; - Point point2 = vectorAimedAheadOfTarget.ToTileCoordinates(); - int num5 = 5; - int num8 = 0; - while (num8 < 100) + Point teleportAheadPos = vectorAimedAheadOfTarget.ToTileCoordinates(); + int maxTeleportTries = 0; + while (maxTeleportTries < 100) { - num8++; - int num9 = Main.rand.Next(point2.X - num5, point2.X + num5 + 1); - int num10 = Main.rand.Next(point2.Y - num5, point2.Y); - if (Main.tile[num9, num10].HasUnactuatedTile) + maxTeleportTries++; + int teleportPosX = Main.rand.Next(teleportAheadPos.X - 5, teleportAheadPos.X + 6); + int teleportPosY = Main.rand.Next(teleportAheadPos.Y - 5, teleportAheadPos.Y); + if (Main.tile[teleportPosX, teleportPosY].HasUnactuatedTile) continue; - bool flag4 = true; - if (flag4 && Main.tile[num9, num10].LiquidType == LiquidID.Lava) - flag4 = false; - if (flag4 && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) - flag4 = false; + bool canTeleport = true; + if (canTeleport && Main.tile[teleportPosX, teleportPosY].LiquidType == LiquidID.Lava) + canTeleport = false; + if (canTeleport && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) + canTeleport = false; - if (flag4) + if (canTeleport) { - NPC.localAI[0] = num9 * 16 + 8; - NPC.localAI[3] = num10 * 16 + 16; + NPC.localAI[0] = teleportPosX * 16 + 8; + NPC.localAI[3] = teleportPosY * 16 + 16; calamityGlobalNPC.newAI[0] = 0f; break; } } // Default teleport if the above conditions aren't met in 100 iterations - if (num8 >= 100) + if (maxTeleportTries >= 100) { Vector2 bottom = Main.player[Player.FindClosest(NPC.position, NPC.width, NPC.height)].Bottom; NPC.localAI[0] = bottom.X; @@ -362,24 +361,24 @@ namespace CalamityMod.NPCs.SlimeGod NPC.spriteDirection = NPC.direction; NPC.TargetClosest(); - Vector2 center40 = player.Center; - center40.Y -= 350f; - Vector2 vector272 = center40 - NPC.Center; + Vector2 targetCenter = player.Center; + targetCenter.Y -= 350f; + Vector2 targetDist = targetCenter - NPC.Center; if (NPC.ai[2] == 1f) { NPC.ai[1] += 1f; - vector272 = player.Center - NPC.Center; - vector272.Normalize(); - vector272 *= death ? 10f : revenge ? 9f : expertMode ? 8f : 7f; - NPC.velocity = (NPC.velocity * 4f + vector272) / 5f; + targetDist = player.Center - NPC.Center; + targetDist.Normalize(); + targetDist *= death ? 10f : revenge ? 9f : expertMode ? 8f : 7f; + NPC.velocity = (NPC.velocity * 4f + targetDist) / 5f; if (NPC.ai[1] > 12f) { NPC.ai[1] = 0f; NPC.ai[0] = 1.1f; NPC.ai[2] = 0f; - NPC.velocity = vector272; + NPC.velocity = targetDist; } } else @@ -391,9 +390,9 @@ namespace CalamityMod.NPCs.SlimeGod return; } - vector272.Normalize(); - vector272 *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; - NPC.velocity = (NPC.velocity * 5f + vector272) / 6f; + targetDist.Normalize(); + targetDist *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; + NPC.velocity = (NPC.velocity * 5f + targetDist) / 6f; } } else if (NPC.ai[0] == 1.1f) @@ -442,8 +441,8 @@ namespace CalamityMod.NPCs.SlimeGod } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(velocity2) * 30f * NPC.scale, velocity2, type, damage, 0f, Main.myPlayer); + Vector2 projFireDirection = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projFireDirection) * 30f * NPC.scale, projFireDirection, type, damage, 0f, Main.myPlayer); } } } @@ -591,11 +590,11 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Crimson; dustColor.A = 150; - for (int num245 = 0; num245 < 10; num245++) + for (int i = 0; i < 10; i++) { - int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); - Main.dust[num246].noGravity = true; - Main.dust[num246].velocity *= 0.5f; + int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + Main.dust[crimsonDust].noGravity = true; + Main.dust[crimsonDust].velocity *= 0.5f; } } else if (NPC.ai[0] == 6f) @@ -625,11 +624,11 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Crimson; dustColor.A = 150; - for (int num245 = 0; num245 < 10; num245++) + for (int i = 0; i < 10; i++) { - int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); - Main.dust[num246].noGravity = true; - Main.dust[num246].velocity *= 0.5f; + int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + Main.dust[crimsonDust].noGravity = true; + Main.dust[crimsonDust].velocity *= 0.5f; } } @@ -638,15 +637,15 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.life > 0) { - float num659 = lifeRatio; - num659 = num659 * 0.5f + 0.75f; - num659 *= scale; + float scaleRatio = lifeRatio; + scaleRatio = scaleRatio * 0.5f + 0.75f; + scaleRatio *= scale; - if (num659 != NPC.scale) + if (scaleRatio != NPC.scale) { NPC.position.X = NPC.position.X + (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y + (float)NPC.height; - NPC.scale = num659; + NPC.scale = scaleRatio; NPC.width = (int)(150f * NPC.scale); NPC.height = (int)(92f * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); @@ -655,25 +654,25 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.netMode != NetmodeID.MultiplayerClient) { - int num660 = (int)((double)NPC.lifeMax * 0.15); - if ((float)(NPC.life + num660) < bossLife) + int slimeSpawnThreshold = (int)((double)NPC.lifeMax * 0.15); + if ((float)(NPC.life + slimeSpawnThreshold) < bossLife) { bossLife = (float)NPC.life; int x = (int)(NPC.position.X + (float)Main.rand.Next(NPC.width - 32)); int y = (int)(NPC.position.Y + (float)Main.rand.Next(NPC.height - 32)); - int num663 = ModContent.NPCType(); + int slimeType = ModContent.NPCType(); if (Main.rand.NextBool(3)) { - num663 = ModContent.NPCType(); + slimeType = ModContent.NPCType(); } - int num664 = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, num663, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[num664].SetDefaults(num663); - Main.npc[num664].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; - Main.npc[num664].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; - Main.npc[num664].ai[0] = (float)(-1000 * Main.rand.Next(3)); - Main.npc[num664].ai[1] = 0f; - if (Main.netMode == NetmodeID.Server && num664 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0); + int slimeSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, slimeType, 0, 0f, 0f, 0f, 0f, 255); + Main.npc[slimeSpawn].SetDefaults(slimeType); + Main.npc[slimeSpawn].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; + Main.npc[slimeSpawn].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; + Main.npc[slimeSpawn].ai[0] = (float)(-1000 * Main.rand.Next(3)); + Main.npc[slimeSpawn].ai[1] = 0f; + if (Main.netMode == NetmodeID.Server && slimeSpawn < Main.maxNPCs) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn, 0f, 0f, 0f, 0, 0, 0); } } } diff --git a/NPCs/SlimeGod/EbonianPaladin.cs b/NPCs/SlimeGod/EbonianPaladin.cs index ba6c41d255..09a2661ab7 100644 --- a/NPCs/SlimeGod/EbonianPaladin.cs +++ b/NPCs/SlimeGod/EbonianPaladin.cs @@ -177,34 +177,33 @@ namespace CalamityMod.NPCs.SlimeGod NPC.TargetClosest(false); player = Main.player[NPC.target]; Vector2 vectorAimedAheadOfTarget = player.Center + new Vector2((float)Math.Round(player.velocity.X), 0f).SafeNormalize(Vector2.Zero) * 960f; - Point point2 = vectorAimedAheadOfTarget.ToTileCoordinates(); - int num5 = 5; - int num8 = 0; - while (num8 < 100) + Point teleportAheadPos = vectorAimedAheadOfTarget.ToTileCoordinates(); + int maxTeleportTries = 0; + while (maxTeleportTries < 100) { - num8++; - int num9 = Main.rand.Next(point2.X - num5, point2.X + num5 + 1); - int num10 = Main.rand.Next(point2.Y - num5, point2.Y); - if (Main.tile[num9, num10].HasUnactuatedTile) + maxTeleportTries++; + int teleportPosX = Main.rand.Next(teleportAheadPos.X - 5, teleportAheadPos.X + 6); + int teleportPosY = Main.rand.Next(teleportAheadPos.Y - 5, teleportAheadPos.Y); + if (Main.tile[teleportPosX, teleportPosY].HasUnactuatedTile) continue; - bool flag4 = true; - if (flag4 && Main.tile[num9, num10].LiquidType == LiquidID.Lava) - flag4 = false; - if (flag4 && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) - flag4 = false; + bool canTeleport = true; + if (canTeleport && Main.tile[teleportPosX, teleportPosY].LiquidType == LiquidID.Lava) + canTeleport = false; + if (canTeleport && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) + canTeleport = false; - if (flag4) + if (canTeleport) { - NPC.localAI[0] = num9 * 16 + 8; - NPC.localAI[3] = num10 * 16 + 16; + NPC.localAI[0] = teleportPosX * 16 + 8; + NPC.localAI[3] = teleportPosY * 16 + 16; calamityGlobalNPC.newAI[0] = 0f; break; } } // Default teleport if the above conditions aren't met in 100 iterations - if (num8 >= 100) + if (maxTeleportTries >= 100) { Vector2 bottom = Main.player[Player.FindClosest(NPC.position, NPC.width, NPC.height)].Bottom; NPC.localAI[0] = bottom.X; @@ -371,24 +370,24 @@ namespace CalamityMod.NPCs.SlimeGod NPC.spriteDirection = NPC.direction; NPC.TargetClosest(); - Vector2 center40 = player.Center; - center40.Y -= 350f; - Vector2 vector272 = center40 - NPC.Center; + Vector2 targetCenter = player.Center; + targetCenter.Y -= 350f; + Vector2 targetDist = targetCenter - NPC.Center; if (NPC.ai[2] == 1f) { NPC.ai[1] += 1f; - vector272 = player.Center - NPC.Center; - vector272.Normalize(); - vector272 *= death ? 9f : revenge ? 8f : expertMode ? 7f : 6f; - NPC.velocity = (NPC.velocity * 4f + vector272) / 5f; + targetDist = player.Center - NPC.Center; + targetDist.Normalize(); + targetDist *= death ? 9f : revenge ? 8f : expertMode ? 7f : 6f; + NPC.velocity = (NPC.velocity * 4f + targetDist) / 5f; if (NPC.ai[1] > 12f) { NPC.ai[1] = 0f; NPC.ai[0] = 2.1f; NPC.ai[2] = 0f; - NPC.velocity = vector272; + NPC.velocity = targetDist; } } else @@ -400,9 +399,9 @@ namespace CalamityMod.NPCs.SlimeGod return; } - vector272.Normalize(); - vector272 *= (death ? 11f : revenge ? 10f : expertMode ? 9f : 8f) + distanceSpeedBoost; - NPC.velocity = (NPC.velocity * 5f + vector272) / 6f; + targetDist.Normalize(); + targetDist *= (death ? 11f : revenge ? 10f : expertMode ? 9f : 8f) + distanceSpeedBoost; + NPC.velocity = (NPC.velocity * 5f + targetDist) / 6f; } } else if (NPC.ai[0] == 2.1f) @@ -455,8 +454,8 @@ namespace CalamityMod.NPCs.SlimeGod } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(velocity2) * 30f * NPC.scale, velocity2, type, damage, 0f, Main.myPlayer); + Vector2 projFireDirection = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projFireDirection) * 30f * NPC.scale, projFireDirection, type, damage, 0f, Main.myPlayer); } } } @@ -604,11 +603,11 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Lavender; dustColor.A = 150; - for (int num245 = 0; num245 < 10; num245++) + for (int i = 0; i < 10; i++) { - int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); - Main.dust[num246].noGravity = true; - Main.dust[num246].velocity *= 0.5f; + int corruptDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + Main.dust[corruptDust].noGravity = true; + Main.dust[corruptDust].velocity *= 0.5f; } } else if (NPC.ai[0] == 7f) @@ -638,11 +637,11 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Lavender; dustColor.A = 150; - for (int num245 = 0; num245 < 10; num245++) + for (int i = 0; i < 10; i++) { - int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); - Main.dust[num246].noGravity = true; - Main.dust[num246].velocity *= 0.5f; + int corruptDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + Main.dust[corruptDust].noGravity = true; + Main.dust[corruptDust].velocity *= 0.5f; } } @@ -651,15 +650,15 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.life > 0) { - float num659 = lifeRatio; - num659 = num659 * 0.5f + 0.75f; - num659 *= scale; + float scaleRatio = lifeRatio; + scaleRatio = scaleRatio * 0.5f + 0.75f; + scaleRatio *= scale; - if (num659 != NPC.scale) + if (scaleRatio != NPC.scale) { NPC.position.X = NPC.position.X + (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y + (float)NPC.height; - NPC.scale = num659; + NPC.scale = scaleRatio; NPC.width = (int)(150f * NPC.scale); NPC.height = (int)(92f * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); @@ -668,24 +667,24 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.netMode != NetmodeID.MultiplayerClient) { - int num660 = (int)((double)NPC.lifeMax * 0.2); - if ((float)(NPC.life + num660) < bossLife) + int slimeSpawnThreshold = (int)((double)NPC.lifeMax * 0.2); + if ((float)(NPC.life + slimeSpawnThreshold) < bossLife) { bossLife = (float)NPC.life; - int num661 = Main.rand.Next(1, 3); - for (int num662 = 0; num662 < num661; num662++) + int randSlimeAmt = Main.rand.Next(1, 3); + for (int j = 0; j < randSlimeAmt; j++) { int x = (int)(NPC.position.X + (float)Main.rand.Next(NPC.width - 32)); int y = (int)(NPC.position.Y + (float)Main.rand.Next(NPC.height - 32)); - int num663 = ModContent.NPCType(); - int num664 = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, num663, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[num664].SetDefaults(num663); - Main.npc[num664].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; - Main.npc[num664].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; - Main.npc[num664].ai[0] = (float)(-1000 * Main.rand.Next(3)); - Main.npc[num664].ai[1] = 0f; - if (Main.netMode == NetmodeID.Server && num664 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0); + int slimeType = ModContent.NPCType(); + int slimeSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, slimeType, 0, 0f, 0f, 0f, 0f, 255); + Main.npc[slimeSpawn].SetDefaults(slimeType); + Main.npc[slimeSpawn].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; + Main.npc[slimeSpawn].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; + Main.npc[slimeSpawn].ai[0] = (float)(-1000 * Main.rand.Next(3)); + Main.npc[slimeSpawn].ai[1] = 0f; + if (Main.netMode == NetmodeID.Server && slimeSpawn < Main.maxNPCs) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn, 0f, 0f, 0f, 0, 0, 0); } } } diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index 8b2dc2225a..ca478c3440 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -221,27 +221,27 @@ namespace CalamityMod.NPCs.SlimeGod NPC.height = 40; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { Color color = Main.rand.NextBool() ? Color.Lavender : Color.Crimson; color.A = 150; - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, color, 2f); - Main.dust[num622].velocity *= 3f; + int slimyDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, color, 2f); + Main.dust[slimyDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[slimyDust].scale = 0.5f; + Main.dust[slimyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { Color color = Main.rand.NextBool() ? Color.Lavender : Color.Crimson; color.A = 150; - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, color, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, color, 2f); - Main.dust[num624].velocity *= 2f; + int slimyDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, color, 3f); + Main.dust[slimyDust2].noGravity = true; + Main.dust[slimyDust2].velocity *= 5f; + slimyDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, color, 2f); + Main.dust[slimyDust2].velocity *= 2f; } // Let the player know that the Slime God isn't dead fr @@ -432,9 +432,9 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.getGoodWorld) flySpeed *= 1.25f; - Vector2 vector167 = new Vector2(NPC.Center.X + (NPC.direction * 20), NPC.Center.Y + 6f); + Vector2 flyDirection = new Vector2(NPC.Center.X + (NPC.direction * 20), NPC.Center.Y + 6f); Vector2 flyDestination = GetFlyDestination(player); - Vector2 idealVelocity = (flyDestination - vector167).SafeNormalize(Vector2.UnitY) * flySpeed; + Vector2 idealVelocity = (flyDestination - flyDirection).SafeNormalize(Vector2.UnitY) * flySpeed; float distanceFromFlyDestination = NPC.Distance(flyDestination); @@ -475,11 +475,11 @@ namespace CalamityMod.NPCs.SlimeGod // If multiple slimes are present, and they are all relatively close together, try to stay in their general area. // If they are far apart, try to stay towards the closest slime. // If no slimes exist, or they are all extremely far away, try to stay near the target player instead. - // TODO -- Consider renaming the big slime god's internal names to be more intuitive? - int crimulanSlimeID = ModContent.NPCType(); - int crimulanSlimeSplitID = ModContent.NPCType(); - int ebonianSlimeID = ModContent.NPCType(); - int ebonianSlimeSplitID = ModContent.NPCType(); + + int largeCrimulanPaladin = ModContent.NPCType(); + int splitCrimulanPaladin = ModContent.NPCType(); + int largeEbonianPaladin = ModContent.NPCType(); + int splitEbonianPaladin = ModContent.NPCType(); List largeSlimes = new(); float ignoreGeneralAreaDistanceThreshold = 750f; @@ -489,7 +489,7 @@ namespace CalamityMod.NPCs.SlimeGod for (int i = 0; i < Main.maxNPCs; i++) { int npcType = Main.npc[i].type; - if (npcType != crimulanSlimeID && npcType != crimulanSlimeSplitID && npcType != ebonianSlimeID && npcType != ebonianSlimeSplitID) + if (npcType != largeCrimulanPaladin && npcType != splitCrimulanPaladin && npcType != largeEbonianPaladin && npcType != splitEbonianPaladin) continue; if (!Main.npc[i].active) @@ -539,44 +539,41 @@ namespace CalamityMod.NPCs.SlimeGod { spriteEffects = SpriteEffects.FlipHorizontally; } - Color color24 = NPC.GetAlpha(drawColor); - Color color25 = Lighting.GetColor((int)((double)NPC.position.X + (double)NPC.width * 0.5) / 16, (int)(((double)NPC.position.Y + (double)NPC.height * 0.5) / 16.0)); + Color drawColorAlpha = NPC.GetAlpha(drawColor); + Color colorLightingArea = Lighting.GetColor((int)((double)NPC.position.X + (double)NPC.width * 0.5) / 16, (int)(((double)NPC.position.Y + (double)NPC.height * 0.5) / 16.0)); Texture2D texture2D3 = TextureAssets.Npc[NPC.type].Value; Texture2D pog = ModContent.Request("CalamityMod/NPCs/SlimeGod/SlimeGodEyes").Value; - int num156 = TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type]; - int y3 = num156 * (int)NPC.frameCounter; - Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, num156); - Vector2 origin2 = rectangle.Size() / 2f; - int num157 = 8; - int num158 = 2; - int num159 = 1; - float num160 = 0f; - int num161 = num159; - spriteBatch.Draw(texture2D3, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY), NPC.frame, color24, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, spriteEffects, 0); + int frameTexture = TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type]; + int y3 = frameTexture * (int)NPC.frameCounter; + Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, frameTexture); + Vector2 halfRect = rectangle.Size() / 2f; + int twoConst = 2; + int coreID = 1; + spriteBatch.Draw(texture2D3, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY), NPC.frame, drawColorAlpha, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, spriteEffects, 0); if (Main.zenithWorld) { - spriteBatch.Draw(pog, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY), NPC.frame, color24, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, spriteEffects, 0); + spriteBatch.Draw(pog, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY), NPC.frame, drawColorAlpha, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, spriteEffects, 0); } if (!Main.zenithWorld) - while (((num158 > 0 && num161 < num157) || (num158 < 0 && num161 > num157)) && CalamityConfig.Instance.Afterimages) + while (((twoConst > 0 && coreID < 8) || (twoConst < 0 && coreID > 8)) && CalamityConfig.Instance.Afterimages) { - Color color26 = NPC.GetAlpha(color25); + Color colorLightingAlpha = NPC.GetAlpha(colorLightingArea); { goto IL_6899; } IL_6881: - num161 += num158; + coreID += twoConst; continue; IL_6899: - float num164 = (float)(num157 - num161); - if (num158 < 0) + float trailLengthMult = (float)(8 - coreID); + if (twoConst < 0) { - num164 = (float)(num159 - num161); + trailLengthMult = (float)(1 - coreID); } - color26 *= num164 / ((float)NPCID.Sets.TrailCacheLength[NPC.type] * 1.5f); - Vector2 value4 = NPC.oldPos[num161]; - float num165 = NPC.rotation; - Main.spriteBatch.Draw(texture2D3, value4 + NPC.Size / 2f - screenPos + new Vector2(0, NPC.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, num165 + NPC.rotation * num160 * (float)(num161 - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, NPC.scale, spriteEffects, 0f); + colorLightingAlpha *= trailLengthMult / ((float)NPCID.Sets.TrailCacheLength[NPC.type] * 1.5f); + Vector2 drawPosition = NPC.oldPos[coreID]; + float coreRotate = NPC.rotation; + Main.spriteBatch.Draw(texture2D3, drawPosition + NPC.Size / 2f - screenPos + new Vector2(0, NPC.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), colorLightingAlpha, coreRotate + NPC.rotation * 0f * (float)(coreID - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), halfRect, NPC.scale, spriteEffects, 0f); goto IL_6881; } return false; diff --git a/NPCs/SlimeGod/SplitCrimulanPaladin.cs b/NPCs/SlimeGod/SplitCrimulanPaladin.cs index dc279b91d3..344477b686 100644 --- a/NPCs/SlimeGod/SplitCrimulanPaladin.cs +++ b/NPCs/SlimeGod/SplitCrimulanPaladin.cs @@ -174,34 +174,33 @@ namespace CalamityMod.NPCs.SlimeGod NPC.TargetClosest(false); player = Main.player[NPC.target]; Vector2 vectorAimedAheadOfTarget = player.Center + new Vector2((float)Math.Round(player.velocity.X), 0f).SafeNormalize(Vector2.Zero) * 1120f; - Point point2 = vectorAimedAheadOfTarget.ToTileCoordinates(); - int num5 = 5; - int num8 = 0; - while (num8 < 100) + Point teleportAheadPos = vectorAimedAheadOfTarget.ToTileCoordinates(); + int maxTeleportTries = 0; + while (maxTeleportTries < 100) { - num8++; - int num9 = Main.rand.Next(point2.X - num5, point2.X + num5 + 1); - int num10 = Main.rand.Next(point2.Y - num5, point2.Y); - if (Main.tile[num9, num10].HasUnactuatedTile) + maxTeleportTries++; + int teleportPosX = Main.rand.Next(teleportAheadPos.X - 5, teleportAheadPos.X + 6); + int teleportPosY = Main.rand.Next(teleportAheadPos.Y - 5, teleportAheadPos.Y); + if (Main.tile[teleportPosX, teleportPosY].HasUnactuatedTile) continue; - bool flag4 = true; - if (flag4 && Main.tile[num9, num10].LiquidType == LiquidID.Lava) - flag4 = false; - if (flag4 && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) - flag4 = false; + bool canTeleport = true; + if (canTeleport && Main.tile[teleportPosX, teleportPosY].LiquidType == LiquidID.Lava) + canTeleport = false; + if (canTeleport && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) + canTeleport = false; - if (flag4) + if (canTeleport) { - NPC.localAI[0] = num9 * 16 + 8; - NPC.localAI[3] = num10 * 16 + 16; + NPC.localAI[0] = teleportPosX * 16 + 8; + NPC.localAI[3] = teleportPosY * 16 + 16; NPC.ai[3] = 0f; break; } } // Default teleport if the above conditions aren't met in 100 iterations - if (num8 >= 100) + if (maxTeleportTries >= 100) { Vector2 bottom = Main.player[Player.FindClosest(NPC.position, NPC.width, NPC.height)].Bottom; NPC.localAI[0] = bottom.X; @@ -344,24 +343,24 @@ namespace CalamityMod.NPCs.SlimeGod NPC.spriteDirection = NPC.direction; NPC.TargetClosest(); - Vector2 center40 = player.Center; - center40.Y -= 350f; - Vector2 vector272 = center40 - NPC.Center; + Vector2 targetCenter = player.Center; + targetCenter.Y -= 350f; + Vector2 targetDist = targetCenter - NPC.Center; if (NPC.ai[2] == 1f) { NPC.ai[1] += 1f; - vector272 = player.Center - NPC.Center; - vector272.Normalize(); - vector272 *= death ? 11f : revenge ? 10f : expertMode ? 9f : 8f; - NPC.velocity = (NPC.velocity * 4f + vector272) / 5f; + targetDist = player.Center - NPC.Center; + targetDist.Normalize(); + targetDist *= death ? 11f : revenge ? 10f : expertMode ? 9f : 8f; + NPC.velocity = (NPC.velocity * 4f + targetDist) / 5f; if (NPC.ai[1] > 12f) { NPC.ai[1] = 0f; NPC.ai[0] = 1.1f; NPC.ai[2] = 0f; - NPC.velocity = vector272; + NPC.velocity = targetDist; } } else @@ -373,9 +372,9 @@ namespace CalamityMod.NPCs.SlimeGod return; } - vector272.Normalize(); - vector272 *= (death ? 13f : revenge ? 12f : expertMode ? 11f : 10f) + distanceSpeedBoost; - NPC.velocity = (NPC.velocity * 5f + vector272) / 6f; + targetDist.Normalize(); + targetDist *= (death ? 13f : revenge ? 12f : expertMode ? 11f : 10f) + distanceSpeedBoost; + NPC.velocity = (NPC.velocity * 5f + targetDist) / 6f; } } else if (NPC.ai[0] == 1.1f) @@ -424,8 +423,8 @@ namespace CalamityMod.NPCs.SlimeGod } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(velocity2) * 30f * NPC.scale, velocity2, type, damage, 0f, Main.myPlayer); + Vector2 projFireDirection = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projFireDirection) * 30f * NPC.scale, projFireDirection, type, damage, 0f, Main.myPlayer); } } } @@ -570,11 +569,11 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Crimson; dustColor.A = 150; - for (int num245 = 0; num245 < 10; num245++) + for (int i = 0; i < 10; i++) { - int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); - Main.dust[num246].noGravity = true; - Main.dust[num246].velocity *= 0.5f; + int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + Main.dust[crimsonDust].noGravity = true; + Main.dust[crimsonDust].velocity *= 0.5f; } } else if (NPC.ai[0] == 6f) @@ -604,11 +603,11 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Crimson; dustColor.A = 150; - for (int num245 = 0; num245 < 10; num245++) + for (int i = 0; i < 10; i++) { - int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); - Main.dust[num246].noGravity = true; - Main.dust[num246].velocity *= 0.5f; + int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + Main.dust[crimsonDust].noGravity = true; + Main.dust[crimsonDust].velocity *= 0.5f; } } @@ -617,15 +616,15 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.life > 0) { - float num659 = lifeRatio; - num659 = num659 * 0.5f + 0.75f; - num659 *= scale; + float scaleRatio = lifeRatio; + scaleRatio = scaleRatio * 0.5f + 0.75f; + scaleRatio *= scale; - if (num659 != NPC.scale) + if (scaleRatio != NPC.scale) { NPC.position.X = NPC.position.X + (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y + (float)NPC.height; - NPC.scale = num659 * 0.75f; + NPC.scale = scaleRatio * 0.75f; NPC.width = (int)(150f * NPC.scale); NPC.height = (int)(92f * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); @@ -634,25 +633,25 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.netMode != NetmodeID.MultiplayerClient) { - int num660 = (int)((double)NPC.lifeMax * 0.15); - if ((float)(NPC.life + num660) < bossLife) + int slimeSpawnThreshold = (int)((double)NPC.lifeMax * 0.15); + if ((float)(NPC.life + slimeSpawnThreshold) < bossLife) { bossLife = (float)NPC.life; int x = (int)(NPC.position.X + (float)Main.rand.Next(NPC.width - 32)); int y = (int)(NPC.position.Y + (float)Main.rand.Next(NPC.height - 32)); - int num663 = ModContent.NPCType(); + int slimeType = ModContent.NPCType(); if (Main.rand.NextBool(3)) { - num663 = ModContent.NPCType(); + slimeType = ModContent.NPCType(); } - int num664 = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, num663, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[num664].SetDefaults(num663); - Main.npc[num664].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; - Main.npc[num664].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; - Main.npc[num664].ai[0] = (float)(-1000 * Main.rand.Next(3)); - Main.npc[num664].ai[1] = 0f; - if (Main.netMode == NetmodeID.Server && num664 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0); + int slimeSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, slimeType, 0, 0f, 0f, 0f, 0f, 255); + Main.npc[slimeSpawn].SetDefaults(slimeType); + Main.npc[slimeSpawn].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; + Main.npc[slimeSpawn].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; + Main.npc[slimeSpawn].ai[0] = (float)(-1000 * Main.rand.Next(3)); + Main.npc[slimeSpawn].ai[1] = 0f; + if (Main.netMode == NetmodeID.Server && slimeSpawn < Main.maxNPCs) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn, 0f, 0f, 0f, 0, 0, 0); } } } @@ -696,23 +695,23 @@ namespace CalamityMod.NPCs.SlimeGod NPC.height = 50; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 2f); - Main.dust[num622].velocity *= 3f; + int crimDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 2f); + Main.dust[crimDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[crimDust].scale = 0.5f; + Main.dust[crimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 2f); - Main.dust[num624].velocity *= 2f; + int crimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 3f); + Main.dust[crimDust2].noGravity = true; + Main.dust[crimDust2].velocity *= 5f; + crimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 2f); + Main.dust[crimDust2].velocity *= 2f; } } } diff --git a/NPCs/SlimeGod/SplitEbonianPaladin.cs b/NPCs/SlimeGod/SplitEbonianPaladin.cs index 656e68f6f8..80772fbe31 100644 --- a/NPCs/SlimeGod/SplitEbonianPaladin.cs +++ b/NPCs/SlimeGod/SplitEbonianPaladin.cs @@ -170,34 +170,33 @@ namespace CalamityMod.NPCs.SlimeGod NPC.TargetClosest(false); player = Main.player[NPC.target]; Vector2 vectorAimedAheadOfTarget = player.Center + new Vector2((float)Math.Round(player.velocity.X), 0f).SafeNormalize(Vector2.Zero) * 1120f; - Point point2 = vectorAimedAheadOfTarget.ToTileCoordinates(); - int num5 = 5; - int num8 = 0; - while (num8 < 100) + Point teleportAheadPos = vectorAimedAheadOfTarget.ToTileCoordinates(); + int maxTeleportTries = 0; + while (maxTeleportTries < 100) { - num8++; - int num9 = Main.rand.Next(point2.X - num5, point2.X + num5 + 1); - int num10 = Main.rand.Next(point2.Y - num5, point2.Y); - if (Main.tile[num9, num10].HasUnactuatedTile) + maxTeleportTries++; + int teleportPosX = Main.rand.Next(teleportAheadPos.X - 5, teleportAheadPos.X + 6); + int teleportPosY = Main.rand.Next(teleportAheadPos.Y - 5, teleportAheadPos.Y); + if (Main.tile[teleportPosX, teleportPosY].HasUnactuatedTile) continue; - bool flag4 = true; - if (flag4 && Main.tile[num9, num10].LiquidType == LiquidID.Lava) - flag4 = false; - if (flag4 && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) - flag4 = false; + bool canTeleport = true; + if (canTeleport && Main.tile[teleportPosX, teleportPosY].LiquidType == LiquidID.Lava) + canTeleport = false; + if (canTeleport && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) + canTeleport = false; - if (flag4) + if (canTeleport) { - NPC.localAI[0] = num9 * 16 + 8; - NPC.localAI[3] = num10 * 16 + 16; + NPC.localAI[0] = teleportPosX * 16 + 8; + NPC.localAI[3] = teleportPosY * 16 + 16; NPC.ai[3] = 0f; break; } } // Default teleport if the above conditions aren't met in 100 iterations - if (num8 >= 100) + if (maxTeleportTries >= 100) { Vector2 bottom = Main.player[Player.FindClosest(NPC.position, NPC.width, NPC.height)].Bottom; NPC.localAI[0] = bottom.X; @@ -357,24 +356,24 @@ namespace CalamityMod.NPCs.SlimeGod NPC.spriteDirection = NPC.direction; NPC.TargetClosest(); - Vector2 center40 = player.Center; - center40.Y -= 350f; - Vector2 vector272 = center40 - NPC.Center; + Vector2 targetCenter = player.Center; + targetCenter.Y -= 350f; + Vector2 targetDist = targetCenter - NPC.Center; if (NPC.ai[2] == 1f) { NPC.ai[1] += 1f; - vector272 = player.Center - NPC.Center; - vector272.Normalize(); - vector272 *= death ? 10f : revenge ? 9f : expertMode ? 8f : 7f; - NPC.velocity = (NPC.velocity * 4f + vector272) / 5f; + targetDist = player.Center - NPC.Center; + targetDist.Normalize(); + targetDist *= death ? 10f : revenge ? 9f : expertMode ? 8f : 7f; + NPC.velocity = (NPC.velocity * 4f + targetDist) / 5f; if (NPC.ai[1] > 12f) { NPC.ai[1] = 0f; NPC.ai[0] = 2.1f; NPC.ai[2] = 0f; - NPC.velocity = vector272; + NPC.velocity = targetDist; } } else @@ -386,9 +385,9 @@ namespace CalamityMod.NPCs.SlimeGod return; } - vector272.Normalize(); - vector272 *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; - NPC.velocity = (NPC.velocity * 5f + vector272) / 6f; + targetDist.Normalize(); + targetDist *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; + NPC.velocity = (NPC.velocity * 5f + targetDist) / 6f; } } else if (NPC.ai[0] == 2.1f) @@ -441,8 +440,8 @@ namespace CalamityMod.NPCs.SlimeGod } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(velocity2) * 30f * NPC.scale, velocity2, type, damage, 0f, Main.myPlayer); + Vector2 projFireDirection = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projFireDirection) * 30f * NPC.scale, projFireDirection, type, damage, 0f, Main.myPlayer); } } } @@ -587,11 +586,11 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Lavender; dustColor.A = 150; - for (int num245 = 0; num245 < 10; num245++) + for (int i = 0; i < 10; i++) { - int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); - Main.dust[num246].noGravity = true; - Main.dust[num246].velocity *= 0.5f; + int corruptDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + Main.dust[corruptDust].noGravity = true; + Main.dust[corruptDust].velocity *= 0.5f; } } else if (NPC.ai[0] == 7f) @@ -621,11 +620,11 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Lavender; dustColor.A = 150; - for (int num245 = 0; num245 < 10; num245++) + for (int i = 0; i < 10; i++) { - int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); - Main.dust[num246].noGravity = true; - Main.dust[num246].velocity *= 0.5f; + int corruptDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + Main.dust[corruptDust].noGravity = true; + Main.dust[corruptDust].velocity *= 0.5f; } } @@ -634,15 +633,15 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.life > 0) { - float num659 = lifeRatio; - num659 = num659 * 0.5f + 0.75f; - num659 *= scale; + float scaleRatio = lifeRatio; + scaleRatio = scaleRatio * 0.5f + 0.75f; + scaleRatio *= scale; - if (num659 != NPC.scale) + if (scaleRatio != NPC.scale) { NPC.position.X = NPC.position.X + (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y + (float)NPC.height; - NPC.scale = num659 * 0.75f; + NPC.scale = scaleRatio * 0.75f; NPC.width = (int)(150f * NPC.scale); NPC.height = (int)(92f * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); @@ -651,21 +650,21 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.netMode != NetmodeID.MultiplayerClient) { - int num660 = (int)((double)NPC.lifeMax * 0.2); - if ((float)(NPC.life + num660) < bossLife) + int slimeSpawnThreshold = (int)((double)NPC.lifeMax * 0.2); + if ((float)(NPC.life + slimeSpawnThreshold) < bossLife) { bossLife = (float)NPC.life; int x = (int)(NPC.position.X + (float)Main.rand.Next(NPC.width - 32)); int y = (int)(NPC.position.Y + (float)Main.rand.Next(NPC.height - 32)); - int num663 = ModContent.NPCType(); - int num664 = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, num663, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[num664].SetDefaults(num663); - Main.npc[num664].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; - Main.npc[num664].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; - Main.npc[num664].ai[0] = (float)(-1000 * Main.rand.Next(3)); - Main.npc[num664].ai[1] = 0f; - if (Main.netMode == NetmodeID.Server && num664 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0); + int slimeType = ModContent.NPCType(); + int slimeSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, slimeType, 0, 0f, 0f, 0f, 0f, 255); + Main.npc[slimeSpawn].SetDefaults(slimeType); + Main.npc[slimeSpawn].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; + Main.npc[slimeSpawn].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; + Main.npc[slimeSpawn].ai[0] = (float)(-1000 * Main.rand.Next(3)); + Main.npc[slimeSpawn].ai[1] = 0f; + if (Main.netMode == NetmodeID.Server && slimeSpawn < Main.maxNPCs) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn, 0f, 0f, 0f, 0, 0, 0); } } } @@ -709,23 +708,23 @@ namespace CalamityMod.NPCs.SlimeGod NPC.height = 50; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 2f); - Main.dust[num622].velocity *= 3f; + int corruptionDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 2f); + Main.dust[corruptionDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[corruptionDust].scale = 0.5f; + Main.dust[corruptionDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 2f); - Main.dust[num624].velocity *= 2f; + int corruptionDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 3f); + Main.dust[corruptionDust2].noGravity = true; + Main.dust[corruptionDust2].velocity *= 5f; + corruptionDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 4, 0f, 0f, NPC.alpha, dustColor, 2f); + Main.dust[corruptionDust2].velocity *= 2f; } } } diff --git a/NPCs/StormWeaver/StormWeaverBody.cs b/NPCs/StormWeaver/StormWeaverBody.cs index ff92fcd7c0..db749693ef 100644 --- a/NPCs/StormWeaver/StormWeaverBody.cs +++ b/NPCs/StormWeaver/StormWeaverBody.cs @@ -186,11 +186,11 @@ namespace CalamityMod.NPCs.StormWeaver { if (NPC.alpha != 0) { - for (int num934 = 0; num934 < 2; num934++) + for (int i = 0; i < 2; i++) { - int num935 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; + int redDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 182, 0f, 0f, 100, default, 2f); + Main.dust[redDust].noGravity = true; + Main.dust[redDust].noLight = true; } } @@ -199,41 +199,41 @@ namespace CalamityMod.NPCs.StormWeaver NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; + Vector2 segmentLocation = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); + float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); + targetX = (int)(targetX / 16f) * 16; + targetY = (int)(targetY / 16f) * 16; + segmentLocation.X = (int)(segmentLocation.X / 16f) * 16; + segmentLocation.Y = (int)(segmentLocation.Y / 16f) * 16; + targetX -= segmentLocation.X; + targetY -= segmentLocation.Y; - float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); + float targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentLocation = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + targetX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - segmentLocation.X; + targetY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - segmentLocation.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2(num192, num191) + MathHelper.PiOver2; - num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = NPC.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2(targetY, targetX) + MathHelper.PiOver2; + targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); + int npcWidth = NPC.width; + targetDistance = (targetDistance - npcWidth) / targetDistance; + targetX *= targetDistance; + targetY *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetX; + NPC.position.Y = NPC.position.Y + targetY; - if (num191 < 0f) + if (targetX < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetX > 0f) NPC.spriteDirection = 1; } } @@ -263,21 +263,21 @@ namespace CalamityMod.NPCs.StormWeaver chargePhaseGateValue *= 0.5f; Texture2D texture = phase2 ? ModContent.Request("CalamityMod/NPCs/StormWeaver/StormWeaverBodyNaked").Value : TextureAssets.Npc[NPC.type].Value; - Vector2 vector = new Vector2(texture.Width / 2, texture.Height / 2); + Vector2 halfSizeTexture = new Vector2(texture.Width / 2, texture.Height / 2); float chargeTelegraphTime = 120f; float chargeTelegraphGateValue = chargePhaseGateValue - chargeTelegraphTime; - Vector2 vector2 = NPC.Center - screenPos; - vector2 -= new Vector2(texture.Width, texture.Height) * NPC.scale / 2f; - vector2 += vector * NPC.scale + new Vector2(0f, NPC.gfxOffY); - Color color = NPC.GetAlpha(drawColor); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture.Width, texture.Height) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + Color drawColorAlpha = NPC.GetAlpha(drawColor); if (Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] > chargeTelegraphGateValue) - color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp((Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] - chargeTelegraphGateValue) / chargeTelegraphTime, 0f, 1f)); + drawColorAlpha = Color.Lerp(drawColorAlpha, Color.Cyan, MathHelper.Clamp((Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] - chargeTelegraphGateValue) / chargeTelegraphTime, 0f, 1f)); else if (Main.npc[(int)NPC.ai[2]].localAI[3] > 0f) - color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp(Main.npc[(int)NPC.ai[2]].localAI[3] / 60f, 0f, 1f)); + drawColorAlpha = Color.Lerp(drawColorAlpha, Color.Cyan, MathHelper.Clamp(Main.npc[(int)NPC.ai[2]].localAI[3] / 60f, 0f, 1f)); - spriteBatch.Draw(texture, vector2, NPC.frame, color, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, drawLocation, NPC.frame, drawColorAlpha, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -329,24 +329,24 @@ namespace CalamityMod.NPCs.StormWeaver NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 20; num621++) + for (int i = 0; i < 20; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int cosmiliteDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[cosmiliteDust].scale = 0.5f; + Main.dust[cosmiliteDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 40; num623++) + for (int j = 0; j < 40; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[cosmiliteDust2].noGravity = true; + Main.dust[cosmiliteDust2].velocity *= 5f; + cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust2].velocity *= 2f; } } } diff --git a/NPCs/StormWeaver/StormWeaverHead.cs b/NPCs/StormWeaver/StormWeaverHead.cs index ac81c6044d..14a4949b6a 100644 --- a/NPCs/StormWeaver/StormWeaverHead.cs +++ b/NPCs/StormWeaver/StormWeaverHead.cs @@ -221,11 +221,11 @@ namespace CalamityMod.NPCs.StormWeaver if (NPC.alpha != 0) { - for (int num934 = 0; num934 < 2; num934++) + for (int i = 0; i < 2; i++) { - int num935 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; + int redDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 182, 0f, 0f, 100, default, 2f); + Main.dust[redDust].noGravity = true; + Main.dust[redDust].noLight = true; } } @@ -252,10 +252,10 @@ namespace CalamityMod.NPCs.StormWeaver totalLength = npcCounts - 20; } - for (int num36 = 0; num36 < totalLength; num36++) + for (int segments = 0; segments < totalLength; segments++) { int lol; - if (num36 >= 0 && num36 < totalLength - 1) + if (segments >= 0 && segments < totalLength - 1) lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); else lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); @@ -292,13 +292,13 @@ namespace CalamityMod.NPCs.StormWeaver if ((double)NPC.position.Y < Main.topWorld + 16f) { - for (int num957 = 0; num957 < Main.maxNPCs; num957++) + for (int j = 0; j < Main.maxNPCs; j++) { - if (Main.npc[num957].active && (Main.npc[num957].type == ModContent.NPCType() - || Main.npc[num957].type == ModContent.NPCType() - || Main.npc[num957].type == ModContent.NPCType())) + if (Main.npc[j].active && (Main.npc[j].type == ModContent.NPCType() + || Main.npc[j].type == ModContent.NPCType() + || Main.npc[j].type == ModContent.NPCType())) { - Main.npc[num957].active = false; + Main.npc[j].active = false; } } } @@ -306,13 +306,13 @@ namespace CalamityMod.NPCs.StormWeaver if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 10000f && NPC.life > 0) { - for (int num957 = 0; num957 < Main.maxNPCs; num957++) + for (int j = 0; j < Main.maxNPCs; j++) { - if (Main.npc[num957].type == ModContent.NPCType() - || Main.npc[num957].type == ModContent.NPCType() - || Main.npc[num957].type == ModContent.NPCType()) + if (Main.npc[j].type == ModContent.NPCType() + || Main.npc[j].type == ModContent.NPCType() + || Main.npc[j].type == ModContent.NPCType()) { - Main.npc[num957].active = false; + Main.npc[j].active = false; } } } @@ -588,16 +588,16 @@ namespace CalamityMod.NPCs.StormWeaver } int dustAmt = 5; - for (int num1474 = 0; num1474 < dustAmt; num1474++) + for (int k = 0; k < dustAmt; k++) { - Vector2 vector171 = Vector2.Normalize(NPC.velocity) * new Vector2((NPC.width + 50) / 2f, NPC.height) * 0.75f; - vector171 = vector171.RotatedBy((num1474 - (dustAmt / 2 - 1)) * (double)MathHelper.Pi / (float)dustAmt) + NPC.Center; - Vector2 value18 = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 206, value18.X, value18.Y, 100, default, 3f); - Main.dust[num1475].noGravity = true; - Main.dust[num1475].noLight = true; - Main.dust[num1475].velocity /= 4f; - Main.dust[num1475].velocity -= NPC.velocity; + Vector2 dustRotation = Vector2.Normalize(NPC.velocity) * new Vector2((NPC.width + 50) / 2f, NPC.height) * 0.75f; + dustRotation = dustRotation.RotatedBy((k - (dustAmt / 2 - 1)) * (double)MathHelper.Pi / (float)dustAmt) + NPC.Center; + Vector2 randDustMovement = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); + int bluishDust = Dust.NewDust(dustRotation + randDustMovement, 0, 0, 206, randDustMovement.X, randDustMovement.Y, 100, default, 3f); + Main.dust[bluishDust].noGravity = true; + Main.dust[bluishDust].noLight = true; + Main.dust[bluishDust].velocity /= 4f; + Main.dust[bluishDust].velocity -= NPC.velocity; } } else @@ -614,20 +614,20 @@ namespace CalamityMod.NPCs.StormWeaver acceleration *= 1.4f; } - float num48 = velocity * 1.3f; - float num49 = velocity * 0.7f; - float num50 = NPC.velocity.Length(); - if (num50 > 0f) + float fasterVelMult = velocity * 1.3f; + float slowerVelMult = velocity * 0.7f; + float weaverSpeed = NPC.velocity.Length(); + if (weaverSpeed > 0f) { - if (num50 > num48) + if (weaverSpeed > fasterVelMult) { NPC.velocity.Normalize(); - NPC.velocity *= num48; + NPC.velocity *= fasterVelMult; } - else if (num50 < num49) + else if (weaverSpeed < slowerVelMult) { NPC.velocity.Normalize(); - NPC.velocity *= num49; + NPC.velocity *= slowerVelMult; } } @@ -660,11 +660,11 @@ namespace CalamityMod.NPCs.StormWeaver source.X += i * 30f - (boltProjectiles * 15f); Vector2 boltVelocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-BoltAngleSpread / 2 + (BoltAngleSpread * i / boltProjectiles))); boltVelocity.X = boltVelocity.X + 3f * Main.rand.NextFloat() - 1.5f; - Vector2 vector94 = Main.player[NPC.target].Center - source; + Vector2 aimDirection = Main.player[NPC.target].Center - source; float ai = Main.rand.Next(100); int type = ProjectileID.CultistBossLightningOrbArc; int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), source, boltVelocity, type, damage, 0f, Main.myPlayer, vector94.ToRotation(), ai); + Projectile.NewProjectile(NPC.GetSource_FromAI(), source, boltVelocity, type, damage, 0f, Main.myPlayer, aimDirection.ToRotation(), ai); } } } @@ -688,12 +688,12 @@ namespace CalamityMod.NPCs.StormWeaver npcCenter.Y = (int)(npcCenter.Y / 16f) * 16; targetCenterX -= npcCenter.X; targetCenterY -= npcCenter.Y; - float num193 = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY); - float num196 = Math.Abs(targetCenterX); - float num197 = Math.Abs(targetCenterY); - float num198 = velocity / num193; - targetCenterX *= num198; - targetCenterY *= num198; + float targetDistance = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY); + float absoluteTargetX = Math.Abs(targetCenterX); + float absoluteTargetY = Math.Abs(targetCenterY); + float timeToReachTarget = velocity / targetDistance; + targetCenterX *= timeToReachTarget; + targetCenterY *= timeToReachTarget; if ((NPC.velocity.X > 0f && targetCenterX > 0f) || (NPC.velocity.X < 0f && targetCenterX < 0f) || (NPC.velocity.Y > 0f && targetCenterY > 0f) || (NPC.velocity.Y < 0f && targetCenterY < 0f)) { @@ -735,7 +735,7 @@ namespace CalamityMod.NPCs.StormWeaver } else { - if (num196 > num197) + if (absoluteTargetX > absoluteTargetY) { if (NPC.velocity.X < targetCenterX) NPC.velocity.X = NPC.velocity.X + acceleration * 1.1f; @@ -827,21 +827,21 @@ namespace CalamityMod.NPCs.StormWeaver chargePhaseGateValue *= 0.5f; Texture2D texture = phase2 ? ModContent.Request("CalamityMod/NPCs/StormWeaver/StormWeaverHeadNaked").Value : TextureAssets.Npc[NPC.type].Value; - Vector2 vector = new Vector2(texture.Width / 2, texture.Height / 2); + Vector2 halfSizeTexture = new Vector2(texture.Width / 2, texture.Height / 2); float chargeTelegraphTime = 120f; float chargeTelegraphGateValue = chargePhaseGateValue - chargeTelegraphTime; - Vector2 vector2 = NPC.Center - screenPos; - vector2 -= new Vector2(texture.Width, texture.Height) * NPC.scale / 2f; - vector2 += vector * NPC.scale + new Vector2(0f, NPC.gfxOffY); - Color color = NPC.GetAlpha(drawColor); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture.Width, texture.Height) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + Color drawColorAlpha = NPC.GetAlpha(drawColor); if (calamityGlobalNPC.newAI[0] > chargeTelegraphGateValue) - color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp((calamityGlobalNPC.newAI[0] - chargeTelegraphGateValue) / chargeTelegraphTime, 0f, 1f)); + drawColorAlpha = Color.Lerp(drawColorAlpha, Color.Cyan, MathHelper.Clamp((calamityGlobalNPC.newAI[0] - chargeTelegraphGateValue) / chargeTelegraphTime, 0f, 1f)); else if (NPC.localAI[3] > 0f) - color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp(NPC.localAI[3] / 60f, 0f, 1f)); + drawColorAlpha = Color.Lerp(drawColorAlpha, Color.Cyan, MathHelper.Clamp(NPC.localAI[3] / 60f, 0f, 1f)); - spriteBatch.Draw(texture, vector2, NPC.frame, color, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, drawLocation, NPC.frame, drawColorAlpha, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -892,34 +892,34 @@ namespace CalamityMod.NPCs.StormWeaver NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 20; num621++) + for (int i = 0; i < 20; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int cosmiliteDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[cosmiliteDust].scale = 0.5f; + Main.dust[cosmiliteDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 40; num623++) + for (int j = 0; j < 40; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[cosmiliteDust2].noGravity = true; + Main.dust[cosmiliteDust2].velocity *= 5f; + cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust2].velocity *= 2f; } } } public override bool CheckDead() { - for (int num569 = 0; num569 < Main.maxNPCs; num569++) + for (int k = 0; k < Main.maxNPCs; k++) { - if (Main.npc[num569].active && (Main.npc[num569].type == ModContent.NPCType() || Main.npc[num569].type == ModContent.NPCType())) - Main.npc[num569].life = 0; + if (Main.npc[k].active && (Main.npc[k].type == ModContent.NPCType() || Main.npc[k].type == ModContent.NPCType())) + Main.npc[k].life = 0; } return true; diff --git a/NPCs/StormWeaver/StormWeaverTail.cs b/NPCs/StormWeaver/StormWeaverTail.cs index e50b446d82..3ff0f7a02e 100644 --- a/NPCs/StormWeaver/StormWeaverTail.cs +++ b/NPCs/StormWeaver/StormWeaverTail.cs @@ -178,11 +178,11 @@ namespace CalamityMod.NPCs.StormWeaver { if (NPC.alpha != 0) { - for (int num934 = 0; num934 < 2; num934++) + for (int i = 0; i < 2; i++) { - int num935 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; + int redDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 182, 0f, 0f, 100, default, 2f); + Main.dust[redDust].noGravity = true; + Main.dust[redDust].noLight = true; } } @@ -191,41 +191,41 @@ namespace CalamityMod.NPCs.StormWeaver NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; + Vector2 segmentLocation = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); + float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); + targetX = (int)(targetX / 16f) * 16; + targetY = (int)(targetY / 16f) * 16; + segmentLocation.X = (int)(segmentLocation.X / 16f) * 16; + segmentLocation.Y = (int)(segmentLocation.Y / 16f) * 16; + targetX -= segmentLocation.X; + targetY -= segmentLocation.Y; - float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); + float targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentLocation = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + targetX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - segmentLocation.X; + targetY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - segmentLocation.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2(num192, num191) + MathHelper.PiOver2; - num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = NPC.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2(targetY, targetX) + MathHelper.PiOver2; + targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); + int npcWidth = NPC.width; + targetDistance = (targetDistance - npcWidth) / targetDistance; + targetX *= targetDistance; + targetY *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetX; + NPC.position.Y = NPC.position.Y + targetY; - if (num191 < 0f) + if (targetX < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetX > 0f) NPC.spriteDirection = 1; } } @@ -255,28 +255,28 @@ namespace CalamityMod.NPCs.StormWeaver chargePhaseGateValue *= 0.5f; Texture2D texture = phase2 ? ModContent.Request("CalamityMod/NPCs/StormWeaver/StormWeaverTailNaked").Value : TextureAssets.Npc[NPC.type].Value; - Vector2 vector = new Vector2(texture.Width / 2, texture.Height / 2); + Vector2 halfSizeTexture = new Vector2(texture.Width / 2, texture.Height / 2); float chargeTelegraphTime = 120f; float chargeTelegraphGateValue = chargePhaseGateValue - chargeTelegraphTime; - Vector2 vector2 = NPC.Center - screenPos; - vector2 -= new Vector2(texture.Width, texture.Height) * NPC.scale / 2f; - vector2 += vector * NPC.scale + new Vector2(0f, NPC.gfxOffY); - Color color = NPC.GetAlpha(drawColor); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture.Width, texture.Height) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + Color drawColorAlpha = NPC.GetAlpha(drawColor); if (Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] > chargeTelegraphGateValue) - color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp((Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] - chargeTelegraphGateValue) / chargeTelegraphTime, 0f, 1f)); + drawColorAlpha = Color.Lerp(drawColorAlpha, Color.Cyan, MathHelper.Clamp((Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] - chargeTelegraphGateValue) / chargeTelegraphTime, 0f, 1f)); else if (Main.npc[(int)NPC.ai[2]].localAI[3] > 0f) - color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp(Main.npc[(int)NPC.ai[2]].localAI[3] / 60f, 0f, 1f)); + drawColorAlpha = Color.Lerp(drawColorAlpha, Color.Cyan, MathHelper.Clamp(Main.npc[(int)NPC.ai[2]].localAI[3] / 60f, 0f, 1f)); - spriteBatch.Draw(texture, vector2, NPC.frame, color, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, drawLocation, NPC.frame, drawColorAlpha, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); if (!phase2) { texture = ModContent.Request("CalamityMod/NPCs/StormWeaver/StormWeaverTailGlow").Value; Color rainbowBecauseWhyTheFuckNot = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); - Color color37 = Color.Lerp(Color.White, rainbowBecauseWhyTheFuckNot, 0.5f); - spriteBatch.Draw(texture, vector2, NPC.frame, color37, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + Color drawColorAlpha37 = Color.Lerp(Color.White, rainbowBecauseWhyTheFuckNot, 0.5f); + spriteBatch.Draw(texture, drawLocation, NPC.frame, drawColorAlpha37, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } return false; @@ -323,24 +323,24 @@ namespace CalamityMod.NPCs.StormWeaver NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 20; num621++) + for (int i = 0; i < 20; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int cosmiliteDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[cosmiliteDust].scale = 0.5f; + Main.dust[cosmiliteDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 40; num623++) + for (int j = 0; j < 40; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[cosmiliteDust2].noGravity = true; + Main.dust[cosmiliteDust2].velocity *= 5f; + cosmiliteDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[cosmiliteDust2].velocity *= 2f; } } }